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

Michael Raskin 7c6f434c at mail.ru
Tue Apr 3 06:22:50 CEST 2012


>>> 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 zsh was mostly sh compatible

Other than ${=}, there is also 
set -o shwordsplit || true;

It should work in zsh and fail harmlessly in sh/bash.





More information about the nix-dev mailing list