#916414 nocache: add usage statement with incorrect arguments

Package:
nocache
Source:
nocache
Description:
bypass/minimize file system caching for a program
Submitter:
Paul Wise
Date:
2018-12-14 05:27:04 UTC
Severity:
wishlist
#916414#5
Date:
2018-12-14 05:25:09 UTC
From:
To:
nocache does not properly handle the situation where an invalid flag
was passed to the script. It complains about the options and continues.
The correct thing to do would be to print a usage statement and exit.
It would also be nice to add a help option to print the usage info.

$ nocache --help echo foo
/usr/bin/nocache: illegal option -- -
/usr/bin/nocache: illegal option -- h
/usr/bin/nocache: illegal option -- e
/usr/bin/nocache: illegal option -- l
/usr/bin/nocache: illegal option -- p
foo

$ shellcheck -eSC2145 `which nocache`

In /usr/bin/nocache line 6:
case "$opt" in
^-- SC2220: Invalid flags are not handled. Add a *) case.

$ cp `which nocache` .

$ sed -i 's/esac/*) echo usage statement here ; exit ;; esac/' nocache

$ ./nocache --help echo foo
./nocache: illegal option -- -
usage statement here