每次我打开 shell,终端上的第一行都是“bash: n: 未找到命令”。我尝试查看 /etc/profile、~/.bashrc、~/.profile 和 ~/.bash_profile,但找不到那个“n”(我猜是某个地方打错了?)来自哪里。因此,我运行命令bash -x -l
并生成以下输出:
++ [[ -n 5.2.26(1)-release ]]
+++ declare -p PROMPT_COMMAND
++ [[ bash: declare: PROMPT_COMMAND: not found =~ declare -a ]]
++ PROMPT_COMMAND=__vte_prompt_command
+++ printf '\033]777;preexec\033\'
++ PS0=''
++ return 0
+ for i in /etc/profile.d/*.sh /etc/profile.d/sh.local
+ '[' -r /etc/profile.d/which2.sh ']'
+ '[' mxBH '!=' himxBH ']'
+ . /etc/profile.d/which2.sh
++ case "$(basename $(readlink /proc/$$/exe))" in
++++ readlink /proc/148743/exe
+++ basename /usr/bin/bash
++ alias 'which=(alias; declare -f) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot'
+ for i in /etc/profile.d/*.sh /etc/profile.d/sh.local
+ '[' -r /etc/profile.d/sh.local ']'
+ '[' mxBH '!=' himxBH ']'
+ . /etc/profile.d/sh.local
+ unset i
+ unset -f pathmunge
+ test /usr/bin/bash
+ n test -z ''
+ local runcnf=1
+ local retval=127
+ [[ himxBH == *\i* ]]
+ [[ ! -S /run/dbus/system_bus_socket ]]
+ [[ ! -x /usr/libexec/packagekitd ]]
+ [[ -n '' ]]
+ [[ ! -x /usr/libexec/pk-command-not-found ]]
+ '[' 1 -eq 1 ']'
+ /usr/libexec/pk-command-not-found n test -z ''
bash: n: command not found...
+ retval=127
+ return 127
+ PT8HOME=/opt/pt
+ export PT8HOME
+ '[' -f /home/alessandro/.bashrc ']'
+ . /home/alessandro/.bashrc
++ '[' -f /etc/bashrc ']'
++ . /etc/bashrc
+++ '[' -z '' ']'
+++ BASHRCSOURCED=Y
+++ '[' '\s-\v\$ ' ']'
+++ '[' -z __vte_prompt_command ']'
+++ shopt -s histappend
+++ shopt -s checkwinsize
+++ '[' '\s-\v\$ ' = '\s-\v\$ ' ']'
+++ PS1='[\u@\h \W]\$ '
+++ shopt -q login_shell
++ PS1='[\[\033[1;35m\]\u\[\033[0m\]@\h \W]\$ '
++ [[ /home/alessandro/.local/bin:/home/alessandro/bin:/usr/lib64/ccache:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/var/lib/snapd/snap/bin =~ /home/alessandro/\.local/bin:/home/alessandro/bin: ]]
++ '[' -d /home/alessandro/.bashrc.d ']'
++ unset rc
++ alias 'll=ls -lhtr'
++ alias 'ccomp=clang -std=c11 -Wall -Wextra'
++ alias '..=cd ..'
++ __vte_prompt_command
+++ HISTTIMEFORMAT=
+++ history 1
+++ sed 's/^ *[0-9]\+ *//'
++ local 'command=bash -x -l >> logs.txt'
++ command='bash -x -l >> logs.txt'
++ local 'pwd=~'
++ '[' /home/alessandro '!=' /home/alessandro ']'
++ pwd='~'
++ printf '\033]777;notify;Command completed;%s\033\\\033]777;precmd\033\\\033]0;%s@%s:%s\033\\' 'bash -x -l >> logs.txt' alessandro fedora '~'
++ __vte_osc7
+++ /usr/libexec/vte-urlencode-cwd
++ printf '\033]7;file://%s%s\033\' fedora /home/alessandro
这实际上只是输出的最后一部分,但您可以看到中间部分有错误“bash:n:未找到命令...”。问题是我无法读取该输出。我只知道加号表示脚本执行的深度。 那么,您能通过阅读输出了解错误来自何处吗?