Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • Thanks. i noticed something perhaps incorrect. and changed it. Commented Aug 8, 2017 at 17:38
  • @Tim could you explain your change? I think it’s wrong... Commented Aug 8, 2017 at 17:39
  • When a shell sees var=3 bash -c "/bin/echo '$var'", the single quotes within the double quotes are literal, so don't prevent parameter expansion $var in the shell, where var is unset. So the child shell which the shell forks to execute the double quoted content sees /bin/echo ''. See Arrow's answer. Commented Aug 8, 2017 at 17:44
  • Still not correct. the current shell changes "/bin/echo '$var'" to /bin/echo '' (assuming var is undefined). parameter expansion happens before quote removal. Commented Aug 8, 2017 at 18:59
  • @Tim huh, yes, that’s what I meant to write :-/. Commented Aug 8, 2017 at 19:46