File: example.return

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 (43 lines) | stat: -rwxr-xr-x 829 bytes parent folder | download | duplicates (4)
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
#!/bin/sh
# vim: set filetype=sh :
#        file: example.chk_errors
#   copyright: Bernd Schumacher <bernd.schumacher@hpe.com> (2007-2020)
#     license: GNU General Public License, version 3
# description: test handling of error output
#    see also: test.chk_errors

#set -e # this line can not be used, because we really want to test errors
set -u

. ./ia

# fun1 without shellia
fun1()
{
  echo "msg1 on stdout"
  echo "msg2 on stderr" >&2
  return $1
  echo "msg3 never shown"
  echo "msg4 never shown" >&2
}

eval "$ia_init"

ia_add ":"
ia_stdout "^return=<0>$"
ia_add "echo \"return=<\$?>\""

ia_stdout "^msg1"
ia_stdout "^msg2"
ia_stdout "^exit=42"
ia_add "fun1 42"

ia_stdout "^return=<42>$"
ia_add "echo \"return=<\$?>\""

ia_nocheck -f
ia_add "fun1 24"
ia_stdout "^return=<24>$"
ia_add "echo \"return=<\$?>\""

ia -c