Re: inotifywait in bash script: space
- Date: Sat, 02 Dec 2017 17:53:20 +0100
- From: "Thomas Schmitt" <scdbackup@xxxxxxx>
- Subject: Re: inotifywait in bash script: space
> MYCOMMAND = "inotifywait -qqr -e create \"$MYDIR\""
I assume you later execute this by
(and that you have no blanks around the '=').
> echo shows the command correctly
Not for me. I get already riddled in dialog:
$ Y="a b c"
$ X="echo \"$Y\""
"a b c"
Obviously "echo" sees three arguments here:
I get the expected result by
$ eval "$X"
a b c
Still being riddled, my theory is that bash variable substitution happens
after quotation mark interpretation. So the marks inserted by $X stay
as they are.
The command "eval" performs a full shell parser interpretation after "$X"
got evaluated. (This might have other undesirable effects ... ponder ...)
Have a nice day :)