{"thread":{"id":"39277","subject":"t0005-signals.sh fails with ksh","startedAt":"2015-05-08T20:15:14Z","lastAt":"2015-05-09T20:01:05Z","messageCount":11,"participants":["evgeny","Junio C Hamano","Jeff King","Andreas Schwab","brian m. carlson"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"260852","messageId":"31108626.20150508231514@gmail.com","threadId":"39277","inReplyTo":null,"subject":"t0005-signals.sh fails with ksh","fromName":"evgeny","fromEmail":"illumsoft.org@gmail.com","sentAt":"2015-05-08T20:15:14Z","receivedAt":"2015-05-08T20:15:14Z","isPatch":false,"sender":{"key":"illumsoft.org@gmail.com","avatar":null},"body":"Hi,\n\nTest t0005-signals.sh fails when I run 'make test' under ksh (on Solaris and on Linux)\n\n$ ksh t0005-signals.sh -v\nInitialized empty Git repository in /home/test/git/t/trash directory.t0005-signals/.git/\nexpecting success: \n        { test-sigchain >actual; ret=$?; } &&\n        case \"$ret\" in\n        143) true ;; # POSIX w/ SIGTERM=15\n        271) true ;; # ksh w/ SIGTERM=15\n          3) true ;; # Windows\n          *) false ;;\n        esac &&\n        test_cmp expect actual\n\nt0005-signals.sh[499]: eval: line 4: 23622: Terminated\nok 1 - sigchain works\n\nexpecting success: \n        # we use exec here to avoid any sub-shell interpretation\n        # of the exit code\n        git config alias.sigterm \"!exec test-sigchain\" &&\n        test_expect_code 143 git sigterm\n\nthree\ntwo\none\nerror: exec test-sigchain died of signal 15\nok 2 - signals are propagated using shell convention\n\nexpecting success: \n        test-genrandom foo 16384 >file &&\n        git add file\n\nok 3 - create blob\n\nexpecting success: \n        OUT=$( ((large_git; echo $? 1>&3) | :) 3>&1 ) &&\n        test \"$OUT\" -eq 141\n\nt0005-signals.sh[499]: eval: syntax error at line 4: `(' unmatched\nMemory fault\n\nI rather think there are two issues:\n1. two adjacent parentheses\n2. numeric constant (141) should be 269 for ksh, like there are two different \nconstants in the test 'test-sigchain' in this file (in t0005-signals.sh)\n\n'man ksh' reads:\n  (list)\n    Execute  list  in  a  separate environment.\n    Note, that if two adjacent open parentheses are needed for nesting,\n    a space must be inserted to avoid evaluation as an arithmetic command as\n    described above.\n\n\n-- \nBest regards,\n evgeny\n"},{"id":"260857","messageId":"xmqq1tiqkdue.fsf@gitster.dls.corp.google.com","threadId":"39277","inReplyTo":"31108626.20150508231514@gmail.com","subject":"Re: t0005-signals.sh fails with ksh","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-05-08T20:34:49Z","receivedAt":"2015-05-08T20:34:49Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"evgeny <illumsoft.org@gmail.com> writes:\n\n> expecting success: \n>         OUT=$( ((large_git; echo $? 1>&3) | :) 3>&1 ) &&\n>         test \"$OUT\" -eq 141\n>\n> t0005-signals.sh[499]: eval: syntax error at line 4: `(' unmatched\n> Memory fault\n\nDoes this work if you did\n\n\tOUT=$( ( (large_git ; echo $? 1>&3) | : ) 3>&2 ) &&\n\ninstead?\n\n> 'man ksh' reads:\n>   (list)\n>     Execute  list  in  a  separate environment.\n>     Note, that if two adjacent open parentheses are needed for nesting,\n>     a space must be inserted to avoid evaluation as an arithmetic command as\n>     described above.\n\nHmm, I cannot see \"as described above\" in your message, but isn't\nthat talking about a common mistake of turning cmd1 in this pipeline\n\n\tx=$(cmd1 | cmd2)\n\ninto a series of two commands, e.g. (cmd1a && cmd1b) and saying\n\n\tx=$((cmd1a && cmd1b) | cmd2)\n\nwhich does make \"$((\" interpreted as the beginning of arithmetic\nexpansion?\n\nAnd the \"OUT=$( ((large...\" construct seems to be written in order\nto avoid that exact issue (notice the SP after \"$(\").\n\nPuzzled....\n"},{"id":"260861","messageId":"20150508205548.GB13457@peff.net","threadId":"39277","inReplyTo":"xmqq1tiqkdue.fsf@gitster.dls.corp.google.com","subject":"Re: t0005-signals.sh fails with ksh","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2015-05-08T20:55:48Z","receivedAt":"2015-05-08T20:55:48Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, May 08, 2015 at 01:34:49PM -0700, Junio C Hamano wrote:\n\n> evgeny <illumsoft.org@gmail.com> writes:\n> \n> > expecting success: \n> >         OUT=$( ((large_git; echo $? 1>&3) | :) 3>&1 ) &&\n> >         test \"$OUT\" -eq 141\n> >\n> > t0005-signals.sh[499]: eval: syntax error at line 4: `(' unmatched\n> > Memory fault\n> \n> Does this work if you did\n> \n> \tOUT=$( ( (large_git ; echo $? 1>&3) | : ) 3>&2 ) &&\n> \n> instead?\n\nIt does for me. I've tested our suite with mksh before, and it passed\n(that's why the earlier check already covers ksh). But using the ksh I\nget from \"apt-get install ksh\" on Debian (ksh93, it looks like?) fails\nas described. The change above prevents the shell from crashing, and\nthen if we also massage the code, the test passes (i.e., the patch\nbelow).\n\nI'm on the fence, though, on declaring ksh93 to be unsupported. I don't\nknow how many other instances of this are in our test suite, and it's\none more maintenance headache to deal with. Are there really platforms\nwith no actual POSIX shell (on Solaris, for example, the xpg6 shell is a\nmuch better choice)?\n\n\ndiff --git a/t/t0005-signals.sh b/t/t0005-signals.sh\nindex e7f27eb..cbf778e 100755\n--- a/t/t0005-signals.sh\n+++ b/t/t0005-signals.sh\n@@ -9,14 +9,23 @@ two\n one\n EOF\n \n+# $1 - expected signal number\n+# $2 - actual exit code\n+check_signal_exit () {\n+\tif test \"$2\" = \"$(($1 + 128))\"; then\n+\t\treturn 0; # POSIX\n+\telif test \"$2\" = \"$(($1 + 256))\"; then\n+\t\treturn 0; # ksh\n+\telif test \"$2\" = 3; then\n+\t\treturn 0; # Windows\n+\tfi\n+\techo >&2 \"expected death by signal $1, got exit code $2\"\n+\treturn 1\n+}\n+\n test_expect_success 'sigchain works' '\n \t{ test-sigchain >actual; ret=$?; } &&\n-\tcase \"$ret\" in\n-\t143) true ;; # POSIX w/ SIGTERM=15\n-\t271) true ;; # ksh w/ SIGTERM=15\n-\t  3) true ;; # Windows\n-\t  *) false ;;\n-\tesac &&\n+\tcheck_signal_exit 15 $ret &&\n \ttest_cmp expect actual\n '\n \n@@ -40,13 +49,13 @@ test_expect_success 'create blob' '\n '\n \n test_expect_success !MINGW 'a constipated git dies with SIGPIPE' '\n-\tOUT=$( ((large_git; echo $? 1>&3) | :) 3>&1 ) &&\n-\ttest \"$OUT\" -eq 141\n+\tOUT=$( ( (large_git; echo $? 1>&3) | :) 3>&1 ) &&\n+\tcheck_signal_exit 13 $OUT\n '\n \n test_expect_success !MINGW 'a constipated git dies with SIGPIPE even if parent ignores it' '\n-\tOUT=$( ((trap \"\" PIPE; large_git; echo $? 1>&3) | :) 3>&1 ) &&\n-\ttest \"$OUT\" -eq 141\n+\tOUT=$( ( (trap \"\" PIPE; large_git; echo $? 1>&3) | :) 3>&1 ) &&\n+\tcheck_signal_exit 13 $OUT\n '\n \n test_done\n"},{"id":"260864","messageId":"20150508211453.GA11594@peff.net","threadId":"39277","inReplyTo":"20150508205548.GB13457@peff.net","subject":"Re: t0005-signals.sh fails with ksh","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2015-05-08T21:14:54Z","receivedAt":"2015-05-08T21:14:54Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, May 08, 2015 at 04:55:48PM -0400, Jeff King wrote:\n\n> > Does this work if you did\n> > \n> > \tOUT=$( ( (large_git ; echo $? 1>&3) | : ) 3>&2 ) &&\n> > \n> > instead?\n> \n> It does for me. I've tested our suite with mksh before, and it passed\n> (that's why the earlier check already covers ksh). But using the ksh I\n> get from \"apt-get install ksh\" on Debian (ksh93, it looks like?) fails\n> as described. The change above prevents the shell from crashing, and\n> then if we also massage the code, the test passes (i.e., the patch\n> below).\n> \n> I'm on the fence, though, on declaring ksh93 to be unsupported. I don't\n> know how many other instances of this are in our test suite, and it's\n> one more maintenance headache to deal with. Are there really platforms\n> with no actual POSIX shell (on Solaris, for example, the xpg6 shell is a\n> much better choice)?\n\nHmph. I just ran the whole suite with SHELL_PATH=ksh. There are about 35\nfailures overall, and they are not all related. For instance, in t4014,\nit looks like a variable assignment just goes missing (whether it is\nbecause it is a one-shot against a function, or because it contains a\nbunch of utf8 characters, I'm not sure). We might be able to work around\nthat. But some of the other failures leave me quite confused.\n\nHere's an oddity I isolated based on a failure in t5502:\n\n  $ git init foo && cd foo\n  Initialized empty Git repository in /home/peff/foo/.git/\n\n  $ (cd .git/objects && ls)\n  info pack\n\nOK, makes sense. Now...\n\n  $ mkdir subdir && cd subdir\n  $ ls ../.git/objects\n  info  pack\n  $ cd ../.git/objects\n  ksh: cd: /home/peff/foo/git/objects: [No such file or directory]\n\nUm, what? Apparently using \"../.foo\" will eat the \".\" off of \"foo\"?\n\n-Peff\n"},{"id":"260865","messageId":"xmqqwq0iixcs.fsf@gitster.dls.corp.google.com","threadId":"39277","inReplyTo":"20150508205548.GB13457@peff.net","subject":"Re: t0005-signals.sh fails with ksh","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-05-08T21:16:19Z","receivedAt":"2015-05-08T21:16:19Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> On Fri, May 08, 2015 at 01:34:49PM -0700, Junio C Hamano wrote:\n>\n>> evgeny <illumsoft.org@gmail.com> writes:\n>> \n>> > expecting success: \n>> >         OUT=$( ((large_git; echo $? 1>&3) | :) 3>&1 ) &&\n>> >         test \"$OUT\" -eq 141\n>> >\n>> > t0005-signals.sh[499]: eval: syntax error at line 4: `(' unmatched\n>> > Memory fault\n>> \n>> Does this work if you did\n>> \n>> \tOUT=$( ( (large_git ; echo $? 1>&3) | : ) 3>&2 ) &&\n>> \n>> instead?\n>\n> It does for me. I've tested our suite with mksh before, and it passed\n> (that's why the earlier check already covers ksh). But using the ksh I\n> get from \"apt-get install ksh\" on Debian (ksh93, it looks like?) fails\n> as described. \n> ...\n\nYuck.\n\n> I'm on the fence, though, on declaring ksh93 to be unsupported. I don't\n> know how many other instances of this are in our test suite, and it's\n> one more maintenance headache to deal with. Are there really platforms\n> with no actual POSIX shell (on Solaris, for example, the xpg6 shell is a\n> much better choice)?\n\nYeah, ksh has gone too far and now is on the other side, I would\nhave to say.  Introducing new keywords and semantics to let its\nusers use new features (e.g. \"let\") is one thing, but breaking a\nvalid POSIX shell construct and interpreting it in an incompatible\nway is going just too far for it to be treated as a Bourne variant.\n\nI wonder if zsh is in the same league.  Do we support people who do\nSHELL_PATH=/bin/zsh and bend over backwards when it breaks?\n\nI'm on the fence, too.\n"},{"id":"260869","messageId":"20150508212146.GA16614@peff.net","threadId":"39277","inReplyTo":"xmqqwq0iixcs.fsf@gitster.dls.corp.google.com","subject":"Re: t0005-signals.sh fails with ksh","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2015-05-08T21:21:47Z","receivedAt":"2015-05-08T21:21:47Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, May 08, 2015 at 02:16:19PM -0700, Junio C Hamano wrote:\n\n> Yeah, ksh has gone too far and now is on the other side, I would\n> have to say.  Introducing new keywords and semantics to let its\n> users use new features (e.g. \"let\") is one thing, but breaking a\n> valid POSIX shell construct and interpreting it in an incompatible\n> way is going just too far for it to be treated as a Bourne variant.\n\nYeah, especially after my followup email, I think I'm not on the fence\nanymore.\n\n> I wonder if zsh is in the same league.  Do we support people who do\n> SHELL_PATH=/bin/zsh and bend over backwards when it breaks?\n\nI tried \"make SHELL_PATH=zsh test\", but had trouble seeing the test\noutput for all of the errors being spewed to stderr. ;)\n\nCertainly this:\n\n  $ zsh ./t0000-basic.sh -v -i\n  > [...]\n  test_cmp:1: command not found: diff -u\n  not ok 4 - pretend we have a fully passing test suite\n\nis not especially encouraging (it looks like running \"$FOO bar\" does not\nword-split $FOO). I am not a zsh user, though, so there may be ways to\nconvince it to be more POSIX-y (e.g., just calling it as \"sh\").\n\n-Peff\n"},{"id":"260872","messageId":"xmqqk2wiiwa3.fsf@gitster.dls.corp.google.com","threadId":"39277","inReplyTo":"20150508211453.GA11594@peff.net","subject":"Re: t0005-signals.sh fails with ksh","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-05-08T21:39:32Z","receivedAt":"2015-05-08T21:39:32Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> Here's an oddity I isolated based on a failure in t5502:\n>\n>   $ git init foo && cd foo\n>   Initialized empty Git repository in /home/peff/foo/.git/\n>\n>   $ (cd .git/objects && ls)\n>   info pack\n>\n> OK, makes sense. Now...\n>\n>   $ mkdir subdir && cd subdir\n>   $ ls ../.git/objects\n>   info  pack\n>   $ cd ../.git/objects\n>   ksh: cd: /home/peff/foo/git/objects: [No such file or directory]\n>\n> Um, what? Apparently using \"../.foo\" will eat the \".\" off of \"foo\"?\n\nThat is fun.  And doing\n\n    $ mkdir -p git/objects\n\njust before you create and chdir into subdir does tell me that the\nlast \"cd ../.git/objects\" is turned into \"cd ../git/objects\".\n\nActually, with that extra thing, changing the last one to\n\n    $ cd ../..git/objects\n\nstill takes me to ../git/objects, it seems.  But lookie here:\n\n    $ cd ../.....git/objects\n    ksh: cd: /var/tmp/x/ksh/...git/objects: [No such file or directory]\n\nWAT.\n\nI am tempted to say that we should write it off as utterly broken.\n"},{"id":"260879","messageId":"727591966.20150509020506@gmail.com","threadId":"39277","inReplyTo":"xmqq1tiqkdue.fsf@gitster.dls.corp.google.com","subject":"Re: t0005-signals.sh fails with ksh","fromName":"evgeny","fromEmail":"illumsoft.org@gmail.com","sentAt":"2015-05-08T23:05:06Z","receivedAt":"2015-05-08T23:05:06Z","isPatch":false,"sender":{"key":"illumsoft.org@gmail.com","avatar":null},"body":"Hello Junio,\n\nFriday, May 8, 2015, 11:34:49 PM, you wrote:\n\n> evgeny <illumsoft.org@gmail.com> writes:\n\n>> expecting success: \n>>         OUT=$( ((large_git; echo $? 1>&3) | :) 3>&1 ) &&\n>>         test \"$OUT\" -eq 141\n>>\n>> t0005-signals.sh[499]: eval: syntax error at line 4: `(' unmatched\n>> Memory fault\n\n> Does this work if you did\n\n>         OUT=$( ( (large_git ; echo $? 1>&3) | : ) 3>&2 ) &&\n\n> instead?\n\nYes. when I add a space between parentheses and change 141 to 269 all tests in \nt0005-signals.sh are passed.\n\n... stripped first lines ...\nok 3 - create blob\n\nexpecting success: \n        OUT=$( ( (large_git; echo $? 1>&3) | :) 3>&1 ) &&\n        test \"$OUT\" -eq 269\n\nok 4 - a constipated git dies with SIGPIPE\n\nexpecting success: \n        OUT=$( ( (trap \"\" PIPE; large_git; echo $? 1>&3) | :) 3>&1 ) &&\n        test \"$OUT\" -eq 269\n\nok 5 - a constipated git dies with SIGPIPE even if parent ignores it\n\n# passed all 5 test(s)\n1..5\n\n\n>> 'man ksh' reads:\n>>   (list)\n>>     Execute  list  in  a  separate environment.\n>>     Note, that if two adjacent open parentheses are needed for nesting,\n>>     a space must be inserted to avoid evaluation as an arithmetic command as\n>>     described above.\n\n> Hmm, I cannot see \"as described above\" in your message, but isn't\n> that talking about a common mistake of turning cmd1 in this pipeline\n\n>         x=$(cmd1 | cmd2)\n\n> into a series of two commands, e.g. (cmd1a && cmd1b) and saying\n\n>         x=$((cmd1a && cmd1b) | cmd2)\n\n> which does make \"$((\" interpreted as the beginning of arithmetic\n> expansion?\n\n> And the \"OUT=$( ((large...\" construct seems to be written in order\n> to avoid that exact issue (notice the SP after \"$(\").\n\n> Puzzled....\n\nIt was an excerpt from ksh's man page, and \"as described above\" refers to \nprevious paragraph where \"((expression))\" expained.\n\nI think the space after \"$(\" refers to \"Arithmetic Substitution\" paragraph\nand the following two parentheses are about \"Note, that if two adjacent open \nparentheses are needed for nesting, a space must be inserted\"\n\n              \n$ man ksh\n... skipped ...\n\n      Arithmetic Substitution.\n       An  arithmetic  expression  enclosed  in  double parentheses preceded by a dollar sign ( $(()) ) is replaced by the\n       value of the arithmetic expression within the double parentheses.\n\n... skipped ...\n\n       ((expression))\n              The expression is evaluated using the rules for arithmetic evaluation described below.  If the value of  the\n              arithmetic expression is non-zero, the exit status is 0, otherwise the exit status is 1.\n\n       (list)\n              Execute list in a separate environment.  Note, that if two adjacent open parentheses are needed for nesting,\n              a space must be inserted to avoid evaluation as an arithmetic command as described above.\n\n... skipped ...\n\n\nSome info about my system:\n\n$ head -1 /etc/os-release \nPRETTY_NAME=\"Debian GNU/Linux 7 (wheezy)\"\n\n$ ksh --version\n  version         sh (AT&T Research) 93u+ 2012-02-29\n\n  It is surprise for me that ksh is so old.\n  \n$ ls -l $(which ksh)\nlrwxrwxrwx 1 root root 29 May  6 22:44 /usr/bin/ksh -> /etc/alternatives/usr.bin.ksh\n\n$ ls -l /etc/alternatives/usr.bin.ksh\nlrwxrwxrwx 1 root root 10 May  6 22:44 /etc/alternatives/usr.bin.ksh -> /bin/ksh93\n\n$ ls -l /bin/ksh93\n-rwxr-xr-x 1 root root 1446836 Jan  3  2013 /bin/ksh93\n  \n-- \nBest regards,\n evgeny\n \n"},{"id":"260881","messageId":"479525721.20150509024300@gmail.com","threadId":"39277","inReplyTo":"xmqqk2wiiwa3.fsf@gitster.dls.corp.google.com","subject":"Re: t0005-signals.sh fails with ksh","fromName":"evgeny","fromEmail":"illumsoft.org@gmail.com","sentAt":"2015-05-08T23:43:00Z","receivedAt":"2015-05-08T23:43:00Z","isPatch":false,"sender":{"key":"illumsoft.org@gmail.com","avatar":null},"body":"Hi,\njust for information about ksh on Linux and OpenIndiana\n\n           ksh93 on Debian GNU/Linux 7 (wheezy)\n\n$ ksh --version\n  version         sh (AT&T Research) 93u+ 2012-02-29\n\n$ git init foo && cd foo\nInitialized empty Git repository in /var/tmp/foo/.git/\n$ (cd .git/objects && ls)\ninfo  pack\n$ mkdir subdir && cd subdir\n$ ls ../.git/objects\ninfo  pack\n$ cd ../.git/objects\n/bin/ksh93: cd: /var/tmp/foo/git/objects: [No such file or directory]\n\n\n           ksh93 on OpenIndiana oi_151.1.9 X86\n\n$ ksh --version\n  version         sh (AT&T Research) 93t+ 2010-03-05\n\n$ pwd\n/var/tmp\n$ git init foo && cd foo\nInitialized empty Git repository in /var/tmp/foo/.git/\n$ (cd .git/objects && ls)\ninfo  pack\n$ mkdir subdir && cd subdir\n$ ls ../.git/objects\ninfo  pack\n$ cd ../.git/objects\n$ pwd\n/var/tmp/foo/.git/objects\n\nLooks like older version (or Solaris version?) of ksh did not have this bug.\n\nSaturday, May 9, 2015, 12:39:32 AM, you wrote:\n\n> Jeff King <peff@peff.net> writes:\n\n>> Here's an oddity I isolated based on a failure in t5502:\n>>\n>>   $ git init foo && cd foo\n>>   Initialized empty Git repository in /home/peff/foo/.git/\n>>\n>>   $ (cd .git/objects && ls)\n>>   info pack\n>>\n>> OK, makes sense. Now...\n>>\n>>   $ mkdir subdir && cd subdir\n>>   $ ls ../.git/objects\n>>   info  pack\n>>   $ cd ../.git/objects\n>>   ksh: cd: /home/peff/foo/git/objects: [No such file or directory]\n>>\n>> Um, what? Apparently using \"../.foo\" will eat the \".\" off of \"foo\"?\n\n> That is fun.  And doing\n\n>     $ mkdir -p git/objects\n\n> just before you create and chdir into subdir does tell me that the\n> last \"cd ../.git/objects\" is turned into \"cd ../git/objects\".\n\n> Actually, with that extra thing, changing the last one to\n\n>     $ cd ../..git/objects\n\n> still takes me to ../git/objects, it seems.  But lookie here:\n\n>     $ cd ../.....git/objects\n>     ksh: cd: /var/tmp/x/ksh/...git/objects: [No such file or directory]\n\n> WAT.\n\n> I am tempted to say that we should write it off as utterly broken.\n\n\n\n\n\n-- \nBest regards,\n evgeny                            mailto:illumsoft.org@gmail.com\n"},{"id":"260894","messageId":"m2h9rmupq5.fsf@linux-m68k.org","threadId":"39277","inReplyTo":"xmqqk2wiiwa3.fsf@gitster.dls.corp.google.com","subject":"Re: t0005-signals.sh fails with ksh","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2015-05-09T08:20:18Z","receivedAt":"2015-05-09T08:20:18Z","isPatch":false,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> That is fun.  And doing\n>\n>     $ mkdir -p git/objects\n>\n> just before you create and chdir into subdir does tell me that the\n> last \"cd ../.git/objects\" is turned into \"cd ../git/objects\".\n\nThis has been fixed in ksh93v.  Looking at the diff between openSUSE\n13.1 and 13.2 version of ksh, this hunk from\nsrc/cmd/ksh93/bltins/cd_pwd.c is responsible:\n\n@@ -109,34 +155,22 @@\n \t\tif(!oldpwd)\n \t\t\toldpwd = path_pwd(shp,1);\n \t}\n-\tif(*dir=='.')\n+\tif(dirfd==shp->pwdfd && *dir!='/')\n \t{\n-\t\t/* test for pathname . ./ .. or ../ */\n-\t\tint\tn=0;\n-\t\tchar\t*sp;\n-\t\tfor(dp=dir; *dp=='.'; dp++)\n-\t\t{\n-\t\t\tif(*++dp=='.' && (*++dp=='/' || *dp==0))\n-\t\t\t\tn++;\n-\t\t\telse if(*dp && *dp!='/')\n-\t\t\t\tbreak;\n-\t\t\tif(*dp==0)\n-\t\t\t\tbreak;\n-\t\t}\n-\t\tif(n)\t\n-\t\t{\n-\t\t\tcdpath = 0;\n-\t\t\tsp = oldpwd + strlen(oldpwd);\n-\t\t\twhile(n--)\n-\t\t\t{\n-\t\t\t\twhile(--sp > oldpwd && *sp!='/');\n-\t\t\t\tif(sp==oldpwd)\n-\t\t\t\t\tbreak;\n-\t\t\t\t\n-\t\t\t}\n-\t\t\tsfwrite(shp->strbuf,oldpwd,sp+1-oldpwd);\n-\t\t\tsfputr(shp->strbuf,dp,0);\n-\t\t\tdir = sfstruse(shp->strbuf);\n+\t\t/* check for leading .. */\n+\n+\t\tchar *cp;\n+\n+\t\tj = sfprintf(shp->strbuf,\"%s\",dir);\n+\t\tcp = sfstruse(shp->strbuf);\n+\t\tpathcanon(cp, j + 1, 0);\n+\t\tif(cp[0]=='.' && cp[1]=='.' && (cp[2]=='/' || cp[2]==0))\n+\t\t{\n+\t\t\tif(!shp->strbuf2)\n+\t\t\t\tshp->strbuf2 = sfstropen();\n+\t\t\tj = sfprintf(shp->strbuf2,\"%s/%s\",oldpwd,cp);\n+\t\t\tdir = sfstruse(shp->strbuf2);\n+\t\t\tpathcanon(dir, j + 1, 0);\n \t\t}\n \t}\n \trval = -1;\n\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n\"And now for something completely different.\"\n"},{"id":"260904","messageId":"20150509200104.GB225482@vauxhall.crustytoothpaste.net","threadId":"39277","inReplyTo":"20150508212146.GA16614@peff.net","subject":"Re: t0005-signals.sh fails with ksh","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2015-05-09T20:01:05Z","receivedAt":"2015-05-09T20:01:05Z","isPatch":false,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On Fri, May 08, 2015 at 05:21:47PM -0400, Jeff King wrote:\n> On Fri, May 08, 2015 at 02:16:19PM -0700, Junio C Hamano wrote:\n> > I wonder if zsh is in the same league.  Do we support people who do\n> > SHELL_PATH=/bin/zsh and bend over backwards when it breaks?\n> \n> I tried \"make SHELL_PATH=zsh test\", but had trouble seeing the test\n> output for all of the errors being spewed to stderr. ;)\n> \n> Certainly this:\n> \n>   $ zsh ./t0000-basic.sh -v -i\n>   > [...]\n>   test_cmp:1: command not found: diff -u\n>   not ok 4 - pretend we have a fully passing test suite\n> \n> is not especially encouraging (it looks like running \"$FOO bar\" does not\n> word-split $FOO). I am not a zsh user, though, so there may be ways to\n> convince it to be more POSIX-y (e.g., just calling it as \"sh\").\n\nI use zsh.  It's possible to convince it to be more POSIXy by saying\n\"emulate sh\" or invoking it via a symlink called sh.  However, having\nsaid that, I don't recommend it.  I set /bin/sh to zsh on my Debian\nsystem and a lot of things broke.  Early versions of Mac OS X did that,\ntoo, and they stopped because it was very broken.\n\nAs for ksh, I don't know whether you want to kill support for just ksh93\nor mksh as well.  I've generally had good experience with mksh as\n/bin/sh when I've tried it, and it's at least semi-supported in Debian\nbecause it meets Debian's POSIX-plus requirements.\n-- \nbrian m. carlson / brian with sandals: Houston, Texas, US\n+1 832 623 2791 | http://www.crustytoothpaste.net/~bmc | My opinion only\nOpenPGP: RSA v4 4096b: 88AC E9B2 9196 305B A994 7552 F1BA 225C 0223 B187\n"}]}