Re: IFS valid characters

2009-03-16 Thread Dave B
Stephane CHAZELAS wrote:

> 2009-03-10, 15:43(-04), Chet Ramey:
>>> What are the valid charactes for the IFS variable? In particular, is '\0' a 
>>> valid one? 
>> Technically, yes, but in practice it's not useful.  There are too many things
>> represented as C strings to make NUL work right.
> [...]
> 
> And to answer the rest of the question. In bash, any character
> except NUL is allowed in $IFS.
> 
> Some points that should be noted:
>   - the SPC, TAB and NL characters are treated specially.
>   - contrary to in the Bourne shell, pdksh or zsh, IFS is an
> internal field terminator, not separator ("a:b:" is split
> into "a" and "b", not "a" and "b" and "" which makes it
> inappropriate to split $PATH for instance) (in the Bourne
> shell, it splits into "a" and "b" as well but that's because
> empty elements are removed there)

It looks like an empty word is created when the separator is at the
beginning, but not when it's at the end (bash 3.2 and 4):

$ IFS=':'
$ v=":a:b"
$ arr=($v)
$ declare -p arr
declare -a arr='([0]="" [1]="a" [2]="b")'
$ v="a:b:"
$ arr=($v)
$ declare -p arr
declare -a arr='([0]="a" [1]="b")'

-- 
D.




String Concatenation with $'\NNN' Error

2009-03-16 Thread tony
Configuration Information [Automatically generated, do not change]:
Machine: i686
OS: linux-gnu
Compiler: i686-pc-linux-gnu-gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i686' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-pc-linux-gnu' 
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL 
-DHAVE_CONFIG_H   -I.  -I. -I./include -I./lib   -O2 -march=pentium3 -pipe
uname output: Linux steelbox 2.6.27.10 #11 Mon Mar 2 19:48:16 CST 2009 i686 AMD 
Athlon(tm) XP 3000+ AuthenticAMD GNU/Linux
Machine Type: i686-pc-linux-gnu

Bash Version: 3.2
Patch Level: 39
Release Status: release

Description:
This command sequence concatenates a text string with a $'\NNN' string 
producing an error:
shopt -s extglob; x="hello"$'\179'; echo "${x//+([^[:print:]])/?}"

EXPECTED RESULT IS -> hello?

HOWEVER, THE RESULT THAT IS PRODUCED IS -> hello?9

Repeat-By:
Reproduce by running the above command sequence.




Re: Bash Bug: Concatenating String with $'\NNN' Error

2009-03-16 Thread Tony Thedford
I just sent a bug report with the above description; please ignore.. I'm 
an idiot. There is no error actually my math was bad.





bash error on tab completion Ubuntu 8.04

2009-03-16 Thread Cian Brennan,v177B,017005132,0851601473
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='/fast-storage/users/l/lil_cain/32bit/share/locale' 
-DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H   -I.  -I. -I./include -I./lib   -g -O2
uname output: Linux carbon 2.6.24-22-generic #1 SMP Mon Nov 24 18:32:42 UTC 
2008 i686 GNU/Linux
Machine Type: i686-pc-linux-gnu

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

Description:
When attempting tab completion, the following error occcurs:
malloc: /Users/chet/src/bash/src/parse.y:5561: assertion botched
free: called with unallocated block argument
last command: (null)
Aborting...Aborted
Bash then exits.


Repeat-By:
Run Bash. Type ls *. Hit tab.




Re: String Concatenation with $'\NNN' Error

2009-03-16 Thread Greg Wooledge
On Sun, Mar 15, 2009 at 07:21:06AM -, t...@accesslab.com wrote:
>   This command sequence concatenates a text string with a $'\NNN' string 
> producing an error:
>   shopt -s extglob; x="hello"$'\179'; echo "${x//+([^[:print:]])/?}"
>   
>   EXPECTED RESULT IS -> hello?
> 
>   HOWEVER, THE RESULT THAT IS PRODUCED IS -> hello?9

'179' is not a valid octal number.  What you're actually doing is putting
hello$'\017'9 into the variable, which you can verify by dumping the
contents of $x before the substitution.




Re: bash error on tab completion Ubuntu 8.04

2009-03-16 Thread Chet Ramey
> Machine Type: i686-pc-linux-gnu
> 
> Bash Version: 4.0
> Patch Level: 0
> Release Status: release
> 
> Description:
>   When attempting tab completion, the following error occcurs:
>   malloc: /Users/chet/src/bash/src/parse.y:5561: assertion botched
>   free: called with unallocated block argument
>   last command: (null)
>   Aborting...Aborted
>   Bash then exits.
> 
> 
> Repeat-By:
>   Run Bash. Type ls *. Hit tab.

Apply the bash-4.0 patches.  This is fixed by patch 2.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer

Chet Ramey, ITS, CWRUc...@case.eduhttp://tiswww.tis.case.edu/~chet/