Make binstubs offset invariant (#3586)

After realizing that batch-files pick up changes while they are running: https://stackoverflow.com/questions/906586/changing-a-batch-file-when-its-running it seems that it is prudent to avoid changing the offsets inside the file when it is regenerated.

This pr changes two things:

Always generate the full logic in the binstub (it will check for snapshot presence anyways)
For windows we generate some padding after the snapshot path, such that changing the path will not affect indices.
diff --git a/lib/src/global_packages.dart b/lib/src/global_packages.dart
index d8cdef6..9d79a16 100644
--- a/lib/src/global_packages.dart
+++ b/lib/src/global_packages.dart
@@ -732,35 +732,18 @@
       }
     }
 
-    // If the script was built to a snapshot, just try to invoke that
-    // directly and skip pub global run entirely.
-    String invocation;
     late String binstub;
+    // Batch files behave in funky ways if they are modified while updating.
+    // To ensure that the byte-offsets of everything stays the same even if the
+    // snapshot filename changes we insert some padding in lines containing the
+    // snapshot.
+    // 260 is the maximal short path length on Windows. Hopefully that is
+    // enough.
+    final padding = ' ' * (260 - snapshot.length);
+    // We need an absolute path since relative ones won't be relative to the
+    // right directory when the user runs this.
+    snapshot = p.absolute(snapshot);
     if (Platform.isWindows) {
-      if (fileExists(snapshot)) {
-        // We expect absolute paths from the precompiler since relative ones
-        // won't be relative to the right directory when the user runs this.
-        assert(p.isAbsolute(snapshot));
-        invocation = '''
-if exist "$snapshot" (
-  call dart "$snapshot" %*
-  rem The VM exits with code 253 if the snapshot version is out-of-date.
-  rem If it is, we need to delete it and run "pub global" manually.
-  if not errorlevel 253 (
-    goto error
-  )
-  dart pub global run ${package.name}:$script %*
-) else (
-  dart pub global run ${package.name}:$script %*
-)
-goto eof
-:error
-exit /b %errorlevel%
-:eof
-''';
-      } else {
-        invocation = 'dart pub global run ${package.name}:$script %*';
-      }
       binstub = '''
 @echo off
 rem This file was created by pub v${sdk.version}.
@@ -768,14 +751,30 @@
 rem Version: ${package.version}
 rem Executable: $executable
 rem Script: $script
-$invocation
+if exist "$snapshot" $padding(
+  call dart "$snapshot" $padding%*
+  rem The VM exits with code 253 if the snapshot version is out-of-date.
+  rem If it is, we need to delete it and run "pub global" manually.
+  if not errorlevel 253 (
+    goto error
+  )
+  call dart pub global run ${package.name}:$script %*
+) else (
+  call dart pub global run ${package.name}:$script %*
+)
+goto eof
+:error
+exit /b %errorlevel%
+:eof
 ''';
     } else {
-      if (fileExists(snapshot)) {
-        // We expect absolute paths from the precompiler since relative ones
-        // won't be relative to the right directory when the user runs this.
-        assert(p.isAbsolute(snapshot));
-        invocation = '''
+      binstub = '''
+#!/usr/bin/env sh
+# This file was created by pub v${sdk.version}.
+# Package: ${package.name}
+# Version: ${package.version}
+# Executable: $executable
+# Script: $script
 if [ -f $snapshot ]; then
   dart "$snapshot" "\$@"
   # The VM exits with code 253 if the snapshot version is out-of-date.
@@ -789,18 +788,6 @@
   dart pub global run ${package.name}:$script "\$@"
 fi
 ''';
-      } else {
-        invocation = 'dart pub global run ${package.name}:$script "\$@"';
-      }
-      binstub = '''
-#!/usr/bin/env sh
-# This file was created by pub v${sdk.version}.
-# Package: ${package.name}
-# Version: ${package.version}
-# Executable: $executable
-# Script: $script
-$invocation
-''';
     }
 
     // Write the binstub to a temporary location, make it executable and move