I have the following very simple script:
#!/bin/bash
checkCmdLineArgs() {
echo -e "num input args $#"
if (( $# == 0 )); then
echo "$0 usage: install_dir home_dir"
exit 255
fi
}
checkCmdLineArgs
It does not work. If I run it like so:
./test.sh foo bar
It outputs:
num input args 0
./test.sh usage: install_dir home_dir
Any idea why it's failing?
echo -e-- default builds of bash break the POSIX spec forechoby having it do anything other than print-eon output, but a compliant implementation can be enabled at compile-time or runtime; and other, more-compliant shells will behave contrary to your expectations. (This is unlike most bashisms, which extend the spec rather than breaking it, butechois explicitly disallowed from accepting any options other than-n).