102-500 · Question #189
Which of the following is the best way to list all defined shell variables?
The correct answer is B. set. set lists all shell variables - both environment variables and shell-local variables (including functions) - making it the most complete option for seeing everything defined in the current shell session. Why the distractors are wrong: A. env - shows only exported environment…
Question
Options
- Aenv
- Bset
- Cenv -a
- Decho $ENV
How the community answered
(25 responses)- A4% (1)
- B84% (21)
- C8% (2)
- D4% (1)
Explanation
set lists all shell variables - both environment variables and shell-local variables (including functions) - making it the most complete option for seeing everything defined in the current shell session.
Why the distractors are wrong:
- A.
env- shows only exported environment variables, missing shell-local variables that haven't been exported withexport. - C.
env -a- not a standard/portable flag;envdoesn't accept-ain most implementations, and even where it does it still only covers environment variables. - D.
echo $ENV- prints the value of a single variable namedENV(typically the path to the shell's config file), not a list of variables.
Memory tip: Think "Set = Sees everything" - set is the most comprehensive command because it operates at the shell level, while env only sees what's been promoted to the environment.
Topics
Community Discussion
No community discussion yet for this question.