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

Re: filename expansion problem



On Apr 3, 11:41am, djh wrote:
}
} What is the trick to enable me to use wild cards withing the
} conditional [[ ]]

There is no trick.  Wildcards in [[ ]] are treated as patterns to be
matched against other strings, not against file names.  E.g.

	food=fodder
	if [[ $food = *odd* ]]; then ...

You couldn't do that if the *odd* expanded into a file name first.

If you want file names expanded, use [ ] as in

	if [ -e file-name-*.tar.bz2 ] ; then print hello ; fi

However, that will usually cause an error if the pattern expands to
more than one file, so you might want to use

	if [ -e file-name-*.tar.bz2([1]) ]; then ...

Replace ([1]) with ([0]) if you have the ksh_arrays option set.



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