sane-which: only cat
text-based files
This commit is contained in:
parent
8d051d319f
commit
10c6801ccd
|
@ -7,11 +7,18 @@ v=$(which $1)
|
||||||
# this probably doesn't handle paths with spaces
|
# this probably doesn't handle paths with spaces
|
||||||
while [ "$(readlink $v || echo $v)" != "$v" ]
|
while [ "$(readlink $v || echo $v)" != "$v" ]
|
||||||
do
|
do
|
||||||
echo '->' "$v"
|
# TODO: this doesn't handle relative symlinks
|
||||||
v=$(readlink "$v")
|
echo '->' "$v"
|
||||||
|
v=$(readlink "$v")
|
||||||
done
|
done
|
||||||
|
|
||||||
echo '->' "$v"
|
echo '->' "$v"
|
||||||
echo ''
|
echo ''
|
||||||
# TODO: it'd be nice if we checked file type and only cat'd it if it's text
|
case $(file --brief --mime "$v") in
|
||||||
cat "$v"
|
(*text*)
|
||||||
|
cat "$v"
|
||||||
|
;;
|
||||||
|
(*)
|
||||||
|
echo $(file "$v")
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
Loading…
Reference in New Issue
Block a user