aboutsummaryrefslogtreecommitdiff
path: root/doc/testscript.cli
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-02-15 18:32:32 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-02-15 18:32:32 +0200
commit9ce514f4ec14a13f11da75a7b90ef67141a5487e (patch)
treeb01f064b8c0f882c5047d339a198257704511bcf /doc/testscript.cli
parenta9371024da41f96e29d584dce790b1f2ff02bb3f (diff)
Spec set testscript builtin
Diffstat (limited to 'doc/testscript.cli')
-rw-r--r--doc/testscript.cli44
1 files changed, 42 insertions, 2 deletions
diff --git a/doc/testscript.cli b/doc/testscript.cli
index 61319a3..5cb4521 100644
--- a/doc/testscript.cli
+++ b/doc/testscript.cli
@@ -1169,8 +1169,8 @@ the line is examined in the \c{first_token} mode (see below). If the first
token is an unquoted word, then the second token of the line is examined in
the \c{second_token} mode (see below). If it is a variable assignment (either
\c{+=}, \c{=+}, or \c{=}), then the line type is a variable line. Otherwise,
-it is a test command line. Note that computed variable names are not
-supported.
+it is a test command line. Note that variables with computed names can only
+be set using the \l{#builtins-set \c{set} builtin}.
The Testscript language defines the following distinct lexing modes (or
contexts):
@@ -2428,6 +2428,46 @@ are supported.
in \i{replacement}.||
+\h#builtins-set|\c{set}|
+
+\
+set [-e|--exact] [(-n|--newline)|(-w|--whitespace)] [<attr>] <var>
+\
+
+Set variable from the \c{stdin} input.
+
+Unless the \c{-e|--exact} option is specified, a single final newline is
+ignored in the input.
+
+If the \c{-n|--newline} option is specified, then the input is split into a
+list of elements at newlines, including a final blank element in case of
+\c{-e|--exact}. Multiple consecutive newlines are not collapsed.
+
+If the \c{-w|--whitespace} option is specified, then the input is split into a
+list of elements at whitespaces, including a final blank element in case of
+\c{-e|--exact}. Multiple consecutive whitespaces (including newlines) are
+collapsed.
+
+If neither \c{-n|--newline} nor \c{-w|--whitespace} is specified, then the
+entire input is used as a single element, including a final newline in case
+of \c{-e|--exact}.
+
+If the \i{attr} argument is specified, then it must contain a list of value
+attributes enclosed in \c{[]}, for example:
+
+\
+sed -s '/foo/bar/' input | set [string] x
+\
+
+Note that this is also the only way to set a variable with a computed name,
+for example:
+
+\
+foo = FOO
+set [null] $foo <-
+\
+
+
\h#builtins-test|\c{test}|
\