The outermost string must have double quotes for string substitution to work in nested single quote strings

This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the bash category.

Last Updated: 2024-11-23

If the outer quotes are double, string substitution will happen even inside nested single quotes. But not the inverse:

# works
log stream --info --predicate "process == '$process_name'"
# does not work
log stream --info --predicate 'process == "$process_name"'