💥 fix(install): check variable emptiness instead of boolean checks
This commit is contained in:
+7
-6
@@ -1,6 +1,5 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
|
||||||
trap "printf \"\nOk, quitting beacuse you entered an exit signal. (SIGINT).\n\"; exit 1" SIGINT
|
trap "printf \"\nOk, quitting beacuse you entered an exit signal. (SIGINT).\n\"; exit 1" SIGINT
|
||||||
trap "printf \"\nOh noo!! Some application just killed the script! (SIGTERM)\"; exit 2" SIGTERM
|
trap "printf \"\nOh noo!! Some application just killed the script! (SIGTERM)\"; exit 2" SIGTERM
|
||||||
|
|
||||||
@@ -9,7 +8,7 @@ XDG_DATA_HOME=`[[ -z "$XDG_DATA_HOME" ]] && echo -n "$HOME/.local/share" || echo
|
|||||||
XDG_CACHE_HOME=`[[ -z "$XDG_CACHE_HOME" ]] && echo -n $HOME/.cache || echo -n $XDG_CACHE_HOME`
|
XDG_CACHE_HOME=`[[ -z "$XDG_CACHE_HOME" ]] && echo -n $HOME/.cache || echo -n $XDG_CACHE_HOME`
|
||||||
XDG_CONFIG_HOME=`[[ -z "$XDG_CONFIG_HOME" ]] && echo -n "$HOME/.config" || echo -n "$XDG_CONFIG_HOME"`
|
XDG_CONFIG_HOME=`[[ -z "$XDG_CONFIG_HOME" ]] && echo -n "$HOME/.config" || echo -n "$XDG_CONFIG_HOME"`
|
||||||
|
|
||||||
skip_prompts=`[[ "$@" =~ -y ]] && echo -n true`
|
skip_prompts=`[[ ! -z "$@" ]] && [[ "$@" =~ -y ]] && echo -n true`
|
||||||
is_standalone=`(git remote -v > /dev/null 2>&1) || echo -n true`
|
is_standalone=`(git remote -v > /dev/null 2>&1) || echo -n true`
|
||||||
|
|
||||||
temp_dir="$XDG_CACHE_HOME/colorshell-installer"
|
temp_dir="$XDG_CACHE_HOME/colorshell-installer"
|
||||||
@@ -18,7 +17,7 @@ repo_directory=`[[ "$is_standalone" ]] && echo -n "$temp_dir/repo" || echo -n ".
|
|||||||
|
|
||||||
# source utils script before installation
|
# source utils script before installation
|
||||||
if [[ "$is_standalone" ]]; then
|
if [[ "$is_standalone" ]]; then
|
||||||
mkdir -p $temp_dir
|
mkdir -p "$repo_directory"
|
||||||
# testing only, change to commented value before merging (hope I don't forget lol)
|
# testing only, change to commented value before merging (hope I don't forget lol)
|
||||||
default_branch="gtk4-ags3" # `curl -s https://api.github.com/repos/retrozinndev/colorshell | jq -r .default_branch`
|
default_branch="gtk4-ags3" # `curl -s https://api.github.com/repos/retrozinndev/colorshell | jq -r .default_branch`
|
||||||
# get utils script
|
# get utils script
|
||||||
@@ -36,6 +35,7 @@ fi
|
|||||||
# makes bash force-load the script into memory to avoid issues when
|
# makes bash force-load the script into memory to avoid issues when
|
||||||
# switching source to a tag
|
# switching source to a tag
|
||||||
|
|
||||||
|
{
|
||||||
Print_header
|
Print_header
|
||||||
echo -e "Colorshell is a project made by retrozinndev.
|
echo -e "Colorshell is a project made by retrozinndev.
|
||||||
Source: https://github.com/retrozinndev/colorshell\n"
|
Source: https://github.com/retrozinndev/colorshell\n"
|
||||||
@@ -61,13 +61,13 @@ fi
|
|||||||
if [[ "$answer" == "y" ]] || [[ "$skip_prompts" ]]; then
|
if [[ "$answer" == "y" ]] || [[ "$skip_prompts" ]]; then
|
||||||
Ask "Nice! Do you want to use the stable version instead of the unstable(latest commit)?"
|
Ask "Nice! Do you want to use the stable version instead of the unstable(latest commit)?"
|
||||||
|
|
||||||
if [[ ! "$skip_prompts" ]] && [[ "$answer" == "y" ]]; then
|
if [[ -z "$skip_prompts" ]] && [[ "$answer" == "y" ]]; then
|
||||||
Send_log "fetching latest release from colorshell repository"
|
Send_log "fetching latest release from colorshell repository"
|
||||||
latest_tag=`curl -s "$repo_api_url/releases" | jq -r '. | select(.[].prerelease == false) | .[0].tag_name'`
|
latest_tag=`curl -s "$repo_api_url/releases" | jq -r '. | select(.[].prerelease == false) | .[0].tag_name'`
|
||||||
|
|
||||||
Send_log "Done fetching"
|
Send_log "Done fetching"
|
||||||
Send_log "Checking out latest non-pre-release version: $latest_tag"
|
Send_log "Checking out latest non-pre-release version: $latest_tag"
|
||||||
git -C $repo_directory checkout $latest_tag 1> /dev/null
|
git -C "$repo_directory" checkout $latest_tag > /dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
Send_log "Starting installation..."
|
Send_log "Starting installation..."
|
||||||
@@ -96,7 +96,7 @@ if [[ "$answer" == "y" ]] || [[ "$skip_prompts" ]]; then
|
|||||||
Send_log "Cleaning"
|
Send_log "Cleaning"
|
||||||
pnpm clean
|
pnpm clean
|
||||||
|
|
||||||
if [[ ! "$skip_prompts" ]]; then
|
if [[ -z "$skip_prompts" ]]; then
|
||||||
echo "Colorshell is installed! :D"
|
echo "Colorshell is installed! :D"
|
||||||
sleep .8
|
sleep .8
|
||||||
echo "If you have issues, please report it!"
|
echo "If you have issues, please report it!"
|
||||||
@@ -114,3 +114,4 @@ fi
|
|||||||
|
|
||||||
printf "Ok, doing as you said! Bye bye!\n"
|
printf "Ok, doing as you said! Bye bye!\n"
|
||||||
exit 0
|
exit 0
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user