[Open-FCoE] [PATCH] fcoe-utils: Add debug/ directory and dcbcheck.sh script

Joe Eykholt jeykholt at cisco.com
Tue Apr 14 16:59:17 UTC 2009


Robert Love wrote:
> On Mon, 2009-04-13 at 15:20 -0700, Joe Eykholt wrote:
>> Robert Love wrote:
> <snip>
>> BTW, you could use grep -q instead of grep -c.
>>
>> Instead of:
>>
>> 	if [ `dcbtool gc ${IFNAME} app:0 | grep Enable | grep -c true` -ne 1 ] ; then
>>
>> do:
>> 	if dcbtool gc ${IFNAME} app:0 | grep Enable | grep -q true ; then : ; else
>> 		echo ...
>>
>> To further simplify (but possibly obscure):
>>
>> 	dcbtool gc ${IFNAME} app:0 | grep Enable | grep -q true || echo "not enabled ..."
>>
> I started coding this, but I don't think that I like it. This is the DCB
> check, not app:0, but it's the syntax we're talking about. I end up
> with-
> 
> dcbtool gc ${IFNAME} dcb | grep 'DCB State' | grep -q on ||
> ( echo "DCB is not on, exectue the following command to turn it on" >&2
> &&
>     echo "dcbtool sc ${IFNAME} dcb on" >&2 &&
>     failure=1 )
> 
> (the line wrap is making this look a bit funky, the "&&" on line #3
> should really be at the end of line #2)
> 
> I don't think the shortcut use makes it any more readable since I really
> want to do 3 things on the failure of my dcbtool output greppping.

Also, setting failure=1 in a subshell (in the parens) doesn't change
the value in the parent shell, so that won't work.

How about:

	dcbtool gc ${IFNAME} dcb | grep 'DCB State' | grep -q on
	if [ $? -ne 0 ]
	then
		echo "DCB is not on, exectue the following command to turn it on" >&2
		echo "dcbtool sc ${IFNAME} dcb on" >&2
		failure=1
	fi

Regards,
	Joe







More information about the devel mailing list