I see a lot of snippets that do:
SOME_LONG_VARIABLE_NAME=whatever_value
export SOME_LONG_VARIABLE_NAME
And I was wondering why people don't just do:
export SOME_LONG_VARIABLE_NAME=whatever_value
My questions:
export VAR=value
syntax? I.e., is it portable?"Is it portable" is not quite the same question as "is it POSIX". export var=value
is specified by POSIX, but it is not portable if you target the wider group of all (current and legacy) Bourne-like shells.
I don't know if there are any systems currently being sold by a vendor that don't allow this syntax. But again, "systems currently being sold" and "systems currently running" are different questions. We'd need some actual users of AIX, HP-UX, Solaris, etc. to stop by and tell us...
You may find a script using the two-step "assign then export" for any of these reasons:
/bin/sh
expr
for arithmetic, and the mystical construction ${1+"$@"}
may appear.