zsh-users
 help / color / mirror / code / Atom feed
From: ZyX <kp-pav@yandex.ru>
To: Koch <omgoch@gmail.com>, "zsh-users@zsh.org" <zsh-users@zsh.org>
Subject: Re: PATH variable case-insensitive?
Date: Thu, 05 Feb 2015 19:38:36 +0300	[thread overview]
Message-ID: <4875411423154316@web22m.yandex.ru> (raw)
In-Reply-To: <54D39290.9020702@gmail.com>

05.02.2015, 19:10, "Koch" <omgoch@gmail.com>:
> Using zsh 5.0.2 (x86_64-pc-linux-gnu) with the following file contents in
> ./test.zsh:
>
> PATH=bar
> path=omg
> echo $PATH
>
> and running zsh ./test.zsh outputs:
> omg
>
> Is this a bug? It's certainly not my intention to have this meaning attached to
> this program, since it goes against POSIX.

If you want  POSIX emulation in zsh, do use either `emulate -L sh` at the top of the script or run it with symlink named sh (i.e. rather use `sh` as the last component of the program name*)`.

Strict POSIX compatibility was never a goal of zsh in its “native” mode. For interactive uses this feature is rather convenient. In scripts I myself have run several times into the effective inability to use `path` variable in e.g. `for path in foo/*` until learned this thing though.

* Like this with execve, see the beginning of execve argument:

        % echo 'int main(int argc, char **argv, char **environ) { execve("/bin/zsh", (const char *[]) {"/bin/sh", "-c", "echo path:$path PATH:$PATH", 0}, environ); }' | tcc -run -
        path: PATH:/bin:/usr/bin:/usr/ucb:/usr/local/bin
        % echo 'int main(int argc, char **argv, char **environ) { execve("/bin/zsh", (const char *[]) {"/bin/zsh", "-c", "echo path:$path PATH:$PATH", 0}, environ); }' | tcc -run 
        path:/bin /usr/bin /usr/ucb /usr/local/bin PATH:/bin:/usr/bin:/usr/ucb:/usr/local/bin

  (It actually appears that tcc does not support 3-argument form of main() (this is not my actual $PATH setting). But the point can be seen in any case since shell is able to get $PATH setting somewhere. Use `gcc -xc - && ./a.out && rm ./a.out` in place of `tcc -run -` to see your actual $PATH setting.)


      parent reply	other threads:[~2015-02-05 16:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-05 15:56 Koch
2015-02-05 16:18 ` Kurtis Rader
2015-02-05 16:38 ` Peter Stephenson
2015-02-05 16:54   ` Peter Stephenson
2015-02-05 16:38 ` ZyX [this message]

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=4875411423154316@web22m.yandex.ru \
    --to=kp-pav@yandex.ru \
    --cc=omgoch@gmail.com \
    --cc=zsh-users@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).