my @ignore = ();
my $help = 0;
my $configuration_file = ".checkpatch.conf";
+my $def_configuration_dirs_help = '.:$HOME:.scripts';
+(my $def_configuration_dirs = $def_configuration_dirs_help) =~ s/\$(\w+)/$ENV{$1}/g;
+my $env_config_dir = 'CHECKPATCH_CONFIG_DIR';
my $max_line_length = 100;
my $ignore_perl_version = 0;
my $minimum_perl_version = 5.10.0;
-h, --help, --version display this help and exit
When FILE is - read standard input.
+
+CONFIGURATION FILE
+Default configuration options can be stored in $configuration_file,
+search path: '$def_configuration_dirs_help' or in a directory specified by
+\$$env_config_dir environment variable (fallback to the default search path).
EOM
exit($exitcode);
exit($exitcode);
}
-my $conf = which_conf($configuration_file);
+my $conf = which_conf($configuration_file, $env_config_dir, $def_configuration_dirs);
if (-f $conf) {
my @conf_args;
open(my $conffile, '<', "$conf")
}
sub which_conf {
- my ($conf) = @_;
+ my ($conf, $env_key, $paths) = @_;
+ my $env_dir = $ENV{$env_key};
+
+ if (defined($env_dir) && $env_dir ne "") {
+ return "$env_dir/$conf" if (-e "$env_dir/$conf");
+ warn "$P: Can't find a readable $conf in '$env_dir', falling back to default search paths\n";
+ }
- foreach my $path (split(/:/, ".:$ENV{HOME}:.scripts")) {
+ foreach my $path (split(/:/, $paths)) {
if (-e "$path/$conf") {
return "$path/$conf";
}