~alpine/devel

4 2

[alpine-devel] Busybox diff / grep oddities

Details
Message ID
<CAEuRe+3fb1Xz-+DJzPth2uJP6XaGjDWMwLmcbnggv_c89bskOQ@mail.gmail.com>
Sender timestamp
1408714398
DKIM signature
missing
Download raw message
Recursive diff succeeds without trying?
  busybox diff -rq /bin /etc
  echo $?


This should be a match?
  echo "abbc" |  busybox grep 'ab\+c'

 - Jeff


---
Unsubscribe:  alpine-devel+unsubscribe@lists.alpinelinux.org
Help:         alpine-devel+help@lists.alpinelinux.org
---

[alpine-devel] Re: Busybox diff / grep oddities

Details
Message ID
<53F75FF0.6050305@arcor.de>
In-Reply-To
<CAEuRe+3fb1Xz-+DJzPth2uJP6XaGjDWMwLmcbnggv_c89bskOQ@mail.gmail.com> (view parent)
Sender timestamp
1408720880
DKIM signature
missing
Download raw message
Hi Jeff,
> Recursive diff succeeds without trying?
>   busybox diff -rq /bin /etc
>   echo $?
Actually, it does what it's supposed to do with BusyBox 1.21.1 on Alpine
2.7.9.

|  $ diff -rq /bin /etc||
||  Only in /etc: TZ||
||  Only in /bin: addgroup||
||  Only in /bin: adduser||
||  Only in /etc: adjtime||
||  Only in /etc: alpine-release||
||  Only in /bin: ash||
||  [...]||
||  $ echo $?||
||  1||
|
> This should be a match?
>   echo "abbc" |  busybox grep 'ab\+c'
A very peculiar behaviour, indeed. Though, syntax and match are correct,
because:

  "In  basic  regular  expressions the metacharacters ?, +, {, |, (, and )
  lose their special meaning; instead use the backslashed versions \?,
  \+, \{, \|, \(, and \)."


For more information see: http://unixhelp.ed.ac.uk/CGI/man-cgi?grep

I've verified the behaviour with GNU grep 2.18, as well. Your example is
equivalent to:

|  echo "abbc" | grep 'abb*c'||
|
HIH, Tiger

[alpine-devel] Re: Busybox diff / grep oddities

Details
Message ID
<53F7C19A.506@arcor.de>
In-Reply-To
<20140823004905.03159b08@vostro> (view parent)
Sender timestamp
1408745882
DKIM signature
missing
Download raw message
>>> Recursive diff succeeds without trying?
>>>   busybox diff -rq /bin /etc
>>>   echo $?
>> Actually, it does what it's supposed to do with BusyBox 1.21.1 on
>> Alpine 2.7.9.
> Not sure about this... but.
The given example works with BusyBox 1.22.1 on 3.0.1 just as well.

> Alpine 3.0+ use musl implementation of regular expressions in busybox.
There we go: grep 'ab\+c' certainly fails on 3.0, while grep 'abb*c' is
POSIX and therefore working fine.

Tiger


---
Unsubscribe:  alpine-devel+unsubscribe@lists.alpinelinux.org
Help:         alpine-devel+help@lists.alpinelinux.org
---

Re: [alpine-devel] Re: Busybox diff / grep oddities

Timo Teras <timo.teras@iki.fi>
Details
Message ID
<20140823004905.03159b08@vostro>
In-Reply-To
<53F75FF0.6050305@arcor.de> (view parent)
Sender timestamp
1408744145
DKIM signature
missing
Download raw message
On Fri, 22 Aug 2014 17:21:20 +0200
Der Tiger <der.tiger.alpine@arcor.de> wrote:

> Hi Jeff,
> > Recursive diff succeeds without trying?
> >   busybox diff -rq /bin /etc
> >   echo $?
> Actually, it does what it's supposed to do with BusyBox 1.21.1 on
> Alpine 2.7.9.
> 
> |  $ diff -rq /bin /etc||
> ||  Only in /etc: TZ||
> ||  Only in /bin: addgroup||
> ||  Only in /bin: adduser||
> ||  Only in /etc: adjtime||
> ||  Only in /etc: alpine-release||
> ||  Only in /bin: ash||
> ||  [...]||
> ||  $ echo $?||
> ||  1||

Not sure about this... but.

> > This should be a match?
> >   echo "abbc" |  busybox grep 'ab\+c'
> A very peculiar behaviour, indeed. Though, syntax and match are
> correct, because:
> 
>   "In  basic  regular  expressions the metacharacters ?, +, {, |, (,
> and ) lose their special meaning; instead use the backslashed
> versions \?, \+, \{, \|, \(, and \)."
> 
> 
> For more information see: http://unixhelp.ed.ac.uk/CGI/man-cgi?grep
> 
> I've verified the behaviour with GNU grep 2.18, as well. Your example
> is equivalent to:
> 
> |  echo "abbc" | grep 'abb*c'||
> |

Alpine 3.0+ use musl implementation of regular expressions in busybox.
musl is strictly POSIX confirming, and \+ in BRE is not POSIX
specified. Some implementations support it, notable GNU. But that is
implementation specific extension and not portable or standard
compliant.

The posix compliant way is:

$ echo "abbc" | busybox grep "ab\{1,\}c"
abbc

See, eg. http://www.regular-expressions.info/posix.html

/Timo


---
Unsubscribe:  alpine-devel+unsubscribe@lists.alpinelinux.org
Help:         alpine-devel+help@lists.alpinelinux.org
---

[alpine-devel] Re: Busybox diff / grep oddities

Timo Teras <timo.teras@iki.fi>
Details
Message ID
<20140823013326.6f9d4103@vostro>
In-Reply-To
<53F7C19A.506@arcor.de> (view parent)
Sender timestamp
1408746806
DKIM signature
missing
Download raw message
On Sat, 23 Aug 2014 00:18:02 +0200
Der Tiger <der.tiger.alpine@arcor.de> wrote:

> 
> >>> Recursive diff succeeds without trying?
> >>>   busybox diff -rq /bin /etc
> >>>   echo $?
> >> Actually, it does what it's supposed to do with BusyBox 1.21.1 on
> >> Alpine 2.7.9.
> > Not sure about this... but.
> The given example works with BusyBox 1.22.1 on 3.0.1 just as well.

Yes. And is broken in edge. Seems stat() returns different stuff. Not
sure if it's kernel, musl or busybox bug, but it is a bug.

- Timo


---
Unsubscribe:  alpine-devel+unsubscribe@lists.alpinelinux.org
Help:         alpine-devel+help@lists.alpinelinux.org
---
Reply to thread Export thread (mbox)