NAME
export — set
export attribute for variables
SYNOPSIS
export name[=word]. . .
DESCRIPTION
export -p The shell shall give the
export attribute to the variables corresponding to
the specified names, which shall cause them to be in the environment of
subsequently executed commands. When −p is specified,
export shall write to the standard output the names
and values of all exported variables, in the following format:
" export %s=%s\n", <name>,
<value> The shell shall format the output, including the proper use of
quoting, so that it is suitable for re-input to the shell as commands that
achieve the same exporting results. The export
special built-in shall conform to the utility argument syntax guidelines
described in 2.10.2.
EXIT STATUS
Zero.
RATIONALE
When no arguments are given, the results are unspecified. Some
historical shells use the no-argument case as the functional equivalent of
what is required here with −p. This feature was left unspecified
because it is not existing practice in all shells and some scripts may rely
on the now-unspecified results on their implementations. Attempts to specify
the −p output as the default case were unsuccessful in achieving
consensus. The −p option was added to allow portable access to the
values that can be saved and then later restored using, for instance, a dot
script. Examples: Export PWD and HOME
variables: export PWD
HOME Set and export the
PATH variable:
export PATH
=/local/bin:$ PATH Save and restore all exported
variables: export -p > temp-file unset a lot of
variables . . . processing . temp-file