gA: declare and assign vs. declare then assign
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/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib -D_FORTIFY_SOURCE=2 -march=i686 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -DDEFAULT_PATH_VALUE='/usr/local/sbin:/usr/local/bin:/usr/bin' -DSTANDARD_UTILS_PATH='/usr/bin' -DSYS_BASHRC='/etc/bash.bashrc' -DSYS_BASH_LOGOUT='/etc/bash.bash_logout' uname output: Linux localhost 3.12.5-1-ARCH #1 SMP PREEMPT Thu Dec 12 13:32:40 CET 2013 i686 GNU/Linux Machine Type: i686-pc-linux-gnu Bash Version: 4.2 Patch Level: 45 Release Status: release Description: When declaring a global associative array inside a function and assigning a value to it at the same time, then the array is not globally visible. This doesn't happen if I declare the array first and then do the assignment. That is: Buggy?: function f { declare -gA a=([a]=2 [b]=4) } Ok: function f { declare -gA a; a4=([a]=2 [b]=4) } I'm not sure if this is related to this previous report of mine: http://lists.gnu.org/archive/html/bug-bash/2013-09/msg00025.html If it is, at least I could say I've found a workaround :). Repeat-By: function f1 { declare -ga a1=([1]=2 [2]=4) declare -p a1 } function f2 { declare -gA a2=([a]=2 [b]=4) declare -p a2 } function f3 { declare -ga a3; a3=([1]=2 [2]=4) declare -p a3 } function f4 { declare -gA a4; a4=([a]=2 [b]=4) declare -p a4 } declare -A a5=([a]=2 [b]=4) f1 f2 f3 f4 declare -p a1 declare -p a2 declare -p a3 declare -p a4 declare -p a5
Re: gA: declare and assign vs. declare then assign
On 1/15/14, 10:04 PM, Carlos Pita wrote: > Bash Version: 4.2 > Patch Level: 45 > Release Status: release > > Description: > > When declaring a global associative array inside a function and > assigning a value to it at the same time, then the array is not > globally visible. This doesn't happen if I declare the array first and > then do the assignment. That is: > > Buggy?: > function f { > declare -gA a=([a]=2 [b]=4) > } This is a bug in bash-4.2 that is fixed in bash-4.3. It looks like it was fixed back in November, 2012. 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/
history writing bug
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/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I../bash -I../bash/include -I../bash/lib -D_FORTIFY_SOURCE=2 -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wall uname output: Linux celerypad 3.13.0-3-generic #18-Ubuntu SMP Mon Jan 13 19:16:46 UTC 2014 i686 i686 i686 GNU/Linux Machine Type: i686-pc-linux-gnu Bash Version: 4.2 Patch Level: 45 Release Status: release Description: portions of bash history appear repeatedly in .bash_history, and prior session history is prematurely eliminated. Repeat-By: not predictably repeatable. no idea of the causing condition. Observations: in both examples below, the history file begins with two copies of a portion of the offending session, followed by *preceeding* session commands, followed by additional repetition of the offending session, followed by another session. Example #1 history: first repetition: 1 2014-01-15Wed17:00:30 10ut (/root/.bash_history ) root 10ut ,pts/2 2 2014-01-15Wed17:10:38 10ut dfm 3 2014-01-15Wed17:11:11 10ut aagi vim vim-doc htop twm xterm vnc4server xvnc4viewer vlc vlc-plugin-jack xpdf 4 2014-01-15Wed17:11:27 10ut rqb vim-doc 5 2014-01-15Wed17:11:47 10ut agi vim vim-doc htop twm xterm vnc4server xvnc4viewer vlc vlc-plugin-jack xpdf second repetition: 6 2014-01-15Wed17:00:30 10ut (/root/.bash_history ) root 10ut ,pts/2 7 2014-01-15Wed17:10:38 10ut dfm 8 2014-01-15Wed17:11:11 10ut aagi vim vim-doc htop twm xterm vnc4server xvnc4viewer vlc vlc-plugin-jack xpdf 9 2014-01-15Wed17:11:27 10ut rqb vim-doc 10 2014-01-15Wed17:11:47 10ut agi vim vim-doc htop twm xterm vnc4server xvnc4viewer vlc vlc-plugin-jack xpdf *prior* session(s): 11 2014-01-15Wed16:31:18 10ut apt-get install openssh-server screen 12 2014-01-15Wed16:31:32 10ut apt-get install openssh-server 13 2014-01-15Wed16:32:04 10ut df -m 14 2014-01-15Wed16:32:27 10ut mkdir /ql 15 2014-01-15Wed16:32:33 10ut mount /dev/sda1 /ql 16 2014-01-15Wed16:32:46 0ut (/root/.bash_history ) root 0ut ,tty1 17 2014-01-15Wed16:33:59 0ut . /ql/home/greg/ 18 2014-01-15Wed16:34:14 0ut rqa trusty-alternate-i386 19 2014-01-15Wed16:34:46 0ut apt-get install openssh-server 20 2014-01-15Wed16:35:59 0ut ag update 21 2014-01-15Wed16:36:48 0ut apt-get update 22 2014-01-15Wed16:37:55 0ut apt-get install openssh-server third repetition: 23 2014-01-15Wed17:00:30 10ut (/root/.bash_history ) root 10ut ,pts/2 24 2014-01-15Wed17:10:38 10ut dfm 25 2014-01-15Wed17:11:11 10ut aagi vim vim-doc htop twm xterm vnc4server xvnc4viewer vlc vlc-plugin-jack xpdf 26 2014-01-15Wed17:11:27 10ut rqb vim-doc 27 2014-01-15Wed17:11:47 10ut agi vim vim-doc htop twm xterm vnc4server xvnc4viewer vlc vlc-plugin-jack xpdf 28 2014-01-15Wed17:13:18 10ut agi vim 29 2014-01-15Wed17:14:44 10ut rqb vim 30 2014-01-15Wed17:14:53 10ut agi vim vim-doc htop twm xterm vnc4server xvnc4viewer vlc vlc-plugin-jack xpdf 31 2014-01-15Wed17:44:09 10ut llt /var/local/?p*/* 32 2014-01-15Wed17:44:15 10ut llt {,/*}/var/local/?p*/* 33 2014-01-15Wed17:44:48 10ut rqa vlc 34 2014-01-15Wed17:48:08 10ut dfm 35 2014-01-15Wed17:48:23 10ut agi lubuntu-desktop fourth repetition: 36 2014-01-15Wed17:00:30 10ut (/root/.bash_history ) root 10ut ,pts/2 37 2014-01-15Wed17:10:38 10ut dfm 38 2014-01-15Wed17:11:11 10ut aagi vim vim-doc htop twm xterm vnc4server xvnc4viewer vlc vlc-plugin-jack xpdf 39 2014-01-15Wed17:11:27 10ut rqb vim-doc 40 2014-01-15Wed17:11:47 10ut agi vim vim-doc htop twm xterm vnc4server xvnc4viewer vlc vlc-plugin-jack xpdf 41 2014-01-15Wed17:13:18 10ut agi vim 42 2014-01-15Wed17:14:44 10ut rqb vim 43 2014-01-15Wed17:14:53 10ut agi vim vim-doc htop twm xterm vnc4server xvnc4viewer vlc vlc-plugin-jack xpdf 44 2014-01-15Wed17:44:09 10ut llt /var/local/?p*/* 45 2014-01-15Wed17:44:15 10ut llt {,/*}/var/local/?p*/* 46 2014-01-15Wed17:44:48 10ut rqa vlc 47 2014-01-15Wed17:48:08 10ut dfm 48 2014-01-15Wed17:48:23 10ut agi lubuntu-desktop fifth repetition, complete session: 49 2014-01-15Wed17:00:30 10ut (/root/.bash_history ) root 10ut ,pts/2 50 2014-01-15Wed17:10:38 10ut dfm 51 2014-01-15Wed17:11:11 10ut aagi vim vim-doc htop twm xterm vnc4server xvnc4viewer vlc vlc-plugin-jack xpdf 52 2014-01-15Wed17:11:27 10ut rqb vim-doc 53 2014-01-15Wed17:11:47 10ut agi vim vim-doc htop twm xterm vnc4server xvnc4viewer vlc vlc-plugin-jack xpdf 54 2014-01-15Wed17:13:18
DEL character treated specially when preceded by a backslash when used in the RHS of the regex operator ([[ $'\177' =~ $'\\\177' ]])
The DEL ($'\177') character does not behave like the other control characters when used with the regex operator inside the test keyword. This example shows the difference in operation: ubuntu@ubuntu:~$ for c in $'\001' $'\a' $'\177' $'\377'; do for r in "$c" "\\$c" "\\[$c]"; do [[ $c =~ $r ]]; printf '[[ %q =~ %q ]] -> %d\n' "$c" "$r" "$?"; done; printf %s\\n ---; done; [[ $'\001' =~ $'\001' ]] -> 0 [[ $'\001' =~ $'\\\001' ]] -> 0 [[ $'\001' =~ $'\\[\001]' ]] -> 1 --- [[ $'\a' =~ $'\a' ]] -> 0 [[ $'\a' =~ $'\\\a' ]] -> 0 [[ $'\a' =~ $'\\[\a]' ]] -> 1 --- [[ $'\177' =~ $'\177' ]] -> 0 [[ $'\177' =~ $'\\\177' ]] -> 1 [[ $'\177' =~ $'\\[\177]' ]] -> 1 --- [[ $'\377' =~ $'\377' ]] -> 0 [[ $'\377' =~ $'\\\377' ]] -> 0 [[ $'\377' =~ $'\\[\377]' ]] -> 1 --- Notice that only $'\177' seems to fail in the middle case, while the others work just fine. I also noticed the following strange behavior in bash under Cygwin: $ for c in $'\001' $'\a' $'\177' $'\377'; do for r in "$c" "\\$c" "\\[$c]"; do [[ $c =~ $r ]]; printf '[[ %q =~ %q ]] -> %d\n' "$c" "$r" "$?"; done; printf %s\\n ---; done; [[ $'\001' =~ $'\001' ]] -> 0 [[ $'\001' =~ $'\\\001' ]] -> 0 [[ $'\001' =~ $'\\[\001]' ]] -> 1 --- [[ $'\a' =~ $'\a' ]] -> 0 [[ $'\a' =~ $'\\\a' ]] -> 0 [[ $'\a' =~ $'\\[\a]' ]] -> 1 --- [[ $'\177' =~ $'\177' ]] -> 0 [[ $'\177' =~ $'\\\177' ]] -> 1 [[ $'\177' =~ $'\\[\177]' ]] -> 1 --- [[ $'\377' =~ $'\377' ]] -> 2 [[ $'\377' =~ $'\\\377' ]] -> 2 [[ $'\377' =~ $'\\[\377]' ]] -> 2 --- Notice the weird return code for non-ASCII characters. I wonder if this has to do more with the regex library it was compiled against. The bash versions: - cygwin: $ bash --version GNU bash, version 4.1.10(4)-release (i686-pc-cygwin) - ubuntu: $ bash --version GNU bash, version 4.2.25(1)-release (x86_64-pc-linux-gnu) (seems to be present in 4.3.x, the DEL character issue) Why is DEL treated specially when preceded by a backslash in the regex operator? -- Eduardo Alan Bustamante López
Re: Including \t, \T or \A at beginning of PS1 causes line wrap issues
+Cc: bug-bash Please do not take discussions off-list, it decreases the value of conversations for future readers. On 2014-01-16 23:13:35 -0600, David C. Rankin wrote: > A sanitized version w/o color. That detail matters -- please include the full scope of the issue in future when reporting issues. My first thought when hearing about wrapping issues is always that there are improperly stated zero-width sequences in the prompt. > The full prompt exported in .bashrc is: > > PS1="\[\e[0;37m\]\A\[\e[1;34m\] \h:\w> \[\e[0m\]" > > also tested with: > > PS1="\[\e[0;37m\]\D{%R}\[\e[1;34m\] \h:\w> \[\e[0m\]" Those actually look okay to me (and I can't seem to reproduce your issue, unless I misunderstood the steps), but maybe I'm missing something. Either way, just use "tput", it will save you from a world of pain, and it actually uses the terminfo database: PS1='\[$(tput setaf 7)\]\A\[$(tput bold)$(tput setaf 4)\] \h:\w> \[$(tput sgr0)\]' You can also put those in variables to avoid calling "tput" every time the prompt is drawn. pgppRR0z_fzkh.pgp Description: PGP signature