Subject: [PATCH 05/14] checkbashisms: detect some printf-related bashisms

From: Raphael Geissert <[email-masked]>
Date: Wed, 12 May 2010 13:27:30 -0500

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

diff --git a/scripts/checkbashisms.pl b/scripts/checkbashisms.pl
index f5c79e4..1074ed9 100755
--- a/scripts/checkbashisms.pl
+++ b/scripts/checkbashisms.pl
@@ -518,6 +518,7 @@ sub init_hashes {
 	$LEADIN . qr'(sh|\$\{?SHELL\}?) --\w+' =>  q<sh --long-option>,
 	$LEADIN . qr'(sh|\$\{?SHELL\}?) [-+]O' =>  q<sh [-+]O>,
 	qr'\[\^[^]]+\]' =>  q<[^] should be [!]>,
+	$LEADIN . qr'printf\s+-v' => q<'printf -v var ...' should be var='$(printf ...)'>,
     );
 
     %string_bashisms = (
@@ -544,6 +545,7 @@ sub init_hashes {
 	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))'>,
+	$LEADIN . qr'printf\s["\'][^"\']+?%[qb].+?["\']' => q<printf %q|%b>,
     );
 
     %singlequote_bashisms = (
-- 
1.7.1