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

Re: Suppressing "no matches found" Glob Message?



    Hi Aaron :)

 * Aaron Davies <agdavi01@xxxxxxxxxxxxxx> dixit:
> >Don't know, but you don't want NOMATCH set: it *prints* an error
> >if a match is not found. If you unset it, what you are going to have
> >is the pattern as-is, so 'ls' will complain saying that '**/*(.)'
> >doesn't exist.
> That wouldn't be so bad, actually; I could redirect that error to 
> /dev/null. So, does anyone know how to set that option in a pattern?

    I don't know. I've took a look at the manual and I haven't found
anything about it. Anyway, if you are using such pattern you're bound
to zsh, so, why not using 'print' instead of 'ls'? Using the 'stat'
module of zsh will give you all information 'ls' gives.

    Otherwise, your solution of redirecting the error is good. You
just need a shell function in order to set the NOMATCH option,
something like (I'm writing on the fly, so it's untested):

    function special_ls() {

        emulate -L zsh
        setopt NOMATCH

        ls **/*(.) >& /dev/null

        return 0
    }

    That will do.

    Raúl Núñez de Arenas Coronado

-- 
Linux Registered User 88736
http://www.pleyades.net & http://raul.pleyades.net/



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