A value visible in your shell is not automatically available to a program you start from it. A command may therefore report that a setting is absent even though you can print it at the prompt. To diagnose that difference, distinguish the shell's variables from the environment it passes to new processes.
You will create two temporary, synthetic values containing spaces, decide when
they are exported, and check what newly started Bash children receive. You will
also inspect PATH to connect environment data with command lookup, without
editing that setting or any startup file.
1. Reserve two names in the ordinary practice shell
Complete Build a short pipeline and check every stage
first. Use the ordinary Bash account in the checked Ubuntu guest. This task
needs no file fixture: stay in your existing home or practice directory.
The usual per-exercise directory convention applies to file tasks; there is
no reason to create an unused manage-session-environment directory here.
Run one line at a time, inspect the result, and stop after unexpected errors. The expected absent-name observations are explained before they occur. Begin with the already taught identity and command-origin checks:
id -u
id -un
ps -p $ -o comm=
type printf set declare export unset bash printenv
Require a nonzero user ID, the expected ordinary username and Bash. printf,
set, declare, export and unset must be Bash builtins; bash and
printenv must resolve to the expected guest executables. Stop and reconcile
an unexpected alias, function or executable origin before proceeding.
Use the taught read-only option inspection:
set -o
Require allexport and errexit to be off. allexport would automatically
mark new or changed variables for export, preventing the intended local-only
comparison. errexit off lets the expected absent-name commands report their
results without ending the practice shell. Preserve a different configuration
and reconcile the baseline; do not change either option for this task.
Check actual shell declarations, not just exported values
We reserve only VECTA_LAB_LABEL and VECTA_LAB_OWNER. The taught
declare -p inspects named shell variables, including variables that are not
exported. It prints a declaration if the name exists, or a diagnostic if it
does not. The displayed declarations are evidence to read, not commands to
copy back into the shell.
declare -p VECTA_LAB_LABEL VECTA_LAB_OWNER
Require an absence diagnostic for each name before assigning either one.
An illustrative English message includes VECTA_LAB_LABEL: not found;
wording can vary. Check the named variable and the meaning. A nonzero result
is expected here, but one overall status does not prove both names absent.
Inspect both observations.
Any existing declaration is a collision, even if it has an empty value, is not exported, or declares the name without assigning a value. Preserve it and stop this exercise in that shell. Do not overwrite it, unset it, or assume that a newly opened terminal will necessarily be free of the same startup configuration. Resume only after establishing an appropriate ordinary shell where both reserved names are demonstrably absent.
Bound the child Bash startup behavior
A noninteractive Bash child can read a file named by the existing BASH_ENV
variable. The flags used below do not by themselves disable that mechanism.
Inspect this specific setting before any child launch:
declare -p BASH_ENV
Require it absent. If it is declared, preserve it and stop before launching these children; do not clear it or change a startup file as a shortcut. Keep that absence condition throughout the task. This is a bounded check of one relevant startup input, not a claim to inspect every possible machine configuration.
The only names we will assign or remove are the two originally absent course
variables. PATH, BASH_ENV, other session values and startup files remain
unchanged.
2. Inspect PATH without changing command lookup
A shell variable is a named value stored in the current shell. Some shell variables are marked for export. Their names and values are included in the environment supplied to newly started programs. The environment is one way a parent process passes settings to a child process.
printenv NAME asks the external printenv program to display the named entry
from the environment it received. It does not inspect every unexported Bash
variable in the parent. Always supply a name in this lesson; we do not dump
the complete environment.
PATH normally holds a colon-separated list of directories used when looking
for an external command whose name does not contain a slash. It does not
replace the earlier distinctions among aliases, functions, builtins and
executables. Use the known lookup commands to identify the actual result.
Read the existing exported path and the two executable resolutions:
printenv PATH
command -v bash
command -v printenv
Record your actual output. A short illustrative PATH fragment is
/usr/local/bin:/usr/bin:/bin; the complete value in your guest may differ.
The colons separate entries. The lookup results should identify the expected
guest executables already checked above. If the path is missing, unfamiliar
or inconsistent with the declared setup, stop and investigate the observation.
Do not paste a sample PATH value into an assignment to make it look familiar.
This distinction matters: reading the search path explains a lookup, while changing it can change which external program a later name selects. No PATH change is needed to learn inheritance.
3. Assign a local value containing a space
A plain Bash assignment has the form NAME=value, with no spaces around
=. It is shell syntax, not a program named NAME. The chosen name begins
with a letter and uses only letters and underscores. The VECTA_LAB_ prefix
identifies this task's reserved values; it gives them no special shell power.
Single quotes preserve the space in the supplied text as part of one value.
Under our checked allexport-off baseline, assigning a previously absent
ordinary variable does not mark it for export.
Only after both reserved names passed the absence check, create the guided value:
VECTA_LAB_LABEL='Delivery desk'
The quotes are syntax; the stored value is Delivery desk, without quote
characters. The already taught double-quoted expansion reads the value as one
argument, and the printf format makes that boundary visible:
printf '<%s>\n' "$VECTA_LAB_LABEL"
declare -p VECTA_LAB_LABEL
Expect one <Delivery desk> output line. The declaration should show the same
value without an export attribute; a usual display starts with declare --.
A later exported declaration will show -x. These are representations to
inspect, not instructions to execute.
Now ask an external program for that same named environment entry. Predict
whether it sees the unexported parent variable. Use the previously taught
$? immediately after printenv, before another command replaces the status:
printenv VECTA_LAB_LABEL
printf 'Named environment status: %s\n' "$?"
For this one absent environment name, GNU printenv prints no value and
returns status 1. The parent variable still exists: the external program
simply did not receive it. An existing exported empty string is different:
printenv can print an empty line and return 0 for that present entry.
Read the named status and the prior declaration instead of treating a blank
looking output as proof of absence. Other errors require diagnosis rather
than being called an expected missing-value result.
4. Launch a child, then export to a new child
A child process is a process started by another process. We will start a short, noninteractive Bash child that runs one inspection command and exits. Its launch does not switch your existing terminal into a lasting new shell.
In bash --noprofile --norc -c 'printenv VECTA_LAB_LABEL':
--noprofilerequests that the usual login profile files not be read.--norcrequests that the usual interactive Bash startup file not be read.-ctells the new Bash to read commands from the following single argument.- The outer single quotes keep
printenv VECTA_LAB_LABELtogether as one command string for the child to parse. They are removed by the parent and are not characters in the child's command. - The child runs named
printenv; no assignment, file write or complete environment dump is hidden in that command string.
These flags are not a substitute for the checked absence of BASH_ENV.
Recheck that absence before the first launch if the session changed during
your work. Keep the known executable origins and startup condition for every
child below.
Predict the child's value and status before running:
bash --noprofile --norc -c 'printenv VECTA_LAB_LABEL'
printf 'Child status: %s\n' "$?"
No named value should appear, and the status should be 1. The child exits
with its final inspection command's status. The parent's existing local value
did not cross the launch boundary merely because the parent could print it.
export NAME marks the current variable for inclusion in the environment
of subsequently started programs. It does not save the value into a profile
or send it backward into the process that started this shell. Mark the known
value for export, then inspect its attribute:
export VECTA_LAB_LABEL
declare -p VECTA_LAB_LABEL
Require the same Delivery desk value and the export attribute, normally
shown as declare -x. Then inspect a new external process and a new Bash
child, one line at a time:
printenv VECTA_LAB_LABEL
bash --noprofile --norc -c 'printenv VECTA_LAB_LABEL'
printf 'Child status: %s\n' "$?"
Each named value should be Delivery desk; the final child status should be
0. The value itself did not change. The export decision changed which new
processes receive it. An already launched process is not retroactively updated
when the parent later exports, changes or removes a variable. A child's own
later changes likewise do not rewrite the parent's copy.

