On Sat, 2 Dec 2017, B.M. wrote:
Dear all,
not a Debian specific question, but I hope to get an answer here...
I try to use inotifywait in a bash script to block until a file in a directory
gets changed. Then the script should continue. That's working well unless the
path I hand over to inotifywait contains spaces.
I already tried to escape them like so:
MYCOMMAND = "inotifywait -qqr -e create \"$MYDIR\""
where MYDIR is something like "/tmp/test dir" but although echo shows the
command correctly and putting the very same command in a shell just works, as
part of my script it doesn't work. (I don't want to get paths back from
inotifywait.)
Thanks for any pointers towards clarification and help.
I don't know anything about inotifywait. Maybe that doesn't matter?
$ foo="filename with spaces"
$ echo content > "$foo"
$ command=(cat "$foo")
$ "${command[@]}" # This will work:
content
$ ${command[@]} # but do notice that this will not work:
cat: filename: No such file or directory
cat: with: No such file or directory
cat: spaces: No such file or directory
Best,
Bernd