{"thread":{"id":"33604","subject":"[PATCH] check-non-portable-shell: Check for non portable grep usage","startedAt":"2013-04-25T18:48:18Z","lastAt":"2013-04-25T20:44:28Z","messageCount":2,"participants":["Torsten Bögershausen","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"215470","messageId":"201304252048.19235.tboegi@web.de","threadId":"33604","inReplyTo":null,"subject":"[PATCH] check-non-portable-shell: Check for non portable grep usage","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2013-04-25T18:48:18Z","receivedAt":"2013-04-25T18:48:18Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"The make test-lint could check for some common non portable\ngrep usage:\n\nThe + as a qualifier is not a \"basic regular expression\".\nSome grep understand \\+, but in general egrep should be used.\n\nThe \\t can not be used to find an ASCII TAB, neither\ncan \\s be used to find a whitespace\n\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\n t/check-non-portable-shell.pl | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/t/check-non-portable-shell.pl b/t/check-non-portable-shell.pl\nindex ff87611..58f8e2c 100755\n--- a/t/check-non-portable-shell.pl\n+++ b/t/check-non-portable-shell.pl\n@@ -16,6 +16,8 @@ sub err {\n \n while (<>) {\n \tchomp;\n+\t/ e?grep\\s+\\\"[^\"]*\\\\([st])/ and err \"grep \\\\$1 is not portable)\";\n+\t/ [^e]grep.*\\\\\\+/ and err 'grep with \\+ is not portable (please use egrep)';\n \t/^\\s*sed\\s+-i/ and err 'sed -i is not portable';\n \t/^\\s*echo\\s+-(\\S)\\s+/ and err \"echo -$1 is not portable (please use printf)\";\n \t/^\\s*declare\\s+/ and err 'arrays/declare not portable';\n-- \n1.8.2.1.614.g66d7af5\n"},{"id":"215505","messageId":"7vehdy2vdf.fsf@alter.siamese.dyndns.org","threadId":"33604","inReplyTo":"201304252048.19235.tboegi@web.de","subject":"Re: [PATCH] check-non-portable-shell: Check for non portable grep usage","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-04-25T20:44:28Z","receivedAt":"2013-04-25T20:44:28Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Torsten Bögershausen <tboegi@web.de> writes:\n\n> The make test-lint could check for some common non portable\n> grep usage:\n>\n> The + as a qualifier is not a \"basic regular expression\".\n> Some grep understand \\+, but in general egrep should be used.\n>\n> The \\t can not be used to find an ASCII TAB, neither\n> can \\s be used to find a whitespace\n>\n> Signed-off-by: Torsten Bögershausen <tboegi@web.de>\n> ---\n>  t/check-non-portable-shell.pl | 2 ++\n>  1 file changed, 2 insertions(+)\n>\n> diff --git a/t/check-non-portable-shell.pl b/t/check-non-portable-shell.pl\n> index ff87611..58f8e2c 100755\n> --- a/t/check-non-portable-shell.pl\n> +++ b/t/check-non-portable-shell.pl\n> @@ -16,6 +16,8 @@ sub err {\n>  \n>  while (<>) {\n>  \tchomp;\n> +\t/ e?grep\\s+\\\"[^\"]*\\\\([st])/ and err \"grep \\\\$1 is not portable)\";\n\ngrep -e \"foo\\tbar\" is exempt?  Indenting with a single tab,\nimmediately followed by \"grep\" or \"egrep\" without SP in front, is\nexempt?\n\n> +\t/ [^e]grep.*\\\\\\+/ and err 'grep with \\+ is not portable (please use egrep)';\n\nNot even checking if the it is inside the pattern of grep?\n\nAs I said number of times, I do not think it is a workable approach\nto textually match patterns in a script that does not understand\neven the basic shell syntax.\n\n>  \t/^\\s*sed\\s+-i/ and err 'sed -i is not portable';\n>  \t/^\\s*echo\\s+-(\\S)\\s+/ and err \"echo -$1 is not portable (please use printf)\";\n>  \t/^\\s*declare\\s+/ and err 'arrays/declare not portable';\n"}]}