diff --git a/lib/Parrot/Configure/Options.pm b/lib/Parrot/Configure/Options.pm index c21839ccc6..8ad5aafe64 100644 --- a/lib/Parrot/Configure/Options.pm +++ b/lib/Parrot/Configure/Options.pm @@ -9,6 +9,7 @@ our @EXPORT_OK = qw( process_options ); use Carp; +use File::Spec; use lib qw( lib ); use Parrot::Configure::Options::Conf::CLI (); use Parrot::Configure::Options::Conf::File (); @@ -92,8 +93,9 @@ sub _initial_pass { unless ( $valid_opts{$key} ) { die qq/Invalid option "$key". See "perl $script --help" for valid options\n/; } - if ( $key eq 'prefix' and $value !~ m[^/] ) { - die qq/Relative path given to --prefix, please pass an absolute path\n/; + if ( $key eq 'prefix' and + ! File::Spec->file_name_is_absolute( $value) ) { + die qq/Relative path given to --prefix, please pass an absolute path/; } if ( $options_components->{short_circuits}{$key} ) { push @short_circuits_seen, $key; diff --git a/t/configure/001-options.t b/t/configure/001-options.t index 96fb10d66c..9fa9ffc341 100644 --- a/t/configure/001-options.t +++ b/t/configure/001-options.t @@ -11,7 +11,7 @@ BEGIN { our $topdir = realpath($Bin) . "/../.."; unshift @INC, qq{$topdir/lib}; } -use Test::More tests => 51; +use Test::More tests => 52; use Carp; use Parrot::Configure::Options qw| process_options |; use Parrot::Configure::Options::Conf::CLI (); @@ -88,6 +88,16 @@ like( "process_options() failed due to invalid 'mode' argument" ); +eval { ($args, $step_list_ref) = process_options( { + argv => [ '--prefix=my/relative/path' ], + mode => q{configure}, } ); +}; +like( + $@, + qr/Relative path given to --prefix, please pass an absolute path/, + "process_options() failed due to relative path as value of 'prefix'", +); + ($args, $step_list_ref) = process_options( { mode => q{configure},