Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
'emulate sh -c' and $0
- X-seq: zsh-workers 32625
- From: Richard Hansen <rhansen@xxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: 'emulate sh -c' and $0
- Date: Thu, 29 May 2014 19:04:45 -0400
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
Hi all,
I just encountered what I think is a bug in Zsh 5.0.5. The following
command:
zsh -c '
emulate sh -c "echo \"\$0\""
bar() { emulate sh -c "echo \"\$0\""; }
bar
' foo arg1
produces the following output:
foo
bar
I expected it to produce:
foo
foo
This is relevant when sourcing a file containing (POSIX) sh code that
might examine $0 (e.g., for logging or to 'exec "$0" "$@"' after
exporting/unsetting environment variables).
Perhaps Zsh should save the original value of $0 somewhere and restore
it when entering sh emulation mode.
Thanks,
Richard
Messages sorted by:
Reverse Date,
Date,
Thread,
Author