The reason is there are bugs in Bash when you have characters like [ or { or \ or / in a string.
By definition these should not happen but they do. Here is an example from a program I was working on yesterday. The project has a folder for a batch of temporary files. Each time the program is run the folder has to be cleaned out. (No, the system
/tmp will not work for this purpose.)
Note: Because these are errors in the language we should always say which version it is. I am using Bash 4.2(37).
Anyway, we enter my program after the location of the temporary folder has is stored in a variable named
$temp:
Code: Select all
temp=$BasePath"/.temp"
rm $temp"/*"
That is rejected wth an error message. But it works in the command line.
After too much time I finally gave it this syntax:
Code: Select all
temp=$BasePath"/.temp"
tempfiles=$temp"/*"
rm $tempfiles
That works OK.
(Disclosure: Actually the program has
rm -f $tempfiles so it won't annoy me with an error message that the folder is already empty. I simplified to illustrate. The above examples work the same with or without the
-f option.)
Possibly changing the order of your arguments to
}{\; would make a difference.