From: Daniel Hahler <dhahler@gmail.com>
To: Zsh Hackers' List <zsh-workers@zsh.org>
Subject: POSIX_ARGZERO: not POSIX compliant in sourced script?!
Date: Thu, 11 Sep 2014 22:07:28 +0200 [thread overview]
Message-ID: <54120100.7030803@thequod.de> (raw)
The option POSIX_ARGZERO (added in 19f3161 for zsh 5.0.5) does not appear to be fully POSIX compliant when being used in a sourced file.
I don't know how POSIX defines it, but at least dash (and bash) behave differently.
Given the following files:
cat > test.sh <<EOF
#!/bin/sh
. ./test_sourced.sh
EOF
cat > test_sourced.sh <<EOF
echo $0
if [ -n "$ZSH_VERSION" ]; then
setopt posixargzero
echo $0
fi
EOF
The second $0 with zsh should be "test.sh", and not "zsh":
% zsh test.sh
test_sourced.sh
zsh
% sh test.sh
test.sh
test.sh
% ./test.sh
./test.sh
The same applies when using zsh in the shebang line, and executing the script (I was under the impression that this would work better, but it does not):
cat > test.sh <<EOF
#!/usr/bin/env zsh
. ./test_sourced.sh
EOF
% ./test.sh
test_sourced.sh
zsh
Regards,
Daniel.
next reply other threads:[~2014-09-11 20:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-11 20:07 Daniel Hahler [this message]
2014-09-12 3:59 ` Bart Schaefer
2014-09-14 1:03 ` Daniel Hahler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=54120100.7030803@thequod.de \
--to=dhahler@gmail.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).