all: update shebangs for more portability
NixOS by default doesn't ship with /bin/bash, rather /usr/bin/env bash is the way to get the right bash.
This caused two issues on NixOS:
1. The `push` button on the web interface would fail with ` ! [remote rejected] <commit> -> <branch> (pre-receive hook declined)`
2. `make` would result in an error
On the host side, for 1 you could see `fatal: cannot exec '/tmp/sketch-git-hooks-3993344797/pre-receive': No such file or directory`, and for 2, you could similarly see `make: ./build/webui.sh: No such file or directory`
This fixes both of those errors by updating to more portable shebangs.
```
diff --git a/bin/run-formatters.sh b/bin/run-formatters.sh
index 0f740ee..75895ce 100755
--- a/bin/run-formatters.sh
+++ b/bin/run-formatters.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
# Script to run formatters for both Go and webui files
diff --git a/build/clean.sh b/build/clean.sh
index d6117da..2391f6a 100755
--- a/build/clean.sh
+++ b/build/clean.sh
@@ -1,6 +1,6 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
rm -f sketch
rm -rf embedded/sketch-linux embedded/webui-dist
-rm -rf webui/node_modules webui/dist
\ No newline at end of file
+rm -rf webui/node_modules webui/dist
diff --git a/build/innie.sh b/build/innie.sh
index bbf8825..8ace0af 100755
--- a/build/innie.sh
+++ b/build/innie.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="${LDFLAGS:-}" -tags=innie -o embedded/sketch-linux/sketch-linux-amd64 ./cmd/sketch &
diff --git a/build/outie.sh b/build/outie.sh
index f267167..def83fd 100755
--- a/build/outie.sh
+++ b/build/outie.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
# Note: This incantation is duplicated in .goreleaser.yml; please keep them in sync.
diff --git a/build/webui.sh b/build/webui.sh
index 46c5e5d..b70bbdd 100755
--- a/build/webui.sh
+++ b/build/webui.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
# Use a content-based hash of the webui dir to avoid unnecessary rebuilds.
diff --git a/claudetool/codereview/update_tests.sh b/claudetool/codereview/update_tests.sh
index 324f28a..2d75df4 100755
--- a/claudetool/codereview/update_tests.sh
+++ b/claudetool/codereview/update_tests.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CURRENT_DIR=$(pwd)
diff --git a/dockerimg/githttp_test.go b/dockerimg/githttp_test.go
index 95a565a..eb5c964 100644
--- a/dockerimg/githttp_test.go
+++ b/dockerimg/githttp_test.go
@@ -51,7 +51,7 @@
// Check for key elements in the script
contentStr := string(content)
if !containsAll(contentStr, []string{
- "#!/bin/bash",
+ "#!/usr/bin/env bash",
"refs/remotes/origin/",
"git push origin",
"Force pushes are not allowed",
@@ -110,7 +110,7 @@
// Verify the script contains the expected bash shebang
scriptContent := string(script)
- if !contains(scriptContent, "#!/bin/bash") {
+ if !contains(scriptContent, "#!/usr/bin/env bash") {
t.Errorf("pre-receive hook missing bash shebang")
}
diff --git a/dockerimg/post-receive.sh b/dockerimg/post-receive.sh
index 360600d..79b4b9d 100644
--- a/dockerimg/post-receive.sh
+++ b/dockerimg/post-receive.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
# Post-receive hook for sketch git http server
# Sets upstream tracking branch for sketch branches
diff --git a/dockerimg/pre-receive.sh b/dockerimg/pre-receive.sh
index dfabb64..6f70559 100644
--- a/dockerimg/pre-receive.sh
+++ b/dockerimg/pre-receive.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
# Pre-receive hook for sketch git http server
# Handles refs/remotes/origin/Y pushes by forwarding them to origin/Y
diff --git a/loop/update_tests.sh b/loop/update_tests.sh
index 1e78edd..ab5e2e0 100755
--- a/loop/update_tests.sh
+++ b/loop/update_tests.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
CURRENT_DIR=$(pwd)