From 6487e68048f91824dfc945ee8b11cf0ec49e75ef Mon Sep 17 00:00:00 2001 From: Ray Kraesig Date: Thu, 14 Nov 2019 14:27:02 -0800 Subject: [PATCH] webview build [nfc]: make all variables readonly where possible --- tools/build-webview | 9 ++++++--- tools/build-webview.d/katex.all.pre | 6 +++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/tools/build-webview b/tools/build-webview index eacdb53b720..3fa05458a8c 100755 --- a/tools/build-webview +++ b/tools/build-webview @@ -62,7 +62,7 @@ export -f z_rsync ################################################################################ # Chdir to the current git repo's root. -_root="$(git rev-parse --show-toplevel)" +readonly _root="$(git rev-parse --show-toplevel)" cd "$_root" # Ensure that we have access to a functional `readlink -f`. @@ -98,6 +98,9 @@ fi # Make $_dest absolute, if it isn't already. _dest=$(readlink -m "$_dest") +# Argument parsing has concluded; argument variables are no longer mutable. +readonly _target _dest _sanity_checks + # Sanity-check _dest and _target, if not explicitly disabled. if (( _sanity_checks )); then case "$_target" in @@ -142,13 +145,13 @@ fi # if _sanity_checks # Set _staging. This is our local staging directory; once it's assembled, it'll # be synced over to _dest. -_staging=src/webview/static +readonly _staging=src/webview/static if [ ! -d "$_staging" ]; then err "cannot find asset staging directory '$_staging'"; fi # The auxiliary build script directory. -_aux_script_dir="$_root"/tools/build-webview.d +readonly _aux_script_dir="$_root"/tools/build-webview.d ################################################################################ # Pre-sync: additional build steps diff --git a/tools/build-webview.d/katex.all.pre b/tools/build-webview.d/katex.all.pre index 042a7e3ef65..915ebaaec9c 100755 --- a/tools/build-webview.d/katex.all.pre +++ b/tools/build-webview.d/katex.all.pre @@ -1,12 +1,12 @@ #!/usr/bin/env bash set -eu -_src=${ROOT}/node_modules/katex/dist -_dest="${STAGING}/katex" +readonly _src=${ROOT}/node_modules/katex/dist +readonly _dest="${STAGING}/katex" # KaTeX provides three versions of each of their font files: TrueType, WOFF, # and WOFF2. WOFF2 support is available as of (iOS) Safari 10 and Chrome 36. -_katex_font_type=woff2 +readonly _katex_font_type=woff2 z_rsync "${_src}/" "${_dest}" <