Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: inconsistent behavior observed with export VAR=VAL versus VAR=VAL zsh 4.2.6



Nex Magik wrote:
> This is a strange issue, it has a workaround, but its still strange.
> 
> The very short way to see it is to try to append an expression
> with spaces in it to a variable.
>
> stimpy% Y="foo bar"
...
> stimpy% export Z=$(/bin/echo $Y):$PATH
> export: not an identifier: bar:/tmp/opt/spi/RapiDev_99a-RC1/tools/bin:/opt/gc
> c-3.2.3/bin:/opt/python-2.4.4/bin:/usr/local/bin:/bin:/usr/bin:/home/jkim/bin
> /exec/i686-Linux2:/home/jkim/bin/shell:/home/jkim/bin/shell/LOGIN/i686-Linux2
> stimpy

If this is what you're worried about, it's not a bug.  zsh applies
completely consistent rules for arguments splitting of commands,
including "export" and it's relatives, which means if you don't want
$(...) expansions to be split into words then you must tell it not to.
The standard way is to put double quotes around the expansion.  However,
if you want to change the behaviour permanently you can set the option
KSH_TYPESET.  See its documentation in the zshoptions manual.

The case without "export" in front is treated differently because the
expansion is no longer part of a command argument; the rules are
different for shell assignments, with no word splitting being done on
the right hand side of the assignment.

-- 
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/



Messages sorted by: Reverse Date, Date, Thread, Author