diff --git a/scripts/install.sh b/scripts/install.sh index 1d208cc..e79d465 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -128,6 +128,15 @@ fi # Final touch touch ~/.resh_history.json +# Generating resh-uuid ... +[ -e ~/.resh/resh-uuid ] \ + || cat /proc/sys/kernel/random/uuid > ~/.resh/resh-uuid 2>/dev/null \ + || scripts/uuid.sh > ~/.resh/resh-uuid 2>/dev/null + +# Source utils to get __resh_run_daemon function +# shellcheck source=util.sh +. ~/.resh/util.sh + # Restarting resh daemon ... if [ -f ~/.resh/resh.pid ]; then kill -SIGTERM "$(cat ~/.resh/resh.pid)" || true @@ -135,12 +144,9 @@ if [ -f ~/.resh/resh.pid ]; then else pkill -SIGTERM "resh-daemon" || true fi -nohup resh-daemon >/dev/null 2>&1 & disown +__resh_run_daemon + -# Generating resh-uuid ... -[ -e ~/.resh/resh-uuid ] \ - || cat /proc/sys/kernel/random/uuid > ~/.resh/resh-uuid 2>/dev/null \ - || scripts/uuid.sh > ~/.resh/resh-uuid 2>/dev/null echo " ########################################################## diff --git a/scripts/util.sh b/scripts/util.sh index 832f1cc..3c1a747 100644 --- a/scripts/util.sh +++ b/scripts/util.sh @@ -4,10 +4,10 @@ __resh_get_uuid() { } __resh_get_pid() { - if [ -n "$ZSH_VERSION" ]; then + if [ -n "${ZSH_VERSION-}" ]; then # assume Zsh local __RESH_PID="$$" # current pid - elif [ -n "$BASH_VERSION" ]; then + elif [ -n "${BASH_VERSION-}" ]; then # assume Bash local __RESH_PID="$BASHPID" # current pid fi @@ -21,7 +21,7 @@ __resh_get_epochrealtime() { elif gdate --version >/dev/null && gdate +%s.%N | grep -vq 'N'; then # GNU date take 2 gdate +%s.%N - elif [ -n "$ZSH_VERSION" ]; then + elif [ -n "${ZSH_VERSION-}" ]; then # zsh fallback using $EPOCHREALTIME if [ -z "${__RESH_ZSH_LOADED_DATETIME+x}" ]; then zmodload zsh/datetime @@ -40,10 +40,10 @@ __resh_get_epochrealtime() { } __resh_run_daemon() { - if [ -n "$ZSH_VERSION" ]; then + if [ -n "${ZSH_VERSION-}" ]; then setopt LOCAL_OPTIONS NO_NOTIFY NO_MONITOR fi - if [ "$__RESH_MACOS" = 1 ]; then + if [ "$(uname)" = Darwin ]; then # needs testing nohup script -q -c 'resh-daemon' ~/.resh/daemon_last_run_out.txt & else