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

Re: [ -f glob ]



On Wed, 9 Jan 2008, Peter Stephenson wrote:

This is broken: -f expectes exactly one argument and you're giving it an expression that expands to multiple arguments.
================

but, why would it work on bsd and not work on solaris?


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
================

very slightly modified, and working great...

 local tz_file
 tz_file=(/usr/{share,lib,share/lib}/{zoneinfo,locale/TZ}/${TZ}(.N))
 (( ${#tz_file} )) || export TZ=Etc/UTC

thanks!


--
        ...atom

 ________________________
 http://atom.smasher.org/
 762A 3B98 A3C3 96C9 C6B7 582A B88D 52E4 D9F5 7808
 -------------------------------------------------

	"I believe that banking institutions are more dangerous
	 to our liberties than standing armies."
		-- Thomas Jefferson



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