stuff
This commit is contained in:
@@ -144,9 +144,9 @@ in
|
||||
echo "expected exactly one arg" 1>&2
|
||||
return 1
|
||||
fi
|
||||
query="$1"
|
||||
quote='`'"$query'"
|
||||
kind="$(type -t "$query")"
|
||||
declare query="$1"
|
||||
declare quote='`'"$query'"
|
||||
declare kind="$(type -t -- "$query")"
|
||||
if [[ "$kind" == "" ]]; then
|
||||
echo "could not find any command $quote" 1>&2
|
||||
return 1
|
||||
@@ -176,7 +176,7 @@ in
|
||||
return 0
|
||||
;;
|
||||
"file")
|
||||
path="$(which "$query")"
|
||||
path="$(type -p "$query")"
|
||||
# continue to below
|
||||
;;
|
||||
*)
|
||||
@@ -188,7 +188,7 @@ in
|
||||
dest="$(readlink "$path")"
|
||||
echo " $path is a symlink to $dest"
|
||||
if [[ "$dest" != /* ]]; then
|
||||
dest="$(dirname "$path")/$dest"
|
||||
dest="$(dirname -- "$path")/$dest"
|
||||
fi
|
||||
path="$dest"
|
||||
done
|
||||
@@ -197,12 +197,16 @@ in
|
||||
echo "$path does not exist!"
|
||||
return 1
|
||||
fi
|
||||
canon="$(readlink -f "$path")"
|
||||
if ! [[ -x "$path" ]]; then
|
||||
echo "$path is not executable!"
|
||||
return 1
|
||||
fi
|
||||
canon="$(readlink -f -- "$path")"
|
||||
if [[ "$path" != "$canon" ]]; then
|
||||
echo " $path canonicalizes to $canon"
|
||||
path="$canon"
|
||||
fi
|
||||
magic_parse="$(file --brief --mime "$path")"
|
||||
magic_parse="$(file --brief --mime -- "$path")"
|
||||
echo "magic: $magic_parse"
|
||||
case "$magic_parse" in
|
||||
'text/x-shellscript;'* | 'text/plain;'*)
|
||||
|
Reference in New Issue
Block a user