[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

${@:0:n} is one parameter too short

From: Neil Moore
Subject: ${@:0:n} is one parameter too short
Date: Fri, 09 Oct 2009 23:38:15 -0400

Configuration Information [Automatically generated, do not change]:
Machine: i686
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i686' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-pc-linux-gnu' 
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/local/share/locale' -DPACKAGE='bash' 
-DSHELL -DHAVE_CONFIG_H   -I.  -I. -I./include -I./lib   -g -O2
uname output: Linux dirac.s-z.org 2.6.26-1-openvz-686 #1 SMP Wed Sep 10 
19:04:44 UTC 2008 i686 GNU/Linux
Machine Type: i686-pc-linux-gnu

Bash Version: 4.0
Patch Level: 33
Release Status: release

        The expansion "${@:0:n}" should be $0 followed by the first
        n-1 positional parameters, but is instead $0 followed by
        the first n-2 positional parameters.  This behavior is different
        from ksh93 and seems nonsensical and unintentional.

        set -- a b c d
        echo "${@:0:3}"  # prints "bash a"; should be "bash a b"

        Apply the following patch.  The important effects are on
        the behaviour of the following loop (params && i < end),
        which without the patch is iterating one time too few.

diff -ur bash-4.0/subst.c bash-4.0-fixed/subst.c
--- ../bash-4.0/subst.c    2009-07-22 19:15:52.472737094 -0400
+++ subst.c      2009-07-22 19:13:48.316733546 -0400
@@ -2739,7 +2739,7 @@
       save = params = t;
-  for (i = 1; params && i < start; i++)
+  for (i = start ? 1 : 0; params && i < start; i++)
     params = params->next;
   if (params == 0)
     return ((char *)NULL);

reply via email to

[Prev in Thread] Current Thread [Next in Thread]