Skip to content

Fixes, tests, and enhancements for grep (part 1)

Chad Williamson requested to merge dahc/extrautils:grepwork into master

The grep implementation here needs some TLC.

In this MR:

  • Use standard exit behavior:
    • Return 0 if there were matches and no errors (and for --help)
    • Return 1 if there were no matches (useful in scripts)
    • Return >1 if there were any errors, but wait to do so until all files have been processed (useful when globbing over a busy directory, for example)
  • Fix a couple bugs:
    • Don't throw a missing pattern error when --help is called
    • Suppress match output if --count is given
  • Add filename headers when dealing with multiple files (and standard -h/-H flags)
  • Implement --ignore-case, --max-count, and --quiet flags
  • Add fairly comprehensive integration/regression tests
  • Switch to arg-parser library for argument parsing

There's more I'd like to do (regex support, recursive search, options for context and binary files), but I don't want this MR to get too big, especially since it's my first Redox contribution.

Edited by Chad Williamson

Merge request reports