@@ -24,6 +24,47 @@ 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+ let first_line = stdout. lines ( ) . next ( ) . unwrap_or ( "" ) ;
54+
55+ assert ! ( stdout. starts_with( "mkdir (uutils coreutils)" ) ) ;
56+ } else {
57+ // If only multicall binary exists, test that (it should already pass)
58+ let output = Command :: new ( tests_binary)
59+ . args ( [ "mkdir" , "--version" ] )
60+ . output ( )
61+ . expect ( "Failed to execute mkdir via multicall binary" ) ;
62+
63+ let stdout = String :: from_utf8_lossy ( & output. stdout ) ;
64+ assert ! ( stdout. starts_with( "mkdir (uutils coreutils)" ) ) ;
65+ }
66+ }
67+
2768#[ test]
2869fn test_no_arg ( ) {
2970 new_ucmd ! ( )
0 commit comments