summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorDenys Vlasenko2017-08-04 15:24:49 +0200
committerDenys Vlasenko2017-08-04 15:24:49 +0200
commitf8cdc7a2bcd0a9d067f5ca7da8ce7bc9c98cf34e (patch)
tree27c49c304513d625e38abcd0df2c55792dcfbc7f /shell
parent7344755823df5510b089cc5db30f8c1cdebdc5a2 (diff)
downloadbusybox-f8cdc7a2bcd0a9d067f5ca7da8ce7bc9c98cf34e.zip
busybox-f8cdc7a2bcd0a9d067f5ca7da8ce7bc9c98cf34e.tar.gz
ash: BASH_XTRACEFD bashism
Based on patch by Johannes Schindelin <johannes.schindelin@gmx.de> function old new delta evalcommand 1447 1500 +53 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell')
-rw-r--r--shell/ash.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 2ad86c1..e80425f 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -188,6 +188,7 @@
#define BASH_PIPEFAIL ENABLE_ASH_BASH_COMPAT
#define BASH_HOSTNAME_VAR ENABLE_ASH_BASH_COMPAT
#define BASH_SHLVL_VAR ENABLE_ASH_BASH_COMPAT
+#define BASH_XTRACEFD ENABLE_ASH_BASH_COMPAT
#if defined(__ANDROID_API__) && __ANDROID_API__ <= 24
/* Bionic at least up to version 24 has no glob() */
@@ -9792,6 +9793,15 @@ evalcommand(union node *cmd, int flags)
expredir(cmd->ncmd.redirect);
redir_stop = pushredir(cmd->ncmd.redirect);
preverrout_fd = 2;
+ if (BASH_XTRACEFD && xflag) {
+ /* NB: bash closes fd == $BASH_XTRACEFD when it is changed.
+ * we do not emulate this. We only use its value.
+ */
+ const char *xtracefd = lookupvar("BASH_XTRACEFD");
+ if (xtracefd && is_number(xtracefd))
+ preverrout_fd = atoi(xtracefd);
+
+ }
status = redirectsafe(cmd->ncmd.redirect, REDIR_PUSH | REDIR_SAVEFD2);
path = vpath.var_text;