Skip to content

Commit

Permalink
use xdg cache paths - should fix permission errors
Browse files Browse the repository at this point in the history
  • Loading branch information
curusarn committed Dec 21, 2020
1 parent c5961b1 commit 61ce618
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 5 deletions.
6 changes: 4 additions & 2 deletions scripts/hooks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ __resh_preexec() {
# core
__RESH_COLLECT=1
__RESH_CMDLINE="$1" # not local to preserve it for postcollect (useful as sanity check)
local tmp_file="$__RESH_XDG_CACHE_HOME/collect_last_run_out.txt"
__resh_collect --cmdLine "$__RESH_CMDLINE" \
--recall-actions "$__RESH_HIST_RECALL_ACTIONS" \
--recall-strategy "$__RESH_HIST_RECALL_STRATEGY" \
--recall-last-cmdline "$__RESH_HIST_PREV_LINE" \
>| /tmp/resh_collect_last_run_out.txt 2>&1 || echo "resh-collect ERROR: $(head -n 1 /tmp/resh_collect_last_run_out.txt)"
>| $tmp_file 2>&1 || echo "resh-collect ERROR: $(head -n 1 $tmp_file)"
}

# used for collect and collect --recall
Expand Down Expand Up @@ -153,6 +154,7 @@ __resh_precmd() {
fi
fi
if [ "$__RESH_VERSION" = "$(resh-postcollect -version)" ] && [ "$__RESH_REVISION" = "$(resh-postcollect -revision)" ]; then
local tmp_file="$__RESH_XDG_CACHE_HOME/postcollect_last_run_out.txt"
resh-postcollect -requireVersion "$__RESH_VERSION" \
-requireRevision "$__RESH_REVISION" \
-cmdLine "$__RESH_CMDLINE" \
Expand All @@ -169,7 +171,7 @@ __resh_precmd() {
-gitRemoteExitCodeAfter "$__RESH_GIT_REMOTE_EXIT_CODE_AFTER" \
-realtimeAfter "$__RESH_RT_AFTER" \
-timezoneAfter "$__RESH_TZ_AFTER" \
>| /tmp/resh_postcollect_last_run_out.txt 2>&1 || echo "resh-postcollect ERROR: $(head -n 1 /tmp/resh_postcollect_last_run_out.txt)"
>| $tmp_file 2>&1 || echo "resh-postcollect ERROR: $(head -n 1 $tmp_file)"
fi
__resh_reset_variables
fi
Expand Down
7 changes: 4 additions & 3 deletions scripts/reshctl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,10 @@ resh() {
elif [ $status_code = 130 ]; then
true
else
echo "$buffer" >| ~/.resh/cli_last_run_out.txt
local tmp_file="$__RESH_XDG_CACHE_HOME/search_last_run_out.txt"
echo "$buffer" >| "$tmp_file"
echo "resh-cli ERROR:"
cat ~/.resh/cli_last_run_out.txt
cat "$tmp_file"
fi
}

Expand Down Expand Up @@ -216,4 +217,4 @@ reshctl() {
return "$_status"
;;
esac
}
}
2 changes: 2 additions & 0 deletions scripts/shellrc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ export __RESH_VERSION=$(resh-collect -version)
# shellcheck disable=2155
export __RESH_REVISION=$(resh-collect -revision)

__resh_set_xdg_home_paths

__resh_run_daemon

# block for anything we only want to do once per session
Expand Down
26 changes: 26 additions & 0 deletions scripts/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,29 @@ __resh_session_init() {
>| ~/.resh/session_init_last_run_out.txt 2>&1 || echo "resh-session-init ERROR: $(head -n 1 ~/.resh/session_init_last_run_out.txt)"
fi
}

__resh_set_xdg_home_paths() {
if [ -z "${XDG_CONFIG_HOME-}" ]; then
__RESH_XDG_CONFIG_FILE="$HOME/.config"
else
__RESH_XDG_CONFIG_FILE="$XDG_CONFIG_HOME"
fi
mkdir -p "$__RESH_XDG_CONFIG_FILE" >/dev/null 2>/dev/null
__RESH_XDG_CONFIG_FILE="$__RESH_XDG_CONFIG_FILE/resh.toml"


if [ -z "${XDG_CACHE_HOME-}" ]; then
__RESH_XDG_CACHE_HOME="$HOME/.cache/resh"
else
__RESH_XDG_CACHE_HOME="$XDG_CACHE_HOME/resh"
fi
mkdir -p "$__RESH_XDG_CACHE_HOME" >/dev/null 2>/dev/null


if [ -z "${XDG_DATA_HOME-}" ]; then
__RESH_XDG_DATA_HOME="$HOME/.local/share/resh"
else
__RESH_XDG_DATA_HOME="$XDG_DATA_HOME/resh"
fi
mkdir -p "$__RESH_XDG_DATA_HOME" >/dev/null 2>/dev/null
}

0 comments on commit 61ce618

Please sign in to comment.