version up
[mrsh.git] / t / 07_host_routing_escapes.t
blob1e190ad68d6858be2feb8719d13eb55cd69db9fb
2 use strict;
3 use warnings;
5 use Test;
6 use App::MrShell;
8 plan tests => 3;
10 my $shell = App::MrShell->new;
11 my @cmd = ("a b", '%h', "c d", '%h', "e f");
13 DIRECT: {
14     my $host  = "nombre";
15     my @res = $shell->set_subst_vars('%h'=>$host)->subst_cmd_vars(@cmd);
16     ok("@res", "a b nombre c d nombre e f");
19 INDIRECT1: {
20     my $host  = "via1!nombre";
21     my @res = $shell->set_subst_vars('%h'=>$host)->subst_cmd_vars(@cmd);
22     ok("@res", 'a b via1 "a b" nombre "c d" via1 "a b" via1 "\"a b\"" nombre "\"c d\"" nombre "\"e f\""');
25 INDIRECT1: {
26     @cmd = map {my @a = map { (m/^\[/ or $_ eq '%h') ? $_ : substr $_, 0, 1} split; "@a"} @App::MrShell::DEFAULT_SHELL_COMMAND;
27     # do { local $" = ")("; warn " wtf(@cmd)\n" };
29     my $host  = "via1!via2!via3!nombre";
30     my @res = $shell->set_subst_vars('%h'=>$host)->subst_cmd_vars(@cmd);
31     ok("@res", 's - B y - S n - C 2 via1 s - "B y" - "S n" - "C 2" via2 s - "\"B y\"" - "\"S n\"" - "\"C 2\"" via3 s - "\"\\\\\\"B y\\\\\\"\"" - "\"\\\\\\"S n\\\\\\"\"" - "\"\\\\\\"C 2\\\\\\"\"" nombre');