leo-arch / clifm

The shell-like, command line terminal file manager: simple, fast, extensible, and lightweight as hell.
https://github.com/leo-arch/clifm/wiki
GNU General Public License v2.0
1.29k stars 41 forks source link

file disappears when moving using mv #257

Closed deathtrip closed 9 months ago

deathtrip commented 9 months ago

Describe the bug When you select two files, then go to another directory, and try to move them there using mv instead of m, the first file isn't moved, but just disappears from the selection and the source directory. When you select more files, then you get an error about one of the files not being a directory.

To Reproduce Steps to reproduce the behavior:

  1. select two files
  2. go to another directory
  3. use mv sel
  4. watch as the first selected file disappears

Expected behavior Should work just as when using m to move files, or give an error regardless of how many files are selected.

Desktop:

Additional context Out of curiosity, i would like to know what happens to the "lost" files. Are they deleted? Do they still take up space? Are they moved somewhere else?

When i try copying files using cp sel, nothing happens. No files copied and/or deselected.

leo-arch commented 9 months ago

Hi @deathtrip, thanks for reporting.

Here's the thing:

Unlike c and m, cp and mv are external commands, and as such, they have no added functionality: they take what you throw at them. In this case, sel is actually expanded, but that's all. So the complete command is: cp file1 file2. As you can guess, this command copies file1 into file2 (the same with mv).

Why are c and m different? Whenever you pass sel as the last parameter, these internal commands add an extra final parameter: ., so that the complete command reads as follows: c file1 file2 ., which means: copy both files into the current directory.

Now, you're right in that in might be confusing having these two different behaviors. It would be better indeed to have the c/m behavior for cp/mv as well. I'll take a look at it.

leo-arch commented 9 months ago

Done! cp and mv should behave now exactly as c and m when using the sel keyword (and it's the last parameter). As per the above explanation: cp sel amounts now to cp file1 file2 .

deathtrip commented 9 months ago

Thanks for the quick fix! I think the new behavior is better and less confusing. So i'm gonna close this one.