From owner-freebsd-stable Tue Jan 16 8:25:26 2001 Delivered-To: freebsd-stable@freebsd.org Received: from tao.org.uk (unknown [194.128.198.234]) by hub.freebsd.org (Postfix) with ESMTP id 27A1837B401 for ; Tue, 16 Jan 2001 08:25:08 -0800 (PST) Received: by tao.org.uk (Postfix, from userid 100) id 779193223; Tue, 16 Jan 2001 16:25:06 +0000 (GMT) Date: Tue, 16 Jan 2001 16:25:06 +0000 From: Josef Karthauser To: Dag-Erling Smorgrav Cc: stable@FreeBSD.ORG Subject: Re: cdcontrol and environment vars - opinions please. Message-ID: <20010116162506.A608@tao.org.uk> Mail-Followup-To: Josef Karthauser , Dag-Erling Smorgrav , stable@FreeBSD.ORG References: <20010116121921.A632@tao.org.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from des@ofug.org on Tue, Jan 16, 2001 at 03:14:03PM +0100 Sender: owner-freebsd-stable@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Tue, Jan 16, 2001 at 03:14:03PM +0100, Dag-Erling Smorgrav wrote: > Josef Karthauser writes: > > How many people are using cdcontrol and defining the drive name > > using one of the following environment variables: MUSIC_CD, CD_DRIVE, > > DISC and CDPLAY? > > > > I've no idea why there are so many different options - it seems a > > bit daft to me. > > > > Recently we added another one: CDROM. What I'd like to do is > > deprecate use of the others and adopt CDROM as standard. > > Heh - I'm the one who added suport for $CDROM, and I had no idea the > others were supported - $CDROM was so self-evident (think of $TAPE, > used by pax(1), mt(1), tar(1), dump(8) and restore(8)) that it didn't > occur to me to check if it already supported other variables (plus, > they weren't documented). > > I totally agree with the idea of deprecating all but $CDROM. How about the following. Joe Index: cdcontrol.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/cdcontrol/cdcontrol.c,v retrieving revision 1.29 diff -u -r1.29 cdcontrol.c --- cdcontrol.c 2000/12/18 14:35:54 1.29 +++ cdcontrol.c 2001/01/16 16:22:40 @@ -159,18 +159,29 @@ exit (1); } +char *use_cdrom_instead(char *old_envvar) { + char *device; + + device = getenv(old_envvar); + if (device) + warnx("%s environment variable deprecated, " + "please use CDROM in the future.", old_envvar); + return device; +} + + int main (int argc, char **argv) { int cmd; char *arg; - cdname = getenv ("MUSIC_CD"); + cdname = use_cdrom_instead("MUSIC_CD"); if (! cdname) - cdname = getenv ("CD_DRIVE"); + cdname = use_cdrom_instead("CD_DRIVE"); if (! cdname) - cdname = getenv ("DISC"); + cdname = use_cdrom_instead("DISC"); if (! cdname) - cdname = getenv ("CDPLAY"); + cdname = use_cdrom_instead("CDPLAY"); for (;;) { switch (getopt (argc, argv, "svhf:")) { To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-stable" in the body of the message