From e829f95f353962571f837ef44ad80ee6dd9f86b7 Mon Sep 17 00:00:00 2001 From: bar-g <105970722+bar-g@users.noreply.github.com> Date: Thu, 8 Feb 2024 19:46:10 +0000 Subject: [PATCH 01/15] word_parse.py: consistent parse_backslash error + hint --- osh/word_parse.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osh/word_parse.py b/osh/word_parse.py index d965ecd388..5a4cc3aa05 100644 --- a/osh/word_parse.py +++ b/osh/word_parse.py @@ -667,7 +667,7 @@ def ReadSingleQuoted(self, lex_mode, left_token, tokens, is_ysh_expr): # x = $'\z' is disallowed; ditto for echo $'\z' if shopt -u parse_backslash if is_ysh_expr or not self.parse_opts.parse_backslash(): - p_die("Invalid char escape in C-style string literal", tok) + p_die("Invalid char escape in C-style string literal. Literal: '\\\\' (parse_backslash)", tok) tokens.append(tok) @@ -944,7 +944,7 @@ def _ReadLikeDQ(self, left_token, is_ysh_expr, out_parts): if (is_ysh_expr or not self.parse_opts.parse_backslash()): p_die( - "Invalid char escape in double quoted string", + "Invalid char escape in double quoted string. Literal: '\\\\' (parse_backslash)", self.cur_token) elif self.token_type == Id.Lit_Dollar: if is_ysh_expr or not self.parse_opts.parse_dollar(): @@ -1611,7 +1611,7 @@ def _MaybeReadWordPart(self, is_first, lex_mode, parts): ch = lexer.TokenSliceLeft(tok, 1) if not self.parse_opts.parse_backslash(): if not pyutil.IsValidCharEscape(ch): - p_die('Invalid char escape (parse_backslash)', + p_die("Invalid char escape. Literal: '\\\\' (parse_backslash)', self.cur_token) part = word_part.EscapedLiteral(self.cur_token, From 70578605928ecc4b7561824f7637d6e6373a984b Mon Sep 17 00:00:00 2001 From: bar-g <105970722+bar-g@users.noreply.github.com> Date: Thu, 8 Feb 2024 20:00:12 +0000 Subject: [PATCH 02/15] Update word_parse.py --- osh/word_parse.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osh/word_parse.py b/osh/word_parse.py index 5a4cc3aa05..689f2dea51 100644 --- a/osh/word_parse.py +++ b/osh/word_parse.py @@ -667,7 +667,7 @@ def ReadSingleQuoted(self, lex_mode, left_token, tokens, is_ysh_expr): # x = $'\z' is disallowed; ditto for echo $'\z' if shopt -u parse_backslash if is_ysh_expr or not self.parse_opts.parse_backslash(): - p_die("Invalid char escape in C-style string literal. Literal: '\\\\' (parse_backslash)", tok) + p_die("Invalid char escape in C-style string literal. Only allowed literal: '\\\\' (parse_backslash)", tok) tokens.append(tok) @@ -944,7 +944,7 @@ def _ReadLikeDQ(self, left_token, is_ysh_expr, out_parts): if (is_ysh_expr or not self.parse_opts.parse_backslash()): p_die( - "Invalid char escape in double quoted string. Literal: '\\\\' (parse_backslash)", + "Invalid char escape in double quoted string. Only allowed literal: '\\\\' (parse_backslash)", self.cur_token) elif self.token_type == Id.Lit_Dollar: if is_ysh_expr or not self.parse_opts.parse_dollar(): @@ -1611,7 +1611,7 @@ def _MaybeReadWordPart(self, is_first, lex_mode, parts): ch = lexer.TokenSliceLeft(tok, 1) if not self.parse_opts.parse_backslash(): if not pyutil.IsValidCharEscape(ch): - p_die("Invalid char escape. Literal: '\\\\' (parse_backslash)', + p_die("Invalid char escape. Only allowed literal: '\\\\' (parse_backslash)', self.cur_token) part = word_part.EscapedLiteral(self.cur_token, From 693002e27a9388cf1c8d4278545e902cdc4d2670 Mon Sep 17 00:00:00 2001 From: bar-g <105970722+bar-g@users.noreply.github.com> Date: Fri, 9 Feb 2024 02:52:58 +0000 Subject: [PATCH 03/15] shorter hint --- osh/word_parse.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osh/word_parse.py b/osh/word_parse.py index 689f2dea51..f9a1eb5167 100644 --- a/osh/word_parse.py +++ b/osh/word_parse.py @@ -667,7 +667,7 @@ def ReadSingleQuoted(self, lex_mode, left_token, tokens, is_ysh_expr): # x = $'\z' is disallowed; ditto for echo $'\z' if shopt -u parse_backslash if is_ysh_expr or not self.parse_opts.parse_backslash(): - p_die("Invalid char escape in C-style string literal. Only allowed literal: '\\\\' (parse_backslash)", tok) + p_die("Invalid char escape in C-style string literal. Use '\\\\' to print \ (parse_backslash).", tok) tokens.append(tok) @@ -944,7 +944,7 @@ def _ReadLikeDQ(self, left_token, is_ysh_expr, out_parts): if (is_ysh_expr or not self.parse_opts.parse_backslash()): p_die( - "Invalid char escape in double quoted string. Only allowed literal: '\\\\' (parse_backslash)", + "Invalid char escape in double quoted string. Use '\\\\' to print \ (parse_backslash).", self.cur_token) elif self.token_type == Id.Lit_Dollar: if is_ysh_expr or not self.parse_opts.parse_dollar(): @@ -1611,7 +1611,7 @@ def _MaybeReadWordPart(self, is_first, lex_mode, parts): ch = lexer.TokenSliceLeft(tok, 1) if not self.parse_opts.parse_backslash(): if not pyutil.IsValidCharEscape(ch): - p_die("Invalid char escape. Only allowed literal: '\\\\' (parse_backslash)', + p_die("Invalid char escape. Use '\\\\' to print \ (parse_backslash).', self.cur_token) part = word_part.EscapedLiteral(self.cur_token, From 2dccfc248533f553b366f6a65d4107a7318fcb0a Mon Sep 17 00:00:00 2001 From: bar-g <105970722+bar-g@users.noreply.github.com> Date: Fri, 9 Feb 2024 02:55:57 +0000 Subject: [PATCH 04/15] compact hint --- osh/word_parse.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osh/word_parse.py b/osh/word_parse.py index f9a1eb5167..a51c41737c 100644 --- a/osh/word_parse.py +++ b/osh/word_parse.py @@ -667,7 +667,7 @@ def ReadSingleQuoted(self, lex_mode, left_token, tokens, is_ysh_expr): # x = $'\z' is disallowed; ditto for echo $'\z' if shopt -u parse_backslash if is_ysh_expr or not self.parse_opts.parse_backslash(): - p_die("Invalid char escape in C-style string literal. Use '\\\\' to print \ (parse_backslash).", tok) + p_die("Invalid char escape in C-style string literal. Use '\\\\' to get \ (parse_backslash).", tok) tokens.append(tok) @@ -944,7 +944,7 @@ def _ReadLikeDQ(self, left_token, is_ysh_expr, out_parts): if (is_ysh_expr or not self.parse_opts.parse_backslash()): p_die( - "Invalid char escape in double quoted string. Use '\\\\' to print \ (parse_backslash).", + "Invalid char escape in double quoted string. Use '\\\\' to get \ (parse_backslash).", self.cur_token) elif self.token_type == Id.Lit_Dollar: if is_ysh_expr or not self.parse_opts.parse_dollar(): @@ -1611,7 +1611,7 @@ def _MaybeReadWordPart(self, is_first, lex_mode, parts): ch = lexer.TokenSliceLeft(tok, 1) if not self.parse_opts.parse_backslash(): if not pyutil.IsValidCharEscape(ch): - p_die("Invalid char escape. Use '\\\\' to print \ (parse_backslash).', + p_die("Invalid char escape. Use '\\\\' to get \ (parse_backslash).', self.cur_token) part = word_part.EscapedLiteral(self.cur_token, From 62709727fd1730b2d02dd065de9387150a2d56f3 Mon Sep 17 00:00:00 2001 From: bar-g <105970722+bar-g@users.noreply.github.com> Date: Fri, 9 Feb 2024 02:58:39 +0000 Subject: [PATCH 05/15] double-up backslashes --- osh/word_parse.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osh/word_parse.py b/osh/word_parse.py index a51c41737c..49231247d0 100644 --- a/osh/word_parse.py +++ b/osh/word_parse.py @@ -667,7 +667,7 @@ def ReadSingleQuoted(self, lex_mode, left_token, tokens, is_ysh_expr): # x = $'\z' is disallowed; ditto for echo $'\z' if shopt -u parse_backslash if is_ysh_expr or not self.parse_opts.parse_backslash(): - p_die("Invalid char escape in C-style string literal. Use '\\\\' to get \ (parse_backslash).", tok) + p_die("Invalid char escape in C-style string literal. Use '\\\\' to get \\ (parse_backslash).", tok) tokens.append(tok) @@ -944,7 +944,7 @@ def _ReadLikeDQ(self, left_token, is_ysh_expr, out_parts): if (is_ysh_expr or not self.parse_opts.parse_backslash()): p_die( - "Invalid char escape in double quoted string. Use '\\\\' to get \ (parse_backslash).", + "Invalid char escape in double quoted string. Use '\\\\' to get \\ (parse_backslash).", self.cur_token) elif self.token_type == Id.Lit_Dollar: if is_ysh_expr or not self.parse_opts.parse_dollar(): @@ -1611,7 +1611,7 @@ def _MaybeReadWordPart(self, is_first, lex_mode, parts): ch = lexer.TokenSliceLeft(tok, 1) if not self.parse_opts.parse_backslash(): if not pyutil.IsValidCharEscape(ch): - p_die("Invalid char escape. Use '\\\\' to get \ (parse_backslash).', + p_die("Invalid char escape. Use '\\\\' to get \\ (parse_backslash).', self.cur_token) part = word_part.EscapedLiteral(self.cur_token, From 2b8c7be7d73c58f5b3b234f298a2d577be131628 Mon Sep 17 00:00:00 2001 From: bar-g <105970722+bar-g@users.noreply.github.com> Date: Fri, 9 Feb 2024 12:15:49 +0000 Subject: [PATCH 06/15] list the few double-quote escapes --- osh/word_parse.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osh/word_parse.py b/osh/word_parse.py index 49231247d0..547b77747d 100644 --- a/osh/word_parse.py +++ b/osh/word_parse.py @@ -667,7 +667,7 @@ def ReadSingleQuoted(self, lex_mode, left_token, tokens, is_ysh_expr): # x = $'\z' is disallowed; ditto for echo $'\z' if shopt -u parse_backslash if is_ysh_expr or not self.parse_opts.parse_backslash(): - p_die("Invalid char escape in C-style string literal. Use '\\\\' to get \\ (parse_backslash).", tok) + p_die('Invalid char escape in C-style string literal. Use \\ to get \ (parse_backslash).', tok) tokens.append(tok) @@ -944,7 +944,7 @@ def _ReadLikeDQ(self, left_token, is_ysh_expr, out_parts): if (is_ysh_expr or not self.parse_opts.parse_backslash()): p_die( - "Invalid char escape in double quoted string. Use '\\\\' to get \\ (parse_backslash).", + 'Invalid char escape in double quoted string. Only \", \$, or \\ to get \ (parse_backslash).', self.cur_token) elif self.token_type == Id.Lit_Dollar: if is_ysh_expr or not self.parse_opts.parse_dollar(): @@ -1611,7 +1611,7 @@ def _MaybeReadWordPart(self, is_first, lex_mode, parts): ch = lexer.TokenSliceLeft(tok, 1) if not self.parse_opts.parse_backslash(): if not pyutil.IsValidCharEscape(ch): - p_die("Invalid char escape. Use '\\\\' to get \\ (parse_backslash).', + p_die('Invalid char escape. Remove, or use \\ to get \ (parse_backslash).', self.cur_token) part = word_part.EscapedLiteral(self.cur_token, From abcfea46bef12909a2baa8c360856176e2b4adb6 Mon Sep 17 00:00:00 2001 From: bar-g <105970722+bar-g@users.noreply.github.com> Date: Fri, 9 Feb 2024 14:22:06 +0000 Subject: [PATCH 07/15] python backslash printing --- osh/word_parse.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osh/word_parse.py b/osh/word_parse.py index 547b77747d..1ae0e49560 100644 --- a/osh/word_parse.py +++ b/osh/word_parse.py @@ -667,7 +667,7 @@ def ReadSingleQuoted(self, lex_mode, left_token, tokens, is_ysh_expr): # x = $'\z' is disallowed; ditto for echo $'\z' if shopt -u parse_backslash if is_ysh_expr or not self.parse_opts.parse_backslash(): - p_die('Invalid char escape in C-style string literal. Use \\ to get \ (parse_backslash).', tok) + p_die('Invalid char escape in C-style string literal. Use \\\\ to get \ (parse_backslash).', tok) tokens.append(tok) @@ -944,7 +944,7 @@ def _ReadLikeDQ(self, left_token, is_ysh_expr, out_parts): if (is_ysh_expr or not self.parse_opts.parse_backslash()): p_die( - 'Invalid char escape in double quoted string. Only \", \$, or \\ to get \ (parse_backslash).', + 'Invalid char escape in double quoted string. Only \", \$, or \\\\ to get \ (parse_backslash).', self.cur_token) elif self.token_type == Id.Lit_Dollar: if is_ysh_expr or not self.parse_opts.parse_dollar(): @@ -1611,7 +1611,7 @@ def _MaybeReadWordPart(self, is_first, lex_mode, parts): ch = lexer.TokenSliceLeft(tok, 1) if not self.parse_opts.parse_backslash(): if not pyutil.IsValidCharEscape(ch): - p_die('Invalid char escape. Remove, or use \\ to get \ (parse_backslash).', + p_die('Invalid char escape. Remove, or use \\\\ to get \ (parse_backslash).', self.cur_token) part = word_part.EscapedLiteral(self.cur_token, From d9f4ef179314a700647a7190c34e169bb3ad9bae Mon Sep 17 00:00:00 2001 From: bar-g <105970722+bar-g@users.noreply.github.com> Date: Sat, 10 Feb 2024 12:22:39 +0000 Subject: [PATCH 08/15] errors now with bullet questions below --- osh/word_parse.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osh/word_parse.py b/osh/word_parse.py index 1ae0e49560..af2ce75fe5 100644 --- a/osh/word_parse.py +++ b/osh/word_parse.py @@ -667,7 +667,7 @@ def ReadSingleQuoted(self, lex_mode, left_token, tokens, is_ysh_expr): # x = $'\z' is disallowed; ditto for echo $'\z' if shopt -u parse_backslash if is_ysh_expr or not self.parse_opts.parse_backslash(): - p_die('Invalid char escape in C-style string literal. Use \\\\ to get \ (parse_backslash).', tok) + p_die('Invalid char escape in C-style string literal (parse_backslash).\n\t* \\\\ to denote \\ ?\n\t* use u\'- or b\'-literal ? (ysh)', tok) tokens.append(tok) @@ -944,7 +944,7 @@ def _ReadLikeDQ(self, left_token, is_ysh_expr, out_parts): if (is_ysh_expr or not self.parse_opts.parse_backslash()): p_die( - 'Invalid char escape in double quoted string. Only \", \$, or \\\\ to get \ (parse_backslash).', + 'Invalid char escape in double quoted string literal (parse_backslash).\n\t Only allowed: \", \$, or \\\\ to denote \\\n\t* change to \\\\ to denote \\ ?\n\t* use u\'- or b\'-literal ? (ysh)', self.cur_token) elif self.token_type == Id.Lit_Dollar: if is_ysh_expr or not self.parse_opts.parse_dollar(): @@ -1611,7 +1611,7 @@ def _MaybeReadWordPart(self, is_first, lex_mode, parts): ch = lexer.TokenSliceLeft(tok, 1) if not self.parse_opts.parse_backslash(): if not pyutil.IsValidCharEscape(ch): - p_die('Invalid char escape. Remove, or use \\\\ to get \ (parse_backslash).', + p_die('Invalid char escape (parse_backslash).\n\t* remove \ ?\n\t* use \\\\ to denote \\ ?\n\t* use \'- or r\'-string-literal ?', self.cur_token) part = word_part.EscapedLiteral(self.cur_token, From 5de4f9f01cc088907b0a15554382054555ec67d1 Mon Sep 17 00:00:00 2001 From: bar-g <105970722+bar-g@users.noreply.github.com> Date: Tue, 13 Feb 2024 14:36:48 +0000 Subject: [PATCH 09/15] dquote for text, refine --- osh/word_parse.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osh/word_parse.py b/osh/word_parse.py index af2ce75fe5..a6ca8f03a2 100644 --- a/osh/word_parse.py +++ b/osh/word_parse.py @@ -667,7 +667,7 @@ def ReadSingleQuoted(self, lex_mode, left_token, tokens, is_ysh_expr): # x = $'\z' is disallowed; ditto for echo $'\z' if shopt -u parse_backslash if is_ysh_expr or not self.parse_opts.parse_backslash(): - p_die('Invalid char escape in C-style string literal (parse_backslash).\n\t* \\\\ to denote \\ ?\n\t* use u\'- or b\'-literal ? (ysh)', tok) + p_die("Invalid char escape in C-style $'-string literal (parse_backslash)\n\t* use \\\\ to denote a \\ ?\n\t* (ysh) use u'- or b'-literal instead ?", tok) tokens.append(tok) @@ -944,7 +944,7 @@ def _ReadLikeDQ(self, left_token, is_ysh_expr, out_parts): if (is_ysh_expr or not self.parse_opts.parse_backslash()): p_die( - 'Invalid char escape in double quoted string literal (parse_backslash).\n\t Only allowed: \", \$, or \\\\ to denote \\\n\t* change to \\\\ to denote \\ ?\n\t* use u\'- or b\'-literal ? (ysh)', + "Invalid char escape in double quoted string literal (parse_backslash)\n\t Only allowed: \\\", \\$, or \\\\ to denote \\\n\t* use \\\\ to denote a \\ ?\n\t* (ysh) use "- ++ u'- or b'-literal instead?", self.cur_token) elif self.token_type == Id.Lit_Dollar: if is_ysh_expr or not self.parse_opts.parse_dollar(): @@ -1611,7 +1611,7 @@ def _MaybeReadWordPart(self, is_first, lex_mode, parts): ch = lexer.TokenSliceLeft(tok, 1) if not self.parse_opts.parse_backslash(): if not pyutil.IsValidCharEscape(ch): - p_die('Invalid char escape (parse_backslash).\n\t* remove \ ?\n\t* use \\\\ to denote \\ ?\n\t* use \'- or r\'-string-literal ?', + p_die("Invalid char escape (parse_backslash)\n\t* remove \ ?\n\t* use \\\\ to denote a \\ ?\n\t* use \"raw\" '-string-literal ?\n\t* use \"interpreted\" $'-string-literal ?\n\t* (ysh) use \"raw\" r'-string-literal ?\n\t* (ysh) use \"interpreted\" u'- or b'-string-literal ?", self.cur_token) part = word_part.EscapedLiteral(self.cur_token, From 1cad8c77146982f13cb1eca39c953f58f752f46e Mon Sep 17 00:00:00 2001 From: bar-g <105970722+bar-g@users.noreply.github.com> Date: Tue, 13 Feb 2024 14:47:28 +0000 Subject: [PATCH 10/15] fixed escaping error --- osh/word_parse.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osh/word_parse.py b/osh/word_parse.py index a6ca8f03a2..a31f26d4d4 100644 --- a/osh/word_parse.py +++ b/osh/word_parse.py @@ -944,7 +944,7 @@ def _ReadLikeDQ(self, left_token, is_ysh_expr, out_parts): if (is_ysh_expr or not self.parse_opts.parse_backslash()): p_die( - "Invalid char escape in double quoted string literal (parse_backslash)\n\t Only allowed: \\\", \\$, or \\\\ to denote \\\n\t* use \\\\ to denote a \\ ?\n\t* (ysh) use "- ++ u'- or b'-literal instead?", + "Invalid char escape in double quoted string literal (parse_backslash)\n\tOnly allowed: \\\", \\$, or \\\\ to denote \", $, or \\\n\t* use \\\\ to denote a \\ ?\n\t* (ysh) use \"- ++ u'- or b'-literals instead ?", self.cur_token) elif self.token_type == Id.Lit_Dollar: if is_ysh_expr or not self.parse_opts.parse_dollar(): From b305129a99055be09a435ff78f49319e72fecbb4 Mon Sep 17 00:00:00 2001 From: bar-g <105970722+bar-g@users.noreply.github.com> Date: Wed, 21 Feb 2024 13:24:23 +0000 Subject: [PATCH 11/15] mention literal chains --- osh/word_parse.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osh/word_parse.py b/osh/word_parse.py index a31f26d4d4..2c3eadcb99 100644 --- a/osh/word_parse.py +++ b/osh/word_parse.py @@ -667,7 +667,7 @@ def ReadSingleQuoted(self, lex_mode, left_token, tokens, is_ysh_expr): # x = $'\z' is disallowed; ditto for echo $'\z' if shopt -u parse_backslash if is_ysh_expr or not self.parse_opts.parse_backslash(): - p_die("Invalid char escape in C-style $'-string literal (parse_backslash)\n\t* use \\\\ to denote a \\ ?\n\t* (ysh) use u'- or b'-literal instead ?", tok) + p_die("Invalid char escape in C-style $'-string literal (parse_backslash)\n\t* use \\\\ to denote a \\ ?\n\t* 'chain'\"different\"$'literals' ?\n\t* (ysh) use u'- or b'-literal instead ?\n\t* (ysh) concat r'- ++ u'- or b'-literals ?", tok) tokens.append(tok) @@ -944,7 +944,7 @@ def _ReadLikeDQ(self, left_token, is_ysh_expr, out_parts): if (is_ysh_expr or not self.parse_opts.parse_backslash()): p_die( - "Invalid char escape in double quoted string literal (parse_backslash)\n\tOnly allowed: \\\", \\$, or \\\\ to denote \", $, or \\\n\t* use \\\\ to denote a \\ ?\n\t* (ysh) use \"- ++ u'- or b'-literals instead ?", + "Invalid char escape in double quoted string literal (parse_backslash)\n\tOnly allowed: \\\", \\$, or \\\\ to denote \", $, or \\\n\t* use \\\\ to denote a \\ ?\n\t* 'chain'\"different\"$'literals' ?\n\t* (ysh) concat \"- ++ u'- or b'-literals ?", self.cur_token) elif self.token_type == Id.Lit_Dollar: if is_ysh_expr or not self.parse_opts.parse_dollar(): From b81a7912c59efbc6eb1fa90e2e9aa905ae499c89 Mon Sep 17 00:00:00 2001 From: bar-g <105970722+bar-g@users.noreply.github.com> Date: Wed, 21 Feb 2024 15:22:13 +0000 Subject: [PATCH 12/15] consistently mention "symbol"-string --- osh/word_parse.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osh/word_parse.py b/osh/word_parse.py index 2c3eadcb99..4ea9e5e24e 100644 --- a/osh/word_parse.py +++ b/osh/word_parse.py @@ -944,7 +944,7 @@ def _ReadLikeDQ(self, left_token, is_ysh_expr, out_parts): if (is_ysh_expr or not self.parse_opts.parse_backslash()): p_die( - "Invalid char escape in double quoted string literal (parse_backslash)\n\tOnly allowed: \\\", \\$, or \\\\ to denote \", $, or \\\n\t* use \\\\ to denote a \\ ?\n\t* 'chain'\"different\"$'literals' ?\n\t* (ysh) concat \"- ++ u'- or b'-literals ?", + "Invalid char escape in double quoted \"-string literal (parse_backslash)\n\tOnly allowed: \\\", \\$, or \\\\ to denote \", $, or \\\n\t* use \\\\ to denote a \\ ?\n\t* 'chain'\"different\"$'literals' ?\n\t* (ysh) concat \"- ++ u'- or b'-literals ?", self.cur_token) elif self.token_type == Id.Lit_Dollar: if is_ysh_expr or not self.parse_opts.parse_dollar(): From 941c3424b8d80988f5b88347b87b6096958babb1 Mon Sep 17 00:00:00 2001 From: bar-g <105970722+bar-g@users.noreply.github.com> Date: Wed, 21 Feb 2024 15:34:10 +0000 Subject: [PATCH 13/15] complete error info --- osh/word_parse.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osh/word_parse.py b/osh/word_parse.py index 4ea9e5e24e..473417c3d5 100644 --- a/osh/word_parse.py +++ b/osh/word_parse.py @@ -944,7 +944,7 @@ def _ReadLikeDQ(self, left_token, is_ysh_expr, out_parts): if (is_ysh_expr or not self.parse_opts.parse_backslash()): p_die( - "Invalid char escape in double quoted \"-string literal (parse_backslash)\n\tOnly allowed: \\\", \\$, or \\\\ to denote \", $, or \\\n\t* use \\\\ to denote a \\ ?\n\t* 'chain'\"different\"$'literals' ?\n\t* (ysh) concat \"- ++ u'- or b'-literals ?", + "Invalid char escape in $variable expanding \"-string literal (parse_backslash)\n\tOnly allowed: \\\", \\$, or \\\\ to denote \", $, or \\\n\t* use \\\\ to denote a \\ ?\n\t* 'chain'\"different\"$'literals' ?\n\t* (ysh) concat \"- ++ u'- or b'-literals ?", self.cur_token) elif self.token_type == Id.Lit_Dollar: if is_ysh_expr or not self.parse_opts.parse_dollar(): From fb7f6034ed9ed844008f7d0c715e3d6ff9d653ea Mon Sep 17 00:00:00 2001 From: bar-g <105970722+bar-g@users.noreply.github.com> Date: Thu, 22 Feb 2024 08:43:29 +0000 Subject: [PATCH 14/15] incl. info: no verbatims / no quotings --- osh/word_parse.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osh/word_parse.py b/osh/word_parse.py index 473417c3d5..42867f1303 100644 --- a/osh/word_parse.py +++ b/osh/word_parse.py @@ -667,7 +667,7 @@ def ReadSingleQuoted(self, lex_mode, left_token, tokens, is_ysh_expr): # x = $'\z' is disallowed; ditto for echo $'\z' if shopt -u parse_backslash if is_ysh_expr or not self.parse_opts.parse_backslash(): - p_die("Invalid char escape in C-style $'-string literal (parse_backslash)\n\t* use \\\\ to denote a \\ ?\n\t* 'chain'\"different\"$'literals' ?\n\t* (ysh) use u'- or b'-literal instead ?\n\t* (ysh) concat r'- ++ u'- or b'-literals ?", tok) + p_die("Invalid char escape in C-style $'-string literal (parse_backslash, no verbatims)\n\t* use \\\\ to denote a \\ ?\n\t* 'chain'\"different\"$'literals' ?\n\t* (ysh) use u'- or b'-literal instead ?\n\t* (ysh) concat r'- ++ u'- or b'-literals ?", tok) tokens.append(tok) @@ -944,7 +944,7 @@ def _ReadLikeDQ(self, left_token, is_ysh_expr, out_parts): if (is_ysh_expr or not self.parse_opts.parse_backslash()): p_die( - "Invalid char escape in $variable expanding \"-string literal (parse_backslash)\n\tOnly allowed: \\\", \\$, or \\\\ to denote \", $, or \\\n\t* use \\\\ to denote a \\ ?\n\t* 'chain'\"different\"$'literals' ?\n\t* (ysh) concat \"- ++ u'- or b'-literals ?", + "Invalid char escape in $variable expanding \"-string literal (parse_backslash, no verbatims)\n\tOnly allowed: \\\", \\$, or \\\\ to denote \", $, or \\\n\t* use \\\\ to denote a \\ ?\n\t* 'chain'\"different\"$'literals' ?\n\t* (ysh) concat \"- ++ u'- or b'-literals ?", self.cur_token) elif self.token_type == Id.Lit_Dollar: if is_ysh_expr or not self.parse_opts.parse_dollar(): @@ -1611,7 +1611,7 @@ def _MaybeReadWordPart(self, is_first, lex_mode, parts): ch = lexer.TokenSliceLeft(tok, 1) if not self.parse_opts.parse_backslash(): if not pyutil.IsValidCharEscape(ch): - p_die("Invalid char escape (parse_backslash)\n\t* remove \ ?\n\t* use \\\\ to denote a \\ ?\n\t* use \"raw\" '-string-literal ?\n\t* use \"interpreted\" $'-string-literal ?\n\t* (ysh) use \"raw\" r'-string-literal ?\n\t* (ysh) use \"interpreted\" u'- or b'-string-literal ?", + p_die("Invalid char escape (parse_backslash, no verbatims, no quotings)\n\t* remove \ ?\n\t* use \\\\ to denote a \\ ?\n\t* use \"raw\" '-string-literal ?\n\t* use \"interpreted\" $'-string-literal ?\n\t* (ysh) use \"raw\" r'-string-literal ?\n\t* (ysh) use \"interpreted\" u'- or b'-string-literal ?", self.cur_token) part = word_part.EscapedLiteral(self.cur_token, From 30704c1de40887a5702be109be78113f575c1ca7 Mon Sep 17 00:00:00 2001 From: bar-g <105970722+bar-g@users.noreply.github.com> Date: Sat, 24 Feb 2024 11:54:53 +0000 Subject: [PATCH 15/15] shorten --- osh/word_parse.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osh/word_parse.py b/osh/word_parse.py index 42867f1303..3b469704ab 100644 --- a/osh/word_parse.py +++ b/osh/word_parse.py @@ -944,7 +944,7 @@ def _ReadLikeDQ(self, left_token, is_ysh_expr, out_parts): if (is_ysh_expr or not self.parse_opts.parse_backslash()): p_die( - "Invalid char escape in $variable expanding \"-string literal (parse_backslash, no verbatims)\n\tOnly allowed: \\\", \\$, or \\\\ to denote \", $, or \\\n\t* use \\\\ to denote a \\ ?\n\t* 'chain'\"different\"$'literals' ?\n\t* (ysh) concat \"- ++ u'- or b'-literals ?", + "Invalid char escape in \"-string literal (parse_backslash, no verbatims)\n\tAllowed: \\\", \\$, or \\\\ to denote \", $, or \\\n\t* use \\\\ to denote a \\ ?\n\t* 'chain'\"different\"$'literals' ?\n\t* (ysh) concat \"- ++ u'- or b'-literals ?", self.cur_token) elif self.token_type == Id.Lit_Dollar: if is_ysh_expr or not self.parse_opts.parse_dollar():