Unfortunately, that won't help. Single quotes in Bash prevents variable interpolation. The ! will need to be escaped and not quoted in any manner, or, preferably, don't use that kind of special character as a password (this is why.. also don't use these either:
% * @ # $ ^ & ( ) ' " < > /
Each of these have some special meaning in Bash and should be avoided. Bash is finicky about quotes and special characters and escapes:
[Expert@cpmgmt:0]# PASSWORD="Foo\!Bar"
[Expert@cpmgmt:0]# echo $PASSWORD
Foo\!Bar
[Expert@cpmgmt:0]# PASSWORD=Foo\!Bar
[Expert@cpmgmt:0]# echo $PASSWORD
Foo!Bar
You can prompt for a password with a special character just fine:
[Expert@moon:0]# read -s -p "Password: " PASSWORD;echo
Password:
[Expert@moon:0]# echo "$PASSWORD"
FOO!BAR
It's best to just avoid the whole ordeal, tho.
Besides, you never know what the back-end developer is doing to your input string, either. 🙁 You know those apps... the ones that do a SQL query somewhere and you throw in a "%" character. 😄
Such as this little gem that's always good for a laugh:
[Expert@cpmgmt:0]# FOO="3/0"
[Expert@cpmgmt:0]# if (( $FOO )); then echo bar; fi
-bash: 3/0 : division by 0 (error token is "0 ")