Skip to content

Files

Latest commit

 

History

History
31 lines (20 loc) · 819 Bytes

SC2026.md

File metadata and controls

31 lines (20 loc) · 819 Bytes

Pattern: Word is outside of quotes in shell script

Issue: -

Description

There is no way to nest single quotes. However, single quotes can be placed literally in double quotes, so you can instead concatenate a single quoted string and a double quoted string.

Example of incorrect code:

#                   v---match--v
alias server_uptime='ssh $host 'uptime -p''
#                                        ^^

This is the same thing as alias server_uptime='ssh $host uptime' -p.

Example of correct code:

#                   v--match---v
alias server_uptime='ssh $host '"'uptime -p'"
#                               ^---match---^ 

This results in an alias with embedded single quotes.

Further Reading