[Bug 1477635] [NEW] checkbashisms test <printf %q|%b> doesn't find those bashisms from the beginning of a string
Eero
1477635 at bugs.launchpad.net
Thu Jul 23 14:53:16 UTC 2015
Public bug reported:
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)
** Affects: devscripts (Ubuntu)
Importance: Undecided
Status: New
** Tags: amd64 apport-bug trusty
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to devscripts in Ubuntu.
https://bugs.launchpad.net/bugs/1477635
Title:
checkbashisms test <printf %q|%b> doesn't find those bashisms from the
beginning of a string
Status in devscripts package in Ubuntu:
New
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)
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/devscripts/+bug/1477635/+subscriptions
More information about the foundations-bugs
mailing list