aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRatakor <ratakor@disroot.org>2023-03-30 01:32:56 +0200
committerRatakor <ratakor@disroot.org>2023-03-30 01:32:56 +0200
commit4f9192075fb5b8c415063ccd18fd146f8ceeecf7 (patch)
tree4fd86c6627f9222d59825d14e733c0a882c7c658
parent957348e40fe650ada1309af2a050464e1e266190 (diff)
fix: add Error if no arg is given to -p and -f options
-rwxr-xr-xquand10
1 files changed, 8 insertions, 2 deletions
diff --git a/quand b/quand
index 7b3d708..11b8f78 100755
--- a/quand
+++ b/quand
@@ -68,8 +68,8 @@ Options:
no option | Default
-h|--help │ Print this help message and exit
-v|--version | Print the version
--p|--past | Temporarily change past
--f|--future | Temporarily change future
+-p|--past [n] | Temporarily change past (n is negative)
+-f|--future [n] | Temporarily change future (n is positive)
|
e|edit | Edit the calendar file
c|cal [n] | Print a calendar with 1 or n months
@@ -94,9 +94,15 @@ main() {
calendar "$2"
return ;;
-p|--past)
+ [ -z "$2" ] &&
+ printf 'Error: no argument given\n' 1>&2 &&
+ return 1
past="$2"
exec ;;
-f|--future)
+ [ -z "$2" ] &&
+ printf 'Error: no argument given\n' 1>&2 &&
+ return 1
future="$2"
exec ;;
'')