coreutils icon indicating copy to clipboard operation
coreutils copied to clipboard

mv prints absolute path instead of binary name on error

Open RGBCube opened this issue 8 months ago • 3 comments

uutils mv:

$ mv foo Foo
/run/current-system/sw/bin/mv: cannot move 'foo' to a subdirectory of itself, 'Foo/foo'

GNU mv:

$ mv foo Foo
mv: cannot move 'foo' to a subdirectory of itself, 'Foo/foo'

uutils coreutils mv 0.0.30

RGBCube avatar May 21 '25 23:05 RGBCube

I can't reproduce the test case here, but there is some difference in how the error message is displayed.

With uutils:

$ target/debug/mv a a
target/debug/mv: ...

With GNU:

$ /bin/mv a a
mv: ...

It looks like show! (and less directly, show_error!) is being used incorrectly here, and we should be manually specifying mv over the binary name. @sylvestre is it worth looking into other utils' behavior (or do you know off the top of your head) and potentially making another version of show_error!?

Qelxiros avatar May 22 '25 23:05 Qelxiros

Oh, for the test case you need a case insensitive (sigh) filesystem. I'm on MacOS.

/bin/mv on MacOS guards against this case (there's a special code path to make it work), but GNU coreutils doesn't so we should get an identical error

RGBCube avatar May 23 '25 04:05 RGBCube

I adjusted the test case to be case insensitive, and I do get the same error as you wrote, although it's elided in my previous comment. However, I couldn't reproduce uutils mv printing an absolute path unless it was specified in the command. I think the actual issue here is that GNU mv will never print a path, only the final component (If I move /bin/mv to ./mv2 and produce an error, GNU mv prints mv2).

Qelxiros avatar May 23 '25 21:05 Qelxiros