Hacker News new | past | comments | ask | show | jobs | submit login

> rm, cp require -r, mv doesn’t, no auto-directory creation for mv

These are all like that on purpose.

mv doesn't have -r because it's a safety feature for rm and cp, since deleting or copying an entire directory is expensive so you should have to specify it explicitly. Moving a directory is really just renaming it, which isn't expensive when it's on the same filesystem (and it usually is).

The most common case for the destination directory not existing when moving something is a typo in the path. Then you'd end up creating a directory you didn't intend to, possibly on a filesystem you didn't intend to, and moving all the other arguments over there. It could be useful to make it possible to explicitly specify that you want this, similar to mkdir -p, but you could add that to the existing mv without breaking anything.




An inspectable and reliable dry run option and/or an interactive confirmation would solve some of these problems.


Not really. Dry run is useful for complex commands you're not sure the effects of. These options are so that when you intend to type:

rm /home/john/some/file.txt

But you accidentally type:

rm /home/john some/file.txt

It says:

rm: cannot remove '/home/john': Is a directory

Instead of john not having a home directory anymore.

And people aren't going to use a dry run option or interactive confirmation every time they run a simple command like that.


I was thinking more of

- listing how many files/directories would be moved

- listing how many files/directories would be overwritten

- telling whether the transfer will cross drives (especially for mv)

reasonably speaking this should not be included in the base posix cp and mv, but could be maybe provided as intrinsics in bash for example


The expensiveness is a bit naïve nowadays. Same for assuming typos by default.


Deleting entire directories by accident is expensive in more than computing resources.

And copying them is still actually expensive. Data expands to consume all available space. Accidentally copy a 16TB directory structure and you're going to max out the I/O on your machine for hours and maybe run it out of space. It's not a big ask to type two characters to confirm that you want to do that.


It’s just inconsistent. There are a infinite possible typos that range from expensive to destructive.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: