mirror of
git://git.gnu.org.ua/wordsplit.git
synced 2025-04-26 00:29:54 +03:00
Minor fixes
* doc/wordsplit.3: Fix some wording. * tests/wordsplit.at (TESTWSP): Generate unique keywords.
This commit is contained in:
parent
b712b11eef
commit
3fca27c20b
2 changed files with 232 additions and 203 deletions
|
@ -14,7 +14,7 @@
|
|||
.\" You should have received a copy of the GNU General Public License
|
||||
.\" along with Grecs. If not, see <http://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.TH WORDSPLIT 3 "October 30, 2014" "GRECS" "Grecs User Reference"
|
||||
.TH WORDSPLIT 3 "October 31, 2014" "GRECS" "Grecs User Reference"
|
||||
.SH NAME
|
||||
wordsplit \- split string into words
|
||||
.SH SYNOPSIS
|
||||
|
@ -47,8 +47,8 @@ using a set of rules governed by \fIflags\fR. Depending on
|
|||
tilde expansion, variable expansion, quote removal, command
|
||||
substitution, and path expansion. On success, the function returns 0
|
||||
and stores the words found in the member \fBws_wordv\fR and the number
|
||||
of words in the member \fBws_wordc\fR. On error, -1 is returned and
|
||||
error code is stored in \fBws_errno\fR.
|
||||
of words in the member \fBws_wordc\fR. On error, a non-zero error
|
||||
code is returned.
|
||||
.PP
|
||||
The function \fBwordsplit_len\fR acts similarly, except that it
|
||||
accesses only first \fBlen\fR bytes of the string \fIs\fR, which is
|
||||
|
@ -940,7 +940,7 @@ static int runcmd(char **ret, const char *str, size_t len,
|
|||
|
||||
extern char **environ;
|
||||
|
||||
/* Parse \fIs\fR much as shell does. Return the array of words on
|
||||
/* Parse \fIs\fR much as shell does. Return array of words on
|
||||
succes, and NULL on error.
|
||||
*/
|
||||
char **shell_parse(char *s)
|
||||
|
@ -953,7 +953,7 @@ char **shell_parse(char *s)
|
|||
/* Initialize \fIws\fR */
|
||||
ws.ws_env = (const char **) environ;
|
||||
ws.ws_command = runcmd;
|
||||
/* Call \fBwordsplit\fR. Let it report the errors. */
|
||||
/* Call \fBwordsplit\fR. Let it report errors, if any. */
|
||||
rc = wordsplit(s, &ws,
|
||||
WRDSF_QUOTE | WRDSF_SQUEEZE_DELIMS | WRDSF_PATHEXPAND
|
||||
| WRDSF_SHOWERR);
|
||||
|
|
|
@ -16,13 +16,30 @@
|
|||
|
||||
AT_BANNER(Wordsplit)
|
||||
|
||||
m4_pushdef([wspnum],[0])
|
||||
m4_pushdef([wspid])
|
||||
m4_pushdef([wspgroupnum])
|
||||
m4_pushdef([wspgroupname])
|
||||
|
||||
m4_pushdef([genkw],[dnl
|
||||
m4_define([wspid],m4_format([wordsplit%03d wsp%03d],wspnum))dnl
|
||||
m4_if(wspgroupname,,,[m4_define([wspid],wspid[ ]dnl
|
||||
m4_format(wspgroupname[ ]wspgroupname[%03d],wspgroupnum))dnl
|
||||
m4_define([wspgroupnum],m4_incr(wspgroupnum))])dnl
|
||||
m4_define([wspnum],m4_incr(wspnum))dnl
|
||||
wspid])
|
||||
|
||||
m4_pushdef([WSPGROUP],[
|
||||
m4_define([wspgroupname],$1)
|
||||
m4_define([wspgroupnum],0)])
|
||||
|
||||
dnl ------------------------------------------------------------
|
||||
dnl TESTWSP([NAME], [KW = `'], [OPTS], [INPUT], [STDOUT = `'],
|
||||
dnl [STDERR = `'], [ENV])
|
||||
dnl
|
||||
m4_pushdef([TESTWSP],[
|
||||
AT_SETUP([$1])
|
||||
AT_KEYWORDS([wordsplit wsp $2])
|
||||
AT_KEYWORDS([wordsplit wsp ]genkw[ $2])
|
||||
AT_CHECK([$7 wsp $3 <<'EOT'
|
||||
[$4]
|
||||
EOT
|
||||
|
@ -37,7 +54,7 @@ dnl ------------------------------------------------------------
|
|||
dnl The first part reproduces legacy argcv tests
|
||||
dnl ------------------------------------------------------------
|
||||
|
||||
TESTWSP([simple input],[wsp-simple wsp00],[],
|
||||
TESTWSP([simple input],[wsp-simple],[],
|
||||
[1 2 3],
|
||||
[NF: 3
|
||||
0: 1
|
||||
|
@ -45,26 +62,27 @@ TESTWSP([simple input],[wsp-simple wsp00],[],
|
|||
2: 3
|
||||
])
|
||||
|
||||
TESTWSP([quoted space],[wsp-quoted wsp01],[],
|
||||
TESTWSP([quoted space],[wsp-quoted],[],
|
||||
[quoted\ space],
|
||||
[NF: 1
|
||||
0: "quoted space"
|
||||
])
|
||||
|
||||
TESTWSP([tab character],[wsp-tab wsp02],[],
|
||||
TESTWSP([tab character],[wsp-tab],[],
|
||||
[a "tab character"],
|
||||
[NF: 2
|
||||
0: a
|
||||
1: tab\tcharacter
|
||||
])
|
||||
|
||||
TESTWSP([octal and hex escapes],[wsp-escape wsp-escape0 wsp03],[],
|
||||
WSPGROUP(wsp-escape)
|
||||
TESTWSP([octal and hex escapes],[],[],
|
||||
[\157\143\164\141\154\40and\x20\x68\x65\x78],
|
||||
[NF: 1
|
||||
0: "octal and hex"
|
||||
])
|
||||
|
||||
TESTWSP([octal and hex escapes 2],[wsp-escape wsp-escape1 wsp04],[],
|
||||
TESTWSP([octal and hex escapes 2],[],[],
|
||||
[\157\143\164\141\154\40 and \x20\x68\x65\x78],
|
||||
[NF: 3
|
||||
0: "octal "
|
||||
|
@ -72,16 +90,18 @@ TESTWSP([octal and hex escapes 2],[wsp-escape wsp-escape1 wsp04],[],
|
|||
2: " hex"
|
||||
])
|
||||
|
||||
TESTWSP([escape representation],[wsp-escape wsp-escape2 wsp05],[],
|
||||
TESTWSP([escape representation],[],[],
|
||||
[A\x3-\48\39],
|
||||
[NF: 1
|
||||
0: A\003-\0048\0039
|
||||
])
|
||||
|
||||
WSPGROUP()
|
||||
|
||||
dnl ------------------------------------------------------------
|
||||
dnl Test worsplit-specific behavior
|
||||
dnl ------------------------------------------------------------
|
||||
TESTWSP([append],[wsp-append wsp06],[append],
|
||||
TESTWSP([append],[wsp-append],[append],
|
||||
[jeden dwa trzy
|
||||
cztery
|
||||
piec szesc],
|
||||
|
@ -103,7 +123,7 @@ NF: 6
|
|||
5: szesc
|
||||
])
|
||||
|
||||
TESTWSP([dooffs],[wsp-doofs wsp07],[dooffs 3 jeden dwa trzy],
|
||||
TESTWSP([dooffs],[wsp-doofs ],[dooffs 3 jeden dwa trzy],
|
||||
[cztery piec],
|
||||
[NF: 2 (3)
|
||||
(0): jeden
|
||||
|
@ -113,7 +133,9 @@ TESTWSP([dooffs],[wsp-doofs wsp07],[dooffs 3 jeden dwa trzy],
|
|||
4: piec
|
||||
])
|
||||
|
||||
TESTWSP([variable substitutions: single var],[wsp-var wsp-var00 wsp08],[],
|
||||
WSPGROUP(wsp-var)
|
||||
|
||||
TESTWSP([variable substitutions: single var],[],[],
|
||||
[a $FOO test],
|
||||
[NF: 3
|
||||
0: a
|
||||
|
@ -123,7 +145,7 @@ TESTWSP([variable substitutions: single var],[wsp-var wsp-var00 wsp08],[],
|
|||
[],
|
||||
[FOO=bar])
|
||||
|
||||
TESTWSP([variable substitutions: concatenated vars],[wsp-var wsp-var01 wsp09],
|
||||
TESTWSP([variable substitutions: concatenated vars],[],
|
||||
[],
|
||||
[a $FOO${BAR}ent test],
|
||||
[NF: 3
|
||||
|
@ -134,7 +156,7 @@ TESTWSP([variable substitutions: concatenated vars],[wsp-var wsp-var01 wsp09],
|
|||
[],
|
||||
[FOO=str BAR=ing])
|
||||
|
||||
TESTWSP([variable substitutions: field splitting],[wsp-var wsp-var02 wsp10],[],
|
||||
TESTWSP([variable substitutions: field splitting],[],[],
|
||||
[a $FOO test],
|
||||
[NF: 4
|
||||
0: a
|
||||
|
@ -145,8 +167,7 @@ TESTWSP([variable substitutions: field splitting],[wsp-var wsp-var02 wsp10],[],
|
|||
[],
|
||||
[FOO="variable substitution"])
|
||||
|
||||
TESTWSP([variable substitutions: double-quoted variable],
|
||||
[wsp-var wsp-var03 wsp11],[],
|
||||
TESTWSP([variable substitutions: double-quoted variable],[],[],
|
||||
[a "$FOO" test],
|
||||
[NF: 3
|
||||
0: a
|
||||
|
@ -156,8 +177,7 @@ TESTWSP([variable substitutions: double-quoted variable],
|
|||
[],
|
||||
[FOO="variable substitution"])
|
||||
|
||||
TESTWSP([variable substitutions: single-quoted variable],
|
||||
[wsp-var wsp-var04 wsp12],[],
|
||||
TESTWSP([variable substitutions: single-quoted variable],[],[],
|
||||
[a '$FOO' test],
|
||||
[NF: 3
|
||||
0: a
|
||||
|
@ -167,7 +187,7 @@ TESTWSP([variable substitutions: single-quoted variable],
|
|||
[],
|
||||
[FOO="variable substitution"])
|
||||
|
||||
TESTWSP([undefined variables 1],[wsp-var wsp-var05 wsp13],[],
|
||||
TESTWSP([undefined variables 1],[],[],
|
||||
[a $FOO test a${FOO}b],
|
||||
[NF: 3
|
||||
0: a
|
||||
|
@ -177,7 +197,7 @@ TESTWSP([undefined variables 1],[wsp-var wsp-var05 wsp13],[],
|
|||
[],
|
||||
[unset FOO;])
|
||||
|
||||
TESTWSP([undefined variables 2],[wsp-var wsp-var06 wsp14],[keepundef],
|
||||
TESTWSP([undefined variables 2],[],[keepundef],
|
||||
[a $FOO test a${FOO}b],
|
||||
[NF: 4
|
||||
0: a
|
||||
|
@ -188,7 +208,7 @@ TESTWSP([undefined variables 2],[wsp-var wsp-var06 wsp14],[keepundef],
|
|||
[],
|
||||
[unset FOO;])
|
||||
|
||||
TESTWSP([warn about undefined variables],[wsp-var wsp-var07 wsp15],[warnundef],
|
||||
TESTWSP([warn about undefined variables],[],[warnundef],
|
||||
[$FOO],
|
||||
[NF: 0
|
||||
],
|
||||
|
@ -196,14 +216,14 @@ TESTWSP([warn about undefined variables],[wsp-var wsp-var07 wsp15],[warnundef],
|
|||
],
|
||||
[unset FOO;])
|
||||
|
||||
TESTWSP([bail out on undefined variables],[wsp-var wsp-var08 wsp16],[undef],
|
||||
TESTWSP([bail out on undefined variables],[],[undef],
|
||||
[$FOO],
|
||||
[],
|
||||
[undefined variable
|
||||
],
|
||||
[unset FOO;])
|
||||
|
||||
TESTWSP([disable variable expansion],[wsp-var wsp-var09 wsp17],[novar],
|
||||
TESTWSP([disable variable expansion],[],[novar],
|
||||
[$FOO],
|
||||
[NF: 1
|
||||
0: $FOO
|
||||
|
@ -211,7 +231,7 @@ TESTWSP([disable variable expansion],[wsp-var wsp-var09 wsp17],[novar],
|
|||
[],
|
||||
[FOO=bar])
|
||||
|
||||
TESTWSP([K/V environment],[wsp-var wsp-var10 wsp18 wsp-env-kv wsp-env_kv],
|
||||
TESTWSP([K/V environment],[wsp-env-kv wsp-env_kv],
|
||||
[env_kv],
|
||||
[$FOO a$BAZ],
|
||||
[NF: 2
|
||||
|
@ -221,8 +241,7 @@ TESTWSP([K/V environment],[wsp-var wsp-var10 wsp18 wsp-env-kv wsp-env_kv],
|
|||
[],
|
||||
[FOO=bar BAZ=qux])
|
||||
|
||||
TESTWSP([nosplit with expansion],
|
||||
[wsp-var wsp-var11 wsp19 wsp-var-nosplit],[nosplit],
|
||||
TESTWSP([nosplit with expansion],[wsp-var-nosplit],[nosplit],
|
||||
[a $FOO test],
|
||||
[NF: 1
|
||||
0: "a variable expansion test\n"
|
||||
|
@ -230,7 +249,7 @@ TESTWSP([nosplit with expansion],
|
|||
[],
|
||||
[FOO="variable expansion"])
|
||||
|
||||
TESTWSP([nosplit without expansion],[wsp-var wsp-var12 wsp20],[nosplit novar],
|
||||
TESTWSP([nosplit without expansion],[],[nosplit novar],
|
||||
[a $FOO test],
|
||||
[NF: 1
|
||||
0: "a $FOO test\n"
|
||||
|
@ -238,14 +257,156 @@ TESTWSP([nosplit without expansion],[wsp-var wsp-var12 wsp20],[nosplit novar],
|
|||
[],
|
||||
[FOO="variable expansion"])
|
||||
|
||||
TESTWSP([ignore quotes],[wsp-ignore-quotes wsp21],[-quote],
|
||||
TESTWSP([default value (defined)],[],[],
|
||||
[${FOO:-bar}],
|
||||
[NF: 1
|
||||
0: qux
|
||||
],
|
||||
[],
|
||||
[FOO=qux])
|
||||
|
||||
TESTWSP([default value],[],[],
|
||||
[${FOO:-bar}],
|
||||
[NF: 1
|
||||
0: bar
|
||||
])
|
||||
|
||||
TESTWSP([default value (defined)],[],[],
|
||||
[${FOO:-bar}],
|
||||
[NF: 1
|
||||
0: qux
|
||||
],
|
||||
[],
|
||||
[FOO=qux])
|
||||
|
||||
TESTWSP([default value (:- null)],[],[],
|
||||
[${FOO:-bar}],
|
||||
[NF: 1
|
||||
0: bar
|
||||
],
|
||||
[],
|
||||
[FOO=])
|
||||
|
||||
TESTWSP([default value (- null)],[],[],
|
||||
[${FOO-bar}],
|
||||
[NF: 0
|
||||
],
|
||||
[],
|
||||
[FOO=])
|
||||
|
||||
TESTWSP([default value (- null, unset)],[],[],
|
||||
[${FOO-bar}],
|
||||
[NF: 1
|
||||
0: bar
|
||||
])
|
||||
|
||||
TESTWSP([assign default values],[],[],
|
||||
[${FOO=bar}
|
||||
$FOO],
|
||||
[NF: 1
|
||||
0: bar
|
||||
NF: 1
|
||||
0: bar
|
||||
])
|
||||
|
||||
TESTWSP([default error message (var defined)],[],[],
|
||||
[a ${FOO:?} test],
|
||||
[NF: 3
|
||||
0: a
|
||||
1: bar
|
||||
2: test
|
||||
],
|
||||
[],
|
||||
[FOO=bar])
|
||||
|
||||
TESTWSP([default error message],[],[],
|
||||
[${FOO:?}],
|
||||
[NF: 0
|
||||
],
|
||||
[FOO: variable null or not set
|
||||
])
|
||||
|
||||
TESTWSP([custom error message (defined)],[wsp-custom-err wsp-custom-err00],[],
|
||||
[a ${FOO:?please define it} test],
|
||||
[NF: 3
|
||||
0: a
|
||||
1: bar
|
||||
2: test
|
||||
],
|
||||
[],
|
||||
[FOO=bar])
|
||||
|
||||
TESTWSP([custom error message],[wsp-custom-err wsp-custom-err01],[],
|
||||
[a ${FOO:?please define it} test],
|
||||
[NF: 2
|
||||
0: a
|
||||
1: test
|
||||
],
|
||||
[FOO: please define it
|
||||
])
|
||||
|
||||
TESTWSP([alternate value (defined)],[wsp-alt wsp-alt00],[],
|
||||
[a ${FOO:+isset} test],
|
||||
[NF: 3
|
||||
0: a
|
||||
1: isset
|
||||
2: test
|
||||
],
|
||||
[],
|
||||
[FOO=bar])
|
||||
|
||||
TESTWSP([alternate value],[wsp-alt wsp-alt01],[],
|
||||
[a ${FOO:+isset} test],
|
||||
[NF: 2
|
||||
0: a
|
||||
1: test
|
||||
],
|
||||
[],
|
||||
[unset FOO;])
|
||||
|
||||
TESTWSP([getvar],[wsp-getvar],
|
||||
[foo=bar x=quux],
|
||||
[begin $foo $x end],
|
||||
[NF: 4
|
||||
0: begin
|
||||
1: bar
|
||||
2: quux
|
||||
3: end
|
||||
])
|
||||
|
||||
TESTWSP([getvar and env],[wsp-getvar],
|
||||
[foo=bar x=quux],
|
||||
[begin $foo $TVAR $x end],
|
||||
[NF: 5
|
||||
0: begin
|
||||
1: bar
|
||||
2: 12
|
||||
3: quux
|
||||
4: end
|
||||
],
|
||||
[],
|
||||
[TVAR=12])
|
||||
|
||||
TESTWSP([getvar, alternate value],[wsp-getvar],
|
||||
[foo=bar],
|
||||
[a ${foo:+isset}],
|
||||
[NF: 2
|
||||
0: a
|
||||
1: isset
|
||||
])
|
||||
|
||||
WSPGROUP()
|
||||
|
||||
TESTWSP([ignore quotes],[wsp-ignore-quotes ],[-quote],
|
||||
["a text"],
|
||||
[NF: 2
|
||||
0: "\"a"
|
||||
1: "text\""
|
||||
])
|
||||
|
||||
TESTWSP([custom delimiters (squeeze)],[wsp-delim wsp-delim00 wsp22],
|
||||
WSPGROUP(wsp-delim)
|
||||
|
||||
TESTWSP([custom delimiters (squeeze)],[],
|
||||
[delim : -ws trimnl],
|
||||
[semicolon: separated::list: of :words],
|
||||
[NF: 5
|
||||
|
@ -256,7 +417,7 @@ TESTWSP([custom delimiters (squeeze)],[wsp-delim wsp-delim00 wsp22],
|
|||
4: words
|
||||
])
|
||||
|
||||
TESTWSP([custom delimiters (no squeeze)],[wsp-delim wsp-delim01 wsp23],
|
||||
TESTWSP([custom delimiters (no squeeze)],[],
|
||||
[delim : -ws -squeeze_delims trimnl],
|
||||
[semicolon: separated::list: of :words],
|
||||
[NF: 6
|
||||
|
@ -268,7 +429,7 @@ TESTWSP([custom delimiters (no squeeze)],[wsp-delim wsp-delim01 wsp23],
|
|||
5: words
|
||||
])
|
||||
|
||||
TESTWSP([custom, with returned delimiters],[wsp-delim wsp-delim02 wsp24],
|
||||
TESTWSP([custom, with returned delimiters],[],
|
||||
[delim : -ws trimnl return_delims],
|
||||
[semicolon: separated::list: of :words],
|
||||
[NF: 9
|
||||
|
@ -283,8 +444,7 @@ TESTWSP([custom, with returned delimiters],[wsp-delim wsp-delim02 wsp24],
|
|||
8: words
|
||||
])
|
||||
|
||||
TESTWSP([custom, with returned & squeezed delimiters],
|
||||
[wsp-delim wsp-delim03 wsp25],
|
||||
TESTWSP([custom, with returned & squeezed delimiters],[],
|
||||
[delim : -ws trimnl return_delims -squeeze_delims],
|
||||
[semicolon: separated::list: of :words],
|
||||
[NF: 10
|
||||
|
@ -300,7 +460,9 @@ TESTWSP([custom, with returned & squeezed delimiters],
|
|||
9: words
|
||||
])
|
||||
|
||||
TESTWSP([sed expressions],[wsp-sed wsp-sed00 wsp26],[sed],
|
||||
WSPGROUP(wsp-sed)
|
||||
|
||||
TESTWSP([sed expressions],[],[sed],
|
||||
[arg1 s/foo/bar/g;s/bar baz/quz quux/ arg2],
|
||||
[NF: 3
|
||||
0: arg1
|
||||
|
@ -308,7 +470,9 @@ TESTWSP([sed expressions],[wsp-sed wsp-sed00 wsp26],[sed],
|
|||
2: arg2
|
||||
])
|
||||
|
||||
TESTWSP([C escapes on],[wcp-c-escape wsp27],[cescapes],
|
||||
WSPGROUP()
|
||||
|
||||
TESTWSP([C escapes on],[wcp-c-escape],[cescapes],
|
||||
[a\ttab form\ffeed and new\nline],
|
||||
[NF: 4
|
||||
0: a\ttab
|
||||
|
@ -317,7 +481,7 @@ TESTWSP([C escapes on],[wcp-c-escape wsp27],[cescapes],
|
|||
3: new\nline
|
||||
])
|
||||
|
||||
TESTWSP([C escapes off],[wcp-c-escape-off wsp28],[-cescapes],
|
||||
TESTWSP([C escapes off],[wcp-c-escape-off],[-cescapes],
|
||||
[a\ttab form\ffeed and new\nline],
|
||||
[NF: 4
|
||||
0: attab
|
||||
|
@ -326,7 +490,7 @@ TESTWSP([C escapes off],[wcp-c-escape-off wsp28],[-cescapes],
|
|||
3: newnline
|
||||
])
|
||||
|
||||
TESTWSP([ws elimination],[wsp-ws-elim wsp29],[delim ' ()' ws return_delims],
|
||||
TESTWSP([ws elimination],[wsp-ws-elim],[delim ' ()' ws return_delims],
|
||||
[( list items )],
|
||||
[NF: 4
|
||||
0: (
|
||||
|
@ -335,14 +499,14 @@ TESTWSP([ws elimination],[wsp-ws-elim wsp29],[delim ' ()' ws return_delims],
|
|||
3: )
|
||||
])
|
||||
|
||||
TESTWSP([empty quotes],[wsp-empty-quotes wsp30],[delim : ws return_delims],
|
||||
TESTWSP([empty quotes],[wsp-empty-quotes],[delim : ws return_delims],
|
||||
[t=""],
|
||||
[NF: 1
|
||||
0: t=
|
||||
])
|
||||
|
||||
TESTWSP([delimiter following empty quotes],
|
||||
[wsp31],[delim : ws return_delims],
|
||||
[],[delim : ws return_delims],
|
||||
[t="":r],
|
||||
[NF: 3
|
||||
0: t=
|
||||
|
@ -351,7 +515,7 @@ TESTWSP([delimiter following empty quotes],
|
|||
])
|
||||
|
||||
TESTWSP([suppress ws trimming within quotes],
|
||||
[wsp32],
|
||||
[],
|
||||
[default delim , ws return_delims],
|
||||
[nocomponent,nonewline, formatfield="In message %{text}, "],
|
||||
[NF: 5
|
||||
|
@ -362,9 +526,8 @@ TESTWSP([suppress ws trimming within quotes],
|
|||
4: "formatfield=In message %{text}, "
|
||||
])
|
||||
|
||||
# FIXME: numbering
|
||||
TESTWSP([unescape],
|
||||
[wsp-unescape wsp-unescape-simple wsp33],
|
||||
[wsp-unescape wsp-unescape-simple],
|
||||
[-default novar nocmd quote escape ':+:\\""'],
|
||||
[\Seen "quote \"" "bs \\"],
|
||||
[NF: 3
|
||||
|
@ -374,7 +537,7 @@ TESTWSP([unescape],
|
|||
])
|
||||
|
||||
TESTWSP([unescape: word/quote],
|
||||
[wsp-unescape wsp-unescape-word wsp33],
|
||||
[wsp-unescape wsp-unescape-word],
|
||||
[-default novar nocmd quote escape-word '\\""' escape-quote ':+0x:\\""'],
|
||||
[\Seen "quote \"" "bs \\" "3\x31 \101" 3\x31 \101],
|
||||
[NF: 6
|
||||
|
@ -386,9 +549,7 @@ TESTWSP([unescape: word/quote],
|
|||
5: 101
|
||||
])
|
||||
|
||||
# END FIXME
|
||||
|
||||
TESTWSP([dquote],[wsp34],[-default novar nocmd dquote],
|
||||
TESTWSP([dquote],[],[-default novar nocmd dquote],
|
||||
[a "quoted example" isn't it],
|
||||
[NF: 4
|
||||
0: a
|
||||
|
@ -397,7 +558,7 @@ TESTWSP([dquote],[wsp34],[-default novar nocmd dquote],
|
|||
3: it
|
||||
])
|
||||
|
||||
TESTWSP([squote],[wsp35],[-default novar nocmd squote],
|
||||
TESTWSP([squote],[],[-default novar nocmd squote],
|
||||
[a 'quoted example' isn"t it],
|
||||
[NF: 4
|
||||
0: a
|
||||
|
@ -406,7 +567,9 @@ TESTWSP([squote],[wsp35],[-default novar nocmd squote],
|
|||
3: it
|
||||
])
|
||||
|
||||
TESTWSP([incremental],[wsp-incr wsp36],[incremental],
|
||||
WSPGROUP(wsp-incr)
|
||||
|
||||
TESTWSP([incremental],[],[incremental],
|
||||
[incremental "input test" line
|
||||
|
||||
|
||||
|
@ -421,7 +584,7 @@ NF: 1
|
|||
[input exhausted
|
||||
])
|
||||
|
||||
TESTWSP([incremental append],[wsp-incr wsp37],[incremental append],
|
||||
TESTWSP([incremental append],[],[incremental append],
|
||||
[incremental "input test" line
|
||||
|
||||
|
||||
|
@ -440,7 +603,7 @@ NF: 3
|
|||
])
|
||||
|
||||
TESTWSP([incremental ws],
|
||||
[wsp-incr wsp38],[return_delims -squeeze_delims incremental ws],
|
||||
[],[return_delims -squeeze_delims incremental ws],
|
||||
[a list test
|
||||
|
||||
|
||||
|
@ -455,151 +618,11 @@ NF: 1
|
|||
[input exhausted
|
||||
])
|
||||
|
||||
TESTWSP([default value (defined)],[wsp-var wsp-var13 wsp39],[],
|
||||
[${FOO:-bar}],
|
||||
[NF: 1
|
||||
0: qux
|
||||
],
|
||||
[],
|
||||
[FOO=qux])
|
||||
|
||||
TESTWSP([default value],[wsp-var wsp-var14 wsp40],[],
|
||||
[${FOO:-bar}],
|
||||
[NF: 1
|
||||
0: bar
|
||||
])
|
||||
|
||||
TESTWSP([default value (defined)],[wsp-var wsp-var13 wsp39],[],
|
||||
[${FOO:-bar}],
|
||||
[NF: 1
|
||||
0: qux
|
||||
],
|
||||
[],
|
||||
[FOO=qux])
|
||||
|
||||
# FIXME: breaks wspN numbering
|
||||
TESTWSP([default value (:- null)],[wsp-var],[],
|
||||
[${FOO:-bar}],
|
||||
[NF: 1
|
||||
0: bar
|
||||
],
|
||||
[],
|
||||
[FOO=])
|
||||
|
||||
TESTWSP([default value (- null)],[wsp-var],[],
|
||||
[${FOO-bar}],
|
||||
[NF: 0
|
||||
],
|
||||
[],
|
||||
[FOO=])
|
||||
|
||||
TESTWSP([default value (- null, unset)],[wsp-var],[],
|
||||
[${FOO-bar}],
|
||||
[NF: 1
|
||||
0: bar
|
||||
])
|
||||
|
||||
TESTWSP([assign default values],[wsp-var],[],
|
||||
[${FOO=bar}
|
||||
$FOO],
|
||||
[NF: 1
|
||||
0: bar
|
||||
NF: 1
|
||||
0: bar
|
||||
])
|
||||
|
||||
# FIXME ends here
|
||||
|
||||
TESTWSP([default error message (var defined)],[wsp-var wsp-var15 wsp41],[],
|
||||
[a ${FOO:?} test],
|
||||
[NF: 3
|
||||
0: a
|
||||
1: bar
|
||||
2: test
|
||||
],
|
||||
[],
|
||||
[FOO=bar])
|
||||
|
||||
TESTWSP([default error message],[wsp-var wsp-var16 wsp42],[],
|
||||
[${FOO:?}],
|
||||
[NF: 0
|
||||
],
|
||||
[FOO: variable null or not set
|
||||
])
|
||||
|
||||
TESTWSP([custom error message (defined)],[wsp-var wsp-var17 wsp-custom-err wsp-custom-err00 wsp43],[],
|
||||
[a ${FOO:?please define it} test],
|
||||
[NF: 3
|
||||
0: a
|
||||
1: bar
|
||||
2: test
|
||||
],
|
||||
[],
|
||||
[FOO=bar])
|
||||
|
||||
TESTWSP([custom error message],[wsp-var wsp-var18 wsp-custom-err wsp-custom-err01 wsp44],[],
|
||||
[a ${FOO:?please define it} test],
|
||||
[NF: 2
|
||||
0: a
|
||||
1: test
|
||||
],
|
||||
[FOO: please define it
|
||||
])
|
||||
|
||||
TESTWSP([alternate value (defined)],[wsp-var wsp-var19 wsp-alt wsp-alt00 wsp45],[],
|
||||
[a ${FOO:+isset} test],
|
||||
[NF: 3
|
||||
0: a
|
||||
1: isset
|
||||
2: test
|
||||
],
|
||||
[],
|
||||
[FOO=bar])
|
||||
|
||||
TESTWSP([alternate value],[wsp-var wsp-var20 wsp-alt wsp-alt01 wsp46],[],
|
||||
[a ${FOO:+isset} test],
|
||||
[NF: 2
|
||||
0: a
|
||||
1: test
|
||||
],
|
||||
[],
|
||||
[unset FOO;])
|
||||
|
||||
TESTWSP([getvar],[wsp-var wsp-var21 wsp-getvar wsp-getvar00 wsp47],
|
||||
[foo=bar x=quux],
|
||||
[begin $foo $x end],
|
||||
[NF: 4
|
||||
0: begin
|
||||
1: bar
|
||||
2: quux
|
||||
3: end
|
||||
])
|
||||
|
||||
TESTWSP([getvar and env],[wsp-var wsp-var22 wsp-getvar wsp-getvar01 wsp48],
|
||||
[foo=bar x=quux],
|
||||
[begin $foo $TVAR $x end],
|
||||
[NF: 5
|
||||
0: begin
|
||||
1: bar
|
||||
2: 12
|
||||
3: quux
|
||||
4: end
|
||||
],
|
||||
[],
|
||||
[TVAR=12])
|
||||
|
||||
TESTWSP([getvar, alternate value],[wsp-var wsp-var23 wsp-alt wsp-alt02 wsp-getvar02 wsp49],
|
||||
[foo=bar],
|
||||
[a ${foo:+isset}],
|
||||
[NF: 2
|
||||
0: a
|
||||
1: isset
|
||||
])
|
||||
|
||||
dnl Something that doesn't fit into TESTWSP
|
||||
|
||||
AT_SETUP([simple command substitution])
|
||||
AT_KEYWORDS([wordsplit wsp wsp-cmd wsp-cmd-1 wsp50])
|
||||
AT_KEYWORDS([wordsplit wsp wsp-cmd wsp-cmd-1])
|
||||
AT_CHECK([
|
||||
mkdir dir
|
||||
> dir/file
|
||||
|
@ -618,7 +641,7 @@ EOT
|
|||
AT_CLEANUP
|
||||
|
||||
AT_SETUP([quoted command substitution])
|
||||
AT_KEYWORDS([wordsplit wsp wsp-cmd wsp-cmd-2 wsp51])
|
||||
AT_KEYWORDS([wordsplit wsp wsp-cmd wsp-cmd-2])
|
||||
AT_CHECK([
|
||||
mkdir dir
|
||||
> dir/file
|
||||
|
@ -636,7 +659,7 @@ EOT
|
|||
AT_CLEANUP
|
||||
|
||||
AT_SETUP([coalesced command substitution])
|
||||
AT_KEYWORDS([wordsplit wsp wsp-cmd wsp-cmd-3 wsp52])
|
||||
AT_KEYWORDS([wordsplit wsp wsp-cmd wsp-cmd-3])
|
||||
AT_CHECK([
|
||||
mkdir dir
|
||||
> dir/file
|
||||
|
@ -653,7 +676,7 @@ EOT
|
|||
AT_CLEANUP
|
||||
|
||||
AT_SETUP([quoted coalesced command substitution])
|
||||
AT_KEYWORDS([wordsplit wsp wsp-cmd wsp-cmd-4 wsp53])
|
||||
AT_KEYWORDS([wordsplit wsp wsp-cmd wsp-cmd-4])
|
||||
AT_CHECK([
|
||||
mkdir dir
|
||||
> dir/file
|
||||
|
@ -669,7 +692,7 @@ EOT
|
|||
AT_CLEANUP
|
||||
|
||||
AT_SETUP([variable and command substitution])
|
||||
AT_KEYWORDS([wordsplit wsp wsp-var wsp-var24 wsp-cmd wsp-cmd-5 wsp54])
|
||||
AT_KEYWORDS([wordsplit wsp wsp-var wsp-var24 wsp-cmd wsp-cmd-5])
|
||||
AT_CHECK([
|
||||
mkdir dir
|
||||
> dir/file
|
||||
|
@ -688,7 +711,7 @@ EOT
|
|||
AT_CLEANUP
|
||||
|
||||
AT_SETUP([variable expansion and command substitution in quotes])
|
||||
AT_KEYWORDS([wordsplit wsp wsp-var wsp-var25 wsp-cmd wsp-cmd-6 wsp55])
|
||||
AT_KEYWORDS([wordsplit wsp wsp-var wsp-var25 wsp-cmd wsp-cmd-6])
|
||||
AT_CHECK([
|
||||
mkdir dir
|
||||
> dir/file
|
||||
|
@ -704,7 +727,7 @@ EOT
|
|||
AT_CLEANUP
|
||||
|
||||
AT_SETUP([pathname expansion])
|
||||
AT_KEYWORDS([wordsplit wsp wsp-path wsp-path-1 wsp56])
|
||||
AT_KEYWORDS([wordsplit wsp wsp-path wsp-path-1])
|
||||
AT_CHECK([
|
||||
mkdir dir
|
||||
> dir/1.c
|
||||
|
@ -725,7 +748,7 @@ EOT
|
|||
AT_CLEANUP
|
||||
|
||||
AT_SETUP([pathname expansion: no match])
|
||||
AT_KEYWORDS([wordsplit wsp wsp-path wsp-path-2 wsp57])
|
||||
AT_KEYWORDS([wordsplit wsp wsp-path wsp-path-2])
|
||||
AT_CHECK([
|
||||
mkdir dir
|
||||
> dir/1.c
|
||||
|
@ -744,7 +767,7 @@ EOT
|
|||
AT_CLEANUP
|
||||
|
||||
AT_SETUP([pathname expansion: nullglob])
|
||||
AT_KEYWORDS([wordsplit wsp wsp-path wsp-path-3 wsp58])
|
||||
AT_KEYWORDS([wordsplit wsp wsp-path wsp-path-3])
|
||||
AT_CHECK([
|
||||
mkdir dir
|
||||
> dir/1.c
|
||||
|
@ -762,7 +785,7 @@ EOT
|
|||
AT_CLEANUP
|
||||
|
||||
AT_SETUP([pathname expansion: failglob])
|
||||
AT_KEYWORDS([wordsplit wsp wsp-path wsp-path-4 wsp59])
|
||||
AT_KEYWORDS([wordsplit wsp wsp-path wsp-path-4])
|
||||
AT_CHECK([
|
||||
mkdir dir
|
||||
> dir/1.c
|
||||
|
@ -779,3 +802,9 @@ EOT
|
|||
AT_CLEANUP
|
||||
|
||||
m4_popdef([TESTWSP])
|
||||
m4_popdef([wspnum])
|
||||
m4_popdef([wspid])
|
||||
m4_popdef([genkw])
|
||||
m4_popdef([wspgroupnum])
|
||||
m4_popdef([wspgroupname])
|
||||
m4_popdef([WSPGROUP])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue