[pacman-dev] [PATCH] makepkg: use type -p's return value for PATH checks

Allan McRae allan at archlinux.org
Wed May 26 21:24:35 EDT 2010


On 27/05/10 02:05, Andres P wrote:
> A new function, check_cmd, relies on type -p's return value instead of a
> string check.
>
> And gettext was previously being tested with type -t, which was
> inconsistent with the rest of the tests pertaining commands that aren't
> expected to be functions nor builtins.
>
> Signed-off-by: Andres P<aepd87 at gmail.com>
> ---
>
> i don't think the inline comments i added are necessary, since the
> function is pretty explicit
>
>   scripts/makepkg.sh.in |   39 ++++++++++++++++++++++++++-------------
>   1 files changed, 26 insertions(+), 13 deletions(-)
>
> diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
> index 8c0da8b..650358b 100644
> --- a/scripts/makepkg.sh.in
> +++ b/scripts/makepkg.sh.in
> @@ -193,6 +193,19 @@ get_url() {
>   	echo "${1#*::}"
>   }
>
> +
> +##
> +# Checks to see if command is present in PATH
> +#
> +#  usage : check_cmd( $command )
> +# return : 0 - found
> +#          1 - not found
> +##
> +check_cmd() {
> +	type -p -- "$1">/dev/null
> +}
> +

I do not see the need to split this out into a function.  It is a single 
line that is not particularly complex and that is very unlikely to ever 
change.  I'd much prefer this inline.

Allan


More information about the pacman-dev mailing list