summaryrefslogtreecommitdiffstats
path: root/usr.sbin/cdplay
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1995-02-22 01:45:03 +0000
committerache <ache@FreeBSD.org>1995-02-22 01:45:03 +0000
commit3060934c591ca0990968f3a46cc18e894403b8d0 (patch)
treeae17f9949eeed7bb992cb49fe58791f855a05f91 /usr.sbin/cdplay
parent72ec25a906cc43dbe37e2c5df19dd2a2c69b6e8f (diff)
downloadFreeBSD-src-3060934c591ca0990968f3a46cc18e894403b8d0.zip
FreeBSD-src-3060934c591ca0990968f3a46cc18e894403b8d0.tar.gz
Use CDPLAY environment variable to not type argument each time
Submitted by: hvd@terry.ping.dk
Diffstat (limited to 'usr.sbin/cdplay')
-rw-r--r--usr.sbin/cdplay/cdplay.18
-rw-r--r--usr.sbin/cdplay/cdplay.c16
2 files changed, 17 insertions, 7 deletions
diff --git a/usr.sbin/cdplay/cdplay.1 b/usr.sbin/cdplay/cdplay.1
index 489b25d..1918bd3 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 2c1cafa..c37fc3c 100644
--- a/usr.sbin/cdplay/cdplay.c
+++ b/usr.sbin/cdplay/cdplay.c
@@ -6,6 +6,7 @@
#include <sys/file.h>
#include <sys/cdio.h>
#include <sys/ioctl.h>
+#include <stdlib.h>
#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 <cd>\n<cd> 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 <cd>\n<cd> is device name such as cd0 or mcd0\n");
+ exit(1);
+ };
+
standalone = isatty (0);
while (input ()) {
rc = 0;
OpenPOWER on IntegriCloud