[Toybox] [PATCH] grep: add -R as well as -r.

Rob Landley rob at landley.net
Fri Jul 12 10:30:01 PDT 2019


On 7/11/19 2:24 PM, enh via Toybox wrote:
> On BSD these are actually the same, and there's a -S that you need in
> addition. So strictly this is a behavior change for Android (which is
> going from BSD grep to toybox grep), but it's a behavior preserving
> change for the AOSP build (which is going from GNU grep to toybox grep),
> and the latter actually has a checked-in use of -R where the former
> doesn't.

Applied. I'm sorry I haven't cycled back around to the input and output larger
buffer sizes. (I think for output I need an alarm(1) with a flush(stdout). It's
terrible, but would provide approximately the interactive behavior I want with
the batching behavior you want. I also need to make the _input_ do large blocks
and/or mmap too, I thought through the design of that at the time bug don't
remember the details, I should try again and blog notes...)

I'm trying to get the darn shell usable this month. Just checked in the second
round of continuation plumbing that may need some debugging but in _theory_ can
now do proper continuations for:

if cat << EOF -; then cat <(cat << ALSO -
> echo rest of parenthetical)
> data for first cat
> EOF
> data for third cat
> ALSO

Now I'm trying to make block redirections work:

if
  read i
  echo $i
then
  cat
fi < file.txt

where the redirect applies to the whole block.

Instead of a stack, the parsing needs to record a list of them all with pointers
to where to look next. So the if would have a pointer to the fi. But this would
imply the HERE documents are parsed out of order, meaning my linked list of them
isn't sufficient, possibly I need to stick them in struct sh_arg along with the
line they go to.

And yes you CAN have multiple HERE documents. They're queried in order. For it
to be useful, you need to use the 2<<EOF or {X}<<EOF syntax, which I figured out
_DOES_ work as block redirections, but bash doesn't seem to implement it as
command redirections? Weird. Probably a bash bug.

Rob



More information about the Toybox mailing list