Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

What does that do?


Great question, I was wondering how if anyone would be interested to ask!

tl;dr: Basically, it's a way to say "do this operation inside this folder".

For example, if you do

  cp -r A B
an A is a directory, the behavior is different depending on whether B already exists or not. If B is a file, you get an error. If B is a directory, then it tries to make a copy of A inside B (i.e. B/A). If B doesn't exist, B itself becomes a copy of A.

This is pretty terrible behavior. The question is how do you avoid this. On Linux, if you always want A to be overlaid on top of B, then you can do

  cp -T A B
which disambiguates in favor of overlay. On the other hand, if you always want A to be copied inside B, then you can do

  cp A B/.
which disambiguates in favor of creating a subdirectory (and gives you an error if B doesn't exist).

Note: I have not checked whether this behavior is uniform across other POSIX systems, but I hope it is.




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

Search: