perf(cli): doomscript: reduce init time
In4989661
, I reduced the init time for bin/doom by eliminating the extra `emacs` call in its shebang. This does the same for bin/doomscript. Ref:498966179f
This commit is contained in:
parent
f27a85ed35
commit
5880348a6c
1 changed files with 15 additions and 12 deletions
|
@ -22,7 +22,16 @@ fi
|
|||
|
||||
case "$EMACS" in
|
||||
*term*) EMACS=emacs ;; # in {ansi-,v}term
|
||||
*) EMACS="${EMACS:-emacs}" ;;
|
||||
*\ *) ;;
|
||||
*) EMACS="${EMACS:-emacs}"
|
||||
# Only sanity-check $EMACS if it's a path or executable
|
||||
if ! type "$EMACS" >/dev/null 2>&1; then
|
||||
echo "Error: failed to run Emacs with command '$EMACS'"
|
||||
echo
|
||||
echo "Are you sure Emacs is installed and in your \$PATH?"
|
||||
exit 1
|
||||
fi >&2
|
||||
;;
|
||||
esac
|
||||
|
||||
# Careful not to use -Q! It implies --no-site-lisp, which omits the site-lisp
|
||||
|
@ -31,17 +40,6 @@ esac
|
|||
# (like Snap or NixOS).
|
||||
emacs="$EMACS -q --no-site-file --batch"
|
||||
|
||||
# $TMPDIR (or $TEMP and $TMP on Windows) aren't guaranteed to have values, and
|
||||
# mktemp isn't available on all systems, but you know what is? Emacs! So I rely
|
||||
# on it to provide TMPDIR. And can second as a quick existence check for Emacs.
|
||||
TMPDIR="${TMPDIR:-$($emacs --eval '(princ (temporary-file-directory))' 2>/dev/null)}"
|
||||
if [ -z "$TMPDIR" ]; then
|
||||
echo "Error: failed to run Emacs with command '$EMACS'"
|
||||
echo
|
||||
echo "Are you sure Emacs is installed and in your \$PATH?"
|
||||
exit 1
|
||||
fi >&2
|
||||
|
||||
# Doom respects $EMACSDIR to tell it where Doom lives. If it fails, then this is
|
||||
# either isn't bash, or it's a posix shell being directly sourced with sh, which
|
||||
# is unsupported.
|
||||
|
@ -79,6 +77,11 @@ exit=$?
|
|||
# To simulate execve syscalls (which replaces the running process), Doom
|
||||
# generates a temporary exit-script if a Doomscript returns a 254 exit code.
|
||||
if [ "${exit:-0}" -eq 254 ]; then
|
||||
# $TMPDIR (or $TEMP and $TMP on Windows) aren't guaranteed to have values,
|
||||
# and mktemp isn't available on all systems, but you know what is? Emacs! So
|
||||
# I rely on it to provide TMPDIR.
|
||||
export TMPDIR="${TMPDIR:-${TMP:-${TEMP:-$($emacs -Q --eval '(princ (temporary-file-directory))' 2>/dev/null)}}}"
|
||||
|
||||
# The user may have a noexec flag set on /tmp, so the exit-script should be
|
||||
# passed to /bin/sh rather than executed directly.
|
||||
sh "${TMPDIR}/doom.${__DOOMPID}.${__DOOMSTEP}.sh" "$0" "$@"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue