File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -177,8 +177,10 @@ fn display_hostname(matches: &ArgMatches) -> UResult<()> {
177177 } else {
178178 println ! ( "{}" , & hostname[ ci. 0 + 1 ..] ) ;
179179 }
180- return Ok ( ( ) ) ;
180+ } else if matches. get_flag ( OPT_SHORT ) {
181+ println ! ( "{hostname}" ) ;
181182 }
183+ return Ok ( ( ) ) ;
182184 }
183185
184186 println ! ( "{hostname}" ) ;
Original file line number Diff line number Diff line change @@ -37,3 +37,16 @@ fn test_hostname_full() {
3737fn test_invalid_arg ( ) {
3838 new_ucmd ! ( ) . arg ( "--definitely-invalid" ) . fails_with_code ( 1 ) ;
3939}
40+
41+ #[ test]
42+ fn test_hostname_domain_empty ( ) {
43+ let fqdn = new_ucmd ! ( ) . arg ( "-f" ) . succeeds ( ) ;
44+ let short = new_ucmd ! ( ) . arg ( "-s" ) . succeeds ( ) ;
45+ let domain = new_ucmd ! ( ) . arg ( "-d" ) . succeeds ( ) ;
46+ let domain_short = new_ucmd ! ( ) . arg ( "-sd" ) . succeeds ( ) ;
47+
48+ if fqdn. stdout ( ) == short. stdout ( ) {
49+ assert ! ( domain. stdout( ) . is_empty( ) ) ;
50+ assert ! ( domain_short. stdout( ) . is_empty( ) ) ;
51+ }
52+ }
You can’t perform that action at this time.
0 commit comments