>>45It's mostly that shell scripts are a pain compared to all other languages that are still in use. Even plain C might be easier for this. Shell is a language that's based on something that was designed for interactive use 45 years ago, and it can't be overhauled for compatibility reasons.
If $f is a variable, you would expect that
rm $f
would run rm with the contents of $f as its first argument. However, if $f happens to contain spaces, it runs all the different parts of $f as different arguments to the command. If you want to avoid that, you can use this:
rm "$f"
Shell also has the $() syntax, which runs a command and substitutes for the output of that command. If that command outputs a list of filenames, there's no way to tell whether a space is part of the filename or one of the separators.
rm "$(cat file)"
Post too long. Click here to view the full text.