Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 224309 - app-shells/bash-3.2_p39 inconsistent treatment of backslash-bang
Summary: app-shells/bash-3.2_p39 inconsistent treatment of backslash-bang
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High minor (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-05-31 11:13 UTC by Lawrence D'Oliveiro
Modified: 2008-07-28 02:59 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lawrence D'Oliveiro 2008-05-31 11:13:21 UTC
In all contexts in which a character "X" has special meaning to bash, it should be possible to insert that character literally by writing "\X". This fails in one case: where "X" is "!", and the context is inside double quotes.

Reproducible: Always

Steps to Reproduce:
1. echo "hi there!0"
2. echo "hi there\!0"
3. echo hi there\!0
4. echo "hi there$0"
5. echo "hi there\$0"
6. echo hi there\$0

Actual Results:  
1. bash: !0: event not found
2. hi there\!0
3. hi there!0
4. hi there/bin/bash
5. hi there$0
6. hi there$0

Expected Results:  
1. bash: !0: event not found
2. hi there!0
3. hi there!0
4. hi there/bin/bash
5. hi there$0
6. hi there$0

Note the difference in number 2.

The following patch (adding "!" to the "slashify_in_quotes" set) seems to fix the problem:

--- syntax.h-orig       2006-06-23 05:45:22.000000000 +1200
+++ syntax.h    2008-05-31 16:23:36.000000000 +1200
@@ -23,7 +23,7 @@

 /* Defines for use by mksyntax.c */

-#define slashify_in_quotes "\\`$\"\n"
+#define slashify_in_quotes "\\`$\"!\n"
 #define slashify_in_here_document "\\`$"

 #define shell_meta_chars   "()<>;&|"
Comment 1 Joe Peterson (RETIRED) gentoo-dev 2008-07-11 02:49:34 UTC
You might want to send this to bug-bash@gnu.org to see if this is a bug or intended behavior.  Is it a regression, or has bash always done this?
Comment 2 Lawrence D'Oliveiro 2008-07-22 01:10:02 UTC
Reported to bug-bash@gnu.org. Discussion is here:

http://groups.google.co.nz/groups?as_ugroup=gnu.bash.bug&as_usubject=backslash-bang

After a great deal of dodging and ducking, it now seems his position is "broken as designed".
Comment 3 Lawrence D'Oliveiro 2008-07-28 02:59:24 UTC
OK, it appears this behaviour is documented in section 3.1.2.3 of the bash reference

http://www.gnu.org/software/bash/manual/bashref.html