blob: be463c3da03e1499fedf0d0bd49b7b46f392c2c2 [file] [log] [blame]
Johnothan Kingadd31ba2024-01-22 11:19:54 -08001#!/bin/ksh
2
3# This script is a test file for ksh93 shared-state
4# command substitutions (subshares) and mksh value
5# substitutions (valsubs).
6
7# ======
8# Below is subshare syntax supported by both ksh93 and mksh.
9print ${ echo one }
10print ${ echo two
11}
12print ${
13echo three }
14print ${ echo 'four'; }
15print ${ echo 'five' ;}
16print ${ echo 'six'
17}
18print ${ echo 'seven' }
19echo ${ print 'eight' }
20typeset nine=${ pwd; }
21
22# ======
23# Value substitutions of the form ${|command} are only
24# supported by mksh, not ksh93.
25if ! command eval '((.sh.version >= 20070703))' 2>/dev/null; then
26 valsubfunc() {
27 REPLY=$1
28 }
29 echo ${|valsubfunc ten}
30 print "${|valsubfunc eleven;}"
31 printf '%s' "${|valsubfunc twelve }"
32 unlucky=${|valsubfunc thirteen
33}
34 typeset notafloat=${|valsubfunc notanumber }
35 print $unlucky $notanumber
36 ${|echo foo}
37 ${|echo bar
38}
39fi
40
41# ======
42# Shared-state command substitutions using the syntax ${<file;}
43# are only supported by ksh93, not mksh.
44echo ${
45 printf %s str
46} > /tmp/strfile
47echo ${</tmp/strfile;}
48
49exit 0