Package: devscripts Version: 2.10.18.1 Severity: wishlist User: [EMAIL PROTECTED] Usertags: checkbashisms Tags: patch
Attached is a .diff which adds the following checks:
'(?:^|\s+)suspend\s' => q<suspend>,
'(?:^|\s+)caller\s' => q<caller>,
'(?:^|\s+)complete\s' => q<complete>,
'(?:^|\s+)compgen\s' => q<compgen>,
'(?:^|\s+)declare\s' => q<declare>,
'(?:^|\s+)typeset\s' => q<typset>,
'(?:^|\s+)disown\s' => q<disown>,
'(?:^|\s+)builtin\s' => q<builtin>,
'(?:^|\s+)set\s+-[BHT]+' => q<set -[BHT]>,
'(?:^|\s+)alias\s+-p' => q<alias -p>,
'(?:^|\s+)unalias\s+-a' => q<unalias -a>,
'(?:^|\s+)local\s+(-[a-zA-Z]+)' => q<local -opt>,
'(?:^|\s+)local\s+[^=;)}]+=' => q<local foo=bar>,
Policy requires 'local' to be implemented, but local -r foo, local foo=bar, and
such are extras.
'\$BASH(_[A-Z]+)?\b' => q<$BASH(_SOMETHING)>,
Obvious but helpful to detect whether the script checks if the interpreter is
bash before using a bashism.
Tests:
$ /usr/bin/checkbashisms --version | head -n1
This is checkbashisms, from the Debian devscripts package, version 2.10.18.1
$ checkbashisms --version | head -n1
This is checkbashisms, from the Debian devscripts package, version 2.10.18.1 EXP
$ cat bashisms
#!/bin/sh
bar() {
caller
}
bar
moo(){
local _moo=apt-get
echo ${_moo}
}
moo
builtin echo foo
alias -p
complete
compgen
disown
declare foo
typeset foo
(set -B)
(set -H)
(set -T)
unalias -a
suspend &
$ /usr/bin/checkbashisms bashisms
$ checkbashisms bashisms
possible bashism in bashisms line 8 (local foo=bar):
local _moo=apt-get
possible bashism in bashisms line 12 (builtin):
builtin echo foo
possible bashism in bashisms line 13 (alias -p):
alias -p
possible bashism in bashisms line 17 (declare):
declare foo
possible bashism in bashisms line 18 (typset):
typeset foo
possible bashism in bashisms line 22 (unalias -a):
unalias -a
possible bashism in bashisms line 23 (suspend):
suspend &
$ bash -p bashisms
6 bashisms
apt-get
foo
bashisms: line 16: disown: current: no such job
bashisms: line 23: suspend: cannot suspend: no job control
$ dash bashisms
bashisms: 6: caller: not found
apt-get
bashisms: 12: builtin: not found
alias: -p not found
bashisms: 14: complete: not found
bashisms: 15: compgen: not found
bashisms: 16: disown: not found
bashisms: 17: declare: not found
bashisms: 18: typeset: not found
set: 19: Illegal option -B
set: 20: Illegal option -H
set: 21: Illegal option -T
bashisms: 23: suspend: not found
$ posh bashisms
bashisms:6: caller: not found
bashisms:11: local: _moo=apt-get: not identifier
foo
bashisms:13: alias: not found
bashisms:14: complete: not found
bashisms:15: compgen: not found
bashisms:16: disown: not found
bashisms:17: declare: not found
bashisms:18: typeset: not found
bashisms:19: set: -B: unknown option
bashisms:20: set: -H: unknown option
bashisms:21: set: -T: unknown option
bashisms:22: unalias: not found
bashisms:24: suspend: not found
$ ksh bashisms
bashisms[4]: caller: not found [No such file or directory]
bashisms[8]: local: not found [No such file or directory]
builtin: foo: not found
alias 2d='set -f;_2d'
alias autoload='typeset -fu'
alias command='command '
alias fc=hist
alias float='typeset -lE'
alias functions='typeset -f'
alias hash='alias -t --'
alias history='hist -l'
alias integer='typeset -li'
alias nameref='typeset -n'
alias nohup='nohup '
alias r='hist -s'
alias redirect='command exec'
alias source='command .'
alias stop='kill -s STOP'
alias suspend='kill -s STOP $$'
alias times='{ { time;} 2>&1;}'
alias type='whence -v'
bashisms[14]: complete: not found [No such file or directory]
bashisms[15]: compgen: not found [No such file or directory]
bashisms[17]: declare: not found [No such file or directory]
bashisms[21]: set: -T: unknown option
Usage: set [-sabefhkmnprtuvxBCGH] [-A name] [-o[option]] [arg ...]
bashisms: line 23: suspend: not found
$ zsh bashisms
bar:1: command not found: caller
apt-get
foo
bashisms:13: bad option: -p
bashisms:14: command not found: complete
bashisms:15: command not found: compgen
bashisms:disown:16: no current job
foo=''
bashisms:22: bad option: -a
TIA
Sincerely,
--
Atomo64 - Raphael
Please avoid sending me Word, PowerPoint or Excel attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html
--- /usr/bin/checkbashisms 2008-02-27 12:34:54.000000000 -0600
+++ /home/raphael/bin/local/checkbashisms 2008-02-28 17:32:40.000000000 -0600
@@ -137,6 +137,19 @@
'\[\[(?!:)' => q<alternative test command ([[ foo ]] should be [ foo ])>,
'<<<' => q<\<\<\< here string>,
'/dev/(tcp|udp)' => q</dev/(tcp|udp)>,
+ '(?:^|\s+)suspend\s' => q<suspend>,
+ '(?:^|\s+)caller\s' => q<caller>,
+ '(?:^|\s+)complete\s' => q<complete>,
+ '(?:^|\s+)compgen\s' => q<compgen>,
+ '(?:^|\s+)declare\s' => q<declare>,
+ '(?:^|\s+)typeset\s' => q<typset>,
+ '(?:^|\s+)disown\s' => q<disown>,
+ '(?:^|\s+)builtin\s' => q<builtin>,
+ '(?:^|\s+)set\s+-[BHT]+' => q<set -[BHT]>,
+ '(?:^|\s+)alias\s+-p' => q<alias -p>,
+ '(?:^|\s+)unalias\s+-a' => q<unalias -a>,
+ '(?:^|\s+)local\s+(-[a-zA-Z]+)' => q<local -opt>,
+ '(?:^|\s+)local\s+[^=;)}]+=' => q<local foo=bar>,
);
my %string_bashisms = (
@@ -153,6 +166,7 @@
'\$DIRSTACK\b' => q<$DIRSTACK>,
'\$EUID\b' => q<$EUID should be "id -u">,
'\$SECONDS\b' => q<$SECONDS>,
+ '\$BASH(_[A-Z]+)?\b' => q<$BASH(_SOMETHING)>,
);
if ($opt_echo) {
signature.asc
Description: This is a digitally signed message part.
