zsh-workers
 help / color / mirror / code / Atom feed
From: Brice Waegeneire <brice@waegenei.re>
To: zsh-workers@zsh.org
Subject: [bug] Special parameters $PATH and $path aren't kept in sync after emulating sh
Date: Mon, 09 Nov 2020 08:27:28 +0100	[thread overview]
Message-ID: <a342172f5c6b83d74cba750b45e1dbb6@waegenei.re> (raw)

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


             reply	other threads:[~2020-11-09  7:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-09  7:27 Brice Waegeneire [this message]
2020-11-09 10:07 ` Peter Stephenson
2020-11-09 10:22 ` Daniel Shahaf

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=a342172f5c6b83d74cba750b45e1dbb6@waegenei.re \
    --to=brice@waegenei.re \
    --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).