Audit hostname(1)
1) Be strict about argc 2) Fix a small error in the manpage
This commit is contained in:
parent
f20075b0bc
commit
80a394139a
2
README
2
README
|
@ -35,7 +35,7 @@ The following tools are implemented ('*' == finished, '#' == UTF-8 support,
|
||||||
#* fold yes none
|
#* fold yes none
|
||||||
=* grep yes none
|
=* grep yes none
|
||||||
=* head yes none
|
=* head yes none
|
||||||
=* hostname non-posix none
|
=*| hostname non-posix none
|
||||||
=* kill yes none
|
=* kill yes none
|
||||||
=*| link yes none
|
=*| link yes none
|
||||||
=* ln yes none
|
=* ln yes none
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
.Dd January 30, 2015
|
.Dd February 28, 2015
|
||||||
.Dt HOSTNAME 1
|
.Dt HOSTNAME 1
|
||||||
.Os sbase
|
.Os sbase
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
|
|
|
@ -21,13 +21,16 @@ main(int argc, char *argv[])
|
||||||
usage();
|
usage();
|
||||||
} ARGEND;
|
} ARGEND;
|
||||||
|
|
||||||
if (argc < 1) {
|
if (!argc) {
|
||||||
if (gethostname(host, sizeof(host)) < 0)
|
if (gethostname(host, sizeof(host)) < 0)
|
||||||
eprintf("gethostname:");
|
eprintf("gethostname:");
|
||||||
puts(host);
|
puts(host);
|
||||||
} else {
|
} else if (argc == 1) {
|
||||||
if (sethostname(argv[0], strlen(argv[0])) < 0)
|
if (sethostname(argv[0], strlen(argv[0])) < 0)
|
||||||
eprintf("sethostname:");
|
eprintf("sethostname:");
|
||||||
|
} else {
|
||||||
|
usage();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user