chiark / gitweb /
nailing-cargo: oot_massage_cmdline: Regularise handling
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 10 May 2020 23:28:04 +0000 (00:28 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 10 May 2020 23:28:04 +0000 (00:28 +0100)
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 <ijackson@chiark.greenend.org.uk>
nailing-cargo

index 737c274d53a0383285c08fd2afb910bad6ce04bf..221b05f26b27c87741ff49294b37c229cef37a47 100755 (executable)
@@ -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;
   };