git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] "test" in Solaris' /bin/sh does not support -e

From
Junio C Hamano <junkio@cox.net>
Date
Jun 26, 2006, 09:19 UTC
Message-ID
<7vwtb4i89d.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20060626082754.G6ec0a61e@leonov.stosberg.net>
Dennis Stosberg <dennis@stosberg.net> writes:
> Running "make clean" currently fails:
>   [ ! -e perl/Makefile ] || make -C perl/ clean
>   /bin/sh: test: argument expected
>   make: *** [clean] Error 1

Ah, _BAD_. We seem to have the same in git-branch, git-checkout, git-clone and git-tag. You would probably need this on top of "master".

-- >8 -- shell scripts: Avoid non-portable "test -e" where possible.

---
diff --git a/git-branch.sh b/git-branch.sh
index e0501ec..76971be 100755
--- a/git-branch.sh
+++ b/git-branch.sh
@@ -112,7 +112,7 @@ rev=$(git-rev-parse --verify "$head") ||
 git-check-ref-format "heads/$branchname" ||
 	die "we do not like '$branchname' as a branch name."
 
-if [ -e "$GIT_DIR/refs/heads/$branchname" ]
+if test -f "$GIT_DIR/refs/heads/$branchname"
 then
 	if test '' = "$force"
 	then
@@ -124,7 +124,7 @@ then
 fi
 if test "$create_log" = 'yes'
 then
-	mkdir -p $(dirname "$GIT_DIR/logs/refs/heads/$branchname")
+	mkdir -p "$(dirname "$GIT_DIR/logs/refs/heads/$branchname")"
 	touch "$GIT_DIR/logs/refs/heads/$branchname"
 fi
 git update-ref -m "branch: Created from $head" "refs/heads/$branchname" $rev
diff --git a/git-checkout.sh b/git-checkout.sh
index 77c2593..bfc2640 100755
--- a/git-checkout.sh
+++ b/git-checkout.sh
@@ -22,7 +22,7 @@ while [ "$#" != "0" ]; do
 		shift
 		[ -z "$newbranch" ] &&
 			die "git checkout: -b needs a branch name"
-		[ -e "$GIT_DIR/refs/heads/$newbranch" ] &&
+		[ -f "$GIT_DIR/refs/heads/$newbranch" ] &&
 			die "git checkout: branch $newbranch already exists"
 		git-check-ref-format "heads/$newbranch" ||
 			die "git checkout: we do not like '$newbranch' as a branch name."
diff --git a/git-clone.sh b/git-clone.sh
index 6fa0daa..b355441 100755
--- a/git-clone.sh
+++ b/git-clone.sh
@@ -202,7 +202,7 @@ fi
 dir="$2"
 # Try using "humanish" part of source repo if user didn't specify one
 [ -z "$dir" ] && dir=$(echo "$repo" | sed -e 's|/$||' -e 's|:*/*\.git$||' -e 's|.*[/:]||g')
-[ -e "$dir" ] && echo "$dir already exists." && usage
+[ -d "$dir" ] && echo "$dir already exists." && usage
 mkdir -p "$dir" &&
 D=$(cd "$dir" && pwd) &&
 trap 'err=$?; cd ..; rm -r "$D"; exit $err' 0
diff --git a/git-tag.sh b/git-tag.sh
index a0afa25..6118b00 100755
--- a/git-tag.sh
+++ b/git-tag.sh
@@ -63,7 +63,7 @@ done
 
 name="$1"
 [ "$name" ] || usage
-if [ -e "$GIT_DIR/refs/tags/$name" -a -z "$force" ]; then
+if [ -f "$GIT_DIR/refs/tags/$name" -a -z "$force" ]; then
     die "tag '$name' already exists"
 fi
 shift
Previous: Dennis StosbergNext: Dennis Stosberg
Message 8 of 19 in “Git.pm: Support for perl/ being built by a different compiler”
  1. Git.pm: Support for perl/ being built by a different compilerPetr Baudis, Jun 25, 2006
  2. Junio C HamanoJun 25, 2006
  3. Petr BaudisJun 25, 2006
  4. Dennis StosbergJun 26, 2006
  5. Solaris needs inclusion of signal.h for signal()Dennis Stosberg, Jun 26, 2006
  6. Fix pkt-line.h to compile with a non-GCC compilerDennis Stosberg, Jun 26, 2006
  7. "test" in Solaris' /bin/sh does not support -eDennis Stosberg, Jun 26, 2006
  8. Junio C HamanoJun 26, 2006
  9. Dennis StosbergJun 26, 2006
  10. Dennis StosbergJun 26, 2006
  11. Junio C HamanoJun 26, 2006
  12. Makefile fix for SolarisDennis Stosberg, Jun 26, 2006
  13. Add possibility to pass CFLAGS and LDFLAGS specific to the perl subdirDennis Stosberg, Jun 26, 2006
  14. Petr BaudisJul 1, 2006
  15. Dennis StosbergJun 26, 2006
  16. Dennis StosbergJun 26, 2006
  17. Thomas GlanzmannJun 26, 2006
  18. Junio C HamanoJun 26, 2006
  19. Dennis StosbergJun 26, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.