Re: shell
- From: Stephane Chazelas <stephane_chazelas@xxxxxxxx>
- Date: 27 Mar 2006 13:49:43 GMT
On Mon, 27 Mar 2006 13:54:09 +0100, Geoff Clare wrote:
[...]
[...]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).
But Solaris is meant to be conformant, isn't it? On startup, it
doesn't provide you with a conforming environment. So there has
to be a way to switch to that environment, otherwise, the
standard is rather pointless.
With Solaris 7, according to the standards(5) man page, it looks
like you only need to make sure /usr/xpg4/bin is before the
other ones to be SUSv2 conformant? What about Solaris 10, then.
So, if I want a SUSv2 conformant toolchest to interpret my
script written in a SUSv2 conformant syntax, practically, what
should I write:
#! /bin/sh -
if [ "$$" != "$FIND_SH_ACK" ]; then
FIND_SH_ACK=$$ export FIND_SH_ACK
case `uname` in
SunOS)
PATH=/usr/xpg4/bin/sh:$PATH
export PATH
exec /usr/xpg4/bin/sh - "$0" ${1+"$@"}
;;
Linux)
export POSIXLY_CORRECT=1 _POSIX2_VERSION=199210
;;
Tru64) ???;;
*) ???;;
esac
fi
unset FIND_SH_ACK
?
As far as the standard is concerned, the behaviour is undefined.The suggested method (not yet implemented) in the link you
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).
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.
On which system can't environment variable names begin with "-"?
I agree it's very unlikely that getconf will return a variable
whose name doesn't only consist of uppercase
letters, digits, and the '_' (cf
http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap08.html)
but the "--" can't harm there anyway.
[...]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.
OK, thanks.
--
Stephane
.
- Follow-Ups:
- Re: shell
- From: Geoff Clare
- Re: shell
- References:
- Prev by Date: Re: cron + cygwin
- Next by Date: Re: Daylight Savings? indiana
- Previous by thread: Re: shell
- Next by thread: Re: shell
- Index(es):