[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150626073145.GU5927@medion.lan>
Date: Fri, 26 Jun 2015 09:31:45 +0200
From: Bastian Bittorf <bittorf@...ebottle.com>
To: netdev@...r.kernel.org, Vadim Kochan <vadim4j@...il.com>
Subject: Re: iproute2 / question: returncode when query a match
* Vadim Kochan <vadim4j@...il.com> [15.06.2015 18:36]:
> > root@box:~ ip route list exact '0.0.0.0/8'
> > root@box:~ echo $?
> > 0
> >
> > i expected an RC of != 0 when there is no match.
> > is this by design?
> >
> > root@box:~ ip -V
> > ip utility, iproute2-ss4.0.0-1-openwrt
>
> I think that RC != 0 only in case error happened, but may be its good
> idea to add such behaviour or add option to consider ret code
> if there is no results ?
ofcourse this is only useful for scripting:
# ip route list exact '0.0.0.0/8' || do_some_action
instead of the now used construct:
# [ -n "$( ip route list exact '0.0.0.0/8' )" ] || do_some_action
i'am sure there are other queries, where this also
makes sense. there are 2 possible ways for implementing this IMHO:
introduce a commandlineswitch like --pedantic
or just always throw an error 1 when there is no match like this:
root@box:~ echo foo | grep bar
root@box:~ echo $?
1
more opinions about that?
bye, bastian
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists