Subject: [PATCH 04/14] checkbashisms: Detect use of $((n++)) (and similar variants)

From: Raphael Geissert <[email-masked]>
Date: Mon, 10 May 2010 02:19:28 -0500

This is a very simple implementation that doesn't handle cases such as
$((n-m++)) or $(((n-1)-m++))

Closes: #572006

Signed-off-by: Raphael Geissert <[email-masked]>
---
 scripts/checkbashisms.pl |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/scripts/checkbashisms.pl b/scripts/checkbashisms.pl
index 182c531..f5c79e4 100755
--- a/scripts/checkbashisms.pl
+++ b/scripts/checkbashisms.pl
@@ -540,6 +540,10 @@ sub init_hashes {
 	qr'\$\{?SHLVL\}?\b'           => q<$SHLVL>,
 	qr'<<<'                       => q<\<\<\< here string>,
 	$LEADIN . qr'echo\s+(?:-[^e\s]+\s+)?\"[^\"]*(\\[abcEfnrtv0])+.*?[\"]' => q<unsafe echo with backslash>,
+	qr'\$\(\(\s*\w+\+\+\s*\)\)'   => q<'$((n++))' should be '$n; $((n=n+1))'>,
+	qr'\$\(\(\s*\+\+\w+\s*\)\)'   => q<'$((++n))' should be '$((n=n+1))'>,
+	qr'\$\(\(\s*\w+\-\-\s*\)\)'   => q<'$((n--))' should be '$n; $((n=n-1))'>,
+	qr'\$\(\(\s*\-\-\w+\s*\)\)'   => q<'$((--n))' should be '$((n=n-1))'>,
     );
 
     %singlequote_bashisms = (
-- 
1.7.1