From ae9ad53d8415ccb0ecf7fb14334de22eb7d6637f Mon Sep 17 00:00:00 2001 From: "Andrey A. Chernov" Date: Wed, 22 Feb 1995 01:45:03 +0000 Subject: [PATCH] Use CDPLAY environment variable to not type argument each time Submitted by: hvd@terry.ping.dk --- usr.sbin/cdplay/cdplay.1 | 8 ++++++-- usr.sbin/cdplay/cdplay.c | 16 +++++++++++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/usr.sbin/cdplay/cdplay.1 b/usr.sbin/cdplay/cdplay.1 index 489b25d25d3..1918bd31724 100644 --- a/usr.sbin/cdplay/cdplay.1 +++ b/usr.sbin/cdplay/cdplay.1 @@ -6,13 +6,17 @@ .Nd Audio CD player .Sh SYNOPSIS .Nm cdplay -.Ar device +.Op Ar device .Sh DESCRIPTION .Nm cdplay is a program to control an audio CD player. The device is a name such as cd0 or mcd0. .Pp - Currently supported commands are as follows: +If the device not specified, the environment variable +.Ev CDPLAY +will be used to find the cd device. +.Pp +Currently supported commands are as follows: .Bl -tag -width Cm .It Cm play first_track last_track Play from track diff --git a/usr.sbin/cdplay/cdplay.c b/usr.sbin/cdplay/cdplay.c index 2c1cafacc40..c37fc3cd307 100644 --- a/usr.sbin/cdplay/cdplay.c +++ b/usr.sbin/cdplay/cdplay.c @@ -6,6 +6,7 @@ #include #include #include +#include #define command(s) strncmp(cmd,s,strlen(s))==0 @@ -27,11 +28,16 @@ main (int argc, char **argv) { int rc; - if (argc != 2) { - fprintf(stderr, "Usage: cdplay \n is device name such as cd0 or mcd0\n"); - exit(1); - } - cdname = argv[1]; + switch (argc) { + case 2: cdname = argv[1]; + break; + case 1: if(cdname = getenv("CDPLAY")) + /* Break if CDPLAY is set */ + break; + default: fprintf(stderr, "Usage: cdplay \n is device name such as cd0 or mcd0\n"); + exit(1); + }; + standalone = isatty (0); while (input ()) { rc = 0;