@@ -24,6 +24,45 @@ fn test_invalid_arg() {
2424 new_ucmd ! ( ) . arg ( "--definitely-invalid" ) . fails_with_code ( 1 ) ;
2525}
2626
27+ #[ test]
28+ fn test_version_no_path ( ) {
29+ use std:: process:: Command ;
30+ use uutests:: get_tests_binary;
31+
32+ // This test verifies that when an individual utility binary is invoked with its full path,
33+ // the version output shows just "mkdir", not the full path like "/path/to/mkdir".
34+ //
35+ // Note: The multicall binary (coreutils) doesn't have this issue because it reads
36+ // the utility name from ARGV[1], not ARGV[0]. This bug only affects individual binaries.
37+
38+ let tests_binary = get_tests_binary ! ( ) ;
39+ let mkdir_binary_path = std:: path:: Path :: new ( tests_binary)
40+ . parent ( )
41+ . unwrap ( )
42+ . join ( "mkdir" ) ;
43+
44+ // If the individual mkdir binary exists, test it
45+ if mkdir_binary_path. exists ( ) {
46+ // Invoke the individual mkdir binary with its full path
47+ let output = Command :: new ( & mkdir_binary_path)
48+ . arg ( "--version" )
49+ . output ( )
50+ . expect ( "Failed to execute mkdir binary" ) ;
51+
52+ let stdout = String :: from_utf8_lossy ( & output. stdout ) ;
53+ assert ! ( stdout. starts_with( "mkdir (uutils coreutils)" ) ) ;
54+ } else {
55+ // If only multicall binary exists, test that (it should already pass)
56+ let output = Command :: new ( tests_binary)
57+ . args ( [ "mkdir" , "--version" ] )
58+ . output ( )
59+ . expect ( "Failed to execute mkdir via multicall binary" ) ;
60+
61+ let stdout = String :: from_utf8_lossy ( & output. stdout ) ;
62+ assert ! ( stdout. starts_with( "mkdir (uutils coreutils)" ) ) ;
63+ }
64+ }
65+
2766#[ test]
2867fn test_no_arg ( ) {
2968 new_ucmd ! ( )
0 commit comments