View | Details | Raw Unified | Return to bug 212875 | Differences between
and this patch

Collapse All | Expand All

(-)hostname.1 (-1 / +3 lines)
Lines 37-43 Link Here
37
.Nd set or print name of current host system
37
.Nd set or print name of current host system
38
.Sh SYNOPSIS
38
.Sh SYNOPSIS
39
.Nm
39
.Nm
40
.Op Fl fs
40
.Op Fl fsd
41
.Op Ar name-of-host
41
.Op Ar name-of-host
42
.Sh DESCRIPTION
42
.Sh DESCRIPTION
43
The
43
The
Lines 62-67 Link Here
62
.It Fl s
62
.It Fl s
63
Trim off any domain information from the printed
63
Trim off any domain information from the printed
64
name.
64
name.
65
.It Fl d
66
Only print domain information.
65
.El
67
.El
66
.Sh SEE ALSO
68
.Sh SEE ALSO
67
.Xr gethostname 3 ,
69
.Xr gethostname 3 ,
(-)hostname.c (-2 / +11 lines)
Lines 54-64 Link Here
54
int
54
int
55
main(int argc, char *argv[])
55
main(int argc, char *argv[])
56
{
56
{
57
	int ch, sflag;
57
	int ch, sflag, dflag;
58
	char *p, hostname[MAXHOSTNAMELEN];
58
	char *p, hostname[MAXHOSTNAMELEN];
59
59
60
	sflag = 0;
60
	sflag = 0;
61
	while ((ch = getopt(argc, argv, "fs")) != -1)
61
	dflag = 0;
62
	while ((ch = getopt(argc, argv, "fsd")) != -1)
62
		switch (ch) {
63
		switch (ch) {
63
		case 'f':
64
		case 'f':
64
			/*
65
			/*
Lines 70-75 Link Here
70
		case 's':
71
		case 's':
71
			sflag = 1;
72
			sflag = 1;
72
			break;
73
			break;
74
		case 'd':
75
			dflag = 1;
76
			break;
73
		case '?':
77
		case '?':
74
		default:
78
		default:
75
			usage();
79
			usage();
Lines 91-96 Link Here
91
			if (p != NULL)
95
			if (p != NULL)
92
				*p = '\0';
96
				*p = '\0';
93
		}
97
		}
98
		else if (dflag) {
99
			p = strchr(hostname, '.');
100
			if (p != NULL)
101
				strcpy(hostname,++p);
102
		}
94
		(void)printf("%s\n", hostname);
103
		(void)printf("%s\n", hostname);
95
	}
104
	}
96
	exit(0);
105
	exit(0);

Return to bug 212875