Executable check.sh is in the current directory, but that directory is not in PATH.
Which specification runs the file directly?
./check.sh is a relative path from the current directory and does not rely on PATH lookup.
Detailed explanation
check.shIncorrect. Without the current directory in PATH, the bare name is not found.
Incorrect. Without the current directory in PATH, the bare name is not found.
./check.shCorrect. ./check.sh explicitly starts the lookup in the current directory.
Correct. ./check.sh explicitly starts the lookup in the current directory.
/check.shIncorrect. /check.sh refers to a file directly under the filesystem root.
Incorrect. /check.sh refers to a file directly under the filesystem root.
../check.shIncorrect. ../check.sh refers to the parent directory.
Incorrect. ../check.sh refers to the parent directory.
Try it yourself
An example you can run in a temporary verification environment.
tmp=$(mktemp -d); printf '#!/bin/sh\necho checked\n' >"$tmp/check.sh"; chmod +x "$tmp/check.sh"; (cd "$tmp" && ./check.sh); rm -rf "$tmp"Expected result
checkedKey points
- . means the current directory
- ./ is a relative path
- A path beginning with / is absolute
Notes
- Environment: POSIX shell / 一時実行ファイル
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.