From 49926cfbac3b5e7a069b783b2b3dfbf4a685beee Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Thu, 19 Jun 2025 12:00:43 +0200 Subject: [PATCH] Standardize shell script indent level We have a mixture of 2 and 4 space indent. 4 benchmarks/driver.sh 2 build_tools/check.sh 4 build_tools/git_version_gen.sh 4 build_tools/mac_notarize.sh 2 build_tools/make_pkg.sh 2 build_tools/make_tarball.sh 2 build_tools/make_vendor_tarball.sh 4 docker/docker_run_tests.sh 4 osx/install.sh 2 tests/test_functions/sphinx-shared.sh Our editorconfig file specifies 2, with no explicit reason. Our fish and Python scripts use 4, so let's use that. --- .editorconfig | 4 +- build_tools/check.sh | 6 +-- build_tools/make_pkg.sh | 62 +++++++++++++-------------- build_tools/make_tarball.sh | 18 ++++---- build_tools/make_vendor_tarball.sh | 12 +++--- tests/test_functions/sphinx-shared.sh | 24 +++++------ 6 files changed, 63 insertions(+), 63 deletions(-) diff --git a/.editorconfig b/.editorconfig index 545df5a90..24f9ff388 100644 --- a/.editorconfig +++ b/.editorconfig @@ -15,8 +15,8 @@ indent_style = tab [*.{md,rst}] trim_trailing_whitespace = false -[*.{sh,ac}] -indent_size = 2 +[*.sh] +indent_size = 4 [Dockerfile] indent_size = 2 diff --git a/build_tools/check.sh b/build_tools/check.sh index b94661a4d..51952c280 100755 --- a/build_tools/check.sh +++ b/build_tools/check.sh @@ -3,9 +3,9 @@ set -ex cleanup () { - if [ -n "$template_file" ] && [ -e "$template_file" ]; then - rm "$template_file" - fi + if [ -n "$template_file" ] && [ -e "$template_file" ]; then + rm "$template_file" + fi } trap cleanup EXIT INT TERM HUP diff --git a/build_tools/make_pkg.sh b/build_tools/make_pkg.sh index 3188f95f6..5e561c2a9 100755 --- a/build_tools/make_pkg.sh +++ b/build_tools/make_pkg.sh @@ -3,18 +3,18 @@ # Script to produce an OS X installer .pkg and .app(.zip) usage() { - echo "Build macOS packages, optionally signing and notarizing them." - echo "Usage: $0 options" - echo "Options:" - echo " -s Enables code signing" - echo " -f Path to .p12 file for application signing" - echo " -i Path to .p12 file for installer signing" - echo " -p Password for the .p12 files (necessary to access the certificates)" - echo " -e (Optional) Path to an entitlements XML file" - echo " -n Enables notarization. This will fail if code signing is not also enabled." - echo " -j Path to JSON file generated with \`rcodesign encode-app-store-connect-api-key\` (required for notarization)" - echo - exit 1 + echo "Build macOS packages, optionally signing and notarizing them." + echo "Usage: $0 options" + echo "Options:" + echo " -s Enables code signing" + echo " -f Path to .p12 file for application signing" + echo " -i Path to .p12 file for installer signing" + echo " -p Password for the .p12 files (necessary to access the certificates)" + echo " -e (Optional) Path to an entitlements XML file" + echo " -n Enables notarization. This will fail if code signing is not also enabled." + echo " -j Path to JSON file generated with \`rcodesign encode-app-store-connect-api-key\` (required for notarization)" + echo + exit 1 } set -x @@ -33,32 +33,32 @@ X86_64_DEPLOY_TARGET='MACOSX_DEPLOYMENT_TARGET=10.9' RUST_VERSION_X86_64=1.73.0 while getopts "sf:i:p:e:nj:" opt; do - case $opt in - s) SIGN=1;; - f) P12_APP_FILE=$(realpath "$OPTARG");; - i) P12_INSTALL_FILE=$(realpath "$OPTARG");; - p) P12_PASSWORD="$OPTARG";; - e) ENTITLEMENTS_FILE=$(realpath "$OPTARG");; - n) NOTARIZE=1;; - j) API_KEY_FILE=$(realpath "$OPTARG");; - \?) usage;; - esac + case $opt in + s) SIGN=1;; + f) P12_APP_FILE=$(realpath "$OPTARG");; + i) P12_INSTALL_FILE=$(realpath "$OPTARG");; + p) P12_PASSWORD="$OPTARG";; + e) ENTITLEMENTS_FILE=$(realpath "$OPTARG");; + n) NOTARIZE=1;; + j) API_KEY_FILE=$(realpath "$OPTARG");; + \?) usage;; + esac done if [ -n "$SIGN" ] && { [ -z "$P12_APP_FILE" ] || [ -z "$P12_INSTALL_FILE" ] || [ -z "$P12_PASSWORD" ]; }; then - usage + usage fi if [ -n "$NOTARIZE" ] && [ -z "$API_KEY_FILE" ]; then - usage + usage fi VERSION=$(git describe --always --dirty 2>/dev/null) if test -z "$VERSION" ; then - echo "Could not get version from git" - if test -f version; then - VERSION=$(cat version) - fi + echo "Could not get version from git" + if test -f version; then + VERSION=$(cat version) + fi fi echo "Version is $VERSION" @@ -76,7 +76,7 @@ mkdir -p "$PKGDIR/build_x86_64" "$PKGDIR/build_arm64" "$PKGDIR/root" "$PKGDIR/in # and will probably not be built universal, so the package will fail to validate/run on other systems. # Note CMAKE_OSX_ARCHITECTURES is still relevant for the Mac app. { cd "$PKGDIR/build_arm64" \ - && cmake \ + && cmake \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DCMAKE_EXE_LINKER_FLAGS="-Wl,-ld_classic" \ -DWITH_GETTEXT=OFF \ @@ -91,7 +91,7 @@ mkdir -p "$PKGDIR/build_x86_64" "$PKGDIR/build_arm64" "$PKGDIR/root" "$PKGDIR/in # Build for x86-64 but do not install; instead we will make some fat binaries inside the root. # Set RUST_VERSION_X86_64 to the last version of Rust that supports macOS 10.9. { cd "$PKGDIR/build_x86_64" \ - && cmake \ + && cmake \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DCMAKE_EXE_LINKER_FLAGS="-Wl,-ld_classic" \ -DWITH_GETTEXT=OFF \ @@ -99,7 +99,7 @@ mkdir -p "$PKGDIR/build_x86_64" "$PKGDIR/build_arm64" "$PKGDIR/root" "$PKGDIR/in -DRust_CARGO_TARGET=x86_64-apple-darwin \ -DCMAKE_OSX_ARCHITECTURES='arm64;x86_64' \ -DFISH_USE_SYSTEM_PCRE2=OFF "$SRC_DIR" \ - && env $X86_64_DEPLOY_TARGET make VERBOSE=1 -j 12; } + && env $X86_64_DEPLOY_TARGET make VERBOSE=1 -j 12; } # Fatten them up. for FILE in "$PKGDIR"/root/usr/local/bin/*; do diff --git a/build_tools/make_tarball.sh b/build_tools/make_tarball.sh index 1bdb8b274..098ff3641 100755 --- a/build_tools/make_tarball.sh +++ b/build_tools/make_tarball.sh @@ -18,22 +18,22 @@ set -e BUILD_TOOL="make" BUILD_GENERATOR="Unix Makefiles" if command -v ninja >/dev/null; then - BUILD_TOOL="ninja" - BUILD_GENERATOR="Ninja" + BUILD_TOOL="ninja" + BUILD_GENERATOR="Ninja" fi # We need GNU tar as that supports the --mtime and --transform options TAR=notfound for try in tar gtar gnutar; do - if $try -Pcf /dev/null --mtime now /dev/null >/dev/null 2>&1; then - TAR=$try - break - fi + if $try -Pcf /dev/null --mtime now /dev/null >/dev/null 2>&1; then + TAR=$try + break + fi done if [ "$TAR" = "notfound" ]; then - echo 'No suitable tar (supporting --mtime) found as tar/gtar/gnutar in PATH' - exit 1 + echo 'No suitable tar (supporting --mtime) found as tar/gtar/gnutar in PATH' + exit 1 fi # Get the current directory, which we'll use for symlinks @@ -63,7 +63,7 @@ cmake -G "$BUILD_GENERATOR" -DCMAKE_BUILD_TYPE=Debug "$wd" $BUILD_TOOL doc TAR_APPEND="$TAR --append --file=$path --mtime=now --owner=0 --group=0 \ - --mode=g+w,a+rX --transform s/^/$prefix\//" + --mode=g+w,a+rX --transform s/^/$prefix\//" $TAR_APPEND --no-recursion user_doc $TAR_APPEND user_doc/html user_doc/man $TAR_APPEND version diff --git a/build_tools/make_vendor_tarball.sh b/build_tools/make_vendor_tarball.sh index f8c878441..e3b8c85b4 100755 --- a/build_tools/make_vendor_tarball.sh +++ b/build_tools/make_vendor_tarball.sh @@ -11,15 +11,15 @@ set -e # We need GNU tar as that supports the --mtime and --transform options TAR=notfound for try in tar gtar gnutar; do - if $try -Pcf /dev/null --mtime now /dev/null >/dev/null 2>&1; then - TAR=$try - break - fi + if $try -Pcf /dev/null --mtime now /dev/null >/dev/null 2>&1; then + TAR=$try + break + fi done if [ "$TAR" = "notfound" ]; then - echo 'No suitable tar (supporting --mtime) found as tar/gtar/gnutar in PATH' - exit 1 + echo 'No suitable tar (supporting --mtime) found as tar/gtar/gnutar in PATH' + exit 1 fi # Get the current directory, which we'll use for telling Cargo where to find the sources diff --git a/tests/test_functions/sphinx-shared.sh b/tests/test_functions/sphinx-shared.sh index c1ebd14bc..bf648da1d 100755 --- a/tests/test_functions/sphinx-shared.sh +++ b/tests/test_functions/sphinx-shared.sh @@ -3,9 +3,9 @@ set -e cleanup () { - if [ -n "$tmp_dir" ] && [ -e "$tmp_dir" ]; then - rm -r "$tmp_dir" - fi + if [ -n "$tmp_dir" ] && [ -e "$tmp_dir" ]; then + rm -r "$tmp_dir" + fi } trap cleanup EXIT INT TERM HUP @@ -17,12 +17,12 @@ tmp_dir=$(mktemp -d) doctree=$tmp_dir/doctree output_dir=$tmp_dir/$builder sphinx-build \ - -j auto \ - -q \ - -W \ - -E \ - -b "$builder" \ - -c "$docsrc" \ - -d "$doctree" \ - "$docsrc" \ - "$output_dir" + -j auto \ + -q \ + -W \ + -E \ + -b "$builder" \ + -c "$docsrc" \ + -d "$doctree" \ + "$docsrc" \ + "$output_dir"