diff options
author | Chet Ramey <chet.ramey@case.edu> | 2011-12-07 09:07:10 -0500 |
---|---|---|
committer | Chet Ramey <chet.ramey@case.edu> | 2011-12-07 09:07:10 -0500 |
commit | b709b946e4d1e9a039d99afef24cefc5ca1ea614 (patch) | |
tree | f6e2a5540fcd445f2b61a2fc0b2229c3c08085a3 /doc | |
parent | c184f64511d31b4d986a1c545b3cb1461f2b7011 (diff) | |
download | bash-b709b946e4d1e9a039d99afef24cefc5ca1ea614.tar.gz |
commit bash-20070426 snapshot
Diffstat (limited to 'doc')
-rw-r--r-- | doc/FAQ | 32 | ||||
-rw-r--r-- | doc/FAQ~ | 4 |
2 files changed, 34 insertions, 2 deletions
@@ -1,4 +1,4 @@ -This is the Bash FAQ, version 3.35, for Bash version 3.2. +This is the Bash FAQ, version 3.36, for Bash version 3.2. This document contains a set of frequently-asked questions concerning Bash, the GNU Bourne-Again Shell. Bash is a freely-available command @@ -79,6 +79,8 @@ E11) If I resize my xterm while another program is running, why doesn't bash notice the change? E12) Why don't negative offsets in substring expansion work like I expect? E13) Why does filename completion misbehave if a colon appears in the filename? +E14) Why does quoting the pattern argument to the regular expression matching + conditional operator (=~) cause matching to stop working? Section F: Things to watch out for on certain Unix versions @@ -1427,6 +1429,34 @@ COMP_WORDBREAKS=${COMP_WORDBREAKS//:} You can also quote the colon with a backslash to achieve the same result temporarily. +E14) Why does quoting the pattern argument to the regular expression matching + conditional operator (=~) cause regexp matching to stop working? + +In versions of bash prior to bash-3.2, the effect of quoting the regular +expression argument to the [[ command's =~ operator was not specified. +The practical effect was that double-quoting the pattern argument required +backslashes to quote special pattern characters, which interfered with the +backslash processing performed by double-quoted word expansion and was +inconsistent with how the == shell pattern matching operator treated +quoted characters. + +In bash-3.2, the shell was changed to internally quote characters in single- +and double-quoted string arguments to the =~ operator, which suppresses the +special meaning of the characters special to regular expression processing +(`.', `[', `\', `(', `), `*', `+', `?', `{', `|', `^', and `$') and forces +them to be matched literally. This is consistent with how the `==' pattern +matching operator treats quoted portions of its pattern argument. + +Since the treatment of quoted string arguments was changed, several issues +have arisen, chief among them the problem of white space in pattern arguments +and the differing treatment of quoted strings between bash-3.1 and bash-3.2. +Both problems may be solved by using a shell variable to hold the pattern. +Since word splitting is not performed when expanding shell variables in all +operands of the [[ command, this allows users to quote patterns as they wish +when assigning the variable, then expand the values to a single string that +may contain whitespace. The first problem may be solved by using backslashes +or any other quoting mechanism to escape the white space in the patterns. + Section F: Things to watch out for on certain Unix versions F1) Why can't I use command line editing in my `cmdtool'? @@ -908,7 +908,9 @@ D1) Why does bash run a different version of `command' than On many systems, `which' is actually a csh script that assumes you're running csh. In tcsh, `which' and its cousin `where' are builtins. On other Unix systems, `which' is a perl script -that uses the PATH environment variable. +that uses the PATH environment variable. Many Linux distributions +use GNU `which', which is a C program that can understand shell +aliases. The csh script version reads the csh startup files from your home directory and uses those to determine which `command' will |