dash.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephane Chazelas <stephane.chazelas@gmail.com>
To: dash@vger.kernel.org
Subject: Re: % in $PATH
Date: Mon, 10 Nov 2014 21:30:48 +0000	[thread overview]
Message-ID: <20141110213048.GA3938@chaz.gmail.com> (raw)
In-Reply-To: <20141110132002.GA8372@gondor.apana.org.au>

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)

-- 
Stephane


  reply	other threads:[~2014-11-10 21:35 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 [this message]
2014-11-10 21:59     ` Guido Berhoerster
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=20141110213048.GA3938@chaz.gmail.com \
    --to=stephane.chazelas@gmail.com \
    --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;
as well as URLs for NNTP newsgroup(s).