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

Re: [ -f glob ]



Atom Smasher wrote:
> here's a weird one...
> 
> this is part of a sanity test on line 369 of my zshrc (link below):
>      [ -f /usr/{share,lib,share/lib}/{zoneinfo,locale/TZ}/${TZ} ]

This is broken: -f expectes exactly one argument and you're giving it an
expression that expands to multiple arguments.  The [ ... ] form of
tests isn't recommended anyway, because the arguments aren't parsed
properly so this sort of error will be hidden.  But it's not at all
clear what you're trying to do.  I think you're looking to see if at
least one of the files in the expansion exists, in which case try
expanding the expression and using a null glob:

files=(/usr/{share,lib,share/lib}/{zoneinfo,locale/TZ}/${TZ}(N))
if (( ${#files} )); then
  # stuff
fi

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



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