Bash Variables and Environment
Separate a shell variable from a value exported to child processes.
How it works
A shell variable belongs to the current shell unless it is exported. Child programs receive exported environment variables, but cannot directly modify their parent’s variables. Assignment has no spaces around the equals sign. Quote values when passing them as arguments, and avoid repurposing system variables such as HOME or PATH for an unrelated lesson calculation.
Run the code
Reviewed with Git for Windows Bash 5.2.37. Open Git Bash, save the download with LF line endings in a separate learning folder, check it with bash -n lesson-name.sh, then run bash lesson-name.sh using the actual filename. Bash 4 or newer is required for the full course. Linux-only notes identify unavailable tools or POSIX behaviour. There is no Bash browser runner; Apache and MySQL are not required.
This complete example was executed in the stated local review environment.
Example
#!/usr/bin/env bash
set -u
set -o pipefail
export LC_ALL=C
desk_label="Map Desk"
export DESK_DEMO_LABEL="$desk_label"
bash --noprofile --norc -c '[[ $DESK_DEMO_LABEL == "Map Desk" ]] || exit 1; printf "Child received exported label\n"'
Expected result
Child received exported label
The child shell verifies the exported value independently. A regular unexported variable with another name would not become an environment value automatically. Environment variables are inherited data, not secure secret storage: process tools, diagnostic output or application logs may expose them. Use application-appropriate secret handling for real credentials.
Primary technical reference: Bash documentation.