Every time I open the shell, the first line on the terminal is "bash: n: command not found". I tried to look at /etc/profile, ~/.bashrc, ~/.profile and ~/.bash_profile but I was not able to find where that "n" (I guess is a typo somewhere?) was coming from.
So, then I run the command bash -x -l
and the following output was generated:
++ [[ -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
This is actually just the final part of the output, but you can see how at around the middle of it there is the error "bash: n: command not found...". The problem is that I'm not able to read that output. I just know that the plus sign indicates the deepness in the script execution. So, are you able to understand where the error is coming from by reading the output?
/etc/profile.d/sh.local
+ . /etc/profile.d/sh.local
shows the shell is told to start reading commands from that file (the oddly named.
command does that). However, I'm not sure it succeeds, or at least finds any commands there, since I think any commands found there should appear at a deeper nesting level (one more+
, compare withwhich2.sh
earlier there). There aren't any such commands, so the file likely doesn't exist or is empty. Anyway, the linen test -z ''
seems to be what causes the error.PS4='+ $BASH_SOURCE: $LINENO: ' bash -x -l
, it should make it print the current filename and line on each line of the execution trace./etc/profile.d/sh.local
is a commented line. AboutPS4='+ $BASH_SOURCE: $LINENO: ' bash -x -l
, this is the output: ` + /etc/profile: 71: test /usr/bin/bash + /etc/profile: 71: n test -z '' <other-stuff> + /etc/profile.d/PackageKit.sh: 30: /usr/libexec/pk-command-not-found n test -z '' bash: n: command not found... ` But content of line 71 of /etc/profile isif test "$BASH" &&\n test -z "$POSIXLY_CORRECT" &&\n test "${0#-}" != sh &&\n test -r /etc/bashrc
and I do not see the problem with new line characters