commit:     4f18041b98df9ba1f5f5394e47845f9598e5ccc2
Author:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Sat Jun 28 18:18:06 2025 +0000
Commit:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Sat Jun 28 18:18:06 2025 +0000
URL:        https://gitweb.gentoo.org/proj/emacs-tools.git/commit/?id=4f18041b

Posixify the init script

* emacs.rc (start_pre): POSIX shell does not support "local".
(start): Ditto. Drop the intermediate variable because s-s-d
itself can expand the tilde.

Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>

 ChangeLog |  6 ++++++
 emacs.rc  | 10 +++-------
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2af5f69..d4c4455 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2025-06-28  Ulrich Müller  <[email protected]>
+
+       * emacs.rc (start_pre): POSIX shell does not support "local".
+       (start): Ditto. Drop the intermediate variable because s-s-d
+       itself can expand the tilde.
+
 2025-03-14  Ulrich Müller  <[email protected]>
 
        * Version 0.25 released.

diff --git a/emacs.rc b/emacs.rc
index 3f8611f..16c8524 100644
--- a/emacs.rc
+++ b/emacs.rc
@@ -34,9 +34,8 @@ start_pre() {
     # and would therefore hang, waiting for user interaction.
     # Redirecting stdin and unsetting TERM and DISPLAY will cause most
     # of them to exit with an error.
-    local has_daemon=$(unset TERM DISPLAY; ${EMACS} -batch -q --no-site-file \
-        --eval "(princ (fboundp 'daemonp))" </dev/null)
-    if [ "${has_daemon}" != t ]; then
+    if [ "$(unset TERM DISPLAY; ${EMACS} -batch -q --no-site-file \
+            --eval "(princ (fboundp 'daemonp))" </dev/null)" != t ]; then
         eerror "${EMACS} does not support running as a daemon"
         return 1
     fi
@@ -46,9 +45,6 @@ start_pre() {
 }
 
 start() {
-    local home
-    eval home="~${USER}"
-
     SHELL=${EMACS_SHELL:-$(awk -F: "\$1 == \"${USER}\" { print \$7 }" \
         /etc/passwd)}
     export SHELL EMACS
@@ -59,7 +55,7 @@ start() {
 
     ebegin "Starting Emacs daemon for user ${USER}"
     start-stop-daemon --start --background --make-pidfile \
-        --user "${USER}" --pidfile "${PIDFILE}" --chdir "${home}" \
+        --user "${USER}" --pidfile "${PIDFILE}" --chdir "~${USER}" \
         --exec "${EMACS_START}" -- ${EMACS_OPTS}
     eend $?
 }

Reply via email to