diff --git a/yazi.sh b/yazi.sh index 32aee74..e837bb0 100644 --- a/yazi.sh +++ b/yazi.sh @@ -1,19 +1,35 @@ { #!/usr/bin/env bash - PACKAGE=yazi - # ─< Check if the given command exists silently >───────────────────────────────────────── command_exists() { command -v "$@" >/dev/null 2>&1 } - if command_exists $PACKAGE; then - echo_error "$PACKAGE is already installed!" - echo_error "Exiting now!" - return 69 + # ─< package variable >─────────────────────────────────────────────────────────────────── + unset PACKAGE + + # ─< argument list variables >──────────────────────────────────────────────────────────── + unset silent + + sleep 0.1 + + PACKAGE=yazi + if command_exists "$PACKAGE"; then + echo_warning "$PACKAGE is already installed!" + echo_warning "Exiting now!" + exit 69 fi + # ─< parse arguments and get variable contents >────────────────────────────────────────── + for arg in "$@"; do + case "$arg" in + --silent | -s) + silent=true + ;; + esac + done + # WHY: # This import will give you the following variables: # _sudo="sudo -E" <- only if non root user @@ -98,6 +114,10 @@ } main() { + if $silent; then + echo_warning "Executing script silently!" + fi + if $arch; then _install yazi elif ! $opensuse; then @@ -108,13 +128,6 @@ } if getImports; then - case "$@" in - --silent | -s) - silent=true - echo_warning "Executing script silently.." - ;; - *) silent=false ;; - esac main fi }