[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Parameter substring expansion not work for negative offset]

From: hanzlik
Subject: [Parameter substring expansion not work for negative offset]
Date: Sun, 8 Sep 2013 07:20:21 +0200

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 
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

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.

$ 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 <address@hidden>

reply via email to

[Prev in Thread] Current Thread [Next in Thread]