Environment and PATH
PATH Order
Search Directories Left to Right
PATH is a colon-separated list of directories. Bash searches those directories from left to right when a command has no slash.
Program
Play the script to choose the first directory and build the command path Bash would find first.
path_order.sh
#!/usr/bin/env bash
tool_dir=
PATH="$tool_dir:/usr/bin"
deploy_path="$tool_dir/deploy"
echo "$deploy_path"
#!/usr/bin/env bash
tool_dir=
PATH="$tool_dir:/usr/bin"
deploy_path="$tool_dir/deploy"
echo "$deploy_path"
#!/usr/bin/env bash
tool_dir=
PATH="$tool_dir:/usr/bin"
deploy_path="$tool_dir/deploy"
echo "$deploy_path"
PATH
`PATH` tells Bash where to look for commands that are not written with a slash.
search order
The leftmost directory is searched first.
command path
This example models the chosen path without requiring the file to exist.