Resolve the real absolute path and check for its existence.
realpath-check
calls realpath
to resolve a relative path or a
symbolic link to its real absolute path. It then checks for its existence
and returns an error code if the path does not exists.
Resolve a real absolute path and for check its existence. If the file does not exists, display an error message and return error. Print its absolute real path on stdout if found.
source "${BASH_SOURCE[0]%/*}/libs/biapy-bashlings/src/realpath-check.bash"
file_path="../relative/path"
if file_realpath="$( realpath-check "${file_path}" )"; then
echo "File found. processing..."
else
exit 1
fi
-
-q | --quiet
Disable the error message.
-
-e | --exit
Enable exiting on failure.
- $1 (string): A path to resolve.
- 0: If successful.
- 1: If the path does not exists, an argument is missing or more than one argument given.
- The resolved absolute path.
- Error if the argument is missing or more than one argument is given.
- Error if the path does not exist