commit 9f64a4cb7de9d397aa39f4e2dd0d284d5ca8b59e parent 6ff379b4d5bc1669fa8c63a2de4916647b1a459f Author: hhvn <hayden@haydenvh.com> Date: Tue, 2 Feb 2021 23:11:01 +0000 bin/login.sh: truncate 11+ length usernames Diffstat:
M | bin/login.sh | | | 6 | +++++- |
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/bin/login.sh b/bin/login.sh @@ -21,10 +21,14 @@ login(){ echo "Registration" echo info "Only a-z0-9 are accepted in usernames" + info "Max-length of 10 characters" prompt "user" user origuser="$user" user=$(echo "$user" | tr -dc 'a-z0-9') - echo "$origuser" | grep '[^a-z0-9]' >/dev/null && info "username changed to: $user" + [ "$origuser" != "$user" ] && info "username changed to: $user" + origuser="$user" + user=$(echo "$user" | cut -c-10) + [ "$origuser" != "$user" ] && info "username truncated to: $user" checknuser "$user" 2>/dev/null || { anykey return 1