Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: zsh handling of non-standard if-evaluations

On Wed, Jan 31, 2007 at 07:51:24AM -0800, Bart Schaefer wrote:
> On Jan 29, 12:41am, Stephane Chazelas wrote:
> }
> } > > load-sh-profile() {
> } > >   emulate -L sh
> } > >   . /etc/profile
> } > > }
> } > 
> } > No: any "typeset" commands would create parameters that are local to the
> } > load-sh-profile function; that may have undesired consequences.
> } 
> } typeset is not sh, so there wouldn't be any in /etc/profile.
> By that logic, [ "$VAR" == "VAL" ] is not sh either, so the original
> problem should not exist.  If there is one bash-ism in /etc/profile,
> then one might expect that there are others.

That's true. But on the other hand, it's often better not to
accomodate for bugs especially when they are easy to fix, as it
helps detecting them.

Using [ ... == ... ] or typeset in /etc/profile is a bug.
/etc/profile is meant to be read by all the POSIX conformant
shells (and Bourne shells AAMOF) so has to be Bourne compatible
(not only POSIX) (except maybe if you can guarantee that the
Bourne shell won't ever be installed on your system by any of
your users).

On the other hand I think both our solutions fail if
/etc/profile contains something like 

set -u
set -C

which are valid Bourne syntax.

In anycase, there's no much point using typeset or set or
non-Bourne syntax in /etc/profile (though you sometimes find
things like export var=value which is not Bourne and interpreted
differently by bash/ksh/pdksh/zsh).


Messages sorted by: Reverse Date, Date, Thread, Author