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

Re: Help on filename generation



Joel J. Adamson wrote:
> function doit() {
>    for file in $1/*(generic)*~*(~)
>    print $file
>    exit
> }
> 
> Currently I get "doit:1: unknown file attribute."   When I enter this
> globbing pattern at the interactive prompt, I get the files I want.

The pattern should be:

 $1/*generic*~*\~

The parentheses around the final tilde were confusing it.

You don't need the backslash near the end as a final ~ is a special
case, but it makes it more obvious.

It doesn't matter in this case, but as it happens the pattern after the
first "~" is matching against the entire string, including the
directory.  In other words, for everything that matches $1/*generic* it
sees if that entire string matches *\~ and if so rejects it.  That would
become important if you wanted to match some earlier component in the
final part of the path.

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


To access the latest news from CSR copy this link into a web browser:  http://www.csr.com/email_sig.php

To get further information regarding CSR, please visit our Investor Relations page at http://ir.csr.com/csr/about/overview



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