bug-bash
[Top][All Lists]
Advanced

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

bash -c mishandles $LINENO when in complex command


From: Paul Eggert
Subject: bash -c mishandles $LINENO when in complex command
Date: Thu, 1 Nov 2001 02:05:27 -0800 (PST)

Configuration Information [Automatically generated, do not change]:
Machine: i386
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i386' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i386-pc-linux-gnu' 
-DCONF_VENDOR='pc' -DSHELL -DHAVE_CONFIG_H  -D_FILE_OFFSET_BITS=64  -I.  
-I/home/swt/doko/export/packages/bash/bash-2.03 
-I/home/swt/doko/export/packages/bash/bash-2.03/lib -I/usr/include -g -O2
uname output: Linux dum.twinsun.com 2.2.18ss.e820-bda652a #4 SMP Tue Jun 5 
11:24:08 PDT 2001 i686 unknown
Machine Type: i386-pc-linux-gnu

Bash Version: 2.03
Patch Level: 0
Release Status: release

Description:
        Bash's -c option mishandles $LINENO when it is part of a
        complex command.  This bug caused Bash to fail some recently
        proposed Autoconf tests for $LINENO.  The bug still exists in
        the latest Bash beta.

Repeat-By:
        In the following example, the output should always be "1"; but
        in the last two instances it is "2".  The Korn shell gets it right.

        $ (echo '(echo $LINENO'; echo ')') | bash 
        1
        $ (echo '{ echo $LINENO'; echo '}') | bash 
        1
        $ bash -c '(echo $LINENO
        > )'
        2
        $ bash -c '{ echo $LINENO
        > }'
        2

Fix:
The following patch assumes the latest Bash beta, plus all the patches
I've already submitted.

2001-11-01  Paul Eggert  <address@hidden>

        * shell.c (main): Initialize 'executing' to 1 when executing
        a -c option when ONESHOT is defined.  This fixes a bug with
        $LINENO in some -c options that contain newlines.

===================================================================
RCS file: shell.c,v
retrieving revision 2.5.1.2.0.2
retrieving revision 2.5.1.2.0.3
diff -pu -r2.5.1.2.0.2 -r2.5.1.2.0.3
--- shell.c     2001/10/14 05:26:36     2.5.1.2.0.2
+++ shell.c     2001/11/01 10:01:28     2.5.1.2.0.3
@@ -599,6 +599,7 @@ main (argc, argv, env)
       arg_index = bind_args (argv, arg_index, argc, 0);
       startup_state = 2;
 #if defined (ONESHOT)
+      executing = 1;
       run_one_command (local_pending_command);
       exit_shell (last_command_exit_value);
 #else /* ONESHOT */



reply via email to

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