Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I recently migrated all my dotfiles and setting to a new laptop running Ubuntu 13.04, and have been noticing a strange behavior that I've never seen before. Essentially, it seems like my terminal is sometimes trying to parse commands from right to left rather than the normal way. Its not consistant at all, and often typing the same command twice will produce different output.

Example:

 ⋯  www  localwork  cd ~/Downloads
bash: /home/goldenapples/Downloads: Is a directory

 ~  cd ~/Downloads
 ~  Downloads  ls

So, the first command seems to have been parsed as cd ~; Downloads, but the second time I typed the same exact command, it worked fine.

The same thing happens with aliases. Here I have gp aliased to git push:

 ~  Documents  infostats-theme   master  gp
usage: git [--version] [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p|--paginate|--no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           [-c name=value] [--help]
           <command> [<args>]

    [...]

See 'git help <command>' for more information on a specific command.
The program 'push' is currently not installed. You can install it by typing:
sudo apt-get install heimdal-clients

 ~  Documents  infostats-theme   master  gp
Counting objects: 22, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (14/14), done.
Writing objects: 100% (14/14), 1.69 KiB, done.
Total 14 (delta 12), reused 0 (delta 0)
To git@github.com:janrain/statboard.git
   cf86529..3208e21  HEAD -> master:wq

No idea what happened there. My bash aliases were processed in the first example, and it correctly read the line as git push, but I don't knwo what happened after that. Looks like it tried to parse the command as git; push; and so it showed the git help screen, and then displayed an error that no program named push was installed. The werid thing is: typing the same exact command immediately afterwards worked fine.

This is one of those problems I've just been putting up with because it makes no sense. The only thing I can seem to pinpoint is that the problem behavior seems to happen when I'm typing especially fast, and slowing down and retyping the command sometimes makes it work.

I'm mostly using Bash inside of tmux 1.8, if that lends any help.

Update:

Adding this line to my .tmux.conf:

set-option -g default-command "exec /bin/bash --norc"

seems to have fixed the problem... or at least I haven't been able to cause it again since. But I still have no idea why or how, and I'd love an explanation.

share|improve this question
1  
Does it happen in bash --norc? Does it happen if you move ~/.inputrc outi of the way? Does it happen outside tmux? –  Gilles Aug 20 '13 at 23:05
    
I haven't been able to reproduce it outside of tmux... its a very intermittent problem, so I'm not sure that it is tmux-related, but that's a definite possibility. –  goldenapples Aug 21 '13 at 16:30
1  
If skipping your .bashrc fixes the issue, then it's something there causing it. So post your .bashrc. Given that the bug comes up inside an alias, I think this has to be a bug in bash. Hmmm… does the bug survive a reboot? Have you run a memory test recently (pick memtest at the Grub prompt and let stew overnight)? –  Gilles Aug 21 '13 at 16:45
add comment

2 Answers 2

It looks like something is parsing spaces as returns.

Can you remove tmux from the situation (try working in a console or virtual terminal)?

Also, check the setting of IFS, thus:

$ echo ":$IFS:" | cat -vte
: ^I$
:$

(so, SPace, TAB, Return).

Are any other of the problem commands aliased or implemented as functions of the same name as a command?

Try '\cd ...' or 'command cd' to work around.

Also, for diagnosis, try using the TAB key for intra-command white space instead of SPace, and/or the Line Feed (Ctrl-J) instead of Return (Ctrl-M).

share|improve this answer
add comment

To debug such issues you can try to turn on printing of command and input lines the bash is processing during the parsing of an input:

set -v -x

To turn it off again you can use set +v +x. Sometimes quite weird things are happening in the background.

share|improve this answer
add comment

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.