summaryrefslogtreecommitdiffstats
path: root/perl_checker.src
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2004-04-28 15:49:18 +0000
committerPascal Rigaux <pixel@mandriva.com>2004-04-28 15:49:18 +0000
commita6ca42ec6122465baef9d2f2ce4051b8d5aaf4a4 (patch)
tree82cc354f0dd01c5b37858d8ffa665f7a0bd3bfce /perl_checker.src
parent7b0dc8925d8e45cf97bbc2c81f10482476937163 (diff)
downloadperl_checker-a6ca42ec6122465baef9d2f2ce4051b8d5aaf4a4.tar
perl_checker-a6ca42ec6122465baef9d2f2ce4051b8d5aaf4a4.tar.gz
perl_checker-a6ca42ec6122465baef9d2f2ce4051b8d5aaf4a4.tar.bz2
perl_checker-a6ca42ec6122465baef9d2f2ce4051b8d5aaf4a4.tar.xz
perl_checker-a6ca42ec6122465baef9d2f2ce4051b8d5aaf4a4.zip
suggest replacing system(qq(foo "$xxx")) with system('foo', $xxx)
Diffstat (limited to 'perl_checker.src')
-rw-r--r--perl_checker.src/parser_helper.ml8
-rw-r--r--perl_checker.src/test/various_errors.t2
2 files changed, 10 insertions, 0 deletions
diff --git a/perl_checker.src/parser_helper.ml b/perl_checker.src/parser_helper.ml
index 1ebaa13..ca28aa8 100644
--- a/perl_checker.src/parser_helper.ml
+++ b/perl_checker.src/parser_helper.ml
@@ -864,6 +864,14 @@ let call_raw force_non_builtin_func (e, para) =
| [ List [ Deref(I_array, _) ] ] -> ()
| _ -> warn_rule (f ^ " is expecting an array and nothing else"))
+ | "system" ->
+ (match un_parenthesize_full_l para with
+ | [ String(l, _) ] ->
+ if List.exists (fun (s, _) -> String.contains s '\'' || String.contains s '"') l &&
+ not (List.exists (fun (s, _) -> List.exists (String.contains s) [ '<' ; '>' ; '&' ; ';']) l) then
+ warn_rule "instead of quoting parameters you should give a list of arguments"
+ | _ -> ())
+
| _ -> ()
);
diff --git a/perl_checker.src/test/various_errors.t b/perl_checker.src/test/various_errors.t
index 0ad2154..535034b 100644
--- a/perl_checker.src/test/various_errors.t
+++ b/perl_checker.src/test/various_errors.t
@@ -22,6 +22,8 @@ join(@l) first argument of join() must be a scal
join(',', 'foo') join('...', $foo) is the same as $foo
+system(qq(foo "$xxx")) instead of quoting parameters you should give a list of arguments
+
my (@l2, $xxx) = @l; @l2 takes all the arguments, $xxx is undef in any case
$bad undeclared variable $bad