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*

4
  • 10
    You can't embed single-quotes inside single-quotes in shell. in place of '\0', try '\''\0'\''. Or just use double-quotes around the entire sub-shell command (but you'll need to escape the $ in $? as \$? so that the shell you're running it from doesn't interpolate it) Commented Jul 21 at 13:48
  • 4
    BTW, see Why does my shell script choke on whitespace or other special characters?, $VAR vs ${VAR} and to quote or not to quote and When is double-quoting necessary? for more info about shell quoting Commented Jul 21 at 13:53
  • 2
    that's not a subshell Commented Jul 22 at 13:10
  • 1
    Use ShellCheck to find problems like this. It flags this as "This \0 will be a regular '0' in this context." and "This word is outside of quotes." Commented Jul 23 at 13:50