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

Re: "var=value exec > file" ignores the assignment?

On Apr 8, 12:51am, Jun T. wrote:
} If 'exec' has no command arg but has both parameter assignment
} and redirection, the assignment seems to be ignored.

Hm.  This probably comes down to the behavior of "special" built-ins
which are supposed to retain the results of environment assignments.
It's possible (likely?) your patch should add a POSIX_BUILTINS test.

I'm not sure why we skip the XTRACE when nullexec == 1.  If your patch
is otherwise correct, there doesn't seem to be any other reason to
distinguish the 1 and 2 cases.

} Either with or without the patch, and either POSIX_BUILTINS is
} set or unset, the following outputs "x = 1" (/bin/sh outputs
} "x = 0"). But I don't know whether this need be fixed (or how
} to fix it if it need be).
} x=0
} true | x=1 exec | true
} echo "x = $x"

This is a curious one.  Normally zsh would fork off "x=1 exec" so the
assignment would only affect a subshell, but that is apparently short-
circuited because the subshell has nothing else to do.  This:

true | x=1 | true

also assigns so $x == 1 whereas this:

true | { x=1 } | true

which should otherwise be equivalent, leaves $x == 0.  Anyway the point
is I don't think the presence of "exec" has anything to do with this
particular behavior.

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