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

Script breaking on cd *param



Hi
The following should try to cd to a subdirectory in the 4 following ways.

cd param
cd param*
cd *param
cd *param*

However if it fails on the second the script breaks
with "no matches found: *param "

sometimes putting quotes round ${1}* seems to help

alias if_param='
   if [ $# -gt 0 ]
      then
      if builtin cd $1 &> /dev/null ;
         then
         shift
      elif builtin cd ${1}* &> /dev/null;
         then
         shift
      elif builtin cd *$1 &> /dev/null;
         then
         shift
      elif builtin cd *${1}* &> /dev/null;
         then
         shift
      else
         echo $1 not found
         shift
      fi
   fi
'

-- 
http://successtheory.com/tips/ Vim, Zsh, MySQL Tips



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