📄 m4sh.at
字号:
## ------------------- #### Functions Support. #### ------------------- ### Hypothesis: the shell we are running, after having checked for# $LINENO support, supports functions.AT_SETUP([Functions Support])AT_DATA_M4SH([script.as],[[AS_INIT_AS_LINENO_PREPAREfunc_return () { (exit $1)}func_success () { func_return 0}func_failure () { func_return 1}if func_success; then if func_failure; then AS_ERROR([func_failure passed]) fielse AS_ERROR([func_success failed])fi]])AT_CHECK_M4SHAT_CHECK([./script])AT_CLEANUP## ------------------------------ #### Functions and return Support. #### ------------------------------ ### Hypothesis: the shell we are running, after having checked for# $LINENO support, supports functions, and the `return' keyword.AT_SETUP([Functions and return Support])AT_DATA_M4SH([script.as],[[AS_INIT_AS_LINENO_PREPAREfunc_success () { return 0}func_failure () { return 1}if func_success; then if func_failure; then AS_ERROR([func_failure passed]) fielse AS_ERROR([func_success failed])fi]])AT_CHECK_M4SHAT_CHECK([./script])AT_CLEANUP## ------------------------------------ #### AS_REQUIRE_SHELL_FN and m4_require. #### ------------------------------------ ### Hypothesis: M4sh expands the requirements of AS_REQUIRE_SHELL_FN# in the main diversion, and not in M4SH-INIT.AT_SETUP([AS@&t@_REQUIRE_SHELL_FN and m4@&t@_require])AT_DATA_M4SH([script.as], [[dnlAS_INITm4_defun([in_m4_sh_init], still_in_m4sh_init=yes)m4_defun([not_in_m4_sh_init], still_in_m4sh_init=no)m4_defun([error_if_emitted_in_m4sh_init], [ if test x$still_in_m4sh_init = xyes; then AS_ERROR([requirement emitted in M4SH-INIT]) fi])m4_defun([TEST_FUNC_BODY], [m4_require([error_if_emitted_in_m4sh_init]): echo in shell function, with parameter = [$]1])m4_defun([test_init], [AS_REQUIRE([in_m4_sh_init])AS_REQUIRE_SHELL_FN([test_func], [TEST_FUNC_BODY])AS_REQUIRE([not_in_m4_sh_init])])test_inittest_func parameter1]])AT_CHECK_M4SHAT_CHECK([./script])AT_CLEANUP## -------------- #### AS_HELP_STRING #### -------------- ### I'm not totally certain that we want to enforce the defaults here,# but at least it is being tested.AT_SETUP([AS@&t@_HELP_STRING])AT_DATA_M4SH([script.as],[[AS_INIT_AS_LINENO_PREPAREecho "AS_HELP_STRING([--an-option],[some text])"echo "AS_HELP_STRING([--another-much-longer-option],[some other text which should wrap at our default of 80 characters.])"echo "AS_HELP_STRING([--fooT=barT], [foo bar])"echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@], [foo bar])"echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@123456789], [foo bar])"echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@1234567890], [foo bar])"echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@12345678901], [foo bar])"echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@123456789012], [foo bar])"echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@1234567890123], [foo bar])"echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@],[some other text which should wrap at our default of 80 characters.])"echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@123456789],[some other text which should wrap at our default of 80 characters.])"echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@1234567890],[some other text which should wrap at our default of 80 characters.])"echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@12345678901],[some other text which should wrap at our default of 80 characters.])"echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@123456789012],[some other text which should wrap at our default of 80 characters.])"echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@1234567890123],[some other text which should wrap at our default of 80 characters.])"echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@],[some other @<][:@ex@:][>@ which should wrap at our default of 80 characters.])"echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@123456789],[some other @<][:@ex@:][>@ which should wrap at our default of 80 characters.])"echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@1234567890],[some other @<][:@ex@:][>@ which should wrap at our default of 80 characters.])"echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@12345678901],[some other @<][:@ex@:][>@ which should wrap at our default of 80 characters.])"echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@123456789012],[some other @<][:@ex@:][>@ which should wrap at our default of 80 characters.])"echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@1234567890123],[some other @<][:@ex@:][>@ which should wrap at our default of 80 characters.])"]])AT_CHECK_M4SHAT_CHECK([./script], [0],[[ --an-option some text --another-much-longer-option some other text which should wrap at our default of 80 characters. --fooT=barT foo bar --foo[=bar] foo bar --foo[=bar]123456789 foo bar --foo[=bar]1234567890 foo bar --foo[=bar]12345678901 foo bar --foo[=bar]123456789012 foo bar --foo[=bar]1234567890123 foo bar --foo[=bar] some other text which should wrap at our default of 80 characters. --foo[=bar]123456789 some other text which should wrap at our default of 80 characters. --foo[=bar]1234567890 some other text which should wrap at our default of 80 characters. --foo[=bar]12345678901 some other text which should wrap at our default of 80 characters. --foo[=bar]123456789012 some other text which should wrap at our default of 80 characters. --foo[=bar]1234567890123 some other text which should wrap at our default of 80 characters. --foo[=bar] some other [ex] which should wrap at our default of 80 characters. --foo[=bar]123456789 some other [ex] which should wrap at our default of 80 characters. --foo[=bar]1234567890 some other [ex] which should wrap at our default of 80 characters. --foo[=bar]12345678901 some other [ex] which should wrap at our default of 80 characters. --foo[=bar]123456789012 some other [ex] which should wrap at our default of 80 characters. --foo[=bar]1234567890123 some other [ex] which should wrap at our default of 80 characters.]])AT_CLEANUP## ------------------- #### AS_IF and AS_CASE. #### ------------------- ##AT_SETUP([AS@&t@_IF and AS@&t@_CASE])AT_DATA_M4SH([script.as], [[dnlAS_INIT# Syntax checks: cope with empty arguments.AS_IF([:], [], [echo wrong])AS_IF([:], [echo one], [echo wrong])AS_IF([false], [echo wrong], [echo two])AS_IF([false], [echo wrong])# n-ary versionAS_IF([false], [echo wrong], [:], [echo three])AS_IF([false], [echo wrong], [:], [echo four], [echo wrong])AS_IF([false], [echo wrong], [false], [echo wrong])AS_IF([false], [echo wrong], [false], [echo wrong], [echo five])AS_IF([false], [echo wrong], [false], [echo wrong], [:], [echo six], [echo wrong])AS_CASE([foo])AS_CASE([foo], [echo seven])AS_CASE([foo], [foo], [echo eight], [echo wrong])AS_CASE([foo], [foo], [echo nine], [*], [echo wrong])AS_CASE([foo], [bar], [echo wrong], [foo], [echo ten], [*], [echo wrong])# check that require works correctlym4_for([n], 1, 9, [],[m4_defun([FOO]n, [foo]n[=]n)dnlm4_defun([BAR]n, [m4_require([FOO]]n[)dnlbar]n[=]n)[]dnl])AS_IF([:], [BAR1])echo "foo1=$foo1 bar1=$bar1"AS_IF([:], [], [BAR2])echo "foo2=$foo2 bar2=$bar2"AS_IF([false], [BAR3])echo "foo3=$foo3 bar3=$bar3"AS_IF([false], [], [BAR4])echo "foo4=$foo4 bar4=$bar4"AS_CASE([x], [x], [BAR5])echo "foo5=$foo5 bar5=$bar5"AS_CASE([x], [y], [BAR6])echo "foo6=$foo6 bar6=$bar6"AS_CASE([x], [x], [:], [BAR7])echo "foo7=$foo7 bar7=$bar7"AS_CASE([x], [y], [:], [BAR8])echo "foo8=$foo8 bar8=$bar8"AS_CASE([x], [y], [:], [x], [BAR9])echo "foo9=$foo9 bar9=$bar9"]])AT_CHECK_M4SHAT_CHECK([./script], [0], [[onetwothreefourfivesixseveneightninetenfoo1=1 bar1=1foo2=2 bar2=foo3=3 bar3=foo4=4 bar4=4foo5=5 bar5=5foo6=6 bar6=foo7=7 bar7=foo8=8 bar8=8foo9=9 bar9=9]])AT_CLEANUP
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -