File: run.osh

package info (click to toggle)
omake 0.10.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 14,076 kB
  • sloc: ml: 49,729; ansic: 5,163; makefile: 688; sh: 110
file content (37 lines) | stat: -rw-r--r-- 725 bytes parent folder | download | duplicates (6)
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
# The "exit" command should abort the current shell alias, but not the whole
# execution.

Shell. +=
   true(argv) =
      println($'Running internal "true"')
      exit 0

   false(argv) =
      println($'Running internal "false"')
      exit 1

   false_five(argv) =
      exit 5

   false_or1(argv) =
      false_five || exit 10

   false_or2(argv) =
      false_five || exit 10
      exit 0

ABORT_ON_COMMAND_ERROR = false
false || true

test(prog, val) =
   code = $(shell-code $(prog))
   OK = $(eq $(code), $(val))
   eprintln($"$(prog): expected $(val), got $(code) - $(if $(OK), OK, FAILED!)")
   if $(not $(OK))
      exit 1

test(true, 0)
test(false, 1)
test(false_five, 5)
test(false_or1, 10)
test(false_or2, 10)