zsh-workers
 help / color / mirror / code / Atom feed
From: "Daniel Shahaf" <d.s@daniel.shahaf.name>
To: "Brice Waegeneire" <brice@waegenei.re>, zsh-workers@zsh.org
Subject: Re: [bug] Special parameters $PATH and $path aren't kept in sync after emulating sh
Date: Mon, 09 Nov 2020 10:22:33 +0000	[thread overview]
Message-ID: <f6490943-7872-4510-9893-c91f5e6a532f@www.fastmail.com> (raw)
In-Reply-To: <a342172f5c6b83d74cba750b45e1dbb6@waegenei.re>

Brice Waegeneire wrote on Mon, 09 Nov 2020 07:27 +00:00:
> $ 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

Your code is not expected to append an entry to $PATH.  To do that,
you'd want to do «PATH="${PATH}:/new/entry"» (plus or minus the «export»
keyword in front).

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

This doesn't append either.  (Also, a signal might come in whilst PATH
is undefined in the environment.)


      parent reply	other threads:[~2020-11-09 10:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-09  7:27 Brice Waegeneire
2020-11-09 10:07 ` Peter Stephenson
2020-11-09 10:22 ` Daniel Shahaf [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=f6490943-7872-4510-9893-c91f5e6a532f@www.fastmail.com \
    --to=d.s@daniel.shahaf.name \
    --cc=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).