Can create BASH functions that can't be deleted

2006-01-15 Thread Michael ODonnell
Configuration Information [Automatically generated, do not change]:
Machine: i386
OS: linux-gnu
Compiler: i386-redhat-linux-gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i386' -DCONF_OSTYPE='linu
x-gnu' -DCONF_MACHTYPE='i386-redhat-linux-gnu' -DCONF_VENDOR='redhat' -DLOCALEDI
R='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H  -I.  -I. -I./inc
lude -I./lib  -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g -pipe -m32 -marc
h=i386 -mtune=pentium4
uname output: Linux sonic-mike1 2.6.9-22.ELsmp #1 SMP Mon Sep 19 18:32:14 EDT 20
05 i686 i686 i386 GNU/Linux
Machine Type: i386-redhat-linux-gnu

Bash Version: 3.0
Patch Level: 15
Release Status: release

Description:
Naming restriction inconsistencies allow us to create
BASH functions that can't be deleted.

Repeat-By:
function a.b() { echo My name is $FUNCNAME; }

a.b
My name is a.b

unset a.b
-bash: unset: `a.b': not a valid identifier

 


___
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash


Can create function that can't be deleted

2006-01-15 Thread michael . odonnell

Configuration Information [Automatically generated, do not change]:
Machine: i386
OS: linux-gnu
Compiler: i386-redhat-linux-gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i386' -DCONF_OSTYPE='linu
x-gnu' -DCONF_MACHTYPE='i386-redhat-linux-gnu' -DCONF_VENDOR='redhat' -DLOCALEDI
R='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H  -I.  -I. -I./inc
lude -I./lib  -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g -pipe -m32 -marc
h=i386 -mtune=pentium4
uname output: Linux sonic-mike1 2.6.9-22.ELsmp #1 SMP Mon Sep 19 18:32:14 EDT 20
05 i686 i686 i386 GNU/Linux
Machine Type: i386-redhat-linux-gnu

Bash Version: 3.0
Patch Level: 15
Release Status: release

Description:
Naming restriction inconsistencies allow us to create
BASH functions that can't be deleted.

Repeat-By:
function a.b() { echo My name is $FUNCNAME; }

a.b
My name is a.b

unset a.b
-bash: unset: `a.b': not a valid identifier

 


___
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash


