nerdexam
LPI

102-500 · Question #190

Which command allows you to make a shell variable visible to subshells?

The correct answer is B. export VARIABLE. export VARIABLE (no dollar sign) is the correct POSIX command to mark a shell variable for export to the environment of child processes (subshells). The export builtin works on the variable name, not its value, so the dollar sign is wrong in option A - export $VARIABLE would…

Shells and Shell Scripting

Question

Which command allows you to make a shell variable visible to subshells?

Options

  • Aexport $VARIABLE
  • Bexport VARIABLE
  • Cset $VARIABLE
  • Dset VARIABLE
  • Eenv VARIABLE

How the community answered

(61 responses)
  • A
    8% (5)
  • B
    72% (44)
  • C
    15% (9)
  • D
    2% (1)
  • E
    3% (2)

Explanation

export VARIABLE (no dollar sign) is the correct POSIX command to mark a shell variable for export to the environment of child processes (subshells). The export builtin works on the variable name, not its value, so the dollar sign is wrong in option A - export $VARIABLE would try to export whatever string the variable contains, not the variable itself.

Options C and D (set) are wrong because set configures shell options and positional parameters, not environment export; it has no role in making variables available to subshells. Option E (env VARIABLE) is a red herring - env can display environment variables or run a command in a modified environment, but env VARIABLE alone does nothing useful.

Memory tip: Think of export like exporting a label from a warehouse - you hand over the name tag, not the item itself. Since you're naming the variable, no $ prefix is needed, just as you'd write the label without unpacking the box.

Topics

#export command#shell variables#environment variables#subshells

Community Discussion

No community discussion yet for this question.

Full 102-500 Practice