[Nix-dev] slightly off topic: bash/sh quoting/arguments

2012-04-02 Thread Mathijs Kwik
Hi all, args1=one two args2=three four $ mycommand one two three four You passed 4 arguments - one - two - three - fout $ mycommand $args1 $args2 You passed 2 arguments - one two - three four How can I pass args1 and args2 to mycommand as 4 arguments? I think in bash, this script might get run

Re: [Nix-dev] slightly off topic: bash/sh quoting/arguments

2012-04-02 Thread Eelco Dolstra
Hi, On 02/04/12 23:28, Mathijs Kwik wrote: args1=one two args2=three four ... $ mycommand $args1 $args2 You passed 2 arguments Eh? Unless you have set $IFS to a non-standard value, $args1 and $args2 will be split into four arguments. -- Eelco Dolstra |

Re: [Nix-dev] slightly off topic: bash/sh quoting/arguments

2012-04-02 Thread Marc Weber
Yeah, that's OT. on irc there is #bash which should be the source of knowledge to gather some keywords. Nevertheless here is your solution First get a test script (copy paste into your bash shell): args1=one two args2=three four sh -c 'for x in $@; do echo arg: $x; done' -- $args1 $args2 it

Re: [Nix-dev] slightly off topic: bash/sh quoting/arguments

2012-04-02 Thread Mathijs Kwik
On Mon, Apr 2, 2012 at 11:33 PM, Eelco Dolstra eelco.dols...@logicblox.com wrote: Hi, On 02/04/12 23:28, Mathijs Kwik wrote: args1=one two args2=three four ... $ mycommand $args1 $args2 You passed 2 arguments Eh?  Unless you have set $IFS to a non-standard value, $args1 and $args2 will

Re: [Nix-dev] slightly off topic: bash/sh quoting/arguments

2012-04-02 Thread Mathijs Kwik
On Mon, Apr 2, 2012 at 11:42 PM, Marc Weber marco-owe...@gmx.de wrote: Yeah, that's OT. on irc there is #bash which should be the source of knowledge to gather some keywords. Nevertheless here is your solution First get a test script (copy paste into your bash shell): args1=one two

Re: [Nix-dev] slightly off topic: bash/sh quoting/arguments

2012-04-02 Thread Michael Raskin
args1=one two args2=three four ... $ mycommand $args1 $args2 You passed 2 arguments Eh?  Unless you have set $IFS to a non-standard value, $args1 and $args2 will be split into four arguments. Ah, my bad. It seems bash and sh work fine, my zsh seems to be the problem. I blindly assumed

Re: [Nix-dev] slightly off topic: bash/sh quoting/arguments

2012-04-02 Thread Michael Raskin
Ah, that's it then. it seems ${=foo} doesn't do the trick in zsh either though, but I don't care. It's not the target, I just tried it there. In general use a scripting language (ruby/python/perl/tcl/..) for everything more complicated. bash starts to be a bottle neck very soon (example is