mirror of
https://github.com/veeso/termscp.git
synced 2026-09-26 14:01:17 -07:00
fix(install): quote vars, fix set -e cargo check and rustup tmpfile cleanup
- silence SC3043 by declaring dash dialect (local is supported) - quote unquoted vars (SC2086/SC1090) - fix set -e aborting arch install before cargo check - fix install_cargo removing unset $archive instead of $rustup - make brew upgrade fallback a real if-then-else (SC2015) - drop leftover starship BASE_URL and debug echo $1
This commit is contained in:
+17
-18
@@ -1,4 +1,5 @@
|
|||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
|
# shellcheck shell=dash
|
||||||
|
|
||||||
# Options
|
# Options
|
||||||
#
|
#
|
||||||
@@ -86,7 +87,7 @@ download() {
|
|||||||
|
|
||||||
error "Command failed (exit code $rc): ${BLUE}${cmd}${NO_COLOR}"
|
error "Command failed (exit code $rc): ${BLUE}${cmd}${NO_COLOR}"
|
||||||
warn "If you believe this is a bug, please report immediately an issue to <https://github.com/veeso/termscp/issues/new>"
|
warn "If you believe this is a bug, please report immediately an issue to <https://github.com/veeso/termscp/issues/new>"
|
||||||
return $rc
|
return "$rc"
|
||||||
}
|
}
|
||||||
|
|
||||||
test_writeable() {
|
test_writeable() {
|
||||||
@@ -125,7 +126,7 @@ elevate_priv_ex() {
|
|||||||
else
|
else
|
||||||
elevate_priv
|
elevate_priv
|
||||||
fi
|
fi
|
||||||
echo $sudo
|
echo "$sudo"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Currently supporting:
|
# Currently supporting:
|
||||||
@@ -195,9 +196,7 @@ install_on_arch_linux() {
|
|||||||
pkg="$1"
|
pkg="$1"
|
||||||
info "Detected ${YELLOW}${pkg}${NO_COLOR} on your system"
|
info "Detected ${YELLOW}${pkg}${NO_COLOR} on your system"
|
||||||
# check if rust is already installed
|
# check if rust is already installed
|
||||||
has cargo
|
if ! has cargo; then
|
||||||
CARGO=$?
|
|
||||||
if [ $CARGO -ne 0 ]; then
|
|
||||||
confirm "${YELLOW}rust${NO_COLOR} is required to install ${GREEN}termscp${NO_COLOR}; would you like to proceed?"
|
confirm "${YELLOW}rust${NO_COLOR} is required to install ${GREEN}termscp${NO_COLOR}; would you like to proceed?"
|
||||||
$pkg -S rust
|
$pkg -S rust
|
||||||
fi
|
fi
|
||||||
@@ -210,7 +209,10 @@ install_with_brew() {
|
|||||||
if has termscp; then
|
if has termscp; then
|
||||||
info "Upgrading ${GREEN}termscp${NO_COLOR}…"
|
info "Upgrading ${GREEN}termscp${NO_COLOR}…"
|
||||||
# The OR is used since someone could have installed via cargo previously
|
# The OR is used since someone could have installed via cargo previously
|
||||||
brew update && brew upgrade termscp || brew install veeso/termscp/termscp
|
brew update
|
||||||
|
if ! brew upgrade termscp; then
|
||||||
|
brew install veeso/termscp/termscp
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
info "Installing ${GREEN}termscp${NO_COLOR}…"
|
info "Installing ${GREEN}termscp${NO_COLOR}…"
|
||||||
brew install veeso/termscp/termscp
|
brew install veeso/termscp/termscp
|
||||||
@@ -257,7 +259,7 @@ install_on_debian() {
|
|||||||
$sudo dpkg -i "${archive}"
|
$sudo dpkg -i "${archive}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -f ${archive}
|
rm -f "${archive}"
|
||||||
}
|
}
|
||||||
|
|
||||||
install_on_linux() {
|
install_on_linux() {
|
||||||
@@ -329,18 +331,20 @@ install_linux_cargo_deps() {
|
|||||||
set -e
|
set -e
|
||||||
confirm "${YELLOW}gcc, openssl, pkg-config, libdbus${NO_COLOR} are required to install ${GREEN}termscp${NO_COLOR}. The following command will be used to install the dependencies: '${BOLD}${YELLOW}${deps_cmd}${NO_COLOR}'. Would you like to proceed?"
|
confirm "${YELLOW}gcc, openssl, pkg-config, libdbus${NO_COLOR} are required to install ${GREEN}termscp${NO_COLOR}. The following command will be used to install the dependencies: '${BOLD}${YELLOW}${deps_cmd}${NO_COLOR}'. Would you like to proceed?"
|
||||||
sudo="$(elevate_priv_ex /usr/local/bin)"
|
sudo="$(elevate_priv_ex /usr/local/bin)"
|
||||||
|
# shellcheck disable=SC2086 # deps_cmd is a command with args; word-splitting is intended
|
||||||
$sudo $deps_cmd
|
$sudo $deps_cmd
|
||||||
info "Dependencies installed successfully"
|
info "Dependencies installed successfully"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# shellcheck source=/dev/null
|
||||||
install_cargo() {
|
install_cargo() {
|
||||||
if has cargo; then
|
if has cargo; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
cargo_env="$HOME/.cargo/env"
|
cargo_env="$HOME/.cargo/env"
|
||||||
# Check if cargo is already installed (actually), but not loaded
|
# Check if cargo is already installed (actually), but not loaded
|
||||||
if [ -f $cargo_env ]; then
|
if [ -f "$cargo_env" ]; then
|
||||||
. $cargo_env
|
. "$cargo_env"
|
||||||
fi
|
fi
|
||||||
# Check again cargo
|
# Check again cargo
|
||||||
if has cargo; then
|
if has cargo; then
|
||||||
@@ -351,11 +355,11 @@ install_cargo() {
|
|||||||
rustup=$(get_tmpfile "sh")
|
rustup=$(get_tmpfile "sh")
|
||||||
info "Downloading rustup.sh…"
|
info "Downloading rustup.sh…"
|
||||||
download "${rustup}" "https://sh.rustup.rs"
|
download "${rustup}" "https://sh.rustup.rs"
|
||||||
chmod +x $rustup
|
chmod +x "$rustup"
|
||||||
$rustup -y
|
"$rustup" -y
|
||||||
rm -f ${archive}
|
rm -f "${rustup}"
|
||||||
info "Rust installed with success"
|
info "Rust installed with success"
|
||||||
. $cargo_env
|
. "$cargo_env"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -403,13 +407,8 @@ if [ -z "${ARCH-}" ]; then
|
|||||||
ARCH="$(detect_arch)"
|
ARCH="$(detect_arch)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "${BASE_URL-}" ]; then
|
|
||||||
BASE_URL="https://github.com/starship/starship/releases"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# parse argv variables
|
# parse argv variables
|
||||||
while [ "$#" -gt 0 ]; do
|
while [ "$#" -gt 0 ]; do
|
||||||
echo $1
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
|
|
||||||
-V | --verbose)
|
-V | --verbose)
|
||||||
|
|||||||
Reference in New Issue
Block a user