git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Arjen Laarhoven <arjen@yaph.org>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH] t1301-shared-repo.sh: fix 'stat' portability issue
Date: Thu, 16 Aug 2007 12:09:16 -0700	[thread overview]
Message-ID: <7v3ayjjnz7.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <1187277663740-git-send-email-arjen@yaph.org> (Arjen Laarhoven's message of "Thu, 16 Aug 2007 17:21:03 +0200")

Arjen Laarhoven <arjen@yaph.org> 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@yaph.org>
> ---
>  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

  reply	other threads:[~2007-08-16 19:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-16 15:21 [PATCH] t1301-shared-repo.sh: fix 'stat' portability issue Arjen Laarhoven
2007-08-16 19:09 ` Junio C Hamano [this message]
2007-08-16 22:02   ` Arjen Laarhoven
2007-08-17 12:48     ` Uwe Kleine-König
2007-08-17 23:37       ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7v3ayjjnz7.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=arjen@yaph.org \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).