My env
OSX 10.11.6
zsh 5.0.8 (x86_64-apple-darwin15.0)
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin15)
Mono C# compiler version 4.0.5.0
test.cs
class Test {
public static void Main() {
System.Console.WriteLine("hello, world");
}
}
test.sh
#! /bin/bash
mcs -recurse:*.cs
I can use ./test.sh to compile test.cs
but if I change test.sh to
#! /bin/zsh
mcs -recurse:*.cs
error shows
./test.sh:3: no matches found: -recurse:*.cs
So, Why I can not use zsh?
zshis attempting to expand the*in that word as a file glob, failing, and throwing an error.bashdoes the same thing but, by default, it just ignores the globbing failure and keeps the word intact (somcssees the argument it expects).Add
shopt -s failglobto the top of the script (forbash) and it will fail also.Quote the
*in the argument tomcsto avoid this.