branch: externals/detached
commit 10220f8663c57f0868914c6b47f9fa2c765d7b93
Author: Niklas Eklund <[email protected]>
Commit: Niklas Eklund <[email protected]>
Move detached-env mode into detached.el
We can control the mode inside detached.el instead of starting to
build up logic in detached-env.
---
detached-env | 22 +++++++---------------
detached.el | 7 ++++---
2 files changed, 11 insertions(+), 18 deletions(-)
diff --git a/detached-env b/detached-env
index 0db3e69615..b35712662d 100755
--- a/detached-env
+++ b/detached-env
@@ -3,8 +3,8 @@
# detached-env is a script which purpose is to run a detached command, and
# issue to stdout, based on the exit code.
-mode="$1"
-shift
+# mode="$1"
+# shift
detached_command="$*"
# detached-env features two different modes:
@@ -14,17 +14,9 @@ detached_command="$*"
# environmental variable is set to eterm-color in order to enabled
# colored outputs from the detached_command
-if [ "$mode" = "plain-text" ]; then
- if eval "$detached_command"; then
- echo -e "\nDetached session finished"
- else
- echo -e "\nDetached session exited abnormally with code $?"
- fi
-elif [ "$mode" = "terminal-data" ]; then
- TERM="eterm-color"
- if eval script --quiet --flush --return --command "\"$detached_command\""
/dev/null; then
- echo -e "\nDetached session finished"
- else
- echo -e "\nDetached session exited abnormally with code $?"
- fi
+TERM="eterm-color"
+if eval "$detached_command"; then
+ echo -e "\nDetached session finished"
+else
+ echo -e "\nDetached session exited abnormally with code $?"
fi
diff --git a/detached.el b/detached.el
index f712898e1a..5f108bf197 100644
--- a/detached.el
+++ b/detached.el
@@ -1173,9 +1173,10 @@ If SESSION is nonattachable fallback to a command that
doesn't rely on tee."
(format "&> %s" log)))
(env (if detached-env detached-env (format "%s -c"
detached-shell-program)))
(command
- (if detached-env
- (concat (format "%s " (detached--session-env-mode session))
- (shell-quote-argument (detached--session-command
session)))
+ (if (eq 'terminal-data (detached--session-env-mode session))
+ (shell-quote-argument
+ (format "script --quiet --flush --return --command \"%s\"
/dev/null"
+ (detached--session-command session)))
(shell-quote-argument (detached--session-command session)))))
(format "%s %s %s; %s %s" begin-shell-group env command end-shell-group
redirect)))