expansion fails for ${#VAR[$(( 0+0 ))]}

2006-01-15 Thread jckn
Configuration Information [Automatically generated, do not change]:
Machine: i486
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i486' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i486-pc-linux-gnu' 
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -
DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H   -I.  -I../bash -I../bash/include 
-I../bash/lib   -g -O2
uname output: Linux hejre 2.6.15 #3 PREEMPT Tue Jan 10 12:50:16 CET 2006 i686 
GNU/Linux
Machine Type: i486-pc-linux-gnu

Bash Version: 3.1
Patch Level: 5
Release Status: release

Description:
A parameter expression where you want to take _the length of_ an array
member whose index is calculated at the same time fails to expand
with the following error:

[EMAIL PROTECTED]:/usr/share/doc/bash$ echo ${LOGNAME[$(( 0+0 ))]}
jcn
[EMAIL PROTECTED]:/usr/share/doc/bash$ echo ${#LOGNAME[$(( 0+0 ))]}
-bash: ${#LOGNAME[$(( 0+0 ))]}: bad substitution

Repeat-By:
See above.

Fix:
Here's the beginning of subst.c:parameter_brace_expand():

   5779 static WORD_DESC *
   5780 parameter_brace_expand (string, indexp, quoted, quoted_dollar_atp, 
contains_dollar_at)
   5781  char *string;
   5782  int *indexp, quoted, *quoted_dollar_atp, *contains_dollar_at;
   5783 {
   5784   int check_nullness, var_is_set, var_is_null, var_is_special;
   5785   int want_substring, want_indir, want_patsub;
   5786   char *name, *value, *temp, *temp1;
   5787   WORD_DESC *tdesc, *ret;
   5788   int t_index, sindex, c, tflag;
   5789   intmax_t number;
   5790
   5791   value = (char *)NULL;
   5792   var_is_set = var_is_null = var_is_special = check_nullness = 0;
   5793   want_substring = want_indir = want_patsub = 0;
   5794
   5795   sindex = *indexp;
   5796   t_index = ++sindex;
   5797   name = string_extract (string, &t_index, "#%:-=?+/}", EX_VARNAME);
   5798
   5799   ret = 0;
   5800   tflag = 0;
   5801
   5802   /* If the name really consists of a special variable, then make sure
   5803  that we have the entire name.  We don't allow indirect references
   5804  to special variables except `#', `?', `@' and `*'. */
   5805   if ((sindex == t_index &&
   5806 (string[t_index] == '-' ||
   5807  string[t_index] == '?' ||
   5808  string[t_index] == '#')) ||
   5809   (sindex == t_index - 1 && string[sindex] == '!' &&
   5810 (string[t_index] == '#' ||
   5811  string[t_index] == '?' ||
   5812  string[t_index] == '@' ||
   5813  string[t_index] == '*')))
   5814 {
   5815   t_index++;
   5816   free (name);
   5817   temp1 = string_extract (string, &t_index, "#%:-=?+/}", 0);
   5818   name = (char *)xmalloc (3 + (strlen (temp1)));
   5819   *name = string[sindex];
   5820   if (string[sindex] == '!')
   5821 {
   5822   /* indirect reference of $#, $?, $@, or $* */
   5823   name[1] = string[sindex + 1];
   5824   strcpy (name + 2, temp1);
   5825 }
   5826   else
   5827 strcpy (name + 1, temp1);
   5828   free (temp1);
   5829 }
   5830   sindex = t_index;

Assume string = "#LOGNAME[$(( 0+0 ))]}", as in my example above.
Then, in 5797, name = "" and still sindex == t_index.
So the code enters the if-block at 5805 (string[t_index] == '#'),
and in 5817

temp1 = "#LOGNAME[$(( 0"

because the fourth parameter is 0 and not EX_VARNAME, as I'd have
expected. With this content of temp1 (which is then copied back to
name), the later expansion(s) are bound to fail.

I've attached my suggested patch (one-liner, changing the mentioned
fourth parameter).


Regards,

Jan
--- ../bash-3.1/subst.c 2006-01-14 01:12:02.0 +0100
+++ subst.c 2006-01-14 01:12:39.0 +0100
@@ -5814,7 +5814,7 @@
 {
   t_index++;
   free (name);
-  temp1 = string_extract (string, &t_index, "#%:-=?+/}", 0);
+  temp1 = string_extract (string, &t_index, "#%:-=?+/}", EX_VARNAME);
   name = (char *)xmalloc (3 + (strlen (temp1)));
   *name = string[sindex];
   if (string[sindex] == '!')
___
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash


Bash Bugs

2006-01-15 Thread n3d gonzales
Hello,

I used my old script to my new machine and their's a bug on it.  I have
attached the very simplified script. It will determine whether the file has
space or not. The result is different.

gcc-3.4.3-22.1
bash-3.0-19.2
Red Hat Enterprise Linux ES release 4 (Nahant Update 1)
IBM Intel(R) Xeon(TM) CPU 3.60GHz

Simple Script:
===
#!/bin/bash
while read line;do
 if [ -n "$line" ];then
   echo "Without Space, $line"
 else
   echo "Error, With Space"
 fi
done < testing
===

testing file:
===
2005-04703;;
2005-05286;;
2005-07383;;

2005-09416;;

2005-11217;;
===

Result:
Without Space, 2005-04703;;
Without Space, 2005-05286;;
Without Space, 2005-07383;;
Without Space,--> This wil be Error,
With Space
Without Space, 2005-09416;;
Without Space,--> This wil be Error,
With Space
Without Space, 2005-11217;;


Regards,
Ned
___
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash


Re: Can create BASH functions that can't be deleted

2006-01-15 Thread Chris F.A. Johnson

On Fri, 13 Jan 2006, Michael ODonnell wrote:


Configuration Information [Automatically generated, do not change]:
Machine: i386
OS: linux-gnu
Compiler: i386-redhat-linux-gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i386' -DCONF_OSTYPE='linu
x-gnu' -DCONF_MACHTYPE='i386-redhat-linux-gnu' -DCONF_VENDOR='redhat' -DLOCALEDI
R='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H  -I.  -I. -I./inc
lude -I./lib  -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g -pipe -m32 -marc
h=i386 -mtune=pentium4
uname output: Linux sonic-mike1 2.6.9-22.ELsmp #1 SMP Mon Sep 19 18:32:14 EDT 20
05 i686 i686 i386 GNU/Linux
Machine Type: i386-redhat-linux-gnu

Bash Version: 3.0
Patch Level: 15
Release Status: release

Description:
   Naming restriction inconsistencies allow us to create
   BASH functions that can't be deleted.

Repeat-By:
   function a.b() { echo My name is $FUNCNAME; }

   a.b
   My name is a.b

   unset a.b
   -bash: unset: `a.b': not a valid identifier


unset -f a.b


--
   Chris F.A. Johnson  
   ===
   Author:
   Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)


___
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash


Re: [patch] fix 'exec -l /bin/bash'

2006-01-15 Thread Mike Frysinger
On Friday 13 January 2006 12:11, Tim Waugh wrote:
> Description:
>   If bash has argv[0] as '-/bin/bash' it does not become a login
>   shell.
>
> Repeat-By:
>   exec -l /bin/bash
>   shopt
>
> Fix:

patch works for me using screen / login shells

thanks
-mike


___
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash