I have picked up -- probably on Usenet in the mid-1990s (!) -- that the construct
export var=value
is a Bashism, and that the portable expression is
var=value
export var
I have been advocating this for years, but recently, somebody challenged me about it, and I really cannot find any documentation to back up what used to be a solid belief of mine.
Googling for "export: command not found"
does not seem to bring up any cases where somebody actually had this problem, so even if it's genuine, I guess it's not very common.
(The hits I get seem to be newbies who copy/pasted punctuation, and ended up with 'export: command not found
or some such, or trying to use export
with sudo
; and newbie csh
users trying to use Bourne shell syntax.)
I can certainly tell that it works on OS X, and on various Linux distros, including the ones where sh
is dash
.
sh$ export var=value
sh$ echo "$var"
value
sh$ sh -c 'echo "$var"' # see that it really is exported
value
In today's world, is it safe to say that export var=value
is safe to use?
I'd like to understand what the consequences are. If it's not portable to v7 "Bourne classic", that's hardly more than trivia. If there are production systems where the shell really cannot cope with this syntax, that would be useful to know.
busybox
come with its own minimal shell? (I am not in a position to try either right this second.)