Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sometimes when I simply type a valid command like 'find ...', or anything really, I get back the following, which is completely unexpected and confusing (... is command name I type):

sh: $'\302\211...': command not found

There is some corruption going on I think. I don't use color in my prompt, I am using the Bash shell in POSIX mode as sh (chsh to /bin/sh and so on - $SHELL is sh).

What is going on and why does this keep happening? Anything I can debug? I think this is more of an xterm issue than sh, or at least a combination of the two.

Files, for context:

My /etc/profile, as distributed with Arch Linux x86-64:

# /etc/profile

#Set our umask
umask 022

# Set our default path
PATH="/usr/local/sbin:/usr/local/bin:/usr/bin"
export PATH

# Load profiles from /etc/profile.d
if test -d /etc/profile.d/; then
        for profile in /etc/profile.d/*.sh; do
                test -r "$profile" && . "$profile"
        done
        unset profile
fi

# Source global bash config
if test "$PS1" && test "$BASH" && test -r /etc/bash.bashrc; then
        . /etc/bash.bashrc
fi

# Termcap is outdated, old, and crusty, kill it.
unset TERMCAP

# Man is much better than us at figuring this out
unset MANPATH

My /etc/shrc, which I created as a way to have sh parse some file on startup, when non-login shell. This is achieved using ENV variable set in /etc/environment with the line ENV=/etc/shrc:

PS1='\u@\H \w \$ '
alias ls='ls -F --color'
alias grep='grep -i --color'
[ -f ~/.shrc ] && . ~/.shrc

My ~/.profile, I am launching X when logging in through first virtual tty:

[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && exec xinit -- -dpi 111

My ~/.xinitc, as you can see I am using the system as a Virtual Box guest:

xrdb -merge ~/.Xresources

VBoxClient-all

awesome &

exec xterm

And finally, my ~/.Xresources, no fancy stuff here I guess:

*faceName: Inconsolata
*faceSize: 10
xterm*VT100*translations: #override <Btn1Up>: select-end(PRIMARY, CLIPBOARD, CUT_BUFFER0)

xterm*colorBDMode: true
xterm*colorBD: #ff8000
xterm*cursorColor: S_red

Since ~/.profile references among other things /etc/bash.bashrc, here is its content:

#
# /etc/bash.bashrc
#

# If not running interactively, don't do anything
[[ $- != *i* ]] && return

PS1='[\u@\h \W]\$ '
PS2='> '
PS3='> '
PS4='+ '

case ${TERM} in
  xterm*|rxvt*|Eterm|aterm|kterm|gnome*)
    PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'

    ;;
  screen)
    PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033_%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'
    ;;
esac

[ -r /usr/share/bash-completion/bash_completion   ] && . /usr/share/bash-completion/bash_completion

I have no idea what that case statement does, by the way, it does look a bit suspicious though, but then again, who am I to know.

share|improve this question
1  
What is the output of ls -l /bin/sh? Also, please post your ~/.bashrc, the problem is probably there. What OS is this? Answers are often OS-dependent. Are you connecting to a remote machine via ssh or is this local? If remote, please post your ~/.profile and/or ~/.bash_profile if present. –  terdon Nov 7 '13 at 14:26
    
I have updated the question with all kinds of file content, I hope it suffices. Output of ls -l /bin/sh is lrwxrwxrwx 1 root root 4 Aug 25 12:06 /bin/sh -> bash*. I don't have a ~/.bashrc as I am running the Bash shell in so-called POSIX mode. No ~/.bash_profile either. –  amn Nov 8 '13 at 8:29

1 Answer 1

That's the ‰ character also used as "CHARACTER TABULATION WITH JUSTIFICATION".

I guess you are using a specific keyboard or editor that uses this unusual character instead of the regular tab, which is normally ignored in shell command lines, or having a locale mismatch between the shell and the terminal emulator.

share|improve this answer
    
Sorry, I don't think I am following - am I using % somewhere? How? I am only using vim and locale reports all as en_US.UTF-8 except LC_ALL which is not set. Anything I can do to test your assumptions? –  amn Nov 8 '13 at 10:11
    
@amn: I am almost sure it is not but the Unicode character "CHARACTER TABULATION WITH JUSTIFICATION". The code which bash shows is UTF-8 representation (C2 89) of the character (U+0089). I would check if you accidentally do not press some key (TAB?) or key combination before the problem occurs. If you have a suspicion, try the key combination here: od -ctx1. After typing the key sequence, press Enter and Ctrl+D. –  pabouk Nov 8 '13 at 10:56
    
Indeed, it is not the common % but a control character that also have a graphic representation which is (per thousand vs percent). Is this happening during interactive shell sessions ? Are you using tab to autocomplete commands ? Is your keyboard providing a key ? –  jlliagre Nov 8 '13 at 11:12
    
No whatever it is, and the error I described happens seemingly at random. I am not using tab when that happens. No on the keybord, either. od -ctx1 tells me sh: $'\302\211\302\211\302\211od': command not found - I think we're getting somewhere! –  amn Nov 8 '13 at 11:59
    
Is the issue still present when using a different terminal emulator ? When connecting remotely from another machine ? –  jlliagre Nov 8 '13 at 15:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.