yellowman / nsh

OpenBSD networking configuration shell
http://www.nmedia.net/nsh/
Other
174 stars 27 forks source link

Missing newline char after header for `show interface status` #145

Closed ryan-sg closed 2 months ago

ryan-sg commented 2 months ago

I noticed a missing \n, causing the loopback interface to appear on the same line as the header:

% Name    Status  Link        Routing-Domain  Media  lo0     up      -                        0  
  vio0    up      active                   0  Ethernet 
  vio1    down    active                   0  Ethernet 
  vio2    down    active                   0  Ethernet 
  vio3    up      active                   0  Ethernet 
  enc0    down    active                   0  
  pflog0  up      -                        0  
  pair0   up      active                   0  Ethernet 
  pair1   up      no carrier               2  Ethernet 
  lo2     down    -                        2  
  pair2   up      active                   3  Ethernet 
  lo3     down    -                        3  

The following patch seems to be all that is needed. Troubles with github and ssh keys right now, not worth the time to try and make a pull request over 2 chars :-)

index 4ce758e..48cb569 100644
--- a/if.c
+++ b/if.c
@@ -302,7 +302,7 @@ show_int(int argc, char **argv, FILE *outfile)
                        close(ifs);
                        return 0;
                }
-               fputs("% Name    Status  Link        Routing-Domain  Media",
+               fputs("% Name    Status  Link        Routing-Domain  Media\n",
                    outfile);
                for (ifnp = ifn_list; ifnp->if_name != NULL; ifnp++)
                        show_int_status(ifnp->if_name, ifs, outfile);

Results:

% Name    Status  Link        Routing-Domain  Media
  lo0     up      -                        0  
  vio0    up      active                   0  Ethernet 
  vio1    down    active                   0  Ethernet 
  vio2    down    active                   0  Ethernet 
  vio3    up      active                   0  Ethernet 
  enc0    down    active                   0  
  pflog0  up      -                        0  
  pair0   up      active                   0  Ethernet 
  pair1   up      no carrier               2  Ethernet 
  lo2     down    -                        2  
  pair2   up      active                   3  Ethernet 
  lo3     down    -                        3  
smytht commented 2 months ago

thanks Ryan, we repeated the issue tried your code fix and it worked as you specified fixed in commit f2d2d8611103b65f1d2fde42d1cdc5c1c23dac92

thank you for your feedback and your help it is very very much appreciated

smytht commented 2 months ago

fixed in f2d2d8611103b65f1d2fde42d1cdc5c1c23dac92