@@ -242,7 +242,7 @@ userinfo () {
242
242
while true
243
243
do
244
244
read -r -p " Please enter username: " username
245
- if [[ " ${ username,,} " =~ ^[a-z_]( [a-z0-9_-]{0,31}| [a-z0-9_-]{0,30} \$ )$ ]]
245
+ if echo " $username " | grep -qE ' ^[a-z_][a-z0-9_-]{0,31}( \$)?$ '
246
246
then
247
247
break
248
248
fi
@@ -267,20 +267,23 @@ userinfo () {
267
267
# Loop through user input until the user gives a valid hostname, but allow the user to force save
268
268
while true
269
269
do
270
- read -r -p " Please name your machine: " name_of_machine
271
- # hostname regex (!!couldn't find spec for computer name!!)
272
- if [[ " ${name_of_machine,,} " =~ ^[a-z][a-z0-9_.-]{0,62}[a-z0-9]$ ]]
270
+ printf " %b" " Please name your machine: "
271
+ read -r machine_name
272
+
273
+ lower_machine_name=$( echo " $machine_name " | tr ' [:upper:]' ' [:lower:]' )
274
+ if echo " $lower_machine_name " | grep -q ' ^[a-z][a-z0-9_.-]\{0,62\}[a-z0-9]$'
273
275
then
274
276
break
275
277
fi
276
278
# if validation fails allow the user to force saving of the hostname
277
- read -r -p " Hostname doesn't seem correct. Do you still want to save it? (y/n)" force
278
- if [[ " ${force,,} " = " y" ]]
279
+ printf " %b" " Hostname doesn't seem correct. Do you still want to save it? (y/N) "
280
+ read -r force
281
+ if [[ " $force " == " y" || " $force " == " Y" ]]
279
282
then
280
283
break
281
284
fi
282
285
done
283
- export NAME_OF_MACHINE=$name_of_machine
286
+ export NAME_OF_MACHINE=$lower_machine_name
284
287
}
285
288
286
289
# Starting functions
@@ -376,7 +379,7 @@ subvolumesetup () {
376
379
mountallsubvol
377
380
}
378
381
379
- if [[ " ${ DISK} " =~ " nvme" ]] ; then
382
+ if echo " $DISK " | grep -q " nvme" ; then
380
383
partition2=${DISK} p2
381
384
partition3=${DISK} p3
382
385
else
@@ -670,4 +673,4 @@ sed -i 's/^%wheel ALL=(ALL:ALL) NOPASSWD: ALL/# %wheel ALL=(ALL:ALL) NOPASSWD: A
670
673
# Add sudo rights
671
674
sed -i 's/^# %wheel ALL=(ALL) ALL/%wheel ALL=(ALL) ALL/' /etc/sudoers
672
675
sed -i 's/^# %wheel ALL=(ALL:ALL) ALL/%wheel ALL=(ALL:ALL) ALL/' /etc/sudoers
673
- EOF
676
+ EOF
0 commit comments