introduce isnumeric function
This commit is contained in:
parent
97c9dfb986
commit
f9d0b56f97
3 changed files with 10 additions and 3 deletions
|
|
@ -100,6 +100,8 @@ function confirm-file-overwrite {
|
||||||
[[ "$OVERWRITE" = false ]] || confirm
|
[[ "$OVERWRITE" = false ]] || confirm
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isnumeric { [[ "$1" =~ ^[0-9]+$ ]]; }
|
||||||
|
|
||||||
# ====== Core ======
|
# ====== Core ======
|
||||||
function run-subcmd {
|
function run-subcmd {
|
||||||
# if CMD_MIN is empty, then CMD_MAJ is the root cmd (ie ceru)
|
# if CMD_MIN is empty, then CMD_MAJ is the root cmd (ie ceru)
|
||||||
|
|
|
||||||
|
|
@ -214,11 +214,9 @@ esac
|
||||||
unset -f perr-unsupportedhash perr-forbiddenhash perr-recommendhash
|
unset -f perr-unsupportedhash perr-forbiddenhash perr-recommendhash
|
||||||
|
|
||||||
# ensure $ROUNDS is a valid numeric
|
# ensure $ROUNDS is a valid numeric
|
||||||
re='^[0-9]+$'
|
if ! isnumeric "$ROUNDS"; then
|
||||||
if ! [[ "$ROUNDS" =~ ^[0-9]+$ ]] ; then
|
|
||||||
throw-badval 1 "$ROUNDS" '-r|--rounds'
|
throw-badval 1 "$ROUNDS" '-r|--rounds'
|
||||||
fi
|
fi
|
||||||
unset -v re
|
|
||||||
|
|
||||||
# Acquire password from stdin
|
# Acquire password from stdin
|
||||||
if [[ "$STDIN" == true ]]; then
|
if [[ "$STDIN" == true ]]; then
|
||||||
|
|
|
||||||
|
|
@ -81,6 +81,10 @@ while [[ $# -gt 0 ]]; do
|
||||||
done; unset -v ARG
|
done; unset -v ARG
|
||||||
|
|
||||||
EXTRA=''
|
EXTRA=''
|
||||||
|
# ensure $ROUNDS is a valid numeric
|
||||||
|
if ! isnumeric "$ROUNDS"; then
|
||||||
|
throw-badval 1 "$ROUNDS" '-r|--rounds'
|
||||||
|
fi
|
||||||
|
|
||||||
case "$TYPE" in
|
case "$TYPE" in
|
||||||
ed25519)
|
ed25519)
|
||||||
|
|
@ -93,6 +97,9 @@ case "$TYPE" in
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
if ! isnumeric "$BITS"; then
|
||||||
|
throw-badval 1 "$BITS" '-b|--bits'
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ "$HWKEY" == true ]]; then
|
if [[ "$HWKEY" == true ]]; then
|
||||||
if [[ "$TYPE" == "rsa" ]]; then
|
if [[ "$TYPE" == "rsa" ]]; then
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue