]> ruderich.org/simon Gitweb - coloredstderr/coloredstderr.git/blob - tests/example_redirects.sh
tests: Fix tests when running under coloredstderr.
[coloredstderr/coloredstderr.git] / tests / example_redirects.sh
1 #!/bin/bash
2
3 # Use bash to get consistent test results, /bin/sh can point to multiple
4 # shells with different behaviour.
5
6 # Copyright (C) 2013  Simon Ruderich
7 #
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
12 #
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
21
22 echo write to stderr 1 >&2
23 echo write to stdout 1
24
25 (
26     echo write to stdout which gets redirected to stderr
27 ) >&2
28
29 echo write to stdout 2
30
31 (
32     echo write to stderr which gets redirected to stdout >&2
33 ) 2>&1
34
35 echo write to stdout 3
36
37 (
38     (
39         echo another redirect to stderr
40     ) >&3
41 ) 3>&2