[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: Re: sh shell - pattern substitution bug?
From: Steven Honeyman <stevenhoneyman () gmail ! com>
Date: 2015-01-09 21:36:10
Message-ID: CABz95_A+-Dw9uHdR16+V5OCgUm8OwotPkrYpFubtAgoKZ6E8gw () mail ! gmail ! com
[Download RAW message or body]
On 9 January 2015 at 19:34, Richard Moore <rich@richud.com> wrote:
> The inconsistent behaviour (below) leads me to think there some sort of
> backslash addition bug rather than a lack of function?
>
> ~ # i="a#b#c"
> ~ # echo ${i//#/':'}
> a\:b\:c
> ~ # echo ${i//#/';'}
> a;b;c
> ~ # echo ${i//#/'*'}
> a\*b\*c
> ~ # echo ${i//#/'^'}
> a^b^c
Hmm, so it is! I agree this is a bug. I did see it works OK without
the quotes though.
With the debug prints enabled:
$ echo ${i//#/'*'}
sh: subevalvar(p:'#/��*��',varname:'(null)',strloc:6,subtype:14,startloc:0,varflags:e,quotes:1)
sh: arg:'#/\*' varflags:e
sh: pattern:'#' repl:'\*'
a\*b\*c
$ echo ${i//#/*}
sh: subevalvar(p:'#/*�',varname:'(null)',strloc:6,subtype:14,startloc:0,varflags:e,quotes:1)
sh: arg:'#/*' varflags:e
sh: pattern:'#' repl:'*'
a*b*c
$ echo ${i//#/'^'}
sh: subevalvar(p:'#/�^��',varname:'(null)',strloc:6,subtype:14,startloc:0,varflags:e,quotes:1)
sh: arg:'#/^' varflags:e
sh: pattern:'#' repl:'^'
a^b^c
$ echo ${i//#/^}
sh: subevalvar(p:'#/^�',varname:'(null)',strloc:6,subtype:14,startloc:0,varflags:e,quotes:1)
sh: arg:'#/^' varflags:e
sh: pattern:'#' repl:'^'
a^b^c
Hopefully a quick fix for someone familiar with the ash code.
Thanks,
Steven
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic