File: test.block

package info (click to toggle)
shellia 5.7.6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 728 kB
  • sloc: sh: 7,087; makefile: 34
file content (94 lines) | stat: -rwxr-xr-x 1,854 bytes parent folder | download | duplicates (3)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/sh
# vim: set filetype=sh :
#        file: test.block
#   copyright: Bernd Schumacher <bernd.schumacher@hpe.com> (2007-2021)
#     license: GNU General Public License, version 3
# description: test a script that uses a block of commands in one ia_add call
#    see also: example.block

# The following tests are included:
# (1) Run this script without options
# (2) check the logfile

. ./tstlib

# change multiple + (as produced in bash set -x) to just one + (as produced in dash set -x)

shell=""
while [ $# -ne 0 ]; do
  if [ "$1" = "-s" ]; then
    shell="$2"
    shift 2
  else
    echo "ERROR $0: unknown option <$1>" >&2
    exit 1
  fi
done

[ "$shell" ] && set -- "$@" -s "$shell"
[ "$shell" = "mksh" ] && set -- "$@" -u "$UNIFY_mksh"
[ "$shell" = "bash" ] && set -- "$@" -u "$UNIFY_bash"
bug913718_unify UNIFY_posh
[ "$shell" = "posh" ] && set -- "$@" -u "$UNIFY_posh"
[ "$shell" = "busybox sh" ] && set -- "$@" -u "$UNIFY_busybox"
cmd=$(dirname $0)/example.block
bug913718_cmd

ia_logfile="$(mktemp)"
export ia_logfile

rm -f $ia_logfile
check "(1) Run this script without options" "$@" "$cmd" \
"2"

check "(2) check the logfile" "$@" "cat $ia_logfile" \
"|example.block
|s:2"

rm -f $ia_logfile

check "(3) Run this script with -i" "$@" -i "/bin/echo \"

\"" "$cmd -a -i" \
"=== example.block ===
1 if [ \"\" ]; then
  echo \"1\"
else
  echo \"2\"
fi
d ... change dbg: 0
q quit
? [1] 
2
=== example.block ===
1 if [ \"\" ]; then
  echo \"1\"
else
  echo \"2\"
fi
d ... change dbg: 0
q quit
? [q] "

check "(4) check the logfile" "$@" "cat $ia_logfile" \
"|=== example.block ===
|1 if [ \"\" ]; then
|  echo \"1\"
|else
|  echo \"2\"
|fi
|d ... change dbg: 0
|q quit
|? [1] <RETURN>
|s:2
|=== example.block ===
|1 if [ \"\" ]; then
|  echo \"1\"
|else
|  echo \"2\"
|fi
|d ... change dbg: 0
|q quit
|? [q] <RETURN>"

rm -f $ia_logfile