I have a problem. I tried many options how to prevent my parameter from escaping with "&" character. Nothing works for unfortunately. Do You have any option how to prevent my string and allow only [a-z]?? I tried everything on stack overflow and still nothing.
That's the script example:
#!/bin/bash/
initials=$1
initials_buffer(){
if [[ ${#initials} -ge 5 ]] ; then echo "Error: Bad initials. Too long!!!" ; exit 0
elif [[ ${#initials} -le 3 ]] ; then echo "Error: Bad initials. Too short!!!" ; exit 0
elif [[ $initials == *['!'@#\$%^\&*()_+]* ]] ; then echo "Hey!! No special chars" ; exit 0
else
echo "properly string"
fi
}
initials_buffer
exit 0
And that's results where i have too short, too long and i escaped from script to whoami command as a root.
┌──(rootkali)-[/]
└─# bash test.sh pr
Error: Bad initials. Too short!!!
┌──(rootkali)-[/]
└─# bash test.sh praaaaaa
Error: Bad initials. Too long!!!
┌──(rootkali)-[/]
└─# bash test.sh pr*n
Hey!! No special chars
┌──(rootkali)-[/]
└─# bash test.sh pra& whoami
[1] 7951
root
Error: Bad initials. Too short!!!
[1] + done bash test.sh pra
Every char prevention is working except "&", "(" and ")"..