summaryrefslogtreecommitdiffabout
path: root/src
authorSergey Poznyakoff <gray@gnu.org>2019-05-13 12:20:24 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2019-05-13 12:20:24 (GMT)
commit65f41a742e025487f8ec7f2e7ca2a3af3283fc96 (patch) (side-by-side diff)
treecef728d35f7683f7721659a58fdb2aa1f61387bc /src
parent07930c5ee74b8d2645fc55465833ab84e2f4444a (diff)
downloadgrecs-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 'src') (more/less context) (ignore whitespace changes)
-rw-r--r--src/wordsplit.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/wordsplit.c b/src/wordsplit.c
index e979f27..521a1eb 100644
--- a/src/wordsplit.c
+++ b/src/wordsplit.c
@@ -2058,11 +2058,13 @@ scan_word (struct wordsplit *wsp, size_t start, int consume_all)
if (command[i] == '$')
{
- if (!(wsp->ws_flags & WRDSF_NOVAR)
+ if ((!(wsp->ws_flags & WRDSF_NOVAR)
+ || (wsp->ws_options & WRDSO_NOVARSPLIT))
&& command[i+1] == '{'
&& find_closing_paren (command, i + 2, len, &i, "{}") == 0)
continue;
- if (!(wsp->ws_flags & WRDSF_NOCMD)
+ if ((!(wsp->ws_flags & WRDSF_NOCMD)
+ || (wsp->ws_options & WRDSO_NOCMDSPLIT))
&& command[i+1] == '('
&& find_closing_paren (command, i + 2, len, &i, "()") == 0)
continue;

Return to:

Send suggestions and report system problems to the System administrator.