summaryrefslogtreecommitdiff
path: root/rushs/tinyprintf/alphanum
diff options
context:
space:
mode:
authorMartial Simon <msimon_fr@hotmail.com>2025-09-15 01:08:27 +0200
committerMartial Simon <msimon_fr@hotmail.com>2025-09-15 01:08:27 +0200
commitc9b6b9a5ca082fe7c1b6f58d7713f785a9eb6a5c (patch)
tree3e4f42f93c7ae89a364e4d51fff6e5cec4e55fa9 /rushs/tinyprintf/alphanum
add: graphs et rushs
Diffstat (limited to 'rushs/tinyprintf/alphanum')
-rwxr-xr-xrushs/tinyprintf/alphanum/alphanum.sh53
1 files changed, 53 insertions, 0 deletions
diff --git a/rushs/tinyprintf/alphanum/alphanum.sh b/rushs/tinyprintf/alphanum/alphanum.sh
new file mode 100755
index 0000000..e4c5aee
--- /dev/null
+++ b/rushs/tinyprintf/alphanum/alphanum.sh
@@ -0,0 +1,53 @@
+#!/bin/sh
+
+letters()
+{
+ grepped=$(echo "$1" | grep -E "^[a-zA-Z]+$")
+ [ "$1" = "$grepped" ] && return 0 || return 1
+}
+
+empty()
+{
+ if echo "$1" | grep -qE '^[[:space:]]+$'; then
+ return 0
+ fi
+ return 1
+}
+
+digit()
+{
+ grepped=$(echo "$1" | grep -E "^[0-9]$")
+ [ "$1" = "$grepped" ] && return 0 || return 1
+}
+
+number()
+{
+ grepped=$(echo "$1" | grep -E "^[1-9][0-9]+$")
+ [ "$1" = "$grepped" ] && return 0 || return 1
+}
+
+alph()
+{
+ grepped=$(echo "$1" | grep -E "^[a-zA-Z0-9]+$")
+ [ "$1" = "$grepped" ] && return 0 || return 1
+}
+
+while IFS='' read -r str; do
+ if [ -z "$str" ]; then
+ echo it is empty
+ continue
+ elif letters "$str"; then
+ echo "it is a word"
+ elif number "$str"; then
+ echo "it is a number"
+ elif digit "$str"; then
+ echo "it is a digit"
+ elif empty "$str"; then
+ echo "it is empty"
+ elif alph "$str"; then
+ echo "it is an alphanum"
+ else
+ echo "it is too complicated"
+ exit
+ fi
+done