zsh-workers
 help / color / mirror / code / Atom feed
* 'emulate sh -c' and $0
@ 2014-05-29 23:04 Richard Hansen
  2014-05-30  3:45 ` Bart Schaefer
  0 siblings, 1 reply; 17+ messages in thread
From: Richard Hansen @ 2014-05-29 23:04 UTC (permalink / raw)
  To: zsh-workers

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


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2014-06-04  1:24 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-29 23:04 'emulate sh -c' and $0 Richard Hansen
2014-05-30  3:45 ` Bart Schaefer
2014-05-30  8:49   ` Richard Hansen
2014-05-30 17:00     ` Bart Schaefer
2014-05-30 21:14       ` Richard Hansen
2014-05-31  5:13         ` Bart Schaefer
2014-05-31 23:47           ` Bart Schaefer
2014-06-03 20:15           ` Richard Hansen
2014-06-03 20:26             ` Peter Stephenson
2014-06-03 21:10               ` Bart Schaefer
2014-06-03 23:35                 ` Richard Hansen
2014-06-04  0:09                   ` Bart Schaefer
2014-06-03 21:21             ` Bart Schaefer
2014-06-03 22:54               ` Richard Hansen
2014-06-04  0:03                 ` Bart Schaefer
2014-06-04  1:10                   ` Bart Schaefer
2014-06-04  1:23                 ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).