Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATH variable case-insensitive?
- X-seq: zsh-users 19824
- From: ZyX <kp-pav@xxxxxxxxx>
- To: Koch <omgoch@xxxxxxxxx>, "zsh-users@xxxxxxx" <zsh-users@xxxxxxx>
- Subject: Re: PATH variable case-insensitive?
- Date: Thu, 05 Feb 2015 19:38:36 +0300
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1423154316; bh=1z/GZw+w9xLqsXiJk/G6oCyj9OBxOTSkVrajTw6YpfE=; h=From:To:In-Reply-To:References:Subject:Date; b=ei0JqYGHVt0h8y1uXnXytpbKXeoxMoga3TiiMxcwjLPOIzVgBpnc9HSXUQgXTJF57 Zh3lIgIogoH4WN6+OBGOu23aM5EmQ+m9eoBM91xlexekj2KHEubgfsGlb1eiq8WkBN Zl9jbD+ZQFGCG75sZ7L95l9vS84KZxOQEc6oXFXo=
- In-reply-to: <54D39290.9020702@gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <54D39290.9020702@gmail.com>
05.02.2015, 19:10, "Koch" <omgoch@xxxxxxxxx>:
> 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.)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author