aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Müller <ulm@gentoo.org>2009-09-19 07:46:58 +0000
committerUlrich Müller <ulm@gentoo.org>2009-09-19 07:46:58 +0000
commit6cc684e2ac29a131fd2fdcda42cbf49ffd80b284 (patch)
tree9f0212c21143f67f74c2bd7fa34ff85b1523193d
parentUndo r1405. (diff)
downloademacs-tools-6cc684e2ac29a131fd2fdcda42cbf49ffd80b284.tar.gz
emacs-tools-6cc684e2ac29a131fd2fdcda42cbf49ffd80b284.tar.bz2
emacs-tools-6cc684e2ac29a131fd2fdcda42cbf49ffd80b284.zip
Save output in a temporary file and display in case of error.
svn path=/emacs-daemon/; revision=1417
-rw-r--r--ChangeLog5
-rw-r--r--emacs-wrapper.sh11
2 files changed, 14 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index a598af4..3aeef3a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-09-19 Ulrich Mueller <ulm@gentoo.org>
+
+ * emacs-wrapper.sh: Save Emacs's output in a temporary file.
+ Display it only in case of error.
+
2009-07-17 Ulrich Mueller <ulm@gentoo.org>
* Version 0.15 released.
diff --git a/emacs-wrapper.sh b/emacs-wrapper.sh
index b3bb597..a3983ba 100644
--- a/emacs-wrapper.sh
+++ b/emacs-wrapper.sh
@@ -3,8 +3,12 @@
# Distributed under the terms of the GNU General Public License v2
# $Id$
+# Save output in a temporary file and display in case of error
+logfile=$(mktemp ${TMPDIR:-/tmp}/emacs.log.XXXXXX)
+trap "rm -f '${logfile}'" EXIT
+
# Start Emacs with a login shell wrapper to read the user's profile
-exec -l "${SHELL}" -c "exec \"${EMACS}\" $*" </dev/null &>/dev/null &
+exec -l "${SHELL}" -c "exec \"${EMACS}\" $*" </dev/null &>"${logfile}" &
pid=$!
# Wait for Emacs daemon to detach
@@ -12,10 +16,13 @@ for (( t=${EMACS_TIMEOUT:-30}; t > 0; t-- )); do
sleep 1
if ! kill -0 ${pid} 2>/dev/null; then
wait ${pid} # get exit status
- exit
+ status=$?
+ [[ ${status} -ne 0 ]] && cat "${logfile}"
+ exit ${status}
fi
done
+cat "${logfile}"
echo "${0##*/}: timeout waiting for ${EMACS} to detach" >&2
kill ${pid} $(pgrep -P ${pid}) 2>/dev/null
exit 1