On Thu, Oct 30, 2008 at 8:53 AM, Christian Kellermann
<[EMAIL PROTECTED]> wrote:
> Hi,
>
> This obsoletes the last patch and incorporates the set_env suggestion
> made by Jason. It is supposed to be portable for windows as well
> as it does not use the setEnv funciton from Posix anymore.
>
> As always comments and suggestions are more than welcome.
Okay, since you've opened the door for comments :) I'll put on my
nitpickers hat and comment here.
+ let myenv =
[("HOME",cwd),("PWD",cwd),("EMAIL","tester"),("DARCSEMAIL","tester"),("PATH",(darcs_path++":"++path)),("DARCS_DONT_COLOR","1"),("DARCS_DONT_ESCAPE_ANYTHING","1")]
We don't seem to have any hard and fast rules about line length, but
this one does seem overly long. This might be a bit easier for
people:
+ let myenv = [("HOME",cwd),("PWD",cwd),("EMAIL","tester")
+ ,("DARCSEMAIL","tester"),("PATH",(darcs_path++":"++path))
+ ,("DARCS_DONT_COLOR","1")
+ ,("DARCS_DONT_ESCAPE_ANYTHING","1")]
I think we can make this a bit simpler:
+set_env :: [(String,String)] -> [(String,String)] -> [(String, String)]
+set_env [] env = env
+set_env (e:es) env = set_env es (set_env_helper e env)
+ where set_env_helper :: (String,String) -> [(String,String)] ->
[(String, String)]
+ set_env_helper (key, val) env = nubBy (\(x,_) (y,_) -> x ==
y) ((key,val):env)
The way nubBy works is that it will remove all duplicates and we
really only need to run it once the way you've structured the code.
Untested, but I think what you've written is equivalent to this:
+set_env es env = nubBy (\(x,_) (y,_) -> x == y) (es ++ env)
By the way, have you tried using your code in place of the existing
shell_harness to see that everything works?
Thanks!
Jason
_______________________________________________
darcs-users mailing list
[email protected]
http://lists.osuosl.org/mailman/listinfo/darcs-users