Index: sash-3.7/sash.c
===================================================================
--- sash-3.7.orig/sash.c	2010-04-04 14:56:47.964954627 +0200
+++ sash-3.7/sash.c	2010-04-04 14:57:03.932954934 +0200
@@ -375,10 +375,10 @@
  */
 static	void	catchInt(int);
 static	void	catchQuit(int);
-static	void	readFile(const char * name);
-static	void	command(const char * cmd);
+static	int	readFile(const char * name);
+static	int	command(const char * cmd);
 static	BOOL	tryBuiltIn(const char * cmd);
-static	void	runCmd(const char * cmd);
+static	int	runCmd(const char * cmd);
 static	void	childProcess(const char * cmd);
 static	void	showPrompt(void);
 static	void	usage(void);
@@ -524,9 +524,7 @@
 	 */
 	if (singleCommand)
 	{
-		command(singleCommand);
-
-		return 0;
+		return command(singleCommand);
 	}
 
 	/*
@@ -561,9 +559,8 @@
 	/*
 	 * Read commands from stdin or from a command file.
 	 */
-	readFile(commandFile);
+	return readFile(commandFile);
 
-	return 0;
 }
 
 
@@ -571,19 +568,20 @@
  * Read commands from the specified file.
  * A null name pointer indicates to read from stdin.
  */
-static void
+static int
 readFile(const char * name)
 {
 	FILE *	fp;
 	int	cc;
 	BOOL	ttyFlag;
 	char	buf[CMD_LEN];
+	int	r = 0;
 
 	if (sourceCount >= MAX_SOURCE)
 	{
 		fprintf(stderr, "Too many source files\n");
 
-		return;
+		return 1;
 	}
 
 	fp = stdin;
@@ -596,7 +594,7 @@
 		{
 			perror(name);
 
-			return;
+			return 1;
 		}
 	}
 
@@ -614,7 +612,7 @@
 			fclose(fp);
 			sourceCount--;
 
-			return;
+			return 1;
 		}
 	
 		if (fgets(buf, CMD_LEN - 1, fp) == NULL)
@@ -639,7 +637,7 @@
 
 		buf[cc] = '\0';
 
-		command(buf);
+		r = command(buf);
 	}
 
 	if (ferror(fp))
@@ -656,6 +654,7 @@
 		fclose(fp);
 
 	sourceCount--;
+	return r;
 }
 
 
@@ -664,7 +663,7 @@
  * This breaks the command line up into words, checks to see if the
  * command is an alias, and expands wildcards.
  */
-static void
+static int
 command(const char * cmd)
 {
 	const char *	endCmd;
@@ -690,7 +689,7 @@
 	 * If the command is empty or is a comment then ignore it.
 	 */
 	if ((*cmd == '\0') || (*cmd == '#'))
-		return;
+		return 0;
 
 	/*
 	 * Look for the end of the command name and then copy the
@@ -726,13 +725,13 @@
 	 * the command if found.
 	 */
 	if (tryBuiltIn(cmd))
-		return;
+		return 0; /* This is a blatant lie */
 
 	/*
 	 * The command is not a built-in, so run the program along
 	 * the PATH list.
 	 */
-	runCmd(cmd);
+	return runCmd(cmd);
 }
 
 
@@ -809,7 +808,7 @@
  * Execute the specified command either by forking and executing
  * the program ourself, or else by using the shell.
  */
-static void
+static int
 runCmd(const char * cmd)
 {
 	const char *	cp;
@@ -854,9 +853,7 @@
 	 */
 	if (magic)
 	{
-		system(cmd);
-
-		return;
+		return system(cmd);
 	}
 
 	/*
@@ -869,7 +866,7 @@
 	{
 		perror("fork failed");
 
-		return;
+		return -1;
 	}
 
 	/*
@@ -894,7 +891,7 @@
 	{
 		fprintf(stderr, "Error from waitpid: %s", strerror(errno));
 
-		return;
+		return -1;
 	}
 
 	if (WIFSIGNALED(status))
@@ -902,6 +899,7 @@
 		fprintf(stderr, "pid %ld: killed by signal %d\n",
 			(long) pid, WTERMSIG(status));
 	}
+	return WEXITSTATUS(status);
 }
 
 
