01 / 06
Two kinds of quote
Have you ever wondered why there are two kinds of quote? There is a proper difference.
~ $ echo 'a $HOME'a $HOME~ $ echo "a $HOME"a /home/learnerThe same thing wrapped, and different results.
| How you wrap it | What the shell does |
|---|---|
'...' (single) | rewrites nothing; hands it over as seen |
"..." (double) | rewrites $; keeps spaces safe |
| unwrapped | rewrites $ and *, and splits on spaces |
Remember it this way.
single = guards everything (strong)double = guards only the spaces (ordinary)none = guards nothing (weak)The view this chapter has held from the start works here too. It is the shell doing the rewriting. Quotes are the signal to that shell saying "hands off".
And quotes never reach the command. The shell strips the marks themselves before handing anything over.