On Wednesday 18 March 2009 19:16, Mikhail Gusarov wrote:
> Hello,
> 
> I can't make busybox ash (1.13.3 and svn trunk) to duplicate the stdin:
> 
> ./busybox ash -c "exec 1>&0"
> ash: 0: Bad file descriptor
> 
> bash & debian ash seem to handle such construction. Is it a bug, is this
> statement non-standard or maybe something else?
> 
> .config file is attached.

Try this patch
--
vda
--- busybox-1.13.3/shell/ash.c	Thu Feb 26 12:46:55 2009
+++ busybox-1.13.3/shell/ash.c	Thu Mar 19 02:51:08 2009
@@ -13692,15 +13693,20 @@
 	}
  state3:
 	state = 4;
-	if (minusc)
+	if (minusc) {
+		/* evalstring pushes parsefile stack.
+		 * Ensure we don't falsely claim that 0 (stdin)
+		 * is one of stacked source fds */
+		if (!sflag)
+			g_parsefile->fd = -1;
 		evalstring(minusc, 0);
+	}
 
 	if (sflag || minusc == NULL) {
 #if ENABLE_FEATURE_EDITING_SAVEHISTORY
 		if (iflag) {
 			const char *hp = lookupvar("HISTFILE");
-
-			if (hp != NULL)
+			if (hp)
 				line_input_state->hist_file = hp;
 		}
 #endif
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to