diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2019-05-13 15:20:24 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2019-05-13 15:20:24 +0300 |
commit | 65f41a742e025487f8ec7f2e7ca2a3af3283fc96 (patch) | |
tree | cef728d35f7683f7721659a58fdb2aa1f61387bc /include | |
parent | 07930c5ee74b8d2645fc55465833ab84e2f4444a (diff) | |
download | grecs-65f41a742e025487f8ec7f2e7ca2a3af3283fc96.tar.gz grecs-65f41a742e025487f8ec7f2e7ca2a3af3283fc96.tar.bz2 |
wordsplit: optionally disable splitting of unexpandable variable and command refs
* include/wordsplit.h (WRDSO_NOVARSPLIT)
(WRDSO_NOCMDSPLIT): New options.
* src/wordsplit.c (scan_word): Treat any variable reference, even
containing whitespace, as a single word if WRDSO_NOVARSPLIT is set.
Ditto for commands and WRDSO_NOCMDSPLIT.
* tests/wordsplit.at: Add new tests.
* tests/wsp.c: Recognize novarsplit and nocmdsplit
options.
For future use: recognize bskeep_words, bskeep_quote, bskeep.
Diffstat (limited to 'include')
-rw-r--r-- | include/wordsplit.h | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/include/wordsplit.h b/include/wordsplit.h index 3a7ab25..a175275 100644 --- a/include/wordsplit.h +++ b/include/wordsplit.h | |||
@@ -201,9 +201,7 @@ struct wordsplit | |||
201 | #define WRDSO_FAILGLOB 0x00000002 | 201 | #define WRDSO_FAILGLOB 0x00000002 |
202 | /* Allow a leading period to be matched by metacharacters. */ | 202 | /* Allow a leading period to be matched by metacharacters. */ |
203 | #define WRDSO_DOTGLOB 0x00000004 | 203 | #define WRDSO_DOTGLOB 0x00000004 |
204 | #if 0 /* Unused value */ | 204 | /* Unused value: 0x00000008 */ |
205 | #define WRDSO_ARGV 0x00000008 | ||
206 | #endif | ||
207 | /* Keep backslash in unrecognized escape sequences in words */ | 205 | /* Keep backslash in unrecognized escape sequences in words */ |
208 | #define WRDSO_BSKEEP_WORD 0x00000010 | 206 | #define WRDSO_BSKEEP_WORD 0x00000010 |
209 | /* Handle octal escapes in words */ | 207 | /* Handle octal escapes in words */ |
@@ -220,6 +218,13 @@ struct wordsplit | |||
220 | #define WRDSO_OESC_QUOTE 0x00000200 | 218 | #define WRDSO_OESC_QUOTE 0x00000200 |
221 | /* Handle hex escapes in quoted strings */ | 219 | /* Handle hex escapes in quoted strings */ |
222 | #define WRDSO_XESC_QUOTE 0x00000400 | 220 | #define WRDSO_XESC_QUOTE 0x00000400 |
221 | /* Unused: 0x00000800 */ | ||
222 | /* Don't split variable references, even if they contain whitespace | ||
223 | (e.g. ${VAR:-foo bar}) */ | ||
224 | #define WRDSO_NOVARSPLIT 0x00001000 | ||
225 | /* Don't split commands, even containing whitespace, e.g. | ||
226 | $(echo foo bar) */ | ||
227 | #define WRDSO_NOCMDSPLIT 0x00002000 | ||
223 | 228 | ||
224 | #define WRDSO_BSKEEP WRDSO_BSKEEP_WORD | 229 | #define WRDSO_BSKEEP WRDSO_BSKEEP_WORD |
225 | #define WRDSO_OESC WRDSO_OESC_WORD | 230 | #define WRDSO_OESC WRDSO_OESC_WORD |