Subject: Add -i option
From: Michael Meskes <meskes@debian.org>
Bug-Debian: #19656
Last-updated: 2010-04-04
Index: sash-3.7/sash.c
===================================================================
--- sash-3.7.orig/sash.c	2010-04-04 10:35:51.268950839 +0200
+++ sash-3.7/sash.c	2010-04-04 10:36:42.572973204 +0200
@@ -399,12 +399,14 @@
 	const char *	commandFile;
 	BOOL		quietFlag;
 	BOOL		aliasFlag;
+        BOOL		interactiveFlag;
 	char		buf[PATH_LEN];
 
 	singleCommand = NULL;
 	commandFile = NULL;
 	quietFlag = FALSE;
 	aliasFlag = FALSE;
+        interactiveFlag = FALSE;
 
 	/*
 	 * Look for options.
@@ -419,11 +421,17 @@
 
 		while (*cp) switch (*cp++)
 		{
+                        case '-':
+                                /*
+                                 * Ignore.  This is so that we can be
+                                 * run from login.
+                                 */
+                                break;
 			case 'c':
 				/*
 				 * Execute specified command.
 				 */
-				if ((argc != 1) || singleCommand)
+				if ((argc != 1) || singleCommand || interactiveFlag)
 					usage();
 
 				singleCommand = *argv++;
@@ -446,6 +454,18 @@
 
 				break;
 
+			case 'i':
+				/*
+				 * Be an interactive shell
+				 * ..is a no-op, but some contexts require this
+				 * ..interactiveFlag is to avoid -ic as a legacy
+				 */
+				 if (singleCommand)
+				 	usage();
+				 
+				 interactiveFlag = TRUE;
+				 break;
+				 
 			case 'p':
 				/*
 				 * Set the prompt string.
@@ -1263,7 +1290,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] [-i]\n");
 
 	exit(1);
 }
