A startup file exported http_proxy, and for the rest of this session the variable must be gone completely: neither set nor env should list it any more, and a program started from this shell must not find it even as an empty value. Which command does that?

LPIC-1 Exam 102-500, objective 105. Shells and shell scripting medium

Machine-checked — no person has signed for it. This question was read against the source cited below by an automated pass, which found no contradiction. That is a weaker claim than it sounds: the same kind of process wrote the question, so it can confirm its own mistake.

Treat it as a good draft rather than as settled fact, and read the source below before you rely on it. It is not used in mock exams here — only questions a person has signed for are.

How these questions are written — where each question comes from, what the verification ledger records, and what happens when one is found wrong.

The options

Correct unset http_proxy

Correct. unset removes the variable from the shell altogether, so it disappears from the shell's own variable list and from the environment handed to every child process.

Not correct http_proxy=""

Wrong. The variable still exists and is still exported, now holding an empty string. env prints it as http_proxy= with nothing after the equals sign, and a program that only asks whether the name is set still finds it.

Not correct export -n http_proxy

Wrong for this requirement. The -n option removes only the export attribute. Children stop receiving it, but it remains a shell variable of the current shell and set still lists it.

Not correct readonly http_proxy

Wrong, and it makes the situation permanent. readonly freezes the current value, and a readonly variable cannot be unset afterwards: bash answers a later unset with cannot unset: readonly variable.

Why

Three states are worth telling apart, because programs test them differently. Not set at all is what unset NAME produces. Set but empty is what NAME= produces, and it is still exported, which is why an empty proxy variable can still change a program's behaviour. Set but not exported is what export -n leaves behind: visible to set, invisible to children. unset also removes functions, with unset -f NAME, and plain unset without -f looks for a variable of that name before it looks for a function. The only escape from a readonly variable is a new shell.

Where this comes from

Cited
manual page bash(1)

Practise this

Reading one question is not practice. The trainer will draw a short set from objective 105 and space the ones you get wrong.

Practise LPIC-1 Exam 102-500

More questions on this objective

All questions on Shells and shell scripting

Practise LPIC-1 Exam 102-500