incoming exit status

Jason Harris jason at jasonfharris.com
Wed Nov 10 16:02:44 CST 2010


On Nov 10, 2010, at 10:52 PM, Haszlakiewicz, Eric wrote:

>> -----Original Message-----
>> From: Jason Harris [mailto:jason at jasonfharris.com]
>> 
>> Well you can just use 'hg --quiet incoming' to ensure you don't have any
>> chatty messages... If thats the empty string you don't have any incoming
>> changesets. Simple.
> 
> X=$(hg --quiet incoming)
> if [ -z "$X" ] ; then
> 	...
> fi
> 
> vs.
> 
> hg incoming > /dev/null
> if [ $? -eq 1 ] ; then
> 	...
> fi
> 
> eh, seems about the same to me.
> 
>> On Nov 10, 2010, at 8:50 PM, Matt Mackall wrote:
>>> On Wed, 2010-11-10 at 20:08 +0100, Jason Harris wrote:
>>>> Personally, I still feel that a valid command, that has executed in a
>> valid way, returning a valid result of (nothing) should have an exit code
>> of 0.
>> 
>>> Simply put, you're wrong. The grep command was created on March 3, 1973,
>>> so there's decades of historical and standards precedent for giving
>>> useful exit codes.
>> 
>> (Maybe grep is more of an aberration here than a paragon of consistency
>> with the wider world?  Are there many other examples of this behavior?
>> From what I can tell by googling it appears not... Eg things like ' touch
>> bob; wc bob; echo $? ' yields an exit code of 0. As does the unix 'find'
>> command when it doesn't find any matches, etc..)
> 
> There are lots of programs that use the exit value as more than just a boolean.  For instance:
> cmp
> diff
> gzip
> ping
> 
> just to name a few off the top of my head.

Ahh... Ok, its good to see other examples so it looks like the grep case isn't as weird as it first seemed to me. Thanks for the examples!

Cheers,
  Jas


More information about the Mercurial mailing list