OILS / spec / testdata / top-level-control-flow.sh View on Github | oilshell.org

27 lines, 9 significant
1#!/usr/bin/env bash
2
3# Hm this changes everything -- exit code is 1!
4#set -o errexit
5
6# Inspired by sources/download_functions.sh in Aboriginal:
7
8# wget -t 2 -T 20 -O "$SRCDIR/$FILENAME" "$1" ||
9# (rm -f "$SRCDIR/$FILENAME"; return 2)
10
11# This also causes a warning, but is not fatal.
12# bash gives a warning but mksh doesn't.
13echo SUBSHELL
14false || (rm -f foo; return 2)
15
16echo BREAK
17break
18echo CONTINUE
19continue
20
21echo RETURN
22# dash returns, bash warns that it's invalid.
23# mksh returns.
24return # This is like exit?
25
26# Bash gets here.
27echo DONE