Re: shell



Stephane Chazelas <stephane_chazelas@xxxxxxxx> wrote, on Fri, 24 Mar 2006:

On Fri, 24 Mar 2006 14:07:56 +0000, Geoff Clare wrote:
[...]
command -p env -i PATH=/undef /usr/xpg4/bin/sh -c '
command -p getconf PATH'

As far as the standard is concerned, the behaviour is undefined.
Utilities are only required to behave as described in the standard
if they are executed in a "conforming environment" (which includes
which environment variables are set among other things).

So, how do you force a XPG4 or XPG6 "conforming environment" in
a portable way? (based on a "case `uname`"?).

There is no portable way to set up a conforming environment from
a non-conforming one. (Nor could there ever be, if you think about
it, as the standards cannot place any constraint on the behaviour
of non-conforming environments).

The suggested method (not yet implemented) in the link you
refered to:

env -i $(getconf V6_ENV) $(getconf PATH) command

(I suppose they mean
env -i -- $(getconf V6_ENV) "PATH=$(getconf PATH)" command

Environment variable names can't begin with dash, so the "--" is
unnecessary. You are right about PATH.

Doesn't seem to work. First, there are issues with the current
value of IFS and globbing, and the second getconf will not be
run in a "conforming environment", so PATH may not be correct,
and it clears my environment, that's not what I want.

This is not a way of setting up a conforming environment, it is
a way of ensuring that enough of a current conforming environment
is inherited by commands started with "env -i" for them also to
be executing in a conforming environment.

(Point taken about IFS and globbing.)

--
Geoff Clare <netnews@xxxxxxxxxxxxx>

.



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 ... you already have PATH set to find the SUSv3 utilities before ...
    (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 ... 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, ... 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: 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)

Quantcast