Sophie

Sophie

distrib > Mandriva > 2009.1 > i586 > media > main-release-src > by-pkgid > b335ff519454bc96ce131f483cb7d518 > files > 1

sash-3.7-8mdv2009.1.src.rpm

--- sash-3.6/sash.c.orig	2002-07-22 00:55:28.000000000 +0200
+++ sash-3.6/sash.c	2003-09-01 12:41:51.000000000 +0200
@@ -481,6 +481,24 @@
 		}
 	}
 
+	/* A single argument is allowed, and it must be a filename which
+	   provides stdin. This allows #! usage. */
+	if (argc) {
+		int fd;
+
+		fd = open(argv[0], O_RDONLY);
+		if (fd < 0) {
+			fprintf(stderr, "Error opening %s: %s\n", argv[0],
+				strerror(errno));
+			return 1;
+		}
+
+		dup2(fd, 0);
+		close(fd);
+
+		argc--, argv++;
+	}
+
 	/*
 	 * No more arguments are allowed.
 	 */
@@ -1271,7 +1289,7 @@
 	fprintf(stderr, "Stand-alone shell (version %s)\n", version);
 	fprintf(stderr, "\n");
 	fprintf(stderr, "Usage: sash [-a] [-q] [-f fileName] [-c command] [-p prompt]\n");
-
+	fprintf(stderr, "Usage: sash [-a] [-q] [-f fileName] [-c command] [-p prompt] [script]\n");
 	exit(1);
 }
 
--- sash-3.6/sash.1.orig	2002-07-22 01:16:40.000000000 +0200
+++ sash-3.6/sash.1	2003-09-01 12:43:04.000000000 +0200
@@ -2,7 +2,7 @@
 .SH NAME
 sash \- stand-alone shell with built-in commands
 .SH SYNOPSYS
-.B sash [-c command] [-f fileName ] [-p prompt] [-q] [-a]
+.B sash [-c command] [-f fileName ] [-p prompt] [-q] [-a] [script]
 .SH DESCRIPTION
 The
 .B sash
@@ -496,6 +496,12 @@
 The -a option creates aliases for the built-in commands so
 that they replace the corresponding standard commands.
 This is the same result as if the 'aliasall' command was used.
+
+A file name may be provided as the last argument to sash, in which case
+sash's standard input is read from that file. This allows #! scripts
+to use sash as their script interpretor. Be aware that sash does not provide
+most normal bourne-shell programming features, however.
+
 .SH SYSTEM RECOVERY
 This section contains some useful information about using
 .B sash