bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: initialisation bash variables


From: Stephane CHAZELAS
Subject: Re: initialisation bash variables
Date: Wed, 28 Mar 2012 18:26:01 -0000
User-agent: slrn/pre1.0.0-18 (Linux)

2011-08-18, 12:44(+02), Patrick:
[...]
>> $ VAR=foo sh -c 'VAR=bar; env' | grep VAR
>> VAR=foo
>> $ VAR=foo sh -c 'VAR=bar; export VAR; env' | grep VAR
>> VAR=bar
> Interresting! I do not have the bourne shell installed. Bash tries to 
> mimic it when called as "sh", but it does not produce the "correct" 
> result for your first example. Not that I would mind about that though. 
> Busybox btw. also yields "VAR=bar". Phew... Dash as well. There is no 
> "sh" package in the ubuntu repos. Google also has no quick answer. What 
> kind of "sh" are you actually using if I may ask ?

Yes, that was the behavior of the Bourne shell, it was changed
by the Korn shell and every other Bourne-like shell followed,
and the new behavior is now specified by POSIX.

The Bourne shell is a shell written by Steve Bourne in the late
seventies and is the ancestor of all of nowadays "Bourne-like
shells" (ash, dash, ksh88, ksh93, pdksh, posh, mksh, bash,
zsh...). There have been many variants of the Bourne shell with
modifications added by the various Unix vendors.

It's still found for backward compatibility in some commercial
Unices. Nowaday, "sh" refers to an implementation or another of
a shell that is able to interpret a POSIX script as specified
(just to avoid saying a "POSIX shell" which would be too much of
a shortcut). The Bourne shell is not one of them (for the reason
above and many others). The code of the Bourne shell was
released as opensource  /recently/ as part of OpenSolaris, so
you can now find ports of it to Linux (See heirloom-sh for
instance). You can also run the Bourne shell from UnixV7 (the OS
where it was first released in 1979) in a PDP11 emulator, and
you'll notice a few differences between the two.

See 
http://www.in-ulm.de/~mascheck/bourne/
for a reference on the Bourne shell.

-- 
Stephane


reply via email to

[Prev in Thread] Current Thread [Next in Thread]