Fixed: Stdin not being logged for background execution commands

This commit is contained in:
agnostic-apollo
2021-08-21 03:40:31 +05:00
parent 6409019a40
commit 486faf7fad
4 changed files with 36 additions and 11 deletions

View File

@@ -8,6 +8,7 @@ import android.system.OsConstants;
import androidx.annotation.NonNull;
import com.termux.shared.R;
import com.termux.shared.data.DataUtils;
import com.termux.shared.models.ExecutionCommand;
import com.termux.shared.models.ResultData;
import com.termux.shared.models.errors.Errno;
@@ -80,7 +81,9 @@ public final class TermuxTask {
return null;
}
Logger.logDebug(LOG_TAG, executionCommand.toString());
// No need to log stdin if logging is disabled, like for app internal scripts
int customLogLevel = Logger.isLogLevelValid(executionCommand.backgroundCustomLogLevel) ? executionCommand.backgroundCustomLogLevel: Logger.LOG_LEVEL_VERBOSE;
Logger.logDebug(LOG_TAG, ExecutionCommand.getExecutionInputLogString(executionCommand, true, customLogLevel >= Logger.getLogLevel()));
String taskName = ShellUtils.getExecutableBasename(executionCommand.executable);
@@ -146,7 +149,7 @@ public final class TermuxTask {
STDOUT.start();
STDERR.start();
if (mExecutionCommand.stdin != null && !mExecutionCommand.stdin.isEmpty()) {
if (!DataUtils.isNullOrEmpty(mExecutionCommand.stdin)) {
try {
STDIN.write((mExecutionCommand.stdin + "\n").getBytes(StandardCharsets.UTF_8));
STDIN.flush();