RFD: return code for mogtool listkey

Brad Fitzpatrick brad at danga.com
Thu Jun 21 13:52:09 UTC 2007


Why gt and not >?

Just document the mogtool return values in the POD (perhaps a new =head1
RETURN VALUES section), and it looks fine.


On Thu, 21 Jun 2007, Robin H. Johnson wrote:

> Hi folks,
>
> I didn't want to commit this change blindly, since somebody might be depending
> on the behavior.
>
> When you use 'mogtool listkey', I want exit with a non-zero code if no files
> were found. This saves having to parse the output.
>
> Opinions?
>
> ==============
>
> Give an non-zero return code if listkey returns no output.
>
> Signed-off-by: Robin H. Johnson <robbat2 at gentoo.org>
>
> diff --git a/utils/mogtool b/utils/mogtool
> index 2a0b17a..7d822ea 100755
> --- a/utils/mogtool
> +++ b/utils/mogtool
> @@ -1249,6 +1249,7 @@ sub listkey {
>
>      # list all files matchine a key
>      my ($ct, $after, $list);
> +    $ct = 0;
>      while (($after, $list) = $mogfs->list_keys("$key_pattern", $after)) {
>          last unless $list && @$list;
>
> @@ -1261,7 +1262,8 @@ sub listkey {
>          }
>      }
>      print "#$ct files found\n";
> -    exit 0;
> +    exit 0 if($ct gt 0);
> +    exit 1;
>  }
>
>  sub mdelete {
>
> --
> Robin Hugh Johnson
> Gentoo Linux Developer & Council Member
> E-Mail     : robbat2 at gentoo.org
> GnuPG FP   : 11AC BA4F 4778 E3F6 E4ED  F38E B27B 944E 3488 4E85
>


More information about the mogilefs mailing list