Re: shell
- From: Stephane Chazelas <stephane_chazelas@xxxxxxxx>
- Date: 23 Mar 2006 16:59:34 GMT
On Thu, 23 Mar 2006 14:39:32 +0000, Geoff Clare wrote:
Stephane Chazelas <stephane_chazelas@xxxxxxxx> wrote, on Wed, 22 Mar 2006:[...]
# ensure `Unix' utilities
PATH=$(command -p getconf PATH; :):$PATH
export PATH
Unfortunately this method has a chicken-and-egg problem.
The output from "command -p getconf PATH" can vary depending on
whether you are running it in a conforming environment or not
(or in which conforming environment, if the system supports
multiple versions of the standard concurrently).
For example on Solaris 10, you only get the SUSv3 PATH out if
you already have PATH set to find the SUSv3 utilities before
the SUSv2 ones:
$ type sh
sh is a tracked alias for /usr/xpg4/bin/sh
$ sh -c 'PATH=/bin; command -p getconf PATH'
/usr/xpg4/bin:/usr/ccs/bin:/usr/bin:/opt/SUNWspro/bin
$ sh -c 'PATH=/usr/xpg6/bin:/usr/xpg4/bin:/bin; command -p getconf PATH'
/usr/xpg6/bin:/usr/xpg4/bin:/usr/ccs/bin:/usr/bin:/opt/SUNWspro/bin
Thanks for pointing this out.
What would/should:
command -p env -i /usr/xpg4/bin/sh -c 'command -p getconf PATH'
return then?
and
command -p env -i PATH=/undef /usr/xpg4/bin/sh -c '
command -p getconf PATH'
What about:
#! /bin/sh -
[ "x$FIND_SH_HACK" = "x$$" ] ||
exec /usr/bin/env \
PATH="`/usr/bin/env -i /usr/bin/getconf PATH`:$PATH" \
FIND_SH_HACK="$$" POSIXLY_CORRECT=1 _POSIX2_VERSION=200112 \
UNIX95=1 UNIX98=1 sh - "$0" ${1+"$@"}
Is it likely to maximise the SUSv<n> conformance of the sh and
utilities on a maximum number of SUSv<n> conformant systems?
--
Stephane
.
- Follow-Ups:
- Re: shell
- From: Geoff Clare
- Re: shell
- Prev by Date: Re: shell
- Next by Date: automatic mount on system startup
- Previous by thread: Re: shell
- Next by thread: Re: shell
- Index(es):
Relevant Pages
|