sbase

suckless unix tools
git clone git://git.2f30.org/sbase
Log | Files | Refs | README | LICENSE

commit 80a394139a45501c8f8ca4f1b1315a343fb1c999
parent f20075b0bca57d0037b5680ab130272af30ffa4b
Author: FRIGN <dev@frign.de>
Date:   Sat, 28 Feb 2015 21:22:55 +0100

Audit hostname(1)

1) Be strict about argc
2) Fix a small error in the manpage

Diffstat:
MREADME | 2+-
Mhostname.1 | 4++--
Mhostname.c | 7+++++--
3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/README b/README @@ -35,7 +35,7 @@ The following tools are implemented ('*' == finished, '#' == UTF-8 support, #* fold yes none =* grep yes none =* head yes none -=* hostname non-posix none +=*| hostname non-posix none =* kill yes none =*| link yes none =* ln yes none diff --git a/hostname.1 b/hostname.1 @@ -1,4 +1,4 @@ -.Dd January 30, 2015 +.Dd February 28, 2015 .Dt HOSTNAME 1 .Os sbase .Sh NAME @@ -13,6 +13,6 @@ sets the current host name to .Ar name . If no .Ar name -is given, the current hostname is written to stdout. +is given, the current host name is written to stdout. .Sh SEE ALSO .Xr hostname 7 diff --git a/hostname.c b/hostname.c @@ -21,13 +21,16 @@ main(int argc, char *argv[]) usage(); } ARGEND; - if (argc < 1) { + if (!argc) { if (gethostname(host, sizeof(host)) < 0) eprintf("gethostname:"); puts(host); - } else { + } else if (argc == 1) { if (sethostname(argv[0], strlen(argv[0])) < 0) eprintf("sethostname:"); + } else { + usage(); } + return 0; }