zsh-workers
 help / color / mirror / code / Atom feed
* [bug] Special parameters $PATH and $path aren't kept in sync after emulating sh
@ 2020-11-09  7:27 Brice Waegeneire
  2020-11-09 10:07 ` Peter Stephenson
  2020-11-09 10:22 ` Daniel Shahaf
  0 siblings, 2 replies; 3+ messages in thread
From: Brice Waegeneire @ 2020-11-09  7:27 UTC (permalink / raw)
  To: zsh-workers

Hello,

Yesterday I stumbled upon a bug where setting $PATH when emulating
sh would would break the variable synchronization between the string
($PATH) and the array ($path):
--8<---------------cut here---------------start------------->8---
$ echo $PATH
/gnu/store/j1jv0f6cs18s76jbkp8h7nbh1i7rwgz2-profile/bin:/home/bricewge/.zsh/polaris/sbin:/home/bricewge/.zsh/polaris/bin:/home/bricewge/.zsh/polaris/usr/sbin:/home/bricewge/.zsh/polaris/usr/bin:/home/bricewge/misc/go/bin:/home/bricewge/.emacs.d/bin:/home/bricewge/.local/bin:/run/setuid-programs:/home/bricewge/.config/guix/current/bin:/home/bricewge/.guix-profile/bin:/home/bricewge/.guix-profile/sbin:/run/current-system/profile/bin:/run/current-system/profile/sbin
$ echo $path
/gnu/store/j1jv0f6cs18s76jbkp8h7nbh1i7rwgz2-profile/bin 
/home/bricewge/.zsh/polaris/sbin /home/bricewge/.zsh/polaris/bin 
/home/bricewge/.zsh/polaris/usr/sbin /home/bricewge/.zsh/polaris/usr/bin 
/home/bricewge/misc/go/bin /home/bricewge/.emacs.d/bin 
/home/bricewge/.local/bin /run/setuid-programs 
/home/bricewge/.config/guix/current/bin /home/bricewge/.guix-profile/bin 
/home/bricewge/.guix-profile/sbin /run/current-system/profile/bin 
/run/current-system/profile/sbin
$ cat /tmp/test.sh
unset PATH
export PATH=/foo
$ emulate sh -c 'source /tmp/test.sh'
_direnv_hook:1: command not found: direnv
$ echo $PATH
/foo
$ echo $path

$ export PATH=bar:baz
$ echo $PATH
bar:baz
$ echo $path
--8<---------------cut here---------------end--------------->8---

In effect it overwride my path instead of adding a new entry to it
when I do it from the array variable ($path) after setting it from
from the string variable ($PATH). To workaround this issue I have
found the following to work:

--8<---------------cut here---------------start------------->8---
$ tmp="$PATH"
$ unset PATH
$ export PATH="$tmp"
$ unset tmp
--8<---------------cut here---------------end--------------->8---

Cheers,
- Brice


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

end of thread, other threads:[~2020-11-09 10:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-09  7:27 [bug] Special parameters $PATH and $path aren't kept in sync after emulating sh Brice Waegeneire
2020-11-09 10:07 ` Peter Stephenson
2020-11-09 10:22 ` Daniel Shahaf

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).