fix(cli): site file loader

I had missed the fact that -Q implies not only
--no-site-file (intended), but --no-site-lisp (unintended). Without the
latter, no site-lisp directory is left in load-path, and any attempt to
load it after-the-fact (which I do in core-cli.el) will fail. Thanks to
@yamanq for noticing this!

Fix: #6473
Fix: #4198
Co-authored-by: Yaman Qalieh <yamanq@users.noreply.github.com>
This commit is contained in:
Henrik Lissner 2022-06-21 22:38:06 +02:00
parent 681d40ab58
commit 3b3c008b1b
No known key found for this signature in database
GPG key ID: B60957CA074D39A3
2 changed files with 9 additions and 7 deletions

View file

@ -1,14 +1,15 @@
#!/usr/bin/env sh
:; set -e # -*- mode: emacs-lisp; lexical-binding: t -*-
:; case "$EMACS" in *term*) EMACS=emacs ;; *) EMACS="${EMACS:-emacs}" ;; esac
:; tmpdir=`$EMACS -Q --batch --eval '(princ (temporary-file-directory))' 2>/dev/null`
:; emacs="$EMACS -q --no-site-file --no-x-resources --no-splash --batch"
:; tmpdir=`$emacs --eval '(princ (temporary-file-directory))' 2>/dev/null`
:; [ -z "$tmpdir" ] && { >&2 echo "Error: failed to run Emacs with command '$EMACS'"; >&2 echo; >&2 echo "Are you sure Emacs is installed and in your \$PATH?"; exit 1; }
:; export __DOOMPID="${__DOOMPID:-$$}"
:; export __DOOMSTEP="$((__DOOMSTEP+1))"
:; export __DOOMGEOM="${__DOOMGEOM:-`tput cols 2>/dev/null`x`tput lines 2>/dev/null`}"
:; export __DOOMGPIPE=${__DOOMGPIPE:-$__DOOMPIPE}
:; export __DOOMPIPE=; [ -t 0 ] || __DOOMPIPE+=0; [ -t 1 ] || __DOOMPIPE+=1
:; $EMACS -Q --batch --load "$0" -- "$@" || exit=$?
:; $emacs --load "$0" -- "$@" || exit=$?
:; [ "${exit:-0}" -eq 254 ] && { sh "${tmpdir}/doom.${__DOOMPID}.${__DOOMSTEP}.sh" "$0" "$@" && true; exit="$?"; }
:; exit $exit

View file

@ -22,7 +22,9 @@ case "$EMACS" in
*) EMACS="${EMACS:-emacs}" ;;
esac
TMPDIR="${TMPDIR:-$($EMACS -Q --batch --eval '(princ (temporary-file-directory))' 2>/dev/null)}"
emacs="$EMACS -q --no-site-file --no-x-resources --no-splash --batch"
TMPDIR="${TMPDIR:-$($emacs --eval '(princ (temporary-file-directory))' 2>/dev/null)}"
if [ -z "$TMPDIR" ]; then
>&2 echo "Error: failed to run Emacs with command '$EMACS'"
>&2 echo
@ -41,10 +43,9 @@ tmpfile="$TMPDIR/doomscript.${__DOOMPID}"
target="$1"
shift
$EMACS -Q --batch \
--load "$EMACSDIR/core/core-cli" \
--load "$target" \
-- "$@" || exit=$?
$emacs --load "$EMACSDIR/core/core-cli" \
--load "$target" \
-- "$@" || exit=$?
# Execute exit-script, if requested (to simulate execve)
if [ "${exit:-0}" -eq 254 ]; then
sh "${tmpdir}/doom.${__DOOMPID}.${__DOOMSTEP}.sh" "$0" "$@" && true