我使用的是 Ubuntu Linux 系统,我输入的每个命令都会显示在下一行,后面跟着命令的输出。例如:
root@dpkube165:~# ls
ls <--- why is this here?
Desktop Documents Downloads
root@dpkube165:~# date
date <--- or this?
Mon Mar 19 11:24:59 EDT 2018
root@dpkube165:~# echo "Hello, world!"
echo "Hello, world!" <--- or this?
Hello, world!
我认为这可能与提示有关,提示如下(PS1):
\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$
但查看在线指南以提示转义序列并没有发现任何明显的结果。
答案1
看起来您已经-v
设置了(某些东西正在运行set -v
)。
要撤销此操作,请运行set +v
。
set [--abefhkmnptuvxBCEHPT] [-o option-name] [arg ...] set [+abefhkmnptuvxBCEHPT] [+o option-name] [arg ...] Without options, the name and value of each shell variable are displayed in a format that can be reused as input for setting or resetting the currently-set variables. Read-only variables cannot be reset. In posix mode, only shell variables are listed. The output is sorted according to the current locale. When options are specified, they set or unset shell attributes. Any arguments remaining after option processing are treated as values for the positional parameters and are assigned, in order, to $1, $2, ... $n. Options, if specified, have the following meanings: [...] -v Print shell input lines as they are read.
查看bash
手册页(在下面 ”Shell 内置命令set
”部分)以获取有关内置命令的更多信息。
或者help set
从内部运行bash
以更直接地访问帮助文本。
答案2
至少在 Bash 4.3 中,此命令具有与以下命令类似的效果set -v
:
trap 'echo "$BASH_COMMAND"' DEBUG
要检查这是否影响到你,请运行
trap -p DEBUG
要取消设置,请运行
trap - DEBUG