Fixed macros (%u,%s,%h,%n) multiple replacements

This commit is contained in:
Duncan Ferguson 2013-04-20 09:17:20 +01:00
parent ea8081ea91
commit e9bb9ef34c
2 changed files with 8 additions and 5 deletions

View file

@ -1,3 +1,6 @@
????-??-?? Duncan Ferguson <duncan_ferguson@user.sf.net> - v4.02_02
- Fixed macros (%u, %s, %h, %n) not doing multiple replacements
2013-04-16 Duncan Ferguson <duncan_ferguson@user.sf.net> - v4.02_01 2013-04-16 Duncan Ferguson <duncan_ferguson@user.sf.net> - v4.02_01
- Refactured file loading code - Refactured file loading code
- Add in 'tags' file handling - Add in 'tags' file handling

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.02_01'); use version; our $VERSION = version->new('4.02_02');
use Carp; use Carp;
@ -538,17 +538,17 @@ sub send_text($@) {
{ {
my $servername = $svr; my $servername = $svr;
$servername =~ s/\s+//; $servername =~ s/\s+//;
$text =~ s/%s/$servername/xsm; $text =~ s/%s/$servername/xsmg;
} }
$text =~ s/%h/hostname()/xsme; $text =~ s/%h/hostname()/xsmeg;
# use connection username, else default to current username # use connection username, else default to current username
{ {
my $username = $servers{$svr}{username}; my $username = $servers{$svr}{username};
$username ||= getpwuid($UID); $username ||= getpwuid($UID);
$text =~ s/%u/$username/xsm; $text =~ s/%u/$username/xsmg;
} }
$text =~ s/%n/\n/xsm; $text =~ s/%n/\n/xsmg;
foreach my $char ( split( //, $text ) ) { foreach my $char ( split( //, $text ) ) {
next if ( !defined($char) ); next if ( !defined($char) );