Closed Konfekt closed 5 months ago
The default is -E
for egrep. See ugrep.com.
If you read the README from which this is quoted "Ugrep is a true drop-in replacement for GNU grep", then it says it is a drop-in replacement if you copy or rename ugrep. When you copy or rename ugrep to grep then it behaves as grep (with -G
). Likewise, copy ugrep to fgrep and it behaves as fgrep.
Or alias grep=ugrep -G
works fine.
The choice to make -E
the default is because ERE is more common these days and also Perl/PCRE syntax is ERE.
Okay, still getting used to executables behaving differently depending on how they are named (or which symlink called them!?)
Symlinking ug
or ugrep
to grep
generally works, but there are problems with bash when it does not propagate the grep
name to argv[0]
, which ugrep checks internally. Instead, bash propagates the symlinked target name ugrep
. This is not good. This was a surprise to me too.
It may work when symlinking from a home bin dir that is on your path, but not when installing the symlinked grep
command on a system path.
To check if ug
or ugrep
properly sees the symlinked name grep
, option --version
should tell you it is in "grep emu mode":
$ grep --version
ugrep 6.1.0 aarch64-apple-darwin21.6.0 (grep emu mode) +neon/AArch64; -P:pcre2jit; -z:zlib,bzip2,lzma,lz4,zstd,brotli,7z,tar/pax/cpio/zip
Referring to https://github.com/Genivia/ugrep?tab=readme-ov-file#why-use-ugrep
While
ugrep -G
interprets, say\(a1\|a2\)b\+
as basic regexp,ugrep
does not, though -G is the standard switch? Tested with GNU grep 3.7 on Opensuse 15.5