From owner-svn-src-all@freebsd.org Wed Nov 9 04:42:19 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E013FC3732E; Wed, 9 Nov 2016 04:42:19 +0000 (UTC) (envelope-from araujobsdport@gmail.com) Received: from mail-yw0-x22f.google.com (mail-yw0-x22f.google.com [IPv6:2607:f8b0:4002:c05::22f]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A5B2FAD5; Wed, 9 Nov 2016 04:42:19 +0000 (UTC) (envelope-from araujobsdport@gmail.com) Received: by mail-yw0-x22f.google.com with SMTP id r204so201884483ywb.0; Tue, 08 Nov 2016 20:42:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:reply-to:in-reply-to:references:from:date:message-id :subject:to:cc; bh=uFsDqUeYAEGd89Nsx0VN9cW6wwpauG5xp8WQuzq2KN4=; b=xeWKwyU6dsuEpEf9Drfbq6GW/5q9yuwo/ZZVHpNlg4KSoeT8R+4nu8dFrqmNyXT4ED l5j5g5AfOyC/IAszuHsJ9uc/f2aGUdwj01NB8sUgJ/0FCrGjrVPhAYMj6nbZ+pdZYBoO Y/JzJeAD0KR5EhbAFPsL0TbbWT5r82t0r77DhV48XTz4ft/u9yx1K0NJ7HlsjesKGdcF tehYCBLl65GZlwW7+JRxV8jFBg4ay0I3kzc+XLEK0e2LrERZnfLseCUHWwm4w45zYFRo Ktv9MbpGq88Mm8+xW9sL2XlTQRVg6ev+OR8s8zci9VfqoRy2hq39/2f8sVYfWfz5D/o8 7GEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:reply-to:in-reply-to:references :from:date:message-id:subject:to:cc; bh=uFsDqUeYAEGd89Nsx0VN9cW6wwpauG5xp8WQuzq2KN4=; b=mG5d9GxIpprw8gDr6MHY16zoK8aaYTyXD6/po8pF3GSVu1BfFmZijkqyOH6za4MBne 1ccuyIly4dCxOTAWNK0xkY2xfxIMJ1yAvOFLiZ3WuZEebMZI+L03Dv3tsXDsusrZ8OOg NV1sWoLOw+N6ClgMRHwk3ttYNio7tta+PKCOebj2XZ285BrAyOWlPhx8uGNO37eLHyHt iaN26hYyMKrvZVWSur43CNJVE1sdQzNi/KximJGKHMxzC6+P5FgQ4Okx3nILaTi5UtcF NZbVEED6WIi7C9bCFjARQIFHIBr9n+1BFxEMWtAnnGv8qiUbEwD0enUD+L5dCfIF2DyH 89Fw== X-Gm-Message-State: ABUngvdKL12vfmmXYagbw3v7VFpFlBCTTg5QBrOlgTAz6EqYZfMUJsrypTKVyp5P8A8EVI9Y2QuNqki7RT0vEA== X-Received: by 10.129.98.65 with SMTP id w62mr15145520ywb.38.1478666538477; Tue, 08 Nov 2016 20:42:18 -0800 (PST) MIME-Version: 1.0 Received: by 10.129.133.131 with HTTP; Tue, 8 Nov 2016 20:42:18 -0800 (PST) Reply-To: araujo@freebsd.org In-Reply-To: <20161109115729.F924@besplex.bde.org> References: <201611081136.uA8BaXrs073937@repo.freebsd.org> <20161109115729.F924@besplex.bde.org> From: Marcelo Araujo Date: Wed, 9 Nov 2016 12:42:18 +0800 Message-ID: Subject: Re: svn commit: r308443 - head/bin/hostname To: Bruce Evans Cc: Renato Botelho , "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Nov 2016 04:42:20 -0000 Fixed, thanks! 2016-11-09 9:39 GMT+08:00 Bruce Evans : > On Tue, 8 Nov 2016, Renato Botelho wrote: > > On 8 Nov 2016, at 09:36, Marcelo Araujo wrote: >>> >>> Log: >>> Add -d flag that prints domain only. >>> >>> PR: 212875 >>> Submitted by: Ben RUBSON >>> Reviewed by: pi >>> >> > This has many style bugs. > > > Modified: >>> head/bin/hostname/hostname.1 >>> head/bin/hostname/hostname.c >>> >>> Modified: head/bin/hostname/hostname.1 >>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >>> --- head/bin/hostname/hostname.1 Tue Nov 8 10:10:55 2016 >>> (r308442) >>> +++ head/bin/hostname/hostname.1 Tue Nov 8 11:36:33 2016 >>> (r308443) >>> @@ -29,7 +29,7 @@ >>> .\" @(#)hostname.1 8.2 (Berkeley) 4/28/95 >>> .\" $FreeBSD$ >>> .\" >>> -.Dd December 7, 2006 >>> +.Dd November 9, 2016 >>> .Dt HOSTNAME 1 >>> .Os >>> .Sh NAME >>> @@ -37,7 +37,8 @@ >>> .Nd set or print name of current host system >>> .Sh SYNOPSIS >>> .Nm >>> -.Op Fl fs >>> +.Op Fl f >>> +.Op Fl s|d >>> .Op Ar name-of-host >>> .Sh DESCRIPTION >>> The >>> @@ -62,6 +63,8 @@ This is the default behavior. >>> .It Fl s >>> Trim off any domain information from the printed >>> name. >>> +.It Fl d >>> +Only print domain information. >>> .El >>> .Sh SEE ALSO >>> .Xr gethostname 3 , >>> >>> Modified: head/bin/hostname/hostname.c >>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >>> --- head/bin/hostname/hostname.c Tue Nov 8 10:10:55 2016 >>> (r308442) >>> +++ head/bin/hostname/hostname.c Tue Nov 8 11:36:33 2016 >>> (r308443) >>> @@ -54,11 +54,12 @@ static void usage(void) __dead2; >>> int >>> main(int argc, char *argv[]) >>> { >>> - int ch, sflag; >>> + int ch, sflag, dflag; >>> char *p, hostname[MAXHOSTNAMELEN]; >>> >>> sflag =3D 0; >>> - while ((ch =3D getopt(argc, argv, "fs")) !=3D -1) >>> + dflag =3D 0; >>> + while ((ch =3D getopt(argc, argv, "fsd")) !=3D -1) >>> switch (ch) { >>> case 'f': >>> /* >>> @@ -70,6 +71,9 @@ main(int argc, char *argv[]) >>> case 's': >>> sflag =3D 1; >>> break; >>> + case 'd': >>> + dflag =3D 1; >>> + break; >>> case '?': >>> default: >>> usage(); >>> @@ -77,7 +81,7 @@ main(int argc, char *argv[]) >>> argc -=3D optind; >>> argv +=3D optind; >>> >>> - if (argc > 1) >>> + if (argc > 1 || (sflag && dflag)) >>> usage(); >>> >>> if (*argv) { >>> @@ -90,6 +94,10 @@ main(int argc, char *argv[]) >>> p =3D strchr(hostname, '.'); >>> if (p !=3D NULL) >>> *p =3D '\0'; >>> + } else if (dflag) { >>> + p =3D strchr(hostname, '.'); >>> + if (p !=3D NULL) >>> + strcpy(hostname, ++p); >>> } >>> (void)printf("%s\n", hostname); >>> } >>> @@ -100,6 +108,6 @@ static void >>> usage(void) >>> { >>> >>> - (void)fprintf(stderr, "usage: hostname [-fs] [name-of-host]\n")= ; >>> + (void)fprintf(stderr, "usage: hostname [-f] [s|d] >>> [name-of-host]\n"); >>> >> >> >> It=E2=80=99s missing =E2=80=98-=E2=80=98 sign on [s|d] block, what makes= message a bit confused >> IMO. Maybe [-s|-d] would be more clear. >> > > Both are wrong. > > This is also broken in the man page, where the '|' is literal and > misformatted. Normal markup would give '[-d | -s]' in the man page, and > this should be copied to the usage message. Hard-coding the '|' using > 's|d' gives the different syntax error of a hyphen before the 's'but no > hyphen before the 's' ('[-s|d]'). > > The hard-coding has 2 other bugs: > - missing spaces around '|' > - d and s are unsorted > > d and s are unsorted consistently in about 8 instances in the patch. > > The correct order for sorting -f and [-d | -s] in the synopsis and > usage message is unclear. It would be best to put -f after -d and keep > -s attached to -d, but with longer options list this takes too much > space by splitting up the single-letter options. > > Bruce --=20 --=20 Marcelo Araujo (__)araujo@FreeBSD.org \\\'',)http://www.FreeBSD.org \/ \ ^ Power To Server. .\. /_)