|
|
@ -33,6 +33,13 @@ error[0]="Exiting..." |
|
|
|
error[1]="Invalid expression!" |
|
|
|
error[2]="Invalid argument!" |
|
|
|
|
|
|
|
copy='Copyright (C) 2022 Blau Araujo <blau@debxp.org>. |
|
|
|
|
|
|
|
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>. |
|
|
|
This is free software: you are free to change and redistribute it. |
|
|
|
There is NO WARRANTY, to the extent permitted by law. |
|
|
|
' |
|
|
|
|
|
|
|
help="cawk ($version) - REPL calculator in Bash and AWK |
|
|
|
|
|
|
|
USAGE |
|
|
@ -74,10 +81,10 @@ repl() { |
|
|
|
read -erp ': ' |
|
|
|
history -s "$REPLY" |
|
|
|
case "${REPLY,,}" in |
|
|
|
f*( )+([0-9])) PRECISION=${REPLY:1} ;; |
|
|
|
h|'?') echo "$help" ;; |
|
|
|
q|quit) die 0 ;; |
|
|
|
*) calc "$REPLY" $PRECISION;; |
|
|
|
f*( )+([0-9])) PRECISION=${REPLY:1};; |
|
|
|
h|'?') echo "$help" ;; |
|
|
|
q|quit) die 0 ;; |
|
|
|
*) calc "$REPLY" $PRECISION ;; |
|
|
|
esac |
|
|
|
done |
|
|
|
} |
|
|
@ -86,7 +93,7 @@ opts() { |
|
|
|
local param |
|
|
|
for param; do |
|
|
|
case $param in |
|
|
|
-h|--help) echo "$help"; exit ;; |
|
|
|
-h|--help) echo "$help"; echo "$copy"; exit;; |
|
|
|
-e) EXPRESSION=${@:2:1} ;; |
|
|
|
-e?*) EXPRESSION=${param:2};; |
|
|
|
-f) PRECISION=${@:2:1} ;; |
|
|
|