diff options
author | Philip Wittamore <philip@wittamore.com> | 2025-05-17 09:04:10 +0200 |
---|---|---|
committer | Philip Wittamore <philip@wittamore.com> | 2025-05-17 09:04:10 +0200 |
commit | 6c1ff8fe7947266e4c8e47a55f73542ce88b6fe9 (patch) | |
tree | 7c505f5dcfcf93168079c772656292433d8bf29e | |
parent | de9249cc1b768687daa2a41e6a05455759890129 (diff) | |
download | bashlib-6c1ff8fe7947266e4c8e47a55f73542ce88b6fe9.tar.gz bashlib-6c1ff8fe7947266e4c8e47a55f73542ce88b6fe9.tar.bz2 bashlib-6c1ff8fe7947266e4c8e47a55f73542ce88b6fe9.zip |
update
-rwxr-xr-x | pb_colour (renamed from pb) | 8 | ||||
-rwxr-xr-x | pb_number | 9 |
2 files changed, 10 insertions, 7 deletions
@@ -1,13 +1,7 @@ #!/usr/bin/env bash -#--- is number functions -# https://stackoverflow.com/questions/806906/how-do-i-test-if-a-variable-is-a-number-in-bash/806923#806923 -pb_isuint() { case $1 in '' | *[!0-9]* ) return 1;; esac ;} -pb_isint() { case ${1#[-+]} in '' | *[!0-9]* ) return 1;; esac ;} -pb_isunum() { case $1 in '' | . | *[!0-9.]* | *.*.* ) return 1;; esac ;} -pb_isnum() { case ${1#[-+]} in '' | . | *[!0-9.]* | *.*.* ) return 1;; esac ;} - #--- 256 colour functions +# requires pb_number # usage: # source ./pb # printf %b "$(pb_bg 196)$(pb_fg 254) RED $(pb_nc)\n" diff --git a/pb_number b/pb_number new file mode 100755 index 0000000..40a96be --- /dev/null +++ b/pb_number @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +#--- is number functions +# https://stackoverflow.com/questions/806906/how-do-i-test-if-a-variable-is-a-number-in-bash/806923#806923 + +pb_isuint() { case $1 in '' | *[!0-9]* ) return 1;; esac ;} +pb_isint() { case ${1#[-+]} in '' | *[!0-9]* ) return 1;; esac ;} +pb_isunum() { case $1 in '' | . | *[!0-9.]* | *.*.* ) return 1;; esac ;} +pb_isnum() { case ${1#[-+]} in '' | . | *[!0-9.]* | *.*.* ) return 1;; esac ;} |