Re: shell



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
.



Relevant Pages

  • Re: shell
    ... The output from "command -p getconf PATH" can vary depending on ... whether you are running it in a conforming environment or not ... a PATH set for SUSv3 it changes it to one set for SUSv2. ...
    (comp.unix.questions)
  • Re: shell
    ... command -p getconf PATH' ... As far as the standard is concerned, ... if they are executed in a "conforming environment" (which includes ...
    (comp.unix.questions)
  • Re: shell
    ... The output from "command -p getconf PATH" can vary depending on ... whether you are running it in a conforming environment or not ... you only get the SUSv3 PATH out if ...
    (comp.unix.questions)
  • Re: shell
    ... command -p getconf PATH' ... As far as the standard is concerned, ... Utilities are only required to behave as described in the standard ... if they are executed in a "conforming environment" (which includes ...
    (comp.unix.questions)
  • Re: Read command and trailing spaces
    ... >> shell (isn't it still on Solaris?). ... > standards-compliant environment should set their PATH to something ... > beginning with $(getconf PATH), thus ensuring that they always get ... -bash: getconf: command not found ...
    (comp.unix.shell)