Re: git config --get-regexp exit status

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



David Kågedal <davidk@xxxxxxxxxxxxxx> writes:

> David Kågedal <davidk@xxxxxxxxxxxxxx> writes:
> ...
> One thing that annoyed me what that "git config --get-regexp" will
> return zero, one, or more matches, which are all valid reponses. But
> it treats the zero-match special and return an exit status of 1.
>
> Is that a conscious choice, or just an effect of how "git config
> --get" works?
>
> Since zero matches isn't really an error, I would like the exit status
> to be 0. At least for this use case :-)

I would imagine "matching variant" may want to signal "I did not match
anything" as a special event, just like grep does.  As long as the
caller can distinguish "no match" from real failure cases (say, not in a
git repository and hence no configuration file), that is one valid use
of status code.

I haven't been annoyed by that myself, but I see what you mean.  "give
me all the matching ones" callers would want to consider zero match and
seven matches both the same way as non errors.  And similarity to "grep"
does not extend very far because there is no "--get-regexp" variant that
is quiet (i.e. "no output, just checking if there is a match").

So I do not mind if --get-regexp considered zero matches as non-error
myself.  If an existing script did something like:

	if list=$(git config --get-regexp '$pattern')
        then
        	# use list, without verifying if it is empty
                ...
	fi

such a change would break it, though.  But the script should have been
doing:

	LF='
	'
	if list=$(git config --get-regexp '$pattern')
        then
		IFS="$LF"
		for $list
                do
                	...
		done
	fi

anyway, so...
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux