Date: Tue, 16 Jan 2001 16:25:06 +0000 From: Josef Karthauser <joe@tao.org.uk> To: Dag-Erling Smorgrav <des@ofug.org> Cc: stable@FreeBSD.ORG Subject: Re: cdcontrol and environment vars - opinions please. Message-ID: <20010116162506.A608@tao.org.uk> In-Reply-To: <xzpwvbvk2j8.fsf@flood.ping.uio.no>; from des@ofug.org on Tue, Jan 16, 2001 at 03:14:03PM %2B0100 References: <20010116121921.A632@tao.org.uk> <xzpwvbvk2j8.fsf@flood.ping.uio.no>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Jan 16, 2001 at 03:14:03PM +0100, Dag-Erling Smorgrav wrote:
> Josef Karthauser <joe@tao.org.uk> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010116162506.A608>
