Fixed tests on systems where bash is not /bin/bash

Some systems, such as BSD, have bash stored in /usr/local/bin

Remove the assumption that bash is /bin/bash

Github issue #60
This commit is contained in:
Duncan Ferguson 2016-04-08 20:46:51 +01:00
parent 754a7137b6
commit 454f30978d
7 changed files with 25 additions and 9 deletions

View file

@ -1,3 +1,6 @@
4.07_1 0000-00-00 Duncan Ferguson <duncan_ferguson@user.sf.net>
- Fixed tests on systems where bash is not installed in /bin/bash (Github issue #60)
4.06 2016-03-26 Duncan Ferguson <duncan_ferguson@user.sf.net> 4.06 2016-03-26 Duncan Ferguson <duncan_ferguson@user.sf.net>
- Failure to find the terminal binary should not be fatal - Failure to find the terminal binary should not be fatal
- Fix processing of '--extra_tag_file' and its configuration item (Github issue #51) - Fix processing of '--extra_tag_file' and its configuration item (Github issue #51)

View file

@ -3,7 +3,7 @@ package App::ClusterSSH;
use 5.008.004; use 5.008.004;
use warnings; use warnings;
use strict; use strict;
use version; our $VERSION = version->new('4.06'); use version; our $VERSION = version->new('4.07_1');
use Carp qw/cluck :DEFAULT/; use Carp qw/cluck :DEFAULT/;

View file

@ -226,7 +226,10 @@ sub expand_glob {
if ( grep {m/[{]/} @items ) { if ( grep {m/[{]/} @items ) {
#@expanded = split / /, `/bin/bash -c 'shopt -s extglob\n echo @items'`; #@expanded = split / /, `/bin/bash -c 'shopt -s extglob\n echo @items'`;
my $cmd = $self->parent->config->{shell_expansion}; my $shell = $self->config->find_binary(
$self->parent->config->{shell} );
my $cmd
= $shell . q{ } . $self->parent->config->{shell_expansion};
$cmd =~ s/%items%/@items/; $cmd =~ s/%items%/@items/;
@expanded = split / /, `$cmd`; @expanded = split / /, `$cmd`;
chomp(@expanded); chomp(@expanded);

View file

@ -102,7 +102,8 @@ my %default_config = (
send_menu_xml_file => $ENV{HOME} . '/.clusterssh/send_menu', send_menu_xml_file => $ENV{HOME} . '/.clusterssh/send_menu',
shell_expansion => "/bin/bash -c 'shopt -s extglob\n echo %items%'", shell => "bash",
shell_expansion => "-c 'shopt -s extglob\n echo %items%'",
# don't set username here as takes precendence over ssh config # don't set username here as takes precendence over ssh config
user => '', user => '',

View file

@ -573,7 +573,7 @@ would replace the <Alt-n> with the client's name in each window.}
output 'C<< webservers websvr6 websvr7 websvr8 websvr9 >>'; output 'C<< webservers websvr6 websvr7 websvr8 websvr9 >>';
output $self->loc( output $self->loc(
q{B<NOTE:> this requires [_1] to be installed on your system (see [_2] configuration option }, q{B<NOTE:> this requires [_1] to be installed on your system (see [_2] configuration option },
'/bin/bash', 'C<shell_expansion>' 'bash', 'C<shell_expansion>'
); );
output $self->loc( output $self->loc(
q{Extra cluster files may also be specified either as an option on the command line (see [_1]) or in the user's [_2] file (see [_3] configuration option).}, q{Extra cluster files may also be specified either as an option on the command line (see [_1]) or in the user's [_2] file (see [_3] configuration option).},
@ -772,8 +772,8 @@ B<NOTE:> Any "generic" change to the method (e.g., specifying the ssh port to us
q{Number of pixels from the screen's side to reserve when calculating screen geometry for tiling. Setting this to something like 50 will help keep cssh from positioning windows over your window manager's menu bar if it draws one at that side of the screen.} q{Number of pixels from the screen's side to reserve when calculating screen geometry for tiling. Setting this to something like 50 will help keep cssh from positioning windows over your window manager's menu bar if it draws one at that side of the screen.}
); );
output output q{=item shell = bash};
q{=item shell_expansion = /bin/bash -c 'shopt -s extglob\n echo %items%'"}; output q{=item shell_expansion = -c 'shopt -s extglob\n echo %items%'"};
output $self->loc( output $self->loc(
q{Command used to expand a given string (provided by the macro [_1]) - used for expanding host names when a [_2] is in the name. See [_3]}, q{Command used to expand a given string (provided by the macro [_1]) - used for expanding host names when a [_2] is in the name. See [_3]},
'C<%items%>', 'C<{>', 'L<bash/EXPANSION>' 'C<%items%>', 'C<{>', 'L<bash/EXPANSION>'

View file

@ -116,7 +116,8 @@ Readonly::Hash my %default_config => {
send_menu_xml_file => $ENV{HOME} . '/.clusterssh/send_menu', send_menu_xml_file => $ENV{HOME} . '/.clusterssh/send_menu',
shell_expansion => "/bin/bash -c 'shopt -s extglob\n echo %items%'", shell => "bash",
shell_expansion => "-c 'shopt -s extglob\n echo %items%'",
# other bits inheritted from App::ClusterSSH::Base # other bits inheritted from App::ClusterSSH::Base
debug => 0, debug => 0,
@ -575,7 +576,8 @@ screen_reserve_top=0
send_menu_xml_file=} . $ENV{HOME} . qq{/.clusterssh/send_menu send_menu_xml_file=} . $ENV{HOME} . qq{/.clusterssh/send_menu
sftp=sftp sftp=sftp
sftp_args= sftp_args=
shell_expansion=/bin/bash -c \'shopt -s extglob\n echo %items%\' shell=bash
shell_expansion=-c \'shopt -s extglob\n echo %items%\'
show_history=0 show_history=0
ssh=ssh ssh=ssh
ssh_args= ssh_args=

View file

@ -53,10 +53,13 @@ package main;
BEGIN { BEGIN {
use_ok("App::ClusterSSH::Cluster") || BAIL_OUT('failed to use module'); use_ok("App::ClusterSSH::Cluster") || BAIL_OUT('failed to use module');
use_ok("App::ClusterSSH::Config") || BAIL_OUT('failed to use module');
} }
my $mock_object = Test::ClusterSSH::Mock->new( my $mock_object = Test::ClusterSSH::Mock->new(
shell_expansion => "/bin/bash -c 'shopt -s extglob\n echo %items%'", ); shell => which("bash"),
shell_expansion => "-c 'shopt -s extglob\n echo %items%'",
);
my $cluster1 = App::ClusterSSH::Cluster->new( parent => $mock_object ); my $cluster1 = App::ClusterSSH::Cluster->new( parent => $mock_object );
isa_ok( $cluster1, 'App::ClusterSSH::Cluster' ); isa_ok( $cluster1, 'App::ClusterSSH::Cluster' );
@ -261,6 +264,10 @@ is( $trap->leaveby, 'return', 'exit okay on get_tag_entries' );
is( $trap->stdout, '', 'no stdout for get_tag_entries' ); is( $trap->stdout, '', 'no stdout for get_tag_entries' );
is( $trap->stderr, '', 'no stderr for get_tag_entries' ); is( $trap->stderr, '', 'no stderr for get_tag_entries' );
# This step is required for using find_binary within the underlying
# code of the following methods
$cluster1->set_config( App::ClusterSSH::Config->new() );
# test bash expansion # test bash expansion
my @expected = ( 'aa', 'ab', 'ac' ); my @expected = ( 'aa', 'ab', 'ac' );
$cluster1->register_tag( 'glob1', 'a{a,b,c}' ); $cluster1->register_tag( 'glob1', 'a{a,b,c}' );