Re: [PATCH] t1301-shared-repo.sh: fix 'stat' portability issue

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

 



Arjen Laarhoven <arjen@xxxxxxxx> writes:

> The t1301-shared-repo.sh testscript uses /usr/bin/stat to get the file
> mode, which isn't portable.  There already is a dependency on Perl, so
> use a Perl one-liner to do the file mode test, but portable.
>
> Signed-off-by: Arjen Laarhoven <arjen@xxxxxxxx>
> ---
>  t/t1301-shared-repo.sh |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/t/t1301-shared-repo.sh b/t/t1301-shared-repo.sh
> index bb5f302..888c5fb 100755
> --- a/t/t1301-shared-repo.sh
> +++ b/t/t1301-shared-repo.sh
> @@ -21,7 +21,7 @@ test_expect_success 'update-server-info honors core.sharedRepository' '
>  	git commit -m a1 &&
>  	umask 0277 &&
>  	git update-server-info &&
> -	test 444 = $(stat -c %a .git/info/refs)
> +	$(perl -e '\''exit !(((stat ".git/info/refs")[2] & 0777) == 0444)'\'')
>  '

Why is this inside a $()?

I am just wondering if this is more portable and readable...

	... &&
	current="$(ls -l .git/info/refs)" &&
	case "$current" in
        -r--r--r--*)
        	: happy
                ;;
	*)
        	echo Oops, .git/info/refs is not 0444
                false
                ;;
	esac

-
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