From 66cdcec22a236171d2f630747e04d69c590f7dfc Mon Sep 17 00:00:00 2001 From: Benjamin Barenblat Date: Mon, 16 Sep 2019 11:21:44 -0400 Subject: Support --help option --- sor | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'sor') diff --git a/sor b/sor index 12f5652..0960db8 100755 --- a/sor +++ b/sor @@ -13,6 +13,48 @@ # See the License for the specific language governing permissions and # limitations under the License. +short_usage() { + echo 'Usage: sor SNIPPET...' +} + +help() { + short_usage + cat <&2 + exit 1 +fi +eval set -- "$temp" +unset temp +while true; do + case "$1" in + --help) + help + exit 0 + ;; + --) + shift + break + ;; + *) + echo >&2 'Internal error; please report.' + exit 1 + ;; + esac +done + while read file; do for test in "$@"; do if eval "$test \"$file\""; then -- cgit v1.2.3