File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -328,7 +328,14 @@ static UTIL_NAME: LazyLock<String> = LazyLock::new(|| {
328328 let is_man = usize:: from ( ARGV [ base_index] . eq ( "manpage" ) ) ;
329329 let argv_index = base_index + is_man;
330330
331- ARGV [ argv_index] . to_string_lossy ( ) . into_owned ( )
331+ // Strip directory path to show only utility name
332+ // (e.g., "mkdir" instead of "./target/debug/mkdir")
333+ // in version output, error messages, and other user-facing output
334+ std:: path:: Path :: new ( & ARGV [ argv_index] )
335+ . file_name ( )
336+ . unwrap_or ( & ARGV [ argv_index] )
337+ . to_string_lossy ( )
338+ . into_owned ( )
332339} ) ;
333340
334341/// Derive the utility name.
Original file line number Diff line number Diff line change @@ -24,6 +24,17 @@ 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+ let result = new_ucmd ! ( ) . arg ( "--version" ) . succeeds ( ) ;
30+ let stdout = result. stdout_str ( ) ;
31+
32+ assert ! ( stdout. starts_with( "mkdir (uutils coreutils)" ) ) ;
33+
34+ let first_line = stdout. lines ( ) . next ( ) . unwrap ( ) ;
35+ assert ! ( !first_line. starts_with( "./" ) && !first_line. starts_with( '/' ) ) ;
36+ }
37+
2738#[ test]
2839fn test_no_arg ( ) {
2940 new_ucmd ! ( )
You can’t perform that action at this time.
0 commit comments