From 5c7b41320fd9b42402583e5f3036c6257891a6c3 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 11 May 2020 00:28:04 +0100 Subject: [PATCH] nailing-cargo: oot_massage_cmdline: Regularise handling Move $pre and $post massage to after the if, so it takes effect on the PATH manipulation if applicable. Add a missing semicolon in ENDPRE. Have it actually remove newlines. Fix up a few tiny spaces to be in the right place cosmetically. Signed-off-by: Ian Jackson --- nailing-cargo | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/nailing-cargo b/nailing-cargo index 737c274..221b05f 100755 --- a/nailing-cargo +++ b/nailing-cargo @@ -372,7 +372,7 @@ sub oot_massage_cmdline () { my @xargs; if (!$cargo_lock_update) { push @xargs, $build_absdir; - ($pre, $post) = ('cd "$1"; shift;', ''); + ($pre, $post) = ('cd "$1"; shift; ', ''); } else { push @xargs, $oot_absdir, $subdir, $src_absdir; $pre = <<'END'; @@ -387,14 +387,12 @@ END cp -- "$1"/Cargo.lock .; ENDLK $pre .= <<'ENDPRE'; - shift + shift; mkdir -p src; >src/lib.rs; ENDPRE $post = <<'ENDPOST'; rm -r src Cargo.toml; ENDPOST - $pre =~ s/^\s+//mg; $pre =~ s/^\s+\n/ /g; - $post =~ s/^\s+//mg; $post =~ s/^\s+\n/ /g; } my $addpath = (cfg_uc qw(oot path_add)) // $use eq 'really' ? Types::Serialiser::true : Types::Serialiser::false; @@ -408,15 +406,17 @@ ENDPOST export PATH; END } + $pre =~ s/^\s+//mg; $pre =~ s/\s+/ /g; + $post =~ s/^\s+//mg; $post =~ s/\s+/ /g; my $getuser = sub { cfgsn qw(oot user) }; my @command; my $xe = $verbose >= 2 ? 'xe' : 'e'; my $sh_ec = sub { if (!length $post) { - @command = (@_, 'sh',"-${xe}c",$pre.' exec "$@"','--',@xargs); + @command = (@_, 'sh',"-${xe}c",$pre.'exec "$@"','--',@xargs); } else { - @command = (@_, 'sh',"-${xe}c",$pre.' "$@"; '.$post,'--',@xargs); + @command = (@_, 'sh',"-${xe}c",$pre.'"$@"; '.$post,'--',@xargs); } push @command, @ARGV; }; -- 2.30.2