diff options
author | Ulrich Müller <ulm@gentoo.org> | 2009-09-19 07:46:58 +0000 |
---|---|---|
committer | Ulrich Müller <ulm@gentoo.org> | 2009-09-19 07:46:58 +0000 |
commit | 6cc684e2ac29a131fd2fdcda42cbf49ffd80b284 (patch) | |
tree | 9f0212c21143f67f74c2bd7fa34ff85b1523193d | |
parent | Undo r1405. (diff) | |
download | emacs-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-- | ChangeLog | 5 | ||||
-rw-r--r-- | emacs-wrapper.sh | 11 |
2 files changed, 14 insertions, 2 deletions
@@ -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 |