{"thread":{"id":"42638","subject":"[PATCH] rebase: update comment about FreeBSD /bin/sh","startedAt":"2016-06-17T15:41:02Z","lastAt":"2016-06-17T17:10:16Z","messageCount":2,"participants":["Ed Maste","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"289447","messageId":"1466177609-33185-1-git-send-email-emaste@freebsd.org","threadId":"42638","inReplyTo":null,"subject":"[PATCH] rebase: update comment about FreeBSD /bin/sh","fromName":"Ed Maste","fromEmail":"emaste@freebsd.org","sentAt":"2016-06-17T15:33:29Z","receivedAt":"2016-06-17T15:41:02Z","isPatch":true,"sender":{"key":"emaste@freebsd.org","avatar":"https://avatars.githubusercontent.com/u/1034582?v=4"},"body":"Commit 9f50d32 introduced a fix for FreeBSD /bin/sh misbehaviour\nwhen dot-sourcing a file containing \"return\" statements outside of\nany function, from a function in another shell script. That issue\naffects FreeBSD 9.x, and is not present in the /bin/sh in FreeBSD\n10.3 and later. Update the comment to clarify this.\n\nThe example from 9f50d32's commit message produces the expected output\non FreeBSD 10.3 and -CURRENT (the upcoming 11.0):\n\n% sh script1.sh\nonly this line should show\n%\n\nSigned-off-by: Ed Maste <emaste@freebsd.org>\n---\n git-rebase--am.sh          | 4 ++--\n git-rebase--interactive.sh | 4 ++--\n git-rebase--merge.sh       | 4 ++--\n 3 files changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/git-rebase--am.sh b/git-rebase--am.sh\nindex 9ae898b..3752393 100644\n--- a/git-rebase--am.sh\n+++ b/git-rebase--am.sh\n@@ -9,8 +9,8 @@\n # below were not inside any function, and expected to return\n # to the function that dot-sourced us.\n #\n-# However, FreeBSD /bin/sh misbehaves on such a construct and\n-# continues to run the statements that follow such a \"return\".\n+# However, older (9.x) versions of FreeBSD /bin/sh misbehave on such a\n+# construct and continue to run the statements that follow such a \"return\".\n # As a work-around, we introduce an extra layer of a function\n # here, and immediately call it after defining it.\n git_rebase__am () {\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 6e96abc..05f22e4 100644\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -1038,8 +1038,8 @@ check_todo_list () {\n # below were not inside any function, and expected to return\n # to the function that dot-sourced us.\n #\n-# However, FreeBSD /bin/sh misbehaves on such a construct and\n-# continues to run the statements that follow such a \"return\".\n+# However, older (9.x) versions of FreeBSD /bin/sh misbehave on such a\n+# construct and continue to run the statements that follow such a \"return\".\n # As a work-around, we introduce an extra layer of a function\n # here, and immediately call it after defining it.\n git_rebase__interactive () {\ndiff --git a/git-rebase--merge.sh b/git-rebase--merge.sh\nindex 8d43db9..06a4723 100644\n--- a/git-rebase--merge.sh\n+++ b/git-rebase--merge.sh\n@@ -107,8 +107,8 @@ finish_rb_merge () {\n # below were not inside any function, and expected to return\n # to the function that dot-sourced us.\n #\n-# However, FreeBSD /bin/sh misbehaves on such a construct and\n-# continues to run the statements that follow such a \"return\".\n+# However, older (9.x) versions of FreeBSD /bin/sh misbehave on such a\n+# construct and continue to run the statements that follow such a \"return\".\n # As a work-around, we introduce an extra layer of a function\n # here, and immediately call it after defining it.\n git_rebase__merge () {\n-- \n2.8.1\n\n"},{"id":"289459","messageId":"xmqqoa6z213m.fsf@gitster.mtv.corp.google.com","threadId":"42638","inReplyTo":"1466177609-33185-1-git-send-email-emaste@freebsd.org","subject":"Re: [PATCH] rebase: update comment about FreeBSD /bin/sh","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-06-17T17:10:05Z","receivedAt":"2016-06-17T17:10:16Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ed Maste <emaste@freebsd.org> writes:\n\n> Commit 9f50d32 introduced a fix for FreeBSD /bin/sh misbehaviour\n> when dot-sourcing a file containing \"return\" statements outside of\n> any function, from a function in another shell script. That issue\n> affects FreeBSD 9.x, and is not present in the /bin/sh in FreeBSD\n> 10.3 and later. Update the comment to clarify this.\n>\n> The example from 9f50d32's commit message produces the expected output\n> on FreeBSD 10.3 and -CURRENT (the upcoming 11.0):\n>\n> % sh script1.sh\n> only this line should show\n> %\n>\n> Signed-off-by: Ed Maste <emaste@freebsd.org>\n> ---\n>  git-rebase--am.sh          | 4 ++--\n>  git-rebase--interactive.sh | 4 ++--\n>  git-rebase--merge.sh       | 4 ++--\n>  3 files changed, 6 insertions(+), 6 deletions(-)\n\nNice.\n\nIt's only two years since 9f50d32b (rebase: avoid non-function use\nof \"return\" on FreeBSD, 2014-04-11) so we still need the warning,\nbut eventually 9.x will die out and we can stop worrying about this\none.\n\nThanks, will queue.\n\n> diff --git a/git-rebase--am.sh b/git-rebase--am.sh\n> index 9ae898b..3752393 100644\n> --- a/git-rebase--am.sh\n> +++ b/git-rebase--am.sh\n> @@ -9,8 +9,8 @@\n>  # below were not inside any function, and expected to return\n>  # to the function that dot-sourced us.\n>  #\n> -# However, FreeBSD /bin/sh misbehaves on such a construct and\n> -# continues to run the statements that follow such a \"return\".\n> +# However, older (9.x) versions of FreeBSD /bin/sh misbehave on such a\n> +# construct and continue to run the statements that follow such a \"return\".\n>  # As a work-around, we introduce an extra layer of a function\n>  # here, and immediately call it after defining it.\n>  git_rebase__am () {\n> diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\n> index 6e96abc..05f22e4 100644\n> --- a/git-rebase--interactive.sh\n> +++ b/git-rebase--interactive.sh\n> @@ -1038,8 +1038,8 @@ check_todo_list () {\n>  # below were not inside any function, and expected to return\n>  # to the function that dot-sourced us.\n>  #\n> -# However, FreeBSD /bin/sh misbehaves on such a construct and\n> -# continues to run the statements that follow such a \"return\".\n> +# However, older (9.x) versions of FreeBSD /bin/sh misbehave on such a\n> +# construct and continue to run the statements that follow such a \"return\".\n>  # As a work-around, we introduce an extra layer of a function\n>  # here, and immediately call it after defining it.\n>  git_rebase__interactive () {\n> diff --git a/git-rebase--merge.sh b/git-rebase--merge.sh\n> index 8d43db9..06a4723 100644\n> --- a/git-rebase--merge.sh\n> +++ b/git-rebase--merge.sh\n> @@ -107,8 +107,8 @@ finish_rb_merge () {\n>  # below were not inside any function, and expected to return\n>  # to the function that dot-sourced us.\n>  #\n> -# However, FreeBSD /bin/sh misbehaves on such a construct and\n> -# continues to run the statements that follow such a \"return\".\n> +# However, older (9.x) versions of FreeBSD /bin/sh misbehave on such a\n> +# construct and continue to run the statements that follow such a \"return\".\n>  # As a work-around, we introduce an extra layer of a function\n>  # here, and immediately call it after defining it.\n>  git_rebase__merge () {\n"}]}