Append char if only numeric

This commit is contained in:
Douglas Barone 2023-03-01 12:53:47 -04:00
parent 1fad5689af
commit cabeaafab5
2 changed files with 12 additions and 0 deletions

View File

@ -25,6 +25,12 @@ if [[ $USERNAME =~ " " ]]; then
exit 1
fi
# Check if $USERNAME starts with a number
if [[ $USERNAME =~ ^[0-9] ]]; then
echo "Username cannot start with a number. Appending 'u' to the beginning of the username..."
USERNAME="u$USERNAME"
fi
NAME=$(echo $NAME | tr "[A-Z]" "[a-z]" | sed -e "s/\b\(.\)/\u\1/g")
# Check if $USERNAME is already in use

View File

@ -25,6 +25,12 @@ if [[ $USERNAME =~ " " ]]; then
exit 1
fi
# Check if $USERNAME starts with a number
if [[ $USERNAME =~ ^[0-9] ]]; then
echo "Username cannot start with a number. Appending 'u' to the beginning of the username..."
USERNAME="u$USERNAME"
fi
NAME=$(echo $NAME | tr "[A-Z]" "[a-z]" | sed -e "s/\b\(.\)/\u\1/g")
# Check if $USERNAME is already in use