Skip to content

Commit

Permalink
🐛 mkifdiff -h prints help and exits sucessfully
Browse files Browse the repository at this point in the history
  • Loading branch information
WillForan committed Feb 19, 2024
1 parent 293f15a commit ca784d8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mkifdiff
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ set -euo pipefail
# 20230718WF add NOEMPTY (-n or --noempty)

# need a file and needs to be in a pipe
tty >/dev/null && echo "need to pipe to $0; cmd | $0 output.txt" && exit 1
usage(){ echo "USAGE: cmd | $0 [-n|--noempty] output.txt"; }
[ $# -eq 0 -o $# -gt 2 ] && usage >&2 && exit 1
[ "$1" == "-h" ] && usage && exit 0
tty >/dev/null && echo "need to pipe to $0; cmd | $0 output.txt" && exit 1

# might want to avoid overwritting with an empty file
NOEMPTY=
Expand Down
6 changes: 6 additions & 0 deletions t/mkifdiff.bats
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ teardown(){
return 0
}

mkifdiff_help() { #@test
run mkifdiff -h
[ $status -eq 0 ]
[[ "$output" =~ USAGE ]]
}

batmsg(){ echo "$*"|sed 's/: /:\t/' >&2; }
modtime_unchanged() {
mod_date="$(stat -c"%.10y" $MKIFDIFFFILE)"
Expand Down

0 comments on commit ca784d8

Please sign in to comment.