[Parameter substring expansion not work for negative offset]
Configuration Information: Machine: i686 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i686' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-redhat-linux-gnu' -DCONF_VENDOR='redhat' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib -D_GNU_SOURCE -DRECYCLES_PIDS -DDEFAULT_PATH_VALUE='/usr/local/bin:/usr/bin' -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables uname output: Linux franta.hanzlici.cz 3.10.10-200.fc19.i686.PAE #1 SMP Thu Aug 29 19:16:15 UTC 2013 i686 i686 i386 GNU/Linux Machine Type: i686-redhat-linux-gnu Bash Version: 4.2 Patch Level: 45 Release Status: release Description: As I understand bash man page, using negative offset in substring expansion ${parameter:offset} / ${parameter:offset:length} then offset shoul be taken as offset from the parameter value string. Thus, e.g. ${A:-1} or ${A:-1:1} should return last character from $A string. But this construct return me all $A string. Repeat-By: $ A="abcd0"; E1=${A:-1:1}; E2=${A:-1}; echo "A=$A, E1=$E1, E2=$E2." A=abcd0, E1=abcd0, E2=abcd0. # I expect result E1==E2=="0", right? Sorry if I made some mistake here. With regards, Franta Hanzlik
Re: [Parameter substring expansion not work for negative offset]
On Sep 8, 2013 10:44 AM, "hanzlik" wrote: > > Configuration Information: > Machine: i686 > OS: linux-gnu > Compiler: gcc > Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i686' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-redhat-linux-gnu' -DCONF_VENDOR='redhat' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib -D_GNU_SOURCE -DRECYCLES_PIDS -DDEFAULT_PATH_VALUE='/usr/local/bin:/usr/bin' -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables > uname output: Linux franta.hanzlici.cz 3.10.10-200.fc19.i686.PAE #1 SMP Thu Aug 29 19:16:15 UTC 2013 i686 i686 i386 GNU/Linux > Machine Type: i686-redhat-linux-gnu > > Bash Version: 4.2 > Patch Level: 45 > Release Status: release > > Description: > As I understand bash man page, using negative offset in substring expansion > ${parameter:offset} / ${parameter:offset:length} > then offset shoul be taken as offset from the parameter value string. > Thus, e.g. ${A:-1} or ${A:-1:1} should return last character from $A string. > But this construct return me all $A string. > > Repeat-By: > $ A="abcd0"; E1=${A:-1:1}; E2=${A:-1}; echo "A=$A, E1=$E1, E2=$E2." > A=abcd0, E1=abcd0, E2=abcd0. > > # I expect result E1==E2=="0", right? > > Sorry if I made some mistake here. > With regards, Franta Hanzlik > The man page says "Note that a negative offset must be separated from the colon by at least one space..."
Re: multi-line like C-style comments ( /* code */ ) in bash
On 9/7/13 1:05 PM, Edik Bondarenko wrote: > I am added function `discard_multiline_comments` which disables code > between /* and */ (C-style comments). > The body of the function is located in the file y.tab.c : 5140 . > Can this functionality be added in the next release ? Thanks for your contribution. I don't think this feature is desirable or needed enough to add to bash. 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/