From 680040d17d2c30d01481f2bef581e0ee00c5638c Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Thu, 15 Nov 2018 11:59:13 -0600 Subject: [PATCH] Document new PCRE2 string escaping in CHANGELOG and string.txt --- CHANGELOG.md | 1 + doc_src/string.txt | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index df7809e37..84e7af1c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -67,6 +67,7 @@ A new feature flags mechanism is added for staging deprecations and breaking cha - `string split` supports a new `--no-empty` option to exclude empty strings from the result (#4779). - `string` has new subcommands `split0` and `join0` for working with NUL-delimited output. - `string` no longer stops processing text after NUL characters (#4605) +- `string escape` has a new `--style pcre2` option for escaping strings to be matched literally in `string` regex operations. - `test` now supports floating point values in numeric comparisons. ### Interactive improvements diff --git a/doc_src/string.txt b/doc_src/string.txt index ed329f06a..3ea42fc3a 100644 --- a/doc_src/string.txt +++ b/doc_src/string.txt @@ -42,11 +42,13 @@ The following subcommands are available. `string escape` escapes each STRING in one of three ways. The first is `--style=script`. This is the default. It alters the string such that it can be passed back to `eval` to produce the original argument again. By default, all special characters are escaped, and quotes are used to simplify the output when possible. If `-n` or `--no-quoted` is given, the simplifying quoted format is not used. Exit status: 0 if at least one string was escaped, or 1 otherwise. -The second is `--style=var` which ensures the string can be used as a variable name by hex encoding any non-alphanumeric characters. The string is first converted to UTF-8 before being encoded. +`--style=var` ensures the string can be used as a variable name by hex encoding any non-alphanumeric characters. The string is first converted to UTF-8 before being encoded. -The third is `--style=url` which ensures the string can be used as a URL by hex encoding any character which is not legal in a URL. The string is first converted to UTF-8 before being encoded. +`--style=url` ensures the string can be used as a URL by hex encoding any character which is not legal in a URL. The string is first converted to UTF-8 before being encoded. -`string unescape` performs the inverse of the `string escape` command. If the string to be unescaped is not properly formatted it is ignored. For example, doing `string unescape --style=var (string escape --style=var $str)` will return the original string. +`--style=pcre2` escapes an input string for literal matching within a regex expression. The string is first converted to UTF-8 before being encoded. + +`string unescape` performs the inverse of the `string escape` command. If the string to be unescaped is not properly formatted it is ignored. For example, doing `string unescape --style=var (string escape --style=var $str)` will return the original string. There is no support for unescaping pcre2. \subsection string-join "join" subcommand