summaryrefslogtreecommitdiffhomepage
path: root/tests/zash/zos-options.sh
blob: 4b890d41e8a5e6109627fc87f5ee1f7a82282f4f (plain)
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
# The z/OS-motivated options and the time keyword, checked on any
# platform: they only add environment variables or format output.
echo "-- time keyword"
norm() { sed -e 's/[0-9][0-9]*/N/g'; }
{ time -p true; } 2>&1 | norm
{ time { sleep 0; :; }; } 2>&1 | norm
{ time -p; } 2>&1 | norm
f() { :; }
{ time f | cat; } 2>/dev/null; echo "status $?"
{ time false; } 2>/dev/null; echo "status $?"
{ ! time -p false; } 2>/dev/null; echo "negated $?"
# the report goes to the shell's stderr, not the timed command's
{ time -p echo out 2>/dev/null; } 2>&1 | norm
time=1; echo "time as a word: $time time"
g() { time -p :; }
sleep 0 &
{ g; } 2>&1 | norm

echo "-- set -o jobnames"
env | grep '^_BPX_' || echo none
set -o jobnames
env | grep '^_BPX_JOBNAME'
/usr/bin/env | grep '^_BPX_JOBNAME'
_BPX_JOBNAME=MINE env | grep '^_BPX_JOBNAME'
set +o jobnames
env | grep -c '^_BPX_JOBNAME'

echo "-- set -o shareas (foreground commands only)"
set -o shareas
env >out
grep '^_BPX_SHAREAS' out
env >all &
wait
grep -c '^_BPX_SHAREAS' all
x=$(env | grep -c '^_BPX_SHAREAS'); echo "cmdsub/pipe: $x"
_BPX_SHAREAS=NO env | grep '^_BPX_SHAREAS'
set +o shareas
set -o | grep -E 'jobnames|shareas|msgid'

echo "-- set -o msgid"
set -o msgid
cd /nonexistent/dir 2>&1 | sed 's/^\(ZSH[0-9]*[EW]\) .*/\1/'
( . /nonexistent/file ) 2>&1 | sed 's/^\(ZSH[0-9]*[EW]\) .*/\1/'
set +o msgid
cd /nonexistent/dir 2>&1 | sed 's/^.*\(cd:\)/\1/'