maint: update URLs
[autoconf.git] / tests / m4sh.at
blobe9d70b021b92ee0ba2c5e2ce79fc4e406655b2b0
1 #                                                       -*- Autotest -*-
3 AT_BANNER([M4sh.])
5 # Copyright (C) 2000-2017 Free Software Foundation, Inc.
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
20 ## --------------------------- ##
21 ## Re-exec with CONFIG_SHELL.  ##
22 ## --------------------------- ##
24 AT_SETUP([No extra re-exec with CONFIG_SHELL])
25 AT_KEYWORDS([CONFIG_SHELL])
26 AT_DATA_M4SH([script.as],
28 dnl We have to muck with internal details to goad the script into
29 dnl thinking that the default shell is always good enough.
30 m4_define([_AS_DETECT_REQUIRED_BODY], [])dnl
31 m4_define([_AS_DETECT_SUGGESTED_BODY], [])dnl
32 AS_INIT
33 echo foo > ok
34 ]])
35 AT_CHECK_M4SH
36 AT_CHECK([CONFIG_SHELL=/bin/false ./script], [0], [], [])
37 AT_CHECK([test -f ok], [0])
38 rm -f ok
40 AT_CLEANUP
42 AT_SETUP([Forced re-exec with CONFIG_SHELL])
43 AT_KEYWORDS([CONFIG_SHELL])
45 AT_DATA_M4SH([script.as],
46 [[m4_define([_AS_FORCE_REEXEC_WITH_CONFIG_SHELL], [yes])
47 AS_INIT
48 echo foo > sentinel
49 ]])
50 AT_CHECK_M4SH
52 # Calling the script simply 'script' could cause problems with
53 # Solaris /usr/xpg4/bin/sh in the invocation 'sh script' below.
54 mv -f script script2
56 AT_DATA([fake-shell],
57 [[#!/bin/sh
58 echo 'Fake shell executed.'
59 shift # fake shell
60 echo "nargs = @S|@#"
61 for i
63   printf ' :%s:\n' "$i"
64 done
65 ]])
66 chmod a+x fake-shell
68 AT_CHECK([CONFIG_SHELL=./fake-shell ./script2 1 2 4 8], [0],
69 [Fake shell executed.
70 nargs = 4
71  :1:
72  :2:
73  :4:
74  :8:
75 ], [])
76 AT_CHECK([test ! -f sentinel], [0])
77 test ! -f sentinel || rm -f sentinel # Cleanup for next test.
79 AT_CHECK(
80 [CONFIG_SHELL=`pwd`/fake-shell sh script2 a 'b  c' '  d    e '],
81 [0],
82 [Fake shell executed.
83 nargs = 3
84  :a:
85  :b  c:
86  :  d      e :
87 ], [])
88 AT_CHECK([test ! -f sentinel], [0])
89 test ! -f sentinel || rm -f sentinel # Cleanup for next test.
91 AT_CHECK([(PATH=`pwd`:$PATH; export PATH;
92 CONFIG_SHELL=fake-shell script2 '' '&' '!;*' '<($[]@%:@)>,' 'x
93 y  z
94 1 2 3')], [0],
95 [Fake shell executed.
96 nargs = 5
97  ::
98  :&:
99  :!;*:
100  :<($[]@%:@)>,:
101  :x
102 y  z
103 1 2 3:
104 ], [])
105 AT_CHECK([test ! -f sentinel], [0])
106 test ! -f sentinel || rm -f sentinel # Cleanup for next test.
108 AT_CLEANUP
110 AT_SETUP([Configure re-execs self with CONFIG_SHELL])
112 AT_DATA([configure.ac],
113 [[AC_INIT
114 echo foobar >> quux
117 AT_CHECK_AUTOCONF
119 AT_DATA([cfg-sh],
120 [[#!/bin/sh
121 : > cfg-sh-has-run
122 exec sh "@S|@@"
124 chmod a+x cfg-sh
126 AT_CAPTURE_FILE([config.log])
127 # Export CONFIG_SITE to /dev/null to avoid spurious diffs in expected
128 # stdout/stderr.
129 AT_CHECK([env CONFIG_SITE=/dev/null CONFIG_SHELL=./cfg-sh ./configure],
130          [0], [], [])
131 # ./configure re-executed itself.
132 AT_CHECK([test -f cfg-sh-has-run], [0])
133 # And did that not to cause extra execution of later commands.
134 AT_CHECK([cat quux], [0], [foobar
135 ], [])
137 rm -f quux cfg-sh*
138 AT_CLEANUP
141 ## ------------------- ##
142 ## AS_WARN, AS_ERROR.  ##
143 ## ------------------- ##
145 AT_SETUP([AS@&t@_WARN and AS@&t@_ERROR])
146 AT_KEYWORDS([m4sh])
148 dnl without logging
149 AT_DATA_M4SH([script.as],
150 [[AS_INIT
151 AS_WARN([*watch out*])dnl
153 if test x"$die" != x; then
154   AS_ERROR([you're dead])dnl
156   AS_ERROR([really])dnl
159 echo got here
162 AT_CHECK_M4SH
163 AT_CHECK([$CONFIG_SHELL ./script], [],
164 [[got here
165 ]], [[script: WARNING: *watch out*
167 AT_CHECK([die=: $CONFIG_SHELL ./script], [1],
168 [], [[script: WARNING: *watch out*
169 script: error: you're dead
172 dnl with logging
173 rm script
174 AT_DATA_M4SH([script.as],
175 [[AS_INIT
176 m4_define([gone], [AS_ERROR([really])])
177 m4_define([AS_MESSAGE_LOG_FD], [5])
178 exec AS_MESSAGE_LOG_FD>log.txt
179 AS_WARN([*watch out*])dnl
181 if test x"$die" != x; then
182   AS_ERROR([you're dead])dnl
184   AS_ERROR([really])dnl
187 echo got here
188 exec AS_MESSAGE_LOG_FD>&-
191 AT_CHECK_M4SH
192 AT_CHECK([$CONFIG_SHELL ./script], [],
193 [[got here
194 ]], [[script: WARNING: *watch out*
196 AT_CHECK([[grep 'script:[0-9]*: WARNING: \*watch out\*' log.txt]], [], [ignore])
197 AT_CHECK([die=: $CONFIG_SHELL ./script], [1],
198 [], [[script: WARNING: *watch out*
199 script: error: you're dead
201 AT_CHECK([[grep 'script:[0-9]*: WARNING: \*watch out\*' log.txt]], [], [ignore])
202 AT_CHECK([[grep 'script:[0-9]*: error: you'\''re dead' log.txt]], [], [ignore])
204 AT_CLEANUP
206 ## ---------------- ##
207 ## LINENO support.  ##
208 ## ---------------- ##
210 AT_SETUP([LINENO])
211 AT_KEYWORDS([m4sh])
213 # We cannot unset LINENO with Zsh, yet this test case relies on
214 # unsetting LINENO to compare its result when (i) LINENO is supported
215 # and when (ii) it is not.
216 # So just skip if the shell is ZSH.
217 AT_CHECK([test ${ZSH_VERSION+y} && exit 77], ignore)
219 # AT_DATA_LINENO(FILE-NAME,
220 #                UNSET-LINENO = true | false, COUNTER, COUNTER-RE)
221 # ----------------------------------------------------------------
222 # Produce the FILE-NAME M4sh script which uses the COUNTER LINENO or
223 # _oline_, which we can recognized via COUNTER-RE.  Unset LINENO is
224 # UNSET-LINENO.
226 # Use COUNTER, COUNTER-RE = [__LINENO__], [LINENO]
227 #  or                     = [__OLINE__],  [_oline__]
229 # instead of the obvious $LINENO and __oline__, because they would
230 # be replaced in the test suite itself, even before creating these
231 # scripts.  For the same reason, grep for LINENO and _oline__ (sic).
233 # UNSET-LINENO is a shell condition to make sure the scripts have the
234 # same number of lines in the output, so that their outputs be identical.
235 m4_define([AT_DATA_LINENO],
236 [AT_DATA([$1.tas],
237 [[AS@&t@_INIT
238 m4@&t@_divert_text([], [
239 if $2; then
240   AS@&t@_UNSET([LINENO])
243 AS@&t@_LINENO_PREPARE
244 echo "Line: $3"
245 grep 'Line: .*$4' "$[0]" >/dev/null ||
246   AS@&t@_ERROR([cannot find original script])
247 exit 0
249 # If occurrences of $LINENO or __@&t@oline__ were wanted, create them.
250 sed 's/__LINENO__/$''LINENO/g;s/__OLINE__/__''oline__/g' $1.tas >$1.as
251 AT_CHECK([autom4te -l m4sh $1.as -o $1])
252 ])# AT_DATA_LINENO
254 # `_oline_', once processed and ran, produces our reference.
255 # We check that we find ourselves by looking at a string which is
256 # available only in the original script: `_oline_'.
257 AT_DATA_LINENO([reference], [false], [__OLINE__], [_oline__])
258 AT_CHECK([./reference], 0, [stdout])
260 # The reference:
261 mv stdout expout
263 # Now using a maybe-functioning LINENO, with different call conventions.
264 # Be sure to be out of the PATH.
265 AT_CHECK([mkdir test || exit 77])
267 AT_DATA_LINENO([test/test-1], [false], [__LINENO__], [LINENO])
268 AT_CHECK([./test/test-1],                          0, [expout])
269 AT_CHECK([(PATH=test$PATH_SEPARATOR$PATH; export PATH; exec test-1)],
270                                                    0, [expout])
271 AT_CHECK([sh ./test/test-1],                       0, [expout])
273 # Now using a disabled LINENO, with different call conventions.
274 AT_DATA_LINENO([test/test-2], [true], [__LINENO__], [LINENO])
275 AT_CHECK([./test/test-2],                          0, [expout])
276 AT_CHECK([(PATH=test$PATH_SEPARATOR$PATH; export PATH; exec test-2)],
277                                                    0, [expout])
278 AT_CHECK([sh ./test/test-2],                       0, [expout])
280 AT_CLEANUP
283 ## ---------------------- ##
284 ## LINENO stack support.  ##
285 ## ---------------------- ##
287 AT_SETUP([LINENO stack])
288 AT_KEYWORDS([m4sh])
290 AT_DATA_M4SH([script.as],
291 [[AS_INIT
293 AS_LINENO_PUSH([9999])
294 test $as_lineno = 9999 || AS_ERROR([bad as_lineno at depth 1])
295 AS_LINENO_PUSH([8888])
296 test $as_lineno = 9999 || AS_ERROR([bad as_lineno at depth 2])
297 AS_LINENO_POP
298 test $as_lineno = 9999 || AS_ERROR([bad as_lineno at depth 1])
299 AS_LINENO_POP
300 test ${as_lineno+y} && AS_ERROR([as_lineno set at depth 0])
302 AS_EXIT([0])
305 AT_CHECK_M4SH
306 AT_CHECK([$CONFIG_SHELL ./script])
308 AT_CLEANUP
311 ## -------- ##
312 ## AS_BOX.  ##
313 ## -------- ##
315 # Output a framed one-line message.
316 AT_SETUP([AS@&t@_BOX])
317 AT_KEYWORDS([m4sh])
319 AT_DATA_M4SH([script.as],
320 [[AS_INIT
321 echo
322 AS_BOX([Send a simple message, to foobar@example.com])
323 AS_BOX([Send a simple message, to foobar@example.com], [$])
324 m4_define([msg], [$complex])
325 complex='Not quite as simple |$[1]'
326 AS_BOX([msg])
327 AS_BOX([msg], [,])
328 AS_EXIT(0)
331 AT_CHECK_M4SH
332 AT_CHECK([sed -n '/ -\{44\} /,/ -\{44\} /p' script ]dnl
333 [| sed '1 s/.*## -/## -/; 3 s/- ##.*/- ##/'], [],
334 [[## -------------------------------------------- ##
335 ## Send a simple message, to foobar@example.com ##
336 ## -------------------------------------------- ##
339 AT_CHECK([$CONFIG_SHELL ./script], [], [[
340 ## -------------------------------------------- ##
341 ## Send a simple message, to foobar@example.com ##
342 ## -------------------------------------------- ##
343 ## $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ##
344 ## Send a simple message, to foobar@example.com ##
345 ## $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ##
346 ## ----------------------- ##
347 ## Not quite as simple |$1 ##
348 ## ----------------------- ##
349 ## ,,,,,,,,,,,,,,,,,,,,,,, ##
350 ## Not quite as simple |$1 ##
351 ## ,,,,,,,,,,,,,,,,,,,,,,, ##
354 AT_CLEANUP
357 # Strip path from file.
358 AT_SETUP([AS@&t@_BASENAME])
359 AT_KEYWORDS([m4sh])
361 AT_DATA_M4SH([script.as],
362 [[AS_INIT
364 m4_define([BASENAME_TEST],
365 [base=`AS_BASENAME([$1])`
366 test "$base" = "$2" ||
367   echo "basename($1) = $base instead of $2" >&2
369 base=`_AS_BASENAME_SED([$1])`
370 test "$base" = "$2" ||
371   echo "basename_sed($1) = $base instead of $2" >&2])
373 BASENAME_TEST([//1],             [1])
374 BASENAME_TEST([/1],              [1])
375 BASENAME_TEST([./1],             [1])
376 BASENAME_TEST([../../2],         [2])
377 BASENAME_TEST([//1/],            [1])
378 BASENAME_TEST([/1/],             [1])
379 BASENAME_TEST([./1/],            [1])
380 BASENAME_TEST([../../2],         [2])
381 BASENAME_TEST([//1/3],           [3])
382 BASENAME_TEST([/1/3],            [3])
383 BASENAME_TEST([./1/3],           [3])
384 BASENAME_TEST([../../2/3],       [3])
385 BASENAME_TEST([//1/3///],        [3])
386 BASENAME_TEST([/1/3///],         [3])
387 BASENAME_TEST([./1/3///],        [3])
388 BASENAME_TEST([../../2/3///],    [3])
389 BASENAME_TEST([//1//3/],         [3])
390 BASENAME_TEST([/1//3/],          [3])
391 BASENAME_TEST([./1//3/],         [3])
392 BASENAME_TEST([a.c],             [a.c])
393 BASENAME_TEST([a.c/],            [a.c])
394 BASENAME_TEST([/a.c/],           [a.c])
395 BASENAME_TEST([/1/a.c],          [a.c])
396 BASENAME_TEST([/1/a.c/],         [a.c])
397 BASENAME_TEST([/1/../a.c],       [a.c])
398 BASENAME_TEST([/1/../a.c/],      [a.c])
399 BASENAME_TEST([./1/a.c],         [a.c])
400 BASENAME_TEST([./1/a.c/],        [a.c])
401 AS_EXIT(0)
404 AT_CHECK_M4SH
405 AT_CHECK([$CONFIG_SHELL ./script])
407 AT_CLEANUP
410 ## ------------ ##
411 ## AS_DIRNAME.  ##
412 ## ------------ ##
414 # Strip filename component.
415 AT_SETUP([AS@&t@_DIRNAME])
416 AT_KEYWORDS([m4sh])
418 AT_DATA_M4SH([script.as],
419 [[AS_INIT
421 # The EXPR variant is allowed to fail if `expr' was considered as too
422 # weak for us, in which case `as_expr=false'.
423 m4_define([DIRNAME_TEST],
424 [dir=`AS_DIRNAME([$1])`
425 test "$dir" = "$2" || (test -n "$3" && test "$dir" = "$3") ||
426   echo "dirname($1) = $dir instead of $2" >&2
428 if test "$as_expr" != false; then
429   dir=`_AS_DIRNAME_EXPR([$1])`
430   test "$dir" = "$2" || (test -n "$3" && test "$dir" = "$3") ||
431     echo "dirname_expr($1) = $dir instead of $2" >&2
434 dir=`_AS_DIRNAME_SED([$1])`
435 test "$dir" = "$2" || (test -n "$3" && test "$dir" = "$3") ||
436   echo "dirname_sed($1) = $dir instead of $2" >&2])
438 DIRNAME_TEST([/],               [/])
439 DIRNAME_TEST([//],              [//],   [/])
440 DIRNAME_TEST([///],             [/])
441 DIRNAME_TEST([//1],             [//],   [/])
442 DIRNAME_TEST([/1],              [/])
443 DIRNAME_TEST([./1],             [.])
444 DIRNAME_TEST([../../2],         [../..])
445 DIRNAME_TEST([//1/],            [//],   [/])
446 DIRNAME_TEST([/1/],             [/])
447 DIRNAME_TEST([./1/],            [.])
448 DIRNAME_TEST([../../2],         [../..])
449 DIRNAME_TEST([//1/3],           [//1])
450 DIRNAME_TEST([/1/3],            [/1])
451 DIRNAME_TEST([./1/3],           [./1])
452 DIRNAME_TEST([../../2/3],       [../../2])
453 DIRNAME_TEST([//1/3///],        [//1])
454 DIRNAME_TEST([/1/3///],         [/1])
455 DIRNAME_TEST([./1/3///],        [./1])
456 DIRNAME_TEST([../../2/3///],    [../../2])
457 DIRNAME_TEST([//1//3/],         [//1])
458 DIRNAME_TEST([/1//3/],          [/1])
459 DIRNAME_TEST([./1//3/],         [./1])
460 DIRNAME_TEST([../../2//3/],     [../../2])
461 AS_EXIT(0)
464 AT_CHECK_M4SH
465 AT_CHECK([$CONFIG_SHELL ./script])
467 AT_CLEANUP
470 ## ---------------- ##
471 ## AS_SET_CATFILE.  ##
472 ## ---------------- ##
474 AT_SETUP([AS@&t@_SET_CATFILE])
475 AT_KEYWORDS([m4sh])
477 AT_DATA_M4SH([script.as],
478 [[AS_INIT
480 # CATFILE_TEST(DIR, FILE, EXPECTED)
481 m4_define([CATFILE_TEST],
482 [# AS_SET_CATFILE works and can be used in a compound list.
483 if AS_SET_CATFILE([var], [$1], [$2]) \
484    && test "$var" = $3; then :; else
485   echo "catfile($1, $2) = $var != $3" >&2
487 # AS_SET_CATFILE can use non-literals in its arguments.
488 varname=var2
489 dirpart=$1
490 filepart=$2
491 if AS_SET_CATFILE([$varname], [$dirpart], [$filepart]) \
492    && test "$var2" = $3; then :; else
493   echo "catfile($dirpart, $filepart) = $var2 != $3" >&2
497 CATFILE_TEST([dir], [file], [dir/file])
498 CATFILE_TEST([.], [file], [file])
499 CATFILE_TEST([dir], [.], [dir])
500 CATFILE_TEST([dir], [/abs/file], [/abs/file])
501 CATFILE_TEST([dir], [C:/abs/file], [C:/abs/file])
502 CATFILE_TEST(["dir  name"], ['file  name'], ['dir  name/file  name'])
504 AS_EXIT(0)
507 AT_CHECK_M4SH
508 AT_CHECK([$CONFIG_SHELL ./script])
510 AT_CLEANUP
513 ## --------- ##
514 ## AS_ECHO.  ##
515 ## --------- ##
517 # Print literal strings, with/without newline.
518 AT_SETUP([AS@&t@_ECHO and AS@&t@_ECHO_N])
519 AT_KEYWORDS([m4sh])
521 AT_DATA_M4SH([script.as],
522 [[AS_INIT
524 m4_define([ECHO_TEST],
525 [echo=`AS_ECHO(['$1'])`
526 test "X$echo" = 'X$1' ||
527   echo "AS@&t@_ECHO('"'$1'"') outputs '$echo'" >&2
529 echo=`AS_ECHO_N(['$1'])`
530 test "X$echo" = 'X$1' ||
531   echo "AS@&t@_ECHO_N('"'$1'"') outputs '$echo'" >&2])
533 ECHO_TEST([-])
534 ECHO_TEST([--])
535 ECHO_TEST([---...---])
536 ECHO_TEST([      ])
537 ECHO_TEST([-e])
538 ECHO_TEST([-E])
539 ECHO_TEST([-n])
540 ECHO_TEST([-n -n])
541 ECHO_TEST([-e -n])
542 ECHO_TEST([ab\ncd])
543 ECHO_TEST([abcd\c])
544 ECHO_TEST([\a\b\c\f\n\r\t\v\"\])
545 ECHO_TEST([ab
548 ECHO_TEST([
549  ])
550 ECHO_TEST([
551 \c])
552 AS_EXIT(0)
555 AT_CHECK_M4SH
556 AT_CHECK([$CONFIG_SHELL ./script])
558 AT_CLEANUP
562 ## ----------------- ##
563 ## AS_EXECUTABLE_P.  ##
564 ## ----------------- ##
566 # Check for executable regular files.
567 AT_SETUP([AS@&t@_EXECUTABLE_P])
568 AT_KEYWORDS([m4sh])
570 AT_DATA_M4SH([script.as],
571 [[AS_INIT
573 if AS_EXECUTABLE_P([/]); then
574   echo fail
575 else
576   echo 1
578 cat > foo.sh <<\EOF || AS_EXIT([1])
579 #!/bin/sh
580 exit 0
582 # File systems like FAT tend to fake executable permissions on all files.
583 # At this point, foo.sh should be executable iff permissions are faked.
584 AS_EXECUTABLE_P([foo.sh])
585 st1=$?
586 (./foo.sh) >/dev/null 2>&1
587 st2=$?
588 case $st1:$st2 in
589   *[[1-9]]*:*[[1-9]]* | 0:0 ) echo 2 ;;
590   *) echo "fail ($st1:$st2)" ;;
591 esac
592 # Now things better be executable
593 chmod a+x foo.sh || AS_EXIT([2])
594 mkdir 'two  spaces' || AS_EXIT([3])
595 'two  spaces'/../foo.sh || AS_EXIT([4])
596 if AS_EXECUTABLE_P(["two  spaces/../foo.sh"]); then
597   echo 3
598 else
599   echo fail
603 AT_CHECK_M4SH
604 AT_CHECK([$CONFIG_SHELL ./script], [],
610 AT_CLEANUP
614 ## --------- ##
615 ## AS_EXIT.  ##
616 ## --------- ##
618 # Exit scripts with given status.
619 AT_SETUP([AS@&t@_EXIT])
620 AT_KEYWORDS([m4sh AS@&t@_SET_STATUS])
622 AT_DATA_M4SH([script.as],
623 [[AS_INIT
624 test x${1} = xa && AS_EXIT
625 test x${1} = xb && AS_EXIT([${2}])
626 test x${1} = xc && { AS_SET_STATUS([${2}]); AS_EXIT; }
627 test x${1} = xd && trap 's=$?; echo $s; AS_EXIT([$s])' 0
628 test x${2} = xe && set -e
629 test $[#] -gt 0 || AS_EXIT
630 AS_SET_STATUS([3])
631 dnl Solaris /bin/sh 'set -e' doesn't react to failed function calls
632 test x${2} = xe \
633   && { echo 'skipping rest of test: set -e support is lousy'; exit 77; }
634 AS_SET_STATUS([4])
637 AT_CHECK_M4SH
638 AT_CHECK([$CONFIG_SHELL ./script], [1])
639 AT_CHECK([$CONFIG_SHELL ./script ''], [4])
640 AT_CHECK([$CONFIG_SHELL ./script a], [0])
641 AT_CHECK([$CONFIG_SHELL ./script b], [0])
642 AT_CHECK([$CONFIG_SHELL ./script b 0], [0])
643 AT_CHECK([$CONFIG_SHELL ./script b 2], [2])
644 AT_CHECK([$CONFIG_SHELL ./script c 0], [0])
645 AT_CHECK([$CONFIG_SHELL ./script c 2], [2])
646 AT_CHECK([$CONFIG_SHELL ./script d], [4], [[4
648 dnl If we got to this point without a FAIL, then AS_EXIT at least works.
649 dnl The rest of this test relies on semi-decent 'set -e' support, even
650 dnl though m4sh in general should not try to rely on it because of
651 dnl portability nightmares on what constructs are considered errors across
652 dnl various shells; therefore, an overall SKIP result is desirable on
653 dnl broken shells like Solaris /bin/sh.
654 AT_CHECK([$CONFIG_SHELL ./script '' e], [3])
655 AT_CHECK([$CONFIG_SHELL ./script d e], [3], [stdout])
656 dnl NetBSD sh fails to output on stderr here.
657 AT_CHECK([grep 3 stdout || exit 77], [], [ignore])
659 AT_CLEANUP
663 ## ------------ ##
664 ## AS_MKDIR_P.  ##
665 ## ------------ ##
667 # Build nested dirs.
668 AT_SETUP([AS@&t@_MKDIR_P])
669 AT_KEYWORDS([m4sh])
671 AT_DATA_M4SH([script.as],
672 [[AS_INIT
674 pwd=`pwd`
675 set -e
676 # Absolute
677 AS_MKDIR_P(["$pwd/1/2/3/4/5/6"])
678 test -d "$pwd/1/2/3/4/5/6" ||
679   AS_ERROR([$pwd/1/2/3/4/5/6 has not been properly created])
680 # Relative
681 AS_MKDIR_P(["a/b/c/d/e/f"])
682 test -d a/b/c/d/e/f ||
683   AS_ERROR([a/b/c/d/e/f has not been properly created])
684 AS_EXIT(0)
687 AT_CHECK_M4SH
688 AT_CHECK([$CONFIG_SHELL ./script])
690 AT_CLEANUP
695 ## -------------------- ##
696 ## AS_VERSION_COMPARE.  ##
697 ## -------------------- ##
699 # Three-way version comparison.
700 AT_SETUP([AS@&t@_VERSION_COMPARE])
701 AT_KEYWORDS([m4sh])
703 AT_DATA_M4SH([script.as],
704 [[AS_INIT
706 m4_define([VERSION_COMPARE_TEST],
707 [AS_VERSION_COMPARE([$1], [$3], [result='<'], [result='='], [result='>'])
708 test "X$result" = "X$2" ||
709   AS_ERROR([version $1 $result $3; should be $1 $2 $3])
710 m4_if([$1], <,
711 [AS_VERSION_COMPARE([$3], [$1], [result='<'], [result='='], [result='>'])
712 test "X$result" = "X>" ||
713   AS_ERROR([version $3 $result $1; should be $3 > $1])])])
715 VERSION_COMPARE_TEST([], =, [])
716 VERSION_COMPARE_TEST([1.0], =, [1.0])
717 VERSION_COMPARE_TEST([alpha-1.0], =, [alpha-1.0])
719 # These tests are taken from libc/string/tst-svc.expect.
720 tst_svc_expect='
721   000 001 00 00a 01 01a 0 0a 2.8 2.8-0.4 20 21 22 212 CP037 CP345 CP1257
722   foo foo-0.4 foo-0.4a foo-0.4b foo-0.5 foo-0.10.5 foo-3.01 foo-3.0
723   foo-3.0.0 foo-3.0.1 foo-3.2 foo-3.10 foo00 foo0
725 test1=''
726 for test2 in $tst_svc_expect; do
727   VERSION_COMPARE_TEST([$test1], <, [$test2])
728   test1=$test2
729 done
731 AS_EXIT(0)
734 AT_CHECK_M4SH
735 AT_CHECK([$CONFIG_SHELL ./script])
737 AT_CLEANUP
742 ## ------- ##
743 ## as_me.  ##
744 ## ------- ##
746 AT_SETUP([as_me])
747 AT_KEYWORDS([m4sh])
749 AT_DATA_M4SH([script.as],
750 [[AS_INIT
751 AS_ME_PREPARE
752 test "$as_me" = script || AS_ECHO([["incorrect value of \$as_me: $as_me"]])
755 AT_CHECK_M4SH
756 AT_CHECK([$CONFIG_SHELL ./script])
758 AT_CLEANUP
763 ## ----------------------------- ##
764 ## Negated classes in globbing.  ##
765 ## ----------------------------- ##
767 # According to https://www.in-ulm.de/~mascheck/bourne/, all shells with
768 # functions also support `[!...]'.  But `[^...]' is not universally supported.
770 AT_SETUP([Negated classes in globbing])
771 AT_KEYWORDS([m4sh])
773 AT_DATA_M4SH([script.as],
774 [[AS_INIT
776 case 'with!two!bangs' in
777   *[[!a-z]]*) ;;
778            *) AS_ERROR([[`*[!a-z]*' didn't match `with!two!bangs']]);;
779 esac
781 case without in
782   *[[!a-z]]*) AS_ERROR([[`*[!a-z]*' matched `without']]);;
783 esac
786 AT_CHECK_M4SH
787 AT_CHECK([$CONFIG_SHELL ./script])
789 AT_CLEANUP
791 ## ---------------------------- ##
792 ## Null variable substitution.  ##
793 ## ---------------------------- ##
795 # According to https://www.in-ulm.de/~mascheck/bourne/, all shells with
796 # functions also support `${a:-b}'.
798 AT_SETUP([Null variable substitution])
799 AT_KEYWORDS([m4sh])
801 AT_DATA_M4SH([script.as],
802 [[AS_INIT
804 AS_UNSET([a])
807 case ${a:-x}${b:-y}${c:-z} in
808   xy.) ;;
809   *) exit 1 ;;
810 esac
811 case ${a-x}${b-y}${c-z} in
812   x.) ;;
813   *) exit 2 ;;
814 esac
816 case ${a+x}${b+y}${c+z} in
817   yz) ;;
818   *) exit 3 ;;
819 esac
820 case ${a:+x}${b:+y}${c:+z} in
821   z) ;;
822   *) exit 4 ;;
823 esac
825 case ${a=x}${b=y}${c=z} in
826   x.) ;;
827   *) exit 5 ;;
828 esac
829 AS_UNSET([a])
830 case ${a:=x}${b:=y}${c:=z} in
831   xy.) ;;
832   *) exit 6 ;;
833 esac
834 case $a$b$c in
835   xy.) ;;
836   *) exit 7 ;;
837 esac
838 AS_UNSET([a])
841 (: ${a?oops}; echo fail) 2>err && exit 8
842 grep oops err >/dev/null || exit 9
843 test "${b?oops}" = '' || exit 10
844 test "${c?oops}" = . || exit 11
845 (: ${a:?oops}; echo fail) 2>err && exit 12
846 grep oops err >/dev/null || exit 13
847 (: ${b:?oops}; echo fail) 2>err && exit 14
848 grep oops err >/dev/null || exit 15
849 test "${c:?oops}" = . || exit 16
852 AT_CHECK_M4SH
853 AT_CHECK([$CONFIG_SHELL ./script])
855 AT_CLEANUP
858 ## ------------------- ##
859 ## Functions Support.  ##
860 ## ------------------- ##
862 # All m4sh scripts require function support.
864 AT_SETUP([Functions Support])
865 AT_KEYWORDS([m4sh])
867 AT_DATA_M4SH([script.as],
868 [[AS_INIT
869 AS_LINENO_PREPARE
871 func_return () {
872   (exit $1)
875 func_success () {
876   func_return 0
879 func_failure () {
880   func_return 1
883 if func_success; then
884   if func_failure; then
885     AS_ERROR([func_failure passed])
886   fi
887 else
888   AS_ERROR([func_success failed])
892 AT_CHECK_M4SH
893 AT_CHECK([$CONFIG_SHELL ./script])
895 AT_CLEANUP
900 ## ------------------------------ ##
901 ## Functions and return Support.  ##
902 ## ------------------------------ ##
904 # All m4sh scripts require working return within functions.
906 AT_SETUP([Functions and return Support])
907 AT_KEYWORDS([m4sh])
909 AT_DATA_M4SH([script.as],
910 [[AS_INIT
911 AS_LINENO_PREPARE
913 func_success () {
914   return 0
917 func_failure () {
918   return 1
921 if func_success; then
922   if func_failure; then
923     AS_ERROR([func_failure passed])
924   fi
925 else
926   AS_ERROR([func_success failed])
930 AT_CHECK_M4SH
931 AT_CHECK([$CONFIG_SHELL ./script])
933 AT_CLEANUP
936 ## --------------------------- ##
937 ## Nested AS_REQUIRE_SHELL_FN. ##
938 ## --------------------------- ##
940 # Hypothesis: M4sh expands nested AS_REQUIRE_SHELL_FN
941 # separately.
943 AT_SETUP([Nested AS@&t@_REQUIRE_SHELL_FN])
944 AT_KEYWORDS([m4sh])
946 AT_DATA_M4SH([script.as], [[dnl
947 m4_define([INIT], [oops])dnl
948 AS_INIT
950 m4_defun([TEST_FUNC2_BODY], [
954 m4_defun([TEST_FUNC1_BODY], [
955 AS_REQUIRE_SHELL_FN([test_func2], [], [TEST_FUNC2_BODY])
959 AS_REQUIRE_SHELL_FN([test_func1], [], [TEST_FUNC1_BODY])
960 test_func2
963 AT_CHECK_M4SH
964 AT_CHECK([$CONFIG_SHELL ./script])
966 AT_CLEANUP
969 ## ------------------- ##
970 ## Nested AS_REQUIRE.  ##
971 ## ------------------- ##
973 # Hypothesis: M4sh expands the requirements of AS_REQUIRE in the
974 # requested diversion, even if other AS_REQUIREs are interleaved.
976 AT_SETUP([Nested AS@&t@_REQUIRE])
977 AT_KEYWORDS([m4sh])
979 AT_DATA_M4SH([script.as], [[dnl
980 AS_INIT
982 m4_defun([in_fn_diversion], still_in_m4sh_init_fn=yes)
983 m4_defun([not_in_fn_diversion], still_in_m4sh_init_fn=no)
985 m4_defun([NESTED], [nested_require_in_fn_diversion=$still_in_m4sh_init_fn])
987 m4_defun([OUTER], [AS_REQUIRE([NESTED])dnl
988 outer_require_in_fn_diversion=$still_in_m4sh_init_fn])
990 m4_defun([test_init], [
991 AS_REQUIRE([in_fn_diversion], , [M4SH-INIT-FN])
992 AS_REQUIRE([OUTER], , [M4SH-INIT-FN])
993 AS_REQUIRE([not_in_fn_diversion], , [M4SH-INIT-FN])
996 test_init
997 if test $outer_require_in_fn_diversion != yes; then AS_EXIT([1]); fi
998 if test $nested_require_in_fn_diversion != no; then AS_EXIT([1]); fi
1001 AT_CHECK_M4SH
1002 AT_CHECK([$CONFIG_SHELL ./script])
1004 AT_CLEANUP
1007 ## ------------------------------------ ##
1008 ## AS_REQUIRE_SHELL_FN and m4_require.  ##
1009 ## ------------------------------------ ##
1011 # Hypothesis: M4sh expands the requirements of AS_REQUIRE_SHELL_FN
1012 # in M4SH-INIT-FN.  This changed after Autoconf 2.63.
1014 AT_SETUP([AS@&t@_REQUIRE_SHELL_FN and m4@&t@_require])
1015 AT_KEYWORDS([m4sh])
1017 AT_DATA_M4SH([script.as], [[dnl
1018 AS_INIT
1020 m4_defun([in_m4_sh_init], still_in_m4sh_init=yes)
1021 m4_defun([not_in_m4_sh_init], still_in_m4sh_init=no)
1023 m4_defun([error_if_emitted_in_m4sh_init], [
1024   if test x$still_in_m4sh_init = xyes; then
1025     AS_ERROR([requirement emitted in M4SH-INIT])
1026   fi
1029 m4_defun([TEST_FUNC_BODY], [
1030 m4_require([error_if_emitted_in_m4sh_init])
1031 : echo in shell function, with parameter = [$]1
1035 m4_defun([test_init], [
1036 AS_REQUIRE([in_m4_sh_init], , [M4SH-INIT-FN])
1037 AS_REQUIRE_SHELL_FN([test_func], [], [TEST_FUNC_BODY])
1038 AS_REQUIRE([not_in_m4_sh_init])
1041 test_init
1042 test_func parameter1
1045 AT_CHECK_M4SH
1046 AT_CHECK([$CONFIG_SHELL ./script])
1048 AT_CLEANUP
1051 ## -------------- ##
1052 ## AS_HELP_STRING ##
1053 ## -------------- ##
1055 AT_SETUP([AS@&t@_HELP_STRING])
1056 AT_KEYWORDS([m4sh m4@&t@_text_wrap m4@&t@_expand])
1058 AT_DATA_M4SH([script.as],
1059 [[AS_INIT
1061 echo "AS_HELP_STRING([--an-option],[some text])"
1062 echo "AS_HELP_STRING([--another-much-longer-option],
1063 [some other text which should wrap at our default of 80 characters.])"
1064 echo "AS_HELP_STRING([--fooT=barT], [foo bar])"
1065 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@], [foo bar])"
1066 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@123456789], [foo bar])"
1067 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@1234567890], [foo bar])"
1068 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@12345678901], [foo bar])"
1069 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@123456789012], [foo bar])"
1070 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@1234567890123], [foo bar])"
1071 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@],
1072 [some other text which should wrap at our default of 80 characters.])"
1073 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@123456789],
1074 [some other text which should wrap at our default of 80 characters.])"
1075 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@1234567890],
1076 [some other text which should wrap at our default of 80 characters.])"
1077 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@12345678901],
1078 [some other text which should wrap at our default of 80 characters.])"
1079 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@123456789012],
1080 [some other text which should wrap at our default of 80 characters.])"
1081 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@1234567890123],
1082 [some other text which should wrap at our default of 80 characters.])"
1083 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@],
1084 [some other @<][:@ex@:][>@ which should wrap at our default of 80 characters.])"
1085 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@123456789],
1086 [some other @<][:@ex@:][>@ which should wrap at our default of 80 characters.])"
1087 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@1234567890],
1088 [some other @<][:@ex@:][>@ which should wrap at our default of 80 characters.])"
1089 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@12345678901],
1090 [some other @<][:@ex@:][>@ which should wrap at our default of 80 characters.])"
1091 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@123456789012],
1092 [some other @<][:@ex@:][>@ which should wrap at our default of 80 characters.])"
1093 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@1234567890123],
1094 [some other @<][:@ex@:][>@ which should wrap at our default of 80 characters.])"
1095 echo "AS_HELP_STRING([[--foo[=bar]]],
1096 [some other t[]t which should wrap at our default of 80 characters.])"
1097 echo "AS_HELP_STRING([[--foo[=bar]123456789]],
1098 [some other t[]t which should wrap at our default of 80 characters.])"
1099 echo "AS_HELP_STRING([[--foo[=bar]1234567890]],
1100 [some other t[]t which should wrap at our default of 80 characters.])"
1101 echo "AS_HELP_STRING([[--foo[=bar]12345678901]],
1102 [some other t[]t which should wrap at our default of 80 characters.])"
1103 echo "AS_HELP_STRING([[--foo[=bar]123456789012]],
1104 [some other t[]t which should wrap at our default of 80 characters.])"
1105 echo "AS_HELP_STRING([[--foo[=bar]1234567890123]],
1106 [some other t[]t which should wrap at our default of 80 characters.])"
1107 m4_define([mac], [MACRO])dnl
1108 echo "AS_HELP_STRING([--mac], [mac])"
1109 echo "AS_HELP_STRING([--o1, --o2], [two
1110 options,        one  description])"
1111 echo "AS_HELP_STRING([[[--o3, --o4]]], [comma inside literal quoting])"
1112 echo "AS_HELP_STRING([--tune1], [check out the tuned formatting],
1113 [            ])"
1114 echo "AS_HELP_STRING([--tune2], [check out the tuned formatting],
1115 [12])"
1116 echo "AS_HELP_STRING([--tune3], [check out the tuned formatting],
1117 [], [40])"
1118 echo "AS_HELP_STRING([--tune4], [check out the tuned formatting],
1119 [12], [40])"
1122 AT_CHECK_M4SH
1123 AT_CHECK([$CONFIG_SHELL ./script], [0],
1124 [[  --an-option             some text
1125   --another-much-longer-option
1126                           some other text which should wrap at our default of
1127                           80 characters.
1128   --fooT=barT             foo bar
1129   --foo[=bar]             foo bar
1130   --foo[=bar]123456789    foo bar
1131   --foo[=bar]1234567890   foo bar
1132   --foo[=bar]12345678901  foo bar
1133   --foo[=bar]123456789012 foo bar
1134   --foo[=bar]1234567890123
1135                           foo bar
1136   --foo[=bar]             some other text which should wrap at our default of
1137                           80 characters.
1138   --foo[=bar]123456789    some other text which should wrap at our default of
1139                           80 characters.
1140   --foo[=bar]1234567890   some other text which should wrap at our default of
1141                           80 characters.
1142   --foo[=bar]12345678901  some other text which should wrap at our default of
1143                           80 characters.
1144   --foo[=bar]123456789012 some other text which should wrap at our default of
1145                           80 characters.
1146   --foo[=bar]1234567890123
1147                           some other text which should wrap at our default of
1148                           80 characters.
1149   --foo[=bar]             some other [ex] which should wrap at our default of
1150                           80 characters.
1151   --foo[=bar]123456789    some other [ex] which should wrap at our default of
1152                           80 characters.
1153   --foo[=bar]1234567890   some other [ex] which should wrap at our default of
1154                           80 characters.
1155   --foo[=bar]12345678901  some other [ex] which should wrap at our default of
1156                           80 characters.
1157   --foo[=bar]123456789012 some other [ex] which should wrap at our default of
1158                           80 characters.
1159   --foo[=bar]1234567890123
1160                           some other [ex] which should wrap at our default of
1161                           80 characters.
1162   --foo[=bar]             some other t[]t which should wrap at our default of
1163                           80 characters.
1164   --foo[=bar]123456789    some other t[]t which should wrap at our default of
1165                           80 characters.
1166   --foo[=bar]1234567890   some other t[]t which should wrap at our default of
1167                           80 characters.
1168   --foo[=bar]12345678901  some other t[]t which should wrap at our default of
1169                           80 characters.
1170   --foo[=bar]123456789012 some other t[]t which should wrap at our default of
1171                           80 characters.
1172   --foo[=bar]1234567890123
1173                           some other t[]t which should wrap at our default of
1174                           80 characters.
1175   --MACRO                 mac
1176   --o1, --o2              two options, one description
1177   [--o3, --o4]            comma inside literal quoting
1178   --tune1   check out the tuned formatting
1179   --tune2   check out the tuned formatting
1180   --tune3                 check out the
1181                           tuned
1182                           formatting
1183   --tune4   check out the tuned
1184             formatting
1187 AT_CLEANUP
1190 ## ------------------- ##
1191 ## AS_IF and AS_CASE.  ##
1192 ## ------------------- ##
1194 AT_SETUP([AS@&t@_IF and AS@&t@_CASE])
1195 AT_KEYWORDS([m4sh m4@&t@_map_args_pair])
1197 AT_DATA_M4SH([script.as], [[dnl
1198 AS_INIT
1199 # Syntax checks: cope with empty arguments.
1200 AS_IF([:], [], [echo wrong])
1201 AS_IF([:], [echo one], [echo wrong])
1202 AS_IF([false], [echo wrong], [echo two])
1203 AS_IF([false], [echo wrong])
1204 # n-ary version
1205 AS_IF([false], [echo wrong],
1206       [:], [echo three])
1207 AS_IF([false], [echo wrong],
1208       [:], [echo four],
1209       [echo wrong])
1210 AS_IF([false], [echo wrong],
1211       [false], [echo wrong])
1212 AS_IF([false], [echo wrong],
1213       [false], [echo wrong],
1214       [echo five])
1215 AS_IF([false], [echo wrong],
1216       [false], [echo wrong],
1217       [:], [echo six],
1218       [echo wrong])
1219 AS_CASE([foo])
1220 AS_CASE([foo], [echo seven])
1221 AS_CASE([foo],
1222         [foo], [echo eight],
1223         [echo wrong])
1224 AS_CASE([foo],
1225         [foo], [echo nine],
1226         [*],   [echo wrong])
1227 AS_CASE([foo],
1228         [bar], [echo wrong],
1229         [foo], [echo ten],
1230         [*],   [echo wrong])
1232 # check for nesting, lists, and side effects, and quoting robustness
1233 empty=
1234 AS_IF([AS_IF([$empty], [echo eleven])]) && AS_CASE([foo]) && echo twelve
1235 rm -f file
1236 AS_IF([touch file; false]) && echo thirteen
1237 test -f file && echo fourteen
1238 rm -f file
1239 AS_CASE([`touch file; false`]) && test -f file && echo fifteen
1240 dnl The next line is badly underquoted; don't intentionally copy this style.
1241 AS_CASE([foo], [foo], m4_do(AS_CASE([bar], [bar], [echo sixteen])))
1242 dnl Handle blank arguments.
1243 AS_IF([false], [:], [ ]) && AS_CASE([foo], [foo], []
1244 ) && echo seventeen
1245 m4_define([empty])AS_IF([:], [empty]
1246 ) && AS_CASE([foo], [foo], [empty]) && echo eighteen
1247 dnl Allow for users that don't know to avoid trailing whitespace
1248 AS_IF([:
1249 ], [echo nineteen])
1250 dnl We can't handle AS_IF([false], [:], [empty]) unless m4_expand is
1251 dnl taught how to handle m4_require.  The user is responsible for
1252 dnl avoiding the syntax error in that case.
1254 # check that require works correctly
1255 m4_for([n], 1, 9, [],
1256 [m4_defun([FOO]n, [foo]n[=]n)dnl
1257 m4_defun([BAR]n,
1258          [m4_require([FOO]]n[)dnl
1259 bar]n[=]n)[]dnl
1262 AS_IF([:], [BAR1])
1263 echo "foo1=$foo1 bar1=$bar1"
1264 AS_IF([:], [], [BAR2])
1265 echo "foo2=$foo2 bar2=$bar2"
1266 AS_IF([false], [BAR3])
1267 echo "foo3=$foo3 bar3=$bar3"
1268 AS_IF([false], [], [BAR4])
1269 echo "foo4=$foo4 bar4=$bar4"
1270 AS_CASE([x], [x], [BAR5])
1271 echo "foo5=$foo5 bar5=$bar5"
1272 AS_CASE([x], [y], [BAR6])
1273 echo "foo6=$foo6 bar6=$bar6"
1274 AS_CASE([x],
1275         [x], [:],
1276         [BAR7])
1277 echo "foo7=$foo7 bar7=$bar7"
1278 AS_CASE([x],
1279         [y], [:],
1280         [BAR8])
1281 echo "foo8=$foo8 bar8=$bar8"
1282 AS_CASE([x],
1283         [y], [:],
1284         [x], [BAR9])
1285 echo "foo9=$foo9 bar9=$bar9"
1288 AT_CHECK_M4SH
1289 AT_CHECK([$CONFIG_SHELL ./script], [0], [[one
1291 three
1292 four
1293 five
1295 seven
1296 eight
1297 nine
1299 eleven
1300 twelve
1301 thirteen
1302 fourteen
1303 fifteen
1304 sixteen
1305 seventeen
1306 eighteen
1307 nineteen
1308 foo1=1 bar1=1
1309 foo2=2 bar2=
1310 foo3=3 bar3=
1311 foo4=4 bar4=4
1312 foo5=5 bar5=5
1313 foo6=6 bar6=
1314 foo7=7 bar7=
1315 foo8=8 bar8=8
1316 foo9=9 bar9=9
1319 dnl stress test for large number of conditionals
1320 dnl too large, and we start tickling shell bugs
1321 m4_pushdef([limit], [1000])dnl
1322 AT_DATA_M4SH([script.as], [[dnl
1323 AS_INIT
1324 AS_IF(m4_shift(m4_for([i], [1], ]limit[, [], [, test $[1] = i, echo i])))
1325 AS_IF(m4_shift(m4_for([i], [1], ]limit[, [], [, test $[1] = i, echo i])),
1326       [echo default])
1327 AS_CASE([$[1]]m4_for([i], [1], ]limit[, [], [, i, echo i]))
1328 AS_CASE([$[1]]m4_for([i], [1], ]limit[, [], [, i, echo i]), [echo default])
1331 dnl Add --force so autom4te doesn't think `script' is still up to date.
1332 AT_CHECK_M4SH([--force])
1333 AT_CHECK([$CONFIG_SHELL ./script 1], [0], [[1
1338 AT_CHECK([$CONFIG_SHELL ./script limit], [0], [limit
1339 limit
1340 limit
1341 limit
1343 AT_CHECK([$CONFIG_SHELL ./script default], [0], [[default
1344 default
1346 m4_popdef([limit])
1348 AT_CLEANUP
1351 ## -------- ##
1352 ## AS_FOR.  ##
1353 ## -------- ##
1355 AT_SETUP([AS@&t@_FOR])
1356 AT_KEYWORDS([m4sh])
1358 AT_DATA_M4SH([script.as], [[dnl
1359 AS_INIT
1361 # Simple checks.
1362 AS_FOR([m4var], [shvar], [a],
1363 [echo "m4var $shvar"])
1364 AS_FOR([m4var], [shvar], [b c],
1365 [echo "m4var $shvar"])
1366 list='d e'
1367 AS_FOR([m4var], [shvar], [$list],
1368 [echo "m4var $shvar"])
1369 AS_FOR([m4var], [shvar], ["$list"],
1370 [echo "m4var $shvar"])
1371 AS_FOR([m4var], [shvar], ['$list'],
1372 [echo "m4var $shvar"])
1373 AS_FOR([m4var], [shvar], [\'],
1374 [echo "m4var $shvar"])
1376 # Syntax checks: cope with empty/blank arguments.
1377 set f g
1378 AS_FOR([], [shvar], [],
1379 [echo "m4_defn([]) $shvar"])
1380 rm -f file
1381 AS_FOR([], [shvar], [`touch file`])
1382 test -f file || exit 1
1383 AS_FOR([], [shvar], [], [ ])
1384 m4_define([empty])AS_FOR([], [shvar], [], [empty])
1386 # Check that break works.
1387 while :
1389   AS_FOR([m4var], [shvar], [h i],
1390     [echo "m4var"; break 2])
1391   exit 1
1392 done
1393 while :
1395   AS_FOR([m4var], [shvar], [j],
1396     [echo "m4var"; break 2])
1397   exit 1
1398 done
1401 AT_CHECK_M4SH
1402 AT_CHECK([$CONFIG_SHELL ./script], [0], [[a a
1403 b b
1404 c c
1405 d d
1406 e e
1407 d e d e
1408 $list $list
1409 ' '
1410 f f
1411 g g
1416 AT_CLEANUP
1419 ## --------------- ##
1420 ## AS_LITERAL_IF.  ##
1421 ## --------------- ##
1423 AT_SETUP([AS@&t@_LITERAL_IF])
1424 AT_KEYWORDS([m4sh AS@&t@_LITERAL_WORD_IF AS@&t@_LITERAL_HEREDOC_IF])
1426 AT_DATA_M4SH([script.as], [[dnl
1427 AS_INIT
1428 echo AS_LITERAL_IF([lit], [ok], [ERR]) 1
1429 echo AS_LITERAL_IF([l-/.it], [ok], [ERR]) 2
1430 echo AS_LITERAL_IF([l''it], [ERR], [ok]) 3
1431 echo AS_LITERAL_IF([l$it], [ERR], [ok]) 4
1432 echo AS_LITERAL_IF([l$it], [ERR1], [ERR2], [ok]) 5
1433 echo AS_LITERAL_IF([l${it}], [ERR1], [ERR2], [ok]) 6
1434 echo AS_LITERAL_IF([l`case a in b) ;; esac`it], [ERR], [ok]) 7
1435 echo AS_LITERAL_IF([l`case a in b) ;; esac`it], [ERR1], [ok], [ERR2]) 8
1436 m4_define([mac], [l-/.it])
1437 echo AS_LITERAL_IF([mac], [ok], [ERR]) 9
1438 echo AS_LITERAL_IF([mac($, ``)], [ok], [ERR]) 10
1439 m4_define([mac], [l$it])
1440 echo AS_LITERAL_IF([mac], [ERR], [ok]) 11
1441 echo AS_LITERAL_IF([mac], [ERR1], [ERR2], [ok]) 12
1442 m4_define([mac], [l``it])
1443 echo AS_LITERAL_IF([mac], [ERR], [ok]) 13
1444 echo AS_LITERAL_IF([mac], [ERR1], [ok], [ERR2]) 14
1445 echo AS_LITERAL_IF([    a ][
1446 b], [ok], [ERR]) 15
1447 echo AS_LITERAL_WORD_IF([       a ][
1448 b], [ERR], [ok]) 16
1449 echo AS_LITERAL_HEREDOC_IF([    a ][
1450 b], [ok], [ERR]) 17
1451 echo AS_LITERAL_IF([(a)], [ERR], [ok]) 18
1452 echo AS_LITERAL_WORD_IF([(a)], [ERR], [ok]) 19
1453 echo AS_LITERAL_HEREDOC_IF([(a)], [ok], [ERR]) 20
1454 echo AS_LITERAL_IF([@S|@a], [ERR], [ok]) 21
1455 echo AS_LITERAL_WORD_IF([@S|@a], [ERR], [ok]) 22
1456 echo AS_LITERAL_HEREDOC_IF([@S|@a], [ERR], [ok]) 23
1457 echo AS_LITERAL_IF([${a+b}], [ERR1], [ok], [ERR2]) 24
1458 echo AS_LITERAL_IF([${a=b}], [ERR1], [ok], [ERR2]) 25
1459 echo AS_LITERAL_IF([a+b], [ok], [ERR1], [ERR2]) 26
1460 echo AS_LITERAL_IF([a=b], [ok], [ERR1], [ERR2]) 27
1463 AT_CHECK_M4SH
1464 AT_CHECK([$CONFIG_SHELL ./script], [],
1465 [[ok 1
1466 ok 2
1467 ok 3
1468 ok 4
1469 ok 5
1470 ok 6
1471 ok 7
1472 ok 8
1473 ok 9
1474 ok 10
1475 ok 11
1476 ok 12
1477 ok 13
1478 ok 14
1479 ok 15
1480 ok 16
1481 ok 17
1482 ok 18
1483 ok 19
1484 ok 20
1485 ok 21
1486 ok 22
1487 ok 23
1488 ok 24
1489 ok 25
1490 ok 26
1491 ok 27
1494 AT_CLEANUP
1497 ## --------------------- ##
1498 ## AS_TR_SH, AS_TR_CPP.  ##
1499 ## --------------------- ##
1501 AT_SETUP([AS@&t@_TR_SH and AS@&t@_TR_CPP])
1503 AT_DATA_M4SH([script.as], [[dnl
1504 AS_INIT
1505 m4_define([abc], [hI])m4_define([ABC], [Hi])
1506 m4_define([hi], [oops])m4_define([HI], [OOPS])
1507 echo AS_TR_SH(abc) AS_TR_SH(aBc) AS_TR_SH(ABC)
1508 echo AS_TR_SH([abc]) AS_TR_SH([aBc]) AS_TR_SH([ABC])
1509 echo AS_TR_SH([[abc]]) AS_TR_SH([[aBc]]) AS_TR_SH([[ABC]])
1510 echo AS_TR_CPP(abc) AS_TR_CPP(aBc) AS_TR_CPP(ABC)
1511 echo AS_TR_CPP([abc]) AS_TR_CPP([aBc]) AS_TR_CPP([ABC])
1512 echo AS_TR_CPP([[abc]]) AS_TR_CPP([[aBc]]) AS_TR_CPP([[ABC]])
1513 echo ===
1514 [var=abc vAr=aBc VAR=ABC]
1515 echo AS_TR_SH($var) AS_TR_SH($vAr) AS_TR_SH($VAR)
1516 echo AS_TR_SH([$var]) AS_TR_SH([$vAr]) AS_TR_SH([$VAR])
1517 echo AS_TR_SH([[$var]]) AS_TR_SH([[$vAr]]) AS_TR_SH([[$VAR]])
1518 echo AS_TR_CPP($var) AS_TR_CPP($vAr) AS_TR_CPP($VAR)
1519 echo AS_TR_CPP([$var]) AS_TR_CPP([$vAr]) AS_TR_CPP([$VAR])
1520 echo AS_TR_CPP([[$var]]) AS_TR_CPP([[$vAr]]) AS_TR_CPP([[$VAR]])
1521 echo ===
1522 echo AS_TR_SH(`echo abc`) AS_TR_SH(`echo aBc`) AS_TR_SH(`echo ABC`)
1523 echo AS_TR_SH([`echo abc`]) AS_TR_SH([`echo aBc`]) AS_TR_SH([`echo ABC`])
1524 echo AS_TR_SH([[`echo abc`]]) AS_TR_SH([[`echo aBc`]]) AS_TR_SH([[`echo ABC`]])
1525 echo AS_TR_CPP(`echo abc`) AS_TR_CPP(`echo aBc`) AS_TR_CPP(`echo ABC`)
1526 echo AS_TR_CPP([`echo abc`]) AS_TR_CPP([`echo aBc`]) AS_TR_CPP([`echo ABC`])
1527 echo AS_TR_CPP([[`echo abc`]]) AS_TR_CPP([[`echo aBc`]]) AS_TR_CPP([[`echo ABC`]])
1528 echo ===
1529 # start here
1530 echo AS_TR_SH([a.b/c+*-=])
1531 echo AS_TR_CPP([a.b/c+*-=])
1532 var=a.b/c+*-=
1533 echo AS_TR_SH([$var])
1534 echo AS_TR_CPP([$var])
1535 m4_define([macro], [a.b/c+*-=])
1536 echo AS_TR_SH([macro])
1537 echo AS_TR_CPP([macro])
1540 AT_CHECK_M4SH
1541 AT_CHECK([$CONFIG_SHELL ./script], [],
1542 [[hI aBc Hi
1543 hI aBc Hi
1544 abc aBc ABC
1545 HI ABC HI
1546 HI ABC HI
1547 ABC ABC ABC
1549 abc aBc ABC
1550 abc aBc ABC
1551 abc aBc ABC
1552 ABC ABC ABC
1553 ABC ABC ABC
1554 ABC ABC ABC
1556 hI aBc Hi
1557 hI aBc Hi
1558 abc aBc ABC
1559 HI ABC HI
1560 HI ABC HI
1561 ABC ABC ABC
1563 a_b_cpp__
1564 A_B_C_P__
1565 a_b_cpp__
1566 A_B_C_P__
1567 a_b_cpp__
1568 A_B_C_P__
1571 dnl Check that of the last 6 macros, only 2 needed command substitution.
1572 dnl This test abuses our knowledge of m4sh internals a bit; oh well.
1573 AT_CHECK([tab=' ' # a single ASCII tab character
1574 sed -n '/start here/,$ {
1575 /`.*`/p
1576 }' script | wc -l | sed "s/[[ $tab]]//g" ], [], [[2
1579 AT_CLEANUP
1582 ## ---------- ##
1583 ## AS_VAR_*.  ##
1584 ## ---------- ##
1586 AT_SETUP([AS@&t@_VAR basics])
1587 AT_KEYWORDS([m4sh AS@&t@_VAR_COPY AS@&t@_VAR_SET AS@&t@_VAR_GET])
1588 AT_KEYWORDS([AS@&t@_VAR_TEST_SET AS@&t@_VAR_SET_IF AS@&t@_VAR_IF])
1589 AT_KEYWORDS([AS@&t@_VAR_PUSHDEF AS@&t@_VAR_POPDEF])
1591 AT_DATA_M4SH([script.as], [[dnl
1592 AS_INIT
1593  m4_define([with], [WITH])
1594 # Literals.
1595 dnl AS_VAR_SET_IF also covers AS_VAR_TEST_SET
1596 AS_VAR_SET_IF([foo], [echo oops]) && echo ok
1597 AS_VAR_IF([foo], [], [echo ok], [echo oops])
1598 foo=
1599 AS_VAR_SET_IF([foo], [echo ok])
1600 AS_VAR_SET([foo], ['\a  "weird" `value` with; $fun '\''characters
1601 ']) # 'font-lock
1602 AS_VAR_COPY([bar], [foo])
1603 AS_ECHO(["$bar-"])
1604 AS_ECHO(["AS_VAR_GET([foo])-"])
1605 AS_VAR_SET_IF([foo], [echo ok], [echo oops])
1606 AS_VAR_IF([foo], [string], [echo oops]) && echo ok
1607 AS_VAR_PUSHDEF([tmp], [foo])
1608 AS_VAR_IF([tmp], ['\a  "weird" `value` with; $fun '\''characters
1609 '], [echo ok], [echo oops]) # 'font-lock
1610 AS_VAR_POPDEF([tmp])
1611 m4_ifdef([tmp], [echo oops])
1613 # Indirects via shell vars.
1614 echo '===='
1615 num=1
1616 AS_VAR_SET_IF([foo$num], [echo oops]) && echo ok
1617 AS_VAR_IF([foo$num], [], [echo ok], [echo oops])
1618 foo1=
1619 AS_VAR_SET_IF([foo$num], [echo ok])
1620 AS_VAR_SET([foo$num], ['\a  "weird" `value` with; $fun '\''characters
1621 ']) # 'font-lock
1622 AS_VAR_COPY([bar], [foo$num])
1623 num=2
1624 AS_VAR_COPY([foo$num], [bar])
1625 AS_ECHO(["$foo2-"])
1626 AS_ECHO(["AS_VAR_GET([foo$num])-"])
1627 AS_VAR_SET_IF([foo$num], [echo ok], [echo oops])
1628 AS_VAR_IF([foo$num], [string], [echo oops]) && echo ok
1629 AS_VAR_PUSHDEF([tmp], [foo$num])
1630 AS_VAR_IF([tmp], ['\a  "weird" `value` with; $fun '\''characters
1631 '], [echo ok], [echo oops]) # 'font-lock
1632 AS_VAR_POPDEF([tmp])
1633 m4_ifdef([tmp], [echo oops])
1635 # Indirects via command substitution.
1636 echo '===='
1637 AS_VAR_SET_IF([`echo foo3`], [echo oops]) && echo ok
1638 AS_VAR_IF([`echo foo3`], [], [echo ok], [echo oops])
1639 foo3=
1640 AS_VAR_SET_IF([`echo foo3`], [echo ok])
1641 AS_VAR_SET([`echo foo3`], ['\a  "weird" `value` with; $fun '\''characters
1642 ']) # 'font-lock
1643 AS_VAR_COPY([bar], [`echo foo3`])
1644 num=2
1645 AS_VAR_COPY([`echo foo4`], [bar])
1646 AS_ECHO(["$foo4-"])
1647 AS_ECHO(["AS_VAR_GET([`echo foo4`])-"])
1648 AS_VAR_SET_IF([`echo foo4`], [echo ok], [echo oops])
1649 AS_VAR_IF([`echo foo4`], [string], [echo oops]) && echo ok
1650 AS_VAR_PUSHDEF([tmp], [`echo foo4`])
1651 AS_VAR_IF([tmp], ['\a  "weird" `value` with; $fun '\''characters
1652 '], [echo ok], [echo oops]) # 'font-lock
1653 AS_VAR_POPDEF([tmp])
1654 m4_ifdef([tmp], [echo oops])
1658 AT_CHECK_M4SH
1659 AT_CHECK([$CONFIG_SHELL ./script], [], [[ok
1662 \a  "weird" `value` WITH; $fun 'characters
1664 \a  "weird" `value` WITH; $fun 'characters
1669 ====
1673 \a  "weird" `value` WITH; $fun 'characters
1675 \a  "weird" `value` WITH; $fun 'characters-
1679 ====
1683 \a  "weird" `value` WITH; $fun 'characters
1685 \a  "weird" `value` WITH; $fun 'characters-
1691 AT_CLEANUP
1694 ## --------------- ##
1695 ## AS_VAR_APPEND.  ##
1696 ## --------------- ##
1698 AT_SETUP([AS@&t@_VAR_APPEND])
1699 AT_KEYWORDS([m4sh AS@&t@_VAR])
1701 AT_DATA_M4SH([script.as], [[dnl
1702 AS_INIT
1703 # Literals.
1704 AS_VAR_APPEND([foo], ["hello,  "])
1705 AS_VAR_APPEND([foo], [world])
1706 echo "$foo"
1707 # Indirects via shell vars.
1708 num=1
1709 AS_VAR_APPEND([foo$num], ['hello,  '])
1710 AS_VAR_APPEND([foo$num], [`echo "world"`])
1711 echo "$foo1"
1712 # Indirects via command substitution.
1713 h=hello w=',  world'
1714 AS_VAR_APPEND([`echo foo2`], [${h}])
1715 AS_VAR_APPEND([`echo foo2`], ["$w"])
1716 echo "$foo2"
1719 AT_CHECK_M4SH
1720 AT_CHECK([$CONFIG_SHELL ./script], [],
1721 [[hello,  world
1722 hello,  world
1723 hello,  world
1726 AT_CLEANUP
1729 ## -------------- ##
1730 ## AS_VAR_ARITH.  ##
1731 ## -------------- ##
1733 AT_SETUP([AS@&t@_VAR_ARITH])
1734 AT_KEYWORDS([m4sh AS@&t@_VAR])
1736 AT_DATA_M4SH([script.as], [[dnl
1737 AS_INIT
1738 # Literals.
1739 AS_VAR_ARITH([foo], [1 + 1])
1740 echo "$foo"
1741 # Indirects via shell vars.
1742 num=1
1743 AS_VAR_ARITH([foo$num], [\( 2 + 3 \) \* 4])
1744 echo "$foo1"
1745 # Indirects via command substitution.
1746 AS_VAR_ARITH([`echo foo2`], [0 + -2 + $foo1 / 2])
1747 echo "$foo2"
1750 AT_CHECK_M4SH
1751 AT_CHECK([$CONFIG_SHELL ./script], [],
1757 AT_CLEANUP
1760 ## ----------------- ##
1761 ## AS_INIT cleanup.  ##
1762 ## ----------------- ##
1764 AT_SETUP([AS@&t@_INIT cleanup])
1765 AT_KEYWORDS([m4sh m4@&t@_wrap m4@&t@_wrap_lifo])
1767 AT_DATA_M4SH([script.as], [[dnl
1768 dnl Registered before AS_INIT's cleanups
1769 m4_wrap([echo cleanup 1
1771 m4_pushdef([_AS_SHELL_FN_SPY])dnl neutralize the spy, we don't care about it
1772 AS_INIT
1773 dnl Registered after AS_INIT's cleanups, thus goes to KILL diversion
1774 m4_wrap([echo cleanup 2
1775 dnl However, nested wraps and diversions can still be used
1776 dnl Also, test wrapping text that looks like parameter reference
1777 m4_wrap([echo cleanup 3
1778 m4_divert_text([M4SH-INIT], [m4_define([foo], [$1])dnl
1779 echo prep foo([4])
1780 ])])])
1781 dnl Registered before AS_INIT's cleanups
1782 m4_wrap_lifo([echo cleanup 5
1784 echo body
1787 AT_CHECK_M4SH
1788 AT_CHECK([$CONFIG_SHELL ./script], [], [[prep 4
1789 body
1790 cleanup 5
1791 cleanup 1
1794 AT_CLEANUP
1797 ## ------------------- ##
1798 ## AS_INIT_GENERATED.  ##
1799 ## ------------------- ##
1801 AT_SETUP([AS@&t@_INIT_GENERATED])
1802 AT_KEYWORDS([AS@&t@_MESSAGE AS@&t@_MESSAGE_LOG_FD])
1804 dnl First run, no logging, tests shell selection
1805 AT_DATA_M4SH([script.as], [[dnl
1806 AS_INIT
1807 AS_INIT_GENERATED([child], [echo hello from child])
1808 cat >>child <<\EOF
1809 AS_ECHO(["SHELL=$SHELL"])
1811 echo hello from parent
1812 AS_ECHO(["SHELL=$SHELL"])
1815 AT_CHECK_M4SH
1816 AT_CHECK([$CONFIG_SHELL ./script], [0], [stdout])
1817 AT_CHECK([grep 'SHELL=.' stdout], [0], [ignore])
1818 sed s/parent/child/ <stdout >expout
1819 AT_CHECK([./child], [0], [expout])
1820 SHELL=/bogus
1821 export SHELL
1822 cp stdout expout
1823 mv child child.bak
1824 AT_CHECK([$CONFIG_SHELL ./script], [0], [expout])
1825 AT_CHECK([cmp child child.bak])
1826 AT_CHECK([grep 'SHELL=.' stdout], [0], [ignore])
1827 sed s/parent/child/ <stdout >expout
1828 AT_CHECK([./child], [0], [expout])
1831 dnl Second run, with logging from parent and child, tests fd handling
1832 AT_DATA_M4SH([script.as], [[dnl
1833 AS_INIT
1834 child=${1-child}
1835 m4_define([AS_MESSAGE_LOG_FD], [5])
1836 exec AS_MESSAGE_LOG_FD>log
1837 AS_INIT_GENERATED([$child], [echo hello1 from $child]) || AS_EXIT([1])
1838 cat >>$child <<\EOF
1839 m4_pushdef([AS_MESSAGE_LOG_FD])
1840 AS_MESSAGE([hello2 from ${child}child])
1841 m4_popdef([AS_MESSAGE_LOG_FD])
1842 exec AS_MESSAGE_LOG_FD>>log
1843 AS_MESSAGE([hello3 from child])
1845 AS_MESSAGE([hello from parent])
1846 dnl close log in parent before spawning child, for mingw
1847 exec AS_MESSAGE_LOG_FD>&-
1848 ./$child
1851 rm -f script
1852 AT_CHECK_M4SH
1853 AT_CHECK([$CONFIG_SHELL ./script], [0], [[script: hello from parent
1854 hello1 from child
1855 child: hello2 from child
1856 child: hello3 from child
1858 AT_CHECK([[sed 's,:[0-9][0-9]*:,:0:,' log]], [0],
1859 [[script:0: hello from parent
1860 child:0: hello3 from child
1863 # Force write error creating a file on stdout
1864 if test -w /dev/full && test -c /dev/full; then
1865   AT_CHECK([$CONFIG_SHELL ./script /dev/full], [1], [ignore], [ignore])
1868 AT_CLEANUP
1871 ## --------------- ##
1872 ## AS_MESSAGE_FD.  ##
1873 ## --------------- ##
1875 AT_SETUP([AS@&t@_MESSAGE_FD])
1876 AT_KEYWORDS([AS@&t@_MESSAGE AS@&t@_MESSAGE_LOG_FD AS@&t_ORIGINAL_STDIN_FD])
1877 AT_KEYWORDS([AS@&t@_LINENO_PUSH])
1879 AT_DATA_M4SH([script.as], [[dnl
1880 AS_INIT
1881 m4_define([AS_ORIGINAL_STDIN_FD], [5])
1882 m4_define([AS_MESSAGE_LOG_FD], [6])
1883 m4_define([AS_MESSAGE_FD], [7])
1884 exec AS_ORIGINAL_STDIN_FD<&0 </dev/null AS_MESSAGE_LOG_FD>log
1885 if test $[#] -gt 0; then
1886   exec AS_MESSAGE_FD>/dev/null
1887 else
1888   exec AS_MESSAGE_FD>&1
1890 AS_LINENO_PUSH([100])
1891 cat # tests that stdin is neutralized
1892 AS_MESSAGE([hello world])
1893 cat <&AS_ORIGINAL_STDIN_FD
1896 AT_CHECK_M4SH
1897 AT_CHECK([echo goodbye | $CONFIG_SHELL ./script], [0],
1898 [[script: hello world
1899 goodbye
1901 AT_CHECK([cat log], [0],
1902 [[script:100: hello world
1904 rm log
1905 AT_CHECK([echo goodbye | $CONFIG_SHELL ./script silent], [0],
1906 [[goodbye
1908 AT_CHECK([cat log], [0],
1909 [[script:100: hello world
1912 AT_CLEANUP
1915 ## --------------- ##
1916 ## _AS_CLEAN_DIR.  ##
1917 ## --------------- ##
1919 AT_SETUP([_AS@&t@_CLEAN_DIR])
1921 dnl ensure that we can erase all files in a directory.  Note that
1922 dnl _AS_CLEAN_DIR needs three globs to catch all these files.
1923 AT_DATA_M4SH([script.as], [[dnl
1924 AS_INIT
1925 # Unwritable subdirectories are common during 'make distcheck'.
1926 mkdir sub sub/unwritable || AS_ERROR([failed to mkdir])
1927 touch sub/unwritable/file || AS_ERROR([failed to touch])
1928 chmod a-wx sub/unwritable || AS_ERROR([failed to chmod])
1929 # Cygwin 1.5 can't touch 'sub/...', so make that file optional.
1930 touch sub/a sub/aa sub/aaa sub/.a sub/..a sub/.aa \
1931   || AS_ERROR([failed to touch])
1932 touch sub/... 2>/dev/null
1933 _AS_CLEAN_DIR([sub]) || AS_ERROR([failed to clean])
1934 # rmdir instead of 'rm -fr' here proves that we emptied sub.
1935 rmdir sub || AS_ERROR([failed to rmdir])
1938 AT_CHECK_M4SH
1939 AT_CHECK([$CONFIG_SHELL ./script])
1941 AT_CLEANUP
1944 ## -------- ##
1945 ## ECHO_C.  ##
1946 ## -------- ##
1948 AT_SETUP([ECHO_C])
1950 AT_DATA_M4SH([script.as], [[dnl
1951 AS_INIT
1952 _AS_PREPARE
1953 foo=`echo foobar`
1954 echo "$foo"
1957 AT_CHECK_M4SH
1958 AT_CHECK([$CONFIG_SHELL ./script], [], [foobar
1961 AT_CLEANUP