[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
out-of-range-offset or zero-length substring parameter expansion
From: |
Lorenzo Viali |
Subject: |
out-of-range-offset or zero-length substring parameter expansion |
Date: |
Mon, 25 Sep 2006 03:13:24 -0700 (PDT) |
Configuration Information [Automatically generated, do
not change]:
Machine: i386
OS: linux-gnu
Compiler: i386-pc-linux-gnu-gcc
Compilation CFLAGS: -DPROGRAM='bash'
-DCONF_HOSTTYPE='i386' -DCONF_OSTYPE='linux-gnu'
-DCONF_MACHTYPE='i386-pc-linux-gnu' -DCONF_VENDOR='pc'
-DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash'
-DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib
-Os -mcpu=i686 -pipe
uname output: Linux gseba-mobile 2.6.18-rc7 #3 Fri Sep
22 18:37:46 GMT 2006 i686 Mobile AMD Sempron(tm)
Processor 3300+ AuthenticAMD GNU/Linux
Machine Type: i386-pc-linux-gnu
Bash Version: 3.1
Patch Level: 17
Release Status: release
Description:
when taking the substring of a variable, in
certain conditions, it behaves differently whether or
not is surrounded by other strings
Repeat-By:
$ x="alfa"
$ echo ${#x}
4
$ # now we're taking the substring of x
$ # starting from index 4 (should be null)
$ [ "${x:4}" == "" ] && echo ok
ok
$ # now we're taking the substring of x
$ # starting from index 4, but we wrap
$ # it between `|' (should be `||')
$ [ "|${x:4}|" == "||" ] && echo ok
$ # nothing was echoed
$ #
$ # now we're taking a substring of x
$ # of length 0 (should be null)
$ [ "${x::0}" == "" ] && echo ok
ok
$ # now we're taking a substring of x
$ # of length 0, but we wrap
$ # it between `|' (should be `||')
$ [ "|${x::0}|" == "||" ] && echo ok
$ # nothing was echoed
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- out-of-range-offset or zero-length substring parameter expansion,
Lorenzo Viali <=