[Top][All Lists]

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

Substring Expansion does not work as intended

From: eckard . brauer
Subject: Substring Expansion does not work as intended
Date: Wed, 20 Aug 2014 15:05:48 +0200

Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: x86_64-pc-linux-gnu-gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu' 
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL 
-DHAVE_CONFIG_H   -I. -I./include -I. -I./include -I./lib  
-DSYS_BASHRC='/etc/bash/bashrc' -DSYS_BASH_LOGOUT='/etc/bash/bash_logout' 
uname output: Linux walter 3.15.8-geek #2 SMP PREEMPT Tue Aug 12 14:12:15 CEST 
2014 x86_64 Intel(R) Core(TM)2 Duo CPU T7500 @ 2.20GHz GenuineIntel GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 4.2
Patch Level: 47
Release Status: release

        Substring Expansion actually works different than manpage states, 

        "If offset evaluates to a number less than zero, the value is used as 
an offset from the end of the value of parameter."

        x="abcdef"; echo "${x:-2}"
        Expected: ef
        Got:      abcdef

        x="abcdef"; echo "${x:-2:1}"
        Expected: e
        Got:      abcdef

reply via email to

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