Say I have this simple bash script:
#!/usr/bin/env bash
file="$1";
if [ -z "$file" ]; then
echo "Must pass relative file path as the first argument.";
fi
git_root=
git rev-parse --show-toplevel
;
# => need to resolve file from an absolute path to relative path, relative to git root
git diff HEAD:"$file" remotes/origin/dev:"$file"
If I pass an absolute path to this script, it needs to be able to handle it. What is the canonical way to do that? To check if it's an absolute file path, do we just check if the first character is "/"?
Asked by Alexander Mills
(10744 rep)
Sep 27, 2018, 07:53 PM
Last activity: Sep 27, 2018, 08:06 PM
Last activity: Sep 27, 2018, 08:06 PM