Subsequent `declare -fp` and `.` incorrectly restore function with here string with pattern substitution

2010-01-24 Thread Arfrever Frehtes Taifersar Arahesis
Configuration Information:
Machine: x86_64
OS: linux-gnu
Compiler: x86_64-pc-linux-gnu-gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu' 
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL 
-DHAVE_CONFIG_H   -I.  -I. -I./include -I./lib  
-DDEFAULT_PATH_VALUE='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
 -DSTANDARD_UTILS_PATH='/bin:/usr/bin:/sbin:/usr/sbin' 
-DSYS_BASHRC='/etc/bash/bashrc' -DSYS_BASH_LOGOUT='/etc/bash/bash_logout' 
-DNON_INTERACTIVE_LOGIN_SHELLS -DSSH_SOURCE_BASHRC -march=core2 -O2 -pipe
Machine Type: x86_64-pc-linux-gnu

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

Description:
Subsequent `declare -fp` and `.` incorrectly restore function with here 
string with pattern substitution.

Repeat-By:
The following function is incorrectly restored:
here_string_test() {
:  ${var// /$'\n'}
}

Run the attached bash_test.sh script using this command:
env -i bash_test.sh

-- 
Arfrever Frehtes Taifersar Arahesis


bash_test.sh
Description: application/shellscript


signature.asc
Description: This is a digitally signed message part.


Re: Subsequent `declare -fp` and `.` incorrectly restore function with here string with pattern substitution

2010-01-24 Thread Chet Ramey
On 1/24/10 11:46 AM, Arfrever Frehtes Taifersar Arahesis wrote:

 Bash Version: 4.0
 Patch Level: 37
 Release Status: release
 
 Description:
   Subsequent `declare -fp` and `.` incorrectly restore function with here 
 string with pattern substitution.
 
 Repeat-By:
   The following function is incorrectly restored:
   here_string_test() {
   :  ${var// /$'\n'}
   }
 
   Run the attached bash_test.sh script using this command:
   env -i bash_test.sh

Thanks for the report.  In this case, the here-string does not need to be
requoted.

Chet



-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/




Re: building arrays from non array variables using 'array[${#arr...@]}]='

2010-01-24 Thread Chet Ramey
On 1/24/10 5:13 AM, Mart Frauenlob wrote:
 Hello,
 
 I'd like to ask, if the behavior of indexed array assignment using the
 form: 'array[${#arr...@]}]=' is as expected.

Thanks for the report.  The question is what ${#arr...@]} should return
when it refers to a scalar variable that has not been assigned a value.
Previous versions of bash returned 1, not checking whether or not the
variable is set; the right answer is 0 if the variable is not set and 1
otherwise.

Any official change will probably wait until bash-4.2.  I have attached a
patch to evaluate, though.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/
*** ../bash-4.1-patched/subst.c 2009-12-30 08:24:28.0 -0500
--- subst.c 2010-01-24 14:57:19.0 -0500
***
*** 5244,5247 
--- 5244,5248 
char *t, c;
ARRAY *array;
+   HASH_TABLE *h;
SHELL_VAR *var;
  
***
*** 5267,5279 
  
array = array_p (var) ? array_cell (var) : (ARRAY *)NULL;
  
if (ALL_ELEMENT_SUB (t[0])  t[1] == ']')
  {
if (assoc_p (var))
!   return (assoc_num_elements (assoc_cell (var)));
else if (array_p (var))
!   return (array_num_elements (array));
else
!   return 1;
  }
  
--- 5268,5281 
  
array = array_p (var) ? array_cell (var) : (ARRAY *)NULL;
+   h = assoc_p (var) ? assoc_cell (var) : (HASH_TABLE *)NULL;
  
if (ALL_ELEMENT_SUB (t[0])  t[1] == ']')
  {
if (assoc_p (var))
!   return (h ? assoc_num_elements (h) : 0);
else if (array_p (var))
!   return (array ? array_num_elements (array) : 0);
else
!   return (value_cell (var) ? 1 : 0);
  }
  


Re: Command completion considering characters after the cursor?

2010-01-24 Thread Chet Ramey
On 1/23/10 1:04 PM, Peng Yu wrote:
 On Mon, Jan 18, 2010 at 10:00 AM, Chet Ramey chet.ra...@case.edu wrote:
 On 1/18/10 9:49 AM, Peng Yu wrote:
 Suppose I have 'some.sh' in my command line, and my cursor is at '.'

 $some.sh

 Suppose there is only one command that start with 'some', which is
 'something.sh'. After I type TAB, I will have 'something.sh.sh' in my
 command line.

 $something.sh.sh

 I'm wondering if there is a way to configure bash, so that I will get
 'something.sh' rather than 'something.sh.sh'.

 There is nothing directly analogous in bash.  The closest thing is the
 `skip-completed-text' readline variable in bash-4.1/readline-6.1, but
 that will not help in this case.
 
 Can I request this feature be added in future version of bash?

Thanks for the suggestion.  I will consider it for a future release.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/