projects
/
scripts.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fixed multiple bugs related to spaces in filenames.
[scripts.git]
/
viewer.sh
diff --git
a/viewer.sh
b/viewer.sh
index
27b93df
..
98682d4
100755
(executable)
--- a/
viewer.sh
+++ b/
viewer.sh
@@
-41,24
+41,24
@@
function getgeometry () {
# If no argument is given, we pick the most recent file
# If no argument is given, we pick the most recent file
-if [[ !
$1
]]; then
+if [[ !
"$1"
]]; then
file=$(\ls -tQ | head -1 | sed -e s/\"//g)
echo "Most recent is ${file}"
file=$(\ls -tQ | head -1 | sed -e s/\"//g)
echo "Most recent is ${file}"
- $0
${file}
+ $0
"${file}"
exit 0
fi
# If there were arguments, we loop through them
exit 0
fi
# If there were arguments, we loop through them
-echo "Viewing $
*
"
+echo "Viewing $
@
"
-while [[
$1
]]; do
+while [[
"$1"
]]; do
- file=
$1
+ file=
"$1"
# file=$(\ls -tQd $1 | head -1 | sed -e s/\"//g)
# file=$(\ls -tQd $1 | head -1 | sed -e s/\"//g)
- # if [[ ! -a
${file}
]]; then
+ # if [[ ! -a
"${file}"
]]; then
# echo "Can not find file $1"
# exit 1
# fi
# echo "Can not find file $1"
# exit 1
# fi
@@
-70,7
+70,7
@@
while [[ $1 ]]; do
*"FIG image text"*)
echo "${file}"
temp=$(mktemp /tmp/view.XXXXXX)
*"FIG image text"*)
echo "${file}"
temp=$(mktemp /tmp/view.XXXXXX)
- fig2dev -L pdf
${file}
${temp}
+ fig2dev -L pdf
"${file}"
${temp}
# xpdf -g 800x600+8+8 ${temp}
getgeometry
xpdf -g ${GEOMETRY} ${temp}
# xpdf -g 800x600+8+8 ${temp}
getgeometry
xpdf -g ${GEOMETRY} ${temp}
@@
-79,67
+79,67
@@
while [[ $1 ]]; do
*"image"*)
echo "${file}"
*"image"*)
echo "${file}"
- # feh -g 800x600
${file}
+ # feh -g 800x600
"${file}"
getgeometry
getgeometry
- feh -g ${GEOMETRY}
${file}
+ feh -g ${GEOMETRY}
"${file}"
;;
*"TeX DVI"*)
echo "${file}"
;;
*"TeX DVI"*)
echo "${file}"
- xdvi
${file}
+ xdvi
"${file}"
;;
# *"FIG image"*)
# echo "${file}"
;;
# *"FIG image"*)
# echo "${file}"
- # xfig
${file}
+ # xfig
"${file}"
# ;;
*"PostScript"*)
echo "${file}"
# ;;
*"PostScript"*)
echo "${file}"
- gv
${file}
+ gv
"${file}"
;;
*"PDF"*)
echo "${file}"
;;
*"PDF"*)
echo "${file}"
- # xpdf -g 800x600+8+8
${file}
+ # xpdf -g 800x600+8+8
"${file}"
getgeometry
getgeometry
- xpdf -g ${GEOMETRY}
${file}
+ xpdf -g ${GEOMETRY}
"${file}"
;;
*"WAVE audio"*)
echo "${file}"
;;
*"WAVE audio"*)
echo "${file}"
- esdplay
${file}
+ esdplay
"${file}"
;;
*"MP3"*|*"MPEG"*|*"movie"*|*"video"*|*"AVI"*|*"Microsoft ASF"*)
;;
*"MP3"*|*"MPEG"*|*"movie"*|*"video"*|*"AVI"*|*"Microsoft ASF"*)
- mplayer -quiet
${file}
+ mplayer -quiet
"${file}"
;;
*" text"*)
HEIGHT=$(stty size | awk '{print $1}')
;;
*" text"*)
HEIGHT=$(stty size | awk '{print $1}')
- if [[ $(wc -l
${file}
| cut -f 1 -d' ') -gt $((HEIGHT-2)) ]]; then
- less
${file}
+ if [[ $(wc -l
"${file}"
| cut -f 1 -d' ') -gt $((HEIGHT-2)) ]]; then
+ less
"${file}"
else
else
- cat
${file}
+ cat
"${file}"
fi
;;
*"tar archive"*)
fi
;;
*"tar archive"*)
- tar ztf
${file}
+ tar ztf
"${file}"
;;
*"Microsoft Word Document"*)
;;
*"Microsoft Word Document"*)
- antiword
${file}
| less
+ antiword
"${file}"
| less
;;
*"directory"*)
;;
*"directory"*)
- echo "
${file}:"; ls -lt ${file}
+ echo "
"${file}":"; ls -lt "${file}"
;;
*"gzip compressed"*)
temp=$(mktemp /tmp/view.XXXXXX)
echo "Decompressing to ${temp}"
;;
*"gzip compressed"*)
temp=$(mktemp /tmp/view.XXXXXX)
echo "Decompressing to ${temp}"
- zcat
${file}
> ${temp}
+ zcat
"${file}"
> ${temp}
$0 ${temp}
echo "Removing ${temp}"
rm ${temp}
$0 ${temp}
echo "Removing ${temp}"
rm ${temp}