summaryrefslogtreecommitdiffstats
path: root/runtime/syntax/testdir
diff options
context:
space:
mode:
authorJohnothan King <johnothanking@protonmail.com>2024-01-22 11:19:54 -0800
committerGitHub <noreply@github.com>2024-01-22 20:19:54 +0100
commitadd31baedaf03b92dbd41427860c61c639ef705c (patch)
tree61cb9148281adad01c27f9d0178d1a15b69696fb /runtime/syntax/testdir
parent7c71db3a58f658b4329b82ab603efa928d17bdbc (diff)
runtime(sh): Add handling for ksh93 shared-state comsubs and mksh valsubs (#13884)
This commit adds support for ksh93 shared-state command substitutions (syntax: ${ command; }) and mksh's value substitutions (syntax: ${|command;}) in the sh syntax script. Also add a syntax test for ksh subshares with dumps included to make sure it doesn't regress. fixes: #9514 Signed-off-by: Johnothan King <johnothanking@protonmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'runtime/syntax/testdir')
-rw-r--r--runtime/syntax/testdir/dumps/sh_10_00.dump20
-rw-r--r--runtime/syntax/testdir/dumps/sh_10_01.dump20
-rw-r--r--runtime/syntax/testdir/dumps/sh_10_02.dump20
-rw-r--r--runtime/syntax/testdir/dumps/sh_10_99.dump20
-rw-r--r--runtime/syntax/testdir/input/sh_10.sh49
5 files changed, 129 insertions, 0 deletions
diff --git a/runtime/syntax/testdir/dumps/sh_10_00.dump b/runtime/syntax/testdir/dumps/sh_10_00.dump
new file mode 100644
index 0000000000..b0c98eab4c
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/sh_10_00.dump
@@ -0,0 +1,20 @@
+>#+0#0000e05#ffffff0|!|/|b|i|n|/|k|s|h| +0#0000000&@64
+@75
+|#+0#0000e05&| |T|h|i|s| |s|c|r|i|p|t| |i|s| |a| |t|e|s|t| |f|i|l|e| |f|o|r| |k|s|h|9|3| |s|h|a|r|e|d|-|s|t|a|t|e| +0#0000000&@23
+|#+0#0000e05&| |c|o|m@1|a|n|d| |s|u|b|s|t|i|t|u|t|i|o|n|s| |(|s|u|b|s|h|a|r|e|s|)| |a|n|d| |m|k|s|h| |v|a|l|u|e| +0#0000000&@24
+|#+0#0000e05&| |s|u|b|s|t|i|t|u|t|i|o|n|s| |(|v|a|l|s|u|b|s|)|.| +0#0000000&@48
+@75
+|#+0#0000e05&| |=@5| +0#0000000&@66
+|#+0#0000e05&| |B|e|l|o|w| |i|s| |s|u|b|s|h|a|r|e| |s|y|n|t|a|x| |s|u|p@1|o|r|t|e|d| |b|y| |b|o|t|h| |k|s|h|9|3| |a|n|d| |m|k|s|h|.| +0#0000000&@14
+|p+0#af5f00255&|r|i|n|t| +0#e000002&|$+0#e000e06&|{| |e+0#af5f00255&|c|h|o| +0#e000002&|o|n|e| +0#e000e06&|}| +0#0000000&@55
+|p+0#af5f00255&|r|i|n|t| +0#e000002&|$+0#e000e06&|{| @7|e+0#af5f00255&|c|h|o| +0#e000002&|t|w|o| +0#0000000&@50
+|}+0#e000e06&| +0#0000000&@73
+|p+0#af5f00255&|r|i|n|t| +0#e000002&|$+0#e000e06&|{| +0#0000000&@66
+|e+0#af5f00255&|c|h|o| +0#e000002&|t|h|r|e@1| +0#e000e06&@5|}| +0#0000000&@57
+|p+0#af5f00255&|r|i|n|t| +0#e000002&|$+0#e000e06&|{| |e+0#af5f00255&|c|h|o| +0#e000002&|'+0#af5f00255&|f+0#e000002&|o|u|r|'+0#af5f00255&|;| +0#e000e06&|}| +0#0000000&@51
+|p+0#af5f00255&|r|i|n|t| +0#e000002&|$+0#e000e06&|{| |e+0#af5f00255&|c|h|o| +0#e000002&|'+0#af5f00255&|f+0#e000002&|i|v|e|'+0#af5f00255&| +0#e000002&|;+0#e000e06&|}| +0#0000000&@51
+|p+0#af5f00255&|r|i|n|t| +0#e000002&|$+0#e000e06&|{| |e+0#af5f00255&|c|h|o| +0#e000002&|'+0#af5f00255&|s+0#e000002&|i|x|'+0#af5f00255&| +0#0000000&@55
+|}+0#e000e06&| +0#0000000&@73
+|p+0#af5f00255&|r|i|n|t| +0#e000002&|$+0#e000e06&|{| @7|e+0#af5f00255&|c|h|o| +0#e000002&|'+0#af5f00255&|s+0#e000002&|e|v|e|n|'+0#af5f00255&| +0#e000e06&@3|}| +0#0000000&@41
+|e+0#af5f00255&|c|h|o| +0#e000002&|$+0#e000e06&|{| |p+0#af5f00255&|r|i|n|t| +0#e000002&|'+0#af5f00255&|e+0#e000002&|i|g|h|t|'+0#af5f00255&| +0#e000e06&@2|}| +0#0000000&@49
+|i|s|_|k|o|r|n|s|h|e|l@1|:| |1|,| @40|1|,|1| @10|T|o|p|
diff --git a/runtime/syntax/testdir/dumps/sh_10_01.dump b/runtime/syntax/testdir/dumps/sh_10_01.dump
new file mode 100644
index 0000000000..c1d3531a6e
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/sh_10_01.dump
@@ -0,0 +1,20 @@
+|p+0#af5f00255#ffffff0|r|i|n|t| +0#e000002&|$+0#e000e06&|{| |e+0#af5f00255&|c|h|o| +0#e000002&|'+0#af5f00255&|f+0#e000002&|o|u|r|'+0#af5f00255&|;| +0#e000e06&|}| +0#0000000&@51
+|p+0#af5f00255&|r|i|n|t| +0#e000002&|$+0#e000e06&|{| |e+0#af5f00255&|c|h|o| +0#e000002&|'+0#af5f00255&|f+0#e000002&|i|v|e|'+0#af5f00255&| +0#e000002&|;+0#e000e06&|}| +0#0000000&@51
+|p+0#af5f00255&|r|i|n|t| +0#e000002&|$+0#e000e06&|{| |e+0#af5f00255&|c|h|o| +0#e000002&|'+0#af5f00255&|s+0#e000002&|i|x|'+0#af5f00255&| +0#0000000&@55
+|}+0#e000e06&| +0#0000000&@73
+|p+0#af5f00255&|r|i|n|t| +0#e000002&|$+0#e000e06&|{| @7|e+0#af5f00255&|c|h|o| +0#e000002&|'+0#af5f00255&|s+0#e000002&|e|v|e|n|'+0#af5f00255&| +0#e000e06&@3|}| +0#0000000&@41
+>e+0#af5f00255&|c|h|o| +0#e000002&|$+0#e000e06&|{| |p+0#af5f00255&|r|i|n|t| +0#e000002&|'+0#af5f00255&|e+0#e000002&|i|g|h|t|'+0#af5f00255&| +0#e000e06&@2|}| +0#0000000&@49
+|t+0#af5f00255&|y|p|e|s|e|t| +0#0000000&|n+0#00e0e07&|i|n|e|=+0#0000000&|$+0#e000e06&|{| |p+0#af5f00255&|w|d|;| +0#e000e06&|}| +0#0000000&@52
+@75
+|#+0#0000e05&| |=@5| +0#0000000&@66
+|#+0#0000e05&| |V|a|l|u|e| |s|u|b|s|t|i|t|u|t|i|o|n|s| |o|f| |t|h|e| |f|o|r|m| |$|{|||c|o|m@1|a|n|d|}| |a|r|e| |o|n|l|y| +0#0000000&@20
+|#+0#0000e05&| |s|u|p@1|o|r|t|e|d| |b|y| |m|k|s|h|,| |n|o|t| |k|s|h|9|3|.| +0#0000000&@43
+|i+0#af5f00255&|f| |!| +0#0000000&|c+0#af5f00255&|o|m@1|a|n|d| +0#0000000&|e+0#af5f00255&|v|a|l| +0#0000000&|'+0#af5f00255&|(+0#e000002&@1|.|s|h|.|v|e|r|s|i|o|n| |>|=| |2|0@1|7|0|7|0|3|)@1|'+0#af5f00255&| +0#0000000&|2+0#e000002&|>+0#af5f00255&|/+0#0000000&|d|e|v|/|n|u|l@1|;+0#af5f00255&| +0#0000000&|t+0#af5f00255&|h|e|n| +0#0000000&@9
+| +0#00e0e07&@7|v|a|l|s|u|b|f|u|n|c|(|)| |{| +0#0000000&@52
+@16|R+0#e000e06&|E|P|L|Y|=+0#af5f00255&|$+0#e000e06&|1| +0#0000000&@50
+@8|}+0#00e0e07&| +0#0000000&@65
+@8|e+0#af5f00255&|c|h|o| +0#e000002&|$+0#e000e06&|{|||v|a|l|s|u|b|f|u|n|c| |t|e|n|}| +0#0000000&@43
+@8|p+0#af5f00255&|r|i|n|t| +0#e000002&|"+0#af5f00255&|$+0#e000e06&|{|||v|a|l|s|u|b|f|u|n|c| |e|l|e|v|e|n|;+0#af5f00255&|}+0#e000e06&|"+0#af5f00255&| +0#0000000&@36
+@8|p+0#af5f00255&|r|i|n|t|f| +0#0000000&|'+0#af5f00255&|%+0#e000002&|s|'+0#af5f00255&| +0#0000000&|"+0#af5f00255&|$+0#e000e06&|{|||v|a|l|s|u|b|f|u|n|c| |t|w|e|l|v|e| @6|}|"+0#af5f00255&| +0#0000000&@24
+@8|u+0#00e0e07&|n|l|u|c|k|y|=+0#0000000&|$+0#e000e06&|{|||v|a|l|s|u|b|f|u|n|c| |t|h|i|r|t|e@1|n| +0#0000000&@36
+@57|1|9|,|1| @9|4|3|%|
diff --git a/runtime/syntax/testdir/dumps/sh_10_02.dump b/runtime/syntax/testdir/dumps/sh_10_02.dump
new file mode 100644
index 0000000000..e03c3f8144
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/sh_10_02.dump
@@ -0,0 +1,20 @@
+| +0&#ffffff0@7|u+0#00e0e07&|n|l|u|c|k|y|=+0#0000000&|$+0#e000e06&|{|||v|a|l|s|u|b|f|u|n|c| |t|h|i|r|t|e@1|n| +0#0000000&@36
+|}+0#e000e06&| +0#0000000&@73
+@8|t+0#af5f00255&|y|p|e|s|e|t| +0#0000000&|n+0#00e0e07&|o|t|a|f|l|o|a|t|=+0#0000000&|$+0#e000e06&|{|||v|a|l|s|u|b|f|u|n|c| |n|o|t|a|n|u|m|b|e|r| @5|}| +0#0000000&@17
+@8|p+0#af5f00255&|r|i|n|t| +0#e000002&|$+0#e000e06&|u|n|l|u|c|k|y| +0#e000002&|$+0#e000e06&|n|o|t|a|n|u|m|b|e|r| +0#0000000&@40
+@8|$+0#e000e06&|{|||e+0#af5f00255&|c|h|o| +0#e000002&|f|o@1|}+0#e000e06&| +0#0000000&@54
+@8>$+0#e000e06&|{|||e+0#af5f00255&|c|h|o| +0#e000002&|b|a|r| +0#0000000&@55
+|}+0#e000e06&| +0#0000000&@73
+|f+0#af5f00255&|i| +0#0000000&@72
+@75
+|#+0#0000e05&| |=@5| +0#0000000&@66
+|#+0#0000e05&| |S|h|a|r|e|d|-|s|t|a|t|e| |c|o|m@1|a|n|d| |s|u|b|s|t|i|t|u|t|i|o|n|s| |u|s|i|n|g| |t|h|e| |s|y|n|t|a|x| |$|{|<|f|i|l|e|;|}| +0#0000000&@11
+|#+0#0000e05&| |a|r|e| |o|n|l|y| |s|u|p@1|o|r|t|e|d| |b|y| |k|s|h|9|3|,| |n|o|t| |m|k|s|h|.| +0#0000000&@34
+|e+0#af5f00255&|c|h|o| +0#e000002&|$+0#e000e06&|{| +0#0000000&@67
+| +0#e000e06&@7|p+0#af5f00255&|r|i|n|t|f| +0#e000e06&|%|s| |s|t|r| +0#0000000&@53
+|}+0#e000e06&| +0#e000002&|>+0#af5f00255&| +0#0000000&|/|t|m|p|/|s|t|r|f|i|l|e| @58
+|e+0#af5f00255&|c|h|o| +0#e000002&|$+0#e000e06&|{|<+0#af5f00255&|/+0#e000e06&|t|m|p|/|s|t|r|f|i|l|e|;|}| +0#0000000&@52
+@75
+|e+0#af5f00255&|x|i|t| +0#0000000&|0+0#e000002&| +0#0000000&@68
+|~+0#4040ff13&| @73
+| +0#0000000&@56|3|7|,|2|-|9| @7|B|o|t|
diff --git a/runtime/syntax/testdir/dumps/sh_10_99.dump b/runtime/syntax/testdir/dumps/sh_10_99.dump
new file mode 100644
index 0000000000..f97ea3282a
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/sh_10_99.dump
@@ -0,0 +1,20 @@
+| +0&#ffffff0@7|p+0#af5f00255&|r|i|n|t|f| +0#0000000&|'+0#af5f00255&|%+0#e000002&|s|'+0#af5f00255&| +0#0000000&|"+0#af5f00255&|$+0#e000e06&|{|||v|a|l|s|u|b|f|u|n|c| |t|w|e|l|v|e| @6|}|"+0#af5f00255&| +0#0000000&@24
+@8|u+0#00e0e07&|n|l|u|c|k|y|=+0#0000000&|$+0#e000e06&|{|||v|a|l|s|u|b|f|u|n|c| |t|h|i|r|t|e@1|n| +0#0000000&@36
+|}+0#e000e06&| +0#0000000&@73
+@8|t+0#af5f00255&|y|p|e|s|e|t| +0#0000000&|n+0#00e0e07&|o|t|a|f|l|o|a|t|=+0#0000000&|$+0#e000e06&|{|||v|a|l|s|u|b|f|u|n|c| |n|o|t|a|n|u|m|b|e|r| @5|}| +0#0000000&@17
+@8|p+0#af5f00255&|r|i|n|t| +0#e000002&|$+0#e000e06&|u|n|l|u|c|k|y| +0#e000002&|$+0#e000e06&|n|o|t|a|n|u|m|b|e|r| +0#0000000&@40
+@8|$+0#e000e06&|{|||e+0#af5f00255&|c|h|o| +0#e000002&|f|o@1|}+0#e000e06&| +0#0000000&@54
+@8|$+0#e000e06&|{|||e+0#af5f00255&|c|h|o| +0#e000002&|b|a|r| +0#0000000&@55
+|}+0#e000e06&| +0#0000000&@73
+|f+0#af5f00255&|i| +0#0000000&@72
+@75
+|#+0#0000e05&| |=@5| +0#0000000&@66
+|#+0#0000e05&| |S|h|a|r|e|d|-|s|t|a|t|e| |c|o|m@1|a|n|d| |s|u|b|s|t|i|t|u|t|i|o|n|s| |u|s|i|n|g| |t|h|e| |s|y|n|t|a|x| |$|{|<|f|i|l|e|;|}| +0#0000000&@11
+|#+0#0000e05&| |a|r|e| |o|n|l|y| |s|u|p@1|o|r|t|e|d| |b|y| |k|s|h|9|3|,| |n|o|t| |m|k|s|h|.| +0#0000000&@34
+|e+0#af5f00255&|c|h|o| +0#e000002&|$+0#e000e06&|{| +0#0000000&@67
+| +0#e000e06&@7|p+0#af5f00255&|r|i|n|t|f| +0#e000e06&|%|s| |s|t|r| +0#0000000&@53
+|}+0#e000e06&| +0#e000002&|>+0#af5f00255&| +0#0000000&|/|t|m|p|/|s|t|r|f|i|l|e| @58
+|e+0#af5f00255&|c|h|o| +0#e000002&|$+0#e000e06&|{|<+0#af5f00255&|/+0#e000e06&|t|m|p|/|s|t|r|f|i|l|e|;|}| +0#0000000&@52
+@75
+>e+0#af5f00255&|x|i|t| +0#0000000&|0+0#e000002&| +0#0000000&@68
+@57|4|9|,|1| @9|B|o|t|
diff --git a/runtime/syntax/testdir/input/sh_10.sh b/runtime/syntax/testdir/input/sh_10.sh
new file mode 100644
index 0000000000..be463c3da0
--- /dev/null
+++ b/runtime/syntax/testdir/input/sh_10.sh
@@ -0,0 +1,49 @@
+#!/bin/ksh
+
+# This script is a test file for ksh93 shared-state
+# command substitutions (subshares) and mksh value
+# substitutions (valsubs).
+
+# ======
+# Below is subshare syntax supported by both ksh93 and mksh.
+print ${ echo one }
+print ${ echo two
+}
+print ${
+echo three }
+print ${ echo 'four'; }
+print ${ echo 'five' ;}
+print ${ echo 'six'
+}
+print ${ echo 'seven' }
+echo ${ print 'eight' }
+typeset nine=${ pwd; }
+
+# ======
+# Value substitutions of the form ${|command} are only
+# supported by mksh, not ksh93.
+if ! command eval '((.sh.version >= 20070703))' 2>/dev/null; then
+ valsubfunc() {
+ REPLY=$1
+ }
+ echo ${|valsubfunc ten}
+ print "${|valsubfunc eleven;}"
+ printf '%s' "${|valsubfunc twelve }"
+ unlucky=${|valsubfunc thirteen
+}
+ typeset notafloat=${|valsubfunc notanumber }
+ print $unlucky $notanumber
+ ${|echo foo}
+ ${|echo bar
+}
+fi
+
+# ======
+# Shared-state command substitutions using the syntax ${<file;}
+# are only supported by ksh93, not mksh.
+echo ${
+ printf %s str
+} > /tmp/strfile
+echo ${</tmp/strfile;}
+
+exit 0