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

Re: Script breaking on cd *param



Peter Stephenson <pws@xxxxxxx> wrote in news:200612061226.kB6CQnpu022275
@news01.csr.com:

> local str
> local -a dirs
> for str in param param\* \*param \*param\*; do
>   # Expands to all matching directories, else nothing.
>   dirs=(${~str}(N/))
>   if (( ${#dirs} == 1 )); then
>     cd $dirs
>     break
>   fi
> done
PWS
Thanx JWTDO

but did you forget the dollars on $param?

function cdc()
{
local str
local param=$1
local -a dirs
echo $param
for str in $param $param\* \*$param \*$param\*; do
  # Expands to all matching directories, else nothing.
     dirs=(${~str}(N/))
       if (( ${#dirs} == 1 )); then
           cd $dirs
               break
                 fi
                 done
  
}


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



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