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

Re: Why doesn't cd ignore files when you type say "cd fred*"



On Thu, Dec 04, 2003 at 08:50:33PM +0000, zzapper wrote:
> Thanx Stephen & Bart
> 
> Can anyone talk me thru the following two expressions  I can guess
> what they are doing but I'd like to know the principles (which do the
> same thing (?)). I'm a zsh newbie and the shell syntax is still a bit
> shocking!
> 
>    dirs=( "${^@}"(-/N) )  

"${^array}"_text  expands array to
    "${array[1]}"_text "${array[2]}"_text ...
and so the expression in parenthesis is expanded to
    ( "$1"(-/N) "$2"(-/N) "$3"(-/N) ... )

(-/N) is a globing qualifier, where '-' specifies that following
qualifiers apply to targets of symlinks, '/' requests directories, and
so '-/' requires directories or symbolic links that point to
directories.  'N' turns on the null_glob option for this pattern, which
means that the word is deleted if it does not match a file (otherwise an
error message would be printed).  You may try this with
    print no_dir(/)
and
    print no_dir(/N)

Summing up  ( "${^@}"(-/N) )  is expanded to an array of positional
arguments which are directories or symbolic links to directories.

Ref: man zshexpn  then search for /glob qua/
     info zsh filename\ generation
     zsh reference card from www.zsh.org is also very useful

HTH,

Pavol



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