Sophie

Sophie

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

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

--- sash-3.7/sash.c.pix	2004-06-02 14:02:59.609564675 +0200
+++ sash-3.7/sash.c	2004-06-02 14:03:56.137579142 +0200
@@ -405,6 +405,7 @@
 	const char *	commandFile;
 	BOOL		quietFlag;
 	BOOL		aliasFlag;
+	BOOL		ignoreRemainingArgsFlag = FALSE;
 	char		buf[PATH_LEN];
 
 	singleCommand = NULL;
@@ -418,6 +419,13 @@
 	argv++;
 	argc--;
 
+	if (argc && strcmp(*argv, "--ignore-remaining-args") == 0)
+	{
+		ignoreRemainingArgsFlag = TRUE;
+		argv++;
+		argc--;		
+	}
+
 	while ((argc > 0) && (**argv == '-'))
 	{
 		cp = *argv++ + 1;
@@ -429,7 +437,7 @@
 				/*
 				 * Execute specified command.
 				 */
-				if ((argc != 1) || singleCommand)
+				if ((argc < 1) || singleCommand)
 					usage();
 
 				singleCommand = *argv++;
@@ -443,7 +451,7 @@
 				 * This is used for sash script files.
 				 * The quiet flag is also set.
 				 */
-				if ((argc != 1) || commandFile)
+				if ((argc < 1) || commandFile)
 					usage();
 
 				quietFlag = TRUE;
@@ -489,7 +497,7 @@
 
 	/* A single argument is allowed, and it must be a filename which
 	   provides stdin. This allows #! usage. */
-	if (argc) {
+	if (argc && !(ignoreRemainingArgsFlag && commandFile)) {
 		int fd;
 
 		fd = open(argv[0], O_RDONLY);
@@ -505,10 +513,18 @@
 		argc--, argv++;
 	}
 
+	if (argc > 0 && !commandFile && !singleCommand)
+	{
+		fprintf(stderr, "Using \"#!/sbin/sash\" is deprecated, use \"#!/sbin/sash -f\" instead\n");
+		quietFlag = TRUE;
+		commandFile = *argv++;
+		argc--;
+	}
+
 	/*
 	 * No more arguments are allowed.
 	 */
-	if (argc > 0)
+	if (argc > 0 && !ignoreRemainingArgsFlag)
 		usage();
 
 	/*