[Toybox] Bug: "grep ^." matches only literal '.'

Jörgen Cederlöf jc0x00 at gmail.com
Mon Jul 20 00:29:52 UTC 2026


This was unexpected. If the first one matches, the second one should match too:

  kirkwood:/etc $ ls -l |grep '^-......r' |wc -l
  30
  kirkwood:/etc $ ls -l |grep '^.......r' |wc -l
  0
  kirkwood:/etc $ grep --version
  toybox 0.8.9-android

It is reproducible on current master (0bb70e68):

  $ echo foo |./toybox grep ^f || echo FAIL
  foo
  $ echo foo |./toybox grep ^. || echo FAIL
  FAIL
  $ echo .oo |./toybox grep ^. || echo FAIL
  .oo
  $

It matches correctly if the regexp is more complex so the fast path
does not kick in:

  $ echo foo |./toybox grep '^.\{1\}' || echo FAIL
  foo
  $

Jorgen


More information about the Toybox mailing list