9menu / 03_stdin.diff

Description: Allow '-file -' to cause stdin to be read as the file
Forwarded: yes
Author: Andrew Stribblehill <ads@debian.org>
Origin: vendor
Last-Update: 2003-09-02

diff --git a/9menu.1 b/9menu.1
--- a/9menu.1
+++ b/9menu.1
@@ -97,11 +97,11 @@ instead of the default display.
 Read items to display from
 .IR filename ,
 in addition to any other command line arguments.  This is intended for use
 .B #!
-in scripts.
+in scripts. If the filename is "-" read from stdin.
 .BI \-fg " foreground-color"
 Set the foreground color to
 .IR foreground-color .
 By default, the foreground color is black.
diff --git a/9menu.c b/9menu.c
--- a/9menu.c
+++ b/9menu.c
@@ -262,11 +262,15 @@ char **argv;
 	if (filename) {
 		/* Read options and labels from file */
 		char fbuf[1024];
 		FILE *fp;
-		fp = fopen(filename, "r");
+                if (strcmp(filename, "-") == 0) {
+                        fp = stdin;
+                } else {
+                        fp = fopen(filename, "r");
+                }
 		if (fp == NULL) {
 			fprintf(stderr, "%s: couldn't open '%s'\n", progname,
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.