File: sh_10.sh

package info (click to toggle)
vim 2%3A9.1.1230-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 88,180 kB
  • sloc: ansic: 416,989; cpp: 6,324; makefile: 4,448; java: 2,226; sh: 1,861; perl: 1,419; python: 960; awk: 730; lisp: 501; cs: 458; objc: 369; xml: 247; sed: 8; csh: 6
file content (49 lines) | stat: -rw-r--r-- 1,030 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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