/bin/sh: invalid option -- 1

Denys Vlasenko vda.linux at googlemail.com
Thu Aug 20 01:37:47 UTC 2009


On Wednesday 19 August 2009 23:39, piotr at powersmiths.com wrote:
> 
> > > Running bb v1.15.0.svn (2009-08-14) and hush.
>                                            ^^^^^^
> > >
> > > The runsv applet (part of runit utility) calls
> > my finish script with an> argument set to "-1". busybox seems to
> > assume that this is an option and> displays:
> > >
> > >     /bin/sh: invalid option -- 1
> > >
> > > The same happens if I call the script with an
> > > argument containing leading> '-' . Example: ./finish -abc
> > >
> > > Is this a bug?
> > 
> > What is your /bin/sh? (bash/ash/hush/...)
> > 
> 
> hush it is (as I said - not very precisely - above).

Ahhh stupid bug. Please find the fix below.
-- 
vda

diff -d -urpN busybox.4/shell/hush.c busybox.5/shell/hush.c
--- busybox.4/shell/hush.c	2009-08-17 02:11:09.000000000 +0200
+++ busybox.5/shell/hush.c	2009-08-20 03:29:56.000000000 +0200
@@ -6461,7 +6461,7 @@ int hush_main(int argc, char **argv)
 	/* http://www.opengroup.org/onlinepubs/9699919799/utilities/sh.html */
 	builtin_argc = 0;
 	while (1) {
-		opt = getopt(argc, argv, "c:xins"
+		opt = getopt(argc, argv, "+c:xins"
 #if !BB_MMU
 				"<:$:R:V:"
 # if ENABLE_HUSH_FUNCTIONS


More information about the busybox mailing list