zsh-users
 help / color / mirror / code / Atom feed
* Script breaking on cd *param
@ 2006-12-06 12:11 zzapper
  2006-12-06 12:26 ` Peter Stephenson
  0 siblings, 1 reply; 4+ messages in thread
From: zzapper @ 2006-12-06 12:11 UTC (permalink / raw)
  To: zsh-users

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-12-06 13:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-12-06 12:11 Script breaking on cd *param zzapper
2006-12-06 12:26 ` Peter Stephenson
2006-12-06 13:42   ` zzapper
2006-12-06 13:52     ` Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).