Questions: Command-Line Arguments and Environment Variables

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

A shell script contains the line: export DATABASE_URL=postgres://localhost/mydb. After the script finishes, you check the variable in your interactive shell and find it is not set. What explains this?

AThe export keyword only sets variables for the script's own use, not for child processes
BThe script ran in a child process; environment changes in child processes do not propagate to the parent
CThe variable was set incorrectly — DATABASE_URL cannot contain slashes
DEnvironment variables set in scripts are automatically unset when the script exits
Question 2 Multiple Choice

What is the difference between running ./configure.sh and source ./configure.sh with respect to environment variables?

Asource runs the script faster because it skips process creation overhead
Bsource executes the script's commands in the current shell process, so any environment changes persist in the calling shell; ./configure.sh runs in a child process where changes are invisible to the parent
CThere is no difference — both methods inherit the parent environment and return it after completion
Dsource prevents the script from accessing the parent shell's environment variables for security reasons
Question 3 True / False

Environment variable changes made by a child process are not visible to the parent process that launched it.

TTrue
FFalse
Question 4 True / False

When a shell expands wildcards like *.txt before passing arguments to a program, the program receives the original *.txt pattern and performs its own expansion internally.

TTrue
FFalse
Question 5 Short Answer

Why do command-line arguments and environment variables serve complementary rather than identical purposes, and when is each appropriate?

Think about your answer, then reveal below.