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.
This commit is contained in:
Matthias Krüger 2023-05-06 23:32:01 +02:00 committed by GitHub
commit 60db448790
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

5
x
View File

@ -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

5
x.ps1
View File

@ -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.