Explaining the issue using examples ...
Demonstrates that single quotes after -chapters become escaped when the variable expands (I did not expect this):
prompt@ubuntu:/my/scripts$ cat test1.sh
actions="--tags all:"
actions+=" --chapters ''"
mkvpropedit "$1" $actions
prompt@ubuntu:/my/scripts$ ./test1.sh some.mkv
Error: Could not open '''' for reading.
And now for some reason, mkvpropedit gets double quotes as part of the file name (I didn't expect this either):
prompt@ubuntu:/my/scripts$ cat test1x.sh
#!/bin/bash
command="mkvpropedit \"$1\""
command+=" --tags all:"
command+=" --chapters ''"
echo "$command"
$command
prompt@ubuntu:/my/scripts$ ./test1x.sh some.mkv
mkvpropedit "some.mkv" --tags all: --chapters ''
Error: Could not open '''' for reading.
The above echo'd command seems correct. Putting the same text in another script gives the expected result:
prompt@ubuntu:/my/scripts$ cat test2.sh
mkvpropedit "$1" --tags all: --chapters ''
prompt@ubuntu:/my/scripts$ ./test2.sh some.mkv
The file is being analyzed.
The changes are written to the file.
Done.
Can someone explain why quotation marks do not behave as expected. I found that searching for this issue is difficult because there are so many other quotes on the Internet. I don’t even know how to explain the question without examples.
, - - , , , , . , - script . , .
.