Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Make install.sh sh-compatible (#12899)
Conrad Irwine16bbe048f44
diff --git a/script/install.sh b/script/install.shindex 621862ec598..b446fb771c3 100755--- a/script/install.sh+++ b/script/install.sh@@ -1,5 +1,5 @@-#!/usr/bin/env bash-set -euo pipefail+#!/usr/bin/env sh+set -eumain() {platform="$(uname -s)"@@ -7,9 +7,9 @@ main() {channel="${ZED_CHANNEL:-stable}"temp="$(mktemp -d "/tmp/zed-XXXXX")"- if [[ $platform == "Darwin" ]]; then+ if [ "$platform" = "Darwin" ]; thenplatform="macos"- elif [[ $platform == "Linux" ]]; then+ elif [ "$platform" = "Linux" ]; thenplatform="linux"channel="${ZED_CHANNEL:-preview}"else@@ -17,14 +17,18 @@ main() {exit 1fi- if [[ $platform == "macos" ]] && [[ $arch == arm64* ]]; then- arch="aarch64"- elif [[ $arch = x86* || $arch == i686* ]]; then- arch="x86_64"- else- echo "Unsupported architecture $arch"- exit 1- fi+ case "$platform-$arch" in+ macos-arm64*)+ arch="aarch64"+ ;;+ macos-x86* | linux-x86* | linux-i686*)+ arch="x86_64"+ ;;+ *)+ echo "Unsupported platform or architecture"+ exit 1+ ;;+ esacif which curl >/dev/null 2>&1; thencurl () {@@ -33,7 +37,7 @@ main() {elif which wget >/dev/null 2>&1; thencurl () {wget -O- "$@"- }+ }elseecho "Could not find 'curl' or 'wget' in your path"exit 1@@ -51,7 +55,7 @@ linux() {fisuffix=""- if [[ $channel != "stable" ]]; then+ if [ "$channel" != "stable" ]; thensuffix="-$channel"fi@@ -84,16 +88,16 @@ linux() {mkdir -p "$HOME/.local/bin" "$HOME/.local/share/applications"# Link the binary- if [ -f ~/.local/zed$suffix.app/bin/zed ]; then- ln -sf ~/.local/zed$suffix.app/bin/zed "$HOME/.local/bin/zed"+ if [ -f "$HOME/.local/zed$suffix.app/bin/zed" ]; then+ ln -sf "$HOME/.local/zed$suffix.app/bin/zed" "$HOME/.local/bin/zed"else# support for versions before 0.139.x.- ln -sf ~/.local/zed$suffix.app/bin/cli "$HOME/.local/bin/zed"+ ln -sf "$HOME/.local/zed$suffix.app/bin/cli" "$HOME/.local/bin/zed"fi# Copy .desktop filedesktop_file_path="$HOME/.local/share/applications/${appid}.desktop"- cp ~/.local/zed$suffix.app/share/applications/zed$suffix.desktop "${desktop_file_path}"+ cp "$HOME/.local/zed$suffix.app/share/applications/zed$suffix.desktop" "${desktop_file_path}"sed -i "s|Icon=zed|Icon=$HOME/.local/zed$suffix.app/share/icons/hicolor/512x512/apps/zed.png|g" "${desktop_file_path}"sed -i "s|Exec=zed|Exec=$HOME/.local/zed$suffix.app/libexec/zed-editor|g" "${desktop_file_path}"@@ -114,7 +118,7 @@ macos() {hdiutil attach -quiet "$temp/Zed-$arch.dmg" -mountpoint "$temp/mount"app="$(cd "$temp/mount/"; echo *.app)"echo "Installing $app"- if [[ -d "/Applications/$app" ]]; then+ if [ -d "/Applications/$app" ]; thenecho "Removing existing $app"rm -rf "/Applications/$app"fi@@ -123,7 +127,7 @@ macos() {mkdir -p "$HOME/.local/bin"# Link the binary- ln -sf /Applications/$app/Contents/MacOS/cli "$HOME/.local/bin/zed"+ ln -sf "/Applications/$app/Contents/MacOS/cli" "$HOME/.local/bin/zed"if which "zed" >/dev/null 2>&1; thenecho "Zed has been installed. Run with 'zed'"