From 2846a3d21dc4b7f7291c1205428ba4c9433ee00c Mon Sep 17 00:00:00 2001 From: Joelle Maslak Date: Thu, 23 May 2024 21:05:55 -0600 Subject: [PATCH 1/2] Allow bash init to run with hashing disabled --- Changes | 4 ++++ META.json | 3 ++- lib/App/perlbrew.pm | 4 +++- t/bashrc_executes.t | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 t/bashrc_executes.t diff --git a/Changes b/Changes index 331ea121..da7863aa 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,7 @@ +0.99 + - Thanks to our contributors: Joelle Maslak + - bashrc executes properly in bash shells with +h option set + 0.98 - Released at 2023-08-11T22:54:38+0900 - Remove the support of cperl from `available` and `install` command. Github PR: #777. cperl can still be installed by specifying the tarball, just not by their short names. diff --git a/META.json b/META.json index 8ff39616..4ddd1409 100644 --- a/META.json +++ b/META.json @@ -49,7 +49,8 @@ "Test::Output" : "1.03", "Test::Simple" : "1.001002", "Test::Spec" : "0.49", - "Test::TempDir::Tiny" : "0.016" + "Test::TempDir::Tiny" : "0.016", + "Test::Which" : "1.27" } } }, diff --git a/lib/App/perlbrew.pm b/lib/App/perlbrew.pm index ea02dfe8..6a751a8e 100644 --- a/lib/App/perlbrew.pm +++ b/lib/App/perlbrew.pm @@ -2881,7 +2881,9 @@ __perlbrew_purify () { __perlbrew_set_path () { export MANPATH=${PERLBREW_MANPATH:-}${PERLBREW_MANPATH:+:}$(__perlbrew_purify "$(manpath 2>/dev/null)") export PATH=${PERLBREW_PATH:-$PERLBREW_ROOT/bin}:$(__perlbrew_purify "$PATH") - hash -r + if [ -o hashall ] ; then + hash -r + fi } __perlbrew_set_env() { diff --git a/t/bashrc_executes.t b/t/bashrc_executes.t new file mode 100644 index 00000000..120c0dee --- /dev/null +++ b/t/bashrc_executes.t @@ -0,0 +1,38 @@ +#!/usr/bin/env perl +use strict; +use warnings; + +use FindBin; +use lib $FindBin::Bin; +use App::perlbrew; +require 'test_helpers.pl'; + +use Test::More; +use Capture::Tiny qw( capture_stderr ); +use File::Which qw( which ); + +note "PERLBREW_ROOT set to $ENV{PERLBREW_ROOT}"; + +subtest "Works without error output on bash where hashing is off", sub { + my $bash = which("bash"); + if (!defined($bash)) { + plan skip_all => "Bash executable not found, skipping this test."; + return; + } + + my $app = App::perlbrew->new('self-install'); + $app->current_shell("bash"); + $app->run; + + my $ret; + my $out = capture_stderr { + my $bash_init = file($ENV{PERLBREW_ROOT}, "etc", "bashrc"); + system("ls $ENV{PERLBREW_ROOT}/etc/bashrc"); + $ret = system($bash, "+h", "-c", "source $bash_init"); + }; + is($out, "", "No error messages in output"); + is($ret, 0, "Return value proper"); +}; + + +done_testing; From ab27c1518d48935064dca846fecb101eef0d81b1 Mon Sep 17 00:00:00 2001 From: Joelle Maslak Date: Thu, 23 May 2024 21:06:50 -0600 Subject: [PATCH 2/2] Allow specification of non-standard Perl path --- Changes | 1 + lib/App/perlbrew.pm | 5 +++++ perlbrew-install | 5 +++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Changes b/Changes index da7863aa..7e9dfdbf 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,7 @@ 0.99 - Thanks to our contributors: Joelle Maslak - bashrc executes properly in bash shells with +h option set + - Allow specification of non-standard Perl location 0.98 - Released at 2023-08-11T22:54:38+0900 diff --git a/lib/App/perlbrew.pm b/lib/App/perlbrew.pm index 6a751a8e..19f36ee8 100644 --- a/lib/App/perlbrew.pm +++ b/lib/App/perlbrew.pm @@ -3433,6 +3433,11 @@ As a result, different users on the same machine can all share the same perlbrew root directory (although only original user that made the installation would have the permission to perform perl installations.) +If you need to install perlbrew using a Perl that isn't either C +or C, set and export the environment variable +C and then install as described above. Note that you +must not use a perlbrew-managed perl. + You may also install perlbrew from CPAN: cpan App::perlbrew diff --git a/perlbrew-install b/perlbrew-install index 389ab7c3..a9eca238 100755 --- a/perlbrew-install +++ b/perlbrew-install @@ -42,13 +42,14 @@ echo echo "## Installing perlbrew" # loop thru available well known Perl installations -for PERL in "/usr/bin/perl" "/usr/local/bin/perl" +for PERL in "/usr/bin/perl" "/usr/local/bin/perl" "$PERLBREW_SYSTEM_PERL" do - [ -x "$PERL" ] && echo "Using Perl <$PERL>" && break + [ -n "$PERL" ] && [ -x "$PERL" ] && echo "Using Perl <$PERL>" && break done if [ ! -x "$PERL" ]; then echo "Need /usr/bin/perl or /usr/local/bin/perl to use $0" + echo "Alternatively, set PERLBREW_SYSTEM_PERL to point at system perl" clean_exit 2 fi