{"thread":{"id":"31253","subject":"[PATCH] Document bash style we prefer for if and functions","startedAt":"2012-08-14T20:39:31Z","lastAt":"2012-08-15T17:55:04Z","messageCount":4,"participants":["Heiko Voigt","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"197016","messageId":"20120814203931.GB33843@book.hvoigt.net","threadId":"31253","inReplyTo":null,"subject":"[PATCH] Document bash style we prefer for if and functions","fromName":"Heiko Voigt","fromEmail":"hvoigt@hvoigt.net","sentAt":"2012-08-14T20:39:31Z","receivedAt":"2012-08-14T20:39:31Z","isPatch":true,"sender":{"key":"hvoigt@hvoigt.net","avatar":"https://avatars.githubusercontent.com/u/184958?v=4"},"body":"During discussion of other patches these preferences have been revealed.\nLets add them to the guidelines.\n\nSigned-off-by: Heiko Voigt <hvoigt@hvoigt.net>\n---\n Documentation/CodingGuidelines | 6 ++++++\n 1 file changed, 6 insertions(+)\n\ndiff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines\nindex 4557711..0a07990 100644\n--- a/Documentation/CodingGuidelines\n+++ b/Documentation/CodingGuidelines\n@@ -76,11 +76,16 @@ For shell scripts specifically (not exhaustive):\n \n  - We do not use Process Substitution <(list) or >(list).\n \n+ - We prefer \"then\" on the next line for if statements.\n+\n  - We prefer \"test\" over \"[ ... ]\".\n \n  - We do not write the noiseword \"function\" in front of shell\n    functions.\n \n+ - We prefer a space between the function name and the parentheses.\n+   E.g.: my_function ()\n+\n  - As to use of grep, stick to a subset of BRE (namely, no \\{m,n\\},\n    [::], [==], nor [..]) for portability.\n \n@@ -97,6 +102,7 @@ For shell scripts specifically (not exhaustive):\n    interface translatable. See \"Marking strings for translation\" in\n    po/README.\n \n+\n For C programs:\n \n  - We use tabs to indent, and interpret tabs as taking up to\n-- \n1.7.12.rc2.11.g5d52328\n"},{"id":"197023","messageId":"7vipcl89kg.fsf@alter.siamese.dyndns.org","threadId":"31253","inReplyTo":"20120814203931.GB33843@book.hvoigt.net","subject":"Re: [PATCH] Document bash style we prefer for if and functions","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-08-14T21:09:35Z","receivedAt":"2012-08-14T21:09:35Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Heiko Voigt <hvoigt@hvoigt.net> writes:\n\n> During discussion of other patches these preferences have been revealed.\n> Lets add them to the guidelines.\n>\n> Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>\n> ---\n>  Documentation/CodingGuidelines | 6 ++++++\n>  1 file changed, 6 insertions(+)\n>\n> diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines\n> index 4557711..0a07990 100644\n> --- a/Documentation/CodingGuidelines\n> +++ b/Documentation/CodingGuidelines\n> @@ -76,11 +76,16 @@ For shell scripts specifically (not exhaustive):\n>  \n>   - We do not use Process Substitution <(list) or >(list).\n>  \n> + - We prefer \"then\" on the next line for if statements.\n> +\n\nThis is not limited to \"if\".  An easy rule of thumb is to write the\ncontrol structure _without_ using semicolon.\n\nThat is:\n\n\tif test ...\n        then\n            ...\n\telse\n\t    ...\n\tfi\n\n\twhile test ...\n        do\n        \t...\n\tdone\n\nnot\n\n\tif test ...; then\n            ...\n\telse ...;\n        fi\n\n        while test ...; do\n\t    ...\n\tdone\n\n>   - We prefer \"test\" over \"[ ... ]\".\n>  \n>   - We do not write the noiseword \"function\" in front of shell\n>     functions.\n>  \n> + - We prefer a space between the function name and the parentheses.\n> +   E.g.: my_function ()\n> +\n\nAlso opening \"{\" on the same line, i.e.\n\n\tmyfunc () {\n\n>   - As to use of grep, stick to a subset of BRE (namely, no \\{m,n\\},\n>     [::], [==], nor [..]) for portability.\n>  \n\n\n> @@ -97,6 +102,7 @@ For shell scripts specifically (not exhaustive):\n>     interface translatable. See \"Marking strings for translation\" in\n>     po/README.\n>  \n> +\n>  For C programs:\n\nProbably not needed, as there is no such double space between C\nand Documentation sections.\n\n>  \n>   - We use tabs to indent, and interpret tabs as taking up to\n"},{"id":"197043","messageId":"20120815170601.GB43523@book.hvoigt.net","threadId":"31253","inReplyTo":"7vipcl89kg.fsf@alter.siamese.dyndns.org","subject":"[PATCH v2] add some bash style we prefer","fromName":"Heiko Voigt","fromEmail":"hvoigt@hvoigt.net","sentAt":"2012-08-15T17:06:01Z","receivedAt":"2012-08-15T17:06:01Z","isPatch":true,"sender":{"key":"hvoigt@hvoigt.net","avatar":"https://avatars.githubusercontent.com/u/184958?v=4"},"body":"During discussion of other patches these preferences have been revealed.\nLets add them to the guidelines.\n\nSigned-off-by: Heiko Voigt <hvoigt@hvoigt.net>\n---\nHere an updated version of the patch.\n\nOn Tue, Aug 14, 2012 at 02:09:35PM -0700, Junio C Hamano wrote:\n> Heiko Voigt <hvoigt@hvoigt.net> writes:\n> > @@ -97,6 +102,7 @@ For shell scripts specifically (not exhaustive):\n> >     interface translatable. See \"Marking strings for translation\" in\n> >     po/README.\n> >  \n> > +\n> >  For C programs:\n> \n> Probably not needed, as there is no such double space between C\n> and Documentation sections.\n\nSorry about that whitespace noise.\n\nCheers Heiko\n\n Documentation/CodingGuidelines | 8 ++++++++\n 1 file changed, 8 insertions(+)\n\ndiff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines\nindex 4557711..e70d110 100644\n--- a/Documentation/CodingGuidelines\n+++ b/Documentation/CodingGuidelines\n@@ -76,11 +76,19 @@ For shell scripts specifically (not exhaustive):\n \n  - We do not use Process Substitution <(list) or >(list).\n \n+ - We prefer writing all control structures without semicolon on the\n+   same line. E.g. \"then\" should be on the next line for if statements.\n+   The same applies to while, for, ...\n+\n  - We prefer \"test\" over \"[ ... ]\".\n \n  - We do not write the noiseword \"function\" in front of shell\n    functions.\n \n+ - We prefer a space between the function name and the parentheses. The\n+   opening \"{\" should also be on the same line.\n+   E.g.: my_function () {\n+\n  - As to use of grep, stick to a subset of BRE (namely, no \\{m,n\\},\n    [::], [==], nor [..]) for portability.\n \n-- \n1.7.12.rc2.11.g5d52328\n"},{"id":"197048","messageId":"7vzk5w59c7.fsf@alter.siamese.dyndns.org","threadId":"31253","inReplyTo":"20120815170601.GB43523@book.hvoigt.net","subject":"Re: [PATCH v2] add some bash style we prefer","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-08-15T17:55:04Z","receivedAt":"2012-08-15T17:55:04Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Heiko Voigt <hvoigt@hvoigt.net> writes:\n\n> During discussion of other patches these preferences have been revealed.\n> Lets add them to the guidelines.\n>\n> Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>\n> ---\n> Here an updated version of the patch.\n\nThanks.\n\n\n>\n> On Tue, Aug 14, 2012 at 02:09:35PM -0700, Junio C Hamano wrote:\n>> Heiko Voigt <hvoigt@hvoigt.net> writes:\n>> > @@ -97,6 +102,7 @@ For shell scripts specifically (not exhaustive):\n>> >     interface translatable. See \"Marking strings for translation\" in\n>> >     po/README.\n>> >  \n>> > +\n>> >  For C programs:\n>> \n>> Probably not needed, as there is no such double space between C\n>> and Documentation sections.\n>\n> Sorry about that whitespace noise.\n>\n> Cheers Heiko\n>\n>  Documentation/CodingGuidelines | 8 ++++++++\n>  1 file changed, 8 insertions(+)\n>\n> diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines\n> index 4557711..e70d110 100644\n> --- a/Documentation/CodingGuidelines\n> +++ b/Documentation/CodingGuidelines\n> @@ -76,11 +76,19 @@ For shell scripts specifically (not exhaustive):\n>  \n>   - We do not use Process Substitution <(list) or >(list).\n>  \n> + - We prefer writing all control structures without semicolon on the\n> +   same line. E.g. \"then\" should be on the next line for if statements.\n> +   The same applies to while, for, ...\n> +\n>   - We prefer \"test\" over \"[ ... ]\".\n>  \n>   - We do not write the noiseword \"function\" in front of shell\n>     functions.\n>  \n> + - We prefer a space between the function name and the parentheses. The\n> +   opening \"{\" should also be on the same line.\n> +   E.g.: my_function () {\n> +\n>   - As to use of grep, stick to a subset of BRE (namely, no \\{m,n\\},\n>     [::], [==], nor [..]) for portability.\n"}]}