LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-27-2014, 03:10 PM   #1
Gullible Jones
Member
 
Registered: Apr 2011
Posts: 142

Rep: Reputation: 10
bash does not read backslashes; other shells are fine


Today bash suddenly stopped accepting the '\' character. It does not appear - not ever - when I type it in a bash prompt, and is not parsed in whatever command I type. It also triggers a system beep if I type it with beeps enabled. This happens in terminals and on VTs, both as limited user and as root.

In other shells, such as zsh, ksh, etc., and in graphical applications, it works fine and is registered as a backslash.

strace of bash when failing to read a backslash looks like this:

Code:
read(0, "\\", 1)                        = 1
write(2, "\7", 1)                       = 1
rt_sigprocmask(SIG_BLOCK, [INT], [], 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, [INT], [], 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
And when successfully reading a forward slash, looks like this:

Code:
read(0, "/", 1)                         = 1
rt_sigprocmask(SIG_BLOCK, [INT], [], 8) = 0
write(2, "/", 1)                        = 1
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8)  = 0
Anyone have any ideas what might be going on here? (FWIW I did not change anything keymap related.)
 
Old 06-27-2014, 03:28 PM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
Is it possible it has been assigned a different meaning with stty?

Type "stty -a" and see if you find anything defined as just the backslash.

For example on my terminal I see:

stty -a
speed 38400 baud; rows 24; columns 80; line = 0;
intr = ^C; quit = ^\; erase = ^H; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 -hupcl -cstopb cread -clocal -crtscts -cdtrdsr
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff
-iuclc -ixany -imaxbel -iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke

Note that "quit" is defined as ^\ with the "^" indicating "ctrl" key. It would be very easy to accidentally set that so it had "quit = \" which is without the ctrl key.
 
Old 06-27-2014, 03:36 PM   #3
Gullible Jones
Member
 
Registered: Apr 2011
Posts: 142

Original Poster
Rep: Reputation: 10
Thanks, but it doesn't look like that's the case (and in any case I have not been messing with stty):

Code:
speed 38400 baud; rows 24; columns 80; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = M-^?; eol2 = M-^?;
swtch = M-^?; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W;
lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 hupcl -cstopb cread -clocal -crtscts
-ignbrk brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff
-iuclc ixany imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke
 
Old 06-27-2014, 03:45 PM   #4
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,286
Blog Entries: 24

Rep: Reputation: 4238Reputation: 4238Reputation: 4238Reputation: 4238Reputation: 4238Reputation: 4238Reputation: 4238Reputation: 4238Reputation: 4238Reputation: 4238Reputation: 4238
WHat had you been changing or working with immediately before (or simply prior to) you first noticed this?

Last edited by astrogeek; 06-27-2014 at 03:46 PM.
 
Old 06-27-2014, 04:14 PM   #5
Gullible Jones
Member
 
Registered: Apr 2011
Posts: 142

Original Poster
Rep: Reputation: 10
I don't recall from yesterday exactly, but it wasn't anything to do with the shell configuration.

I basically booted up this morning and noticed this...
 
Old 06-27-2014, 04:33 PM   #6
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,286
Blog Entries: 24

Rep: Reputation: 4238Reputation: 4238Reputation: 4238Reputation: 4238Reputation: 4238Reputation: 4238Reputation: 4238Reputation: 4238Reputation: 4238Reputation: 4238Reputation: 4238
That is really strange... I guess we should ask what distro and version.

But since it is bash specific, a faster way of narrowing it down mught be to temporarily remove each bash startup or config file in turn, then start a new login shell. That should get you to some kind of starting point pretty quickly.

Some to try:

/etc/{inputrc,bashrc,profile}
~/{.bashrc,.bash_profile}

Not all of these may exist on your system and there may be others, but quick to try.

Also, of there are multiple users on the machine, see if it is the same for all of them. Looking for clues...

Last edited by astrogeek; 06-27-2014 at 04:35 PM.
 
Old 06-30-2014, 07:58 AM   #7
Gullible Jones
Member
 
Registered: Apr 2011
Posts: 142

Original Poster
Rep: Reputation: 10
Got it!

The problem was an extraneous backslash at the beginning of my /etc/inputrc, which must have been added accidentally when viewing the file in an editor. (I hadn't made any other changes to inputrc).

(Lesson: when just viewing a file, use your editor in read-only mode. Also, be really careful when logged in as root. I normally follow both of these, but they bare repeating.)

Thanks everyone!
 
3 members found this post helpful.
Old 06-30-2014, 01:28 PM   #8
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,286
Blog Entries: 24

Rep: Reputation: 4238Reputation: 4238Reputation: 4238Reputation: 4238Reputation: 4238Reputation: 4238Reputation: 4238Reputation: 4238Reputation: 4238Reputation: 4238Reputation: 4238
Glad you found it - thanks for letting us know!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bash - how to keep echo from replacing backslashes stuff? eantoranz Programming 3 06-26-2013 10:08 AM
[SOLVED] Can all shells read all environmental variables set by other shells? carlodelmundo Linux - Newbie 2 07-23-2010 02:03 PM
[SOLVED] How to read $PS1 on non-login shells? sombragris Slackware 5 06-07-2010 12:26 PM
should you know other shells then bash? WOP1337 Linux - General 8 05-06-2007 08:30 PM
Bash and login shells Adrohak Linux - Software 3 11-18-2004 10:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:18 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration