git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] t/t5560: use `X=Y && export X' not `export X=Y'
@ 2010-10-07  7:47 Ævar Arnfjörð Bjarmason
  2010-10-07  7:55 ` Matthieu Moy
  2010-10-13 18:36 ` Junio C Hamano
  0 siblings, 2 replies; 5+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2010-10-07  7:47 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Pat Thoyts, Tarmigan Casebolt,
	Ævar Arnfjörð Bjarmason

Change t/t5560-http-backend-noserver.sh to use the `X=Y && export X'
style instead of `export X=Y'. The latter doesn't work on all POSIX
shells.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 t/t5560-http-backend-noserver.sh |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/t/t5560-http-backend-noserver.sh b/t/t5560-http-backend-noserver.sh
index 406432e..effe797 100755
--- a/t/t5560-http-backend-noserver.sh
+++ b/t/t5560-http-backend-noserver.sh
@@ -5,7 +5,11 @@ test_description='test git-http-backend-noserver'
 
 HTTPD_DOCUMENT_ROOT_PATH="$TRASH_DIRECTORY"
 
-test_have_prereq MINGW && export GREP_OPTIONS=-U
+if test_have_prereq MINGW
+then
+	GREP_OPTIONS=-U
+	export GREP_OPTIONS
+fi
 
 run_backend() {
 	echo "$2" |
@@ -15,7 +19,8 @@ run_backend() {
 }
 
 GET() {
-	export REQUEST_METHOD="GET" &&
+	REQUEST_METHOD="GET" &&
+	export REQUEST_METHOD &&
 	run_backend "/repo.git/$1" &&
 	unset REQUEST_METHOD &&
 	if ! grep "Status" act.out >act
@@ -27,8 +32,9 @@ GET() {
 }
 
 POST() {
-	export REQUEST_METHOD="POST" &&
-	export CONTENT_TYPE="application/x-$1-request" &&
+	REQUEST_METHOD="POST" &&
+	CONTENT_TYPE="application/x-$1-request" &&
+	export REQUEST_METHOD CONTENT_TYPE &&
 	run_backend "/repo.git/$1" "$2" &&
 	unset REQUEST_METHOD &&
 	unset CONTENT_TYPE &&
@@ -47,7 +53,8 @@ log_div() {
 . "$TEST_DIRECTORY"/t556x_common
 
 expect_aliased() {
-	export REQUEST_METHOD="GET" &&
+	REQUEST_METHOD="GET" &&
+	export REQUEST_METHOD &&
 	if test $1 = 0; then
 		run_backend "$2"
 	else
-- 
1.7.3.1.50.g1e633

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] t/t5560: use `X=Y && export X' not `export X=Y'
  2010-10-07  7:47 [PATCH] t/t5560: use `X=Y && export X' not `export X=Y' Ævar Arnfjörð Bjarmason
@ 2010-10-07  7:55 ` Matthieu Moy
  2010-10-07  8:09   ` Ævar Arnfjörð Bjarmason
  2010-10-13 18:36 ` Junio C Hamano
  1 sibling, 1 reply; 5+ messages in thread
From: Matthieu Moy @ 2010-10-07  7:55 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: git, Junio C Hamano, Pat Thoyts, Tarmigan Casebolt

Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:

> Change t/t5560-http-backend-noserver.sh to use the `X=Y && export X'
> style instead of `export X=Y'. The latter doesn't work on all POSIX
> shells.

According to

git grep '\<export [A-Za-z_]*='

there seem to be a couple of other instances of this.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] t/t5560: use `X=Y && export X' not `export X=Y'
  2010-10-07  7:55 ` Matthieu Moy
@ 2010-10-07  8:09   ` Ævar Arnfjörð Bjarmason
  2010-10-10 17:20     ` Clemens Buchacher
  0 siblings, 1 reply; 5+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2010-10-07  8:09 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: git, Junio C Hamano, Pat Thoyts, Tarmigan Casebolt

On Thu, Oct 7, 2010 at 07:55, Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> wrote:
> Ęvar Arnfjörš Bjarmason <avarab@gmail.com> writes:
>
>> Change t/t5560-http-backend-noserver.sh to use the `X=Y && export X'
>> style instead of `export X=Y'. The latter doesn't work on all POSIX
>> shells.
>
> According to
>
> git grep '\<export [A-Za-z_]*='
>
> there seem to be a couple of other instances of this.

Yeah, the ones in Documentation/*.txt are OK IMO. The users reading
the docs probably don't have a shell old enough to complain about
this.

Likewise for contrib/hg-to-git/hg-to-git.py and gitweb/INSTALL.

These we probably want to fix:

    git-am.sh:          export GIT_MERGE_VERBOSITY=0
    git-rebase.sh:          export GIT_MERGE_VERBOSITY=1
    git-stash.sh:           export GIT_MERGE_VERBOSITY=0

and maybe this:

    git-gui/lib/shortcut.tcl:                               puts $fd
"export PATH=[sq [file dirname $::_git]]:\$PATH &&"

This is the only other thing in the test suite:

    t/t1509-root-worktree.sh:export GIT_DIR="$TRASH_DIRECTORY/.git"
    t/t1509-root-worktree.sh:export GIT_WORK_TREE=/
    t/t1509-root-worktree.sh:export GIT_DIR="$(echo
$TRASH_DIRECTORY|sed 's,^/,,')/.git"

But I didn't touch that since nobody runs that test anyway, and if
they do having a strict POSIX shell is the least of their problems.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] t/t5560: use `X=Y && export X' not `export X=Y'
  2010-10-07  8:09   ` Ævar Arnfjörð Bjarmason
@ 2010-10-10 17:20     ` Clemens Buchacher
  0 siblings, 0 replies; 5+ messages in thread
From: Clemens Buchacher @ 2010-10-10 17:20 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: Matthieu Moy, git, Junio C Hamano, Pat Thoyts, Tarmigan Casebolt

[-- Attachment #1: Type: text/plain, Size: 275 bytes --]

On Thu, Oct 07, 2010 at 08:09:34AM +0000, Ævar Arnfjörð Bjarmason wrote:
> >
> > According to
> >
> > git grep '\<export [A-Za-z_]*='
> >
> > there seem to be a couple of other instances of this.

What about t556x_common?

 export GIT_HTTP_EXPORT_ALL=1

Clemens

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] t/t5560: use `X=Y && export X' not `export X=Y'
  2010-10-07  7:47 [PATCH] t/t5560: use `X=Y && export X' not `export X=Y' Ævar Arnfjörð Bjarmason
  2010-10-07  7:55 ` Matthieu Moy
@ 2010-10-13 18:36 ` Junio C Hamano
  1 sibling, 0 replies; 5+ messages in thread
From: Junio C Hamano @ 2010-10-13 18:36 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason; +Cc: git, Pat Thoyts, Tarmigan Casebolt

Let's do this instead.

 * One patch to clean things up in all of 'maint';
 * Another to clean the remainder that are in 'master'.

Here is the one for 'maint' to make the output from

    $ git grep '^[ 	]*export .*=' -- '*.sh'

empty.

-- >8 --
Subject: shell portability: no "export VAR=VAL"

It is more portable to say "VAR=VAL && export VAR" instead.

Noticed by Ævar.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 git-am.sh                        |    2 +-
 git-rebase.sh                    |    2 +-
 git-stash.sh                     |    2 +-
 t/t1509-root-worktree.sh         |   28 ++++++++++++++--------------
 t/t5560-http-backend-noserver.sh |    8 ++++----
 t/t556x_common                   |    4 ++--
 6 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/git-am.sh b/git-am.sh
index e7f008c..5f24948 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -137,7 +137,7 @@ It does not apply to blobs recorded in its index."
     export GITHEAD_$his_tree
     if test -n "$GIT_QUIET"
     then
-	    export GIT_MERGE_VERBOSITY=0
+	    GIT_MERGE_VERBOSITY=0 && export GIT_MERGE_VERBOSITY
     fi
     git-merge-recursive $orig_tree -- HEAD $his_tree || {
 	    git rerere $allow_rerere_autoupdate
diff --git a/git-rebase.sh b/git-rebase.sh
index 3335cee..e5df23b 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -111,7 +111,7 @@ call_merge () {
 	export GITHEAD_$cmt GITHEAD_$hd
 	if test -n "$GIT_QUIET"
 	then
-		export GIT_MERGE_VERBOSITY=1
+		GIT_MERGE_VERBOSITY=1 && export GIT_MERGE_VERBOSITY
 	fi
 	eval 'git-merge-$strategy' $strategy_opts '"$cmt^" -- "$hd" "$cmt"'
 	rv=$?
diff --git a/git-stash.sh b/git-stash.sh
index 5fb1245..7561b37 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -373,7 +373,7 @@ apply_stash () {
 
 	if test -n "$GIT_QUIET"
 	then
-		export GIT_MERGE_VERBOSITY=0
+		GIT_MERGE_VERBOSITY=0 && export GIT_MERGE_VERBOSITY
 	fi
 	if git merge-recursive $b_tree -- $c_tree $w_tree
 	then
diff --git a/t/t1509-root-worktree.sh b/t/t1509-root-worktree.sh
index 7f60fd0..335420f 100755
--- a/t/t1509-root-worktree.sh
+++ b/t/t1509-root-worktree.sh
@@ -134,8 +134,8 @@ cat >ls.expected <<EOF
 100644 $ONE_SHA1 0	me
 EOF
 
-export GIT_DIR="$TRASH_DIRECTORY/.git"
-export GIT_WORK_TREE=/
+GIT_DIR="$TRASH_DIRECTORY/.git" && export GIT_DIR
+GIT_WORK_TREE=/ && export GIT_WORK_TREE
 
 test_vars 'abs gitdir, root' "$GIT_DIR" "/" ""
 test_foobar_root
@@ -154,24 +154,24 @@ say "GIT_DIR relative, GIT_WORK_TREE set"
 
 test_expect_success 'go to /' 'cd /'
 
-export GIT_DIR="$(echo $TRASH_DIRECTORY|sed 's,^/,,')/.git"
-export GIT_WORK_TREE=/
+GIT_DIR="$(echo $TRASH_DIRECTORY|sed 's,^/,,')/.git" && export GIT_DIR
+GIT_WORK_TREE=/ && export GIT_WORK_TREE
 
 test_vars 'rel gitdir, root' "$GIT_DIR" "/" ""
 test_foobar_root
 
 test_expect_success 'go to /foo' 'cd /foo'
 
-export GIT_DIR="../$TRASH_DIRECTORY/.git"
-export GIT_WORK_TREE=/
+GIT_DIR="../$TRASH_DIRECTORY/.git" && export GIT_DIR
+GIT_WORK_TREE=/ && export GIT_WORK_TREE
 
 test_vars 'rel gitdir, foo' "$TRASH_DIRECTORY/.git" "/" "foo/"
 test_foobar_foo
 
 test_expect_success 'go to /foo/bar' 'cd /foo/bar'
 
-export GIT_DIR="../../$TRASH_DIRECTORY/.git"
-export GIT_WORK_TREE=/
+GIT_DIR="../../$TRASH_DIRECTORY/.git" && export GIT_DIR
+GIT_WORK_TREE=/ && export GIT_WORK_TREE
 
 test_vars 'rel gitdir, foo/bar' "$TRASH_DIRECTORY/.git" "/" "foo/bar/"
 test_foobar_foobar
@@ -180,24 +180,24 @@ say "GIT_DIR relative, GIT_WORK_TREE relative"
 
 test_expect_success 'go to /' 'cd /'
 
-export GIT_DIR="$(echo $TRASH_DIRECTORY|sed 's,^/,,')/.git"
-export GIT_WORK_TREE=.
+GIT_DIR="$(echo $TRASH_DIRECTORY|sed 's,^/,,')/.git" && export GIT_DIR
+GIT_WORK_TREE=. && export GIT_WORK_TREE
 
 test_vars 'rel gitdir, root' "$GIT_DIR" "/" ""
 test_foobar_root
 
 test_expect_success 'go to /' 'cd /foo'
 
-export GIT_DIR="../$TRASH_DIRECTORY/.git"
-export GIT_WORK_TREE=..
+GIT_DIR="../$TRASH_DIRECTORY/.git" && export GIT_DIR
+GIT_WORK_TREE=.. && export GIT_WORK_TREE
 
 test_vars 'rel gitdir, foo' "$TRASH_DIRECTORY/.git" "/" "foo/"
 test_foobar_foo
 
 test_expect_success 'go to /foo/bar' 'cd /foo/bar'
 
-export GIT_DIR="../../$TRASH_DIRECTORY/.git"
-export GIT_WORK_TREE=../..
+GIT_DIR="../../$TRASH_DIRECTORY/.git" && export GIT_DIR
+GIT_WORK_TREE=../.. && export GIT_WORK_TREE
 
 test_vars 'rel gitdir, foo/bar' "$TRASH_DIRECTORY/.git" "/" "foo/bar/"
 test_foobar_foobar
diff --git a/t/t5560-http-backend-noserver.sh b/t/t5560-http-backend-noserver.sh
index 44885b8..94f9d2e 100755
--- a/t/t5560-http-backend-noserver.sh
+++ b/t/t5560-http-backend-noserver.sh
@@ -14,7 +14,7 @@ run_backend() {
 }
 
 GET() {
-	export REQUEST_METHOD="GET" &&
+	REQUEST_METHOD="GET" && export REQUEST_METHOD &&
 	run_backend "/repo.git/$1" &&
 	unset REQUEST_METHOD &&
 	if ! grep "Status" act.out >act
@@ -26,8 +26,8 @@ GET() {
 }
 
 POST() {
-	export REQUEST_METHOD="POST" &&
-	export CONTENT_TYPE="application/x-$1-request" &&
+	REQUEST_METHOD="POST" && export REQUEST_METHOD &&
+	CONTENT_TYPE="application/x-$1-request" && export CONTENT_TYPE &&
 	run_backend "/repo.git/$1" "$2" &&
 	unset REQUEST_METHOD &&
 	unset CONTENT_TYPE &&
@@ -46,7 +46,7 @@ log_div() {
 . "$TEST_DIRECTORY"/t556x_common
 
 expect_aliased() {
-	export REQUEST_METHOD="GET" &&
+	REQUEST_METHOD="GET" && export REQUEST_METHOD &&
 	if test $1 = 0; then
 		run_backend "$2"
 	else
diff --git a/t/t556x_common b/t/t556x_common
index be024e5..51287d8 100755
--- a/t/t556x_common
+++ b/t/t556x_common
@@ -50,7 +50,7 @@ get_static_files() {
 }
 
 SMART=smart
-export GIT_HTTP_EXPORT_ALL=1
+GIT_HTTP_EXPORT_ALL=1 && export GIT_HTTP_EXPORT_ALL
 test_expect_success 'direct refs/heads/master not found' '
 	log_div "refs/heads/master"
 	GET refs/heads/master "404 Not Found"
@@ -73,7 +73,7 @@ test_expect_success 'export if git-daemon-export-ok' '
         get_static_files "200 OK"
 '
 SMART=smart
-export GIT_HTTP_EXPORT_ALL=1
+GIT_HTTP_EXPORT_ALL=1 && export GIT_HTTP_EXPORT_ALL
 test_expect_success 'static file if http.getanyfile true is ok' '
 	log_div "getanyfile true"
 	config http.getanyfile true &&

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-10-13 18:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-07  7:47 [PATCH] t/t5560: use `X=Y && export X' not `export X=Y' Ævar Arnfjörð Bjarmason
2010-10-07  7:55 ` Matthieu Moy
2010-10-07  8:09   ` Ævar Arnfjörð Bjarmason
2010-10-10 17:20     ` Clemens Buchacher
2010-10-13 18:36 ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).