Skip to contentSkip to conversation

another cleanup: "grep ... >/dev/null" -> "grep -q"?

DISCUSSION Robert P. J. Day 2 participants 2 messages Mar 25, 2017 – Mar 27, 2017

lore
Share & tools
lore
#0 lore raw

something else that grates on me:

$ grep "grep.*/dev/null" *
autotools.bbclass:		if grep "^[[:space:]]*AM_GLIB_GNU_GETTEXT" $CONFIGURE_AC >/dev/null; then
autotools.bbclass:			if grep "sed.*POTFILES" $CONFIGURE_AC >/dev/null; then
autotools.bbclass:		elif grep "^[[:space:]]*AM_GNU_GETTEXT" $CONFIGURE_AC >/dev/null; then
autotools.bbclass:		if grep "^[[:space:]]*[AI][CT]_PROG_INTLTOOL" $CONFIGURE_AC >/dev/null; then
insane.bbclass:            statement = "grep -e '%s/[^ :]\{1,\}/[^ :]\{1,\}' %s > /dev/null" % (exec_prefix, path)
insane.bbclass:        statement = "grep -e 'CROSS COMPILE Badness:' -e 'is unsafe for cross-compilation' %s > /dev/null" % compilelog
insane.bbclass:        statement = "grep -e 'CROSS COMPILE Badness:' -e 'is unsafe for cross-compilation' %s > /dev/null" % installlog
insane.bbclass:                gnu = "grep \"^[[:space:]]*AM_GNU_GETTEXT\" %s >/dev/null" % config
rootfs-postcommands.bbclass:		if grep -q DROPBEAR_EXTRA_ARGS ${IMAGE_ROOTFS}${sysconfdir}/default/dropbear 2>/dev/null ; then
utils.bbclass:	if echo "$destpath/" | egrep '^${STAGING_LIBDIR}/' >/dev/null
$

1) can most of those be simplified with "grep -q"?
2) is there any need for "egrep" in that last match?

rday

Signature · 7 lines
========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================
#1 lore raw
Quoted 2 lines · Robert P. J. Day

1) can most of those be simplified with "grep -q"?

Yes.

Quoted 2 lines

2) is there any need for "egrep" in that last match?

egrep is grep -E, but that regex is a valid basic RE, so that can just be grep.

Ross