Unquoted right-hand sides in Bash conditional expressions can lead to unexpected glob matching behavior. To prevent this, always quote the right-hand side of equality operators in square bracket constructs.
1
2# Noncompliant: Unquoted variable on RHS can cause issues with special characters.
3password="my[pass]word"
4if [[ $entered_password = $password ]]; then
5 echo "Password correct"
6fi1
2# Compliant: Quoted RHS prevents glob interpretation, ensuring exact string comparison.
3password="my[pass]word"
4if [[ $entered_password = "$password" ]]; then
5 echo "Password correct"
6fi