Re: % in $PATH

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* Stephane Chazelas <stephane.chazelas@xxxxxxxxx> [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
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux