2 ms·
Tar is one example of a command with dubious usage syntax. But how about cp? cp a.txt b/c/d Will this create a new file "b/c/d/a.txt", or will it create a
by amelius 8y ago
Tar is one example of a command with dubious usage syntax. But how about cp?
cp a.txt b/c/d
Will this create a new file "b/c/d/a.txt", or will it create a new file "b/c/d"? It's not clear, and depends on the circumstances (if a directory b/c/d exists). There's a flag to control the behavior, but nobody uses it often, so nobody remembers that flag. The best way to assert that "d" is a directory is by adding a trailing slash, but there's no similar way to assert that "d" should be a file. I suspect that there are many bash scripts that are essentially broken because of this problem.
Rsync has a similar problem.
- andrei-n 8y agoFor cp you can use -nv. I discovered it two days ago. It displays what will happen without doing it.