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

[PATCH] test: switch to POSIX compliance symlink check

From
Doan Tran Cong Danh <congdanhqx@gmail.com>
Date
Dec 21, 2019, 16:40 UTC
Message-ID
<20191221164057.24616-1-congdanhqx@gmail.com>

POSIX doesn't specify `-L' flag for test(1), POSIX specify `-h' for checking symlink instead.

While most shells and test(1) implementation provides both `-L' and `-h' for checking symlink, OpenBSD and NetBSD says we shouldn't rely on its existence. [1]

Replace all usages of `test -L' with `test -h'.
[1]: https://man.openbsd.org/test.1
Signed-off-by: Doan Tran Cong Danh <congdanhqx@gmail.com>
---
 t/t9131-git-svn-empty-symlink.sh  | 4 ++--
 t/t9132-git-svn-broken-symlink.sh | 4 ++--
 t/t9802-git-p4-filetype.sh        | 2 +-
 t/t9830-git-p4-symlink-dir.sh     | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/t/t9131-git-svn-empty-symlink.sh b/t/t9131-git-svn-empty-symlink.sh
index 3bf4255aa3..6812028258 100755
--- a/t/t9131-git-svn-empty-symlink.sh
+++ b/t/t9131-git-svn-empty-symlink.sh
@@ -97,14 +97,14 @@ test_expect_success 'disable broken symlink workaround' \
 test_expect_success '"bar" is an empty file' 'test_must_be_empty y/bar'
 test_expect_success 'get "bar" => symlink fix from svn' \
 		'(cd y && git svn rebase)'
-test_expect_success '"bar" does not become a symlink' '! test -L y/bar'
+test_expect_success '"bar" does not become a symlink' '! test -h y/bar'
 
 # svn.brokenSymlinkWorkaround is unset
 test_expect_success 'clone using git svn' 'git svn clone -r1 "$svnrepo" z'
 test_expect_success '"bar" is an empty file' 'test_must_be_empty z/bar'
 test_expect_success 'get "bar" => symlink fix from svn' \
 		'(cd z && git svn rebase)'
-test_expect_success '"bar" does not become a symlink' '! test -L z/bar'
+test_expect_success '"bar" does not become a symlink' '! test -h z/bar'
 
 
 test_done
diff --git a/t/t9132-git-svn-broken-symlink.sh b/t/t9132-git-svn-broken-symlink.sh
index aeceffaf7b..2b15b97cdf 100755
--- a/t/t9132-git-svn-broken-symlink.sh
+++ b/t/t9132-git-svn-broken-symlink.sh
@@ -86,7 +86,7 @@ EOF
 test_expect_success 'clone using git svn' 'git svn clone -r1 "$svnrepo" x'
 
 test_expect_success SYMLINKS '"bar" is a symlink that points to "asdf"' '
-	test -L x/bar &&
+	test -h x/bar &&
 	(cd x && test xasdf = x"$(git cat-file blob HEAD:bar)")
 '
 
@@ -95,7 +95,7 @@ test_expect_success 'get "bar" => symlink fix from svn' '
 '
 
 test_expect_success SYMLINKS '"bar" remains a proper symlink' '
-	test -L x/bar &&
+	test -h x/bar &&
 	(cd x && test xdoink = x"$(git cat-file blob HEAD:bar)")
 '
 
diff --git a/t/t9802-git-p4-filetype.sh b/t/t9802-git-p4-filetype.sh
index 94edebe272..197752b45a 100755
--- a/t/t9802-git-p4-filetype.sh
+++ b/t/t9802-git-p4-filetype.sh
@@ -262,7 +262,7 @@ test_expect_success SYMLINKS 'ensure p4 symlink parsed correctly' '
 	git p4 clone --dest="$git" //depot@all &&
 	(
 		cd "$git" &&
-		test -L symlink &&
+		test -h symlink &&
 		test $(readlink symlink) = symlink-target
 	)
 '
diff --git a/t/t9830-git-p4-symlink-dir.sh b/t/t9830-git-p4-symlink-dir.sh
index 3fb6960c18..4b4cc015fc 100755
--- a/t/t9830-git-p4-symlink-dir.sh
+++ b/t/t9830-git-p4-symlink-dir.sh
@@ -30,7 +30,7 @@ test_expect_success 'symlinked directory' '
 	(
 		cd "$cli" &&
 		p4 sync &&
-		test -L some/sub/directory/subdir2 &&
+		test -h some/sub/directory/subdir2 &&
 		test_path_is_file some/sub/directory/subdir2/file.t
 	)
 
-- 
2.24.1.485.gad05a3d8e5
Next: Carlo Arenas
Message 1 of 3 in “test: switch to POSIX compliance symlink check”
  1. test: switch to POSIX compliance symlink checkDoan Tran Cong Danh, Dec 21, 2019
  2. Carlo ArenasDec 21, 2019
  3. Danh DoanDec 22, 2019

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.