{"thread":{"id":"52502","subject":"[PATCH] test: switch to POSIX compliance symlink check","startedAt":"2019-12-21T16:41:07Z","lastAt":"2019-12-22T02:07:59Z","messageCount":3,"participants":["Doan Tran Cong Danh","Carlo Arenas","Danh Doan"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"388710","messageId":"20191221164057.24616-1-congdanhqx@gmail.com","threadId":"52502","inReplyTo":null,"subject":"[PATCH] test: switch to POSIX compliance symlink check","fromName":"Doan Tran Cong Danh","fromEmail":"congdanhqx@gmail.com","sentAt":"2019-12-21T16:40:57Z","receivedAt":"2019-12-21T16:41:07Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"POSIX doesn't specify `-L' flag for test(1), POSIX specify `-h' for\nchecking symlink instead.\n\nWhile most shells and test(1) implementation provides both `-L' and\n`-h' for checking symlink,\nOpenBSD and NetBSD says we shouldn't rely on its existence. [1]\n\nReplace all usages of `test -L' with `test -h'.\n\n[1]: https://man.openbsd.org/test.1\n\nSigned-off-by: Doan Tran Cong Danh <congdanhqx@gmail.com>\n---\n t/t9131-git-svn-empty-symlink.sh  | 4 ++--\n t/t9132-git-svn-broken-symlink.sh | 4 ++--\n t/t9802-git-p4-filetype.sh        | 2 +-\n t/t9830-git-p4-symlink-dir.sh     | 2 +-\n 4 files changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/t/t9131-git-svn-empty-symlink.sh b/t/t9131-git-svn-empty-symlink.sh\nindex 3bf4255aa3..6812028258 100755\n--- a/t/t9131-git-svn-empty-symlink.sh\n+++ b/t/t9131-git-svn-empty-symlink.sh\n@@ -97,14 +97,14 @@ test_expect_success 'disable broken symlink workaround' \\\n test_expect_success '\"bar\" is an empty file' 'test_must_be_empty y/bar'\n test_expect_success 'get \"bar\" => symlink fix from svn' \\\n \t\t'(cd y && git svn rebase)'\n-test_expect_success '\"bar\" does not become a symlink' '! test -L y/bar'\n+test_expect_success '\"bar\" does not become a symlink' '! test -h y/bar'\n \n # svn.brokenSymlinkWorkaround is unset\n test_expect_success 'clone using git svn' 'git svn clone -r1 \"$svnrepo\" z'\n test_expect_success '\"bar\" is an empty file' 'test_must_be_empty z/bar'\n test_expect_success 'get \"bar\" => symlink fix from svn' \\\n \t\t'(cd z && git svn rebase)'\n-test_expect_success '\"bar\" does not become a symlink' '! test -L z/bar'\n+test_expect_success '\"bar\" does not become a symlink' '! test -h z/bar'\n \n \n test_done\ndiff --git a/t/t9132-git-svn-broken-symlink.sh b/t/t9132-git-svn-broken-symlink.sh\nindex aeceffaf7b..2b15b97cdf 100755\n--- a/t/t9132-git-svn-broken-symlink.sh\n+++ b/t/t9132-git-svn-broken-symlink.sh\n@@ -86,7 +86,7 @@ EOF\n test_expect_success 'clone using git svn' 'git svn clone -r1 \"$svnrepo\" x'\n \n test_expect_success SYMLINKS '\"bar\" is a symlink that points to \"asdf\"' '\n-\ttest -L x/bar &&\n+\ttest -h x/bar &&\n \t(cd x && test xasdf = x\"$(git cat-file blob HEAD:bar)\")\n '\n \n@@ -95,7 +95,7 @@ test_expect_success 'get \"bar\" => symlink fix from svn' '\n '\n \n test_expect_success SYMLINKS '\"bar\" remains a proper symlink' '\n-\ttest -L x/bar &&\n+\ttest -h x/bar &&\n \t(cd x && test xdoink = x\"$(git cat-file blob HEAD:bar)\")\n '\n \ndiff --git a/t/t9802-git-p4-filetype.sh b/t/t9802-git-p4-filetype.sh\nindex 94edebe272..197752b45a 100755\n--- a/t/t9802-git-p4-filetype.sh\n+++ b/t/t9802-git-p4-filetype.sh\n@@ -262,7 +262,7 @@ test_expect_success SYMLINKS 'ensure p4 symlink parsed correctly' '\n \tgit p4 clone --dest=\"$git\" //depot@all &&\n \t(\n \t\tcd \"$git\" &&\n-\t\ttest -L symlink &&\n+\t\ttest -h symlink &&\n \t\ttest $(readlink symlink) = symlink-target\n \t)\n '\ndiff --git a/t/t9830-git-p4-symlink-dir.sh b/t/t9830-git-p4-symlink-dir.sh\nindex 3fb6960c18..4b4cc015fc 100755\n--- a/t/t9830-git-p4-symlink-dir.sh\n+++ b/t/t9830-git-p4-symlink-dir.sh\n@@ -30,7 +30,7 @@ test_expect_success 'symlinked directory' '\n \t(\n \t\tcd \"$cli\" &&\n \t\tp4 sync &&\n-\t\ttest -L some/sub/directory/subdir2 &&\n+\t\ttest -h some/sub/directory/subdir2 &&\n \t\ttest_path_is_file some/sub/directory/subdir2/file.t\n \t)\n \n-- \n2.24.1.485.gad05a3d8e5\n\n"},{"id":"388739","messageId":"CAPUEsphavRpYeJGLY73rzy18VFvTUfhsb=y6pC53e8b9aEbfRw@mail.gmail.com","threadId":"52502","inReplyTo":"20191221164057.24616-1-congdanhqx@gmail.com","subject":"Re: [PATCH] test: switch to POSIX compliance symlink check","fromName":"Carlo Arenas","fromEmail":"carenas@gmail.com","sentAt":"2019-12-21T20:45:43Z","receivedAt":"2019-12-21T20:45:58Z","isPatch":true,"sender":{"key":"carenas@gmail.com","avatar":"https://avatars.githubusercontent.com/u/76036?v=4"},"body":"On Sat, Dec 21, 2019 at 8:50 AM Doan Tran Cong Danh\n<congdanhqx@gmail.com> wrote:\n>\n> POSIX doesn't specify `-L' flag for test(1), POSIX specify `-h' for\n> checking symlink instead.\n\nhttps://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html\n\nseems to indicate both are valid and equivalent\n\n> While most shells and test(1) implementation provides both `-L' and\n> `-h' for checking symlink,\n> OpenBSD and NetBSD says we shouldn't rely on its existence. [1]\n\nand macOS (from FreeBSD[1]) says the exact opposite :\n\n     -h file     True if file exists and is a symbolic link.  This operator\n                   is retained for compatibility with previous versions of\n                   this program.  Do not rely on its existence; use -L\n                   instead.\n\nagree it would be a good idea to use only one for consistency though,\nbut it might be in that case a good idea to add it as a\n\"recommendation\" by adding this rule in t/check-non-portable-shell.pl\nor something like that IMHO\n\nCarlo\n\n[1] https://www.freebsd.org/cgi/man.cgi?test\n"},{"id":"388776","messageId":"20191222020753.GA14802@danh.dev","threadId":"52502","inReplyTo":"CAPUEsphavRpYeJGLY73rzy18VFvTUfhsb=y6pC53e8b9aEbfRw@mail.gmail.com","subject":"Re: [PATCH] test: switch to POSIX compliance symlink check","fromName":"Danh Doan","fromEmail":"congdanhqx@gmail.com","sentAt":"2019-12-22T02:07:53Z","receivedAt":"2019-12-22T02:07:59Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"On 2019-12-21 12:45:43-0800, Carlo Arenas <carenas@gmail.com> wrote:\n> On Sat, Dec 21, 2019 at 8:50 AM Doan Tran Cong Danh\n> <congdanhqx@gmail.com> wrote:\n> >\n> > POSIX doesn't specify `-L' flag for test(1), POSIX specify `-h' for\n> > checking symlink instead.\n> \n> https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html\n> \n> seems to indicate both are valid and equivalent\n\nIt's seems like I've misread my manpages.\nSomehow, I couldn't find the mention of `-L' when I tried it last\ntime.\nPlease ignore this patch.\n\n> \n> > While most shells and test(1) implementation provides both `-L' and\n> > `-h' for checking symlink,\n> > OpenBSD and NetBSD says we shouldn't rely on its existence. [1]\n> \n> and macOS (from FreeBSD[1]) says the exact opposite :\n> \n>      -h file     True if file exists and is a symbolic link.  This operator\n>                    is retained for compatibility with previous versions of\n>                    this program.  Do not rely on its existence; use -L\n>                    instead.\n> \n> agree it would be a good idea to use only one for consistency though,\n> but it might be in that case a good idea to add it as a\n> \"recommendation\" by adding this rule in t/check-non-portable-shell.pl\n> or something like that IMHO\n> \n> Carlo\n> \n> [1] https://www.freebsd.org/cgi/man.cgi?test\n\n-- \nDanh\n"}]}