Johnothan King | add31ba | 2024-01-22 11:19:54 -0800 | [diff] [blame^] | 1 | #!/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. |
| 9 | print ${ echo one } |
| 10 | print ${ echo two |
| 11 | } |
| 12 | print ${ |
| 13 | echo three } |
| 14 | print ${ echo 'four'; } |
| 15 | print ${ echo 'five' ;} |
| 16 | print ${ echo 'six' |
| 17 | } |
| 18 | print ${ echo 'seven' } |
| 19 | echo ${ print 'eight' } |
| 20 | typeset nine=${ pwd; } |
| 21 | |
| 22 | # ====== |
| 23 | # Value substitutions of the form ${|command} are only |
| 24 | # supported by mksh, not ksh93. |
| 25 | if ! 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 | } |
| 39 | fi |
| 40 | |
| 41 | # ====== |
| 42 | # Shared-state command substitutions using the syntax ${<file;} |
| 43 | # are only supported by ksh93, not mksh. |
| 44 | echo ${ |
| 45 | printf %s str |
| 46 | } > /tmp/strfile |
| 47 | echo ${</tmp/strfile;} |
| 48 | |
| 49 | exit 0 |