DASH Shell discussions
 help / color / mirror / Atom feed
From: Guido Berhoerster <gber@opensuse.org>
To: dash@vger.kernel.org
Subject: Re: % in $PATH
Date: Mon, 10 Nov 2014 22:59:38 +0100	[thread overview]
Message-ID: <20141110215938.GA25437@hal.lan> (raw)
In-Reply-To: <20141110213048.GA3938@chaz.gmail.com>

* Stephane Chazelas <stephane.chazelas@gmail.com> [2014-11-10 22:35]:
> 2014-11-10 21:20:02 +0800, Herbert Xu:
> > On Wed, Nov 05, 2014 at 11:59:47AM +0000, Stephane Chazelas wrote:
> > > Hello,
> > > 
> > > ash/dash have a nice feature that allows to have:
> > > 
> > > PATH=/bin:%builtin:/usr/bin:/some/dir%func:/sbin
> > > 
> > > To have commands in /bin take precedence over builtins and
> > > files in /some/dir being looked up for autoloaded functions (a
> > > bit like FPATH in ksh/zsh).
> > > 
> > > That's nice but the way it is implemented, that means that %
> > > characters in $PATH cause problems. See for instance:
> > > 
> > > http://unix.stackexchange.com/questions/126955/percent-in-path-environment-variable
> > 
> > I'm inclined to just kill this feature, or at least make it a
> > configuration option that's disabled by default.
> [...]
> 
> Though I'd agree there's little chance of many people using it as
> the documentation about it has been removed in dash, I don't
> think there's any harm in leaving it in but implemented the way
> I suggest.
> 
> It's useful as an equivalent to bash's exported functions (and
> is a better/safer approach IMO) as an instrumentation tool.
> 
> Example: redefine "echo" as a Unix conformant one before running
> something that expects a Unix conformant "echo":
> 
> $ printf '%s\n' 'echo() { local IFS=" "; printf "%b\n" "$*"; }' > echo
> $ PATH=$PWD%func:%builtins:$PATH dash -c 'echo "-n\c"; echo x'
> -nx
> 
> I don't see the point in keeping it if it's to make it disabled
> by default though (unless we add an equivalent of BASHOPTS which
> can be used to turn it on via the environment)

A much nicer solution would be to do something similar to the
original Korn shell and assign additional builtins a virtual
path which can be freely assigned in PATH and with which they can
be explicitly called. No more "%" in PATH and the feature can
be retained.
-- 
Guido Berhoerster

  reply	other threads:[~2014-11-10 22:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-05 11:59 % in $PATH Stephane Chazelas
2014-11-10 13:20 ` Herbert Xu
2014-11-10 21:30   ` Stephane Chazelas
2014-11-10 21:59     ` Guido Berhoerster [this message]
2014-11-10 22:23       ` Stephane Chazelas
2014-11-10 22:39         ` Guido Berhoerster
2014-11-10 23:15           ` Stephane Chazelas

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=20141110215938.GA25437@hal.lan \
    --to=gber@opensuse.org \
    --cc=dash@vger.kernel.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox