mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-01 12:17:25 -05:00
nit(bin): doomscript: revise comments
This commit is contained in:
@ -24,7 +24,8 @@ case "$EMACS" in
|
|||||||
*term*) EMACS=emacs ;; # in {ansi-,v}term
|
*term*) EMACS=emacs ;; # in {ansi-,v}term
|
||||||
*\ *) ;;
|
*\ *) ;;
|
||||||
*) EMACS="${EMACS:-emacs}"
|
*) EMACS="${EMACS:-emacs}"
|
||||||
# Only sanity-check $EMACS if it's a path or executable
|
# Only sanity-check $EMACS if it's a path or executable, beacuse it might
|
||||||
|
# be a full command.
|
||||||
if ! type "$EMACS" >/dev/null 2>&1; then
|
if ! type "$EMACS" >/dev/null 2>&1; then
|
||||||
echo "Error: failed to run Emacs with command '$EMACS'"
|
echo "Error: failed to run Emacs with command '$EMACS'"
|
||||||
echo
|
echo
|
||||||
@ -34,9 +35,9 @@ case "$EMACS" in
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Careful not to use -Q! It implies --no-site-lisp, which omits the site-lisp
|
# Careful not to use -Q! It implies --no-site-lisp; it omits the site-lisp
|
||||||
# directory from `load-path', which would prevent Doom from manually loading the
|
# directory from `load-path' which prevent Doom from manually loading the site
|
||||||
# site files later. These are important on some systems or deployment methods
|
# files later. Site files are important on some systems or deployment methods
|
||||||
# (like Snap or NixOS).
|
# (like Snap or NixOS).
|
||||||
emacs="$EMACS -q --no-site-file --batch"
|
emacs="$EMACS -q --no-site-file --batch"
|
||||||
|
|
||||||
@ -45,16 +46,16 @@ emacs="$EMACS -q --no-site-file --batch"
|
|||||||
# is unsupported.
|
# is unsupported.
|
||||||
export EMACSDIR="${EMACSDIR:-$(CDPATH='' cd -- "$(dirname -- "${BASH_SOURCE:-$0}")/.." && pwd)}"
|
export EMACSDIR="${EMACSDIR:-$(CDPATH='' cd -- "$(dirname -- "${BASH_SOURCE:-$0}")/.." && pwd)}"
|
||||||
if [ ! -f "$EMACSDIR/early-init.el" ]; then
|
if [ ! -f "$EMACSDIR/early-init.el" ]; then
|
||||||
echo "Error: cannot load $EMACSDIR/early-init.el."
|
echo "Error: failed to load $EMACSDIR/early-init.el."
|
||||||
echo
|
echo
|
||||||
echo "Either the file doesn't exist (indicating a broken or missing Doom install)"
|
echo "Either the file doesn't exist (indicating a broken or missing Doom install)"
|
||||||
echo "or that doomscript is being source directly (which is unsupported)."
|
echo "or that this script is being sourced directly (which is unsupported)."
|
||||||
echo
|
echo
|
||||||
echo "Set \$EMACSDIR to the path of an existing Doom installation."
|
echo "Set \$EMACSDIR to the path of an existing Doom installation."
|
||||||
exit 1
|
exit 1
|
||||||
fi >&2
|
fi >&2
|
||||||
# Some state that Doom's CLI framework needs to know about the terminal. Read
|
# Inform Doom's CLI about the characteristics of the current terminal and how
|
||||||
# the comments at the top of bin/doom for explanations.
|
# bin/doom's been invoked. Read the shebang of bin/doom for explanations.
|
||||||
export __DOOMSH="${__DOOMSH:-sh}"
|
export __DOOMSH="${__DOOMSH:-sh}"
|
||||||
export __DOOMPID="${__DOOMPID:-$$}"
|
export __DOOMPID="${__DOOMPID:-$$}"
|
||||||
export __DOOMSTEP="${__DOOMSTEP:-0}"
|
export __DOOMSTEP="${__DOOMSTEP:-0}"
|
||||||
@ -74,19 +75,19 @@ $emacs --load "$EMACSDIR/early-init" \
|
|||||||
-- "$@"
|
-- "$@"
|
||||||
exit=$?
|
exit=$?
|
||||||
|
|
||||||
# To simulate execve syscalls (which replaces the running process), Doom
|
# bin/doom can request the caller emulate an execve syscall by returning a 254
|
||||||
# generates a temporary exit-script if a Doomscript returns a 254 exit code.
|
# exit code and generating a (temporary) exit script to be executed afterwards.
|
||||||
if [ "${exit:-0}" -eq 254 ]; then
|
if [ "${exit:-0}" -eq 254 ]; then
|
||||||
# $TMPDIR (or $TEMP and $TMP on Windows) aren't guaranteed to have values,
|
# $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
|
# and mktemp isn't available on all systems, but you know what is? Emacs! So
|
||||||
# I rely on it to provide TMPDIR.
|
# I rely on it to provide TMPDIR.
|
||||||
export TMPDIR="${TMPDIR:-${TMP:-${TEMP:-$($emacs -Q --eval '(princ (temporary-file-directory))' 2>/dev/null)}}}"
|
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
|
# /tmp may be mounted with the noexec flag, so the exit-script can't be
|
||||||
# passed to /bin/sh rather than executed directly.
|
# executed directly.
|
||||||
sh "${TMPDIR}/doom.${__DOOMPID}.${__DOOMSTEP}.sh" "$0" "$@"
|
sh "${TMPDIR}/doom.${__DOOMPID}.${__DOOMSTEP}.sh" "$0" "$@"
|
||||||
exit="$?"
|
exit="$?"
|
||||||
fi
|
fi
|
||||||
exit $exit
|
exit $exit
|
||||||
|
|
||||||
# doomscript ends here... Unless?
|
# doomscript ends here... Unless...?
|
||||||
|
Reference in New Issue
Block a user