[prev in list] [next in list] [prev in thread] [next in thread]
List: git
Subject: Re: [PATCH] test-lib: use subshell instead of cd $new && .. && cd $old
From: Ævar Arnfjörð Bjarmason <avarab () gmail ! com>
Date: 2010-08-31 18:11:30
Message-ID: AANLkTim7KWTR0FhnucZ7ROujZ-c7=y80Wz7UnR=+hsgZ () mail ! gmail ! com
[Download RAW message or body]
On Tue, Aug 31, 2010 at 17:58, Junio C Hamano <gitster@pobox.com> wrote:
> Jonathan Nieder <jrnieder@gmail.com> writes:
>
>> Ævar Arnfjörð Bjarmason wrote:
>>
>>> +++ b/t/test-lib.sh
>>> @@ -687,14 +687,12 @@ test_when_finished () {
>>> test_create_repo () {
>>> test "$#" = 1 ||
>>> error "bug in the test script: not 1 parameter to test-create-repo"
>>> - owd=`pwd`
>>> repo="$1"
>>> mkdir -p "$repo"
>>> - cd "$repo" || error "Cannot setup test environment"
>>> + (cd "$repo" || error "Cannot setup test environment"
>>> "$GIT_EXEC_PATH/git-init" "--template=$GIT_BUILD_DIR/templates/blt/" >&3 2>&4 ||
>>> error "cannot run git init -- have you built things yet?"
>>> - mv .git/hooks .git/hooks-disabled
>>> - cd "$owd"
>>> + mv .git/hooks .git/hooks-disabled)
>>
>> Style: why not use
>>
>> (
>> cd "$repo" ...
>> ... .git/hooks-disabled
>> )
>
> That is a sensible suggestion, but what does "error" do?
>
> I think you would need || exit at the end, i.e.
>
> (
> ... || error "..."
> ) || exit
>
> or something.
Good catch, yes. error() calls exit so this patch as-is introduces a
logic error.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic