897f4179b4bcf1a50d39f30e2f5eaabcb7cc7846 — Philip K 2 months ago 73fe25b
Fixed linting issues in add_user.sh
1 files changed, 14 insertions(+), 9 deletions(-)

M add_user.sh
M add_user.sh => add_user.sh +14 -9
@@ 2,19 2,21 @@
 # A short shell script to add a new user to the user file
 
 if [ ! "$USERF" ]; then
-    echo "\$USERF isn't defined" &1>2
+    echo "\$USERF isn't defined" 1>&2
     exit 1
 fi
 
 if [ ! -w "$USERF" ]; then
-    echo "$USERF isn't writable" &1>2
+    echo "$USERF isn't writable" 1>&2
     exit 2
 fi
 
-read -p "User name: " USER
+echo "User name: "
+read -r USER
 if grep "^$USER:" "$USERF" -q; then
     echo "$USER already specified in $USERF"
-    read -p "Do you want to replace it? [yes] " ANS
+	echo "Do you want to replace it? [yes] "
+    read -r ANS
     if [ "$ANS" = "yes" ]; then
 	sed -i "/$USER/d" "$USERF"
     else


@@ 22,9 24,12 @@ if grep "^$USER:" "$USERF" -q; then
 	exit 0
     fi
 fi
-read -p "Password: " PASSW
-read -p "Email: " EMAIL
-read -p "Description: " DESC
+echo "Password: "
+read -r
+echo "Email: "PASSW
+read -r
+echo "Description: "EMAIL
+read -r DESC
 
-HASH=$(echo -n "$USER:$PASS" | sha256sum | cut -d" " -f1)
-echo "$USER:$HASH:$EMAIL:$DESC" >> $USERF
+HASH="$(printf "%s:%s" "$USER" "$PASS" | sha256sum | cut -d" " -f1)"
+echo "$USER:$HASH:$EMAIL:$DESC" >> "$USERF"