checkbashisms test <printf %q|%b> doesn't find those bashisms from the beginning of a string

Bug #1477635 reported by Eero
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
devscripts (Ubuntu)
New
Undecided
Unassigned

Bug Description

Steps to produce:

1. create a script test.sh containing the following:
#!/bin/sh
printf "test %b\n" "test"
printf "%b test\n" "test"
2. run "checkbashisms test.sh"
possible bashism in test.sh line 2 (printf %q|%b):
printf "test %b\n" "test"
3. It didn't find the bashism on line 3.

Luckily checkbashisms script can be fixed quite easily. Here's the diff:
--- /usr/bin/checkbashisms 2015-06-15 21:11:48.000000000 +0300
+++ scripts/checkbashisms 2015-07-23 17:35:03.655075945 +0300
@@ -688,7 +688,7 @@
  qr'\$\(\([\s\w$*/+-]*\w\-\-.*?\)\)' => q<'$((n--))' should be '$n; $((n=n-1))'>,
  qr'\$\(\([\s\w$*/+-]*\-\-\w.*?\)\)' => q<'$((--n))' should be '$((n=n-1))'>,
  qr'\$\(\([\s\w$*/+-]*\*\*.*?\)\)' => q<exponentiation is not POSIX>,
- $LEADIN . qr'printf\s["\'][^"\']+?%[qb].+?["\']' => q<printf %q|%b>,
+ $LEADIN . qr'printf\s["\'][^"\']*?%[qb].+?["\']' => q<printf %q|%b>,
     );

     %singlequote_bashisms = (

After the change it works as expected:
$ scripts/checkbashisms test.sh
possible bashism in test.sh line 2 (printf %q|%b):
printf "test %b\n" "test"
possible bashism in test.sh line 3 (printf %q|%b):
printf "%b test\n" "test

ProblemType: Bug
DistroRelease: Ubuntu 14.04
Package: devscripts 2.14.1ubuntu0.1
ProcVersionSignature: Ubuntu 3.13.0-57.95-generic 3.13.11-ckt21
Uname: Linux 3.13.0-57-generic x86_64
NonfreeKernelModules: nvidia_uvm nvidia
ApportVersion: 2.14.1-0ubuntu3.11
Architecture: amd64
CurrentDesktop: Unity
Date: Thu Jul 23 17:41:50 2015
InstallationDate: Installed on 2014-05-16 (433 days ago)
InstallationMedia: Ubuntu 14.04 LTS "Trusty Tahr" - Release amd64 (20140417)
SourcePackage: devscripts
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Eero (eero+launchpad) wrote :
Revision history for this message
Eero (eero+launchpad) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.