Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Ex-bash script for optimisation



Hi
Q1) Is there a better way to generate the array filelst
Q2) the line "for x in *$1*" fails is no match, how can i "catch" this

#!/bin/zsh
# v
# description : vi all files containing $1 in name
#               but excluding non-text files
set +x

filebad=''
filelst=()
filenum='1'
for x in *$1*
do
   if [[ "$x" == *.(aux|toc|dvi|aux|exe|obj|zip|pdf|mdb|xls|bak|swp|log|jpg|gif|tiff|jpeg|bmp) ]]
   then
      let filebad=1
   else 
      if [ -f $x ]
      then
      filelst[$filenum]=$x
      let filenum=filenum+1
      fi
   fi
done

if (( ${#filelst} ))
then
echo "file list : " $filelst
gvim.exe ${filelst[*]} &
else
echo "sorry no file matched *$1*"
fi




Messages sorted by: Reverse Date, Date, Thread, Author