style: add trailing ':' to some test cases
[automake.git] / t / ax / shell-no-trail-bslash.in
blobf785de8a87fd3c77179c7e5ee92a1e1692464d5c
1 #! @AM_TEST_RUNNER_SHELL@
2 # Copyright (C) 2012-2013 Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2, or (at your option)
7 # any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 # A "shell" that chokes on '-c' commands having a trailing '\' character
18 # (possibly followed by whitespace only).  This is to emulate problems
19 # seen in older bash versions (e.g., bash 2.05b).
20 # See also automake bug#10436.
22 set -e
23 set -u
25 am_SHELL=${AM_TESTSUITE_SHELL-'@SHELL@'}
27 tab='   '
28 nl='
30 am_shell_flags=
31 am_shell_command=; unset am_shell_command
32 while test $# -gt 0; do
33   case $1 in
34     # If the shell is invoked by make e.g. as "sh -ec" (seen on
35     # GNU make in POSIX mode) or "sh -ce" (seen on Solaris make).
36     -*c*)
37         am_flg=$(printf '%s\n' "$1" | sed -e 's/^-//' -e 's/c//g')
38         if test x"$am_flg" != x; then
39           am_shell_flags="$am_shell_flags -$am_flg"
40         fi
41         am_shell_command=$2
42         shift;;
43     -?*)
44         am_shell_flags="$am_shell_flags $1";;
45       *)
46         break;;
47   esac
48   shift
49 done
51 if test x${am_shell_command+"set"} != x"set"; then
52   # Some make implementations, like *BSD's, pass the recipes to the shell
53   # through its standard input.  Trying to run our extra checks in this
54   # case would be too tricky, so we just skip them.
55   exec $am_SHELL $am_shell_flags ${1+"$@"}
58 case $am_shell_command in
59   *" "|*"$tab"|*"$nl")
60     am_tweaked_shell_command=$(printf '%s\n' "$am_shell_command" \
61                                  | tr -d " $tab$nl");;
62   *)
63     am_tweaked_shell_command=$am_shell_command;;
64 esac
66 case $am_tweaked_shell_command in
67   *\\)
68     printf '%s\n' "$0: recipe ends with backslash character" >&2
69     printf '%s\n' "=== BEGIN recipe" >&2
70     printf '%s\n' "${am_shell_command-}" >&2
71     printf '%s\n' "=== END recipe" >&2
72     exit 1
73     ;;
74 esac
76 exec $am_SHELL $am_shell_flags -c "$am_shell_command" ${1+"$@"}