Read each launch arrow as a new child receiving the parent's exported values at that time. The last snapshot anticipates the removal you will perform after your independent checks; it does not tell you to remove the guided value yet. Earlier children are not updated by a later parent change.
5. Remove only an owned variable
unset -v NAME removes the named variable, including its export attribute,
from the current shell. Here -v explicitly selects variables, so the command
does not remove a same-named function when a variable is already absent.
NAME is an explanatory placeholder; the exercise uses only the two exact
originally absent names.
Removal affects future launches from this shell. It does not reach into previously started children to erase their copies. Nor does it remove an assignment from a startup file; this task never writes one. You will apply this removal to the independent variable first and leave the guided label until final cleanup.
Diagnose the observation you actually made
| Observation | Possible explanation | Safe next check |
|---|---|---|
The parent prints a value but named printenv cannot find it. | The variable exists locally without export. | Inspect its named declaration and export attribute. |
| A declared name appears before the exercise begins. | It belongs to existing session state, even if empty or unexported. | Preserve it and stop; a missing printenv result is not permission to overwrite it. |
| A child does not see the expected value after export. | A different spelling, different shell or different launch condition was used. | Compare the exact name, parent declaration and child command before changing anything. |
| A value with spaces produces unexpected command behavior. | Assignment spacing or quoting changed the syntax. | Compare the exact NAME='value with spaces' form and quoted expansion. |
| The named output looks empty. | It may be absent or present with an empty value. | Inspect the name-specific declaration and the immediate documented printenv status. |
| A child behaves differently from the taught probe. | Its startup input, executable origin or command string may differ. | Recheck the bounded startup/origin conditions; do not edit PATH or clear unrelated variables as a repair. |
Independent task: a second temporary owner value
Keep the guided label exported and unchanged. Recheck VECTA_LAB_OWNER with
named declare -p; it must still be absent. Keep the same ordinary Bash
session, checked option states, known command origins and absent BASH_ENV.
The new synthetic value is Mira Shah, including the single space.
Before opening the answer:
- Assign that value to
VECTA_LAB_OWNERwithout exporting it yet, and prove the current shell holds the exact value as one argument. - Launch the same kind of named child inspection for this new name. Predict and record the absent environment result and its immediate status.
- Export this new variable, then launch a new child and check the inherited value and status.
- Remove only
VECTA_LAB_OWNERwith the taught variable-only unset form. Prove its declaration is absent and that a later new child no longer receives it. - Check that the guided
VECTA_LAB_LABELstill holdsDelivery deskwith its export attribute. Leave it for final cleanup.
Success: the value is visible in the parent before export, present in a new child's environment only after export, and absent from a later child's environment after removal. The guided value stays unchanged, and no existing setting, file or PATH entry is modified. Explain why the later child check does not prove that an earlier child's copy was changed.
Graduated hints
- Local storage and exported environment are different observations. Use the
parent expansion/declaration for one and named child
printenvfor the other. - Assignment stores the text,
exportchanges inheritance, andunset -vremoves this owned variable. Use the exact same spelling in each operation. - Keep the entire child command inside single quotes. Inspect
$?with the taughtprintfas the next command after each child, before another check replaces the status.
Answer and Reasoning
After the independent name's renewed absence check, assign and inspect it:
VECTA_LAB_OWNER='Mira Shah'
printf '<%s>\n' "$VECTA_LAB_OWNER"
declare -p VECTA_LAB_OWNER
Require one <Mira Shah> line and the same unexported value in the declaration.
Under the unchanged child-startup conditions, check the local-only boundary:
bash --noprofile --norc -c 'printenv VECTA_LAB_OWNER'
printf 'Child status: %s\n' "$?"
The child should have no named value, with status 1. Then mark the existing
value for export and inspect a new child:
export VECTA_LAB_OWNER
bash --noprofile --norc -c 'printenv VECTA_LAB_OWNER'
printf 'Child status: %s\n' "$?"
Expect Mira Shah and status 0. Remove only this originally absent owned
variable, then inspect its declaration:
unset -v VECTA_LAB_OWNER
declare -p VECTA_LAB_OWNER
The absence diagnostic is expected. It is not the same as an assigned empty value. Start a later child to check future inheritance:
bash --noprofile --norc -c 'printenv VECTA_LAB_OWNER'
printf 'Child status: %s\n' "$?"
declare -p VECTA_LAB_LABEL
Expect no owner entry and child status 1. The guided label should still be
exported with value Delivery desk. Each child is a separate launch, so the
sequence checks inheritance at three different times; it does not mutate a
previous child's environment.
The quotation decision preserves one stored value containing a space. The
inheritance decision is export, not quoting and not the uppercase name.
Named printenv inspects a launched program's environment; named declare -p
can also reveal unexported parent variables. Those complementary observations
explain both the initial collision check and the difference seen before export.
Cleanup and proof of removal
Finish the independent checks first. Confirm you are still in the same ordinary shell where both names were recorded absent initially. Inspect the two current declarations:
declare -p VECTA_LAB_LABEL VECTA_LAB_OWNER
At this point the label should be the known exported Delivery desk, and
the owner should already be absent. If a value is unrecognized or you cannot
establish the original absence record, stop before removal; do not guess that
a similarly named existing setting belongs to the task.
Only for the two originally absent names owned by this attempt:
unset -v VECTA_LAB_LABEL VECTA_LAB_OWNER
declare -p VECTA_LAB_LABEL VECTA_LAB_OWNER
Require a separate absence diagnostic for each name. The explicit -v keeps
the operation limited to variables even for the already absent owner. With
the same checked startup condition, prove that a later child does not inherit
the guided label either:
bash --noprofile --norc -c 'printenv VECTA_LAB_LABEL'
printf 'Child status: %s\n' "$?"
Expect no named value and status 1. No directory, file or process needs
removing; each child inspection exits on its own. Preserve PATH, all other
variables, shell options and startup files. Do not clear the environment or
erase shell history as cleanup.
Resume in the right shell
If interrupted, first identify whether this is the same ordinary practice shell. Inspect only the two reserved names and the relevant startup/option conditions. If the known values belong to this attempt, continue from the last state whose declaration, inheritance and status you can explain. Do not reassign a known exported variable and assume it has become local: assignment can retain an existing export attribute.
If you opened a different shell or lost the original absence evidence, treat any existing declaration as a collision. Preserve it. Start only when the two names are demonstrably absent under the stated setup conditions. A fresh terminal is not evidence of absent names until inspected. No startup-file change or environment reset is part of resuming this task.
Sources and other study views
- S18 — Bash 5.2 manual: variables, export, unset, invocation and startup files
- S19 — GNU Coreutils manual: named printenv values and exit statuses
These examples use the course's Bash 5.2 and GNU Coreutils 9.4 baseline. The upstream Coreutils manual may document newer releases; it does not imply that every newer option is available in the course guest.
Use Revision to reconstruct the scope distinctions, or Quick Reference to retrieve the bounded named operations.