about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-05-06 23:32:01 +0200
committerGitHub <noreply@github.com>2023-05-06 23:32:01 +0200
commit60db4487904a1c8ed6a99343c648c0fbda2447b6 (patch)
tree5f1fcdd1b4c3469ab98bf8bcc1aa1e01c3ca91d7
parentbccd29611ac6718d39b8c9d9f4d89052922248b1 (diff)
parenteea6202c248f0aa57a7f490f50a7bf21f322a40e (diff)
downloadrust-60db4487904a1c8ed6a99343c648c0fbda2447b6.tar.gz
rust-60db4487904a1c8ed6a99343c648c0fbda2447b6.zip
Rollup merge of #111151 - ozkanonur:syntax-check-on-bootstrap-scripts, r=Mark-Simulacrum
check bootstrap scripts syntax

Fails bootstrapping if `x`/`x.ps1` scripts are not valid. Currently, it keeps executing lines until the invalid one.
-rwxr-xr-xx5
-rwxr-xr-xx.ps15
2 files changed, 9 insertions, 1 deletions
diff --git a/x b/x
index 4309b82627c..d967988e1c4 100755
--- a/x
+++ b/x
@@ -7,9 +7,12 @@
 
 set -eu
 
+# syntax check
+sh -n $0
+
 realpath() {
     if [ -d "$1" ]; then
-        CDPATH='' command cd "$1" && pwd -P   
+        CDPATH='' command cd "$1" && pwd -P
     else
         echo "$(realpath "$(dirname "$1")")/$(basename "$1")"
     fi
diff --git a/x.ps1 b/x.ps1
index b0cddc9f930..a156017628d 100755
--- a/x.ps1
+++ b/x.ps1
@@ -2,6 +2,11 @@
 
 # See ./x for why these scripts exist.
 
+$ErrorActionPreference = "Stop"
+
+# syntax check
+Get-Command -syntax ${PSCommandPath}
+
 $xpy = Join-Path $PSScriptRoot x.py
 # Start-Process for some reason splits arguments on spaces. (Isn't powershell supposed to be simpler than bash?)
 # Double-quote all the arguments so it doesn't do that.