Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [bug] Special parameters $PATH and $path aren't kept in sync after emulating sh
- X-seq: zsh-workers 47529
- From: "Daniel Shahaf" <d.s@xxxxxxxxxxxxxxxxxx>
- To: "Brice Waegeneire" <brice@xxxxxxxxxxx>, zsh-workers@xxxxxxx
- 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
- Archived-at: <https://zsh.org/workers/47529>
- Archived-at: <http://www.zsh.org/sympa/arcsearch_id/zsh-workers/2020-11/f6490943-7872-4510-9893-c91f5e6a532f%40www.fastmail.com>
- Authentication-results: zsh.org; iprev=pass (wout1-smtp.messagingengine.com) smtp.remote-ip=64.147.123.24; dkim=pass header.d=daniel.shahaf.name header.s=fm1 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm1 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=mime-version:message-id:in-reply-to :references:date:from:to:subject:content-type :content-transfer-encoding; s=fm1; bh=wdede2fVYQdNzxAfqTz457LTgm 5GdLgTn3/hPJrqmYc=; b=pkc0MuDkjSlqdNxeHB8XyZNDxddPHug0JtfGbdczid X73wDA0nu6rCNfA+d8P9sWcA1UiKRDQjpAaX2yjPXzQr1WY2jHGVp6fbHN9RfjrS mUzUgNK40bz8cAOuY0oyQw+SD4U3Ze1BEF8AYhPLKmIn3KbekE8GN5hTAo/zq7Ea svNO7n+w9O7SQAz638zVj6gq7UUS/0lRyzUfk47oGBZQyop0dFLe0OHr1WEYoyTh zkamMYlzyyQwfPmk/QrcoWKv2gmsUA7sZNE6GNOBbfz7ejcFHVcmK2pVS1SpIja/ VJcvtwqN9xF+kVLw6WtkqgnRszUTem2DU2iO/2kBKlYA==
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=wdede2fVYQdNzxAfqTz457LTgm5GdLgTn3/hPJrqm Yc=; b=EzWqJclbakX5o5r4e95RcSC9KaWdBV4HcxrumZuT8+9l3NkQlEnfYb/4K 10bqej+gLKAaZuPwZMO+pxxzZmIy8XAVz0xshjEsI+SJrZhActQMbmzgF/bTjL99 q1ZT6bkZZF0SU1YoVg7xcBmT00FcKk3jxfQV3PphFoUBD/uRBM/SJyeve9Gp6pMF r3w+VrrvvT9FHZOYtz4pX0HaqmLJKGcAGAlB/VHpJZkjyG7BYd/eDszkGBG+H8Y8 F6iTtGT8IPepPZDSN5mYxjcNbcWth2gjOzHspbWXsDFHidxRDiGQxGmIkAStAwuD Ud8HT005F+AJh8sLNrkEKTuSiaQUQ==
- In-reply-to: <a342172f5c6b83d74cba750b45e1dbb6@waegenei.re>
- List-archive: <http://www.zsh.org/sympa/arc/zsh-workers>
- List-help: <mailto:sympa@zsh.org?subject=help>
- List-id: <zsh-workers.zsh.org>
- List-owner: <mailto:zsh-workers-request@zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-subscribe: <mailto:sympa@zsh.org?subject=subscribe%20zsh-workers>
- List-unsubscribe: <mailto:sympa@zsh.org?subject=unsubscribe%20zsh-workers>
- References: <a342172f5c6b83d74cba750b45e1dbb6@waegenei.re>
- Sender: zsh-workers-request@xxxxxxx
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.)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author