AsahiLinux / asahi-installer

Asahi Linux installer
MIT License
782 stars 104 forks source link

toil: update all shell scripts to pass shfmt #310

Closed PaulCharlton closed 3 days ago

PaulCharlton commented 3 days ago

toil: update all shell scripts to pass shfmt

partial fix for https://github.com/AsahiLinux/asahi-installer/issues/309, shellcheck changes separate

toil) undo shfmt bug until it is fixed

in a nutshell, shfmt incorrect places a space between the HEREDOC operator and its LABEL when asked to places spaces after a redirect

to see changes, ignoring whitespace ...

git diff -U0 -w HEAD^ HEAD 

which outputs:

diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..8111ee5
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,4 @@
+[*.sh]
+indent_style = space
+indent_size = 2
+
diff --git a/build.sh b/build.sh
index 93530b6..be67100 100755
--- a/build.sh
+++ b/build.sh
@@ -67 +67 @@ else
-    digest=$( \
+  digest=$(
@@ -71,2 +71,3 @@ else
-        $LIBFFI_MANIFEST_URI \
-        | jq -r '[.manifests[] |
+      $LIBFFI_MANIFEST_URI |
+      jq -r '[
+          .manifests[] |
@@ -75 +76 @@ else
-            ] | first | .annotations."sh.brew.bottle.digest"' \
+        ] | first | .annotations."sh.brew.bottle.digest"'
@@ -124 +125 @@ mkdir -p "$PACKAGE/Frameworks/Python.framework"
-7z x -so "$DL/$PYTHON_PKG" Python_Framework.pkg/Payload | zcat | \
+7z x -so "$DL/$PYTHON_PKG" Python_Framework.pkg/Payload | zcat |
@@ -127 +127,0 @@ mkdir -p "$PACKAGE/Frameworks/Python.framework"
-
@@ -145 +144,0 @@ rm -f _test* _tkinter*
-
diff --git a/push.sh b/push.sh
index 85a35c5..e3b5796 100755
--- a/push.sh
+++ b/push.sh
@@ -13 +13,4 @@ case "$1" in
-    *) echo "Usage: $0 [prod|dev]" 1>&2; exit 1;;
+  *)
+     echo "Usage: $0 [prod|dev]" 1>&2
+     exit 1
+     ;;
@@ -31 +34,3 @@ put() {
-    cat /tmp/ret; echo; echo
+  cat /tmp/ret
+  echo
+  echo
diff --git a/scripts/update-far.sh b/scripts/update-far.sh
index beec9bf..e2a95dd 100755
--- a/scripts/update-far.sh
+++ b/scripts/update-far.sh
@@ -12,3 +12,3 @@ curl -s https://fedora-asahi-remix.org/installer_data.json > /tmp/far.json
-BUILD=$(jq -r < /tmp/far.json \
-    ".os_list[].name | select(. | test(\"$VERSION\")) | sub(\".*\\\\((?<i>.*)\\\\).*\"; \"\\(.i)\")" \
-    | sort -r | head -1)
+BUILD=$(jq -r \
+  ".os_list[].name | select(. | test(\"$VERSION\")) | sub(\".*\\\\((?<i>.*)\\\\).*\"; \"\\(.i)\")" </tmp/far.json  |
+    sort -r | head -1)
@@ -34 +34,4 @@ if [ "$1" == "-u" ] ; then
-    git diff-index --quiet --cached HEAD -- || { echo "There are uncommitted changes, not updating" ; exit 1 ; }
+  git diff-index --quiet --cached HEAD -- || {
+      echo "There are uncommitted changes, not updating"
+      exit 1
+  }
diff --git a/src/install.sh b/src/install.sh
index a053848..18970cd 100755
--- a/src/install.sh
+++ b/src/install.sh
@@ -21 +20,0 @@ export PATH="$PWD/bin:/usr/bin:/bin:/usr/sbin:/sbin:$PATH"
-
diff --git a/src/step2/step2.sh b/src/step2/step2.sh
index 1932e8d..6a6c9ff 100755
--- a/src/step2/step2.sh
+++ b/src/step2/step2.sh
@@ -13 +13,4 @@ cd "${self%%step2.sh}"
-system_dir="$(cd ../../../; pwd)"
+system_dir="$(
+  cd ../../../
+  pwd
+)"
PaulCharlton commented 3 days ago

blocks #311 #312 #313 #314 #315 #316 #317 #318 #319 #320

marcan commented 3 days ago

Pro tip: If you want a project to consider new formatting and coding style conventions, opening 10 independent bugs and sending PRs without any discussion is a really rude way to do it and I now have no interest in pursuing any of this. I'm pretty sure I've cumulatively spent more time dealing with your spam than formatting the relatively small amount of shell scripts we have. Do better.