diff --git a/Makefile b/Makefile index 7e23455..274d805 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,12 @@ build: submodules bin/resh-session-init bin/resh-collect bin/resh-postcollect\ bin/resh-daemon bin/resh-control bin/resh-config bin/resh-cli\ bin/resh-install-utils bin/resh-generate-uuid bin/resh-get-epochtime +# we disable jobserver for the actual installation because we want it to run serially +# Make waits to the daemon process we launch during install and hangs install: build + make -j1 _install + +_install: scripts/install.sh test: @@ -35,7 +40,6 @@ bin/resh-%: $(go_files) .PHONY: submodules build install rebuild uninstall clean test - submodules: | submodules/bash-preexec/bash-preexec.sh submodules/bash-zsh-compat-widgets/bindfunc.sh @# sets submodule.recurse to true if unset @# sets status.submoduleSummary to true if unset diff --git a/scripts/hooks.sh b/scripts/hooks.sh index 6b34dee..3a4f6fe 100644 --- a/scripts/hooks.sh +++ b/scripts/hooks.sh @@ -37,7 +37,6 @@ __resh_collect() { echo "RESH WARNING: You probably just updated RESH - PLEASE RESTART OR RELOAD THIS TERMINAL SESSION (resh revision: $(resh-collect -revision); resh revision of this terminal session: ${__RESH_REVISION})" fi fi - # TODO: change how resh-uuid is read if [ "$__RESH_VERSION" = "$(resh-collect -version)" ] && [ "$__RESH_REVISION" = "$(resh-collect -revision)" ]; then resh-collect -requireVersion "$__RESH_VERSION" \ -requireRevision "$__RESH_REVISION" \ @@ -51,9 +50,9 @@ __resh_collect() { -gitRemote "$__RESH_GIT_REMOTE" \ -time "$__RESH_RT_BEFORE" \ "$@" - return $? - fi - return 1 + return $? + fi + return 1 } __resh_precmd() { diff --git a/scripts/install.sh b/scripts/install.sh index e501078..2ee8b3a 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -109,6 +109,7 @@ cp -f submodules/bash-preexec/bash-preexec.sh ~/.bash-preexec.sh cp -f submodules/bash-zsh-compat-widgets/bindfunc.sh ~/.resh/bindfunc.sh cp -f scripts/shellrc.sh ~/.resh/shellrc +cp -f scripts/resh-daemon-start.sh ~/.resh/bin/resh-daemon-start cp -f scripts/reshctl.sh scripts/widgets.sh scripts/hooks.sh scripts/util.sh ~/.resh/ cp -f scripts/rawinstall.sh ~/.resh/ @@ -126,11 +127,15 @@ if [ ! -f "$pid_file" ]; then pid_file=~/.resh/resh.pid fi +failed_to_kill() { + echo "ERROR: Failed to kill the resh-daemon - maybe it wasn't running?" +} + if [ -f "$pid_file" ]; then - kill -SIGTERM "$pid_file" + kill -SIGKILL "$pid_file" || failed_to_kill rm "$pid_file" else - pkill -SIGTERM "resh-daemon" + pkill -SIGKILL "resh-daemon" || failed_to_kill fi echo "Creating/updating config file ..." @@ -161,13 +166,8 @@ fi # Deleting zsh completion cache - for future use # [ ! -e ~/.zcompdump ] || rm ~/.zcompdump -# Source utils to get __resh_run_daemon function -# shellcheck source=util.sh -. ~/.resh/util.sh - echo "Launching resh daemon ..." -__resh_run_daemon - +~/.resh/bin/resh-daemon-start info="---- Scroll down using arrow keys ---- ##################################### diff --git a/scripts/resh-daemon-start.sh b/scripts/resh-daemon-start.sh new file mode 100755 index 0000000..bbbd7c2 --- /dev/null +++ b/scripts/resh-daemon-start.sh @@ -0,0 +1,2 @@ +#! /usr/bin/env sh +nohup resh-daemon >/dev/null 2>/dev/null & disown \ No newline at end of file diff --git a/scripts/reshctl.sh b/scripts/reshctl.sh index 034c9d4..b8977e4 100644 --- a/scripts/reshctl.sh +++ b/scripts/reshctl.sh @@ -50,14 +50,6 @@ __resh_unbind_control_R() { return 0 } -__resh_bind_all() { - __resh_bind_control_R -} - -__resh_unbind_all() { - __resh_unbind_control_R -} - # wrapper for resh-cli for calling resh directly resh() { local buffer diff --git a/scripts/shellrc.sh b/scripts/shellrc.sh index a72b81f..c99474f 100644 --- a/scripts/shellrc.sh +++ b/scripts/shellrc.sh @@ -1,9 +1,6 @@ #!/hint/sh PATH=$PATH:~/.resh/bin -# if [ -n "$ZSH_VERSION" ]; then -# zmodload zsh/datetime -# fi # shellcheck source=hooks.sh . ~/.resh/hooks.sh @@ -31,7 +28,7 @@ export __RESH_VERSION=$(resh-collect -version) # shellcheck disable=2155 export __RESH_REVISION=$(resh-collect -revision) -__resh_run_daemon +resh-daemon-start [ "$(resh-config --key BindControlR)" = true ] && __resh_bind_control_R diff --git a/scripts/util.sh b/scripts/util.sh index abe354e..a1f89c0 100644 --- a/scripts/util.sh +++ b/scripts/util.sh @@ -2,22 +2,6 @@ # util.sh - resh utility functions -# FIXME: figure out if stdout/stderr should be discarded -__resh_run_daemon() { - if [ -n "${ZSH_VERSION-}" ]; then - setopt LOCAL_OPTIONS NO_NOTIFY NO_MONITOR - fi - if [ "$(uname)" = Darwin ]; then - # hotfix - gnohup resh-daemon >/dev/null 2>/dev/null & disown - else - # TODO: switch to nohup for consistency once you confirm that daemon is - # not getting killed anymore on macOS - nohup resh-daemon >/dev/null 2>/dev/null & disown - #setsid resh-daemon 2>&1 & disown - fi -} - __resh_session_init() { if [ "$__RESH_VERSION" != "$(resh-session-init -version)" ]; then # shellcheck source=shellrc.sh