shopt-option

Bash shopt sourcepath

Controls PATH search by source and dot when the filename has no slash. Only source trusted files; the command executes shell code in the current environment. This fixture sets a private PATH entry and compares an explicit path with lookup. Run in a fresh private directory with HOME set to that directory and LC_ALL=C. Expected output (one item per line): loaded; explicit path works.

Formal Syntax & Structure

bash syntaxbash
shopt -s sourcepath; shopt -u sourcepath; shopt -q sourcepath

Return Value

exit status

Option-setting command returns zero for a valid request; query status is zero if enabled, one if disabled.

Working Example

Example Snippetbash
mkdir libprintf 'value=loaded\n' > lib/configPATH="$PWD/lib:/usr/bin:/bin"shopt -s sourcepathsource config || exit 1printf '%s\n' "$value"shopt -u sourcepathif source config 2>/dev/null; then exit 1; fisource ./lib/config || exit 1printf 'explicit path works\n'
Bash Reference