Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 11 Mar 1997 13:36:34 +0100
From:      j@uriah.heep.sax.de (J Wunsch)
To:        syssgm@devetir.qld.gov.au (Stephen McKay)
Cc:        freebsd-bugs@freefall.freebsd.org
Subject:   Re: bin/2934: sh(1) has problems with $ENV
Message-ID:  <19970311133634.NF15956@uriah.heep.sax.de>
In-Reply-To: <199703110940.BAA09613@freefall.freebsd.org>; from Stephen McKay on Mar 11, 1997 01:40:03 -0800
References:  <199703110940.BAA09613@freefall.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
As Stephen McKay wrote:

>  Well my view on this is that $ENV processing in /bin/sh is a dumbass idea,
>  and should be expunged immediately.  Is it mandated by POSIX?  Then send
>  them a rude letter and delete it anyway.

Sorry, but that's not a very constructive discussion now.

Arguably, $ENV is a crock.  I wonder why David Korn has chosen such a
crock, by a time where things like .cshrc were already widely in use,
and known to work well.

OTOH, throwing away a crock in order to just invent another
incompatible idea is not better either.  The shell is in need of a
mechanism that allows to source some stuff (like aliases) on each
invokation, not just for a login shell only as .profile does.  The
best we can do is to stick with the Korn shell way, in order to avoid
even more diversity than there is already.  Yes, ENV is Posix, yes,
the Posix people were stupid enough to standardize the Korn shell,
with all its idiosyncrasies.

>  Is $ENV there to scare off the last few people who use the shell for scripts?
>  It's a perl plot, right?  "We will trick those foolish sh users!  Ha! Ha!
>  Just look at what we can do to them now:"
>  
>  $ cat silly-bits
>  echo "Hello from ENV processing"
>  echo "This is where people put stupid things that break system scripts"
>  ls() { /bin/ls -sF $*; }

Btw., you should do something here that's already in general use for
csh users: make something like aliases only in effect for interactive
shells.  In csh, it's

	if ($?prompt) then
		...
	endif

since $prompt is (by definition) only set in an interactive shell.  The
equivalent in sh is:

	case "$-" in
	*i*)
		# shell is interactive, do aliases etc here
		alias ls="ls -sF"
		;;
	esac

>  $
>  $ export ENV=`pwd`/silly-bits
>  $
>  $ cat serious-prog
>  #! /bin/sh

Use #!/bin/sh -p, and your sorrows are away.  The Posix folks were
apparently even more stupid by not standardizing this Kornshellism
(but we have it now), as well as they didn't standardize the #!
feature at all.

>  Ouch!  What can you depend on any more, even with PATH set?  It's become
>  that much harder to write shell scripts.

Only if you are writing Posix-unportable scripts that rely on the
(undocumented) behaviour of the ``traditional'' Bourne shell (whatever
version you might attribute this to).  The least Posix gave us is a
definition of what the shell should do, and what should it not do.

>  Oh, and while you're deleting $ENV processing, I'm pretty unhappy with /bin/sh
>  being bloated with history editing.  I'll be testing -DNO_HISTORY, and will
>  put that in my /etc/make.conf if it works.

I understand your sentiments, but did you recognize that it mainly
only bloats the file itself but not the actual memory usage if your
shell is linked with history editing, but you never use it?  I wonder
if these 100 KB of saved filesystem space are really worth the
hassles.  (The remainder should be done well enough by demand-paging.
You can observe this if you load a shell from a floppy: turn on
history editing, and it will start chewing on the floppy again.)

-- 
cheers, J"org

joerg_wunsch@uriah.heep.sax.de -- http://www.sax.de/~joerg/ -- NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19970311133634.NF15956>