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

Re: Why is this happening in zsh?



2012-03-14 19:59:02 +0100, Anonymous:
> I am moving away from Bash to zsh and I have one problem that keeps coming
> up. Somehow zsh is interfering in interpreting commands and I know there
> must be an option to stop this but I can't figure which one to use. An
> example is
> 
> fossil --ignore *.class
> zsh: no matches found *.class
> 
> fossil never receives the command at all
> 
> I also have problems sometimes with rsync and have to use Bash. zsh is
> trying to substitute things that are supposed to be passed to the
> command. How can I set zsh to always ignore these without breaking something
> I haven't though of maybe like rm *.class
> 

I think that maybe one thing you don't realise is the buggy
behavior of *other* shells.

Other shells do expand *.class as well before calling the
command, except that when *.class doesn't match any file, they
pass the string "*.class" unmodified to the application (and the
application will usually fail because they can't find a file
called "*.class", though in this very case I suspect it's the
other way round).

That is generally harmless, but in cases like:

rm -f [a-z]*.class

If there's no file matching that pattern, zsh will not run the
rm command, but other shells will tell rm to delete the file
called '[a-z]*.class' and since the [a-z]*.class pattern doesn't
match the '[a-z]*.class' file, that file may very well exist and
be deleted accidentally.

There are a number of options to change zsh behavior in that
regard, but I wouldn't do that.

In this very case, zsh behavior is helpful because it reminds you
that *.class is a globbing pattern and should be quoted if you
don't want it to be expanded (as I suspect). While in other
shells, *.class will silently be left untouched if there's no
class file in the current directory letting you overlook that
pending bug for when that script will be called from a
directory that has class files.

-- 
Stephane



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