]> git.saurik.com Git - apple/shell_cmds.git/commitdiff
shell_cmds-203.tar.gz macos-1013 macos-10131 macos-10132 macos-10133 macos-10134 macos-10135 macos-10136 macos-1014 macos-10141 macos-10142 macos-10143 macos-10144 macos-10145 macos-10146 v203
authorApple <opensource@apple.com>
Fri, 28 Apr 2017 04:11:12 +0000 (04:11 +0000)
committerApple <opensource@apple.com>
Fri, 28 Apr 2017 04:11:12 +0000 (04:11 +0000)
550 files changed:
.gitignore [new file with mode: 0644]
lastcomm/lastcomm.c
locate/locate/locate.rc
locate/locate/updatedb.sh
printf/printf.1
printf/printf.c
printf/tests/Makefile [new file with mode: 0644]
printf/tests/Makefile.depend [new file with mode: 0644]
printf/tests/legacy_test.sh [new file with mode: 0644]
printf/tests/regress.b.out [new file with mode: 0644]
printf/tests/regress.d.out [new file with mode: 0644]
printf/tests/regress.f.out [new file with mode: 0644]
printf/tests/regress.l1.out [new file with mode: 0644]
printf/tests/regress.l2.out [new file with mode: 0644]
printf/tests/regress.m1.out [new file with mode: 0644]
printf/tests/regress.m2.out [new file with mode: 0644]
printf/tests/regress.m3.out [new file with mode: 0644]
printf/tests/regress.m4.out [new file with mode: 0644]
printf/tests/regress.m5.out [new file with mode: 0644]
printf/tests/regress.missingpos1.out [new file with mode: 0644]
printf/tests/regress.s.out [new file with mode: 0644]
printf/tests/regress.sh [new file with mode: 0644]
printf/tests/regress.zero.out [new file with mode: 0644]
sh/Makefile
sh/Makefile.depend
sh/TOUR
sh/alias.c
sh/alias.h
sh/arith.h
sh/arith_yacc.c
sh/arith_yacc.h
sh/arith_yylex.c
sh/bltin/bltin.h
sh/bltin/echo.c
sh/builtins.def
sh/cd.c
sh/cd.h
sh/error.c
sh/error.h
sh/eval.c
sh/eval.h
sh/exec.c
sh/exec.h
sh/expand.c
sh/expand.h
sh/funcs/cmv
sh/funcs/dirs
sh/funcs/login
sh/funcs/newgrp
sh/funcs/popd
sh/funcs/pushd
sh/funcs/suspend
sh/histedit.c
sh/input.c
sh/input.h
sh/jobs.c
sh/jobs.h
sh/mail.c
sh/mail.h
sh/main.c
sh/main.h
sh/memalloc.c
sh/memalloc.h
sh/miscbltin.c
sh/mkbuiltins
sh/mknodes.c
sh/mksyntax.c
sh/mktokens
sh/myhistedit.h
sh/mystring.c
sh/mystring.h
sh/nodes.c.pat
sh/nodetypes
sh/options.c
sh/options.h
sh/output.c
sh/output.h
sh/parser.c
sh/parser.h
sh/redir.c
sh/redir.h
sh/sh.1
sh/sh.plist.part
sh/shell.h
sh/show.c
sh/show.h
sh/tests/Makefile
sh/tests/Makefile.depend [new file with mode: 0644]
sh/tests/builtins/Makefile
sh/tests/builtins/Makefile.depend [new file with mode: 0644]
sh/tests/builtins/alias.0
sh/tests/builtins/alias.1
sh/tests/builtins/alias3.0
sh/tests/builtins/alias4.0
sh/tests/builtins/break1.0
sh/tests/builtins/break2.0
sh/tests/builtins/break3.0
sh/tests/builtins/break4.4
sh/tests/builtins/break5.4
sh/tests/builtins/break6.0
sh/tests/builtins/builtin1.0
sh/tests/builtins/case1.0
sh/tests/builtins/case10.0
sh/tests/builtins/case11.0
sh/tests/builtins/case12.0
sh/tests/builtins/case13.0
sh/tests/builtins/case14.0
sh/tests/builtins/case15.0
sh/tests/builtins/case16.0
sh/tests/builtins/case17.0
sh/tests/builtins/case18.0
sh/tests/builtins/case19.0
sh/tests/builtins/case2.0
sh/tests/builtins/case20.0 [new file with mode: 0644]
sh/tests/builtins/case3.0
sh/tests/builtins/case4.0
sh/tests/builtins/case5.0
sh/tests/builtins/case6.0
sh/tests/builtins/case7.0
sh/tests/builtins/case8.0
sh/tests/builtins/case9.0
sh/tests/builtins/cd1.0
sh/tests/builtins/cd2.0
sh/tests/builtins/cd3.0
sh/tests/builtins/cd4.0
sh/tests/builtins/cd5.0
sh/tests/builtins/cd6.0
sh/tests/builtins/cd7.0
sh/tests/builtins/cd8.0
sh/tests/builtins/cd9.0 [new file with mode: 0644]
sh/tests/builtins/cd9.0.stdout [new file with mode: 0644]
sh/tests/builtins/command1.0
sh/tests/builtins/command10.0
sh/tests/builtins/command11.0
sh/tests/builtins/command12.0
sh/tests/builtins/command2.0
sh/tests/builtins/command3.0
sh/tests/builtins/command4.0
sh/tests/builtins/command5.0
sh/tests/builtins/command6.0
sh/tests/builtins/command7.0
sh/tests/builtins/command8.0
sh/tests/builtins/command9.0
sh/tests/builtins/dot1.0
sh/tests/builtins/dot2.0
sh/tests/builtins/dot3.0
sh/tests/builtins/dot4.0
sh/tests/builtins/echo1.0 [new file with mode: 0644]
sh/tests/builtins/echo2.0 [new file with mode: 0644]
sh/tests/builtins/echo3.0 [new file with mode: 0644]
sh/tests/builtins/eval1.0
sh/tests/builtins/eval2.0
sh/tests/builtins/eval3.0
sh/tests/builtins/eval4.0
sh/tests/builtins/eval5.0
sh/tests/builtins/eval6.0
sh/tests/builtins/eval7.0
sh/tests/builtins/eval8.7
sh/tests/builtins/exec1.0
sh/tests/builtins/exec2.0
sh/tests/builtins/exit1.0
sh/tests/builtins/exit2.8
sh/tests/builtins/exit3.0
sh/tests/builtins/export1.0
sh/tests/builtins/fc1.0
sh/tests/builtins/fc2.0
sh/tests/builtins/for1.0
sh/tests/builtins/for2.0
sh/tests/builtins/for3.0
sh/tests/builtins/getopts1.0
sh/tests/builtins/getopts10.0 [new file with mode: 0644]
sh/tests/builtins/getopts2.0
sh/tests/builtins/getopts3.0
sh/tests/builtins/getopts4.0
sh/tests/builtins/getopts5.0
sh/tests/builtins/getopts6.0
sh/tests/builtins/getopts7.0
sh/tests/builtins/getopts8.0
sh/tests/builtins/getopts9.0
sh/tests/builtins/hash1.0
sh/tests/builtins/hash2.0
sh/tests/builtins/hash3.0
sh/tests/builtins/hash4.0
sh/tests/builtins/jobid1.0
sh/tests/builtins/jobid2.0
sh/tests/builtins/kill1.0
sh/tests/builtins/kill2.0
sh/tests/builtins/lineno.0
sh/tests/builtins/lineno2.0
sh/tests/builtins/lineno3.0
sh/tests/builtins/local1.0
sh/tests/builtins/local2.0
sh/tests/builtins/local3.0
sh/tests/builtins/local4.0
sh/tests/builtins/local5.0 [new file with mode: 0644]
sh/tests/builtins/local6.0 [new file with mode: 0644]
sh/tests/builtins/local7.0 [new file with mode: 0644]
sh/tests/builtins/locale1.0
sh/tests/builtins/printf1.0
sh/tests/builtins/printf2.0
sh/tests/builtins/printf3.0
sh/tests/builtins/printf4.0
sh/tests/builtins/read1.0
sh/tests/builtins/read2.0
sh/tests/builtins/read3.0
sh/tests/builtins/read4.0
sh/tests/builtins/read5.0
sh/tests/builtins/read6.0
sh/tests/builtins/read7.0
sh/tests/builtins/read8.0 [new file with mode: 0644]
sh/tests/builtins/read9.0 [new file with mode: 0644]
sh/tests/builtins/return1.0
sh/tests/builtins/return2.1
sh/tests/builtins/return3.1
sh/tests/builtins/return4.0
sh/tests/builtins/return5.0
sh/tests/builtins/return6.4
sh/tests/builtins/return7.4
sh/tests/builtins/return8.0
sh/tests/builtins/set2.0
sh/tests/builtins/set3.0 [new file with mode: 0644]
sh/tests/builtins/trap1.0
sh/tests/builtins/trap10.0
sh/tests/builtins/trap11.0
sh/tests/builtins/trap12.0
sh/tests/builtins/trap13.0
sh/tests/builtins/trap14.0
sh/tests/builtins/trap15.0
sh/tests/builtins/trap16.0
sh/tests/builtins/trap17.0 [new file with mode: 0644]
sh/tests/builtins/trap2.0
sh/tests/builtins/trap3.0
sh/tests/builtins/trap4.0
sh/tests/builtins/trap5.0
sh/tests/builtins/trap6.0
sh/tests/builtins/trap7.0
sh/tests/builtins/trap8.0
sh/tests/builtins/trap9.0
sh/tests/builtins/type1.0
sh/tests/builtins/type2.0
sh/tests/builtins/type3.0
sh/tests/builtins/unalias.0
sh/tests/builtins/var-assign.0
sh/tests/builtins/var-assign2.0
sh/tests/builtins/wait1.0
sh/tests/builtins/wait10.0
sh/tests/builtins/wait2.0
sh/tests/builtins/wait3.0
sh/tests/builtins/wait4.0
sh/tests/builtins/wait5.0
sh/tests/builtins/wait6.0
sh/tests/builtins/wait7.0
sh/tests/builtins/wait8.0
sh/tests/builtins/wait9.127
sh/tests/errors/Makefile
sh/tests/errors/Makefile.depend [new file with mode: 0644]
sh/tests/errors/assignment-error1.0
sh/tests/errors/assignment-error2.0
sh/tests/errors/backquote-error1.0
sh/tests/errors/backquote-error2.0
sh/tests/errors/bad-binary1.126
sh/tests/errors/bad-keyword1.0
sh/tests/errors/bad-parm-exp1.0
sh/tests/errors/bad-parm-exp2.2
sh/tests/errors/bad-parm-exp3.2
sh/tests/errors/bad-parm-exp4.2
sh/tests/errors/bad-parm-exp5.2
sh/tests/errors/bad-parm-exp6.2
sh/tests/errors/bad-parm-exp7.0 [new file with mode: 0644]
sh/tests/errors/bad-parm-exp8.0 [new file with mode: 0644]
sh/tests/errors/option-error.0
sh/tests/errors/redirection-error.0
sh/tests/errors/redirection-error2.2
sh/tests/errors/redirection-error3.0
sh/tests/errors/redirection-error4.0
sh/tests/errors/redirection-error5.0
sh/tests/errors/redirection-error6.0
sh/tests/errors/redirection-error7.0
sh/tests/errors/write-error1.0
sh/tests/execution/Makefile
sh/tests/execution/Makefile.depend [new file with mode: 0644]
sh/tests/execution/bg1.0
sh/tests/execution/bg10.0
sh/tests/execution/bg2.0
sh/tests/execution/bg3.0
sh/tests/execution/bg4.0
sh/tests/execution/bg5.0
sh/tests/execution/bg6.0
sh/tests/execution/bg7.0
sh/tests/execution/bg8.0
sh/tests/execution/bg9.0
sh/tests/execution/fork1.0
sh/tests/execution/fork2.0
sh/tests/execution/fork3.0
sh/tests/execution/func1.0
sh/tests/execution/func2.0
sh/tests/execution/func3.0
sh/tests/execution/hash1.0
sh/tests/execution/int-cmd1.0
sh/tests/execution/killed1.0
sh/tests/execution/killed2.0
sh/tests/execution/not1.0
sh/tests/execution/not2.0
sh/tests/execution/path1.0
sh/tests/execution/redir1.0
sh/tests/execution/redir2.0
sh/tests/execution/redir3.0
sh/tests/execution/redir4.0
sh/tests/execution/redir5.0
sh/tests/execution/redir6.0
sh/tests/execution/redir7.0
sh/tests/execution/set-n1.0
sh/tests/execution/set-n2.0
sh/tests/execution/set-n3.0
sh/tests/execution/set-n4.0
sh/tests/execution/set-x1.0
sh/tests/execution/set-x2.0
sh/tests/execution/set-x3.0
sh/tests/execution/set-x4.0
sh/tests/execution/shellproc1.0
sh/tests/execution/subshell1.0
sh/tests/execution/subshell2.0
sh/tests/execution/subshell3.0
sh/tests/execution/subshell4.0
sh/tests/execution/unknown1.0
sh/tests/execution/var-assign1.0
sh/tests/expansion/Makefile
sh/tests/expansion/Makefile.depend [new file with mode: 0644]
sh/tests/expansion/arith1.0
sh/tests/expansion/arith10.0
sh/tests/expansion/arith11.0
sh/tests/expansion/arith12.0
sh/tests/expansion/arith13.0
sh/tests/expansion/arith14.0
sh/tests/expansion/arith2.0
sh/tests/expansion/arith3.0
sh/tests/expansion/arith4.0
sh/tests/expansion/arith5.0
sh/tests/expansion/arith6.0
sh/tests/expansion/arith7.0
sh/tests/expansion/arith8.0
sh/tests/expansion/arith9.0
sh/tests/expansion/assign1.0
sh/tests/expansion/cmdsubst1.0
sh/tests/expansion/cmdsubst10.0
sh/tests/expansion/cmdsubst11.0
sh/tests/expansion/cmdsubst12.0
sh/tests/expansion/cmdsubst13.0
sh/tests/expansion/cmdsubst14.0
sh/tests/expansion/cmdsubst15.0
sh/tests/expansion/cmdsubst16.0
sh/tests/expansion/cmdsubst17.0
sh/tests/expansion/cmdsubst2.0
sh/tests/expansion/cmdsubst3.0
sh/tests/expansion/cmdsubst4.0
sh/tests/expansion/cmdsubst5.0
sh/tests/expansion/cmdsubst6.0
sh/tests/expansion/cmdsubst7.0
sh/tests/expansion/cmdsubst8.0
sh/tests/expansion/cmdsubst9.0
sh/tests/expansion/export1.0
sh/tests/expansion/export2.0
sh/tests/expansion/export3.0
sh/tests/expansion/heredoc1.0
sh/tests/expansion/heredoc2.0
sh/tests/expansion/ifs1.0
sh/tests/expansion/ifs2.0
sh/tests/expansion/ifs3.0
sh/tests/expansion/ifs4.0
sh/tests/expansion/ifs5.0
sh/tests/expansion/ifs6.0
sh/tests/expansion/ifs7.0
sh/tests/expansion/length1.0
sh/tests/expansion/length2.0
sh/tests/expansion/length3.0
sh/tests/expansion/length4.0
sh/tests/expansion/length5.0
sh/tests/expansion/length6.0
sh/tests/expansion/length7.0
sh/tests/expansion/length8.0
sh/tests/expansion/local1.0
sh/tests/expansion/local2.0
sh/tests/expansion/pathname1.0
sh/tests/expansion/pathname2.0
sh/tests/expansion/pathname3.0
sh/tests/expansion/pathname4.0
sh/tests/expansion/pathname5.0
sh/tests/expansion/pathname6.0 [new file with mode: 0644]
sh/tests/expansion/plus-minus1.0
sh/tests/expansion/plus-minus2.0
sh/tests/expansion/plus-minus3.0
sh/tests/expansion/plus-minus4.0
sh/tests/expansion/plus-minus5.0
sh/tests/expansion/plus-minus6.0
sh/tests/expansion/plus-minus7.0
sh/tests/expansion/plus-minus8.0
sh/tests/expansion/question1.0
sh/tests/expansion/readonly1.0
sh/tests/expansion/redir1.0
sh/tests/expansion/set-u1.0
sh/tests/expansion/set-u2.0
sh/tests/expansion/set-u3.0
sh/tests/expansion/tilde1.0
sh/tests/expansion/tilde2.0
sh/tests/expansion/trim1.0
sh/tests/expansion/trim2.0
sh/tests/expansion/trim3.0
sh/tests/expansion/trim4.0
sh/tests/expansion/trim5.0
sh/tests/expansion/trim6.0
sh/tests/expansion/trim7.0
sh/tests/expansion/trim8.0
sh/tests/expansion/trim9.0 [new file with mode: 0644]
sh/tests/functional_test.sh
sh/tests/parameters/Makefile
sh/tests/parameters/Makefile.depend [new file with mode: 0644]
sh/tests/parameters/env1.0
sh/tests/parameters/exitstatus1.0
sh/tests/parameters/ifs1.0 [new file with mode: 0644]
sh/tests/parameters/mail1.0
sh/tests/parameters/mail2.0
sh/tests/parameters/optind1.0
sh/tests/parameters/optind2.0
sh/tests/parameters/positional1.0
sh/tests/parameters/positional2.0
sh/tests/parameters/positional3.0
sh/tests/parameters/positional4.0
sh/tests/parameters/positional5.0
sh/tests/parameters/positional6.0
sh/tests/parameters/positional7.0
sh/tests/parameters/positional8.0 [new file with mode: 0644]
sh/tests/parameters/positional9.0 [new file with mode: 0644]
sh/tests/parameters/pwd1.0
sh/tests/parameters/pwd2.0
sh/tests/parser/Makefile
sh/tests/parser/Makefile.depend [new file with mode: 0644]
sh/tests/parser/alias1.0
sh/tests/parser/alias10.0
sh/tests/parser/alias11.0
sh/tests/parser/alias12.0
sh/tests/parser/alias13.0
sh/tests/parser/alias14.0
sh/tests/parser/alias15.0
sh/tests/parser/alias2.0
sh/tests/parser/alias3.0
sh/tests/parser/alias4.0
sh/tests/parser/alias5.0
sh/tests/parser/alias6.0
sh/tests/parser/alias7.0
sh/tests/parser/alias8.0
sh/tests/parser/alias9.0
sh/tests/parser/and-pipe-not.0
sh/tests/parser/case1.0
sh/tests/parser/case2.0
sh/tests/parser/comment1.0 [new file with mode: 0644]
sh/tests/parser/comment2.42 [new file with mode: 0644]
sh/tests/parser/dollar-quote10.0
sh/tests/parser/dollar-quote11.0
sh/tests/parser/dollar-quote12.0 [new file with mode: 0644]
sh/tests/parser/dollar-quote13.0 [new file with mode: 0644]
sh/tests/parser/empty-braces1.0
sh/tests/parser/empty-cmd1.0
sh/tests/parser/for1.0
sh/tests/parser/for2.0
sh/tests/parser/func1.0
sh/tests/parser/func2.0
sh/tests/parser/func3.0
sh/tests/parser/heredoc1.0
sh/tests/parser/heredoc10.0
sh/tests/parser/heredoc11.0
sh/tests/parser/heredoc12.0
sh/tests/parser/heredoc13.0 [new file with mode: 0644]
sh/tests/parser/heredoc2.0
sh/tests/parser/heredoc3.0
sh/tests/parser/heredoc4.0
sh/tests/parser/heredoc5.0
sh/tests/parser/heredoc6.0
sh/tests/parser/heredoc7.0
sh/tests/parser/heredoc8.0
sh/tests/parser/heredoc9.0
sh/tests/parser/line-cont1.0
sh/tests/parser/line-cont10.0
sh/tests/parser/line-cont11.0
sh/tests/parser/line-cont2.0
sh/tests/parser/line-cont3.0
sh/tests/parser/line-cont4.0
sh/tests/parser/line-cont5.0
sh/tests/parser/line-cont6.0
sh/tests/parser/line-cont7.0
sh/tests/parser/line-cont8.0
sh/tests/parser/line-cont9.0
sh/tests/parser/no-space1.0
sh/tests/parser/no-space2.0
sh/tests/parser/nul1.0 [new file with mode: 0644]
sh/tests/parser/only-redir1.0
sh/tests/parser/only-redir2.0
sh/tests/parser/only-redir3.0
sh/tests/parser/only-redir4.0
sh/tests/parser/pipe-not1.0
sh/tests/parser/set-v1.0 [new file with mode: 0644]
sh/tests/parser/set-v1.0.stderr [new file with mode: 0644]
sh/tests/parser/var-assign1.0
sh/tests/set-e/Makefile
sh/tests/set-e/Makefile.depend [new file with mode: 0644]
sh/tests/set-e/and1.0
sh/tests/set-e/and2.1
sh/tests/set-e/and3.0
sh/tests/set-e/and4.0
sh/tests/set-e/background1.0
sh/tests/set-e/cmd1.0
sh/tests/set-e/cmd2.1
sh/tests/set-e/elif1.0
sh/tests/set-e/elif2.0
sh/tests/set-e/eval1.0
sh/tests/set-e/eval2.1
sh/tests/set-e/for1.0
sh/tests/set-e/func1.0
sh/tests/set-e/func2.1
sh/tests/set-e/if1.0
sh/tests/set-e/if2.0
sh/tests/set-e/if3.0
sh/tests/set-e/not1.0
sh/tests/set-e/not2.0
sh/tests/set-e/or1.0
sh/tests/set-e/or2.0
sh/tests/set-e/or3.1
sh/tests/set-e/pipe1.1
sh/tests/set-e/pipe2.0
sh/tests/set-e/return1.0
sh/tests/set-e/semi1.1
sh/tests/set-e/semi2.1
sh/tests/set-e/subshell1.0
sh/tests/set-e/subshell2.1
sh/tests/set-e/until1.0
sh/tests/set-e/until2.0
sh/tests/set-e/until3.0
sh/tests/set-e/while1.0
sh/tests/set-e/while2.0
sh/tests/set-e/while3.0
sh/trap.c
sh/trap.h
sh/var.c
sh/var.h
shell_cmds.xcodeproj/project.pbxproj
test/tests/legacy_test.sh
tests/regress.m4 [new file with mode: 0644]
tests/shell_cmds.plist [new file with mode: 0644]
which/which.1
which/which.c
xcodescripts/install-files.sh

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..9bce6af
--- /dev/null
@@ -0,0 +1 @@
+xcuserdata
index e712874f71b5112fd54bb15fa61048b3bce942f7..e1d9b669556e0a276f2153dd474e25f34115f84b 100644 (file)
@@ -134,6 +134,7 @@ main(int argc, char *argv[])
                                        *p = '?';
                if (!*argv || requested(argv, &ab)) {
 
                                        *p = '?';
                if (!*argv || requested(argv, &ab)) {
 
+                       time_t timelong = ab.ac_btime;
                        t = expand(ab.ac_utime) + expand(ab.ac_stime);
                        (void)printf(
                            "%-*.*s %-7s %-*.*s %-*.*s %6.2f secs %.16s",
                        t = expand(ab.ac_utime) + expand(ab.ac_stime);
                        (void)printf(
                            "%-*.*s %-7s %-*.*s %-*.*s %6.2f secs %.16s",
@@ -143,7 +144,7 @@ main(int argc, char *argv[])
                             UT_NAMESIZE, UT_NAMESIZE,
                             user_from_uid(ab.ac_uid, 0), UT_LINESIZE,
                             UT_LINESIZE, getdev(ab.ac_tty),
                             UT_NAMESIZE, UT_NAMESIZE,
                             user_from_uid(ab.ac_uid, 0), UT_LINESIZE,
                             UT_LINESIZE, getdev(ab.ac_tty),
-                            t / (double)AHZ, ctime(&ab.ac_btime));
+                            t / (double)AHZ, ctime(&timelong));
                        delta = expand(ab.ac_etime) / (double)AHZ;
                        printf(" (%1.0f:%02.0f:%05.2f)\n",
                               floor(delta / SECSPERHOUR),
                        delta = expand(ab.ac_etime) / (double)AHZ;
                        printf(" (%1.0f:%02.0f:%05.2f)\n",
                               floor(delta / SECSPERHOUR),
index fdf099b6e2d58ce64658b374e62ebf2eb36ce31d..09fbf0e6476bf2bac8268635ee1da905193b3ed1 100644 (file)
@@ -23,4 +23,4 @@
 # an empty database.
 #
 # be careful if you add 'nfs'
 # an empty database.
 #
 # be careful if you add 'nfs'
-#FILESYSTEMS="hfs ufs"
+#FILESYSTEMS="hfs ufs apfs"
index 131b1f480797c6ea4ac7a35e72ad660c6bc30a51..3bbddeaeaeaceb2208dc7e35ac8126747982b0cf 100644 (file)
@@ -56,11 +56,11 @@ PATH=$LIBEXECDIR:/bin:/usr/bin:$PATH; export PATH
 # 6497475
 set -o noglob
 
 # 6497475
 set -o noglob
 
-: ${mklocatedb:=locate.mklocatedb}      # make locate database program
-: ${FCODES:=/var/db/locate.database}    # the database
-: ${SEARCHPATHS:="/"}          # directories to be put in the database
+: ${mklocatedb:=locate.mklocatedb}      # make locate database program
+: ${FCODES:=/var/db/locate.database}    # the database
+: ${SEARCHPATHS:="/"}                   # directories to be put in the database
 : ${PRUNEPATHS:="/private/tmp /private/var/folders /private/var/tmp */Backups.backupdb"} # unwanted directories
 : ${PRUNEPATHS:="/private/tmp /private/var/folders /private/var/tmp */Backups.backupdb"} # unwanted directories
-: ${FILESYSTEMS:="hfs ufs"}                     # allowed filesystems 
+: ${FILESYSTEMS:="hfs ufs apfs"}        # allowed filesystems
 : ${find:=find}
 
 case X"$SEARCHPATHS" in 
 : ${find:=find}
 
 case X"$SEARCHPATHS" in 
index 7256b53df3abc241cd072c704ce73b1b98e893f8..59643b5bccc1531aa8a2e66b500f7a7baa98aed0 100644 (file)
@@ -29,7 +29,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\"    @(#)printf.1    8.1 (Berkeley) 6/6/93
 .\" SUCH DAMAGE.
 .\"
 .\"    @(#)printf.1    8.1 (Berkeley) 6/6/93
-.\" $FreeBSD$
+.\" $FreeBSD: head/usr.bin/printf/printf.1 264743 2014-04-21 22:47:18Z pfg $
 .\"
 .Dd April 21, 2014
 .Dt PRINTF 1
 .\"
 .Dd April 21, 2014
 .Dt PRINTF 1
index 8636cc13c1ef0c338244047eb862f2d4f6f1df2a..438b85ece61f18d90bbe68f01446a783386be8e3 100644 (file)
@@ -46,7 +46,7 @@ static char const copyright[] =
 static char const sccsid[] = "@(#)printf.c     8.1 (Berkeley) 7/20/93";
 #endif
 static const char rcsid[] =
 static char const sccsid[] = "@(#)printf.c     8.1 (Berkeley) 7/20/93";
 #endif
 static const char rcsid[] =
-  "$FreeBSD$";
+  "$FreeBSD: head/usr.bin/printf/printf.c 279503 2015-03-01 21:46:55Z jilles $";
 #endif /* not lint */
 
 #include <sys/types.h>
 #endif /* not lint */
 
 #include <sys/types.h>
diff --git a/printf/tests/Makefile b/printf/tests/Makefile
new file mode 100644 (file)
index 0000000..7d014a5
--- /dev/null
@@ -0,0 +1,22 @@
+# $FreeBSD: head/usr.bin/printf/tests/Makefile 299094 2016-05-04 23:20:53Z ngie $
+
+PACKAGE=       tests
+
+TAP_TESTS_SH=  legacy_test
+
+${PACKAGE}FILES+=              regress.b.out
+${PACKAGE}FILES+=              regress.d.out
+${PACKAGE}FILES+=              regress.f.out
+${PACKAGE}FILES+=              regress.l1.out
+${PACKAGE}FILES+=              regress.l2.out
+${PACKAGE}FILES+=              regress.m1.out
+${PACKAGE}FILES+=              regress.m2.out
+${PACKAGE}FILES+=              regress.m3.out
+${PACKAGE}FILES+=              regress.m4.out
+${PACKAGE}FILES+=              regress.m5.out
+${PACKAGE}FILES+=              regress.missingpos1.out
+${PACKAGE}FILES+=              regress.s.out
+${PACKAGE}FILES+=              regress.sh
+${PACKAGE}FILES+=              regress.zero.out
+
+.include <bsd.test.mk>
diff --git a/printf/tests/Makefile.depend b/printf/tests/Makefile.depend
new file mode 100644 (file)
index 0000000..0fd1616
--- /dev/null
@@ -0,0 +1,11 @@
+# $FreeBSD: head/usr.bin/printf/tests/Makefile.depend 296587 2016-03-09 22:46:01Z bdrewery $
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/printf/tests/legacy_test.sh b/printf/tests/legacy_test.sh
new file mode 100644 (file)
index 0000000..7b1f694
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh
+# $FreeBSD: head/usr.bin/printf/tests/legacy_test.sh 263227 2014-03-16 08:04:06Z jmmv $
+
+SRCDIR="$(dirname "${0}")"; export SRCDIR
+
+m4 /AppleInternal/Tests/shell_cmds/regress.m4 "${SRCDIR}/regress.sh" | sh
diff --git a/printf/tests/regress.b.out b/printf/tests/regress.b.out
new file mode 100644 (file)
index 0000000..0373d93
--- /dev/null
@@ -0,0 +1 @@
+abcdef
diff --git a/printf/tests/regress.d.out b/printf/tests/regress.d.out
new file mode 100644 (file)
index 0000000..da83c08
--- /dev/null
@@ -0,0 +1 @@
+123,  123,00123,00123,00123
diff --git a/printf/tests/regress.f.out b/printf/tests/regress.f.out
new file mode 100644 (file)
index 0000000..127cb8a
--- /dev/null
@@ -0,0 +1 @@
+42.250000,-42.250 ,inf,nan
diff --git a/printf/tests/regress.l1.out b/printf/tests/regress.l1.out
new file mode 100644 (file)
index 0000000..9be0dc9
--- /dev/null
@@ -0,0 +1 @@
+228
diff --git a/printf/tests/regress.l2.out b/printf/tests/regress.l2.out
new file mode 100644 (file)
index 0000000..9be0dc9
--- /dev/null
@@ -0,0 +1 @@
+228
diff --git a/printf/tests/regress.m1.out b/printf/tests/regress.m1.out
new file mode 100644 (file)
index 0000000..a9e063e
Binary files /dev/null and b/printf/tests/regress.m1.out differ
diff --git a/printf/tests/regress.m2.out b/printf/tests/regress.m2.out
new file mode 100644 (file)
index 0000000..cf14915
--- /dev/null
@@ -0,0 +1,2 @@
+abc
+cdef
\ No newline at end of file
diff --git a/printf/tests/regress.m3.out b/printf/tests/regress.m3.out
new file mode 100644 (file)
index 0000000..bbe4e70
--- /dev/null
@@ -0,0 +1,4 @@
+%abc
+%def
+%ghi
+%jkl
diff --git a/printf/tests/regress.m4.out b/printf/tests/regress.m4.out
new file mode 100644 (file)
index 0000000..5e0b5d4
--- /dev/null
@@ -0,0 +1 @@
+0,0.000000,,
diff --git a/printf/tests/regress.m5.out b/printf/tests/regress.m5.out
new file mode 100644 (file)
index 0000000..2838468
--- /dev/null
@@ -0,0 +1 @@
+-d
diff --git a/printf/tests/regress.missingpos1.out b/printf/tests/regress.missingpos1.out
new file mode 100644 (file)
index 0000000..3b04f03
--- /dev/null
@@ -0,0 +1 @@
+printf: incomplete use of n$
diff --git a/printf/tests/regress.s.out b/printf/tests/regress.s.out
new file mode 100644 (file)
index 0000000..3d572b9
--- /dev/null
@@ -0,0 +1 @@
+abc,abc  
diff --git a/printf/tests/regress.sh b/printf/tests/regress.sh
new file mode 100644 (file)
index 0000000..2f68c7d
--- /dev/null
@@ -0,0 +1,33 @@
+# $FreeBSD: head/usr.bin/printf/tests/regress.sh 266854 2014-05-29 19:48:18Z pfg $
+
+enable -n printf
+
+REGRESSION_START($1)
+
+echo '1..23'
+
+REGRESSION_TEST(`b', `printf "abc%b%b" "def\n" "\cghi"')
+REGRESSION_TEST(`d', `printf "%d,%5d,%.5d,%0*d,%.*d\n" 123 123 123 5 123 5 123')
+REGRESSION_TEST(`f', `printf "%f,%-8.3f,%f,%f\n" +42.25 -42.25 inf nan')
+REGRESSION_TEST(`l1', `LC_ALL=en_US.ISO8859-1 printf "%d\n" $(printf \"\\344)')
+REGRESSION_TEST(`l2', `LC_ALL=en_US.UTF-8 printf "%d\n" $(printf \"\\303\\244)')
+REGRESSION_TEST(`m1', `printf "%c%%%d\0\045\n" abc \"abc')
+REGRESSION_TEST(`m2', `printf "abc\n\cdef"')
+REGRESSION_TEST(`m3', `printf "%%%s\n" abc def ghi jkl')
+REGRESSION_TEST(`m4', `printf "%d,%f,%c,%s\n"')
+REGRESSION_TEST(`m5', `printf -- "-d\n"')
+REGRESSION_TEST(`s', `printf "%.3s,%-5s\n" abcd abc')
+REGRESSION_TEST('zero', `printf "%u%u\n" 15')
+REGRESSION_TEST('zero', `printf "%d%d\n" 15')
+REGRESSION_TEST('zero', `printf "%d%u\n" 15')
+REGRESSION_TEST('zero', `printf "%u%d\n" 15')
+REGRESSION_TEST(`missingpos1', `printf "%1\$*s" 1 1 2>&1')
+REGRESSION_TEST(`missingpos1', `printf "%*1\$s" 1 1 2>&1')
+REGRESSION_TEST(`missingpos1', `printf "%1\$*.*s" 1 1 1 2>&1')
+REGRESSION_TEST(`missingpos1', `printf "%*1\$.*s" 1 1 1 2>&1')
+REGRESSION_TEST(`missingpos1', `printf "%*.*1\$s" 1 1 1 2>&1')
+REGRESSION_TEST(`missingpos1', `printf "%1\$*2\$.*s" 1 1 1 2>&1')
+REGRESSION_TEST(`missingpos1', `printf "%*1\$.*2\$s" 1 1 1 2>&1')
+REGRESSION_TEST(`missingpos1', `printf "%1\$*.*2\$s" 1 1 1 2>&1')
+
+REGRESSION_END()
diff --git a/printf/tests/regress.zero.out b/printf/tests/regress.zero.out
new file mode 100644 (file)
index 0000000..fa8f08c
--- /dev/null
@@ -0,0 +1 @@
+150
index 3f28a1231fd3bdc6f54a507a4ae3fabbb7d38bf8..08fa278910d0b08be258ecbf7049548859dd475e 100644 (file)
@@ -1,8 +1,9 @@
 #      @(#)Makefile    8.4 (Berkeley) 5/5/95
 #      @(#)Makefile    8.4 (Berkeley) 5/5/95
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/Makefile 301285 2016-06-03 19:25:41Z bdrewery $
 
 .include <src.opts.mk>
 
 
 .include <src.opts.mk>
 
+PACKAGE=runtime
 PROG=  sh
 INSTALLFLAGS= -S
 SHSRCS=        alias.c arith_yacc.c arith_yylex.c cd.c echo.c error.c eval.c \
 PROG=  sh
 INSTALLFLAGS= -S
 SHSRCS=        alias.c arith_yacc.c arith_yylex.c cd.c echo.c error.c eval.c \
@@ -38,24 +39,27 @@ CLEANFILES+= ${GENSRCS} ${GENHDRS}
 build-tools: mknodes mksyntax
 
 .ORDER: builtins.c builtins.h
 build-tools: mknodes mksyntax
 
 .ORDER: builtins.c builtins.h
+builtins.h: .NOMETA
 builtins.c builtins.h: mkbuiltins builtins.def
        sh ${.CURDIR}/mkbuiltins ${.CURDIR}
 
 # XXX this is just to stop the default .c rule being used, so that the
 # intermediate object has a fixed name.
 # XXX we have a default .c rule, but no default .o rule.
 builtins.c builtins.h: mkbuiltins builtins.def
        sh ${.CURDIR}/mkbuiltins ${.CURDIR}
 
 # XXX this is just to stop the default .c rule being used, so that the
 # intermediate object has a fixed name.
 # XXX we have a default .c rule, but no default .o rule.
-.o:
+mknodes.o mksyntax.o: ${BUILD_TOOLS_META}
        ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
        ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
-mknodes: mknodes.o
-mksyntax: mksyntax.o
+mknodes: mknodes.o ${BUILD_TOOLS_META}
+mksyntax: mksyntax.o ${BUILD_TOOLS_META}
 
 .ORDER: nodes.c nodes.h
 
 .ORDER: nodes.c nodes.h
+nodes.h: .NOMETA
 nodes.c nodes.h: mknodes nodetypes nodes.c.pat
 nodes.c nodes.h: mknodes nodetypes nodes.c.pat
-       ./mknodes ${.CURDIR}/nodetypes ${.CURDIR}/nodes.c.pat
+       ${BTOOLSPATH:U.}/mknodes ${.CURDIR}/nodetypes ${.CURDIR}/nodes.c.pat
 
 .ORDER: syntax.c syntax.h
 
 .ORDER: syntax.c syntax.h
+syntax.h: .NOMETA
 syntax.c syntax.h: mksyntax
 syntax.c syntax.h: mksyntax
-       ./mksyntax
+       ${BTOOLSPATH:U.}/mksyntax
 
 token.h: mktokens
        sh ${.CURDIR}/mktokens
 
 token.h: mktokens
        sh ${.CURDIR}/mktokens
index 9eb4fbac77e6227d4796651054ffcb007c7ee215..e33ea1e569c179c024277f5119e28b30aa8d2cab 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/Makefile.depend 295989 2016-02-24 17:20:11Z bdrewery $
 # Autogenerated - do NOT edit!
 
 DIRDEPS = \
 # Autogenerated - do NOT edit!
 
 DIRDEPS = \
@@ -17,98 +17,4 @@ DIRDEPS = \
 
 .if ${DEP_RELDIR} == ${_DEP_RELDIR}
 # local dependencies - needed for -jN in clean tree
 
 .if ${DEP_RELDIR} == ${_DEP_RELDIR}
 # local dependencies - needed for -jN in clean tree
-alias.o: builtins.h
-alias.po: builtins.h
-arith_yylex.o: syntax.h
-arith_yylex.po: syntax.h
-builtins.o: builtins.c
-builtins.o: builtins.h
-builtins.po: builtins.c
-builtins.po: builtins.h
-cd.o: builtins.h
-cd.o: nodes.h
-cd.po: builtins.h
-cd.po: nodes.h
-echo.o: builtins.h
-echo.po: builtins.h
-error.o: nodes.h
-error.po: nodes.h
-eval.o: builtins.h
-eval.o: nodes.h
-eval.o: syntax.h
-eval.po: builtins.h
-eval.po: nodes.h
-eval.po: syntax.h
-exec.o: builtins.h
-exec.o: nodes.h
-exec.o: syntax.h
-exec.po: builtins.h
-exec.po: nodes.h
-exec.po: syntax.h
-expand.o: builtins.h
-expand.o: nodes.h
-expand.o: syntax.h
-expand.po: builtins.h
-expand.po: nodes.h
-expand.po: syntax.h
-histedit.o: builtins.h
-histedit.po: builtins.h
-input.o: syntax.h
-input.po: syntax.h
-jobs.o: builtins.h
-jobs.o: nodes.h
-jobs.o: syntax.h
-jobs.po: builtins.h
-jobs.po: nodes.h
-jobs.po: syntax.h
-kill.o: builtins.h
-kill.po: builtins.h
-main.o: builtins.h
-main.o: nodes.h
-main.po: builtins.h
-main.po: nodes.h
-miscbltin.o: syntax.h
-miscbltin.po: syntax.h
-mystring.o: syntax.h
-mystring.po: syntax.h
-nodes.o: nodes.c
-nodes.o: nodes.h
-nodes.po: nodes.c
-nodes.po: nodes.h
-options.o: builtins.h
-options.o: nodes.h
-options.po: builtins.h
-options.po: nodes.h
-output.o: syntax.h
-output.po: syntax.h
-parser.o: nodes.h
-parser.o: syntax.h
-parser.o: token.h
-parser.po: nodes.h
-parser.po: syntax.h
-parser.po: token.h
-printf.o: builtins.h
-printf.po: builtins.h
-redir.o: nodes.h
-redir.po: nodes.h
-show.o: nodes.h
-show.po: nodes.h
-syntax.o: syntax.c
-syntax.o: syntax.h
-syntax.po: syntax.c
-syntax.po: syntax.h
-test.o: builtins.h
-test.po: builtins.h
-trap.o: builtins.h
-trap.o: nodes.h
-trap.o: syntax.h
-trap.po: builtins.h
-trap.po: nodes.h
-trap.po: syntax.h
-var.o: builtins.h
-var.o: nodes.h
-var.o: syntax.h
-var.po: builtins.h
-var.po: nodes.h
-var.po: syntax.h
 .endif
 .endif
diff --git a/sh/TOUR b/sh/TOUR
index e9bbe9b121b56deaab00394f62e2c80c56612913..6d180eda68399b9e9064e5bdbd341573b5d25d9d 100644 (file)
--- a/sh/TOUR
+++ b/sh/TOUR
@@ -1,5 +1,5 @@
 #      @(#)TOUR        8.1 (Berkeley) 5/31/93
 #      @(#)TOUR        8.1 (Berkeley) 5/31/93
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/TOUR 253650 2013-07-25 15:08:41Z jilles $
 
 NOTE -- This is the original TOUR paper distributed with ash and
 does not represent the current state of the shell.  It is provided anyway
 
 NOTE -- This is the original TOUR paper distributed with ash and
 does not represent the current state of the shell.  It is provided anyway
index a77ce99a9f070509fac1402e8d3ac519ad5c1eba..4eb6f9e55235a03fc37e4566545bb49e09eabcba 100644 (file)
@@ -36,7 +36,7 @@ static char sccsid[] = "@(#)alias.c   8.3 (Berkeley) 5/4/95";
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/bin/sh/alias.c 295868 2016-02-21 20:58:24Z jilles $");
 
 #include <stdlib.h>
 #include "shell.h"
 
 #include <stdlib.h>
 #include "shell.h"
@@ -144,9 +144,11 @@ rmaliases(void)
 struct alias *
 lookupalias(const char *name, int check)
 {
 struct alias *
 lookupalias(const char *name, int check)
 {
-       struct alias *ap = *hashalias(name);
+       struct alias *ap;
 
 
-       for (; ap; ap = ap->next) {
+       if (aliases == 0)
+               return (NULL);
+       for (ap = *hashalias(name); ap; ap = ap->next) {
                if (equal(name, ap->name)) {
                        if (check && (ap->flag & ALIASINUSE))
                                return (NULL);
                if (equal(name, ap->name)) {
                        if (check && (ap->flag & ALIASINUSE))
                                return (NULL);
index 546e91a1f3f28848561578f16998b451ab7f0c2b..95a20eaefd20ec2b0b5944949c9f01cc737657c3 100644 (file)
@@ -30,7 +30,7 @@
  * SUCH DAMAGE.
  *
  *     @(#)alias.h     8.2 (Berkeley) 5/4/95
  * SUCH DAMAGE.
  *
  *     @(#)alias.h     8.2 (Berkeley) 5/4/95
- * $FreeBSD$
+ * $FreeBSD: head/bin/sh/alias.h 223060 2011-06-13 21:03:27Z jilles $
  */
 
 #define ALIASINUSE     1
  */
 
 #define ALIASINUSE     1
index 5b18bd677cccdcca5a56251013f1c29b5e80e52a..3771fe10116e187078cc421a84c17bca87c173f5 100644 (file)
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  *
  *     @(#)arith.h     1.1 (Berkeley) 5/4/95
  * SUCH DAMAGE.
  *
  *     @(#)arith.h     1.1 (Berkeley) 5/4/95
- * $FreeBSD$
+ * $FreeBSD: head/bin/sh/arith.h 223060 2011-06-13 21:03:27Z jilles $
  */
 
 #include "shell.h"
  */
 
 #include "shell.h"
index 5000c6b0d1bef5764b4b1359823554ad1ecffdd2..20e1e43ebcd03991e6b02323c805e26bb27f7678 100644 (file)
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/bin/sh/arith_yacc.c 270246 2014-08-20 20:15:43Z jilles $");
 
 #include <limits.h>
 #include <errno.h>
 
 #include <limits.h>
 #include <errno.h>
index ca92e6f7fa1754da75b3d08c7ba862c7b9a03901..d386886ad8e55bce85359d6321db60ed42ef3fae 100644 (file)
@@ -31,7 +31,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD$
+ * $FreeBSD: head/bin/sh/arith_yacc.h 279503 2015-03-01 21:46:55Z jilles $
  */
 
 #define ARITH_ASS 1
  */
 
 #define ARITH_ASS 1
index f7eaf3e3fa6da59f82af35835e87f7eb4d5d41c9..993685238dae002d49d6b8e94113c95196521422 100644 (file)
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/bin/sh/arith_yylex.c 279503 2015-03-01 21:46:55Z jilles $");
 
 #include <inttypes.h>
 #include <stdlib.h>
 
 #include <inttypes.h>
 #include <stdlib.h>
index a530ab78b2a5587bf2c3b4d20be1c7c9acd0c991..b79cc43a6517743a183861ecbaacb288cad81cd0 100644 (file)
@@ -30,7 +30,7 @@
  * SUCH DAMAGE.
  *
  *     @(#)bltin.h     8.2 (Berkeley) 5/4/95
  * SUCH DAMAGE.
  *
  *     @(#)bltin.h     8.2 (Berkeley) 5/4/95
- * $FreeBSD$
+ * $FreeBSD: head/bin/sh/bltin/bltin.h 279503 2015-03-01 21:46:55Z jilles $
  */
 
 /*
  */
 
 /*
index 457a4c7aefc8da741301571e988615f44a2cf6a5..3de6589ed2159c879f181d3e7f55cc90e9f9003f 100644 (file)
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/bin/sh/bltin/echo.c 127958 2004-04-06 20:06:54Z markm $");
 
 /*
  * Echo command.
 
 /*
  * Echo command.
index 1cbeea913a92733480b858a9eb1f480d308c5550..dd113b60ed18388e7ab9d101f44d7b3435fc4bb4 100644 (file)
@@ -32,7 +32,7 @@
 # SUCH DAMAGE.
 #
 #      @(#)builtins.def        8.4 (Berkeley) 5/4/95
 # SUCH DAMAGE.
 #
 #      @(#)builtins.def        8.4 (Berkeley) 5/4/95
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/builtins.def 288430 2015-09-30 21:32:29Z jilles $
 
 #
 # This file lists all the builtin commands.  The first column is the name
 
 #
 # This file lists all the builtin commands.  The first column is the name
@@ -65,6 +65,7 @@ exportcmd     -s export -s readonly
 #exprcmd               expr
 falsecmd       false
 fgcmd -j       fg
 #exprcmd               expr
 falsecmd       false
 fgcmd -j       fg
+freebsd_wordexpcmd     freebsd_wordexp
 getoptscmd     getopts
 hashcmd                hash
 histcmd -h     fc
 getoptscmd     getopts
 hashcmd                hash
 histcmd -h     fc
diff --git a/sh/cd.c b/sh/cd.c
index 88f03f57d73b041173d778e8888eb679be3d80de..67a80bd712eeb95b3511c075f542b72d788aeaef 100644 (file)
--- a/sh/cd.c
+++ b/sh/cd.c
@@ -36,7 +36,7 @@ static char sccsid[] = "@(#)cd.c      8.2 (Berkeley) 5/4/95";
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/bin/sh/cd.c 294667 2016-01-24 17:01:34Z jilles $");
 
 #include <sys/types.h>
 #include <sys/stat.h>
 
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -68,15 +68,13 @@ __FBSDID("$FreeBSD$");
 static int cdlogical(char *);
 static int cdphysical(char *);
 static int docd(char *, int, int);
 static int cdlogical(char *);
 static int cdphysical(char *);
 static int docd(char *, int, int);
-static char *getcomponent(void);
+static char *getcomponent(char **);
 static char *findcwd(char *);
 static void updatepwd(char *);
 static char *getpwd(void);
 static char *getpwd2(void);
 
 static char *curdir = NULL;    /* current working directory */
 static char *findcwd(char *);
 static void updatepwd(char *);
 static char *getpwd(void);
 static char *getpwd2(void);
 
 static char *curdir = NULL;    /* current working directory */
-static char *prevdir;          /* previous working directory */
-static char *cdcomppath;
 
 int
 cdcmd(int argc __unused, char **argv __unused)
 
 int
 cdcmd(int argc __unused, char **argv __unused)
@@ -112,11 +110,10 @@ cdcmd(int argc __unused, char **argv __unused)
        if (*dest == '\0')
                dest = ".";
        if (dest[0] == '-' && dest[1] == '\0') {
        if (*dest == '\0')
                dest = ".";
        if (dest[0] == '-' && dest[1] == '\0') {
-               dest = prevdir ? prevdir : curdir;
-               if (dest)
-                       print = 1;
-               else
-                       dest = ".";
+               dest = bltinlookup("OLDPWD", 1);
+               if (dest == NULL)
+                       error("OLDPWD not set");
+               print = 1;
        }
        if (dest[0] == '/' ||
            (dest[0] == '.' && (dest[1] == '/' || dest[1] == '\0')) ||
        }
        if (dest[0] == '/' ||
            (dest[0] == '.' && (dest[1] == '/' || dest[1] == '\0')) ||
@@ -179,6 +176,7 @@ cdlogical(char *dest)
        char *p;
        char *q;
        char *component;
        char *p;
        char *q;
        char *component;
+       char *path;
        struct stat statb;
        int first;
        int badstat;
        struct stat statb;
        int first;
        int badstat;
@@ -189,14 +187,14 @@ cdlogical(char *dest)
         *  next time we get the value of the current directory.
         */
        badstat = 0;
         *  next time we get the value of the current directory.
         */
        badstat = 0;
-       cdcomppath = stsavestr(dest);
+       path = stsavestr(dest);
        STARTSTACKSTR(p);
        if (*dest == '/') {
                STPUTC('/', p);
        STARTSTACKSTR(p);
        if (*dest == '/') {
                STPUTC('/', p);
-               cdcomppath++;
+               path++;
        }
        first = 1;
        }
        first = 1;
-       while ((q = getcomponent()) != NULL) {
+       while ((q = getcomponent(&path)) != NULL) {
                if (q[0] == '\0' || (q[0] == '.' && q[1] == '\0'))
                        continue;
                if (! first)
                if (q[0] == '\0' || (q[0] == '.' && q[1] == '\0'))
                        continue;
                if (! first)
@@ -245,25 +243,25 @@ cdphysical(char *dest)
 }
 
 /*
 }
 
 /*
- * Get the next component of the path name pointed to by cdcomppath.
- * This routine overwrites the string pointed to by cdcomppath.
+ * Get the next component of the path name pointed to by *path.
+ * This routine overwrites *path and the string pointed to by it.
  */
 static char *
  */
 static char *
-getcomponent(void)
+getcomponent(char **path)
 {
        char *p;
        char *start;
 
 {
        char *p;
        char *start;
 
-       if ((p = cdcomppath) == NULL)
+       if ((p = *path) == NULL)
                return NULL;
                return NULL;
-       start = cdcomppath;
+       start = *path;
        while (*p != '/' && *p != '\0')
                p++;
        if (*p == '\0') {
        while (*p != '/' && *p != '\0')
                p++;
        if (*p == '\0') {
-               cdcomppath = NULL;
+               *path = NULL;
        } else {
                *p++ = '\0';
        } else {
                *p++ = '\0';
-               cdcomppath = p;
+               *path = p;
        }
        return start;
 }
        }
        return start;
 }
@@ -274,6 +272,7 @@ findcwd(char *dir)
 {
        char *new;
        char *p;
 {
        char *new;
        char *p;
+       char *path;
 
        /*
         * If our argument is NULL, we don't know the current directory
 
        /*
         * If our argument is NULL, we don't know the current directory
@@ -282,14 +281,14 @@ findcwd(char *dir)
         */
        if (dir == NULL || curdir == NULL)
                return getpwd2();
         */
        if (dir == NULL || curdir == NULL)
                return getpwd2();
-       cdcomppath = stsavestr(dir);
+       path = stsavestr(dir);
        STARTSTACKSTR(new);
        if (*dir != '/') {
                STPUTS(curdir, new);
                if (STTOPC(new) == '/')
                        STUNPUTC(new);
        }
        STARTSTACKSTR(new);
        if (*dir != '/') {
                STPUTS(curdir, new);
                if (STTOPC(new) == '/')
                        STUNPUTC(new);
        }
-       while ((p = getcomponent()) != NULL) {
+       while ((p = getcomponent(&path)) != NULL) {
                if (equal(p, "..")) {
                        while (new > stackblock() && (STUNPUTC(new), *new) != '/');
                } else if (*p != '\0' && ! equal(p, ".")) {
                if (equal(p, "..")) {
                        while (new > stackblock() && (STUNPUTC(new), *new) != '/');
                } else if (*p != '\0' && ! equal(p, ".")) {
@@ -311,14 +310,15 @@ findcwd(char *dir)
 static void
 updatepwd(char *dir)
 {
 static void
 updatepwd(char *dir)
 {
+       char *prevdir;
+
        hashcd();                               /* update command hash table */
 
        hashcd();                               /* update command hash table */
 
-       if (prevdir)
-               ckfree(prevdir);
+       setvar("PWD", dir, VEXPORT);
+       setvar("OLDPWD", curdir, VEXPORT);
        prevdir = curdir;
        curdir = dir ? savestr(dir) : NULL;
        prevdir = curdir;
        curdir = dir ? savestr(dir) : NULL;
-       setvar("PWD", curdir, VEXPORT);
-       setvar("OLDPWD", prevdir, VEXPORT);
+       ckfree(prevdir);
 }
 
 int
 }
 
 int
diff --git a/sh/cd.h b/sh/cd.h
index 91fbc2b692aa881673cba1495ab366ce711a61be..6a2c5d3b18b40022451bcc16fbe17f9f708cfd84 100644 (file)
--- a/sh/cd.h
+++ b/sh/cd.h
@@ -26,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD$
+ * $FreeBSD: head/bin/sh/cd.h 223060 2011-06-13 21:03:27Z jilles $
  */
 
 void    pwd_init(int);
  */
 
 void    pwd_init(int);
index 605722669549f29041ac34a45fb01133e725c17e..65198dd226bd041db016ead0fbd618f69a6a5065 100644 (file)
@@ -36,7 +36,7 @@ static char sccsid[] = "@(#)error.c   8.2 (Berkeley) 5/4/95";
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/bin/sh/error.c 279569 2015-03-03 21:21:43Z jilles $");
 
 /*
  * Errors and exceptions.
 
 /*
  * Errors and exceptions.
index a60b1fa1767f772b7bba2b1d40036f85308b825f..4aa7f370b2bca2e9781119981122965909d45861 100644 (file)
@@ -30,7 +30,7 @@
  * SUCH DAMAGE.
  *
  *     @(#)error.h     8.2 (Berkeley) 5/4/95
  * SUCH DAMAGE.
  *
  *     @(#)error.h     8.2 (Berkeley) 5/4/95
- * $FreeBSD$
+ * $FreeBSD: head/bin/sh/error.h 276038 2014-12-21 23:09:59Z jilles $
  */
 
 /*
  */
 
 /*
index 51206d931874c74c000603d65e6bcceccb64cb5d..4184c06ddf81205fcdf97113fe87d7e4c66d4333 100644 (file)
--- a/sh/eval.c
+++ b/sh/eval.c
@@ -36,7 +36,7 @@ static char sccsid[] = "@(#)eval.c    8.9 (Berkeley) 6/8/95";
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/bin/sh/eval.c 293635 2016-01-10 16:31:28Z jilles $");
 
 #include <paths.h>
 #include <signal.h>
 
 #include <paths.h>
 #include <signal.h>
@@ -82,7 +82,7 @@ static int builtin_flags;     /* evalcommand flags for builtins */
 
 
 char *commandname;
 
 
 char *commandname;
-struct strlist *cmdenviron;
+struct arglist *cmdenviron;
 int exitstatus;                        /* exit status of last command */
 int oexitstatus;               /* saved exit status */
 
 int exitstatus;                        /* exit status of last command */
 int oexitstatus;               /* saved exit status */
 
@@ -352,20 +352,19 @@ evalfor(union node *n, int flags)
 {
        struct arglist arglist;
        union node *argp;
 {
        struct arglist arglist;
        union node *argp;
-       struct strlist *sp;
+       int i;
        int status;
 
        int status;
 
-       arglist.lastp = &arglist.list;
+       emptyarglist(&arglist);
        for (argp = n->nfor.args ; argp ; argp = argp->narg.next) {
                oexitstatus = exitstatus;
                expandarg(argp, &arglist, EXP_FULL | EXP_TILDE);
        }
        for (argp = n->nfor.args ; argp ; argp = argp->narg.next) {
                oexitstatus = exitstatus;
                expandarg(argp, &arglist, EXP_FULL | EXP_TILDE);
        }
-       *arglist.lastp = NULL;
 
        loopnest++;
        status = 0;
 
        loopnest++;
        status = 0;
-       for (sp = arglist.list ; sp ; sp = sp->next) {
-               setvar(n->nfor.var, sp->text, 0);
+       for (i = 0; i < arglist.count; i++) {
+               setvar(n->nfor.var, arglist.args[i], 0);
                evaltree(n->nfor.body, flags);
                status = exitstatus;
                if (evalskip) {
                evaltree(n->nfor.body, flags);
                status = exitstatus;
                if (evalskip) {
@@ -396,12 +395,12 @@ evalcase(union node *n)
        union node *patp;
        struct arglist arglist;
 
        union node *patp;
        struct arglist arglist;
 
-       arglist.lastp = &arglist.list;
+       emptyarglist(&arglist);
        oexitstatus = exitstatus;
        expandarg(n->ncase.expr, &arglist, EXP_TILDE);
        for (cp = n->ncase.cases ; cp ; cp = cp->nclist.next) {
                for (patp = cp->nclist.pattern ; patp ; patp = patp->narg.next) {
        oexitstatus = exitstatus;
        expandarg(n->ncase.expr, &arglist, EXP_TILDE);
        for (cp = n->ncase.cases ; cp ; cp = cp->nclist.next) {
                for (patp = cp->nclist.pattern ; patp ; patp = patp->narg.next) {
-                       if (casematch(patp, arglist.list->text)) {
+                       if (casematch(patp, arglist.args[0])) {
                                while (cp->nclist.next &&
                                    cp->type == NCLISTFALLTHRU &&
                                    cp->nclist.body == NULL)
                                while (cp->nclist.next &&
                                    cp->type == NCLISTFALLTHRU &&
                                    cp->nclist.body == NULL)
@@ -497,10 +496,12 @@ exphere(union node *redir, struct arglist *fn)
        struct jmploc *savehandler;
        struct localvar *savelocalvars;
        int need_longjmp = 0;
        struct jmploc *savehandler;
        struct localvar *savelocalvars;
        int need_longjmp = 0;
+       unsigned char saveoptreset;
 
        redir->nhere.expdoc = "";
        savelocalvars = localvars;
        localvars = NULL;
 
        redir->nhere.expdoc = "";
        savelocalvars = localvars;
        localvars = NULL;
+       saveoptreset = shellparam.reset;
        forcelocal++;
        savehandler = handler;
        if (setjmp(jmploc.loc))
        forcelocal++;
        savehandler = handler;
        if (setjmp(jmploc.loc))
@@ -508,13 +509,14 @@ exphere(union node *redir, struct arglist *fn)
        else {
                handler = &jmploc;
                expandarg(redir->nhere.doc, fn, 0);
        else {
                handler = &jmploc;
                expandarg(redir->nhere.doc, fn, 0);
-               redir->nhere.expdoc = fn->list->text;
+               redir->nhere.expdoc = fn->args[0];
                INTOFF;
        }
        handler = savehandler;
        forcelocal--;
        poplocalvars();
        localvars = savelocalvars;
                INTOFF;
        }
        handler = savehandler;
        forcelocal--;
        poplocalvars();
        localvars = savelocalvars;
+       shellparam.reset = saveoptreset;
        if (need_longjmp)
                longjmp(handler->loc, 1);
        INTON;
        if (need_longjmp)
                longjmp(handler->loc, 1);
        INTON;
@@ -532,7 +534,7 @@ expredir(union node *n)
 
        for (redir = n ; redir ; redir = redir->nfile.next) {
                struct arglist fn;
 
        for (redir = n ; redir ; redir = redir->nfile.next) {
                struct arglist fn;
-               fn.lastp = &fn.list;
+               emptyarglist(&fn);
                switch (redir->type) {
                case NFROM:
                case NTO:
                switch (redir->type) {
                case NFROM:
                case NTO:
@@ -540,13 +542,13 @@ expredir(union node *n)
                case NAPPEND:
                case NCLOBBER:
                        expandarg(redir->nfile.fname, &fn, EXP_TILDE);
                case NAPPEND:
                case NCLOBBER:
                        expandarg(redir->nfile.fname, &fn, EXP_TILDE);
-                       redir->nfile.expfname = fn.list->text;
+                       redir->nfile.expfname = fn.args[0];
                        break;
                case NFROMFD:
                case NTOFD:
                        if (redir->ndup.vname) {
                                expandarg(redir->ndup.vname, &fn, EXP_TILDE);
                        break;
                case NFROMFD:
                case NTOFD:
                        if (redir->ndup.vname) {
                                expandarg(redir->ndup.vname, &fn, EXP_TILDE);
-                               fixredir(redir, fn.list->text, 1);
+                               fixredir(redir, fn.args[0], 1);
                        }
                        break;
                case NXHERE:
                        }
                        break;
                case NXHERE:
@@ -648,6 +650,7 @@ evalbackcmd(union node *n, struct backcmd *result)
        struct jmploc jmploc;
        struct jmploc *savehandler;
        struct localvar *savelocalvars;
        struct jmploc jmploc;
        struct jmploc *savehandler;
        struct localvar *savelocalvars;
+       unsigned char saveoptreset;
 
        result->fd = -1;
        result->buf = NULL;
 
        result->fd = -1;
        result->buf = NULL;
@@ -662,6 +665,7 @@ evalbackcmd(union node *n, struct backcmd *result)
        if (is_valid_fast_cmdsubst(n)) {
                savelocalvars = localvars;
                localvars = NULL;
        if (is_valid_fast_cmdsubst(n)) {
                savelocalvars = localvars;
                localvars = NULL;
+               saveoptreset = shellparam.reset;
                forcelocal++;
                savehandler = handler;
                if (setjmp(jmploc.loc)) {
                forcelocal++;
                savehandler = handler;
                if (setjmp(jmploc.loc)) {
@@ -672,6 +676,7 @@ evalbackcmd(union node *n, struct backcmd *result)
                                forcelocal--;
                                poplocalvars();
                                localvars = savelocalvars;
                                forcelocal--;
                                poplocalvars();
                                localvars = savelocalvars;
+                               shellparam.reset = saveoptreset;
                                longjmp(handler->loc, 1);
                        }
                } else {
                                longjmp(handler->loc, 1);
                        }
                } else {
@@ -682,6 +687,7 @@ evalbackcmd(union node *n, struct backcmd *result)
                forcelocal--;
                poplocalvars();
                localvars = savelocalvars;
                forcelocal--;
                poplocalvars();
                localvars = savelocalvars;
+               shellparam.reset = saveoptreset;
        } else {
                if (pipe(pip) < 0)
                        error("Pipe call failed: %s", strerror(errno));
        } else {
                if (pipe(pip) < 0)
                        error("Pipe call failed: %s", strerror(errno));
@@ -751,30 +757,32 @@ isdeclarationcmd(struct narg *arg)
 }
 
 static void
 }
 
 static void
-xtracecommand(struct arglist *varlist, struct arglist *arglist)
+xtracecommand(struct arglist *varlist, int argc, char **argv)
 {
 {
-       struct strlist *sp;
        char sep = 0;
        char sep = 0;
-       const char *p, *ps4;
+       const char *text, *p, *ps4;
+       int i;
 
        ps4 = expandstr(ps4val());
        out2str(ps4 != NULL ? ps4 : ps4val());
 
        ps4 = expandstr(ps4val());
        out2str(ps4 != NULL ? ps4 : ps4val());
-       for (sp = varlist->list ; sp ; sp = sp->next) {
+       for (i = 0; i < varlist->count; i++) {
+               text = varlist->args[i];
                if (sep != 0)
                        out2c(' ');
                if (sep != 0)
                        out2c(' ');
-               p = strchr(sp->text, '=');
+               p = strchr(text, '=');
                if (p != NULL) {
                        p++;
                if (p != NULL) {
                        p++;
-                       outbin(sp->text, p - sp->text, out2);
+                       outbin(text, p - text, out2);
                        out2qstr(p);
                } else
                        out2qstr(p);
                } else
-                       out2qstr(sp->text);
+                       out2qstr(text);
                sep = ' ';
        }
                sep = ' ';
        }
-       for (sp = arglist->list ; sp ; sp = sp->next) {
+       for (i = 0; i < argc; i++) {
+               text = argv[i];
                if (sep != 0)
                        out2c(' ');
                if (sep != 0)
                        out2c(' ');
-               out2qstr(sp->text);
+               out2qstr(text);
                sep = ' ';
        }
        out2c('\n');
                sep = ' ';
        }
        out2c('\n');
@@ -822,7 +830,6 @@ evalcommand(union node *cmd, int flags, struct backcmd *backcmd)
        int argc;
        char **envp;
        int varflag;
        int argc;
        char **envp;
        int varflag;
-       struct strlist *sp;
        int mode;
        int pip[2];
        struct cmdentry cmdentry;
        int mode;
        int pip[2];
        struct cmdentry cmdentry;
@@ -838,16 +845,19 @@ evalcommand(union node *cmd, int flags, struct backcmd *backcmd)
        int realstatus;
        int do_clearcmdentry;
        const char *path = pathval();
        int realstatus;
        int do_clearcmdentry;
        const char *path = pathval();
+       int i;
 
        /* First expand the arguments. */
        TRACE(("evalcommand(%p, %d) called\n", (void *)cmd, flags));
 
        /* First expand the arguments. */
        TRACE(("evalcommand(%p, %d) called\n", (void *)cmd, flags));
-       arglist.lastp = &arglist.list;
-       varlist.lastp = &varlist.list;
+       emptyarglist(&arglist);
+       emptyarglist(&varlist);
        varflag = 1;
        jp = NULL;
        do_clearcmdentry = 0;
        oexitstatus = exitstatus;
        exitstatus = 0;
        varflag = 1;
        jp = NULL;
        do_clearcmdentry = 0;
        oexitstatus = exitstatus;
        exitstatus = 0;
+       /* Add one slot at the beginning for tryexec(). */
+       appendarglist(&arglist, nullstr);
        for (argp = cmd->ncmd.args ; argp ; argp = argp->narg.next) {
                if (varflag && isassignment(argp->narg.text)) {
                        expandarg(argp, varflag == 1 ? &varlist : &arglist,
        for (argp = cmd->ncmd.args ; argp ; argp = argp->narg.next) {
                if (varflag && isassignment(argp->narg.text)) {
                        expandarg(argp, varflag == 1 ? &varlist : &arglist,
@@ -857,29 +867,19 @@ evalcommand(union node *cmd, int flags, struct backcmd *backcmd)
                        varflag = isdeclarationcmd(&argp->narg) ? 2 : 0;
                expandarg(argp, &arglist, EXP_FULL | EXP_TILDE);
        }
                        varflag = isdeclarationcmd(&argp->narg) ? 2 : 0;
                expandarg(argp, &arglist, EXP_FULL | EXP_TILDE);
        }
-       *arglist.lastp = NULL;
-       *varlist.lastp = NULL;
+       appendarglist(&arglist, nullstr);
        expredir(cmd->ncmd.redirect);
        expredir(cmd->ncmd.redirect);
-       argc = 0;
-       for (sp = arglist.list ; sp ; sp = sp->next)
-               argc++;
-       /* Add one slot at the beginning for tryexec(). */
-       argv = stalloc(sizeof (char *) * (argc + 2));
-       argv++;
+       argc = arglist.count - 2;
+       argv = &arglist.args[1];
 
 
-       for (sp = arglist.list ; sp ; sp = sp->next) {
-               TRACE(("evalcommand arg: %s\n", sp->text));
-               *argv++ = sp->text;
-       }
-       *argv = NULL;
+       argv[argc] = NULL;
        lastarg = NULL;
        if (iflag && funcnest == 0 && argc > 0)
        lastarg = NULL;
        if (iflag && funcnest == 0 && argc > 0)
-               lastarg = argv[-1];
-       argv -= argc;
+               lastarg = argv[argc - 1];
 
        /* Print the command if xflag is set. */
        if (xflag)
 
        /* Print the command if xflag is set. */
        if (xflag)
-               xtracecommand(&varlist, &arglist);
+               xtracecommand(&varlist, argc, argv);
 
        /* Now locate the command. */
        if (argc == 0) {
 
        /* Now locate the command. */
        if (argc == 0) {
@@ -895,9 +895,9 @@ evalcommand(union node *cmd, int flags, struct backcmd *backcmd)
                 * Modify the command lookup path, if a PATH= assignment
                 * is present
                 */
                 * Modify the command lookup path, if a PATH= assignment
                 * is present
                 */
-               for (sp = varlist.list ; sp ; sp = sp->next)
-                       if (strncmp(sp->text, PATH, sizeof(PATH) - 1) == 0) {
-                               path = sp->text + sizeof(PATH) - 1;
+               for (i = 0; i < varlist.count; i++)
+                       if (strncmp(varlist.args[i], PATH, sizeof(PATH) - 1) == 0) {
+                               path = varlist.args[i] + sizeof(PATH) - 1;
                                /*
                                 * On `PATH=... command`, we need to make
                                 * sure that the command isn't using the
                                /*
                                 * On `PATH=... command`, we need to make
                                 * sure that the command isn't using the
@@ -999,7 +999,7 @@ evalcommand(union node *cmd, int flags, struct backcmd *backcmd)
                }
                if (cmdentry.cmdtype == CMDNORMAL &&
                    cmd->ncmd.redirect == NULL &&
                }
                if (cmdentry.cmdtype == CMDNORMAL &&
                    cmd->ncmd.redirect == NULL &&
-                   varlist.list == NULL &&
+                   varlist.count == 0 &&
                    (mode == FORK_FG || mode == FORK_NOJOB) &&
                    !disvforkset() && !iflag && !mflag) {
                        vforkexecshell(jp, argv, environment(), path,
                    (mode == FORK_FG || mode == FORK_NOJOB) &&
                    !disvforkset() && !iflag && !mflag) {
                        vforkexecshell(jp, argv, environment(), path,
@@ -1039,12 +1039,12 @@ evalcommand(union node *cmd, int flags, struct backcmd *backcmd)
                reffunc(cmdentry.u.func);
                savehandler = handler;
                if (setjmp(jmploc.loc)) {
                reffunc(cmdentry.u.func);
                savehandler = handler;
                if (setjmp(jmploc.loc)) {
-                       freeparam(&shellparam);
-                       shellparam = saveparam;
                        popredir();
                        unreffunc(cmdentry.u.func);
                        poplocalvars();
                        localvars = savelocalvars;
                        popredir();
                        unreffunc(cmdentry.u.func);
                        poplocalvars();
                        localvars = savelocalvars;
+                       freeparam(&shellparam);
+                       shellparam = saveparam;
                        funcnest--;
                        handler = savehandler;
                        longjmp(handler->loc, 1);
                        funcnest--;
                        handler = savehandler;
                        longjmp(handler->loc, 1);
@@ -1053,8 +1053,8 @@ evalcommand(union node *cmd, int flags, struct backcmd *backcmd)
                funcnest++;
                redirect(cmd->ncmd.redirect, REDIR_PUSH);
                INTON;
                funcnest++;
                redirect(cmd->ncmd.redirect, REDIR_PUSH);
                INTON;
-               for (sp = varlist.list ; sp ; sp = sp->next)
-                       mklocal(sp->text);
+               for (i = 0; i < varlist.count; i++)
+                       mklocal(varlist.args[i]);
                exitstatus = oexitstatus;
                evaltree(getfuncnode(cmdentry.u.func),
                    flags & (EV_TESTED | EV_EXIT));
                exitstatus = oexitstatus;
                evaltree(getfuncnode(cmdentry.u.func),
                    flags & (EV_TESTED | EV_EXIT));
@@ -1087,7 +1087,7 @@ evalcommand(union node *cmd, int flags, struct backcmd *backcmd)
                }
                savecmdname = commandname;
                savetopfile = getcurrentfile();
                }
                savecmdname = commandname;
                savetopfile = getcurrentfile();
-               cmdenviron = varlist.list;
+               cmdenviron = &varlist;
                e = -1;
                savehandler = handler;
                if (setjmp(jmploc.loc)) {
                e = -1;
                savehandler = handler;
                if (setjmp(jmploc.loc)) {
@@ -1152,8 +1152,8 @@ cmddone:
                trputs("normal command:  ");  trargs(argv);
 #endif
                redirect(cmd->ncmd.redirect, 0);
                trputs("normal command:  ");  trargs(argv);
 #endif
                redirect(cmd->ncmd.redirect, 0);
-               for (sp = varlist.list ; sp ; sp = sp->next)
-                       setvareq(sp->text, VEXPORT|VSTACK);
+               for (i = 0; i < varlist.count; i++)
+                       setvareq(varlist.args[i], VEXPORT|VSTACK);
                envp = environment();
                shellexec(argv, envp, path, cmdentry.u.index);
                /*NOTREACHED*/
                envp = environment();
                shellexec(argv, envp, path, cmdentry.u.index);
                /*NOTREACHED*/
@@ -1336,6 +1336,8 @@ truecmd(int argc __unused, char **argv __unused)
 int
 execcmd(int argc, char **argv)
 {
 int
 execcmd(int argc, char **argv)
 {
+       int i;
+
        /*
         * Because we have historically not supported any options,
         * only treat "--" specially.
        /*
         * Because we have historically not supported any options,
         * only treat "--" specially.
@@ -1343,13 +1345,11 @@ execcmd(int argc, char **argv)
        if (argc > 1 && strcmp(argv[1], "--") == 0)
                argc--, argv++;
        if (argc > 1) {
        if (argc > 1 && strcmp(argv[1], "--") == 0)
                argc--, argv++;
        if (argc > 1) {
-               struct strlist *sp;
-
                iflag = 0;              /* exit on error */
                mflag = 0;
                optschanged();
                iflag = 0;              /* exit on error */
                mflag = 0;
                optschanged();
-               for (sp = cmdenviron; sp ; sp = sp->next)
-                       setvareq(sp->text, VEXPORT|VSTACK);
+               for (i = 0; i < cmdenviron->count; i++)
+                       setvareq(cmdenviron->args[i], VEXPORT|VSTACK);
                shellexec(argv + 1, environment(), pathval(), 0);
 
        }
                shellexec(argv + 1, environment(), pathval(), 0);
 
        }
index d4092be45137045e319b06484e814301ecf60c86..c1045e369ef7927692053b8891fd445f11dc0b3e 100644 (file)
--- a/sh/eval.h
+++ b/sh/eval.h
  * SUCH DAMAGE.
  *
  *     @(#)eval.h      8.2 (Berkeley) 5/4/95
  * SUCH DAMAGE.
  *
  *     @(#)eval.h      8.2 (Berkeley) 5/4/95
- * $FreeBSD$
+ * $FreeBSD: head/bin/sh/eval.h 289159 2015-10-11 21:33:00Z jilles $
  */
 
 extern char *commandname;      /* currently executing command */
 extern int exitstatus;         /* exit status of last command */
 extern int oexitstatus;                /* saved exit status */
  */
 
 extern char *commandname;      /* currently executing command */
 extern int exitstatus;         /* exit status of last command */
 extern int oexitstatus;                /* saved exit status */
-extern struct strlist *cmdenviron;  /* environment for builtin command */
+extern struct arglist *cmdenviron;  /* environment for builtin command */
 
 
 struct backcmd {               /* result of evalbackcmd */
 
 
 struct backcmd {               /* result of evalbackcmd */
index b6ffe5c6ec4759564e9fa22acf4f62f9b4f27c87..6544d70f38985be807b4018d03ebb5882e71583f 100644 (file)
--- a/sh/exec.c
+++ b/sh/exec.c
@@ -36,7 +36,7 @@ static char sccsid[] = "@(#)exec.c    8.4 (Berkeley) 6/8/95";
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/bin/sh/exec.c 296813 2016-03-13 22:54:14Z jilles $");
 
 #include <sys/types.h>
 #include <sys/stat.h>
 
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -335,6 +335,7 @@ find_command(const char *name, struct cmdentry *entry, int act,
        if (strchr(name, '/') != NULL) {
                entry->cmdtype = CMDNORMAL;
                entry->u.index = 0;
        if (strchr(name, '/') != NULL) {
                entry->cmdtype = CMDNORMAL;
                entry->u.index = 0;
+               entry->special = 0;
                return;
        }
 
                return;
        }
 
@@ -411,6 +412,7 @@ find_command(const char *name, struct cmdentry *entry, int act,
                        cmdp = &loc_cmd;
                cmdp->cmdtype = CMDNORMAL;
                cmdp->param.index = idx;
                        cmdp = &loc_cmd;
                cmdp->cmdtype = CMDNORMAL;
                cmdp->param.index = idx;
+               cmdp->special = 0;
                INTON;
                goto success;
        }
                INTON;
                goto success;
        }
@@ -423,6 +425,7 @@ find_command(const char *name, struct cmdentry *entry, int act,
        }
        entry->cmdtype = CMDUNKNOWN;
        entry->u.index = 0;
        }
        entry->cmdtype = CMDUNKNOWN;
        entry->u.index = 0;
+       entry->special = 0;
        return;
 
 success:
        return;
 
 success:
@@ -442,12 +445,14 @@ success:
 int
 find_builtin(const char *name, int *special)
 {
 int
 find_builtin(const char *name, int *special)
 {
-       const struct builtincmd *bp;
+       const unsigned char *bp;
+       size_t len;
 
 
-       for (bp = builtincmd ; bp->name ; bp++) {
-               if (*bp->name == *name && equal(bp->name, name)) {
-                       *special = bp->special;
-                       return bp->code;
+       len = strlen(name);
+       for (bp = builtincmd ; *bp ; bp += 2 + bp[0]) {
+               if (bp[0] == len && memcmp(bp + 2, name, len) == 0) {
+                       *special = (bp[1] & BUILTIN_SPECIAL) != 0;
+                       return bp[1] & ~BUILTIN_SPECIAL;
                }
        }
        return -1;
                }
        }
        return -1;
@@ -589,6 +594,7 @@ addcmdentry(const char *name, struct cmdentry *entry)
        }
        cmdp->cmdtype = entry->cmdtype;
        cmdp->param = entry->u;
        }
        cmdp->cmdtype = entry->cmdtype;
        cmdp->param = entry->u;
+       cmdp->special = entry->special;
        INTON;
 }
 
        INTON;
 }
 
@@ -605,6 +611,7 @@ defun(const char *name, union node *func)
        INTOFF;
        entry.cmdtype = CMDFUNCTION;
        entry.u.func = copyfunc(func);
        INTOFF;
        entry.cmdtype = CMDFUNCTION;
        entry.u.func = copyfunc(func);
+       entry.special = 0;
        addcmdentry(name, &entry);
        INTON;
 }
        addcmdentry(name, &entry);
        INTON;
 }
index b57b2d5b270e7a6fb2bfb0bbe012a7625973c6d0..0bd6df327b2732cd52772ad51c87e71b0c998e54 100644 (file)
--- a/sh/exec.h
+++ b/sh/exec.h
@@ -30,7 +30,7 @@
  * SUCH DAMAGE.
  *
  *     @(#)exec.h      8.3 (Berkeley) 6/8/95
  * SUCH DAMAGE.
  *
  *     @(#)exec.h      8.3 (Berkeley) 6/8/95
- * $FreeBSD$
+ * $FreeBSD: head/bin/sh/exec.h 238468 2012-07-15 10:19:43Z jilles $
  */
 
 /* values of cmdtype */
  */
 
 /* values of cmdtype */
index 193d65177e74c81fb64fa7f5d04a00ed9bbeb7eb..d29237be21fd14a000f613d2e8dc9e49e63f909f 100644 (file)
@@ -3,6 +3,8 @@
  *     The Regents of the University of California.  All rights reserved.
  * Copyright (c) 1997-2005
  *     Herbert Xu <herbert@gondor.apana.org.au>.  All rights reserved.
  *     The Regents of the University of California.  All rights reserved.
  * Copyright (c) 1997-2005
  *     Herbert Xu <herbert@gondor.apana.org.au>.  All rights reserved.
+ * Copyright (c) 2010-2015
+ *     Jilles Tjoelker <jilles@stack.nl>.  All rights reserved.
  *
  * This code is derived from software contributed to Berkeley by
  * Kenneth Almquist.
  *
  * This code is derived from software contributed to Berkeley by
  * Kenneth Almquist.
@@ -38,7 +40,7 @@ static char sccsid[] = "@(#)expand.c  8.5 (Berkeley) 5/15/95";
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/bin/sh/expand.c 303586 2016-07-31 13:11:34Z jilles $");
 
 #include <sys/types.h>
 #include <sys/time.h>
 
 #include <sys/types.h>
 #include <sys/time.h>
@@ -79,46 +81,63 @@ __FBSDID("$FreeBSD$");
 #include "show.h"
 #include "builtins.h"
 
 #include "show.h"
 #include "builtins.h"
 
-/*
- * Structure specifying which parts of the string should be searched
- * for IFS characters.
- */
+enum wordstate { WORD_IDLE, WORD_WS_DELIMITED, WORD_QUOTEMARK };
 
 
-struct ifsregion {
-       struct ifsregion *next; /* next region in list */
-       int begoff;             /* offset of start of region */
-       int endoff;             /* offset of end of region */
-       int inquotes;           /* search for nul bytes only */
+struct worddest {
+       struct arglist *list;
+       enum wordstate state;
 };
 
 };
 
-
 static char *expdest;                  /* output of current string */
 static struct nodelist *argbackq;      /* list of back quote expressions */
 static char *expdest;                  /* output of current string */
 static struct nodelist *argbackq;      /* list of back quote expressions */
-static struct ifsregion ifsfirst;      /* first struct in list of ifs regions */
-static struct ifsregion *ifslastp;     /* last struct in list */
-static struct arglist exparg;          /* holds expanded arg list */
-
-static char *argstr(char *, int);
-static char *exptilde(char *, int);
-static char *expari(char *);
-static void expbackq(union node *, int, int);
-static int subevalvar(char *, char *, int, int, int, int, int);
-static char *evalvar(char *, int);
+
+static const char *argstr(const char *, int, struct worddest *);
+static const char *exptilde(const char *, int);
+static const char *expari(const char *, int, struct worddest *);
+static void expbackq(union node *, int, int, struct worddest *);
+static void subevalvar_trim(const char *, int, int, int);
+static int subevalvar_misc(const char *, const char *, int, int, int);
+static const char *evalvar(const char *, int, struct worddest *);
 static int varisset(const char *, int);
 static int varisset(const char *, int);
-static void strtodest(const char *, int, int, int);
-static void varvalue(const char *, int, int, int);
-static void recordregion(int, int, int);
-static void removerecordregions(int);
-static void ifsbreakup(char *, struct arglist *);
-static void expandmeta(struct strlist *);
-static void expmeta(char *, char *);
-static void addfname(char *);
-static struct strlist *expsort(struct strlist *);
-static struct strlist *msort(struct strlist *, int);
-static int patmatch(const char *, const char *, int);
-static char *cvtnum(int, char *);
+static void strtodest(const char *, int, int, int, struct worddest *);
+static void reprocess(int, int, int, int, struct worddest *);
+static void varvalue(const char *, int, int, int, struct worddest *);
+static void expandmeta(char *, struct arglist *);
+static void expmeta(char *, char *, struct arglist *);
+static int expsortcmp(const void *, const void *);
+static int patmatch(const char *, const char *);
+static void cvtnum(int, char *);
 static int collate_range_cmp(wchar_t, wchar_t);
 
 static int collate_range_cmp(wchar_t, wchar_t);
 
+void
+emptyarglist(struct arglist *list)
+{
+
+       list->args = list->smallarg;
+       list->count = 0;
+       list->capacity = sizeof(list->smallarg) / sizeof(list->smallarg[0]);
+}
+
+void
+appendarglist(struct arglist *list, char *str)
+{
+       char **newargs;
+       int newcapacity;
+
+       if (list->count >= list->capacity) {
+               newcapacity = list->capacity * 2;
+               if (newcapacity < 16)
+                       newcapacity = 16;
+               if (newcapacity > INT_MAX / (int)sizeof(newargs[0]))
+                       error("Too many entries in arglist");
+               newargs = stalloc(newcapacity * sizeof(newargs[0]));
+               memcpy(newargs, list->args, list->count * sizeof(newargs[0]));
+               list->args = newargs;
+               list->capacity = newcapacity;
+       }
+       list->args[list->count++] = str;
+}
+
 static int
 collate_range_cmp(wchar_t c1, wchar_t c2)
 {
 static int
 collate_range_cmp(wchar_t c1, wchar_t c2)
 {
@@ -142,6 +161,53 @@ stputs_quotes(const char *data, const char *syntax, char *p)
 }
 #define STPUTS_QUOTES(data, syntax, p) p = stputs_quotes((data), syntax, p)
 
 }
 #define STPUTS_QUOTES(data, syntax, p) p = stputs_quotes((data), syntax, p)
 
+static char *
+nextword(char c, int flag, char *p, struct worddest *dst)
+{
+       int is_ws;
+
+       is_ws = c == '\t' || c == '\n' || c == ' ';
+       if (p != stackblock() || (is_ws ? dst->state == WORD_QUOTEMARK :
+           dst->state != WORD_WS_DELIMITED) || c == '\0') {
+               STPUTC('\0', p);
+               if (flag & EXP_GLOB)
+                       expandmeta(grabstackstr(p), dst->list);
+               else
+                       appendarglist(dst->list, grabstackstr(p));
+               dst->state = is_ws ? WORD_WS_DELIMITED : WORD_IDLE;
+       } else if (!is_ws && dst->state == WORD_WS_DELIMITED)
+               dst->state = WORD_IDLE;
+       /* Reserve space while the stack string is empty. */
+       appendarglist(dst->list, NULL);
+       dst->list->count--;
+       STARTSTACKSTR(p);
+       return p;
+}
+#define NEXTWORD(c, flag, p, dstlist) p = nextword(c, flag, p, dstlist)
+
+static char *
+stputs_split(const char *data, const char *syntax, int flag, char *p,
+    struct worddest *dst)
+{
+       const char *ifs;
+       char c;
+
+       ifs = ifsset() ? ifsval() : " \t\n";
+       while (*data) {
+               CHECKSTRSPACE(2, p);
+               c = *data++;
+               if (strchr(ifs, c) != NULL) {
+                       NEXTWORD(c, flag, p, dst);
+                       continue;
+               }
+               if (flag & EXP_GLOB && syntax[(int)c] == CCTL)
+                       USTPUTC(CTLESC, p);
+               USTPUTC(c, p);
+       }
+       return (p);
+}
+#define STPUTS_SPLIT(data, syntax, flag, p, dst) p = stputs_split((data), syntax, flag, p, dst)
+
 /*
  * Perform expansions on an argument, placing the resulting list of arguments
  * in arglist.  Parameter expansion, command substitution and arithmetic
 /*
  * Perform expansions on an argument, placing the resulting list of arguments
  * in arglist.  Parameter expansion, command substitution and arithmetic
@@ -157,45 +223,31 @@ stputs_quotes(const char *data, const char *syntax, char *p)
 void
 expandarg(union node *arg, struct arglist *arglist, int flag)
 {
 void
 expandarg(union node *arg, struct arglist *arglist, int flag)
 {
-       struct strlist *sp;
-       char *p;
+       struct worddest exparg;
 
 
+       if (fflag)
+               flag &= ~EXP_GLOB;
        argbackq = arg->narg.backquote;
        argbackq = arg->narg.backquote;
+       exparg.list = arglist;
+       exparg.state = WORD_IDLE;
        STARTSTACKSTR(expdest);
        STARTSTACKSTR(expdest);
-       ifsfirst.next = NULL;
-       ifslastp = NULL;
-       argstr(arg->narg.text, flag);
+       argstr(arg->narg.text, flag, &exparg);
        if (arglist == NULL) {
                STACKSTRNUL(expdest);
                return;                 /* here document expanded */
        }
        if (arglist == NULL) {
                STACKSTRNUL(expdest);
                return;                 /* here document expanded */
        }
-       STPUTC('\0', expdest);
-       p = grabstackstr(expdest);
-       exparg.lastp = &exparg.list;
-       if (flag & EXP_FULL) {
-               ifsbreakup(p, &exparg);
-               *exparg.lastp = NULL;
-               exparg.lastp = &exparg.list;
-               expandmeta(exparg.list);
-       } else {
-               sp = (struct strlist *)stalloc(sizeof (struct strlist));
-               sp->text = p;
-               *exparg.lastp = sp;
-               exparg.lastp = &sp->next;
-       }
-       while (ifsfirst.next != NULL) {
-               struct ifsregion *ifsp;
-               INTOFF;
-               ifsp = ifsfirst.next->next;
-               ckfree(ifsfirst.next);
-               ifsfirst.next = ifsp;
-               INTON;
-       }
-       *exparg.lastp = NULL;
-       if (exparg.list) {
-               *arglist->lastp = exparg.list;
-               arglist->lastp = exparg.lastp;
+       if ((flag & EXP_SPLIT) == 0 || expdest != stackblock() ||
+           exparg.state == WORD_QUOTEMARK) {
+               STPUTC('\0', expdest);
+               if (flag & EXP_SPLIT) {
+                       if (flag & EXP_GLOB)
+                               expandmeta(grabstackstr(expdest), exparg.list);
+                       else
+                               appendarglist(exparg.list, grabstackstr(expdest));
+               }
        }
        }
+       if ((flag & EXP_SPLIT) == 0)
+               appendarglist(arglist, grabstackstr(expdest));
 }
 
 
 }
 
 
@@ -205,15 +257,16 @@ expandarg(union node *arg, struct arglist *arglist, int flag)
  * expansion, and tilde expansion if requested via EXP_TILDE/EXP_VARTILDE.
  * Processing ends at a CTLENDVAR or CTLENDARI character as well as '\0'.
  * This is used to expand word in ${var+word} etc.
  * expansion, and tilde expansion if requested via EXP_TILDE/EXP_VARTILDE.
  * Processing ends at a CTLENDVAR or CTLENDARI character as well as '\0'.
  * This is used to expand word in ${var+word} etc.
- * If EXP_FULL or EXP_CASE are set, keep and/or generate CTLESC
+ * If EXP_GLOB or EXP_CASE are set, keep and/or generate CTLESC
  * characters to allow for further processing.
  * characters to allow for further processing.
- * If EXP_FULL is set, also preserve CTLQUOTEMARK characters.
+ *
+ * If EXP_SPLIT is set, dst receives any complete words produced.
  */
  */
-static char *
-argstr(char *p, int flag)
+static const char *
+argstr(const char *p, int flag, struct worddest *dst)
 {
        char c;
 {
        char c;
-       int quotes = flag & (EXP_FULL | EXP_CASE);      /* do CTLESC */
+       int quotes = flag & (EXP_GLOB | EXP_CASE);      /* do CTLESC */
        int firsteq = 1;
        int split_lit;
        int lit_quoted;
        int firsteq = 1;
        int split_lit;
        int lit_quoted;
@@ -234,34 +287,36 @@ argstr(char *p, int flag)
                case CTLQUOTEMARK:
                        lit_quoted = 1;
                        /* "$@" syntax adherence hack */
                case CTLQUOTEMARK:
                        lit_quoted = 1;
                        /* "$@" syntax adherence hack */
-                       if (p[0] == CTLVAR && p[2] == '@' && p[3] == '=')
+                       if (p[0] == CTLVAR && (p[1] & VSQUOTE) != 0 &&
+                           p[2] == '@' && p[3] == '=')
                                break;
                                break;
-                       if ((flag & EXP_FULL) != 0)
-                               USTPUTC(c, expdest);
+                       if ((flag & EXP_SPLIT) != 0 && expdest == stackblock())
+                               dst->state = WORD_QUOTEMARK;
                        break;
                case CTLQUOTEEND:
                        lit_quoted = 0;
                        break;
                case CTLESC:
                        break;
                case CTLQUOTEEND:
                        lit_quoted = 0;
                        break;
                case CTLESC:
-                       if (quotes)
-                               USTPUTC(c, expdest);
                        c = *p++;
                        c = *p++;
+                       if (split_lit && !lit_quoted &&
+                           strchr(ifsset() ? ifsval() : " \t\n", c) != NULL) {
+                               NEXTWORD(c, flag, expdest, dst);
+                               break;
+                       }
+                       if (quotes)
+                               USTPUTC(CTLESC, expdest);
                        USTPUTC(c, expdest);
                        USTPUTC(c, expdest);
-                       if (split_lit && !lit_quoted)
-                               recordregion(expdest - stackblock() -
-                                   (quotes ? 2 : 1),
-                                   expdest - stackblock(), 0);
                        break;
                case CTLVAR:
                        break;
                case CTLVAR:
-                       p = evalvar(p, flag);
+                       p = evalvar(p, flag, dst);
                        break;
                case CTLBACKQ:
                case CTLBACKQ|CTLQUOTE:
                        break;
                case CTLBACKQ:
                case CTLBACKQ|CTLQUOTE:
-                       expbackq(argbackq->n, c & CTLQUOTE, flag);
+                       expbackq(argbackq->n, c & CTLQUOTE, flag, dst);
                        argbackq = argbackq->next;
                        break;
                case CTLARI:
                        argbackq = argbackq->next;
                        break;
                case CTLARI:
-                       p = expari(p);
+                       p = expari(p, flag, dst);
                        break;
                case ':':
                case '=':
                        break;
                case ':':
                case '=':
@@ -269,10 +324,12 @@ argstr(char *p, int flag)
                         * sort of a hack - expand tildes in variable
                         * assignments (after the first '=' and after ':'s).
                         */
                         * sort of a hack - expand tildes in variable
                         * assignments (after the first '=' and after ':'s).
                         */
+                       if (split_lit && !lit_quoted &&
+                           strchr(ifsset() ? ifsval() : " \t\n", c) != NULL) {
+                               NEXTWORD(c, flag, expdest, dst);
+                               break;
+                       }
                        USTPUTC(c, expdest);
                        USTPUTC(c, expdest);
-                       if (split_lit && !lit_quoted)
-                               recordregion(expdest - stackblock() - 1,
-                                   expdest - stackblock(), 0);
                        if (flag & EXP_VARTILDE && *p == '~' &&
                            (c != '=' || firsteq)) {
                                if (c == '=')
                        if (flag & EXP_VARTILDE && *p == '~' &&
                            (c != '=' || firsteq)) {
                                if (c == '=')
@@ -281,10 +338,12 @@ argstr(char *p, int flag)
                        }
                        break;
                default:
                        }
                        break;
                default:
+                       if (split_lit && !lit_quoted &&
+                           strchr(ifsset() ? ifsval() : " \t\n", c) != NULL) {
+                               NEXTWORD(c, flag, expdest, dst);
+                               break;
+                       }
                        USTPUTC(c, expdest);
                        USTPUTC(c, expdest);
-                       if (split_lit && !lit_quoted)
-                               recordregion(expdest - stackblock() - 1,
-                                   expdest - stackblock(), 0);
                }
        }
 }
                }
        }
 }
@@ -293,12 +352,15 @@ argstr(char *p, int flag)
  * Perform tilde expansion, placing the result in the stack string and
  * returning the next position in the input string to process.
  */
  * Perform tilde expansion, placing the result in the stack string and
  * returning the next position in the input string to process.
  */
-static char *
-exptilde(char *p, int flag)
+static const char *
+exptilde(const char *p, int flag)
 {
 {
-       char c, *startp = p;
+       char c;
+       const char *startp = p;
+       const char *user;
        struct passwd *pw;
        char *home;
        struct passwd *pw;
        char *home;
+       int len;
 
        for (;;) {
                c = *p;
 
        for (;;) {
                c = *p;
@@ -318,17 +380,20 @@ exptilde(char *p, int flag)
                case '\0':
                case '/':
                case CTLENDVAR:
                case '\0':
                case '/':
                case CTLENDVAR:
-                       *p = '\0';
-                       if (*(startp+1) == '\0') {
+                       len = p - startp - 1;
+                       STPUTBIN(startp + 1, len, expdest);
+                       STACKSTRNUL(expdest);
+                       user = expdest - len;
+                       if (*user == '\0') {
                                home = lookupvar("HOME");
                        } else {
                                home = lookupvar("HOME");
                        } else {
-                               pw = getpwnam(startp+1);
+                               pw = getpwnam(user);
                                home = pw != NULL ? pw->pw_dir : NULL;
                        }
                                home = pw != NULL ? pw->pw_dir : NULL;
                        }
-                       *p = c;
+                       STADJUST(-len, expdest);
                        if (home == NULL || *home == '\0')
                                return (startp);
                        if (home == NULL || *home == '\0')
                                return (startp);
-                       strtodest(home, flag, VSNORMAL, 1);
+                       strtodest(home, flag, VSNORMAL, 1, NULL);
                        return (p);
                }
                p++;
                        return (p);
                }
                p++;
@@ -336,51 +401,11 @@ exptilde(char *p, int flag)
 }
 
 
 }
 
 
-static void
-removerecordregions(int endoff)
-{
-       if (ifslastp == NULL)
-               return;
-
-       if (ifsfirst.endoff > endoff) {
-               while (ifsfirst.next != NULL) {
-                       struct ifsregion *ifsp;
-                       INTOFF;
-                       ifsp = ifsfirst.next->next;
-                       ckfree(ifsfirst.next);
-                       ifsfirst.next = ifsp;
-                       INTON;
-               }
-               if (ifsfirst.begoff > endoff)
-                       ifslastp = NULL;
-               else {
-                       ifslastp = &ifsfirst;
-                       ifsfirst.endoff = endoff;
-               }
-               return;
-       }
-
-       ifslastp = &ifsfirst;
-       while (ifslastp->next && ifslastp->next->begoff < endoff)
-               ifslastp=ifslastp->next;
-       while (ifslastp->next != NULL) {
-               struct ifsregion *ifsp;
-               INTOFF;
-               ifsp = ifslastp->next->next;
-               ckfree(ifslastp->next);
-               ifslastp->next = ifsp;
-               INTON;
-       }
-       if (ifslastp->endoff > endoff)
-               ifslastp->endoff = endoff;
-}
-
 /*
  * Expand arithmetic expression.
 /*
  * Expand arithmetic expression.
- * Note that flag is not required as digits never require CTLESC characters.
  */
  */
-static char *
-expari(char *p)
+static const char *
+expari(const char *p, int flag, struct worddest *dst)
 {
        char *q, *start;
        arith_t result;
 {
        char *q, *start;
        arith_t result;
@@ -390,8 +415,7 @@ expari(char *p)
 
        quoted = *p++ == '"';
        begoff = expdest - stackblock();
 
        quoted = *p++ == '"';
        begoff = expdest - stackblock();
-       p = argstr(p, 0);
-       removerecordregions(begoff);
+       p = argstr(p, 0, NULL);
        STPUTC('\0', expdest);
        start = stackblock() + begoff;
 
        STPUTC('\0', expdest);
        start = stackblock() + begoff;
 
@@ -408,7 +432,7 @@ expari(char *p)
        adj = strlen(expdest);
        STADJUST(adj, expdest);
        if (!quoted)
        adj = strlen(expdest);
        STADJUST(adj, expdest);
        if (!quoted)
-               recordregion(begoff, expdest - stackblock(), 0);
+               reprocess(expdest - adj - stackblock(), flag, VSNORMAL, 0, dst);
        return p;
 }
 
        return p;
 }
 
@@ -417,41 +441,40 @@ expari(char *p)
  * Perform command substitution.
  */
 static void
  * Perform command substitution.
  */
 static void
-expbackq(union node *cmd, int quoted, int flag)
+expbackq(union node *cmd, int quoted, int flag, struct worddest *dst)
 {
        struct backcmd in;
        int i;
        char buf[128];
        char *p;
        char *dest = expdest;
 {
        struct backcmd in;
        int i;
        char buf[128];
        char *p;
        char *dest = expdest;
-       struct ifsregion saveifs, *savelastp;
        struct nodelist *saveargbackq;
        char lastc;
        struct nodelist *saveargbackq;
        char lastc;
-       int startloc = dest - stackblock();
        char const *syntax = quoted? DQSYNTAX : BASESYNTAX;
        char const *syntax = quoted? DQSYNTAX : BASESYNTAX;
-       int quotes = flag & (EXP_FULL | EXP_CASE);
+       int quotes = flag & (EXP_GLOB | EXP_CASE);
        size_t nnl;
        size_t nnl;
+       const char *ifs;
 
        INTOFF;
 
        INTOFF;
-       saveifs = ifsfirst;
-       savelastp = ifslastp;
        saveargbackq = argbackq;
        p = grabstackstr(dest);
        evalbackcmd(cmd, &in);
        ungrabstackstr(p, dest);
        saveargbackq = argbackq;
        p = grabstackstr(dest);
        evalbackcmd(cmd, &in);
        ungrabstackstr(p, dest);
-       ifsfirst = saveifs;
-       ifslastp = savelastp;
        argbackq = saveargbackq;
 
        p = in.buf;
        argbackq = saveargbackq;
 
        p = in.buf;
-       lastc = '\0';
        nnl = 0;
        nnl = 0;
+       if (!quoted && flag & EXP_SPLIT)
+               ifs = ifsset() ? ifsval() : " \t\n";
+       else
+               ifs = "";
        /* Don't copy trailing newlines */
        for (;;) {
                if (--in.nleft < 0) {
                        if (in.fd < 0)
                                break;
        /* Don't copy trailing newlines */
        for (;;) {
                if (--in.nleft < 0) {
                        if (in.fd < 0)
                                break;
-                       while ((i = read(in.fd, buf, sizeof buf)) < 0 && errno == EINTR);
+                       while ((i = read(in.fd, buf, sizeof buf)) < 0 && errno == EINTR)
+                               ;
                        TRACE(("expbackq: read returns %d\n", i));
                        if (i <= 0)
                                break;
                        TRACE(("expbackq: read returns %d\n", i));
                        if (i <= 0)
                                break;
@@ -459,15 +482,27 @@ expbackq(union node *cmd, int quoted, int flag)
                        in.nleft = i - 1;
                }
                lastc = *p++;
                        in.nleft = i - 1;
                }
                lastc = *p++;
-               if (lastc != '\0') {
-                       if (lastc == '\n') {
-                               nnl++;
-                       } else {
-                               CHECKSTRSPACE(nnl + 2, dest);
-                               while (nnl > 0) {
-                                       nnl--;
-                                       USTPUTC('\n', dest);
+               if (lastc == '\0')
+                       continue;
+               if (lastc == '\n') {
+                       nnl++;
+               } else {
+                       if (nnl > 0) {
+                               if (strchr(ifs, '\n') != NULL) {
+                                       NEXTWORD('\n', flag, dest, dst);
+                                       nnl = 0;
+                               } else {
+                                       CHECKSTRSPACE(nnl + 2, dest);
+                                       while (nnl > 0) {
+                                               nnl--;
+                                               USTPUTC('\n', dest);
+                                       }
                                }
                                }
+                       }
+                       if (strchr(ifs, lastc) != NULL)
+                               NEXTWORD(lastc, flag, dest, dst);
+                       else {
+                               CHECKSTRSPACE(2, dest);
                                if (quotes && syntax[(int)lastc] == CCTL)
                                        USTPUTC(CTLESC, dest);
                                USTPUTC(lastc, dest);
                                if (quotes && syntax[(int)lastc] == CCTL)
                                        USTPUTC(CTLESC, dest);
                                USTPUTC(lastc, dest);
@@ -481,8 +516,6 @@ expbackq(union node *cmd, int quoted, int flag)
                ckfree(in.buf);
        if (in.jp)
                exitstatus = waitforjob(in.jp, (int *)NULL);
                ckfree(in.buf);
        if (in.jp)
                exitstatus = waitforjob(in.jp, (int *)NULL);
-       if (quoted == 0)
-               recordregion(startloc, dest - stackblock(), 0);
        TRACE(("expbackq: size=%td: \"%.*s\"\n",
                ((dest - stackblock()) - startloc),
                (int)((dest - stackblock()) - startloc),
        TRACE(("expbackq: size=%td: \"%.*s\"\n",
                ((dest - stackblock()) - startloc),
                (int)((dest - stackblock()) - startloc),
@@ -504,109 +537,108 @@ recordleft(const char *str, const char *loc, char *startp)
                *startp++ = *loc++;
 }
 
                *startp++ = *loc++;
 }
 
-static int
-subevalvar(char *p, char *str, int strloc, int subtype, int startloc,
-  int varflags, int quotes)
+static void
+subevalvar_trim(const char *p, int strloc, int subtype, int startloc)
 {
        char *startp;
        char *loc = NULL;
 {
        char *startp;
        char *loc = NULL;
-       char *q;
+       char *str;
        int c = 0;
        struct nodelist *saveargbackq = argbackq;
        int amount;
 
        int c = 0;
        struct nodelist *saveargbackq = argbackq;
        int amount;
 
-       argstr(p, (subtype == VSTRIMLEFT || subtype == VSTRIMLEFTMAX ||
-           subtype == VSTRIMRIGHT || subtype == VSTRIMRIGHTMAX ?
-           EXP_CASE : 0) | EXP_TILDE);
+       argstr(p, EXP_CASE | EXP_TILDE, NULL);
        STACKSTRNUL(expdest);
        argbackq = saveargbackq;
        startp = stackblock() + startloc;
        STACKSTRNUL(expdest);
        argbackq = saveargbackq;
        startp = stackblock() + startloc;
-       if (str == NULL)
-           str = stackblock() + strloc;
+       str = stackblock() + strloc;
 
        switch (subtype) {
 
        switch (subtype) {
-       case VSASSIGN:
-               setvar(str, startp, 0);
-               amount = startp - expdest;
-               STADJUST(amount, expdest);
-               varflags &= ~VSNUL;
-               return 1;
-
-       case VSQUESTION:
-               if (*p != CTLENDVAR) {
-                       outfmt(out2, "%s\n", startp);
-                       error((char *)NULL);
-               }
-               error("%.*s: parameter %snot set", (int)(p - str - 1),
-                     str, (varflags & VSNUL) ? "null or " : "");
-               return 0;
-
        case VSTRIMLEFT:
                for (loc = startp; loc < str; loc++) {
                        c = *loc;
                        *loc = '\0';
        case VSTRIMLEFT:
                for (loc = startp; loc < str; loc++) {
                        c = *loc;
                        *loc = '\0';
-                       if (patmatch(str, startp, quotes)) {
+                       if (patmatch(str, startp)) {
                                *loc = c;
                                recordleft(str, loc, startp);
                                *loc = c;
                                recordleft(str, loc, startp);
-                               return 1;
+                               return;
                        }
                        *loc = c;
                        }
                        *loc = c;
-                       if (quotes && *loc == CTLESC)
-                               loc++;
                }
                }
-               return 0;
+               break;
 
        case VSTRIMLEFTMAX:
                for (loc = str - 1; loc >= startp;) {
                        c = *loc;
                        *loc = '\0';
 
        case VSTRIMLEFTMAX:
                for (loc = str - 1; loc >= startp;) {
                        c = *loc;
                        *loc = '\0';
-                       if (patmatch(str, startp, quotes)) {
+                       if (patmatch(str, startp)) {
                                *loc = c;
                                recordleft(str, loc, startp);
                                *loc = c;
                                recordleft(str, loc, startp);
-                               return 1;
+                               return;
                        }
                        *loc = c;
                        loc--;
                        }
                        *loc = c;
                        loc--;
-                       if (quotes && loc > startp && *(loc - 1) == CTLESC) {
-                               for (q = startp; q < loc; q++)
-                                       if (*q == CTLESC)
-                                               q++;
-                               if (q > loc)
-                                       loc--;
-                       }
                }
                }
-               return 0;
+               break;
 
        case VSTRIMRIGHT:
                for (loc = str - 1; loc >= startp;) {
 
        case VSTRIMRIGHT:
                for (loc = str - 1; loc >= startp;) {
-                       if (patmatch(str, loc, quotes)) {
+                       if (patmatch(str, loc)) {
                                amount = loc - expdest;
                                STADJUST(amount, expdest);
                                amount = loc - expdest;
                                STADJUST(amount, expdest);
-                               return 1;
+                               return;
                        }
                        loc--;
                        }
                        loc--;
-                       if (quotes && loc > startp && *(loc - 1) == CTLESC) {
-                               for (q = startp; q < loc; q++)
-                                       if (*q == CTLESC)
-                                               q++;
-                               if (q > loc)
-                                       loc--;
-                       }
                }
                }
-               return 0;
+               break;
 
        case VSTRIMRIGHTMAX:
                for (loc = startp; loc < str - 1; loc++) {
 
        case VSTRIMRIGHTMAX:
                for (loc = startp; loc < str - 1; loc++) {
-                       if (patmatch(str, loc, quotes)) {
+                       if (patmatch(str, loc)) {
                                amount = loc - expdest;
                                STADJUST(amount, expdest);
                                amount = loc - expdest;
                                STADJUST(amount, expdest);
-                               return 1;
+                               return;
                        }
                        }
-                       if (quotes && *loc == CTLESC)
-                               loc++;
                }
                }
-               return 0;
+               break;
+
+
+       default:
+               abort();
+       }
+       amount = (expdest - stackblock() - strloc) + 1;
+       STADJUST(-amount, expdest);
+}
+
+
+static int
+subevalvar_misc(const char *p, const char *var, int subtype, int startloc,
+  int varflags)
+{
+       char *startp;
+       struct nodelist *saveargbackq = argbackq;
+       int amount;
 
 
+       argstr(p, EXP_TILDE, NULL);
+       STACKSTRNUL(expdest);
+       argbackq = saveargbackq;
+       startp = stackblock() + startloc;
+
+       switch (subtype) {
+       case VSASSIGN:
+               setvar(var, startp, 0);
+               amount = startp - expdest;
+               STADJUST(amount, expdest);
+               return 1;
+
+       case VSQUESTION:
+               if (*p != CTLENDVAR) {
+                       outfmt(out2, "%s\n", startp);
+                       error((char *)NULL);
+               }
+               error("%.*s: parameter %snot set", (int)(p - var - 1),
+                     var, (varflags & VSNUL) ? "null or " : "");
+               return 0;
 
        default:
                abort();
 
        default:
                abort();
@@ -619,12 +651,12 @@ subevalvar(char *p, char *str, int strloc, int subtype, int startloc,
  * input string.
  */
 
  * input string.
  */
 
-static char *
-evalvar(char *p, int flag)
+static const char *
+evalvar(const char *p, int flag, struct worddest *dst)
 {
        int subtype;
        int varflags;
 {
        int subtype;
        int varflags;
-       char *var;
+       const char *var;
        const char *val;
        int patloc;
        int c;
        const char *val;
        int patloc;
        int c;
@@ -633,9 +665,7 @@ evalvar(char *p, int flag)
        int startloc;
        int varlen;
        int varlenb;
        int startloc;
        int varlen;
        int varlenb;
-       int easy;
-       int quotes = flag & (EXP_FULL | EXP_CASE);
-       int record = 0;
+       char buf[21];
 
        varflags = (unsigned char)*p++;
        subtype = varflags & VSTYPE;
 
        varflags = (unsigned char)*p++;
        subtype = varflags & VSTYPE;
@@ -677,10 +707,16 @@ again: /* jump here after setting a variable with ${var=text} */
        if (set && subtype != VSPLUS) {
                /* insert the value of the variable */
                if (special) {
        if (set && subtype != VSPLUS) {
                /* insert the value of the variable */
                if (special) {
-                       if (varflags & VSLINENO)
-                               STPUTBIN(var, p - var - 1, expdest);
-                       else
-                               varvalue(var, varflags & VSQUOTE, subtype, flag);
+                       if (varflags & VSLINENO) {
+                               if (p - var > (ptrdiff_t)sizeof(buf))
+                                       abort();
+                               memcpy(buf, var, p - var - 1);
+                               buf[p - var - 1] = '\0';
+                               strtodest(buf, flag, subtype,
+                                   varflags & VSQUOTE, dst);
+                       } else
+                               varvalue(var, varflags & VSQUOTE, subtype, flag,
+                                   dst);
                        if (subtype == VSLENGTH) {
                                varlenb = expdest - stackblock() - startloc;
                                varlen = varlenb;
                        if (subtype == VSLENGTH) {
                                varlenb = expdest - stackblock() - startloc;
                                varlen = varlenb;
@@ -701,35 +737,29 @@ again: /* jump here after setting a variable with ${var=text} */
                        }
                        else
                                strtodest(val, flag, subtype,
                        }
                        else
                                strtodest(val, flag, subtype,
-                                   varflags & VSQUOTE);
+                                   varflags & VSQUOTE, dst);
                }
        }
 
        if (subtype == VSPLUS)
                set = ! set;
 
                }
        }
 
        if (subtype == VSPLUS)
                set = ! set;
 
-       easy = ((varflags & VSQUOTE) == 0 ||
-               (*var == '@' && shellparam.nparam != 1));
-
-
        switch (subtype) {
        case VSLENGTH:
        switch (subtype) {
        case VSLENGTH:
-               expdest = cvtnum(varlen, expdest);
-               record = 1;
+               cvtnum(varlen, buf);
+               strtodest(buf, flag, VSNORMAL, varflags & VSQUOTE, dst);
                break;
 
        case VSNORMAL:
                break;
 
        case VSNORMAL:
-               record = easy;
                break;
 
        case VSPLUS:
        case VSMINUS:
                if (!set) {
                break;
 
        case VSPLUS:
        case VSMINUS:
                if (!set) {
-                       argstr(p, flag | (flag & EXP_FULL ? EXP_SPLIT_LIT : 0) |
-                           (varflags & VSQUOTE ? EXP_LIT_QUOTED : 0));
+                       argstr(p, flag | (flag & EXP_SPLIT ? EXP_SPLIT_LIT : 0) |
+                           (varflags & VSQUOTE ? EXP_LIT_QUOTED : 0), dst);
                        break;
                }
                        break;
                }
-               record = easy;
                break;
 
        case VSTRIMLEFT:
                break;
 
        case VSTRIMLEFT:
@@ -744,32 +774,22 @@ again: /* jump here after setting a variable with ${var=text} */
                 */
                STPUTC('\0', expdest);
                patloc = expdest - stackblock();
                 */
                STPUTC('\0', expdest);
                patloc = expdest - stackblock();
-               if (subevalvar(p, NULL, patloc, subtype,
-                   startloc, varflags, quotes) == 0) {
-                       int amount = (expdest - stackblock() - patloc) + 1;
-                       STADJUST(-amount, expdest);
-               }
-               /* Remove any recorded regions beyond start of variable */
-               removerecordregions(startloc);
-               record = 1;
+               subevalvar_trim(p, patloc, subtype, startloc);
+               reprocess(startloc, flag, VSNORMAL, varflags & VSQUOTE, dst);
+               if (flag & EXP_SPLIT && *var == '@' && varflags & VSQUOTE)
+                       dst->state = WORD_QUOTEMARK;
                break;
 
        case VSASSIGN:
        case VSQUESTION:
                if (!set) {
                break;
 
        case VSASSIGN:
        case VSQUESTION:
                if (!set) {
-                       if (subevalvar(p, var, 0, subtype, startloc, varflags,
-                           quotes)) {
+                       if (subevalvar_misc(p, var, subtype, startloc,
+                           varflags)) {
                                varflags &= ~VSNUL;
                                varflags &= ~VSNUL;
-                               /*
-                                * Remove any recorded regions beyond
-                                * start of variable
-                                */
-                               removerecordregions(startloc);
                                goto again;
                        }
                        break;
                }
                                goto again;
                        }
                        break;
                }
-               record = easy;
                break;
 
        case VSERROR:
                break;
 
        case VSERROR:
@@ -781,11 +801,6 @@ again: /* jump here after setting a variable with ${var=text} */
                abort();
        }
 
                abort();
        }
 
-       if (record)
-               recordregion(startloc, expdest - stackblock(),
-                   varflags & VSQUOTE || (ifsset() && ifsval()[0] == '\0' &&
-                   (*var == '@' || *var == '*')));
-
        if (subtype != VSNORMAL) {      /* skip to end of alternative */
                int nesting = 1;
                for (;;) {
        if (subtype != VSNORMAL) {      /* skip to end of alternative */
                int nesting = 1;
                for (;;) {
@@ -851,26 +866,80 @@ varisset(const char *name, int nulok)
 }
 
 static void
 }
 
 static void
-strtodest(const char *p, int flag, int subtype, int quoted)
+strtodest(const char *p, int flag, int subtype, int quoted,
+    struct worddest *dst)
 {
 {
-       if (flag & (EXP_FULL | EXP_CASE) && subtype != VSLENGTH)
+       if (subtype == VSLENGTH || subtype == VSTRIMLEFT ||
+           subtype == VSTRIMLEFTMAX || subtype == VSTRIMRIGHT ||
+           subtype == VSTRIMRIGHTMAX)
+               STPUTS(p, expdest);
+       else if (flag & EXP_SPLIT && !quoted && dst != NULL)
+               STPUTS_SPLIT(p, BASESYNTAX, flag, expdest, dst);
+       else if (flag & (EXP_GLOB | EXP_CASE))
                STPUTS_QUOTES(p, quoted ? DQSYNTAX : BASESYNTAX, expdest);
        else
                STPUTS(p, expdest);
 }
 
                STPUTS_QUOTES(p, quoted ? DQSYNTAX : BASESYNTAX, expdest);
        else
                STPUTS(p, expdest);
 }
 
+static void
+reprocess(int startloc, int flag, int subtype, int quoted,
+    struct worddest *dst)
+{
+       static char *buf = NULL;
+       static size_t buflen = 0;
+       char *startp;
+       size_t len, zpos, zlen;
+
+       startp = stackblock() + startloc;
+       len = expdest - startp;
+       if (len >= SIZE_MAX / 2)
+               abort();
+       INTOFF;
+       if (len >= buflen) {
+               ckfree(buf);
+               buf = NULL;
+       }
+       if (buflen < 128)
+               buflen = 128;
+       while (len >= buflen)
+               buflen <<= 1;
+       if (buf == NULL)
+               buf = ckmalloc(buflen);
+       INTON;
+       memcpy(buf, startp, len);
+       buf[len] = '\0';
+       STADJUST(-len, expdest);
+       for (zpos = 0;;) {
+               zlen = strlen(buf + zpos);
+               strtodest(buf + zpos, flag, subtype, quoted, dst);
+               zpos += zlen + 1;
+               if (zpos == len + 1)
+                       break;
+               if (flag & EXP_SPLIT && (quoted || (zlen > 0 && zpos < len)))
+                       NEXTWORD('\0', flag, expdest, dst);
+       }
+}
+
 /*
  * Add the value of a specialized variable to the stack string.
  */
 
 static void
 /*
  * Add the value of a specialized variable to the stack string.
  */
 
 static void
-varvalue(const char *name, int quoted, int subtype, int flag)
+varvalue(const char *name, int quoted, int subtype, int flag,
+    struct worddest *dst)
 {
        int num;
        char *p;
        int i;
 {
        int num;
        char *p;
        int i;
+       int splitlater;
        char sep[2];
        char **ap;
        char sep[2];
        char **ap;
+       char buf[(NSHORTOPTS > 10 ? NSHORTOPTS : 10) + 1];
+
+       if (subtype == VSLENGTH)
+               flag &= ~EXP_FULL;
+       splitlater = subtype == VSTRIMLEFT || subtype == VSTRIMLEFTMAX ||
+               subtype == VSTRIMRIGHT || subtype == VSTRIMRIGHTMAX;
 
        switch (*name) {
        case '$':
 
        switch (*name) {
        case '$':
@@ -886,18 +955,28 @@ varvalue(const char *name, int quoted, int subtype, int flag)
                num = backgndpidval();
                break;
        case '-':
                num = backgndpidval();
                break;
        case '-':
-               for (i = 0 ; i < NOPTS ; i++) {
-                       if (optlist[i].val)
-                               STPUTC(optlist[i].letter, expdest);
+               p = buf;
+               for (i = 0 ; i < NSHORTOPTS ; i++) {
+                       if (optval[i])
+                               *p++ = optletter[i];
                }
                }
+               *p = '\0';
+               strtodest(buf, flag, subtype, quoted, dst);
                return;
        case '@':
                return;
        case '@':
-               if (flag & EXP_FULL && quoted) {
+               if (flag & EXP_SPLIT && quoted) {
                        for (ap = shellparam.p ; (p = *ap++) != NULL ; ) {
                        for (ap = shellparam.p ; (p = *ap++) != NULL ; ) {
-                               strtodest(p, flag, subtype, quoted);
-                               if (*ap)
-                                       STPUTC('\0', expdest);
+                               strtodest(p, flag, subtype, quoted, dst);
+                               if (*ap) {
+                                       if (splitlater)
+                                               STPUTC('\0', expdest);
+                                       else
+                                               NEXTWORD('\0', flag, expdest,
+                                                   dst);
+                               }
                        }
                        }
+                       if (shellparam.nparam > 0)
+                               dst->state = WORD_QUOTEMARK;
                        return;
                }
                /* FALLTHROUGH */
                        return;
                }
                /* FALLTHROUGH */
@@ -908,13 +987,17 @@ varvalue(const char *name, int quoted, int subtype, int flag)
                        sep[0] = ' ';
                sep[1] = '\0';
                for (ap = shellparam.p ; (p = *ap++) != NULL ; ) {
                        sep[0] = ' ';
                sep[1] = '\0';
                for (ap = shellparam.p ; (p = *ap++) != NULL ; ) {
-                       strtodest(p, flag, subtype, quoted);
+                       strtodest(p, flag, subtype, quoted, dst);
                        if (!*ap)
                                break;
                        if (sep[0])
                        if (!*ap)
                                break;
                        if (sep[0])
-                               strtodest(sep, flag, subtype, quoted);
-                       else if (flag & EXP_FULL && !quoted && **ap != '\0')
-                               STPUTC('\0', expdest);
+                               strtodest(sep, flag, subtype, quoted, dst);
+                       else if (flag & EXP_SPLIT && !quoted && **ap != '\0') {
+                               if (splitlater)
+                                       STPUTC('\0', expdest);
+                               else
+                                       NEXTWORD('\0', flag, expdest, dst);
+                       }
                }
                return;
        default:
                }
                return;
        default:
@@ -926,205 +1009,52 @@ varvalue(const char *name, int quoted, int subtype, int flag)
                                p = shellparam.p[num - 1];
                        else
                                return;
                                p = shellparam.p[num - 1];
                        else
                                return;
-                       strtodest(p, flag, subtype, quoted);
+                       strtodest(p, flag, subtype, quoted, dst);
                }
                return;
        }
                }
                return;
        }
-       expdest = cvtnum(num, expdest);
+       cvtnum(num, buf);
+       strtodest(buf, flag, subtype, quoted, dst);
 }
 
 
 
 }
 
 
 
-/*
- * Record the fact that we have to scan this region of the
- * string for IFS characters.
- */
-
-static void
-recordregion(int start, int end, int inquotes)
-{
-       struct ifsregion *ifsp;
-
-       INTOFF;
-       if (ifslastp == NULL) {
-               ifsp = &ifsfirst;
-       } else {
-               if (ifslastp->endoff == start
-                   && ifslastp->inquotes == inquotes) {
-                       /* extend previous area */
-                       ifslastp->endoff = end;
-                       INTON;
-                       return;
-               }
-               ifsp = (struct ifsregion *)ckmalloc(sizeof (struct ifsregion));
-               ifslastp->next = ifsp;
-       }
-       ifslastp = ifsp;
-       ifslastp->next = NULL;
-       ifslastp->begoff = start;
-       ifslastp->endoff = end;
-       ifslastp->inquotes = inquotes;
-       INTON;
-}
-
-
-
-/*
- * Break the argument string into pieces based upon IFS and add the
- * strings to the argument list.  The regions of the string to be
- * searched for IFS characters have been stored by recordregion.
- * CTLESC characters are preserved but have little effect in this pass
- * other than escaping CTL* characters.  In particular, they do not escape
- * IFS characters: that should be done with the ifsregion mechanism.
- * CTLQUOTEMARK characters are used to preserve empty quoted strings.
- * This pass treats them as a regular character, making the string non-empty.
- * Later, they are removed along with the other CTL* characters.
- */
-static void
-ifsbreakup(char *string, struct arglist *arglist)
-{
-       struct ifsregion *ifsp;
-       struct strlist *sp;
-       char *start;
-       char *p;
-       char *q;
-       const char *ifs;
-       const char *ifsspc;
-       int had_param_ch = 0;
-
-       start = string;
-
-       if (ifslastp == NULL) {
-               /* Return entire argument, IFS doesn't apply to any of it */
-               sp = (struct strlist *)stalloc(sizeof *sp);
-               sp->text = start;
-               *arglist->lastp = sp;
-               arglist->lastp = &sp->next;
-               return;
-       }
-
-       ifs = ifsset() ? ifsval() : " \t\n";
-
-       for (ifsp = &ifsfirst; ifsp != NULL; ifsp = ifsp->next) {
-               p = string + ifsp->begoff;
-               while (p < string + ifsp->endoff) {
-                       q = p;
-                       if (*p == CTLESC)
-                               p++;
-                       if (ifsp->inquotes) {
-                               /* Only NULs (should be from "$@") end args */
-                               had_param_ch = 1;
-                               if (*p != 0) {
-                                       p++;
-                                       continue;
-                               }
-                               ifsspc = NULL;
-                       } else {
-                               if (!strchr(ifs, *p)) {
-                                       had_param_ch = 1;
-                                       p++;
-                                       continue;
-                               }
-                               ifsspc = strchr(" \t\n", *p);
-
-                               /* Ignore IFS whitespace at start */
-                               if (q == start && ifsspc != NULL) {
-                                       p++;
-                                       start = p;
-                                       continue;
-                               }
-                               had_param_ch = 0;
-                       }
-
-                       /* Save this argument... */
-                       *q = '\0';
-                       sp = (struct strlist *)stalloc(sizeof *sp);
-                       sp->text = start;
-                       *arglist->lastp = sp;
-                       arglist->lastp = &sp->next;
-                       p++;
-
-                       if (ifsspc != NULL) {
-                               /* Ignore further trailing IFS whitespace */
-                               for (; p < string + ifsp->endoff; p++) {
-                                       q = p;
-                                       if (*p == CTLESC)
-                                               p++;
-                                       if (strchr(ifs, *p) == NULL) {
-                                               p = q;
-                                               break;
-                                       }
-                                       if (strchr(" \t\n", *p) == NULL) {
-                                               p++;
-                                               break;
-                                       }
-                               }
-                       }
-                       start = p;
-               }
-       }
-
-       /*
-        * Save anything left as an argument.
-        * Traditionally we have treated 'IFS=':'; set -- x$IFS' as
-        * generating 2 arguments, the second of which is empty.
-        * Some recent clarification of the Posix spec say that it
-        * should only generate one....
-        */
-       if (had_param_ch || *start != 0) {
-               sp = (struct strlist *)stalloc(sizeof *sp);
-               sp->text = start;
-               *arglist->lastp = sp;
-               arglist->lastp = &sp->next;
-       }
-}
-
-
 static char expdir[PATH_MAX];
 #define expdir_end (expdir + sizeof(expdir))
 
 /*
  * Perform pathname generation and remove control characters.
 static char expdir[PATH_MAX];
 #define expdir_end (expdir + sizeof(expdir))
 
 /*
  * Perform pathname generation and remove control characters.
- * At this point, the only control characters should be CTLESC and CTLQUOTEMARK.
- * The results are stored in the list exparg.
+ * At this point, the only control characters should be CTLESC.
+ * The results are stored in the list dstlist.
  */
 static void
  */
 static void
-expandmeta(struct strlist *str)
+expandmeta(char *pattern, struct arglist *dstlist)
 {
        char *p;
 {
        char *p;
-       struct strlist **savelastp;
-       struct strlist *sp;
+       int firstmatch;
        char c;
 
        char c;
 
-       while (str) {
-               savelastp = exparg.lastp;
-               if (!fflag) {
-                       p = str->text;
-                       for (; (c = *p) != '\0'; p++) {
-                               /* fast check for meta chars */
-                               if (c == '*' || c == '?' || c == '[') {
-                                       INTOFF;
-                                       expmeta(expdir, str->text);
-                                       INTON;
-                                       break;
-                               }
-                       }
-               }
-               if (exparg.lastp == savelastp) {
-                       /*
-                        * no matches
-                        */
-                       *exparg.lastp = str;
-                       rmescapes(str->text);
-                       exparg.lastp = &str->next;
-               } else {
-                       *exparg.lastp = NULL;
-                       *savelastp = sp = expsort(*savelastp);
-                       while (sp->next != NULL)
-                               sp = sp->next;
-                       exparg.lastp = &sp->next;
+       firstmatch = dstlist->count;
+       p = pattern;
+       for (; (c = *p) != '\0'; p++) {
+               /* fast check for meta chars */
+               if (c == '*' || c == '?' || c == '[') {
+                       INTOFF;
+                       expmeta(expdir, pattern, dstlist);
+                       INTON;
+                       break;
                }
                }
-               str = str->next;
+       }
+       if (dstlist->count == firstmatch) {
+               /*
+                * no matches
+                */
+               rmescapes(pattern);
+               appendarglist(dstlist, pattern);
+       } else {
+               qsort(&dstlist->args[firstmatch],
+                   dstlist->count - firstmatch,
+                   sizeof(dstlist->args[0]), expsortcmp);
        }
 }
 
        }
 }
 
@@ -1134,7 +1064,7 @@ expandmeta(struct strlist *str)
  */
 
 static void
  */
 
 static void
-expmeta(char *enddir, char *name)
+expmeta(char *enddir, char *name, struct arglist *arglist)
 {
        const char *p;
        const char *q;
 {
        const char *p;
        const char *q;
@@ -1159,8 +1089,6 @@ expmeta(char *enddir, char *name)
                        if (*q == '!' || *q == '^')
                                q++;
                        for (;;) {
                        if (*q == '!' || *q == '^')
                                q++;
                        for (;;) {
-                               while (*q == CTLQUOTEMARK)
-                                       q++;
                                if (*q == CTLESC)
                                        q++;
                                if (*q == '/' || *q == '\0')
                                if (*q == CTLESC)
                                        q++;
                                if (*q == '/' || *q == '\0')
@@ -1172,8 +1100,6 @@ expmeta(char *enddir, char *name)
                        }
                } else if (*p == '\0')
                        break;
                        }
                } else if (*p == '\0')
                        break;
-               else if (*p == CTLQUOTEMARK)
-                       continue;
                else {
                        if (*p == CTLESC)
                                esc++;
                else {
                        if (*p == CTLESC)
                                esc++;
@@ -1188,8 +1114,6 @@ expmeta(char *enddir, char *name)
                if (enddir != expdir)
                        metaflag++;
                for (p = name ; ; p++) {
                if (enddir != expdir)
                        metaflag++;
                for (p = name ; ; p++) {
-                       if (*p == CTLQUOTEMARK)
-                               continue;
                        if (*p == CTLESC)
                                p++;
                        *enddir++ = *p;
                        if (*p == CTLESC)
                                p++;
                        *enddir++ = *p;
@@ -1199,15 +1123,13 @@ expmeta(char *enddir, char *name)
                                return;
                }
                if (metaflag == 0 || lstat(expdir, &statb) >= 0)
                                return;
                }
                if (metaflag == 0 || lstat(expdir, &statb) >= 0)
-                       addfname(expdir);
+                       appendarglist(arglist, stsavestr(expdir));
                return;
        }
        endname = name + (p - name);
        if (start != name) {
                p = name;
                while (p < start) {
                return;
        }
        endname = name + (p - name);
        if (start != name) {
                p = name;
                while (p < start) {
-                       while (*p == CTLQUOTEMARK)
-                               p++;
                        if (*p == CTLESC)
                                p++;
                        *enddir++ = *p++;
                        if (*p == CTLESC)
                                p++;
                        *enddir++ = *p++;
@@ -1236,8 +1158,6 @@ expmeta(char *enddir, char *name)
        }
        matchdot = 0;
        p = start;
        }
        matchdot = 0;
        p = start;
-       while (*p == CTLQUOTEMARK)
-               p++;
        if (*p == CTLESC)
                p++;
        if (*p == '.')
        if (*p == CTLESC)
                p++;
        if (*p == '.')
@@ -1245,13 +1165,13 @@ expmeta(char *enddir, char *name)
        while (! int_pending() && (dp = readdir(dirp)) != NULL) {
                if (dp->d_name[0] == '.' && ! matchdot)
                        continue;
        while (! int_pending() && (dp = readdir(dirp)) != NULL) {
                if (dp->d_name[0] == '.' && ! matchdot)
                        continue;
-               if (patmatch(start, dp->d_name, 0)) {
+               if (patmatch(start, dp->d_name)) {
                        namlen = dp->d_namlen;
                        if (enddir + namlen + 1 > expdir_end)
                                continue;
                        memcpy(enddir, dp->d_name, namlen + 1);
                        if (atend)
                        namlen = dp->d_namlen;
                        if (enddir + namlen + 1 > expdir_end)
                                continue;
                        memcpy(enddir, dp->d_name, namlen + 1);
                        if (atend)
-                               addfname(expdir);
+                               appendarglist(arglist, stsavestr(expdir));
                        else {
                                if (dp->d_type != DT_UNKNOWN &&
                                    dp->d_type != DT_DIR &&
                        else {
                                if (dp->d_type != DT_UNKNOWN &&
                                    dp->d_type != DT_DIR &&
@@ -1261,7 +1181,7 @@ expmeta(char *enddir, char *name)
                                        continue;
                                enddir[namlen] = '/';
                                enddir[namlen + 1] = '\0';
                                        continue;
                                enddir[namlen] = '/';
                                enddir[namlen + 1] = '\0';
-                               expmeta(enddir + namlen + 1, endname);
+                               expmeta(enddir + namlen + 1, endname, arglist);
                        }
                }
        }
                        }
                }
        }
@@ -1271,81 +1191,13 @@ expmeta(char *enddir, char *name)
 }
 
 
 }
 
 
-/*
- * Add a file name to the list.
- */
-
-static void
-addfname(char *name)
+static int
+expsortcmp(const void *p1, const void *p2)
 {
 {
-       char *p;
-       struct strlist *sp;
+       const char *s1 = *(const char * const *)p1;
+       const char *s2 = *(const char * const *)p2;
 
 
-       p = stsavestr(name);
-       sp = (struct strlist *)stalloc(sizeof *sp);
-       sp->text = p;
-       *exparg.lastp = sp;
-       exparg.lastp = &sp->next;
-}
-
-
-/*
- * Sort the results of file name expansion.  It calculates the number of
- * strings to sort and then calls msort (short for merge sort) to do the
- * work.
- */
-
-static struct strlist *
-expsort(struct strlist *str)
-{
-       int len;
-       struct strlist *sp;
-
-       len = 0;
-       for (sp = str ; sp ; sp = sp->next)
-               len++;
-       return msort(str, len);
-}
-
-
-static struct strlist *
-msort(struct strlist *list, int len)
-{
-       struct strlist *p, *q = NULL;
-       struct strlist **lpp;
-       int half;
-       int n;
-
-       if (len <= 1)
-               return list;
-       half = len >> 1;
-       p = list;
-       for (n = half ; --n >= 0 ; ) {
-               q = p;
-               p = p->next;
-       }
-       q->next = NULL;                 /* terminate first half of list */
-       q = msort(list, half);          /* sort first half of list */
-       p = msort(p, len - half);               /* sort second half */
-       lpp = &list;
-       for (;;) {
-               if (strcmp(p->text, q->text) < 0) {
-                       *lpp = p;
-                       lpp = &p->next;
-                       if ((p = *lpp) == NULL) {
-                               *lpp = q;
-                               break;
-                       }
-               } else {
-                       *lpp = q;
-                       lpp = &q->next;
-                       if ((q = *lpp) == NULL) {
-                               *lpp = p;
-                               break;
-                       }
-               }
-       }
-       return list;
+       return (strcoll(s1, s2));
 }
 
 
 }
 
 
@@ -1403,7 +1255,7 @@ match_charclass(const char *p, wchar_t chr, const char **end)
  */
 
 static int
  */
 
 static int
-patmatch(const char *pattern, const char *string, int squoted)
+patmatch(const char *pattern, const char *string)
 {
        const char *p, *q, *end;
        const char *bt_p, *bt_q;
 {
        const char *p, *q, *end;
        const char *bt_p, *bt_q;
@@ -1421,16 +1273,10 @@ patmatch(const char *pattern, const char *string, int squoted)
                                goto backtrack;
                        return 1;
                case CTLESC:
                                goto backtrack;
                        return 1;
                case CTLESC:
-                       if (squoted && *q == CTLESC)
-                               q++;
                        if (*q++ != *p++)
                                goto backtrack;
                        break;
                        if (*q++ != *p++)
                                goto backtrack;
                        break;
-               case CTLQUOTEMARK:
-                       continue;
                case '?':
                case '?':
-                       if (squoted && *q == CTLESC)
-                               q++;
                        if (*q == '\0')
                                return 0;
                        if (localeisutf8) {
                        if (*q == '\0')
                                return 0;
                        if (localeisutf8) {
@@ -1442,11 +1288,11 @@ patmatch(const char *pattern, const char *string, int squoted)
                                if (wc == 0)
                                        goto backtrack;
                        } else
                                if (wc == 0)
                                        goto backtrack;
                        } else
-                               wc = (unsigned char)*q++;
+                               q++;
                        break;
                case '*':
                        c = *p;
                        break;
                case '*':
                        c = *p;
-                       while (c == CTLQUOTEMARK || c == '*')
+                       while (c == '*')
                                c = *++p;
                        /*
                         * If the pattern ends here, we know the string
                                c = *++p;
                        /*
                         * If the pattern ends here, we know the string
@@ -1464,29 +1310,17 @@ patmatch(const char *pattern, const char *string, int squoted)
                        bt_q = q;
                        break;
                case '[': {
                        bt_q = q;
                        break;
                case '[': {
-                       const char *endp;
+                       const char *savep, *saveq;
                        int invert, found;
                        wchar_t chr;
 
                        int invert, found;
                        wchar_t chr;
 
-                       endp = p;
-                       if (*endp == '!' || *endp == '^')
-                               endp++;
-                       do {
-                               while (*endp == CTLQUOTEMARK)
-                                       endp++;
-                               if (*endp == 0)
-                                       goto dft;               /* no matching ] */
-                               if (*endp == CTLESC)
-                                       endp++;
-                       } while (*++endp != ']');
+                       savep = p, saveq = q;
                        invert = 0;
                        if (*p == '!' || *p == '^') {
                                invert++;
                                p++;
                        }
                        found = 0;
                        invert = 0;
                        if (*p == '!' || *p == '^') {
                                invert++;
                                p++;
                        }
                        found = 0;
-                       if (squoted && *q == CTLESC)
-                               q++;
                        if (*q == '\0')
                                return 0;
                        if (localeisutf8) {
                        if (*q == '\0')
                                return 0;
                        if (localeisutf8) {
@@ -1497,8 +1331,11 @@ patmatch(const char *pattern, const char *string, int squoted)
                                chr = (unsigned char)*q++;
                        c = *p++;
                        do {
                                chr = (unsigned char)*q++;
                        c = *p++;
                        do {
-                               if (c == CTLQUOTEMARK)
-                                       continue;
+                               if (c == '\0') {
+                                       p = savep, q = saveq;
+                                       c = '[';
+                                       goto dft;
+                               }
                                if (c == '[' && *p == ':') {
                                        found |= match_charclass(p, chr, &end);
                                        if (end != NULL)
                                if (c == '[' && *p == ':') {
                                        found |= match_charclass(p, chr, &end);
                                        if (end != NULL)
@@ -1515,8 +1352,6 @@ patmatch(const char *pattern, const char *string, int squoted)
                                        wc = (unsigned char)c;
                                if (*p == '-' && p[1] != ']') {
                                        p++;
                                        wc = (unsigned char)c;
                                if (*p == '-' && p[1] != ']') {
                                        p++;
-                                       while (*p == CTLQUOTEMARK)
-                                               p++;
                                        if (*p == CTLESC)
                                                p++;
                                        if (localeisutf8) {
                                        if (*p == CTLESC)
                                                p++;
                                        if (localeisutf8) {
@@ -1539,8 +1374,6 @@ patmatch(const char *pattern, const char *string, int squoted)
                        break;
                }
 dft:           default:
                        break;
                }
 dft:           default:
-                       if (squoted && *q == CTLESC)
-                               q++;
                        if (*q == '\0')
                                return 0;
                        if (*q++ == c)
                        if (*q == '\0')
                                return 0;
                        if (*q++ == c)
@@ -1553,8 +1386,6 @@ backtrack:
                         */
                        if (bt_p == NULL)
                                return 0;
                         */
                        if (bt_p == NULL)
                                return 0;
-                       if (squoted && *bt_q == CTLESC)
-                               bt_q++;
                        if (*bt_q == '\0')
                                return 0;
                        bt_q++;
                        if (*bt_q == '\0')
                                return 0;
                        bt_q++;
@@ -1610,11 +1441,10 @@ casematch(union node *pattern, const char *val)
        setstackmark(&smark);
        argbackq = pattern->narg.backquote;
        STARTSTACKSTR(expdest);
        setstackmark(&smark);
        argbackq = pattern->narg.backquote;
        STARTSTACKSTR(expdest);
-       ifslastp = NULL;
-       argstr(pattern->narg.text, EXP_TILDE | EXP_CASE);
+       argstr(pattern->narg.text, EXP_TILDE | EXP_CASE, NULL);
        STPUTC('\0', expdest);
        p = grabstackstr(expdest);
        STPUTC('\0', expdest);
        p = grabstackstr(expdest);
-       result = patmatch(p, val, 0);
+       result = patmatch(p, val);
        popstackmark(&smark);
        return result;
 }
        popstackmark(&smark);
        return result;
 }
@@ -1623,7 +1453,7 @@ casematch(union node *pattern, const char *val)
  * Our own itoa().
  */
 
  * Our own itoa().
  */
 
-static char *
+static void
 cvtnum(int num, char *buf)
 {
        char temp[32];
 cvtnum(int num, char *buf)
 {
        char temp[32];
@@ -1639,8 +1469,7 @@ cvtnum(int num, char *buf)
        if (neg)
                *--p = '-';
 
        if (neg)
                *--p = '-';
 
-       STPUTS(p, buf);
-       return buf;
+       memcpy(buf, p, temp + 32 - p);
 }
 
 /*
 }
 
 /*
@@ -1661,3 +1490,56 @@ wordexpcmd(int argc, char **argv)
                outbin(argv[i], strlen(argv[i]) + 1, out1);
         return (0);
 }
                outbin(argv[i], strlen(argv[i]) + 1, out1);
         return (0);
 }
+
+/*
+ * Do most of the work for wordexp(3), new version.
+ */
+
+int
+freebsd_wordexpcmd(int argc __unused, char **argv __unused)
+{
+       struct arglist arglist;
+       union node *args, *n;
+       size_t len;
+       int ch;
+       int protected = 0;
+       int fd = -1;
+       int i;
+
+       while ((ch = nextopt("f:p")) != '\0') {
+               switch (ch) {
+               case 'f':
+                       fd = number(shoptarg);
+                       break;
+               case 'p':
+                       protected = 1;
+                       break;
+               }
+       }
+       if (*argptr != NULL)
+               error("wrong number of arguments");
+       if (fd < 0)
+               error("missing fd");
+       INTOFF;
+       setinputfd(fd, 1);
+       INTON;
+       args = parsewordexp();
+       popfile(); /* will also close fd */
+       if (protected)
+               for (n = args; n != NULL; n = n->narg.next) {
+                       if (n->narg.backquote != NULL) {
+                               outcslow('C', out1);
+                               error("command substitution disabled");
+                       }
+               }
+       outcslow(' ', out1);
+       emptyarglist(&arglist);
+       for (n = args; n != NULL; n = n->narg.next)
+               expandarg(n, &arglist, EXP_FULL | EXP_TILDE);
+       for (i = 0, len = 0; i < arglist.count; i++)
+               len += strlen(arglist.args[i]);
+       out1fmt("%016x %016zx", arglist.count, len);
+       for (i = 0; i < arglist.count; i++)
+               outbin(arglist.args[i], strlen(arglist.args[i]) + 1, out1);
+       return (0);
+}
index 93c80f3013e326526831784475c25f8cb98c4592..0de4c02bcc346d2a59781ada4e84bb45d738268d 100644 (file)
  * SUCH DAMAGE.
  *
  *     @(#)expand.h    8.2 (Berkeley) 5/4/95
  * SUCH DAMAGE.
  *
  *     @(#)expand.h    8.2 (Berkeley) 5/4/95
- * $FreeBSD$
+ * $FreeBSD: head/bin/sh/expand.h 292994 2015-12-31 18:47:54Z jilles $
  */
 
  */
 
-struct strlist {
-       struct strlist *next;
-       char *text;
-};
-
-
 struct arglist {
 struct arglist {
-       struct strlist *list;
-       struct strlist **lastp;
+       char **args;
+       int count;
+       int capacity;
+       char *smallarg[1];
 };
 
 /*
  * expandarg() flags
  */
 };
 
 /*
  * expandarg() flags
  */
-#define EXP_FULL       0x1     /* perform word splitting & file globbing */
+#define EXP_SPLIT      0x1     /* perform word splitting */
 #define EXP_TILDE      0x2     /* do normal tilde expansion */
 #define        EXP_VARTILDE    0x4     /* expand tildes in an assignment */
 #define EXP_CASE       0x10    /* keeps quotes around for CASE pattern */
 #define EXP_SPLIT_LIT  0x20    /* IFS split literal text ${v+-a b c} */
 #define EXP_LIT_QUOTED 0x40    /* for EXP_SPLIT_LIT, start off quoted */
 #define EXP_TILDE      0x2     /* do normal tilde expansion */
 #define        EXP_VARTILDE    0x4     /* expand tildes in an assignment */
 #define EXP_CASE       0x10    /* keeps quotes around for CASE pattern */
 #define EXP_SPLIT_LIT  0x20    /* IFS split literal text ${v+-a b c} */
 #define EXP_LIT_QUOTED 0x40    /* for EXP_SPLIT_LIT, start off quoted */
+#define EXP_GLOB       0x80    /* perform file globbing */
+
+#define EXP_FULL       (EXP_SPLIT | EXP_GLOB)
 
 
 
 
+void emptyarglist(struct arglist *);
+void appendarglist(struct arglist *, char *);
 union node;
 void expandarg(union node *, struct arglist *, int);
 void rmescapes(char *);
 union node;
 void expandarg(union node *, struct arglist *, int);
 void rmescapes(char *);
index 2b92c60ce217030c41939624cf02440f9a769e06..307e32f9583cb0584eed5655f9f0746d259a1bce 100644 (file)
@@ -32,7 +32,7 @@
 # SUCH DAMAGE.
 #
 #      @(#)cmv 8.2 (Berkeley) 5/4/95
 # SUCH DAMAGE.
 #
 #      @(#)cmv 8.2 (Berkeley) 5/4/95
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/funcs/cmv 139969 2005-01-10 08:39:26Z imp $
 
 # Conditional move--don't replace an existing file.
 
 
 # Conditional move--don't replace an existing file.
 
index 95f6857dce4c07f3d2e126c08a5ea1be789fe38a..2a1fba584679303b2d9e9820f331031ef225ab14 100644 (file)
@@ -32,7 +32,7 @@
 # SUCH DAMAGE.
 #
 #      @(#)dirs        8.2 (Berkeley) 5/4/95
 # SUCH DAMAGE.
 #
 #      @(#)dirs        8.2 (Berkeley) 5/4/95
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/funcs/dirs 139969 2005-01-10 08:39:26Z imp $
 
 # pushd, popd, and dirs --- written by Chris Bertin
 # Pixel Computer Inc. ...!wjh12!pixel!pixutl!chris
 
 # pushd, popd, and dirs --- written by Chris Bertin
 # Pixel Computer Inc. ...!wjh12!pixel!pixutl!chris
index 68802a06d9f8121b3c47c9628e230caf8065bb8b..9ca88ec5765de029e7e8cf4e871747e1959cbba4 100644 (file)
@@ -32,7 +32,7 @@
 # SUCH DAMAGE.
 #
 #      @(#)login       8.2 (Berkeley) 5/4/95
 # SUCH DAMAGE.
 #
 #      @(#)login       8.2 (Berkeley) 5/4/95
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/funcs/login 139969 2005-01-10 08:39:26Z imp $
 
 # replaces the login builtin in the BSD shell
 login () exec login "$@"
 
 # replaces the login builtin in the BSD shell
 login () exec login "$@"
index 57ac1cec4cf408574f8d4e98d729a16a911049a8..b99c3fe2a575a6777b4d6004b32286ce0991d612 100644 (file)
@@ -32,6 +32,6 @@
 # SUCH DAMAGE.
 #
 #      @(#)newgrp      8.2 (Berkeley) 5/4/95
 # SUCH DAMAGE.
 #
 #      @(#)newgrp      8.2 (Berkeley) 5/4/95
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/funcs/newgrp 139969 2005-01-10 08:39:26Z imp $
 
 newgrp() exec newgrp "$@"
 
 newgrp() exec newgrp "$@"
index bc1cd5c8fefe7eb359960e8e8d7b312a31670bac..97878009d04a8fed26f5f0b2add768f5f41663c2 100644 (file)
@@ -32,7 +32,7 @@
 # SUCH DAMAGE.
 #
 #      @(#)popd        8.2 (Berkeley) 5/4/95
 # SUCH DAMAGE.
 #
 #      @(#)popd        8.2 (Berkeley) 5/4/95
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/funcs/popd 139969 2005-01-10 08:39:26Z imp $
 
 # pushd, popd, and dirs --- written by Chris Bertin
 # Pixel Computer Inc. ...!wjh12!pixel!pixutl!chris
 
 # pushd, popd, and dirs --- written by Chris Bertin
 # Pixel Computer Inc. ...!wjh12!pixel!pixutl!chris
index 9e31f2a20f8dfe98af89b36299b2cf2e2112dc2b..465dd310de12f7f193b1e9c7e9cc849a412d5dcb 100644 (file)
@@ -32,7 +32,7 @@
 # SUCH DAMAGE.
 #
 #      @(#)pushd       8.2 (Berkeley) 5/4/95
 # SUCH DAMAGE.
 #
 #      @(#)pushd       8.2 (Berkeley) 5/4/95
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/funcs/pushd 139969 2005-01-10 08:39:26Z imp $
 
 # pushd, popd, and dirs --- written by Chris Bertin
 # Pixel Computer Inc. ...!wjh12!pixel!pixutl!chris
 
 # pushd, popd, and dirs --- written by Chris Bertin
 # Pixel Computer Inc. ...!wjh12!pixel!pixutl!chris
index 17492985b2ea6c614cf415c19b2e56ff3fab3f64..2b0b51c8aa5dc9ec2a43c803a99d79ba1ad9ddcd 100644 (file)
@@ -30,7 +30,7 @@
 # SUCH DAMAGE.
 #
 #      @(#)suspend     8.2 (Berkeley) 5/4/95
 # SUCH DAMAGE.
 #
 #      @(#)suspend     8.2 (Berkeley) 5/4/95
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/funcs/suspend 215268 2010-11-13 22:20:46Z jilles $
 
 suspend() {
        local -
 
 suspend() {
        local -
index 7295c3f003c952c05a718988b0743d4b06aa2270..e2017b0e1bdd74c4b507c80f8650249cf2b0a184 100644 (file)
@@ -36,7 +36,7 @@ static char sccsid[] = "@(#)histedit.c        8.2 (Berkeley) 5/4/95";
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/bin/sh/histedit.c 296429 2016-03-06 17:24:02Z jilles $");
 
 #include <sys/param.h>
 #include <limits.h>
 
 #include <sys/param.h>
 #include <limits.h>
@@ -359,7 +359,7 @@ histcmd(int argc, char **argv __unused)
                                         * cursor, set it back to the current
                                         * entry.
                                         */
                                         * cursor, set it back to the current
                                         * entry.
                                         */
-                                       retval = history(hist, &he,
+                                       history(hist, &he,
                                            H_NEXT_EVENT, oldhistnum);
                                }
                        } else
                                            H_NEXT_EVENT, oldhistnum);
                                }
                        } else
index a0fd01df1cd349009057544144a5e1401d7975d2..15edb6775efcec82f9b6ee0daa00033edece1b73 100644 (file)
@@ -36,7 +36,7 @@ static char sccsid[] = "@(#)input.c   8.3 (Berkeley) 6/9/95";
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/bin/sh/input.c 295937 2016-02-23 22:44:01Z jilles $");
 
 #include <stdio.h>     /* defines BUFSIZ */
 #include <fcntl.h>
 
 #include <stdio.h>     /* defines BUFSIZ */
 #include <fcntl.h>
@@ -110,6 +110,22 @@ static void pushfile(void);
 static int preadfd(void);
 static void popstring(void);
 
 static int preadfd(void);
 static void popstring(void);
 
+#ifdef __APPLE__
+// Remove when 28988691 is fixed. Added _ to avoid conflict with future libc definition.
+static char *
+strchrnul_(const char *p, int ch)
+{
+       char c;
+
+       c = ch;
+       for (;; ++p) {
+               if (*p == c || *p == '\0')
+                       return ((char *)p);
+       }
+       /* NOTREACHED */
+}
+#endif /* __APPLE__ */
+
 void
 resetinput(void)
 {
 void
 resetinput(void)
 {
@@ -197,8 +213,7 @@ retry:
 int
 preadbuffer(void)
 {
 int
 preadbuffer(void)
 {
-       char *p, *q;
-       int more;
+       char *p, *q, *r, *end;
        char savec;
 
        while (parsefile->strpush) {
        char savec;
 
        while (parsefile->strpush) {
@@ -215,8 +230,6 @@ preadbuffer(void)
        }
        if (parsenleft == EOF_NLEFT || parsefile->buf == NULL)
                return PEOF;
        }
        if (parsenleft == EOF_NLEFT || parsefile->buf == NULL)
                return PEOF;
-       flushout(&output);
-       flushout(&errout);
 
 again:
        if (parselleft <= 0) {
 
 again:
        if (parselleft <= 0) {
@@ -226,34 +239,32 @@ again:
                }
        }
 
                }
        }
 
-       q = p = parsefile->buf + (parsenextc - parsefile->buf);
-
-       /* delete nul characters */
-       for (more = 1; more;) {
-               switch (*p) {
-               case '\0':
-                       p++;    /* Skip nul */
-                       goto check;
-
-               case '\n':
-                       parsenleft = q - parsenextc;
-                       more = 0; /* Stop processing here */
-                       break;
-
-               default:
-                       break;
-               }
-
-               *q++ = *p++;
-check:
-               if (--parselleft <= 0) {
-                       parsenleft = q - parsenextc - 1;
-                       if (parsenleft < 0)
-                               goto again;
-                       *q = '\0';
-                       more = 0;
+       p = parsefile->buf + (parsenextc - parsefile->buf);
+       end = p + parselleft;
+       *end = '\0';
+       q = strchrnul_(p, '\n');
+       if (q != end && *q == '\0') {
+               /* delete nul characters */
+               for (r = q; q != end; q++) {
+                       if (*q != '\0')
+                               *r++ = *q;
                }
                }
+               parselleft -= end - r;
+               if (parselleft == 0)
+                       goto again;
+               end = p + parselleft;
+               *end = '\0';
+               q = strchrnul_(p, '\n');
+       }
+       if (q == end) {
+               parsenleft = parselleft;
+               parselleft = 0;
+       } else /* *q == '\n' */ {
+               q++;
+               parsenleft = q - parsenextc;
+               parselleft -= parsenleft;
        }
        }
+       parsenleft--;
 
        savec = *q;
        *q = '\0';
 
        savec = *q;
        *q = '\0';
index cb0af77b4bbc014abdb575978a64e511d6d31d55..1c3ece964b0104f7cc0e6447132306c54daec436 100644 (file)
@@ -30,7 +30,7 @@
  * SUCH DAMAGE.
  *
  *     @(#)input.h     8.2 (Berkeley) 5/4/95
  * SUCH DAMAGE.
  *
  *     @(#)input.h     8.2 (Berkeley) 5/4/95
- * $FreeBSD$
+ * $FreeBSD: head/bin/sh/input.h 271593 2014-09-14 16:46:30Z jilles $
  */
 
 /* PEOF (the end of file marker) is defined in syntax.h */
  */
 
 /* PEOF (the end of file marker) is defined in syntax.h */
index b531231e4a592f9ecd1f7db34999a912cc05300d..28baa0c7a65023af2c9a37f4524541aeca5da198 100644 (file)
--- a/sh/jobs.c
+++ b/sh/jobs.c
@@ -36,7 +36,7 @@ static char sccsid[] = "@(#)jobs.c    8.5 (Berkeley) 5/4/95";
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/bin/sh/jobs.c 296326 2016-03-02 21:24:46Z jilles $");
 
 #include <sys/ioctl.h>
 #include <sys/param.h>
 
 #include <sys/ioctl.h>
 #include <sys/param.h>
@@ -322,8 +322,8 @@ static void
 showjob(struct job *jp, int mode)
 {
        char s[64];
 showjob(struct job *jp, int mode)
 {
        char s[64];
-       char statestr[64];
-       const char *sigstr;
+       char statebuf[16];
+       const char *statestr, *coredump;
        struct procstat *ps;
        struct job *j;
        int col, curr, i, jobno, prev, procno;
        struct procstat *ps;
        struct job *j;
        int col, curr, i, jobno, prev, procno;
@@ -339,9 +339,10 @@ showjob(struct job *jp, int mode)
                        prev = j - jobtab + 1;
        }
 #endif
                        prev = j - jobtab + 1;
        }
 #endif
+       coredump = "";
        ps = jp->ps + jp->nprocs - 1;
        if (jp->state == 0) {
        ps = jp->ps + jp->nprocs - 1;
        if (jp->state == 0) {
-               strcpy(statestr, "Running");
+               statestr = "Running";
 #if JOBS
        } else if (jp->state == JOBSTOPPED) {
                while (!WIFSTOPPED(ps->status) && ps > jp->ps)
 #if JOBS
        } else if (jp->state == JOBSTOPPED) {
                while (!WIFSTOPPED(ps->status) && ps > jp->ps)
@@ -350,27 +351,25 @@ showjob(struct job *jp, int mode)
                        i = WSTOPSIG(ps->status);
                else
                        i = -1;
                        i = WSTOPSIG(ps->status);
                else
                        i = -1;
-               sigstr = strsignal(i);
-               if (sigstr != NULL)
-                       strcpy(statestr, sigstr);
-               else
-                       strcpy(statestr, "Suspended");
+               statestr = strsignal(i);
+               if (statestr == NULL)
+                       statestr = "Suspended";
 #endif
        } else if (WIFEXITED(ps->status)) {
                if (WEXITSTATUS(ps->status) == 0)
 #endif
        } else if (WIFEXITED(ps->status)) {
                if (WEXITSTATUS(ps->status) == 0)
-                       strcpy(statestr, "Done");
-               else
-                       fmtstr(statestr, 64, "Done(%d)",
+                       statestr = "Done";
+               else {
+                       fmtstr(statebuf, sizeof(statebuf), "Done(%d)",
                            WEXITSTATUS(ps->status));
                            WEXITSTATUS(ps->status));
+                       statestr = statebuf;
+               }
        } else {
                i = WTERMSIG(ps->status);
        } else {
                i = WTERMSIG(ps->status);
-               sigstr = strsignal(i);
-               if (sigstr != NULL)
-                       strcpy(statestr, sigstr);
-               else
-                       strcpy(statestr, "Unknown signal");
+               statestr = strsignal(i);
+               if (statestr == NULL)
+                       statestr = "Unknown signal";
                if (WCOREDUMP(ps->status))
                if (WCOREDUMP(ps->status))
-                       strcat(statestr, " (core dumped)");
+                       coredump = " (core dumped)";
        }
 
        for (ps = jp->ps ; procno > 0 ; ps++, procno--) { /* for each process */
        }
 
        for (ps = jp->ps ; procno > 0 ; ps++, procno--) { /* for each process */
@@ -399,7 +398,8 @@ showjob(struct job *jp, int mode)
                }
                if (ps == jp->ps) {
                        out1str(statestr);
                }
                if (ps == jp->ps) {
                        out1str(statestr);
-                       col += strlen(statestr);
+                       out1str(coredump);
+                       col += strlen(statestr) + strlen(coredump);
                }
                do {
                        out1c(' ');
                }
                do {
                        out1c(' ');
index 892f12916eb9d23c3c2bd1cf7e965b141a8e5c57..f9978dedcc68543c4cba57497d5f7d43e805fd61 100644 (file)
--- a/sh/jobs.h
+++ b/sh/jobs.h
@@ -30,7 +30,7 @@
  * SUCH DAMAGE.
  *
  *     @(#)jobs.h      8.2 (Berkeley) 5/4/95
  * SUCH DAMAGE.
  *
  *     @(#)jobs.h      8.2 (Berkeley) 5/4/95
- * $FreeBSD$
+ * $FreeBSD: head/bin/sh/jobs.h 255157 2013-09-02 21:57:46Z jilles $
  */
 
 /* Mode argument to forkshell.  Don't change FORK_FG or FORK_BG. */
  */
 
 /* Mode argument to forkshell.  Don't change FORK_FG or FORK_BG. */
index 720cab032abfe6582aacb1eeb49671689fc4ed64..b6de32b61aabf993900eaecd74ee6932070fce03 100644 (file)
--- a/sh/mail.c
+++ b/sh/mail.c
@@ -36,7 +36,7 @@ static char sccsid[] = "@(#)mail.c    8.2 (Berkeley) 5/4/95";
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/bin/sh/mail.c 278820 2015-02-15 21:47:43Z jilles $");
 
 /*
  * Routines to check for mail.  (Perhaps make part of main.c?)
 
 /*
  * Routines to check for mail.  (Perhaps make part of main.c?)
index f88324c628bdb7fb19f723997e6bcea0c37ce536..fb5f90885df3afcf453977643a02ad23ba4684c5 100644 (file)
--- a/sh/mail.h
+++ b/sh/mail.h
@@ -30,7 +30,7 @@
  * SUCH DAMAGE.
  *
  *     @(#)mail.h      8.2 (Berkeley) 5/4/95
  * SUCH DAMAGE.
  *
  *     @(#)mail.h      8.2 (Berkeley) 5/4/95
- * $FreeBSD$
+ * $FreeBSD: head/bin/sh/mail.h 127958 2004-04-06 20:06:54Z markm $
  */
 
 void chkmail(int);
  */
 
 void chkmail(int);
index 08f234e5ee5fd6fe4da1b4d75767d10c7b34e3c1..452ed355d6f7dd4f6229f6aad1ed8e35931d16b8 100644 (file)
--- a/sh/main.c
+++ b/sh/main.c
@@ -42,7 +42,7 @@ static char sccsid[] = "@(#)main.c    8.6 (Berkeley) 5/28/95";
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/bin/sh/main.c 265772 2014-05-09 13:27:30Z jilles $");
 
 #include <stdio.h>
 #include <signal.h>
 
 #include <stdio.h>
 #include <signal.h>
index 3c48e330218a3fb2cd6a7f6b5d99e809f3f9a0e8..1e1b4996110ce118cd818d2345ba98a4be43af3e 100644 (file)
--- a/sh/main.h
+++ b/sh/main.h
@@ -30,7 +30,7 @@
  * SUCH DAMAGE.
  *
  *     @(#)main.h      8.2 (Berkeley) 5/4/95
  * SUCH DAMAGE.
  *
  *     @(#)main.h      8.2 (Berkeley) 5/4/95
- * $FreeBSD$
+ * $FreeBSD: head/bin/sh/main.h 229220 2012-01-01 22:17:12Z jilles $
  */
 
 extern int rootpid;    /* pid of main shell */
  */
 
 extern int rootpid;    /* pid of main shell */
index a04020f80c97293655f1f39b7b979f1fb9267156..32e3838eb2bae05efb18e2e4e92b1ba087d214d1 100644 (file)
@@ -36,7 +36,7 @@ static char sccsid[] = "@(#)memalloc.c        8.3 (Berkeley) 5/4/95";
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/bin/sh/memalloc.c 278818 2015-02-15 21:41:29Z jilles $");
 
 #include <sys/param.h>
 #include "shell.h"
 
 #include <sys/param.h>
 #include "shell.h"
index e8df7cb1c0b9f03e77af10ca9065ec55afd90f58..ee86a9228152ff50a9b405d102f7ff834379db52 100644 (file)
@@ -30,7 +30,7 @@
  * SUCH DAMAGE.
  *
  *     @(#)memalloc.h  8.2 (Berkeley) 5/4/95
  * SUCH DAMAGE.
  *
  *     @(#)memalloc.h  8.2 (Berkeley) 5/4/95
- * $FreeBSD$
+ * $FreeBSD: head/bin/sh/memalloc.h 278818 2015-02-15 21:41:29Z jilles $
  */
 
 #include <string.h>
  */
 
 #include <string.h>
index 789da25e41331b40d7119c7b40a3b421f47fd9d3..1950ebcbbd4be8a057604b0b311021f87fa28233 100644 (file)
@@ -36,7 +36,7 @@ static char sccsid[] = "@(#)miscbltin.c       8.4 (Berkeley) 5/4/95";
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/bin/sh/miscbltin.c 301452 2016-06-05 16:09:31Z jilles $");
 
 /*
  * Miscellaneous builtins.
 
 /*
  * Miscellaneous builtins.
@@ -100,6 +100,7 @@ readcmd(int argc __unused, char **argv __unused)
        int i;
        int is_ifs;
        int saveall = 0;
        int i;
        int is_ifs;
        int saveall = 0;
+       ptrdiff_t lastnonifs, lastnonifsws;
        struct timeval tv;
        char *tvptr;
        fd_set ifds;
        struct timeval tv;
        char *tvptr;
        fd_set ifds;
@@ -169,6 +170,7 @@ readcmd(int argc __unused, char **argv __unused)
        startword = 2;
        backslash = 0;
        STARTSTACKSTR(p);
        startword = 2;
        backslash = 0;
        STARTSTACKSTR(p);
+       lastnonifs = lastnonifsws = -1;
        for (;;) {
                nread = read(STDIN_FILENO, &c, 1);
                if (nread == -1) {
        for (;;) {
                nread = read(STDIN_FILENO, &c, 1);
                if (nread == -1) {
@@ -191,9 +193,11 @@ readcmd(int argc __unused, char **argv __unused)
                CHECKSTRSPACE(1, p);
                if (backslash) {
                        backslash = 0;
                CHECKSTRSPACE(1, p);
                if (backslash) {
                        backslash = 0;
-                       startword = 0;
-                       if (c != '\n')
+                       if (c != '\n') {
+                               startword = 0;
+                               lastnonifs = lastnonifsws = p - stackblock();
                                USTPUTC(c, p);
                                USTPUTC(c, p);
+                       }
                        continue;
                }
                if (!rflag && c == '\\') {
                        continue;
                }
                if (!rflag && c == '\\') {
@@ -217,8 +221,10 @@ readcmd(int argc __unused, char **argv __unused)
                        if (is_ifs == 2 && startword == 1) {
                                /* Only one non-whitespace IFS per word */
                                startword = 2;
                        if (is_ifs == 2 && startword == 1) {
                                /* Only one non-whitespace IFS per word */
                                startword = 2;
-                               if (saveall)
+                               if (saveall) {
+                                       lastnonifsws = p - stackblock();
                                        USTPUTC(c, p);
                                        USTPUTC(c, p);
+                               }
                                continue;
                        }
                }
                                continue;
                        }
                }
@@ -229,6 +235,7 @@ readcmd(int argc __unused, char **argv __unused)
                        if (saveall)
                                /* Not just a spare terminator */
                                saveall++;
                        if (saveall)
                                /* Not just a spare terminator */
                                saveall++;
+                       lastnonifs = lastnonifsws = p - stackblock();
                        USTPUTC(c, p);
                        continue;
                }
                        USTPUTC(c, p);
                        continue;
                }
@@ -239,6 +246,8 @@ readcmd(int argc __unused, char **argv __unused)
                if (ap[1] == NULL) {
                        /* Last variable needs all IFS chars */
                        saveall++;
                if (ap[1] == NULL) {
                        /* Last variable needs all IFS chars */
                        saveall++;
+                       if (is_ifs == 2)
+                               lastnonifsws = p - stackblock();
                        USTPUTC(c, p);
                        continue;
                }
                        USTPUTC(c, p);
                        continue;
                }
@@ -247,20 +256,17 @@ readcmd(int argc __unused, char **argv __unused)
                setvar(*ap, stackblock(), 0);
                ap++;
                STARTSTACKSTR(p);
                setvar(*ap, stackblock(), 0);
                ap++;
                STARTSTACKSTR(p);
+               lastnonifs = lastnonifsws = -1;
        }
        STACKSTRNUL(p);
 
        }
        STACKSTRNUL(p);
 
-       /* Remove trailing IFS chars */
-       for (; stackblock() <= --p; *p = 0) {
-               if (!strchr(ifs, *p))
-                       break;
-               if (strchr(" \t\n", *p))
-                       /* Always remove whitespace */
-                       continue;
-               if (saveall > 1)
-                       /* Don't remove non-whitespace unless it was naked */
-                       break;
-       }
+       /*
+        * Remove trailing IFS chars: always remove whitespace, don't remove
+        * non-whitespace unless it was naked
+        */
+       if (saveall <= 1)
+               lastnonifsws = lastnonifs;
+       stackblock()[lastnonifsws + 1] = '\0';
        setvar(*ap, stackblock(), 0);
 
        /* Set any remaining args to "" */
        setvar(*ap, stackblock(), 0);
 
        /* Set any remaining args to "" */
@@ -335,7 +341,7 @@ umaskcmd(int argc __unused, char **argv __unused)
                } else {
                        void *set;
                        INTOFF;
                } else {
                        void *set;
                        INTOFF;
-                       if ((set = setmode (ap)) == 0)
+                       if ((set = setmode (ap)) == NULL)
                                error("Illegal number: %s", ap);
 
                        mask = getmode (set, ~mask & 0777);
                                error("Illegal number: %s", ap);
 
                        mask = getmode (set, ~mask & 0777);
@@ -400,13 +406,16 @@ static const struct limits limits[] = {
        { "swap limit",         "kbytes",       RLIMIT_SWAP,    1024, 'w' },
 #endif
 #ifdef RLIMIT_SBSIZE
        { "swap limit",         "kbytes",       RLIMIT_SWAP,    1024, 'w' },
 #endif
 #ifdef RLIMIT_SBSIZE
-       { "sbsize",             "bytes",        RLIMIT_SBSIZE,     1, 'b' },
+       { "socket buffer size", "bytes",        RLIMIT_SBSIZE,     1, 'b' },
 #endif
 #ifdef RLIMIT_NPTS
        { "pseudo-terminals",   (char *)0,      RLIMIT_NPTS,       1, 'p' },
 #endif
 #ifdef RLIMIT_KQUEUES
        { "kqueues",            (char *)0,      RLIMIT_KQUEUES,    1, 'k' },
 #endif
 #ifdef RLIMIT_NPTS
        { "pseudo-terminals",   (char *)0,      RLIMIT_NPTS,       1, 'p' },
 #endif
 #ifdef RLIMIT_KQUEUES
        { "kqueues",            (char *)0,      RLIMIT_KQUEUES,    1, 'k' },
+#endif
+#ifdef RLIMIT_UMTXP
+       { "umtx shared locks",  (char *)0,      RLIMIT_UMTXP,      1, 'o' },
 #endif
        { (char *) 0,           (char *)0,      0,                 0, '\0' }
 };
 #endif
        { (char *) 0,           (char *)0,      0,                 0, '\0' }
 };
@@ -443,7 +452,7 @@ ulimitcmd(int argc __unused, char **argv __unused)
        struct rlimit   limit;
 
        what = 'f';
        struct rlimit   limit;
 
        what = 'f';
-       while ((optc = nextopt("HSatfdsmcnuvlbpwk")) != '\0')
+       while ((optc = nextopt("HSatfdsmcnuvlbpwko")) != '\0')
                switch (optc) {
                case 'H':
                        how = HARD;
                switch (optc) {
                case 'H':
                        how = HARD;
index 1be7ff149089758ab8f4b92b257097c1f1dc6199..dd0adc8d000e0ea23d376f104a3dc6fb805adc3b 100755 (executable)
@@ -32,7 +32,7 @@
 # SUCH DAMAGE.
 #
 #      @(#)mkbuiltins  8.2 (Berkeley) 5/4/95
 # SUCH DAMAGE.
 #
 #      @(#)mkbuiltins  8.2 (Berkeley) 5/4/95
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/mkbuiltins 293118 2016-01-03 21:30:22Z jilles $
 
 temp=`/usr/bin/mktemp -t ka`
 havehist=1
 
 temp=`/usr/bin/mktemp -t ka`
 havehist=1
@@ -62,17 +62,16 @@ echo 'int (*const builtinfunc[])(int, char **) = {'
 awk '/^[^#]/ { printf "\t%s,\n", $1}' $temp
 echo '};
 
 awk '/^[^#]/ { printf "\t%s,\n", $1}' $temp
 echo '};
 
-const struct builtincmd builtincmd[] = {'
+const unsigned char builtincmd[] = {'
 awk '{ for (i = 2 ; i <= NF ; i++) {
                if ($i == "-s") {
                        spc = 1;
                } else {
 awk '{ for (i = 2 ; i <= NF ; i++) {
                if ($i == "-s") {
                        spc = 1;
                } else {
-                       printf "\t{ \"%s\", %d, %d },\n",  $i, NR-1, spc
+                       printf "\t\"\\%03o\\%03o%s\"\n", length($i), (spc ? 128 : 0) + NR-1, $i
                        spc = 0;
                }
        }}' $temp
                        spc = 0;
                }
        }}' $temp
-echo ' { NULL, 0, 0 }
-};'
+echo '};'
 
 exec > builtins.h
 cat <<\!
 
 exec > builtins.h
 cat <<\!
@@ -85,14 +84,10 @@ cat <<\!
 tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ < $temp |
        awk '{  printf "#define %s %d\n", $1, NR-1}'
 echo '
 tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ < $temp |
        awk '{  printf "#define %s %d\n", $1, NR-1}'
 echo '
-struct builtincmd {
-      const char *name;
-      int code;
-      int special;
-};
+#define BUILTIN_SPECIAL 0x80
 
 extern int (*const builtinfunc[])(int, char **);
 
 extern int (*const builtinfunc[])(int, char **);
-extern const struct builtincmd builtincmd[];
+extern const unsigned char builtincmd[];
 '
 awk '{ printf "int %s(int, char **);\n", $1}' $temp
 rm -f $temp
 '
 awk '{ printf "int %s(int, char **);\n", $1}' $temp
 rm -f $temp
index d2fed0d6d17c50a043ec42bff94f176d4a40d75c..46944602b7fbb743c4e0ba7b6e00ae75a7ce4350 100644 (file)
@@ -42,7 +42,7 @@ static char sccsid[] = "@(#)mknodes.c 8.2 (Berkeley) 5/4/95";
 #endif /* not lint */
 #endif
 #include <sys/cdefs.h>
 #endif /* not lint */
 #endif
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/bin/sh/mknodes.c 292517 2015-12-20 16:40:36Z jilles $");
 
 /*
  * This program reads the nodetypes file and nodes.c.pat file.  It generates
 
 /*
  * This program reads the nodetypes file and nodes.c.pat file.  It generates
@@ -95,7 +95,6 @@ static struct str *nodestr[MAXTYPES]; /* type of structure used by the node */
 static int nstr;                       /* number of structures */
 static struct str str[MAXTYPES];       /* the structures */
 static struct str *curstr;             /* current structure */
 static int nstr;                       /* number of structures */
 static struct str str[MAXTYPES];       /* the structures */
 static struct str *curstr;             /* current structure */
-static FILE *infp;
 static char line[1024];
 static int linno;
 static char *linep;
 static char line[1024];
 static int linno;
 static char *linep;
@@ -108,7 +107,7 @@ static void outfunc(FILE *, int);
 static void indent(int, FILE *);
 static int nextfield(char *);
 static void skipbl(void);
 static void indent(int, FILE *);
 static int nextfield(char *);
 static void skipbl(void);
-static int readline(void);
+static int readline(FILE *);
 static void error(const char *, ...) __printf0like(1, 2) __dead2;
 static char *savestr(const char *);
 
 static void error(const char *, ...) __printf0like(1, 2) __dead2;
 static char *savestr(const char *);
 
@@ -116,17 +115,19 @@ static char *savestr(const char *);
 int
 main(int argc, char *argv[])
 {
 int
 main(int argc, char *argv[])
 {
+       FILE *infp;
+
        if (argc != 3)
                error("usage: mknodes file");
        if (argc != 3)
                error("usage: mknodes file");
-       infp = stdin;
        if ((infp = fopen(argv[1], "r")) == NULL)
                error("Can't open %s: %s", argv[1], strerror(errno));
        if ((infp = fopen(argv[1], "r")) == NULL)
                error("Can't open %s: %s", argv[1], strerror(errno));
-       while (readline()) {
+       while (readline(infp)) {
                if (line[0] == ' ' || line[0] == '\t')
                        parsefield();
                else if (line[0] != '\0')
                        parsenode();
        }
                if (line[0] == ' ' || line[0] == '\t')
                        parsefield();
                else if (line[0] != '\0')
                        parsenode();
        }
+       fclose(infp);
        output(argv[2]);
        exit(0);
 }
        output(argv[2]);
        exit(0);
 }
@@ -259,6 +260,10 @@ output(char *file)
        fputs("union node *getfuncnode(struct funcdef *);\n", hfile);
        fputs("void reffunc(struct funcdef *);\n", hfile);
        fputs("void unreffunc(struct funcdef *);\n", hfile);
        fputs("union node *getfuncnode(struct funcdef *);\n", hfile);
        fputs("void reffunc(struct funcdef *);\n", hfile);
        fputs("void unreffunc(struct funcdef *);\n", hfile);
+       if (ferror(hfile))
+               error("Can't write to nodes.h");
+       if (fclose(hfile))
+               error("Can't close nodes.h");
 
        fputs(writer, cfile);
        while (fgets(line, sizeof line, patfile) != NULL) {
 
        fputs(writer, cfile);
        while (fgets(line, sizeof line, patfile) != NULL) {
@@ -272,6 +277,11 @@ output(char *file)
                else
                        fputs(line, cfile);
        }
                else
                        fputs(line, cfile);
        }
+       fclose(patfile);
+       if (ferror(cfile))
+               error("Can't write to nodes.c");
+       if (fclose(cfile))
+               error("Can't close nodes.c");
 }
 
 
 }
 
 
@@ -302,10 +312,10 @@ outfunc(FILE *cfile, int calcsize)
        else
                fputs("     return NULL;\n", cfile);
        if (calcsize)
        else
                fputs("     return NULL;\n", cfile);
        if (calcsize)
-               fputs("      funcblocksize += nodesize[n->type];\n", cfile);
+               fputs("      result->blocksize += nodesize[n->type];\n", cfile);
        else {
        else {
-               fputs("      new = funcblock;\n", cfile);
-               fputs("      funcblock = (char *)funcblock + nodesize[n->type];\n", cfile);
+               fputs("      new = state->block;\n", cfile);
+               fputs("      state->block = (char *)state->block + nodesize[n->type];\n", cfile);
        }
        fputs("      switch (n->type) {\n", cfile);
        for (sp = str ; sp < &str[nstr] ; sp++) {
        }
        fputs("      switch (n->type) {\n", cfile);
        for (sp = str ; sp < &str[nstr] ; sp++) {
@@ -319,33 +329,33 @@ outfunc(FILE *cfile, int calcsize)
                        case T_NODE:
                                if (calcsize) {
                                        indent(12, cfile);
                        case T_NODE:
                                if (calcsize) {
                                        indent(12, cfile);
-                                       fprintf(cfile, "calcsize(n->%s.%s);\n",
+                                       fprintf(cfile, "calcsize(n->%s.%s, result);\n",
                                                sp->tag, fp->name);
                                } else {
                                        indent(12, cfile);
                                                sp->tag, fp->name);
                                } else {
                                        indent(12, cfile);
-                                       fprintf(cfile, "new->%s.%s = copynode(n->%s.%s);\n",
+                                       fprintf(cfile, "new->%s.%s = copynode(n->%s.%s, state);\n",
                                                sp->tag, fp->name, sp->tag, fp->name);
                                }
                                break;
                        case T_NODELIST:
                                if (calcsize) {
                                        indent(12, cfile);
                                                sp->tag, fp->name, sp->tag, fp->name);
                                }
                                break;
                        case T_NODELIST:
                                if (calcsize) {
                                        indent(12, cfile);
-                                       fprintf(cfile, "sizenodelist(n->%s.%s);\n",
+                                       fprintf(cfile, "sizenodelist(n->%s.%s, result);\n",
                                                sp->tag, fp->name);
                                } else {
                                        indent(12, cfile);
                                                sp->tag, fp->name);
                                } else {
                                        indent(12, cfile);
-                                       fprintf(cfile, "new->%s.%s = copynodelist(n->%s.%s);\n",
+                                       fprintf(cfile, "new->%s.%s = copynodelist(n->%s.%s, state);\n",
                                                sp->tag, fp->name, sp->tag, fp->name);
                                }
                                break;
                        case T_STRING:
                                if (calcsize) {
                                        indent(12, cfile);
                                                sp->tag, fp->name, sp->tag, fp->name);
                                }
                                break;
                        case T_STRING:
                                if (calcsize) {
                                        indent(12, cfile);
-                                       fprintf(cfile, "funcstringsize += strlen(n->%s.%s) + 1;\n",
+                                       fprintf(cfile, "result->stringsize += strlen(n->%s.%s) + 1;\n",
                                                sp->tag, fp->name);
                                } else {
                                        indent(12, cfile);
                                                sp->tag, fp->name);
                                } else {
                                        indent(12, cfile);
-                                       fprintf(cfile, "new->%s.%s = nodesavestr(n->%s.%s);\n",
+                                       fprintf(cfile, "new->%s.%s = nodesavestr(n->%s.%s, state);\n",
                                                sp->tag, fp->name, sp->tag, fp->name);
                                }
                                break;
                                                sp->tag, fp->name, sp->tag, fp->name);
                                }
                                break;
@@ -407,7 +417,7 @@ skipbl(void)
 
 
 static int
 
 
 static int
-readline(void)
+readline(FILE *infp)
 {
        char *p;
 
 {
        char *p;
 
index 1f81828e5a694065afa322cc231edde10db46eb2..8f9c8fd71f4b7ed08d52633b35a2dbadba758ce5 100644 (file)
@@ -42,7 +42,7 @@ static char sccsid[] = "@(#)mksyntax.c        8.2 (Berkeley) 5/4/95";
 #endif /* not lint */
 #endif
 #include <sys/cdefs.h>
 #endif /* not lint */
 #endif
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/bin/sh/mksyntax.c 279569 2015-03-03 21:21:43Z jilles $");
 
 /*
  * This program creates syntax.h and syntax.c.
 
 /*
  * This program creates syntax.h and syntax.c.
index b6f5f97638a12aed9652a5bfaac96d2c801d7266..7dd80800e30d236b29cbc4ffcb977f05ba6eb6c2 100644 (file)
@@ -32,7 +32,7 @@
 # SUCH DAMAGE.
 #
 #      @(#)mktokens    8.1 (Berkeley) 5/31/93
 # SUCH DAMAGE.
 #
 #      @(#)mktokens    8.1 (Berkeley) 5/31/93
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/mktokens 279503 2015-03-01 21:46:55Z jilles $
 
 # The following is a list of tokens.  The second column is nonzero if the
 # token marks the end of a list.  The third column is the name to print in
 
 # The following is a list of tokens.  The second column is nonzero if the
 # token marks the end of a list.  The third column is the name to print in
index e31276daf4b0e661fe0fefa3aa24453d76a23116..1d21f4674fa17f8e89cfc106ad4b874330cdfb6f 100644 (file)
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  *
  *     @(#)myhistedit.h        8.2 (Berkeley) 5/4/95
  * SUCH DAMAGE.
  *
  *     @(#)myhistedit.h        8.2 (Berkeley) 5/4/95
- * $FreeBSD$
+ * $FreeBSD: head/bin/sh/myhistedit.h 229220 2012-01-01 22:17:12Z jilles $
  */
 
 #include <histedit.h>
  */
 
 #include <histedit.h>
index 19de78d9fd5d9356a32e35974b4f6315225868a2..60349d7e2fd929043798a3ee23408685e94a8426 100644 (file)
@@ -36,7 +36,7 @@ static char sccsid[] = "@(#)mystring.c        8.2 (Berkeley) 5/4/95";
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/bin/sh/mystring.c 270102 2014-08-17 16:40:29Z jilles $");
 
 /*
  * String functions.
 
 /*
  * String functions.
index 919fc867e7cf7a16dcc64ed2321d346db0beeee6..3876bab57f26af5eb39ee11a1dd795fb990395c2 100644 (file)
@@ -30,7 +30,7 @@
  * SUCH DAMAGE.
  *
  *     @(#)mystring.h  8.2 (Berkeley) 5/4/95
  * SUCH DAMAGE.
  *
  *     @(#)mystring.h  8.2 (Berkeley) 5/4/95
- * $FreeBSD$
+ * $FreeBSD: head/bin/sh/mystring.h 268920 2014-07-20 12:06:52Z jilles $
  */
 
 #include <string.h>
  */
 
 #include <string.h>
index e99e3abba69d03eda8cabbfe717c0a8de54885f5..d114d0e4b24cf2025c34a1aa489475940f37ebd0 100644 (file)
@@ -30,7 +30,7 @@
  * SUCH DAMAGE.
  *
  *     @(#)nodes.c.pat 8.2 (Berkeley) 5/4/95
  * SUCH DAMAGE.
  *
  *     @(#)nodes.c.pat 8.2 (Berkeley) 5/4/95
- * $FreeBSD$
+ * $FreeBSD: head/bin/sh/nodes.c.pat 291267 2015-11-24 22:47:19Z jilles $
  */
 
 #include <sys/param.h>
  */
 
 #include <sys/param.h>
 #include "mystring.h"
 
 
 #include "mystring.h"
 
 
-static int     funcblocksize;  /* size of structures in function */
-static int     funcstringsize; /* size of strings in node */
-static pointer funcblock;      /* block to allocate function from */
-static char   *funcstring;     /* block to allocate strings from */
+struct nodesize {
+       int     blocksize;      /* size of structures in function */
+       int     stringsize;     /* size of strings in node */
+};
+
+struct nodecopystate {
+       pointer block;          /* block to allocate function from */
+       char   *string;         /* block to allocate strings from */
+};
 
 %SIZES
 
 
 
 %SIZES
 
 
-static void calcsize(union node *);
-static void sizenodelist(struct nodelist *);
-static union node *copynode(union node *);
-static struct nodelist *copynodelist(struct nodelist *);
-static char *nodesavestr(const char *);
+static void calcsize(union node *, struct nodesize *);
+static void sizenodelist(struct nodelist *, struct nodesize *);
+static union node *copynode(union node *, struct nodecopystate *);
+static struct nodelist *copynodelist(struct nodelist *, struct nodecopystate *);
+static char *nodesavestr(const char *, struct nodecopystate *);
 
 
 struct funcdef {
 
 
 struct funcdef {
@@ -73,18 +78,20 @@ struct funcdef {
 struct funcdef *
 copyfunc(union node *n)
 {
 struct funcdef *
 copyfunc(union node *n)
 {
+       struct nodesize sz;
+       struct nodecopystate st;
        struct funcdef *fn;
 
        if (n == NULL)
                return NULL;
        struct funcdef *fn;
 
        if (n == NULL)
                return NULL;
-       funcblocksize = offsetof(struct funcdef, n);
-       funcstringsize = 0;
-       calcsize(n);
-       fn = ckmalloc(funcblocksize + funcstringsize);
+       sz.blocksize = offsetof(struct funcdef, n);
+       sz.stringsize = 0;
+       calcsize(n, &sz);
+       fn = ckmalloc(sz.blocksize + sz.stringsize);
        fn->refcount = 1;
        fn->refcount = 1;
-       funcblock = (char *)fn + offsetof(struct funcdef, n);
-       funcstring = (char *)fn + funcblocksize;
-       copynode(n);
+       st.block = (char *)fn + offsetof(struct funcdef, n);
+       st.string = (char *)fn + sz.blocksize;
+       copynode(n, &st);
        return fn;
 }
 
        return fn;
 }
 
@@ -97,7 +104,7 @@ getfuncnode(struct funcdef *fn)
 
 
 static void
 
 
 static void
-calcsize(union node *n)
+calcsize(union node *n, struct nodesize *result)
 {
        %CALCSIZE
 }
 {
        %CALCSIZE
 }
@@ -105,11 +112,11 @@ calcsize(union node *n)
 
 
 static void
 
 
 static void
-sizenodelist(struct nodelist *lp)
+sizenodelist(struct nodelist *lp, struct nodesize *result)
 {
        while (lp) {
 {
        while (lp) {
-               funcblocksize += ALIGN(sizeof(struct nodelist));
-               calcsize(lp->n);
+               result->blocksize += ALIGN(sizeof(struct nodelist));
+               calcsize(lp->n, result);
                lp = lp->next;
        }
 }
                lp = lp->next;
        }
 }
@@ -117,7 +124,7 @@ sizenodelist(struct nodelist *lp)
 
 
 static union node *
 
 
 static union node *
-copynode(union node *n)
+copynode(union node *n, struct nodecopystate *state)
 {
        union node *new;
 
 {
        union node *new;
 
@@ -127,16 +134,17 @@ copynode(union node *n)
 
 
 static struct nodelist *
 
 
 static struct nodelist *
-copynodelist(struct nodelist *lp)
+copynodelist(struct nodelist *lp, struct nodecopystate *state)
 {
        struct nodelist *start;
        struct nodelist **lpp;
 
        lpp = &start;
        while (lp) {
 {
        struct nodelist *start;
        struct nodelist **lpp;
 
        lpp = &start;
        while (lp) {
-               *lpp = funcblock;
-               funcblock = (char *)funcblock + ALIGN(sizeof(struct nodelist));
-               (*lpp)->n = copynode(lp->n);
+               *lpp = state->block;
+               state->block = (char *)state->block +
+                   ALIGN(sizeof(struct nodelist));
+               (*lpp)->n = copynode(lp->n, state);
                lp = lp->next;
                lpp = &(*lpp)->next;
        }
                lp = lp->next;
                lpp = &(*lpp)->next;
        }
@@ -147,15 +155,15 @@ copynodelist(struct nodelist *lp)
 
 
 static char *
 
 
 static char *
-nodesavestr(const char *s)
+nodesavestr(const char *s, struct nodecopystate *state)
 {
        const char *p = s;
 {
        const char *p = s;
-       char *q = funcstring;
-       char   *rtn = funcstring;
+       char *q = state->string;
+       char   *rtn = state->string;
 
        while ((*q++ = *p++) != '\0')
                continue;
 
        while ((*q++ = *p++) != '\0')
                continue;
-       funcstring = q;
+       state->string = q;
        return rtn;
 }
 
        return rtn;
 }
 
index d480093a8a324358875197ff0b1ae9f6d2fe7717..7fb341729aa3b67678d640f98929eab98cc5dad8 100644 (file)
@@ -30,7 +30,7 @@
 # SUCH DAMAGE.
 #
 #      @(#)nodetypes   8.2 (Berkeley) 5/4/95
 # SUCH DAMAGE.
 #
 #      @(#)nodetypes   8.2 (Berkeley) 5/4/95
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/nodetypes 278820 2015-02-15 21:47:43Z jilles $
 
 # This file describes the nodes used in parse trees.  Unindented lines
 # contain a node type followed by a structure tag.  Subsequent indented
 
 # This file describes the nodes used in parse trees.  Unindented lines
 # contain a node type followed by a structure tag.  Subsequent indented
index 2d0ddce5a3de150c2a0803293469434b18d58c67..25056b20e0d2b7b9af622e997bf71b47fcc75c01 100644 (file)
@@ -36,7 +36,7 @@ static char sccsid[] = "@(#)options.c 8.2 (Berkeley) 5/4/95";
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/bin/sh/options.c 296577 2016-03-09 21:00:57Z jilles $");
 
 #include <signal.h>
 #include <unistd.h>
 
 #include <signal.h>
 #include <unistd.h>
@@ -73,6 +73,8 @@ char *minusc;                 /* argument to -c option */
 static void options(int);
 static void minus_o(char *, int);
 static void setoption(int, int);
 static void options(int);
 static void minus_o(char *, int);
 static void setoption(int, int);
+static void setoptionbyindex(int, int);
+static void setparam(int, char **);
 static int getopts(char *, char *, char **, char ***, char **);
 
 
 static int getopts(char *, char *, char **, char ***, char **);
 
 
@@ -90,7 +92,7 @@ procargs(int argc, char **argv)
        if (argc > 0)
                argptr++;
        for (i = 0; i < NOPTS; i++)
        if (argc > 0)
                argptr++;
        for (i = 0; i < NOPTS; i++)
-               optlist[i].val = 2;
+               optval[i] = 2;
        privileged = (getuid() != geteuid() || getgid() != getegid());
        options(1);
        if (*argptr == NULL && minusc == NULL)
        privileged = (getuid() != geteuid() || getgid() != getegid());
        options(1);
        if (*argptr == NULL && minusc == NULL)
@@ -103,8 +105,8 @@ procargs(int argc, char **argv)
        if (mflag == 2)
                mflag = iflag;
        for (i = 0; i < NOPTS; i++)
        if (mflag == 2)
                mflag = iflag;
        for (i = 0; i < NOPTS; i++)
-               if (optlist[i].val == 2)
-                       optlist[i].val = 0;
+               if (optval[i] == 2)
+                       optval[i] = 0;
        arg0 = argv[0];
        if (sflag == 0 && minusc == NULL) {
                scriptname = *argptr++;
        arg0 = argv[0];
        if (sflag == 0 && minusc == NULL) {
                scriptname = *argptr++;
@@ -223,7 +225,7 @@ end_options1:
 end_options2:
        if (!cmdline) {
                if (*argptr == NULL)
 end_options2:
        if (!cmdline) {
                if (*argptr == NULL)
-                       setparam(argptr);
+                       setparam(0, argptr);
                return;
        }
 
                return;
        }
 
@@ -249,27 +251,30 @@ static void
 minus_o(char *name, int val)
 {
        int i;
 minus_o(char *name, int val)
 {
        int i;
+       const unsigned char *on;
+       size_t len;
 
        if (name == NULL) {
                if (val) {
                        /* "Pretty" output. */
                        out1str("Current option settings\n");
 
        if (name == NULL) {
                if (val) {
                        /* "Pretty" output. */
                        out1str("Current option settings\n");
-                       for (i = 0; i < NOPTS; i++)
-                               out1fmt("%-16s%s\n", optlist[i].name,
-                                       optlist[i].val ? "on" : "off");
+                       for (i = 0, on = optname; i < NOPTS; i++, on += *on + 1)
+                               out1fmt("%-16.*s%s\n", *on, on + 1,
+                                       optval[i] ? "on" : "off");
                } else {
                        /* Output suitable for re-input to shell. */
                } else {
                        /* Output suitable for re-input to shell. */
-                       for (i = 0; i < NOPTS; i++)
-                               out1fmt("%s %co %s%s",
+                       for (i = 0, on = optname; i < NOPTS; i++, on += *on + 1)
+                               out1fmt("%s %co %.*s%s",
                                    i % 6 == 0 ? "set" : "",
                                    i % 6 == 0 ? "set" : "",
-                                   optlist[i].val ? '-' : '+',
-                                   optlist[i].name,
+                                   optval[i] ? '-' : '+',
+                                   *on, on + 1,
                                    i % 6 == 5 || i == NOPTS - 1 ? "\n" : "");
                }
        } else {
                                    i % 6 == 5 || i == NOPTS - 1 ? "\n" : "");
                }
        } else {
-               for (i = 0; i < NOPTS; i++)
-                       if (equal(name, optlist[i].name)) {
-                               setoption(optlist[i].letter, val);
+               len = strlen(name);
+               for (i = 0, on = optname; i < NOPTS; i++, on += *on + 1)
+                       if (*on == len && memcmp(on + 1, name, len) == 0) {
+                               setoptionbyindex(i, val);
                                return;
                        }
                error("Illegal option -o %s", name);
                                return;
                        }
                error("Illegal option -o %s", name);
@@ -278,26 +283,32 @@ minus_o(char *name, int val)
 
 
 static void
 
 
 static void
-setoption(int flag, int val)
+setoptionbyindex(int idx, int val)
 {
 {
-       int i;
-
-       if (flag == 'p' && !val && privileged) {
+       if (&optval[idx] == &privileged && !val && privileged) {
                if (setgid(getgid()) == -1)
                        error("setgid");
                if (setuid(getuid()) == -1)
                        error("setuid");
        }
                if (setgid(getgid()) == -1)
                        error("setgid");
                if (setuid(getuid()) == -1)
                        error("setuid");
        }
-       for (i = 0; i < NOPTS; i++)
-               if (optlist[i].letter == flag) {
-                       optlist[i].val = val;
-                       if (val) {
-                               /* #%$ hack for ksh semantics */
-                               if (flag == 'V')
-                                       Eflag = 0;
-                               else if (flag == 'E')
-                                       Vflag = 0;
-                       }
+       optval[idx] = val;
+       if (val) {
+               /* #%$ hack for ksh semantics */
+               if (&optval[idx] == &Vflag)
+                       Eflag = 0;
+               else if (&optval[idx] == &Eflag)
+                       Vflag = 0;
+       }
+}
+
+static void
+setoption(int flag, int val)
+{
+       int i;
+
+       for (i = 0; i < NSHORTOPTS; i++)
+               if (optletter[i] == flag) {
+                       setoptionbyindex(i, val);
                        return;
                }
        error("Illegal option -%c", flag);
                        return;
                }
        error("Illegal option -%c", flag);
@@ -308,22 +319,20 @@ setoption(int flag, int val)
  * Set the shell parameters.
  */
 
  * Set the shell parameters.
  */
 
-void
-setparam(char **argv)
+static void
+setparam(int argc, char **argv)
 {
        char **newparam;
        char **ap;
 {
        char **newparam;
        char **ap;
-       int nparam;
 
 
-       for (nparam = 0 ; argv[nparam] ; nparam++);
-       ap = newparam = ckmalloc((nparam + 1) * sizeof *ap);
+       ap = newparam = ckmalloc((argc + 1) * sizeof *ap);
        while (*argv) {
                *ap++ = savestr(*argv++);
        }
        *ap = NULL;
        freeparam(&shellparam);
        shellparam.malloc = 1;
        while (*argv) {
                *ap++ = savestr(*argv++);
        }
        *ap = NULL;
        freeparam(&shellparam);
        shellparam.malloc = 1;
-       shellparam.nparam = nparam;
+       shellparam.nparam = argc;
        shellparam.p = newparam;
        shellparam.optp = NULL;
        shellparam.reset = 1;
        shellparam.p = newparam;
        shellparam.optp = NULL;
        shellparam.reset = 1;
@@ -361,8 +370,7 @@ freeparam(struct shparam *param)
 int
 shiftcmd(int argc, char **argv)
 {
 int
 shiftcmd(int argc, char **argv)
 {
-       int n;
-       char **ap1, **ap2;
+       int i, n;
 
        n = 1;
        if (argc > 1)
 
        n = 1;
        if (argc > 1)
@@ -371,12 +379,11 @@ shiftcmd(int argc, char **argv)
                return 1;
        INTOFF;
        shellparam.nparam -= n;
                return 1;
        INTOFF;
        shellparam.nparam -= n;
-       for (ap1 = shellparam.p ; --n >= 0 ; ap1++) {
-               if (shellparam.malloc)
-                       ckfree(*ap1);
-       }
-       ap2 = shellparam.p;
-       while ((*ap2++ = *ap1++) != NULL);
+       if (shellparam.malloc)
+               for (i = 0; i < n; i++)
+                       ckfree(shellparam.p[i]);
+       memmove(shellparam.p, shellparam.p + n,
+           (shellparam.nparam + 1) * sizeof(shellparam.p[0]));
        shellparam.reset = 1;
        INTON;
        return 0;
        shellparam.reset = 1;
        INTON;
        return 0;
@@ -397,7 +404,7 @@ setcmd(int argc, char **argv)
        options(0);
        optschanged();
        if (*argptr != NULL) {
        options(0);
        optschanged();
        if (*argptr != NULL) {
-               setparam(argptr);
+               setparam(argc - (argptr - argv), argptr);
        }
        INTON;
        return 0;
        }
        INTON;
        return 0;
index 2048a354b6e5e065616ed5e56ff43b88387e8dfc..8910df9a72cbb1ed12743a233fc8cc691785cf5d 100644 (file)
@@ -30,7 +30,7 @@
  * SUCH DAMAGE.
  *
  *     @(#)options.h   8.2 (Berkeley) 5/4/95
  * SUCH DAMAGE.
  *
  *     @(#)options.h   8.2 (Berkeley) 5/4/95
- * $FreeBSD$
+ * $FreeBSD: head/bin/sh/options.h 294348 2016-01-19 22:41:26Z jilles $
  */
 
 struct shparam {
  */
 
 struct shparam {
@@ -45,57 +45,57 @@ struct shparam {
 
 
 
 
 
 
-#define eflag optlist[0].val
-#define fflag optlist[1].val
-#define Iflag optlist[2].val
-#define iflag optlist[3].val
-#define mflag optlist[4].val
-#define nflag optlist[5].val
-#define sflag optlist[6].val
-#define xflag optlist[7].val
-#define vflag optlist[8].val
-#define Vflag optlist[9].val
-#define        Eflag optlist[10].val
-#define        Cflag optlist[11].val
-#define        aflag optlist[12].val
-#define        bflag optlist[13].val
-#define        uflag optlist[14].val
-#define        privileged optlist[15].val
-#define        Tflag optlist[16].val
-#define        Pflag optlist[17].val
-#define        hflag optlist[18].val
+#define eflag optval[0]
+#define fflag optval[1]
+#define Iflag optval[2]
+#define iflag optval[3]
+#define mflag optval[4]
+#define nflag optval[5]
+#define sflag optval[6]
+#define xflag optval[7]
+#define vflag optval[8]
+#define Vflag optval[9]
+#define        Eflag optval[10]
+#define        Cflag optval[11]
+#define        aflag optval[12]
+#define        bflag optval[13]
+#define        uflag optval[14]
+#define        privileged optval[15]
+#define        Tflag optval[16]
+#define        Pflag optval[17]
+#define        hflag optval[18]
+#define        nologflag optval[19]
 
 
-#define NOPTS  19
+#define NSHORTOPTS     19
+#define NOPTS          20
 
 
-struct optent {
-       const char *name;
-       const char letter;
-       char val;
-};
-
-extern struct optent optlist[NOPTS];
+extern char optval[NOPTS];
+extern const char optletter[NSHORTOPTS];
 #ifdef DEFINE_OPTIONS
 #ifdef DEFINE_OPTIONS
-struct optent optlist[NOPTS] = {
-       { "errexit",    'e',    0 },
-       { "noglob",     'f',    0 },
-       { "ignoreeof",  'I',    0 },
-       { "interactive",'i',    0 },
-       { "monitor",    'm',    0 },
-       { "noexec",     'n',    0 },
-       { "stdin",      's',    0 },
-       { "xtrace",     'x',    0 },
-       { "verbose",    'v',    0 },
-       { "vi",         'V',    0 },
-       { "emacs",      'E',    0 },
-       { "noclobber",  'C',    0 },
-       { "allexport",  'a',    0 },
-       { "notify",     'b',    0 },
-       { "nounset",    'u',    0 },
-       { "privileged", 'p',    0 },
-       { "trapsasync", 'T',    0 },
-       { "physical",   'P',    0 },
-       { "trackall",   'h',    0 },
-};
+char optval[NOPTS];
+const char optletter[NSHORTOPTS] = "efIimnsxvVECabupTPh";
+static const unsigned char optname[] =
+       "\007errexit"
+       "\006noglob"
+       "\011ignoreeof"
+       "\013interactive"
+       "\007monitor"
+       "\006noexec"
+       "\005stdin"
+       "\006xtrace"
+       "\007verbose"
+       "\002vi"
+       "\005emacs"
+       "\011noclobber"
+       "\011allexport"
+       "\006notify"
+       "\007nounset"
+       "\012privileged"
+       "\012trapsasync"
+       "\010physical"
+       "\010trackall"
+       "\005nolog"
+;
 #endif
 
 
 #endif
 
 
@@ -108,7 +108,6 @@ extern char *nextopt_optptr;        /* used by nextopt */
 
 void procargs(int, char **);
 void optschanged(void);
 
 void procargs(int, char **);
 void optschanged(void);
-void setparam(char **);
 void freeparam(struct shparam *);
 int nextopt(const char *);
 void getoptsreset(const char *);
 void freeparam(struct shparam *);
 int nextopt(const char *);
 void getoptsreset(const char *);
index 39b722fdba234adc583429ca248644f9971e5d60..7718603528f1e4b4e108b68a74874dea1328f939 100644 (file)
@@ -36,7 +36,7 @@ static char sccsid[] = "@(#)output.c  8.2 (Berkeley) 5/4/95";
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/bin/sh/output.c 275766 2014-12-14 16:26:19Z jilles $");
 
 /*
  * Shell output routines.  We use our own output routines because:
 
 /*
  * Shell output routines.  We use our own output routines because:
index 51974d8d0450d3f9f1bd95eef87966bce3aea0e6..227db2dc9eb15469bae5072c20ba3d2141e0c14a 100644 (file)
@@ -30,7 +30,7 @@
  * SUCH DAMAGE.
  *
  *     @(#)output.h    8.2 (Berkeley) 5/4/95
  * SUCH DAMAGE.
  *
  *     @(#)output.h    8.2 (Berkeley) 5/4/95
- * $FreeBSD$
+ * $FreeBSD: head/bin/sh/output.h 244162 2012-12-12 22:01:10Z jilles $
  */
 
 #ifndef OUTPUT_INCL
  */
 
 #ifndef OUTPUT_INCL
index 2bba84eb913663e7bf5762ef0f4b3a435b971aa3..3dc0d15a2e57f3306e1a6004fe54df03c9dc8f50 100644 (file)
@@ -36,7 +36,7 @@ static char sccsid[] = "@(#)parser.c  8.7 (Berkeley) 5/16/95";
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/bin/sh/parser.c 301139 2016-06-01 16:56:29Z truckman $");
 
 #include <stdlib.h>
 #include <unistd.h>
 
 #include <stdlib.h>
 #include <unistd.h>
@@ -106,6 +106,8 @@ static int startlinno;              /* line # where last token started */
 static int funclinno;          /* line # where the current function started */
 static struct parser_temp *parser_temp;
 
 static int funclinno;          /* line # where the current function started */
 static struct parser_temp *parser_temp;
 
+#define NOEOFMARK ((const char *)&heredoclist)
+
 
 static union node *list(int);
 static union node *andor(void);
 
 static union node *list(int);
 static union node *andor(void);
@@ -229,6 +231,39 @@ parsecmd(int interact)
 }
 
 
 }
 
 
+/*
+ * Read and parse words for wordexp.
+ * Returns a list of NARG nodes; NULL if there are no words.
+ */
+union node *
+parsewordexp(void)
+{
+       union node *n, *first = NULL, **pnext;
+       int t;
+
+       /* This assumes the parser is not re-entered,
+        * which could happen if we add command substitution on PS1/PS2.
+        */
+       parser_temp_free_all();
+       heredoclist = NULL;
+
+       tokpushback = 0;
+       checkkwd = 0;
+       doprompt = 0;
+       setprompt(0);
+       needprompt = 0;
+       pnext = &first;
+       while ((t = readtoken()) != TEOF) {
+               if (t != TWORD)
+                       synexpect(TWORD);
+               n = makename();
+               *pnext = n;
+               pnext = &n->narg.next;
+       }
+       return first;
+}
+
+
 static union node *
 list(int nlflag)
 {
 static union node *
 list(int nlflag)
 {
@@ -593,7 +628,7 @@ simplecmd(union node **rpp, union node *redir)
 
        /* If we don't have any redirections already, then we must reset */
        /* rpp to be the address of the local redir variable.  */
 
        /* If we don't have any redirections already, then we must reset */
        /* rpp to be the address of the local redir variable.  */
-       if (redir == 0)
+       if (redir == NULL)
                rpp = &redir;
 
        args = NULL;
                rpp = &redir;
 
        args = NULL;
@@ -972,6 +1007,10 @@ checkend(int c, const char *eofmark, int striptabs)
                        pungetc();
                        pushstring(eofmark + 1, q - (eofmark + 1), NULL);
                }
                        pungetc();
                        pushstring(eofmark + 1, q - (eofmark + 1), NULL);
                }
+       } else if (c == '\n' && *eofmark == '\0') {
+               c = PEOF;
+               plinno++;
+               needprompt = doprompt;
        }
        return (c);
 }
        }
        return (c);
 }
@@ -1195,7 +1234,8 @@ parsebackq(char *out, struct nodelist **pbqlist,
 static char *
 readcstyleesc(char *out)
 {
 static char *
 readcstyleesc(char *out)
 {
-       int c, v, i, n;
+       int c, vc, i, n;
+       unsigned int v;
 
        c = pgetc();
        switch (c) {
 
        c = pgetc();
        switch (c) {
@@ -1310,12 +1350,12 @@ readcstyleesc(char *out)
        default:
                  synerror("Bad escape sequence");
        }
        default:
                  synerror("Bad escape sequence");
        }
-       v = (char)v;
+       vc = (char)v;
        /*
         * We can't handle NUL bytes.
         * POSIX says we should skip till the closing quote.
         */
        /*
         * We can't handle NUL bytes.
         * POSIX says we should skip till the closing quote.
         */
-       if (v == '\0') {
+       if (vc == '\0') {
                while ((c = pgetc()) != '\'') {
                        if (c == '\\')
                                c = pgetc();
                while ((c = pgetc()) != '\'') {
                        if (c == '\\')
                                c = pgetc();
@@ -1332,9 +1372,9 @@ readcstyleesc(char *out)
                pungetc();
                return out;
        }
                pungetc();
                return out;
        }
-       if (SQSYNTAX[v] == CCTL)
+       if (SQSYNTAX[vc] == CCTL)
                USTPUTC(CTLESC, out);
                USTPUTC(CTLESC, out);
-       USTPUTC(v, out);
+       USTPUTC(vc, out);
        return out;
 }
 
        return out;
 }
 
@@ -1382,7 +1422,7 @@ readtoken1(int firstc, char const *initialsyntax, const char *eofmark,
 
        STARTSTACKSTR(out);
        loop: { /* for each line, until end of word */
 
        STARTSTACKSTR(out);
        loop: { /* for each line, until end of word */
-               if (eofmark)
+               if (eofmark && eofmark != NOEOFMARK)
                        /* set c to PEOF if at end of here document */
                        c = checkend(c, eofmark, striptabs);
                for (;;) {      /* until end of line or end of word */
                        /* set c to PEOF if at end of here document */
                        c = checkend(c, eofmark, striptabs);
                for (;;) {      /* until end of line or end of word */
@@ -1570,13 +1610,11 @@ endword:
  */
 
 parsesub: {
  */
 
 parsesub: {
-       char buf[10];
        int subtype;
        int typeloc;
        int flags;
        char *p;
        static const char types[] = "}-+?=";
        int subtype;
        int typeloc;
        int flags;
        char *p;
        static const char types[] = "}-+?=";
-       int bracketed_name = 0; /* used to handle ${[0-9]*} variables */
        int linno;
        int length;
        int c1;
        int linno;
        int length;
        int c1;
@@ -1600,7 +1638,6 @@ parsesub: {
                subtype = VSNORMAL;
                flags = 0;
                if (c == '{') {
                subtype = VSNORMAL;
                flags = 0;
                if (c == '{') {
-                       bracketed_name = 1;
                        c = pgetc_linecont();
                        subtype = 0;
                }
                        c = pgetc_linecont();
                        subtype = 0;
                }
@@ -1616,22 +1653,25 @@ varname:
                            strncmp(out - length, "LINENO", length) == 0) {
                                /* Replace the variable name with the
                                 * current line number. */
                            strncmp(out - length, "LINENO", length) == 0) {
                                /* Replace the variable name with the
                                 * current line number. */
+                               STADJUST(-6, out);
+                               CHECKSTRSPACE(11, out);
                                linno = plinno;
                                if (funclinno != 0)
                                        linno -= funclinno - 1;
                                linno = plinno;
                                if (funclinno != 0)
                                        linno -= funclinno - 1;
-                               snprintf(buf, sizeof(buf), "%d", linno);
-                               STADJUST(-6, out);
-                               STPUTS(buf, out);
+                               length = snprintf(out, 11, "%d", linno);
+                               if (length > 10)
+                                       length = 10;
+                               out += length;
                                flags |= VSLINENO;
                        }
                } else if (is_digit(c)) {
                                flags |= VSLINENO;
                        }
                } else if (is_digit(c)) {
-                       if (bracketed_name) {
+                       if (subtype != VSNORMAL) {
                                do {
                                        STPUTC(c, out);
                                        c = pgetc_linecont();
                                } while (is_digit(c));
                        } else {
                                do {
                                        STPUTC(c, out);
                                        c = pgetc_linecont();
                                } while (is_digit(c));
                        } else {
-                               STPUTC(c, out);
+                               USTPUTC(c, out);
                                c = pgetc_linecont();
                        }
                } else if (is_special(c)) {
                                c = pgetc_linecont();
                        }
                } else if (is_special(c)) {
@@ -1661,7 +1701,7 @@ varname:
                                pungetc();
                        else if (c == '\n' || c == PEOF)
                                synerror("Unexpected end of line in substitution");
                                pungetc();
                        else if (c == '\n' || c == PEOF)
                                synerror("Unexpected end of line in substitution");
-                       else
+                       else if (BASESYNTAX[c] != CCTL)
                                USTPUTC(c, out);
                }
                if (subtype == 0) {
                                USTPUTC(c, out);
                }
                if (subtype == 0) {
@@ -1677,7 +1717,8 @@ varname:
                                                synerror("Unexpected end of line in substitution");
                                        if (flags == VSNUL)
                                                STPUTC(':', out);
                                                synerror("Unexpected end of line in substitution");
                                        if (flags == VSNUL)
                                                STPUTC(':', out);
-                                       STPUTC(c, out);
+                                       if (BASESYNTAX[c] != CCTL)
+                                               STPUTC(c, out);
                                        subtype = VSERROR;
                                } else
                                        subtype = p - types + VSNORMAL;
                                        subtype = VSERROR;
                                } else
                                        subtype = p - types + VSNORMAL;
@@ -1889,6 +1930,8 @@ static void
 setprompt(int which)
 {
        whichprompt = which;
 setprompt(int which)
 {
        whichprompt = which;
+       if (which == 0)
+               return;
 
 #ifndef NO_HISTORY
        if (!el)
 
 #ifndef NO_HISTORY
        if (!el)
@@ -1955,7 +1998,7 @@ getprompt(void *unused __unused)
        /*
         * Format prompt string.
         */
        /*
         * Format prompt string.
         */
-       for (i = 0; (i < 127) && (*fmt != '\0'); i++, fmt++)
+       for (i = 0; (i < PROMPTLEN - 1) && (*fmt != '\0'); i++, fmt++)
                if (*fmt == '\\')
                        switch (*++fmt) {
 
                if (*fmt == '\\')
                        switch (*++fmt) {
 
@@ -1968,11 +2011,13 @@ getprompt(void *unused __unused)
                        case 'h':
                        case 'H':
                                ps[i] = '\0';
                        case 'h':
                        case 'H':
                                ps[i] = '\0';
-                               gethostname(&ps[i], PROMPTLEN - i);
+                               gethostname(&ps[i], PROMPTLEN - i - 1);
+                               ps[PROMPTLEN - 1] = '\0';
                                /* Skip to end of hostname. */
                                trim = (*fmt == 'h') ? '.' : '\0';
                                /* Skip to end of hostname. */
                                trim = (*fmt == 'h') ? '.' : '\0';
-                               while ((ps[i+1] != '\0') && (ps[i+1] != trim))
+                               while ((ps[i] != '\0') && (ps[i] != trim))
                                        i++;
                                        i++;
+                               --i;
                                break;
 
                                /*
                                break;
 
                                /*
@@ -1984,7 +2029,7 @@ getprompt(void *unused __unused)
                        case 'W':
                        case 'w':
                                pwd = lookupvar("PWD");
                        case 'W':
                        case 'w':
                                pwd = lookupvar("PWD");
-                               if (pwd == NULL)
+                               if (pwd == NULL || *pwd == '\0')
                                        pwd = "?";
                                if (*fmt == 'W' &&
                                    *pwd == '/' && pwd[1] != '\0')
                                        pwd = "?";
                                if (*fmt == 'W' &&
                                    *pwd == '/' && pwd[1] != '\0')
@@ -2017,8 +2062,9 @@ getprompt(void *unused __unused)
                                 * Emit unrecognized formats verbatim.
                                 */
                        default:
                                 * Emit unrecognized formats verbatim.
                                 */
                        default:
-                               ps[i++] = '\\';
-                               ps[i] = *fmt;
+                               ps[i] = '\\';
+                               if (i < PROMPTLEN - 2)
+                                       ps[++i] = *fmt;
                                break;
                        }
                else
                                break;
                        }
                else
@@ -2044,7 +2090,7 @@ expandstr(const char *ps)
                parser_temp = NULL;
                setinputstring(ps, 1);
                doprompt = 0;
                parser_temp = NULL;
                setinputstring(ps, 1);
                doprompt = 0;
-               readtoken1(pgetc(), DQSYNTAX, "", 0);
+               readtoken1(pgetc(), DQSYNTAX, NOEOFMARK, 0);
                if (backquotelist != NULL)
                        error("Command substitution not allowed here");
 
                if (backquotelist != NULL)
                        error("Command substitution not allowed here");
 
index 5982594391244e4777229a7e4db3ffd6b9d7e28c..0a42f4eeaff9e47badb82124e24474e0398c19d5 100644 (file)
@@ -30,7 +30,7 @@
  * SUCH DAMAGE.
  *
  *     @(#)parser.h    8.3 (Berkeley) 5/4/95
  * SUCH DAMAGE.
  *
  *     @(#)parser.h    8.3 (Berkeley) 5/4/95
- * $FreeBSD$
+ * $FreeBSD: head/bin/sh/parser.h 288430 2015-09-30 21:32:29Z jilles $
  */
 
 /* control characters in argument strings */
  */
 
 /* control characters in argument strings */
@@ -76,6 +76,7 @@ extern const char *const parsekwd[];
 
 
 union node *parsecmd(int);
 
 
 union node *parsecmd(int);
+union node *parsewordexp(void);
 void forcealias(void);
 void fixredir(union node *, const char *, int);
 int goodname(const char *);
 void forcealias(void);
 void fixredir(union node *, const char *, int);
 int goodname(const char *);
index 95d3238daf1b24fd1258b81cc6c25239cd4e9586..d0b4535b606f3c75a7a0b860dbc9bd443203fec9 100644 (file)
@@ -36,7 +36,7 @@ static char sccsid[] = "@(#)redir.c   8.2 (Berkeley) 5/4/95";
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/bin/sh/redir.c 295085 2016-01-30 21:21:25Z jilles $");
 
 #include <sys/types.h>
 #include <sys/stat.h>
 
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -70,6 +70,7 @@ struct redirtab {
        struct redirtab *next;
        int renamed[10];
        int fd0_redirected;
        struct redirtab *next;
        int renamed[10];
        int fd0_redirected;
+       unsigned int empty_redirs;
 };
 
 
 };
 
 
@@ -82,6 +83,9 @@ static struct redirtab *redirlist;
 */
 static int fd0_redirected = 0;
 
 */
 static int fd0_redirected = 0;
 
+/* Number of redirtabs that have not been allocated. */
+static unsigned int empty_redirs = 0;
+
 static void openredirect(union node *, char[10 ]);
 static int openhere(union node *);
 
 static void openredirect(union node *, char[10 ]);
 static int openhere(union node *);
 
@@ -115,12 +119,17 @@ redirect(union node *redir, int flags)
                memory[i] = 0;
        memory[1] = flags & REDIR_BACKQ;
        if (flags & REDIR_PUSH) {
                memory[i] = 0;
        memory[1] = flags & REDIR_BACKQ;
        if (flags & REDIR_PUSH) {
-               sv = ckmalloc(sizeof (struct redirtab));
-               for (i = 0 ; i < 10 ; i++)
-                       sv->renamed[i] = EMPTY;
-               sv->fd0_redirected = fd0_redirected;
-               sv->next = redirlist;
-               redirlist = sv;
+               empty_redirs++;
+               if (redir != NULL) {
+                       sv = ckmalloc(sizeof (struct redirtab));
+                       for (i = 0 ; i < 10 ; i++)
+                               sv->renamed[i] = EMPTY;
+                       sv->fd0_redirected = fd0_redirected;
+                       sv->empty_redirs = empty_redirs - 1;
+                       sv->next = redirlist;
+                       redirlist = sv;
+                       empty_redirs = 0;
+               }
        }
        for (n = redir ; n ; n = n->nfile.next) {
                fd = n->nfile.fd;
        }
        for (n = redir ; n ; n = n->nfile.next) {
                fd = n->nfile.fd;
@@ -303,6 +312,12 @@ popredir(void)
        struct redirtab *rp = redirlist;
        int i;
 
        struct redirtab *rp = redirlist;
        int i;
 
+       INTOFF;
+       if (empty_redirs > 0) {
+               empty_redirs--;
+               INTON;
+               return;
+       }
        for (i = 0 ; i < 10 ; i++) {
                if (rp->renamed[i] != EMPTY) {
                        if (rp->renamed[i] >= 0) {
        for (i = 0 ; i < 10 ; i++) {
                if (rp->renamed[i] != EMPTY) {
                        if (rp->renamed[i] >= 0) {
@@ -313,8 +328,8 @@ popredir(void)
                        }
                }
        }
                        }
                }
        }
-       INTOFF;
        fd0_redirected = rp->fd0_redirected;
        fd0_redirected = rp->fd0_redirected;
+       empty_redirs = rp->empty_redirs;
        redirlist = rp->next;
        ckfree(rp);
        INTON;
        redirlist = rp->next;
        ckfree(rp);
        INTON;
index ad44c4eddd8c8a33cf6e071ff37f4b5a2960f0b5..7146dd1f55ac7bf13af5e5865c42445bc5c81b8f 100644 (file)
@@ -30,7 +30,7 @@
  * SUCH DAMAGE.
  *
  *     @(#)redir.h     8.2 (Berkeley) 5/4/95
  * SUCH DAMAGE.
  *
  *     @(#)redir.h     8.2 (Berkeley) 5/4/95
- * $FreeBSD$
+ * $FreeBSD: head/bin/sh/redir.h 254426 2013-08-16 20:24:41Z jilles $
  */
 
 /* flags passed to redirect */
  */
 
 /* flags passed to redirect */
diff --git a/sh/sh.1 b/sh/sh.1
index e193d5da03c682a8d282c6d579b99b4e1f4a0d14..cbfd925785d6201931a41ec097fae5fed531420d 100644 (file)
--- a/sh/sh.1
+++ b/sh/sh.1
@@ -30,9 +30,9 @@
 .\" SUCH DAMAGE.
 .\"
 .\"    from: @(#)sh.1  8.6 (Berkeley) 5/4/95
 .\" SUCH DAMAGE.
 .\"
 .\"    from: @(#)sh.1  8.6 (Berkeley) 5/4/95
-.\" $FreeBSD$
+.\" $FreeBSD: head/bin/sh/sh.1 306843 2016-10-08 13:40:12Z jilles $
 .\"
 .\"
-.Dd July 11, 2015
+.Dd October 8, 2016
 .Dt SH 1
 .Os
 .Sh NAME
 .Dt SH 1
 .Os
 .Sh NAME
@@ -343,6 +343,11 @@ Write each command
 variable subjected to parameter expansion and arithmetic expansion)
 to standard error before it is executed.
 Useful for debugging.
 variable subjected to parameter expansion and arithmetic expansion)
 to standard error before it is executed.
 Useful for debugging.
+.It nolog
+Another do-nothing option for
+.Tn POSIX
+compliance.
+It only has a long name.
 .El
 .Pp
 The
 .El
 .Pp
 The
@@ -1173,7 +1178,9 @@ The only special parameter that can be made local is
 .Ql - .
 Making
 .Ql -
 .Ql - .
 Making
 .Ql -
-local causes any shell options that are
+local causes any shell options
+(including those that only have long names)
+that are
 changed via the
 .Ic set
 command inside the function to be
 changed via the
 .Ic set
 command inside the function to be
@@ -1342,13 +1349,13 @@ used in tilde expansion and as a default directory for the
 built-in.
 .It Va IFS
 Input Field Separators.
 built-in.
 .It Va IFS
 Input Field Separators.
-The default value is
+This is initialized at startup to
 .Aq space ,
 .Aq tab ,
 and
 .Aq newline
 in that order.
 .Aq space ,
 .Aq tab ,
 and
 .Aq newline
 in that order.
-This default also applies if
+This value also applies if
 .Va IFS
 is unset, but not if it is set to the empty string.
 See the
 .Va IFS
 is unset, but not if it is set to the empty string.
 See the
@@ -1396,9 +1403,9 @@ may include any of the following formatting sequences,
 which are replaced by the given information:
 .Bl -tag -width indent
 .It Li \eH
 which are replaced by the given information:
 .Bl -tag -width indent
 .It Li \eH
-The local hostname.
+This system's fully-qualified hostname (FQDN).
 .It Li \eh
 .It Li \eh
-The fully-qualified hostname.
+This system's hostname.
 .It Li \eW
 The final component of the current working directory.
 .It Li \ew
 .It Li \eW
 The final component of the current working directory.
 .It Li \ew
@@ -1945,13 +1952,20 @@ Execute the specified built-in command,
 This is useful when the user wishes to override a shell function
 with the same name as a built-in command.
 .It Ic cd Oo Fl L | P Oc Oo Fl e Oc Op Ar directory
 This is useful when the user wishes to override a shell function
 with the same name as a built-in command.
 .It Ic cd Oo Fl L | P Oc Oo Fl e Oc Op Ar directory
+.It Ic cd Fl
 Switch to the specified
 .Ar directory ,
 Switch to the specified
 .Ar directory ,
-or to the directory specified in the
+to the directory specified in the
 .Va HOME
 environment variable if no
 .Ar directory
 .Va HOME
 environment variable if no
 .Ar directory
-is specified.
+is specified or
+to the directory specified in the
+.Va OLDPWD
+environment variable if
+.Ar directory
+is
+.Fl .
 If
 .Ar directory
 does not begin with
 If
 .Ar directory
 does not begin with
@@ -1975,10 +1989,12 @@ the
 .Ic cd
 command will print out the name of the directory
 that it actually switched to
 .Ic cd
 command will print out the name of the directory
 that it actually switched to
-if this is different from the name that the user gave.
-These may be different either because the
+if the
 .Va CDPATH
 .Va CDPATH
-mechanism was used or because a symbolic link was crossed.
+mechanism was used or if
+.Ar directory
+was
+.Fl .
 .Pp
 If the
 .Fl P
 .Pp
 If the
 .Fl P
@@ -2599,7 +2615,7 @@ and not found.
 For aliases the alias expansion is printed;
 for commands and tracked aliases
 the complete pathname of the command is printed.
 For aliases the alias expansion is printed;
 for commands and tracked aliases
 the complete pathname of the command is printed.
-.It Ic ulimit Oo Fl HSabcdfklmnpstuvw Oc Op Ar limit
+.It Ic ulimit Oo Fl HSabcdfklmnopstuvw Oc Op Ar limit
 Set or display resource limits (see
 .Xr getrlimit 2 ) .
 If
 Set or display resource limits (see
 .Xr getrlimit 2 ) .
 If
@@ -2658,6 +2674,11 @@ kilobytes.
 The maximal resident set size of a process, in kilobytes.
 .It Fl n Ar nofiles
 The maximal number of descriptors that could be opened by a process.
 The maximal resident set size of a process, in kilobytes.
 .It Fl n Ar nofiles
 The maximal number of descriptors that could be opened by a process.
+.It Fl o Ar umtxp
+The maximal number of process-shared locks
+(see
+.Xr pthread 3 )
+for this user ID.
 .It Fl p Ar pseudoterminals
 The maximal number of pseudo-terminals for this user ID.
 .It Fl s Ar stacksize
 .It Fl p Ar pseudoterminals
 The maximal number of pseudo-terminals for this user ID.
 .It Fl s Ar stacksize
@@ -2767,6 +2788,10 @@ Initialization file for interactive shells.
 Locale settings.
 These are inherited by children of the shell,
 and is used in a limited manner by the shell itself.
 Locale settings.
 These are inherited by children of the shell,
 and is used in a limited manner by the shell itself.
+.It Ev OLDPWD
+The previous current directory.
+This is used and updated by
+.Ic cd .
 .It Ev PWD
 An absolute pathname for the current directory,
 possibly containing symbolic links.
 .It Ev PWD
 An absolute pathname for the current directory,
 possibly containing symbolic links.
index f1fb688ede1800407b29eb0cf4ce7a0455fca184..f023fcafae2daccfe6ab3939600b504b298a9fd1 100644 (file)
@@ -2,17 +2,18 @@
                <key>OpenSourceProject</key>
                <string>sh</string>
                <key>OpenSourceVersion</key>
                <key>OpenSourceProject</key>
                <string>sh</string>
                <key>OpenSourceVersion</key>
-               <string>2015-07-11</string>
+               <string>2016-10-08</string>
                <key>OpenSourceWebsiteURL</key>
                <string>http://svnweb.freebsd.org/base/head/bin/sh/</string>
                <key>OpenSourceSCM</key>
                <string>svn co http://svn.freebsd.org/base/head/bin/sh/</string>
                <key>OpenSourceImportDate</key>
                <key>OpenSourceWebsiteURL</key>
                <string>http://svnweb.freebsd.org/base/head/bin/sh/</string>
                <key>OpenSourceSCM</key>
                <string>svn co http://svn.freebsd.org/base/head/bin/sh/</string>
                <key>OpenSourceImportDate</key>
-               <string>2015-08-13</string>
+               <string>2016-10-27</string>
                <key>OpenSourceModifications</key>
                <array>
                    <string>exec.c: eaccess</string>
                    <string>input.c: remove multiple definition</string>
                <key>OpenSourceModifications</key>
                <array>
                    <string>exec.c: eaccess</string>
                    <string>input.c: remove multiple definition</string>
+                   <string>input.c: strchrnul</string>
                    <string>miscbltin.c: warning fix</string>
                    <string>mknodes.c: __printf0like</string>
                    <string>trap.c: sys_nsig</string>
                    <string>miscbltin.c: warning fix</string>
                    <string>mknodes.c: __printf0like</string>
                    <string>trap.c: sys_nsig</string>
index 679efc7b16191def63100d0698df1b4a63737a4d..add2bd8769b0d670c46f4286da6458aefdd23e11 100644 (file)
@@ -30,7 +30,7 @@
  * SUCH DAMAGE.
  *
  *     @(#)shell.h     8.2 (Berkeley) 5/4/95
  * SUCH DAMAGE.
  *
  *     @(#)shell.h     8.2 (Berkeley) 5/4/95
- * $FreeBSD$
+ * $FreeBSD: head/bin/sh/shell.h 253658 2013-07-25 19:48:15Z jilles $
  */
 
 #ifndef SHELL_H_
  */
 
 #ifndef SHELL_H_
index db18ae9701b399d29bab9bc33ea039757eeb37f2..0e8cf433d4db48b67ff9ed055d792e0b049ed438 100644 (file)
--- a/sh/show.c
+++ b/sh/show.c
@@ -36,7 +36,7 @@ static char sccsid[] = "@(#)show.c    8.3 (Berkeley) 5/4/95";
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/bin/sh/show.c 258776 2013-11-30 21:27:11Z jilles $");
 
 #include <fcntl.h>
 #include <stdio.h>
 
 #include <fcntl.h>
 #include <stdio.h>
index 4528fb19a41c94b8395456beab80a92aea287bc2..d9b16669ffa29443fcce528577b8311eb0aef324 100644 (file)
--- a/sh/show.h
+++ b/sh/show.h
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  *
  *     @(#)show.h      1.1 (Berkeley) 5/4/95
  * SUCH DAMAGE.
  *
  *     @(#)show.h      1.1 (Berkeley) 5/4/95
- * $FreeBSD$
+ * $FreeBSD: head/bin/sh/show.h 200956 2009-12-24 18:41:14Z jilles $
  */
 
 void showtree(union node *);
  */
 
 void showtree(union node *);
index c092962ae30349e912331785d047db71556447c6..27932f2dfbc2b7251bb10d294b77a05d8f7bc3e0 100644 (file)
@@ -1,9 +1,7 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/Makefile 299094 2016-05-04 23:20:53Z ngie $
 
 .include <bsd.own.mk>
 
 
 .include <bsd.own.mk>
 
-TESTSDIR=      ${TESTSBASE}/bin/sh
-
 TESTS_SUBDIRS+=        builtins
 TESTS_SUBDIRS+=        errors
 TESTS_SUBDIRS+=        execution
 TESTS_SUBDIRS+=        builtins
 TESTS_SUBDIRS+=        errors
 TESTS_SUBDIRS+=        execution
diff --git a/sh/tests/Makefile.depend b/sh/tests/Makefile.depend
new file mode 100644 (file)
index 0000000..9ff4aed
--- /dev/null
@@ -0,0 +1,11 @@
+# $FreeBSD: head/bin/sh/tests/Makefile.depend 296587 2016-03-09 22:46:01Z bdrewery $
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
index ad39aacf1be5a366453819f30c670309eff1b6e6..0e6258f4d0f400755879d8782eeb6b90905e071a 100644 (file)
@@ -1,4 +1,6 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/Makefile 305305 2016-09-02 21:13:46Z jilles $
+
+PACKAGE=       tests
 
 .include <src.opts.mk>
 
 
 .include <src.opts.mk>
 
@@ -7,161 +9,173 @@ TESTSDIR=   ${TESTSBASE}/bin/sh/${.CURDIR:T}
 .PATH: ${.CURDIR:H}
 ATF_TESTS_SH=  functional_test
 
 .PATH: ${.CURDIR:H}
 ATF_TESTS_SH=  functional_test
 
-FILESDIR=      ${TESTSDIR}
-
-FILES=         alias.0 alias.0.stdout
-FILES+=                alias.1 alias.1.stderr
-FILES+=                alias3.0 alias3.0.stdout
-FILES+=                alias4.0
-FILES+=                break1.0
-FILES+=                break2.0 break2.0.stdout
-FILES+=                break3.0
-FILES+=                break4.4
-FILES+=                break5.4
-FILES+=                break6.0
-FILES+=                builtin1.0
-FILES+=                case1.0
-FILES+=                case2.0
-FILES+=                case3.0
-FILES+=                case4.0
-FILES+=                case5.0
-FILES+=                case6.0
-FILES+=                case7.0
-FILES+=                case8.0
-FILES+=                case9.0
-FILES+=                case10.0
-FILES+=                case11.0
-FILES+=                case12.0
-FILES+=                case13.0
-FILES+=                case14.0
-FILES+=                case15.0
-FILES+=                case16.0
-FILES+=                case17.0
-FILES+=                case18.0
-FILES+=                case19.0
-FILES+=                cd1.0
-FILES+=                cd2.0
-FILES+=                cd3.0
-FILES+=                cd4.0
-FILES+=                cd5.0
-FILES+=                cd6.0
-FILES+=                cd7.0
-FILES+=                cd8.0
-FILES+=                command1.0
-FILES+=                command2.0
-FILES+=                command3.0
-FILES+=                command3.0.stdout
-FILES+=                command4.0
-FILES+=                command5.0
-FILES+=                command5.0.stdout
-FILES+=                command6.0
-FILES+=                command6.0.stdout
-FILES+=                command7.0
-FILES+=                command8.0
-FILES+=                command9.0
-FILES+=                command10.0
-FILES+=                command11.0
-FILES+=                command12.0
-FILES+=                dot1.0
-FILES+=                dot2.0
-FILES+=                dot3.0
-FILES+=                dot4.0
-FILES+=                eval1.0
-FILES+=                eval2.0
-FILES+=                eval3.0
-FILES+=                eval4.0
-FILES+=                eval5.0
-FILES+=                eval6.0
-FILES+=                eval7.0
-FILES+=                eval8.7
-FILES+=                exec1.0
-FILES+=                exec2.0
-FILES+=                exit1.0
-FILES+=                exit2.8
-FILES+=                exit3.0
-FILES+=                export1.0
-FILES+=                fc1.0
-FILES+=                fc2.0
-FILES+=                for1.0
-FILES+=                for2.0
-FILES+=                for3.0
-FILES+=                getopts1.0 getopts1.0.stdout
-FILES+=                getopts2.0 getopts2.0.stdout
-FILES+=                getopts3.0
-FILES+=                getopts4.0
-FILES+=                getopts5.0
-FILES+=                getopts6.0
-FILES+=                getopts7.0
-FILES+=                getopts8.0 getopts8.0.stdout
-FILES+=                hash1.0 hash1.0.stdout
-FILES+=                hash2.0 hash2.0.stdout
-FILES+=                hash3.0 hash3.0.stdout
-FILES+=                hash4.0
-FILES+=                jobid1.0
-FILES+=                jobid2.0
-FILES+=                kill1.0 kill2.0
-FILES+=                lineno.0 lineno.0.stdout
-FILES+=                lineno2.0
-FILES+=                lineno3.0 lineno3.0.stdout
-FILES+=                local1.0
-FILES+=                local2.0
-FILES+=                local3.0
-FILES+=                local4.0
+${PACKAGE}FILES+=              alias.0 alias.0.stdout
+${PACKAGE}FILES+=              alias.1 alias.1.stderr
+${PACKAGE}FILES+=              alias3.0 alias3.0.stdout
+${PACKAGE}FILES+=              alias4.0
+${PACKAGE}FILES+=              break1.0
+${PACKAGE}FILES+=              break2.0 break2.0.stdout
+${PACKAGE}FILES+=              break3.0
+${PACKAGE}FILES+=              break4.4
+${PACKAGE}FILES+=              break5.4
+${PACKAGE}FILES+=              break6.0
+${PACKAGE}FILES+=              builtin1.0
+${PACKAGE}FILES+=              case1.0
+${PACKAGE}FILES+=              case2.0
+${PACKAGE}FILES+=              case3.0
+${PACKAGE}FILES+=              case4.0
+${PACKAGE}FILES+=              case5.0
+${PACKAGE}FILES+=              case6.0
+${PACKAGE}FILES+=              case7.0
+${PACKAGE}FILES+=              case8.0
+${PACKAGE}FILES+=              case9.0
+${PACKAGE}FILES+=              case10.0
+${PACKAGE}FILES+=              case11.0
+${PACKAGE}FILES+=              case12.0
+${PACKAGE}FILES+=              case13.0
+${PACKAGE}FILES+=              case14.0
+${PACKAGE}FILES+=              case15.0
+${PACKAGE}FILES+=              case16.0
+${PACKAGE}FILES+=              case17.0
+${PACKAGE}FILES+=              case18.0
+${PACKAGE}FILES+=              case19.0
+${PACKAGE}FILES+=              case20.0
+${PACKAGE}FILES+=              cd1.0
+${PACKAGE}FILES+=              cd2.0
+${PACKAGE}FILES+=              cd3.0
+${PACKAGE}FILES+=              cd4.0
+${PACKAGE}FILES+=              cd5.0
+${PACKAGE}FILES+=              cd6.0
+${PACKAGE}FILES+=              cd7.0
+${PACKAGE}FILES+=              cd8.0
+${PACKAGE}FILES+=              cd9.0 cd9.0.stdout
+${PACKAGE}FILES+=              command1.0
+${PACKAGE}FILES+=              command2.0
+${PACKAGE}FILES+=              command3.0
+${PACKAGE}FILES+=              command3.0.stdout
+${PACKAGE}FILES+=              command4.0
+${PACKAGE}FILES+=              command5.0
+${PACKAGE}FILES+=              command5.0.stdout
+${PACKAGE}FILES+=              command6.0
+${PACKAGE}FILES+=              command6.0.stdout
+${PACKAGE}FILES+=              command7.0
+${PACKAGE}FILES+=              command8.0
+${PACKAGE}FILES+=              command9.0
+${PACKAGE}FILES+=              command10.0
+${PACKAGE}FILES+=              command11.0
+${PACKAGE}FILES+=              command12.0
+${PACKAGE}FILES+=              dot1.0
+${PACKAGE}FILES+=              dot2.0
+${PACKAGE}FILES+=              dot3.0
+${PACKAGE}FILES+=              dot4.0
+${PACKAGE}FILES+=              echo1.0
+${PACKAGE}FILES+=              echo2.0
+${PACKAGE}FILES+=              echo3.0
+${PACKAGE}FILES+=              eval1.0
+${PACKAGE}FILES+=              eval2.0
+${PACKAGE}FILES+=              eval3.0
+${PACKAGE}FILES+=              eval4.0
+${PACKAGE}FILES+=              eval5.0
+${PACKAGE}FILES+=              eval6.0
+${PACKAGE}FILES+=              eval7.0
+${PACKAGE}FILES+=              eval8.7
+${PACKAGE}FILES+=              exec1.0
+${PACKAGE}FILES+=              exec2.0
+${PACKAGE}FILES+=              exit1.0
+${PACKAGE}FILES+=              exit2.8
+${PACKAGE}FILES+=              exit3.0
+${PACKAGE}FILES+=              export1.0
+${PACKAGE}FILES+=              fc1.0
+${PACKAGE}FILES+=              fc2.0
+${PACKAGE}FILES+=              for1.0
+${PACKAGE}FILES+=              for2.0
+${PACKAGE}FILES+=              for3.0
+${PACKAGE}FILES+=              getopts1.0 getopts1.0.stdout
+${PACKAGE}FILES+=              getopts2.0 getopts2.0.stdout
+${PACKAGE}FILES+=              getopts3.0
+${PACKAGE}FILES+=              getopts4.0
+${PACKAGE}FILES+=              getopts5.0
+${PACKAGE}FILES+=              getopts6.0
+${PACKAGE}FILES+=              getopts7.0
+${PACKAGE}FILES+=              getopts8.0 getopts8.0.stdout
+${PACKAGE}FILES+=              getopts9.0 getopts9.0.stdout
+${PACKAGE}FILES+=              getopts10.0
+${PACKAGE}FILES+=              hash1.0 hash1.0.stdout
+${PACKAGE}FILES+=              hash2.0 hash2.0.stdout
+${PACKAGE}FILES+=              hash3.0 hash3.0.stdout
+${PACKAGE}FILES+=              hash4.0
+${PACKAGE}FILES+=              jobid1.0
+${PACKAGE}FILES+=              jobid2.0
+${PACKAGE}FILES+=              kill1.0 kill2.0
+${PACKAGE}FILES+=              lineno.0 lineno.0.stdout
+${PACKAGE}FILES+=              lineno2.0
+${PACKAGE}FILES+=              lineno3.0 lineno3.0.stdout
+${PACKAGE}FILES+=              local1.0
+${PACKAGE}FILES+=              local2.0
+${PACKAGE}FILES+=              local3.0
+${PACKAGE}FILES+=              local4.0
+${PACKAGE}FILES+=              local5.0
+${PACKAGE}FILES+=              local6.0
+${PACKAGE}FILES+=              local7.0
 .if ${MK_NLS} != "no"
 .if ${MK_NLS} != "no"
-FILES+=                locale1.0
+${PACKAGE}FILES+=              locale1.0
 .endif
 .endif
-FILES+=                printf1.0
-FILES+=                printf2.0
-FILES+=                printf3.0
-FILES+=                printf4.0
-FILES+=                read1.0 read1.0.stdout
-FILES+=                read2.0
-FILES+=                read3.0 read3.0.stdout
-FILES+=                read4.0 read4.0.stdout
-FILES+=                read5.0
-FILES+=                read6.0
-FILES+=                read7.0
-FILES+=                return1.0
-FILES+=                return2.1
-FILES+=                return3.1
-FILES+=                return4.0
-FILES+=                return5.0
-FILES+=                return6.4
-FILES+=                return7.4
-FILES+=                return8.0
-FILES+=                set1.0
-FILES+=                set2.0
-FILES+=                trap1.0
-FILES+=                trap10.0
-FILES+=                trap11.0
-FILES+=                trap12.0
-FILES+=                trap13.0
-FILES+=                trap14.0
-FILES+=                trap15.0
-FILES+=                trap16.0
-FILES+=                trap2.0
-FILES+=                trap3.0
-FILES+=                trap4.0
-FILES+=                trap5.0
-FILES+=                trap6.0
-FILES+=                trap7.0
-FILES+=                trap8.0
-FILES+=                trap9.0
-FILES+=                type1.0 type1.0.stderr
-FILES+=                type2.0
-FILES+=                type3.0
-FILES+=                unalias.0
-FILES+=                var-assign.0
-FILES+=                var-assign2.0
-FILES+=                wait1.0
-FILES+=                wait2.0
-FILES+=                wait3.0
-FILES+=                wait4.0
-FILES+=                wait5.0
-FILES+=                wait6.0
-FILES+=                wait7.0
-FILES+=                wait8.0
-FILES+=                wait9.127
-FILES+=                wait10.0
+${PACKAGE}FILES+=              printf1.0
+${PACKAGE}FILES+=              printf2.0
+${PACKAGE}FILES+=              printf3.0
+${PACKAGE}FILES+=              printf4.0
+${PACKAGE}FILES+=              read1.0 read1.0.stdout
+${PACKAGE}FILES+=              read2.0
+${PACKAGE}FILES+=              read3.0 read3.0.stdout
+${PACKAGE}FILES+=              read4.0 read4.0.stdout
+${PACKAGE}FILES+=              read5.0
+${PACKAGE}FILES+=              read6.0
+${PACKAGE}FILES+=              read7.0
+${PACKAGE}FILES+=              read8.0
+${PACKAGE}FILES+=              read9.0
+${PACKAGE}FILES+=              return1.0
+${PACKAGE}FILES+=              return2.1
+${PACKAGE}FILES+=              return3.1
+${PACKAGE}FILES+=              return4.0
+${PACKAGE}FILES+=              return5.0
+${PACKAGE}FILES+=              return6.4
+${PACKAGE}FILES+=              return7.4
+${PACKAGE}FILES+=              return8.0
+${PACKAGE}FILES+=              set1.0
+${PACKAGE}FILES+=              set2.0
+${PACKAGE}FILES+=              set3.0
+${PACKAGE}FILES+=              trap1.0
+${PACKAGE}FILES+=              trap10.0
+${PACKAGE}FILES+=              trap11.0
+${PACKAGE}FILES+=              trap12.0
+${PACKAGE}FILES+=              trap13.0
+${PACKAGE}FILES+=              trap14.0
+${PACKAGE}FILES+=              trap15.0
+${PACKAGE}FILES+=              trap16.0
+${PACKAGE}FILES+=              trap17.0
+${PACKAGE}FILES+=              trap2.0
+${PACKAGE}FILES+=              trap3.0
+${PACKAGE}FILES+=              trap4.0
+${PACKAGE}FILES+=              trap5.0
+${PACKAGE}FILES+=              trap6.0
+${PACKAGE}FILES+=              trap7.0
+${PACKAGE}FILES+=              trap8.0
+${PACKAGE}FILES+=              trap9.0
+${PACKAGE}FILES+=              type1.0 type1.0.stderr
+${PACKAGE}FILES+=              type2.0
+${PACKAGE}FILES+=              type3.0
+${PACKAGE}FILES+=              unalias.0
+${PACKAGE}FILES+=              var-assign.0
+${PACKAGE}FILES+=              var-assign2.0
+${PACKAGE}FILES+=              wait1.0
+${PACKAGE}FILES+=              wait2.0
+${PACKAGE}FILES+=              wait3.0
+${PACKAGE}FILES+=              wait4.0
+${PACKAGE}FILES+=              wait5.0
+${PACKAGE}FILES+=              wait6.0
+${PACKAGE}FILES+=              wait7.0
+${PACKAGE}FILES+=              wait8.0
+${PACKAGE}FILES+=              wait9.127
+${PACKAGE}FILES+=              wait10.0
 
 .include <bsd.test.mk>
 
 .include <bsd.test.mk>
diff --git a/sh/tests/builtins/Makefile.depend b/sh/tests/builtins/Makefile.depend
new file mode 100644 (file)
index 0000000..21c5642
--- /dev/null
@@ -0,0 +1,11 @@
+# $FreeBSD: head/bin/sh/tests/builtins/Makefile.depend 296587 2016-03-09 22:46:01Z bdrewery $
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
index d9b27969cfd684155b1c5e16ce9fb9315e134be0..067a890b4ffa8231cfd6d9cc006f87b7740bc4e2 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/alias.0 190285 2009-03-22 21:12:00Z stefanf $
 set -e
 
 unalias -a
 set -e
 
 unalias -a
index 31403dc760bf903c2f3a02e5e69cccfe644b6b68..22093dddff5c0e569b974f2995cc04da7b5c04ea 100644 (file)
@@ -1,3 +1,3 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/alias.1 149781 2005-09-04 11:59:59Z stefanf $
 unalias -a
 alias foo
 unalias -a
 alias foo
index fe65e31f5f0323e18f684b6b5cce6c923747b171..e2e215a9ea3640c9ead105697c8178c709dbcfe9 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/alias3.0 242767 2012-11-08 13:36:19Z jilles $
 set -e
 
 unalias -a
 set -e
 
 unalias -a
index 3d5efeccf2c74d1591fba85baff4a8d24b236cd4..d86559b7056f8fa9377c55bd41567c4e6cceae57 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/alias4.0 254849 2013-08-25 11:42:53Z jilles $
 
 unalias -a
 alias --
 
 unalias -a
 alias --
index ba0cbb4bd2689fcd71019f1f8df2bb27cb029be4..219cbf2050599f268c389582937b20c8b5770dd5 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/break1.0 211349 2010-08-15 21:06:53Z jilles $
 
 if [ "$1" != nested ]; then
        while :; do
 
 if [ "$1" != nested ]; then
        while :; do
index ff52dd32146919c32ba4e62fdb4f07211ea30ea8..f836e31ba42d0066b29810426ecf0647fc8ba5d2 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/break2.0 211467 2010-08-18 20:26:50Z jilles $
 
 # It is not immediately obvious that this should work, and someone probably
 # relies on it.
 
 # It is not immediately obvious that this should work, and someone probably
 # relies on it.
index 10a5ca88edff5df310a9c7b0cf4c4816435c12ba..1a6985c14f49ad54296b145caf17b2f97024610d 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/break3.0 211612 2010-08-22 11:07:46Z jilles $
 
 # We accept this and people might rely on it.
 # However, various other shells do not accept it.
 
 # We accept this and people might rely on it.
 # However, various other shells do not accept it.
index d52ff52be4d44928c32fbb36fe84bf5325393f84..3b1bb0c4c0b199807e8153c8bbb290df30655c26 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/break4.4 251180 2013-05-31 14:45:25Z jilles $
 
 # Although this is not specified by POSIX, some configure scripts (gawk 4.1.0)
 # appear to depend on it.
 
 # Although this is not specified by POSIX, some configure scripts (gawk 4.1.0)
 # appear to depend on it.
index 7df8e186311ce665c03263d94c84eea7ff25bef7..a29f3177963025ec652255bc548b5611ff9716c7 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/break5.4 251180 2013-05-31 14:45:25Z jilles $
 
 # Although this is not specified by POSIX, some configure scripts (gawk 4.1.0)
 # appear to depend on it.
 
 # Although this is not specified by POSIX, some configure scripts (gawk 4.1.0)
 # appear to depend on it.
index 09fc0d85eaa394b575848d0c97b0c571e24ca6c8..b5fc63bf96f17c9279f308aea8d7e0113cb97061 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/break6.0 268927 2014-07-20 20:29:09Z jilles $
 # Per POSIX, this need only work if LONG_MAX > 4294967295.
 
 while :; do
 # Per POSIX, this need only work if LONG_MAX > 4294967295.
 
 while :; do
index b6083858f671bab8bd12870ee8ded08679a99982..dd77422cd97d1b5ed98929c6d025e54abe3f4a8a 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/builtin1.0 201431 2010-01-03 15:01:38Z jilles $
 
 failures=0
 
 
 failures=0
 
index 860fc67dacdac9ba412199fd8e225dd75570bfcf..b8e8d9b96f573218de8f94f7c189eeded7c3dba6 100644 (file)
@@ -1,4 +1,4 @@
-#$FreeBSD$
+#$FreeBSD: head/bin/sh/tests/builtins/case1.0 172440 2007-10-04 16:14:48Z stefanf $
 f()
 {
        false
 f()
 {
        false
index a627b5cd996f017457d589a535ee9e49af467b04..e8cd933f195f67abf996abd0cd35927a3cd01eef 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/case10.0 223546 2011-06-25 20:37:43Z jilles $
 
 case ! in
 [\!!]) ;;
 
 case ! in
 [\!!]) ;;
index 0e66e11f0deef04170007203d0d6c82c8e2f1a75..afcfa430bd3c28f73813c07fa686470868905a54 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/case11.0 228007 2011-11-26 22:28:25Z jilles $
 
 false
 case x in
 
 false
 case x in
index 2a442ba7993ae262f77ea407486cb068d379bddf..630bee5c6d3bc8c56b8bb1206ad93e96cd4eadba 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/case12.0 228007 2011-11-26 22:28:25Z jilles $
 
 false
 case x in
 
 false
 case x in
index 78f4e9bdffde3b7b7e8bdf5b579f2906572777ed..669ce6262feb969956dd3d32d4147efeaf7f57e0 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/case13.0 228943 2011-12-28 23:51:17Z jilles $
 
 case ^ in
 [\^^]) ;;
 
 case ^ in
 [\^^]) ;;
index 0338e8a224e370b5844478e9418f811b02697cc6..f6a68cb4d138f2e1552418bd2478a49a0c8941a4 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/case14.0 230154 2012-01-15 20:04:05Z jilles $
 
 case `false` in
 no) exit 3 ;;
 
 case `false` in
 no) exit 3 ;;
index 09b0e113354430229523665690534ffe0803cbc4..083aaa65eb04db6d80f9b8e6cd391d5b4258c4d1 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/case15.0 230154 2012-01-15 20:04:05Z jilles $
 
 case x in
 `false`) exit 3 ;;
 
 case x in
 `false`) exit 3 ;;
index 24303027ba91407425c0b0ff814fa1e63b1f16c0..7031a927d5019544749937e14f1db656620d89c0 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/case16.0 230154 2012-01-15 20:04:05Z jilles $
 
 f() { return 42; }
 f
 
 f() { return 42; }
 f
index ed1d25f0277ad45367da24b54cfff10edfc22d0d..10d8d9ce0021000ee5b2cb1a9be4b40b68422099 100644 (file)
@@ -1,3 +1,3 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/case17.0 230161 2012-01-15 21:39:38Z jilles $
 
 ! case x in x) false ;& y) esac
 
 ! case x in x) false ;& y) esac
index 470253f622eadd18c25e8a4cb8433888e1c8dcb7..b0e601f49cb1a96daea37511f562ce59bc19f1fe 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/case18.0 230161 2012-01-15 21:39:38Z jilles $
 
 case x$(false) in
 x)     ;&
 
 case x$(false) in
 x)     ;&
index 215066ad6321ebf4b0a97f45ebd41d1d966622ab..1a9b09a52fac63f8584f1dd5b0816d2b3e956665 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/case19.0 230161 2012-01-15 21:39:38Z jilles $
 
 [ "`case x in
 x)     false ;&
 
 [ "`case x in
 x)     false ;&
index e319148cdf5d8d1511a3f53db271aded986c065a..ae3f356ab2f58870f12b11ba0cecafea5e3024e2 100644 (file)
@@ -1,5 +1,5 @@
 # Generated by ./test-fnmatch -s 1, do not edit.
 # Generated by ./test-fnmatch -s 1, do not edit.
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/case2.0 207821 2010-05-09 16:15:40Z jilles $
 failures=
 failed() { printf '%s\n' "Failed: $1 '$2' '$3'"; failures=x$failures; }
 testmatch() { eval "case \$2 in ''$1) ;; *) failed testmatch \"\$@\";; esac"; }
 failures=
 failed() { printf '%s\n' "Failed: $1 '$2' '$3'"; failures=x$failures; }
 testmatch() { eval "case \$2 in ''$1) ;; *) failed testmatch \"\$@\";; esac"; }
diff --git a/sh/tests/builtins/case20.0 b/sh/tests/builtins/case20.0
new file mode 100644 (file)
index 0000000..bd91e5b
--- /dev/null
@@ -0,0 +1,9 @@
+# $FreeBSD: head/bin/sh/tests/builtins/case20.0 287148 2015-08-25 21:55:15Z jilles $
+
+# Shells do not agree about what this pattern should match, but it is
+# certain that it must not crash and the missing close bracket must not
+# be simply ignored.
+
+case B in
+[[:alpha:]) echo bad ;;
+esac
index 42e53d62a3cbd45f6a4cedd1867926ec18cc5658..a2efd8731ccf952064100575aea924d36f1d5771 100644 (file)
@@ -1,5 +1,5 @@
 # Generated by ./test-fnmatch -s 2, do not edit.
 # Generated by ./test-fnmatch -s 2, do not edit.
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/case3.0 207821 2010-05-09 16:15:40Z jilles $
 failures=
 failed() { printf '%s\n' "Failed: $1 '$2' '$3'"; failures=x$failures; }
 # We do not treat a backslash specially in this case,
 failures=
 failed() { printf '%s\n' "Failed: $1 '$2' '$3'"; failures=x$failures; }
 # We do not treat a backslash specially in this case,
index 18219f51ee098e197be8023ca2f7a9220845d72c..7ba29ee72a4c8499b0d3499478d817d538e470e7 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/case4.0 220654 2011-04-15 15:14:58Z jilles $
 
 set -- "*"
 case x in
 
 set -- "*"
 case x in
index 8c6db5ab8e575fe5a127bc517a5a40b6daabbd6b..e8b141aa854b6de56d484f629bb7f694c9272dd9 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/case5.0 221646 2011-05-08 11:32:20Z jilles $
 
 unset LC_ALL
 LC_CTYPE=en_US.UTF-8
 
 unset LC_ALL
 LC_CTYPE=en_US.UTF-8
index 8d791831c3d8f2afb675fffb451a8194461464cc..7bc1da8c886c82c00bcd8e735ba86851d05ed440 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/case6.0 223007 2011-06-12 12:27:17Z jilles $
 
 unset LC_ALL
 LC_CTYPE=de_DE.ISO8859-1
 
 unset LC_ALL
 LC_CTYPE=de_DE.ISO8859-1
index 96b9de66fe276c28f0ab1bb5a5a4b2c6f2ecb3b7..b351ad528875fb89e87d3a46f395557dca231a64 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/case7.0 302829 2016-07-14 09:34:42Z ache $
 
 # Character ranges in a locale other than the POSIX locale, not specified
 # by POSIX.
 
 # Character ranges in a locale other than the POSIX locale, not specified
 # by POSIX.
index 8d9f8b604d881432af08994224d066aee8f2dfe4..c63c6e7b59e36301fb915adb6359ccf00a7cdf3b 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/case8.0 223120 2011-06-15 21:48:10Z jilles $
 
 case aZ_ in
 [[:alpha:]_][[:upper:]_][[:alpha:]_]) ;;
 
 case aZ_ in
 [[:alpha:]_][[:upper:]_][[:alpha:]_]) ;;
index 476caec261ba796aabee504eab12d38799bd506b..e374ef0e0d692d9990073a914c10bd5ad9dc4d56 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/case9.0 223186 2011-06-17 13:03:49Z jilles $
 
 errors=0
 
 
 errors=0
 
index bc5108e6be3b483ea3e66d69549af267d2458489..d797157d1912bd403a85923dfd7bca5af30b4b35 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/cd1.0 228975 2011-12-30 00:04:11Z uqs $
 set -e
 
 P=${TMPDIR:-/tmp}
 set -e
 
 P=${TMPDIR:-/tmp}
index f2b6416a12ec128accd9de056c5148bd9f3cd462..b7d39f3cb8819dd3319f0a849995ba4fe0d625a0 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/cd2.0 216019 2010-11-28 22:49:58Z jilles $
 set -e
 
 L=$(getconf PATH_MAX / 2>/dev/null) || L=4096
 set -e
 
 L=$(getconf PATH_MAX / 2>/dev/null) || L=4096
index 7729c54a68954ad05e224a642a1168aca3faecf3..aab8bc0e7ef30638f06caf5cd5901111ededf8ee 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/cd3.0 222154 2011-05-20 22:55:18Z jilles $
 
 # If fully successful, cd -Pe must be like cd -P.
 
 
 # If fully successful, cd -Pe must be like cd -P.
 
index df3a9a48961c06b497ce485881ffd10ada0bd144..da01b3158d243679a9762c5dd06a53fc0cc6157c 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/cd4.0 222154 2011-05-20 22:55:18Z jilles $
 
 # This test assumes that whatever mechanism cd -P uses to determine the
 # pathname to the current directory if it is longer than PATH_MAX requires
 
 # This test assumes that whatever mechanism cd -P uses to determine the
 # pathname to the current directory if it is longer than PATH_MAX requires
index 3dff604583c9b60fd7f33364f3f6a60242b1f985..8a285e071d9115304e7b6ed8992ec223ff6b6b9e 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/cd5.0 222379 2011-05-27 19:36:07Z jilles $
 
 set -e
 T=$(mktemp -d "${TMPDIR:-/tmp}/sh-test.XXXXXX")
 
 set -e
 T=$(mktemp -d "${TMPDIR:-/tmp}/sh-test.XXXXXX")
index 083a06190e647fd370a6faa5c2d9abf800ea634b..171c996181465897dcd48e18bb5e8fd0ff34dd2a 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/cd6.0 222381 2011-05-27 20:01:46Z jilles $
 
 set -e
 cd -P /bin
 
 set -e
 cd -P /bin
index 9adda86c1aedee1672264174383b5d662773b4f7..d4cae399057d559c80427d12d4dd47d24e688da2 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/cd7.0 222381 2011-05-27 20:01:46Z jilles $
 
 set -e
 cd /usr/bin
 
 set -e
 cd /usr/bin
index a68f77f26f75889bd5f264d050e4190c0c0ba976..ab17d380feaf8f5f364e241b520ec635f11943dd 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/cd8.0 230095 2012-01-13 23:32:27Z jilles $
 
 # The exact wording of the error message is not standardized, but giving
 # a description of the errno is useful.
 
 # The exact wording of the error message is not standardized, but giving
 # a description of the errno is useful.
diff --git a/sh/tests/builtins/cd9.0 b/sh/tests/builtins/cd9.0
new file mode 100644 (file)
index 0000000..e929878
--- /dev/null
@@ -0,0 +1,8 @@
+# $FreeBSD: head/bin/sh/tests/builtins/cd9.0 293371 2016-01-07 21:46:07Z jilles $
+
+cd /dev
+cd /bin
+cd - >/dev/null
+pwd
+cd - >/dev/null
+pwd
diff --git a/sh/tests/builtins/cd9.0.stdout b/sh/tests/builtins/cd9.0.stdout
new file mode 100644 (file)
index 0000000..dac16a7
--- /dev/null
@@ -0,0 +1,2 @@
+/dev
+/bin
index fd0afdfa0300f2edbe45f373fc389b5b17c3217a..5454c3f754674c95cd5b566c306ccf64ca33eb85 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/command1.0 151797 2005-10-28 14:02:42Z stefanf $
 true() {
        false
 }
 true() {
        false
 }
index 2c1adf1eb0bd429b69c3aaa7607cf24623c5ed05..08bddaf63ca87f72d410a6692ede0d23b270fb24 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/command10.0 204802 2010-03-06 17:31:09Z jilles $
 
 failures=0
 
 
 failures=0
 
index 10c86479d81b485985ff6fd226d3da6fd34a44ea..0eb204736eb53f5b1bf4baa95527e37c59318878 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/command11.0 205154 2010-03-14 14:24:35Z jilles $
 
 failures=0
 
 
 failures=0
 
index f981db3249463d97265e32baa668e0804335e107..6d9e8e79c189a54e9d4412a979258d4911a5d9e6 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/command12.0 257929 2013-11-10 23:00:39Z jilles $
 
 alias aa=echo\ \'\"\'
 cmd=$(command -v aa)
 
 alias aa=echo\ \'\"\'
 cmd=$(command -v aa)
index ff7b5f2c8dc82dc3bb7b19e0dacd4535bc301a62..7b490921d4000dfb45e19a18630631399e888591 100644 (file)
@@ -1,3 +1,3 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/command2.0 151797 2005-10-28 14:02:42Z stefanf $
 PATH=
 command -p cat < /dev/null
 PATH=
 command -p cat < /dev/null
index 9d4ae89e0e2edb9a9f63150b25bf6ada34306b4b..6d6355db072508c0e4e48bfe42707f72996935ad 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/command3.0 211399 2010-08-16 17:18:08Z jilles $
 command -v ls
 command -v true
 command -v /bin/ls
 command -v ls
 command -v true
 command -v /bin/ls
index 3e496137ff589725f24b069c689a144a3587a6e3..23496692b797edfa498f6511af3e868b9d6f17f5 100644 (file)
@@ -1,2 +1,2 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/command4.0 211973 2010-08-29 20:53:24Z jilles $
 ! command -v nonexisting
 ! command -v nonexisting
index 13b3fe1fe3f443dfd907c6dba0c39ae2aec8b5dd..7c99b52cf17ba599aa677d3b2514ed8845419312 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/command5.0 211399 2010-08-16 17:18:08Z jilles $
 command -V ls
 command -V true
 command -V /bin/ls
 command -V ls
 command -V true
 command -V /bin/ls
index 5b63bfecc0f0aa6f613f821514d7a338a6956ea9..d1902ed69066b3ad707694638cd3708daa480014 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/command6.0 218356 2011-02-05 23:00:24Z jilles $
 PATH=/var/empty
 case $(command -pV ls) in
 */var/empty/ls*)
 PATH=/var/empty
 case $(command -pV ls) in
 */var/empty/ls*)
index fc652f2075847a4182a05395955994025e8e36c3..b8351f22f012b2892af3f969e33a5a40dc658c42 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/command7.0 218356 2011-02-05 23:00:24Z jilles $
 
 failures=0
 
 
 failures=0
 
index 9e3a2b645fbbbb52c17d1c9f66abd437ef95882d..54848d139ce7ea347394bf97d65b482180b4730b 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/command8.0 213738 2010-10-12 18:20:38Z obrien $
 IFS=,
 
 SPECIAL="break,\
 IFS=,
 
 SPECIAL="break,\
index 212e52aafc9814fcdf59ef08104a48b44cd99cb7..40f98c1b7cb49efa2a8d009971d2a379bc67c469 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/command9.0 204801 2010-03-06 17:09:22Z jilles $
 
 failures=0
 
 
 failures=0
 
index 43eab0ddeb33a45eb0856e28359b7f2382f91684..0aa69a8981ca48b0299f30ecc6cbaab92753c665 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/dot1.0 208629 2010-05-28 22:08:34Z jilles $
 
 failures=
 failure() {
 
 failures=
 failure() {
index ed6379b993c37a351fbc74bd8c5fc2be7b4b50fd..dba591e260215c4efc7664d098a4b8c2ddc07895 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/dot2.0 208630 2010-05-28 22:40:24Z jilles $
 
 failures=
 failure() {
 
 failures=
 failure() {
index b337f0f6d3385c7f027b77ee51c5a071c344c4c1..d1589a0e741a1e669c8531d54af2940eb7e41452 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/dot3.0 219390 2011-03-07 23:52:23Z jilles $
 
 # . should return 0 if no command was executed.
 
 
 # . should return 0 if no command was executed.
 
index b898131c0e1c3b0928edc56970d074411b6135bf..d280f3578495b1e3a0c61b598215bc764174309f 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/dot4.0 222174 2011-05-22 12:15:14Z jilles $
 
 v=abcd
 v=$v$v$v$v
 
 v=abcd
 v=$v$v$v$v
diff --git a/sh/tests/builtins/echo1.0 b/sh/tests/builtins/echo1.0
new file mode 100644 (file)
index 0000000..34d75a6
--- /dev/null
@@ -0,0 +1,6 @@
+# $FreeBSD: head/bin/sh/tests/builtins/echo1.0 305305 2016-09-02 21:13:46Z jilles $
+
+# Not specified by POSIX.
+
+[ "`echo -n a b; echo c d; echo e f`" = "a bc d
+e f" ]
diff --git a/sh/tests/builtins/echo2.0 b/sh/tests/builtins/echo2.0
new file mode 100644 (file)
index 0000000..3eae51b
--- /dev/null
@@ -0,0 +1,7 @@
+# $FreeBSD: head/bin/sh/tests/builtins/echo2.0 305305 2016-09-02 21:13:46Z jilles $
+
+# Not specified by POSIX.
+
+a=`echo -e '\a\b\e\f\n\r\t\v\\\\\0041\c'; echo .`
+b=`printf '\a\b\033\f\n\r\t\v\\\\!.'`
+[ "$a" = "$b" ]
diff --git a/sh/tests/builtins/echo3.0 b/sh/tests/builtins/echo3.0
new file mode 100644 (file)
index 0000000..aa86443
--- /dev/null
@@ -0,0 +1,5 @@
+# $FreeBSD: head/bin/sh/tests/builtins/echo3.0 305305 2016-09-02 21:13:46Z jilles $
+
+# Not specified by POSIX.
+
+[ "`echo -e 'a\cb' c; echo d`" = "ad" ]
index 04606a4a87fe556427ef1adb3d9520414669d49c..ad099cead6a5b7835a6598596047491b15a5001f 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/eval1.0 193178 2009-05-31 17:23:27Z stefanf $
 set -e
 
 eval
 set -e
 
 eval
index bf06b6e14e0c3019bd7717190049cc1b8c986285..4df41ea4e6f2470198e6d1abda9fb6dee1aa13d2 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/eval2.0 194897 2009-06-24 20:22:54Z jilles $
 
 eval '
 false
 
 eval '
 false
index dfb8357c727c7ad3055a3366b131b9d5e3c68341..04f9720fbaf1ea096be9b03ef6fda3dfb1a73d98 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/eval3.0 196607 2009-08-27 22:23:23Z jilles $
 
 eval 'false;' && exit 1
 eval 'true;' || exit 1
 
 eval 'false;' && exit 1
 eval 'true;' || exit 1
index 67da2f5c832d121117a11342b377f27183b8589b..82c3ea9c4f440c7b12dfa9530e1310549e8e50d1 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/eval4.0 210738 2010-08-01 22:39:07Z jilles $
 
 # eval should preserve $? from command substitutions when starting
 # the parsed command.
 
 # eval should preserve $? from command substitutions when starting
 # the parsed command.
index 3e86de92fbae2f50c85cf79027246ef287b07d18..89e79b8b0ebb4e4cde527e51c04addeb062e2016 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/eval5.0 210829 2010-08-03 22:17:29Z jilles $
 
 # eval should return 0 if no command was executed.
 eval $(false)
 
 # eval should return 0 if no command was executed.
 eval $(false)
index 6752bb65ad4d84a5bc63e7f08772125bd5b58b90..bfce89fc5346c3240c81b61345a4e1e03a8cb104 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/eval6.0 249220 2013-04-06 22:30:46Z jilles $
 
 # eval should preserve $? from command substitutions when starting
 # the parsed command.
 
 # eval should preserve $? from command substitutions when starting
 # the parsed command.
index a309c917b102dc40124055c395fb04fd7780a45f..f694e735a100e55be5bf4738c57637000379eaec 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/eval7.0 272983 2014-10-12 13:12:06Z jilles $
 # Assumes that break can break out of a loop outside eval.
 
 while :; do
 # Assumes that break can break out of a loop outside eval.
 
 while :; do
index af6064c388df153efe4184da43824e124ce78d85..30902cc5b5eb6113139f17becfa69c8781d5ac45 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/eval8.7 272983 2014-10-12 13:12:06Z jilles $
 
 f() {
        eval "return 7
 
 f() {
        eval "return 7
index dd30a4c9aa93e25c095e2b2ad1b90ea7bf1c959b..8c5bb01192e7b4cbec857ae0aff043ce717a625e 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/exec1.0 213738 2010-10-12 18:20:38Z obrien $
 
 failures=
 failure() {
 
 failures=
 failure() {
index 3dcb6c41156a62867a01da1b2a15f9bdb1cfa65e..5395ba6ca35df69e34a471b16c88cb0595489008 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/exec2.0 213738 2010-10-12 18:20:38Z obrien $
 
 failures=
 failure() {
 
 failures=
 failure() {
index 496d448761cccd84f7f07376b3b9ed0651948c5d..4c378f2f6900cdf50774a7a1f66b31e1b7f3dfea 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/exit1.0 216871 2011-01-01 15:25:15Z jilles $
 
 # exit with an argument should overwrite the exit status in an EXIT trap.
 
 
 # exit with an argument should overwrite the exit status in an EXIT trap.
 
index 124c32e01a3ce428249a0aefcbae757ae8796094..51d38f793b9bd2607c6314c20275b24cebddbae1 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/exit2.8 217172 2011-01-08 23:00:38Z jilles $
 
 # exit without arguments is the same as exit $? outside a trap.
 
 
 # exit without arguments is the same as exit $? outside a trap.
 
index 80655ac539c56457d3b53ad78b98e90747741a2b..4e0c96c81a6a4ebbbfdfd10ec51e18cb57e28533 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/exit3.0 217175 2011-01-08 23:08:13Z jilles $
 
 # exit without arguments differs from exit $? in an EXIT trap.
 
 
 # exit without arguments differs from exit $? in an EXIT trap.
 
index 7b08c9de434947908e7e9c1eb53453e4da64e647..a09263a8ab5931df692f2be9b3fba66e1c26cd3e 100644 (file)
@@ -1,3 +1,3 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/export1.0 223183 2011-06-17 10:21:24Z jilles $
 
 env @badness=1 ${SH} -c 'v=`export -p`; eval "$v"'
 
 env @badness=1 ${SH} -c 'v=`export -p`; eval "$v"'
index ab7a387b507726d8d0245239f457c32467841f9a..042cb3356796458b705ff7d03b6372d19bcec3ee 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/fc1.0 213738 2010-10-12 18:20:38Z obrien $
 set -e
 trap 'echo Broken pipe -- test failed' PIPE
 
 set -e
 trap 'echo Broken pipe -- test failed' PIPE
 
index 7eb92acc2cdfa0bd64f7d6d8206a9f2a8d7f3404..a6151f7858ee36eb631f647ac57824639b539c3a 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/fc2.0 213738 2010-10-12 18:20:38Z obrien $
 set -e
 trap 'echo Broken pipe -- test failed' PIPE
 
 set -e
 trap 'echo Broken pipe -- test failed' PIPE
 
index cd55e2ca029efb758ad8fefab42406dc83478707..276cb0a3961790f68a4bc5c12340ce2fc3d4f52b 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/for1.0 226892 2011-10-28 23:02:21Z jilles $
 
 false
 for i in `false`; do exit 3; done
 
 false
 for i in `false`; do exit 3; done
index 48c22ce71119decda183473cfd93708fd58798c4..2b702cebf34ac0d7b675423f6c640fe9d0459f7c 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/for2.0 230463 2012-01-22 14:00:33Z jilles $
 
 r=x
 f() { return 42; }
 
 r=x
 f() { return 42; }
index cc37238abbc6b0ce482776d89ed15b4b740168b1..a345caab246756b0ef07e9384cba11db28a68dbb 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/for3.0 230463 2012-01-22 14:00:33Z jilles $
 
 r=x
 f() { return 42; }
 
 r=x
 f() { return 42; }
index 64763bc462c1c8799a2e46dcfa11ef2d6f519617..d3e7415787ba5fb285c34bc67ba34e28a493c49e 100644 (file)
@@ -1,9 +1,9 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/getopts1.0 297752 2016-04-09 16:06:13Z jilles $
 
 printf -- '-1-\n'
 set -- -abc
 getopts "ab:" OPTION
 
 printf -- '-1-\n'
 set -- -abc
 getopts "ab:" OPTION
-echo ${OPTION}
+printf '%s\n' "${OPTION}"
 
 # In this case 'getopts' should realize that we have not provided the
 # required argument for "-b".
 
 # In this case 'getopts' should realize that we have not provided the
 # required argument for "-b".
@@ -14,12 +14,12 @@ echo ${OPTION}
 printf -- '-2-\n'
 set -- -ab
 getopts "ab:" OPTION
 printf -- '-2-\n'
 set -- -ab
 getopts "ab:" OPTION
-echo ${OPTION}
+printf '%s\n' "${OPTION}"
 getopts "ab:" OPTION 3>&2 2>&1 >&3 3>&-
 getopts "ab:" OPTION 3>&2 2>&1 >&3 3>&-
-echo ${OPTION}
+printf '%s\n' "${OPTION}"
 
 # The 'shift' is aimed at causing an error.
 printf -- '-3-\n'
 shift 1
 getopts "ab:" OPTION
 
 # The 'shift' is aimed at causing an error.
 printf -- '-3-\n'
 shift 1
 getopts "ab:" OPTION
-echo ${OPTION}
+printf '%s\n' "${OPTION}"
diff --git a/sh/tests/builtins/getopts10.0 b/sh/tests/builtins/getopts10.0
new file mode 100644 (file)
index 0000000..7d34ddc
--- /dev/null
@@ -0,0 +1,11 @@
+# $FreeBSD: head/bin/sh/tests/builtins/getopts10.0 293359 2016-01-07 20:48:24Z jilles $
+
+set -- -x arg
+opt=not
+getopts x opt
+r1=$? OPTIND1=$OPTIND opt1=$opt
+: $(: $((OPTIND = 1)))
+getopts x opt
+r2=$? OPTIND2=$OPTIND
+[ "$r1" = 0 ] && [ "$OPTIND1" = 2 ] && [ "$opt1" = x ] && [ "$r2" != 0 ] &&
+       [ "$OPTIND2" = 2 ]
index 5a5dbe20cb6aa99fa8d2a1f0f13fdd409cd3ced4..607d35e50182893b9a5342ae8a09aa19234fa13a 100644 (file)
@@ -1,6 +1,6 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/getopts2.0 297752 2016-04-09 16:06:13Z jilles $
 set - -ax
 getopts ax option
 set -C
 getopts ax option
 set - -ax
 getopts ax option
 set -C
 getopts ax option
-echo $option
+printf '%s\n' "$option"
index d02469b204696f05788932c67a831151e6a6ff31..6087d73278b79ccdb5e96caa92c671ea3193359d 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/getopts3.0 265616 2014-05-07 21:45:25Z jilles $
 
 shift $#
 getopts x opt
 
 shift $#
 getopts x opt
index 61d5c2b6b15c2c4f67bce41f68793f0ff73a0eff..ea8cc3f2befd3bfbef31f3164494a086060fba5a 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/getopts4.0 265616 2014-05-07 21:45:25Z jilles $
 
 set -- -x
 opt=not
 
 set -- -x
 opt=not
index 666ee7652de50aa62775ab9a88e38f278da0f622..cd4eca65039358203a33aea893b3b2c817d0cdc6 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/getopts5.0 265616 2014-05-07 21:45:25Z jilles $
 
 set -- -x arg
 opt=not
 
 set -- -x arg
 opt=not
index 1d3c39ba953e833e4503d4184fa2a365043bf1cd..c415eda3e3818b5a8d9ea463e5ef8aa1d79f6ecd 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/getopts6.0 265844 2014-05-10 17:42:21Z jilles $
 
 set -- -x -y
 getopts :x var || echo "First getopts bad: $?"
 
 set -- -x -y
 getopts :x var || echo "First getopts bad: $?"
index 3745555f8c1a195a0dfd3e16883a51cb5c03f2b3..58afa5002ee40f587ba36bfb64e94327cc5bb81d 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/getopts7.0 265844 2014-05-10 17:42:21Z jilles $
 
 set -- -x
 getopts :x: var
 
 set -- -x
 getopts :x: var
index da4af6bd0b567422017a1cbdf3b1d517d24eb68e..35814b9b08ba14b8e729bd54bab95dec2b418d6c 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/getopts8.0 265849 2014-05-10 19:18:49Z jilles $
 
 set -- -yz -wx
 opt=wrong1 OPTARG=wrong2
 
 set -- -yz -wx
 opt=wrong1 OPTARG=wrong2
index d23fc432af97ab0411da66a72eac67419bf40275..aa4abbc91c593aad1965969a5fe2fdac173a2688 100644 (file)
@@ -1,9 +1,9 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/getopts9.0 297752 2016-04-09 16:06:13Z jilles $
 
 args='-ab'
 getopts ab opt $args
 
 args='-ab'
 getopts ab opt $args
-echo $?:$opt:$OPTARG
+printf '%s\n' "$?:$opt:$OPTARG"
 for dummy in dummy1 dummy2; do
        getopts ab opt $args
 for dummy in dummy1 dummy2; do
        getopts ab opt $args
-       echo $?:$opt:$OPTARG
+       printf '%s\n' "$?:$opt:$OPTARG"
 done
 done
index 45cc3003fb5937f98fa9213c22f5e9d2e637cb33..a5cae202d87a9bc7b8a78c733f8abf8204521c56 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/hash1.0 149791 2005-09-05 09:42:10Z stefanf $
 cat /dev/null
 hash
 hash -r
 cat /dev/null
 hash
 hash -r
index e5cd21bc57dd418f89394ac27ee982252cede5f0..4ef151a1353a50441bb5ad0712fd34bbc980d73a 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/hash2.0 149791 2005-09-05 09:42:10Z stefanf $
 hash
 hash cat
 hash
 hash
 hash cat
 hash
index eade0b3195461db63a96913c90154eed18805c77..6a155f44ce9d150a19fe259f5bbe56a831bfcf7e 100644 (file)
@@ -1,3 +1,3 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/hash3.0 149791 2005-09-05 09:42:10Z stefanf $
 hash -v cat
 hash
 hash -v cat
 hash
index dec584c4538f1bd7ef7b330c97bac1c7076a2f0f..9e85f92877e9ef4615a26f593c4837848942280e 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/hash4.0 231535 2012-02-11 21:06:45Z jilles $
 
 exec 3>&1
 m=`hash nosuchtool 2>&1 >&3`
 
 exec 3>&1
 m=`hash nosuchtool 2>&1 >&3`
index 483fda20743cfc3292b9aa964f5bc07baad3e777..8ba11c1eeedcce5d019101534f6627784c765691 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/jobid1.0 254412 2013-08-16 13:48:11Z jilles $
 # Non-standard builtin.
 
 : &
 # Non-standard builtin.
 
 : &
index 101831a2e4b83164700aad229d1b079bd8c2bde9..4aca7d5159b4729cb037ec5264f72fd79a3891af 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/jobid2.0 254413 2013-08-16 13:56:43Z jilles $
 
 : &
 p1=$(jobid)
 
 : &
 p1=$(jobid)
index c1b85503848e2ab8db709c7e23220be5d84d501c..c15c86d50927c474bcd7490640a8ecac1044ffa2 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/kill1.0 262931 2014-03-08 19:44:34Z jilles $
 
 : &
 p1=$!
 
 : &
 p1=$!
index 31e0ba362b80bf2d4faac0b3ab006dd2e757b78f..3b2360b5e01c228d3d39de6b9739afa20db6a3b5 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/kill2.0 263206 2014-03-15 14:58:48Z jilles $
 
 sleep 1 | sleep 1 &
 kill %+
 
 sleep 1 | sleep 1 &
 kill %+
index c9311f82d253657d9191fb7522ed9f93aa5d7f40..e678ad8f8610200e3c8573c0b9a70287e9b9ee0f 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/lineno.0 179023 2008-05-15 19:58:44Z stefanf $
 echo $LINENO
 echo $LINENO
 
 echo $LINENO
 echo $LINENO
 
index ddbd10433a36aacd759aad6b4d1680f8111fb641..f60ed11b4b971294d9f646e8fa42db1035bedad7 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/lineno2.0 262565 2014-02-27 16:54:43Z jilles $
 
 f() {
        : ${LINENO+${x?}}
 
 f() {
        : ${LINENO+${x?}}
index eb8f9ab7db9484a875275544a43acf1b8cd757d1..3271262497c00816e1947f9829048e2bb07debac 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/lineno3.0 272482 2014-10-03 20:24:56Z jilles $
 
 echo before: $LINENO
 dummy=$'a\0
 
 echo before: $LINENO
 dummy=$'a\0
index b28837ec005fc45e4b4e0fd085e9811dee22a4fa..6100274abc6cafb534e1bb37e5dca38bad9de4ae 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/local1.0 238469 2012-07-15 10:22:13Z jilles $
 # A commonly used but non-POSIX builtin.
 
 f() {
 # A commonly used but non-POSIX builtin.
 
 f() {
index cc8c10f406185ee1118bfdf4b023e40168e659cc..ed78d931bad9a8610c29a93d656b955ccffe8ffe 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/local2.0 251797 2013-06-15 22:22:03Z jilles $
 
 f() {
        local -
 
 f() {
        local -
index 39ee370099e7637b7c4a922616a6cdf65256c0ac..f1d135d0b9253e5206139339ee07bfc3fd375d4c 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/local3.0 251797 2013-06-15 22:22:03Z jilles $
 
 f() {
        local "$@"
 
 f() {
        local "$@"
index 3955aaa12f1a3cb9f0fc39c8e926ea4c682a6b9a..7d35e6e0887b519b9088e54b8886d114217fda5f 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/local4.0 254339 2013-08-14 21:59:48Z jilles $
 
 f() {
        local -- x
 
 f() {
        local -- x
diff --git a/sh/tests/builtins/local5.0 b/sh/tests/builtins/local5.0
new file mode 100644 (file)
index 0000000..912a77b
--- /dev/null
@@ -0,0 +1,15 @@
+# $FreeBSD: head/bin/sh/tests/builtins/local5.0 293635 2016-01-10 16:31:28Z jilles $
+
+f() {
+       local PATH IFS elem
+       IFS=:
+       for elem in ''$PATH''; do
+               PATH=/var/empty/$elem:$PATH
+       done
+       ls -d / >/dev/null
+}
+
+p1=$(command -v ls)
+f
+p2=$(command -v ls)
+[ "$p1" = "$p2" ]
diff --git a/sh/tests/builtins/local6.0 b/sh/tests/builtins/local6.0
new file mode 100644 (file)
index 0000000..b2e4c68
--- /dev/null
@@ -0,0 +1,10 @@
+# $FreeBSD: head/bin/sh/tests/builtins/local6.0 294582 2016-01-22 18:10:36Z jilles $
+
+f() {
+       local x
+       readonly x=2
+}
+x=3
+f
+x=4
+[ "$x" = 4 ]
diff --git a/sh/tests/builtins/local7.0 b/sh/tests/builtins/local7.0
new file mode 100644 (file)
index 0000000..3819442
--- /dev/null
@@ -0,0 +1,10 @@
+# $FreeBSD: head/bin/sh/tests/builtins/local7.0 294593 2016-01-22 20:10:08Z jilles $
+
+f() {
+       local x
+       readonly x=2
+}
+unset x
+f
+x=4
+[ "$x" = 4 ]
index 90b10944c5a5d9fabd9e1e58e5faacf9ff072c01..a560232b779deff1bd158f9083d545fd053c3503 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/locale1.0 218819 2011-02-18 20:37:09Z jilles $
 # Note: this test depends on strerror() using locale.
 
 failures=0
 # Note: this test depends on strerror() using locale.
 
 failures=0
index 99a82d014794f384cea469fdd4a1b5f1455bd9a7..5730c5b773632069ea81ddfcfdfaedb34a19dce6 100644 (file)
@@ -1,3 +1,3 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/printf1.0 214853 2010-11-05 21:47:58Z jilles $
 
 [ "$(printf '%c\0%s%d' x '\' 010 | tr '\0' Z)" = 'xZ\8' ]
 
 [ "$(printf '%c\0%s%d' x '\' 010 | tr '\0' Z)" = 'xZ\8' ]
index 7763d6fe9636cee2731d476ea04ac0f661f2e605..7084db7cbe8316208ab3d1c220553d9fa7a89ffd 100644 (file)
@@ -1,3 +1,3 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/printf2.0 214853 2010-11-05 21:47:58Z jilles $
 
 [ "$(printf '%cZ%s%d' x '\' 010)" = 'xZ\8' ]
 
 [ "$(printf '%cZ%s%d' x '\' 010)" = 'xZ\8' ]
index 0e7ea85cddb479251460877bb9928f6c689192fb..ba548661e2c9a7b97e3af560182269a043c4933b 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/printf3.0 216606 2010-12-20 23:06:57Z jilles $
 
 set -e
 v=$(! printf "%d" @wrong 2>/dev/null)
 
 set -e
 v=$(! printf "%d" @wrong 2>/dev/null)
index 2dd3e729574a99ff8d30c415af55c5553cfb5c62..5213dd6eceda6859e113b7522e43c54e7bcf325a 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/printf4.0 216606 2010-12-20 23:06:57Z jilles $
 
 set -e
 v=$(! printf "%d" 4wrong 2>/dev/null)
 
 set -e
 v=$(! printf "%d" 4wrong 2>/dev/null)
index 06a68faa32a30e29d7b3c809b421237e77bdb10b..b32272ce3013050df6e5b64655188d30854e0eb8 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/read1.0 190300 2009-03-22 23:00:52Z stefanf $
 set -e
 
 echo "1 2 3"           | { read a; echo "x${a}x"; }
 set -e
 
 echo "1 2 3"           | { read a; echo "x${a}x"; }
index fc7451191586194ca2f58e8433b7266405a2109f..3255a4875bcc2cdc2a6d09bb5e558a74e0e03b00 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/read2.0 212187 2010-09-03 21:17:33Z jilles $
 
 set -e
 {
 
 set -e
 {
index c6ae9c1023c0c5216ce899cad5da30547e9892a3..7cd5b4b6b5cfec05b5a67689d7cb87348f8b22fd 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/read3.0 212330 2010-09-08 18:32:23Z jilles $
 
 printf '%s\n' 'a\ b c' | { read a b; printf '%s\n' "x${a}x${b}x"; }
 printf '%s\n' 'a b\ c' | { read a b; printf '%s\n' "x${a}x${b}x"; }
 
 printf '%s\n' 'a\ b c' | { read a b; printf '%s\n' "x${a}x${b}x"; }
 printf '%s\n' 'a b\ c' | { read a b; printf '%s\n' "x${a}x${b}x"; }
index 7204a35aa0a57efedf57e801edfb2d1f0561972c..abd08af9415552e11f15cbbb478be12ac6bb359d 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/read4.0 212339 2010-09-08 20:35:43Z jilles $
 
 printf '%s\n' '\a\ b c'        | { read a b; printf '%s\n' "x${a}x${b}x"; }
 printf '%s\n' '\a b\ c'        | { read a b; printf '%s\n' "x${a}x${b}x"; }
 
 printf '%s\n' '\a\ b c'        | { read a b; printf '%s\n' "x${a}x${b}x"; }
 printf '%s\n' '\a b\ c'        | { read a b; printf '%s\n' "x${a}x${b}x"; }
index 7d83391cba22dca13bd22cb0b14dacf4c0d0bf4d..659aebbcd7cce84703db69f6255ee75dcbd1d106 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/read5.0 218821 2011-02-18 20:51:13Z jilles $
 
 unset LC_ALL
 LC_CTYPE=en_US.ISO8859-1
 
 unset LC_ALL
 LC_CTYPE=en_US.ISO8859-1
index 2168e10c841aa2b2ee2abab3ea61366d8b4e0044..3f78ee1f73456e2896fd7b21db9e51bb212b507b 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/read6.0 247190 2013-02-23 15:15:41Z jilles $
 
 : | read x
 r=$?
 
 : | read x
 r=$?
index e78f887b60b41e78110c70db64da3edfe5cc58dc..a01082dc270bb294bf9ccf1d8be8aa7cc4ccec7d 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/read7.0 250214 2013-05-03 15:28:31Z jilles $
 
 { errmsg=`read x <&- 2>&1 >&3`; } 3>&1
 r=$?
 
 { errmsg=`read x <&- 2>&1 >&3`; } 3>&1
 r=$?
diff --git a/sh/tests/builtins/read8.0 b/sh/tests/builtins/read8.0
new file mode 100644 (file)
index 0000000..b488279
--- /dev/null
@@ -0,0 +1,17 @@
+# $FreeBSD: head/bin/sh/tests/builtins/read8.0 286826 2015-08-16 12:57:17Z jilles $
+
+read a b c <<\EOF
+\
+A\
+ \
+ \
+ \
+B\
+ \
+ \
+C\
+ \
+ \
+ \
+EOF
+[ "$a.$b.$c" = "A.B.C" ]
diff --git a/sh/tests/builtins/read9.0 b/sh/tests/builtins/read9.0
new file mode 100644 (file)
index 0000000..16f0687
--- /dev/null
@@ -0,0 +1,10 @@
+# $FreeBSD: head/bin/sh/tests/builtins/read9.0 287308 2015-08-30 17:24:22Z jilles $
+
+empty=''
+read a b c <<EOF
+\ \ A B\ \ B C\ \ $empty
+EOF
+read d e <<EOF
+D\ $empty
+EOF
+[ "$a.$b.$c.$d.$e" = "  A.B  B.C  .D ." ]
index 787e892a769802908ac58f5597cc8fec29261238..46de0aea5a4987f491b6e73771d3b1bcc86098af 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/return1.0 149791 2005-09-05 09:42:10Z stefanf $
 f() {
        return 0
        exit 1
 f() {
        return 0
        exit 1
index 0ef817179d73fda3f2e762f39e22c6f40fac9bf6..4da86f5b762cf498998d8fc6bda14b46fabe2411 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/return2.1 149791 2005-09-05 09:42:10Z stefanf $
 f() {
        true && return 1
        return 0
 f() {
        true && return 1
        return 0
index 605ec680d66a2a932082f4b5f6391eb11173283e..bc65c1fc2eee920335241f5236d71598b4911566 100644 (file)
@@ -1,3 +1,3 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/return3.1 149791 2005-09-05 09:42:10Z stefanf $
 return 1
 exit 0
 return 1
 exit 0
index be5582b458b4eb29fc5c601825afc93f65913882..1a702ef6d83ba1359c6b71a2dff0408a5398cd62 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/return4.0 208629 2010-05-28 22:08:34Z jilles $
 
 failures=
 failure() {
 
 failures=
 failure() {
index 6e4b7bd751a8db94ff047437756cbaa77dee883a..476ae7b926f2748c34a596a7b98663262b509f70 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/return5.0 211349 2010-08-15 21:06:53Z jilles $
 
 if [ "$1" != nested ]; then
        f() {
 
 if [ "$1" != nested ]; then
        f() {
index e4d8e0d641a172f816e6d6da44e7b1ebfe9bf3a9..1bddbebaa0c3e1a5ed3fdde81ee1b9cbddbcf680 100644 (file)
@@ -1,3 +1,3 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/return6.4 212475 2010-09-11 15:07:40Z jilles $
 
 while return 4; do exit 3; done
 
 while return 4; do exit 3; done
index 2047373473ab3a90d959f978d5833942ca0072f3..3efdd7fd1c4905206553b90778397df66c27ecf6 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/return7.4 212475 2010-09-11 15:07:40Z jilles $
 
 f() {
        while return 4; do exit 3; done
 
 f() {
        while return 4; do exit 3; done
index f00e859a74ce1b2f24d9607d5828ea8b161da3c8..025f0682554d7cfabe32c63eae034519ef066845 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/return8.0 255215 2013-09-04 22:10:16Z jilles $
 
 if [ "$1" = nested ]; then
        return 17
 
 if [ "$1" = nested ]; then
        return 17
index ad13eab0a7b833449018ac413eaf3232e2537f18..844da916b43ab6680f78d0e5fc2384f09a90274a 100644 (file)
@@ -1,3 +1,3 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/set2.0 223183 2011-06-17 10:21:24Z jilles $
 
 ! env @badness=1 ${SH} -c 'v=`set`; eval "$v"' 2>&1 | grep @badness
 
 ! env @badness=1 ${SH} -c 'v=`set`; eval "$v"' 2>&1 | grep @badness
diff --git a/sh/tests/builtins/set3.0 b/sh/tests/builtins/set3.0
new file mode 100644 (file)
index 0000000..419f702
--- /dev/null
@@ -0,0 +1,4 @@
+# $FreeBSD: head/bin/sh/tests/builtins/set3.0 296578 2016-03-09 21:05:21Z jilles $
+
+settings1=$(set +o) && set -o nolog && settings2=$(set +o) &&
+[ "$settings1" != "$settings2" ]
index 313f6a38767833821cc59810f3c3e752f84d61e7..9f60be44817366b1413b8c4e3321cb115e9a288c 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/trap1.0 213738 2010-10-12 18:20:38Z obrien $
 
 test "$(trap 'echo trapped' EXIT; :)" = trapped || exit 1
 
 
 test "$(trap 'echo trapped' EXIT; :)" = trapped || exit 1
 
index fa0e35d6a6b2686d0ba1b3f07b84ad1b10b65e52..66c51061a036299e53229dd5ef6ab961be7091ff 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/trap10.0 230212 2012-01-16 11:07:46Z dumbbell $
 
 # Check that the return statement will not break the EXIT trap, ie. all
 # trap commands are executed before the script exits.
 
 # Check that the return statement will not break the EXIT trap, ie. all
 # trap commands are executed before the script exits.
index cfeea9ed9ded264ab8a0c803d3ff6a6b1295bbc4..acb4d0f93798d2b09b2a29a49ad740b1a531f402 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/trap11.0 230212 2012-01-16 11:07:46Z dumbbell $
 
 # Check that the return statement will not break the USR1 trap, ie. all
 # trap commands are executed before the script resumes.
 
 # Check that the return statement will not break the USR1 trap, ie. all
 # trap commands are executed before the script resumes.
index 8c62ffd2b570a5c2859397de52bf0858edb50eb8..a7a953c1553c40ca4e5925626eadfb1b63879765 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/trap12.0 247720 2013-03-03 17:33:59Z jilles $
 
 f() {
        trap 'return 42' USR1
 
 f() {
        trap 'return 42' USR1
index d90eb08eb2421bbdc5cd5429740469c393505300..1069b8f027a83df31adc07da34d4f0af0a00e1f7 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/trap13.0 257399 2013-10-30 21:36:15Z jilles $
 
 {
        trap 'exit 0' INT
 
 {
        trap 'exit 0' INT
index 97cce8d0d24436f65f425cd45a05990c3f69fccf..8c982b290da1d3e482880f7ef635296b31f753be 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/trap14.0 257399 2013-10-30 21:36:15Z jilles $
 
 {
        trap - INT
 
 {
        trap - INT
index 6b9857df3d1a336897c788c5fe76d2c069c94c4a..eaf8e8e57aae980141ca5a7c381fdf8e0793db21 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/trap15.0 281718 2015-04-18 23:49:57Z bdrewery $
 
 (${SH} -c 'term(){ exit 5;}; trap term TERM; kill -TERM $$') &
 wait >/dev/null 2>&1 $!
 
 (${SH} -c 'term(){ exit 5;}; trap term TERM; kill -TERM $$') &
 wait >/dev/null 2>&1 $!
index 3d70cce8a72140dcfb1ac42e3e2204419eeffcdd..b72fa1144fa25e2c02f96cd371b4ec2a33664af3 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/trap16.0 281718 2015-04-18 23:49:57Z bdrewery $
 
 traps=$(${SH} -c 'trap "echo bad" 0; trap - 0; trap')
 [ -z "$traps" ] || exit 1
 
 traps=$(${SH} -c 'trap "echo bad" 0; trap - 0; trap')
 [ -z "$traps" ] || exit 1
diff --git a/sh/tests/builtins/trap17.0 b/sh/tests/builtins/trap17.0
new file mode 100644 (file)
index 0000000..35aafe7
--- /dev/null
@@ -0,0 +1,10 @@
+# $FreeBSD: head/bin/sh/tests/builtins/trap17.0 297360 2016-03-28 18:58:40Z jilles $
+# This use-after-free bug probably needs non-default settings to show up.
+
+v1=nothing v2=nothing
+trap 'trap "echo bad" USR1
+v1=trap_received
+v2=trap_invoked
+:' USR1
+kill -USR1 "$$"
+[ "$v1.$v2" = trap_received.trap_invoked ]
index a05287a16771f7defe0ed3f50c94639387ba3e7e..b64bb2457d2456f92a37d1f819e1406bbd63ec82 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/trap2.0 194517 2009-06-19 22:15:59Z jilles $
 # This is really a test for outqstr(), which is readily accessible via trap.
 
 runtest()
 # This is really a test for outqstr(), which is readily accessible via trap.
 
 runtest()
index 81607293531e1d795048561449a17b8ebc47b439..d442f8bd9766dbda53a9c46e301e2275b505c3e8 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/trap3.0 218889 2011-02-20 14:18:58Z jilles $
 
 {
        trap '' garbage && exit 3
 
 {
        trap '' garbage && exit 3
index 7f2080ee4dca5c34596a581019a84724212decc5..9fdab810f91cb88344a12bdcc2004c4350cdc9ae 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/trap4.0 217035 2011-01-05 23:17:29Z jilles $
 
 T=$(mktemp -d ${TMPDIR:-/tmp}/sh-test.XXXXXX)
 trap 'rm -rf $T' 0
 
 T=$(mktemp -d ${TMPDIR:-/tmp}/sh-test.XXXXXX)
 trap 'rm -rf $T' 0
index 56e0fb1b89fe52d8736d75f588a1136dfd5435d7..26eeb50013c81b1920b532c5e9bcc1366146cbd1 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/trap5.0 217461 2011-01-15 21:09:00Z jilles $
 
 set -e
 trap - USR1
 
 set -e
 trap - USR1
index bd2bf7efe769d04a011f709a9ac4fc5f1bf05961..1e79ae779b97f2fc0b6eaa7676884c86e8642b97 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/trap6.0 217472 2011-01-16 13:56:41Z jilles $
 
 v=$(
        ${SH} -c 'trap "echo ok; exit" USR1; kill -USR1 $$' &
 
 v=$(
        ${SH} -c 'trap "echo ok; exit" USR1; kill -USR1 $$' &
index 35529b80f4bf1eeb802d5dfd1a63454b2ea92d68..b62ffb720777f68455d0a2c2b0f45affe872a98d 100644 (file)
@@ -1,3 +1,3 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/trap7.0 217996 2011-01-27 23:08:20Z jilles $
 
 [ "$(trap 'echo trapped' EXIT)" = trapped ]
 
 [ "$(trap 'echo trapped' EXIT)" = trapped ]
index cdce976e36da34a44369a4607388b4672ec0d011..24752b1bafbf4a47415d68692ea14f77629968ed 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/trap8.0 218889 2011-02-20 14:18:58Z jilles $
 
 # I am not sure if POSIX requires the shell to continue processing
 # further trap names in the same trap command after an invalid one.
 
 # I am not sure if POSIX requires the shell to continue processing
 # further trap names in the same trap command after an invalid one.
index 0f584ecec584e15b5b015efe6ae9ae1b285bffc2..bbc35e945ea248bd8f8c62b6402451e58b58f582 100644 (file)
@@ -1,3 +1,3 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/trap9.0 230211 2012-01-16 10:59:44Z dumbbell $
 
 test "$(trap 'printf trap; echo ped' EXIT; f() { :; }; f)" = trapped || exit 1
 
 test "$(trap 'printf trap; echo ped' EXIT; f() { :; }; f)" = trapped || exit 1
index c5e456437946be2fe9a7702c5320048e54ab4205..2f04997ae87f4e73989f90d8a073345607afd125 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/type1.0 165931 2007-01-11 00:25:20Z stefanf $
 command -v not-here && exit 1
 command -v /not-here && exit 1
 command -V not-here && exit 1
 command -v not-here && exit 1
 command -v /not-here && exit 1
 command -V not-here && exit 1
index fe44d957fc0abf34027173739a3080dddec98905..7e0581e74c8ef2e60d871411e7cc989ac25913e3 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/type2.0 201344 2009-12-31 17:44:24Z jilles $
 
 failures=0
 
 
 failures=0
 
index 87cccdd812cc40ac3a6948544703255fba3e1a5c..dad07e9750fe5b304cfb7b73d5be54dba0b7957a 100644 (file)
@@ -1,3 +1,3 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/type3.0 255072 2013-08-30 12:09:59Z jilles $
 
 [ "$(type type)" = "$(type -- type)" ]
 
 [ "$(type type)" = "$(type -- type)" ]
index 34d8d6e07d2e1daed88febc9b571b1ddffc9a0e6..ffdc756c1475640b5360a1cbac6350db553c72dc 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/unalias.0 149781 2005-09-04 11:59:59Z stefanf $
 set -e
 
 alias false=true
 set -e
 
 alias false=true
index ace39c042d5f274b0c19e99826a7102e733f7184..d3766bb2dd35f9d79d7ba4feffe26c977af5c400 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/var-assign.0 213738 2010-10-12 18:20:38Z obrien $
 IFS=,
 
 SPECIAL="break,\
 IFS=,
 
 SPECIAL="break,\
index eafec89a681b3a8471fa62b4336175d6429d3891..b9afb5572e61d5180dc39a6965a57506b65f30b6 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/var-assign2.0 213738 2010-10-12 18:20:38Z obrien $
 IFS=,
 
 SPECIAL="break,\
 IFS=,
 
 SPECIAL="break,\
index 1ca85308c9acad4b2c2b1f235c545d6d8a5bd93c..8538415a6d015d19f955f4a62945f70ba57ff6c0 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/wait1.0 208476 2010-05-23 22:10:20Z jilles $
 
 failures=
 failure() {
 
 failures=
 failure() {
index 864fc78172764990877b91e156068b47d67549d4..c7e39757a94efc26643a49cd666c3a57ef0cfa76 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/wait10.0 251430 2013-06-05 19:40:52Z jilles $
 # Init cannot be a child of the shell.
 exit 49 & p49=$!
 wait 1 "$p49"
 # Init cannot be a child of the shell.
 exit 49 & p49=$!
 wait 1 "$p49"
index e61455cf5f0e83eeb1ca522ec78f70fa3c3b8289..71adfdefaa68710b2c5ae78ea7a6aa288960f48e 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/wait2.0 208476 2010-05-23 22:10:20Z jilles $
 
 failures=
 failure() {
 
 failures=
 failure() {
index 1ed52999630d61b4d9ecc0080036159826156082..d3561aec98fe3fde45c997467fb269102a074177 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/wait3.0 236771 2012-06-08 22:54:25Z jilles $
 
 failures=
 failure() {
 
 failures=
 failure() {
index 79351315d3846729b785dc367e56796ef27d8121..358513c81a8d2d9edc7a05349e99b8a765b10833 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/wait4.0 247206 2013-02-23 22:50:57Z jilles $
 
 T=`mktemp -d ${TMPDIR:-/tmp}/sh-test.XXXXXX`
 trap 'rm -rf $T' 0
 
 T=`mktemp -d ${TMPDIR:-/tmp}/sh-test.XXXXXX`
 trap 'rm -rf $T' 0
index 6874bf6693021c2f12733f40fe8acef7cb23cf63..48e1d2e756eb80a10fbc37ea87fd79e4f5281b82 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/wait5.0 247206 2013-02-23 22:50:57Z jilles $
 
 T=`mktemp -d ${TMPDIR:-/tmp}/sh-test.XXXXXX`
 trap 'rm -rf $T' 0
 
 T=`mktemp -d ${TMPDIR:-/tmp}/sh-test.XXXXXX`
 trap 'rm -rf $T' 0
index 20e3c6808679c937bc5c9d87f0859b62076b11d0..e87b9c9dbb65f657f8f014e507b3950e59bf6dfb 100644 (file)
@@ -1,3 +1,3 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/wait6.0 248349 2013-03-15 20:29:31Z jilles $
 
 wait --
 
 wait --
index 0fb092f8f614dc8b7154fb666a6f0f6278495481..2c50674bbc1c61936e2bc2e0d90c7796174631e4 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/wait7.0 248349 2013-03-15 20:29:31Z jilles $
 
 : &
 wait -- $!
 
 : &
 wait -- $!
index b59ff59622eba599ac07487a31f5037503a051e8..15e23b76b4773028ac2b496c56c033f03643e5c5 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/wait8.0 251429 2013-06-05 19:08:22Z jilles $
 
 exit 44 & p44=$!
 exit 45 & p45=$!
 
 exit 44 & p44=$!
 exit 45 & p45=$!
index 661f275421f84244bd050cb4a710704ab60edc32..9bed737f590cd88eaecf264279d33e2725b1689d 100644 (file)
@@ -1,3 +1,3 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/builtins/wait9.127 251430 2013-06-05 19:40:52Z jilles $
 # Init cannot be a child of the shell.
 wait 1
 # Init cannot be a child of the shell.
 wait 1
index ace9a01ccd7d3f0ad3df16b57f517ab2d4632500..d6904091021d70813a8e6abd365734df63bd0e4b 100644 (file)
@@ -1,32 +1,34 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/errors/Makefile 299094 2016-05-04 23:20:53Z ngie $
+
+PACKAGE=       tests
 
 TESTSDIR=      ${TESTSBASE}/bin/sh/${.CURDIR:T}
 
 .PATH: ${.CURDIR:H}
 ATF_TESTS_SH=  functional_test
 
 
 TESTSDIR=      ${TESTSBASE}/bin/sh/${.CURDIR:T}
 
 .PATH: ${.CURDIR:H}
 ATF_TESTS_SH=  functional_test
 
-FILESDIR=      ${TESTSDIR}
-
-FILES=         assignment-error1.0
-FILES+=                assignment-error2.0
-FILES+=                backquote-error1.0
-FILES+=                backquote-error2.0
-FILES+=                bad-binary1.126
-FILES+=                bad-keyword1.0
-FILES+=                bad-parm-exp1.0
-FILES+=                bad-parm-exp2.2 bad-parm-exp2.2.stderr
-FILES+=                bad-parm-exp3.2 bad-parm-exp3.2.stderr
-FILES+=                bad-parm-exp4.2 bad-parm-exp4.2.stderr
-FILES+=                bad-parm-exp5.2 bad-parm-exp5.2.stderr
-FILES+=                bad-parm-exp6.2 bad-parm-exp6.2.stderr
-FILES+=                option-error.0
-FILES+=                redirection-error.0
-FILES+=                redirection-error2.2
-FILES+=                redirection-error3.0
-FILES+=                redirection-error4.0
-FILES+=                redirection-error5.0
-FILES+=                redirection-error6.0
-FILES+=                redirection-error7.0
-FILES+=                write-error1.0
+${PACKAGE}FILES+=              assignment-error1.0
+${PACKAGE}FILES+=              assignment-error2.0
+${PACKAGE}FILES+=              backquote-error1.0
+${PACKAGE}FILES+=              backquote-error2.0
+${PACKAGE}FILES+=              bad-binary1.126
+${PACKAGE}FILES+=              bad-keyword1.0
+${PACKAGE}FILES+=              bad-parm-exp1.0
+${PACKAGE}FILES+=              bad-parm-exp2.2 bad-parm-exp2.2.stderr
+${PACKAGE}FILES+=              bad-parm-exp3.2 bad-parm-exp3.2.stderr
+${PACKAGE}FILES+=              bad-parm-exp4.2 bad-parm-exp4.2.stderr
+${PACKAGE}FILES+=              bad-parm-exp5.2 bad-parm-exp5.2.stderr
+${PACKAGE}FILES+=              bad-parm-exp6.2 bad-parm-exp6.2.stderr
+${PACKAGE}FILES+=              bad-parm-exp7.0
+${PACKAGE}FILES+=              bad-parm-exp8.0
+${PACKAGE}FILES+=              option-error.0
+${PACKAGE}FILES+=              redirection-error.0
+${PACKAGE}FILES+=              redirection-error2.2
+${PACKAGE}FILES+=              redirection-error3.0
+${PACKAGE}FILES+=              redirection-error4.0
+${PACKAGE}FILES+=              redirection-error5.0
+${PACKAGE}FILES+=              redirection-error6.0
+${PACKAGE}FILES+=              redirection-error7.0
+${PACKAGE}FILES+=              write-error1.0
 
 .include <bsd.test.mk>
 
 .include <bsd.test.mk>
diff --git a/sh/tests/errors/Makefile.depend b/sh/tests/errors/Makefile.depend
new file mode 100644 (file)
index 0000000..dbfdc34
--- /dev/null
@@ -0,0 +1,11 @@
+# $FreeBSD: head/bin/sh/tests/errors/Makefile.depend 296587 2016-03-09 22:46:01Z bdrewery $
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
index 00eaed9b8671e4d6b4ec1478f0b6798bfe995ede..2106b5a869bfff4494feb7ab635684aa0dc273d4 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/errors/assignment-error1.0 213738 2010-10-12 18:20:38Z obrien $
 IFS=,
 
 SPECIAL="break,\
 IFS=,
 
 SPECIAL="break,\
index ff4e6299526205033f8625ce8f07570e4a863ee9..68f2d4869957939f30f3b02204b904da6a6ac680 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/errors/assignment-error2.0 216870 2011-01-01 13:26:18Z jilles $
 
 set -e
 HOME=/
 
 set -e
 HOME=/
index 43e33034af9f9ff0fb9c53f430cdb98578b7e5ec..d35d0b71a6df30d0f74de469fed17518d99e896c 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/errors/backquote-error1.0 213738 2010-10-12 18:20:38Z obrien $
 
 echo 'echo `for` echo ".BAD"CODE.' | ${SH} +m -i 2>&1 | grep -q BADCODE && exit 1
 exit 0
 
 echo 'echo `for` echo ".BAD"CODE.' | ${SH} +m -i 2>&1 | grep -q BADCODE && exit 1
 exit 0
index 5b49e2be17ce81495de41705b49f6edb4ff13ac4..a5955dd308588e8cab44bea46af940b82e525b81 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/errors/backquote-error2.0 213738 2010-10-12 18:20:38Z obrien $
 
 ${SH} -c 'echo `echo .BA"DCODE.`
 echo ".BAD"CODE.' 2>&1 | grep -q BADCODE && exit 1
 
 ${SH} -c 'echo `echo .BA"DCODE.`
 echo ".BAD"CODE.' 2>&1 | grep -q BADCODE && exit 1
index d92e9ded56892d61e35f82950986473a58529a09..7c7c67f26a4f011d9d90dc681ce3c09bda5a215c 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/errors/bad-binary1.126 218320 2011-02-05 12:54:59Z jilles $
 # Checking for binary "scripts" without magic number is permitted but not
 # required by POSIX. However, it is preferable to getting errors like
 # Syntax error: word unexpected (expecting ")")
 # Checking for binary "scripts" without magic number is permitted but not
 # required by POSIX. However, it is preferable to getting errors like
 # Syntax error: word unexpected (expecting ")")
index ac0153655f8d19b9528b275568ab6cff971ab38e..d2680d6799ad9d73c4d3e51d8b1f37424932c7dd 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/errors/bad-keyword1.0 216398 2010-12-12 21:18:16Z jilles $
 
 echo ':; fi' | ${SH} -n 2>/dev/null && exit 1
 exit 0
 
 echo ':; fi' | ${SH} -n 2>/dev/null && exit 1
 exit 0
index 6e949945f9f3278e19641a0c300018da34491408..f2882941126211b0aa56e319060cdb1f786645af 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/errors/bad-parm-exp1.0 164004 2006-11-05 18:41:23Z stefanf $
 false && {
        ${}
        ${foo/}
 false && {
        ${}
        ${foo/}
index a0826ecf9a8b81aeb4d1cd320d2b4522dfb8b7dc..7424840a2873627626b16d03b4a1877d4f79e5d0 100644 (file)
@@ -1,2 +1,2 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/errors/bad-parm-exp2.2 270101 2014-08-17 14:26:12Z jilles $
 eval '${}'
 eval '${}'
index bb41208f258d0718eff175c63b8c11662984de49..56a52dff7f5cf4e57189d68b7c77903cd6c1ecfb 100644 (file)
@@ -1,2 +1,2 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/errors/bad-parm-exp3.2 270101 2014-08-17 14:26:12Z jilles $
 eval '${foo/}'
 eval '${foo/}'
index 2837f9b5be9e2baf02faae99ff43f09ce210c5d8..e0a7099dc6cd1b3c4c2f1e5d1673f96ea7269d83 100644 (file)
@@ -1,2 +1,2 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/errors/bad-parm-exp4.2 270101 2014-08-17 14:26:12Z jilles $
 eval '${foo:@abc}'
 eval '${foo:@abc}'
index 1ba343bb710d713d9d624eb89c0b958dbf5da9db..fa26259720265922cf1cadf15e9cfba28b5805d4 100644 (file)
@@ -1,2 +1,2 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/errors/bad-parm-exp5.2 270101 2014-08-17 14:26:12Z jilles $
 eval '${/}'
 eval '${/}'
index b53a91b364b5f6f2f35fe7a1ebfb9ecc438e162d..51858e8062590ad807fbd8201633988f094e1b63 100644 (file)
@@ -1,2 +1,2 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/errors/bad-parm-exp6.2 270101 2014-08-17 14:26:12Z jilles $
 eval '${#foo^}'
 eval '${#foo^}'
diff --git a/sh/tests/errors/bad-parm-exp7.0 b/sh/tests/errors/bad-parm-exp7.0
new file mode 100644 (file)
index 0000000..d7bff92
--- /dev/null
@@ -0,0 +1,4 @@
+# $FreeBSD: head/bin/sh/tests/errors/bad-parm-exp7.0 287081 2015-08-23 20:44:53Z jilles $
+
+v=1
+eval ": $(printf '${v-${\372}}')"
diff --git a/sh/tests/errors/bad-parm-exp8.0 b/sh/tests/errors/bad-parm-exp8.0
new file mode 100644 (file)
index 0000000..24f6bff
--- /dev/null
@@ -0,0 +1,4 @@
+# $FreeBSD: head/bin/sh/tests/errors/bad-parm-exp8.0 287081 2015-08-23 20:44:53Z jilles $
+
+v=1
+eval ": $(printf '${v-${w\372}}')"
index b4b44c4a4062c2fe03825e5bf81c25b5d8ebb93d..473c0b97cbc651e1553e0b4944d92700164d6e9d 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/errors/option-error.0 213738 2010-10-12 18:20:38Z obrien $
 IFS=,
 
 SPECIAL="break abc,\
 IFS=,
 
 SPECIAL="break abc,\
index cb8c0b113c139c8e23d925bbc3138e0d73f11d6d..2a676983d3aba0142c9f3bde1f9eb1e68f87946b 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/errors/redirection-error.0 213738 2010-10-12 18:20:38Z obrien $
 IFS=,
 
 SPECIAL="break,\
 IFS=,
 
 SPECIAL="break,\
index 32bccd8e784abccad4af724a952fa90545a00090..595e959b8c6c05b6b8eae4af00c40bd9d6fa393a 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/errors/redirection-error2.2 213738 2010-10-12 18:20:38Z obrien $
 
 # sh should fail gracefully on this bad redirect
 ${SH} -c 'echo 1 >&$a' 2>/dev/null
 
 # sh should fail gracefully on this bad redirect
 ${SH} -c 'echo 1 >&$a' 2>/dev/null
index 8a07d037baec5ff15588dd56c805973232a8acb2..fd7a334cc3800f2e3921e5f707d4b13237309c5e 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/errors/redirection-error3.0 213738 2010-10-12 18:20:38Z obrien $
 IFS=,
 
 SPECIAL="break,\
 IFS=,
 
 SPECIAL="break,\
index 206097478e358e6b9b64400448fc2df6966a8ec7..ed58499f7d8b2786f016a1b1b552c4bc348890db 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/errors/redirection-error4.0 205138 2010-03-13 22:53:17Z jilles $
 # A redirection error should not abort the shell if there is no command word.
 exec 2>/dev/null
 </var/empty/x
 # A redirection error should not abort the shell if there is no command word.
 exec 2>/dev/null
 </var/empty/x
index 1fcd47eebf960ebf95c04973458e127adf5c2e47..b96c14e3a46146395294286b986dc300f8271837 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/errors/redirection-error5.0 205153 2010-03-14 13:51:12Z jilles $
 # A redirection error on a subshell should not abort the shell.
 exec 2>/dev/null
 ( echo bad ) </var/empty/x
 # A redirection error on a subshell should not abort the shell.
 exec 2>/dev/null
 ( echo bad ) </var/empty/x
index 17d1109b390f949735164632fb22f87a6801651f..1d84e6ccad70321bf80da4f071936060470f2a32 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/errors/redirection-error6.0 205154 2010-03-14 14:24:35Z jilles $
 # A redirection error on a compound command should not abort the shell.
 exec 2>/dev/null
 { echo bad; } </var/empty/x
 # A redirection error on a compound command should not abort the shell.
 exec 2>/dev/null
 { echo bad; } </var/empty/x
index 5b20f04beb83d6f8a941b9bfde44067fa437ec96..ef5643499ad5cd6143636c657e57208079b4bf24 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/errors/redirection-error7.0 216851 2010-12-31 18:20:17Z jilles $
 
 ! dummy=$(
        exec 3>&1 >&2 2>&3
 
 ! dummy=$(
        exec 3>&1 >&2 2>&3
index fcb52e74178c5fceacfef0326836e6f8f8a68a5d..3001e5c82ca432665d507194a345f31c9ad6b642 100644 (file)
@@ -1,3 +1,3 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/errors/write-error1.0 244924 2013-01-01 12:48:24Z jilles $
 
 ! echo >&- 2>/dev/null
 
 ! echo >&- 2>/dev/null
index 638492bb96adfa654827272b441d055d860a63a6..b3e99ee15e6258c9c64ef61c8896a88fb8a8c5cf 100644 (file)
@@ -1,56 +1,56 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/execution/Makefile 299094 2016-05-04 23:20:53Z ngie $
+
+PACKAGE=       tests
 
 TESTSDIR=      ${TESTSBASE}/bin/sh/${.CURDIR:T}
 
 .PATH: ${.CURDIR:H}
 ATF_TESTS_SH=  functional_test
 
 
 TESTSDIR=      ${TESTSBASE}/bin/sh/${.CURDIR:T}
 
 .PATH: ${.CURDIR:H}
 ATF_TESTS_SH=  functional_test
 
-FILESDIR=      ${TESTSDIR}
-
-FILES=         bg1.0
-FILES+=                bg2.0
-FILES+=                bg3.0
-FILES+=                bg4.0
-FILES+=                bg5.0
-FILES+=                bg6.0 bg6.0.stdout
-FILES+=                bg7.0
-FILES+=                bg8.0
-FILES+=                bg9.0
-FILES+=                bg10.0 bg10.0.stdout
-FILES+=                fork1.0
-FILES+=                fork2.0
-FILES+=                fork3.0
-FILES+=                func1.0
-FILES+=                func2.0
-FILES+=                func3.0
-FILES+=                hash1.0
-FILES+=                int-cmd1.0
-FILES+=                killed1.0
-FILES+=                killed2.0
-FILES+=                not1.0
-FILES+=                not2.0
-FILES+=                path1.0
-FILES+=                redir1.0
-FILES+=                redir2.0
-FILES+=                redir3.0
-FILES+=                redir4.0
-FILES+=                redir5.0
-FILES+=                redir6.0
-FILES+=                redir7.0
-FILES+=                set-n1.0
-FILES+=                set-n2.0
-FILES+=                set-n3.0
-FILES+=                set-n4.0
-FILES+=                set-x1.0
-FILES+=                set-x2.0
-FILES+=                set-x3.0
-FILES+=                set-x4.0
-FILES+=                shellproc1.0
-FILES+=                subshell1.0 subshell1.0.stdout
-FILES+=                subshell2.0
-FILES+=                subshell3.0
-FILES+=                subshell4.0
-FILES+=                unknown1.0
-FILES+=                var-assign1.0
+${PACKAGE}FILES+=              bg1.0
+${PACKAGE}FILES+=              bg2.0
+${PACKAGE}FILES+=              bg3.0
+${PACKAGE}FILES+=              bg4.0
+${PACKAGE}FILES+=              bg5.0
+${PACKAGE}FILES+=              bg6.0 bg6.0.stdout
+${PACKAGE}FILES+=              bg7.0
+${PACKAGE}FILES+=              bg8.0
+${PACKAGE}FILES+=              bg9.0
+${PACKAGE}FILES+=              bg10.0 bg10.0.stdout
+${PACKAGE}FILES+=              fork1.0
+${PACKAGE}FILES+=              fork2.0
+${PACKAGE}FILES+=              fork3.0
+${PACKAGE}FILES+=              func1.0
+${PACKAGE}FILES+=              func2.0
+${PACKAGE}FILES+=              func3.0
+${PACKAGE}FILES+=              hash1.0
+${PACKAGE}FILES+=              int-cmd1.0
+${PACKAGE}FILES+=              killed1.0
+${PACKAGE}FILES+=              killed2.0
+${PACKAGE}FILES+=              not1.0
+${PACKAGE}FILES+=              not2.0
+${PACKAGE}FILES+=              path1.0
+${PACKAGE}FILES+=              redir1.0
+${PACKAGE}FILES+=              redir2.0
+${PACKAGE}FILES+=              redir3.0
+${PACKAGE}FILES+=              redir4.0
+${PACKAGE}FILES+=              redir5.0
+${PACKAGE}FILES+=              redir6.0
+${PACKAGE}FILES+=              redir7.0
+${PACKAGE}FILES+=              set-n1.0
+${PACKAGE}FILES+=              set-n2.0
+${PACKAGE}FILES+=              set-n3.0
+${PACKAGE}FILES+=              set-n4.0
+${PACKAGE}FILES+=              set-x1.0
+${PACKAGE}FILES+=              set-x2.0
+${PACKAGE}FILES+=              set-x3.0
+${PACKAGE}FILES+=              set-x4.0
+${PACKAGE}FILES+=              shellproc1.0
+${PACKAGE}FILES+=              subshell1.0 subshell1.0.stdout
+${PACKAGE}FILES+=              subshell2.0
+${PACKAGE}FILES+=              subshell3.0
+${PACKAGE}FILES+=              subshell4.0
+${PACKAGE}FILES+=              unknown1.0
+${PACKAGE}FILES+=              var-assign1.0
 
 .include <bsd.test.mk>
 
 .include <bsd.test.mk>
diff --git a/sh/tests/execution/Makefile.depend b/sh/tests/execution/Makefile.depend
new file mode 100644 (file)
index 0000000..fac3607
--- /dev/null
@@ -0,0 +1,11 @@
+# $FreeBSD: head/bin/sh/tests/execution/Makefile.depend 296587 2016-03-09 22:46:01Z bdrewery $
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
index edb92ae2ddd09aac3a000a58c297f33d16ce7cbe..95b51c6c12a5aee98d37b5f834796d639b9e8789 100644 (file)
@@ -1,3 +1,3 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/execution/bg1.0 221027 2011-04-25 20:54:12Z jilles $
 
 : `false` &
 
 : `false` &
index 44a25dc23b2e1f8534cecfbaffa47bbcec33f4e6..06a27f48c1208820e6e350638e50be05b52d32a2 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/execution/bg10.0 258535 2013-11-24 23:12:13Z jilles $
 # The redirection overrides the </dev/null implicit in a background command.
 
 echo yes | ${SH} -c '{ cat & wait; } <&0'
 # The redirection overrides the </dev/null implicit in a background command.
 
 echo yes | ${SH} -c '{ cat & wait; } <&0'
index 2e2fbc53bd26331b93684b53024df90f7e761853..74ee54af8118e70e05db9a37731cdbee4d19482e 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/execution/bg2.0 221027 2011-04-25 20:54:12Z jilles $
 
 f() { return 42; }
 f
 
 f() { return 42; }
 f
index 359fc6f476e6d16061a11739e8d977063ee0240c..95f37d3584024a77fefdf8e8b2b53fe9e99f2187 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/execution/bg3.0 221027 2011-04-25 20:54:12Z jilles $
 
 f() { return 42; }
 f
 
 f() { return 42; }
 f
index 25e4f4e34fa5ed247c22f576a60382e28d8c45e2..1220fd3f47b146a52ce27860b0044dcc24cd0d00 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/execution/bg4.0 223283 2011-06-19 00:00:36Z jilles $
 
 x=''
 : ${x:=1} &
 
 x=''
 : ${x:=1} &
index cc9ceaa41d4e5e276e5e5ec3c0e846669b432922..e820035a7bd1ad7765c44c0843c19a4a2bdbfa05 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/execution/bg5.0 258489 2013-11-22 21:50:13Z jilles $
 # A background command has an implicit </dev/null redirection.
 
 echo bad | ${SH} -c '{ cat & wait; }'
 # A background command has an implicit </dev/null redirection.
 
 echo bad | ${SH} -c '{ cat & wait; }'
index b0faf9e73708ef922c96938f35942700c9f894e3..466adc2a8d3312586b94b0920b233b1b81d4ed36 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/execution/bg6.0 258489 2013-11-22 21:50:13Z jilles $
 # The redirection overrides the </dev/null implicit in a background command.
 
 echo yes | ${SH} -c '{ cat & wait; } </dev/stdin'
 # The redirection overrides the </dev/null implicit in a background command.
 
 echo yes | ${SH} -c '{ cat & wait; } </dev/stdin'
index f771edc56cdeeab7fb51965c61d60a0a1d53c8be..788161ea600c0622f51f2f03d3e55d7c20b410fd 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/execution/bg7.0 258533 2013-11-24 22:45:49Z jilles $
 # The redirection does not apply to the background command, and therefore
 # does not override the implicit </dev/null.
 
 # The redirection does not apply to the background command, and therefore
 # does not override the implicit </dev/null.
 
index 33667cb1922bf9b70e3169eb976188ad0a4b4781..aa571dca13f0383a07e51c303d863a62e226fe8c 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/execution/bg8.0 258533 2013-11-24 22:45:49Z jilles $
 # The redirection does not apply to the background command, and therefore
 # does not override the implicit </dev/null.
 
 # The redirection does not apply to the background command, and therefore
 # does not override the implicit </dev/null.
 
index 64fde3e3e333ab206447e7bab67f40c2440e5576..4af1bae76a5efa03b7178b2ab58caf56da38cb19 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/execution/bg9.0 258533 2013-11-24 22:45:49Z jilles $
 # The redirection does not apply to the background command, and therefore
 # does not override the implicit </dev/null.
 
 # The redirection does not apply to the background command, and therefore
 # does not override the implicit </dev/null.
 
index 2eeac79ae8c3fced2e343d663d9b2e0ee5bc94c7..80b013b44e5e0a6003a577ac0aeb7f342812453c 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/execution/fork1.0 218850 2011-02-19 13:22:18Z jilles $
 
 shname=${SH%% *}
 shname=${shname##*/}
 
 shname=${SH%% *}
 shname=${shname##*/}
index 62a25379123cd646897c809fc7bcba6c1db26be9..2639165b4dd78ad740b9d35e1701733b33a40101 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/execution/fork2.0 213738 2010-10-12 18:20:38Z obrien $
 
 result=$(${SH} -c '(/bin/sleep 1)& sleep 0.1; ps -p $! -o comm=; kill $!')
 test "$result" = sleep || exit 1
 
 result=$(${SH} -c '(/bin/sleep 1)& sleep 0.1; ps -p $! -o comm=; kill $!')
 test "$result" = sleep || exit 1
index 3cb678c2d08a4d787a0a509fba910095a8f0666e..008be7bf43c00b945fe8dd4e219d74bd25fb0854 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/execution/fork3.0 220978 2011-04-23 22:28:56Z jilles $
 
 result=$(${SH} -c 'f() { ps -p $$ -o comm=; }; f')
 test "$result" = "ps"
 
 result=$(${SH} -c 'f() { ps -p $$ -o comm=; }; f')
 test "$result" = "ps"
index 29fcc077b592330c9de85c08474b206c529ac37d..1af549574b0676bbd043c1ebba77d6e272e702a4 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/execution/func1.0 213738 2010-10-12 18:20:38Z obrien $
 
 MALLOC_OPTIONS=J ${SH} -c 'g() { g() { :; }; :; }; g' &&
 MALLOC_OPTIONS=J ${SH} -c 'g() { unset -f g; :; }; g'
 
 MALLOC_OPTIONS=J ${SH} -c 'g() { g() { :; }; :; }; g' &&
 MALLOC_OPTIONS=J ${SH} -c 'g() { unset -f g; :; }; g'
index 9830b5e8a7cf62d1e9aa94a1ad3b9a271ca4b32c..eb48cc8a5331f05314bb56026bf20780339b0e02 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/execution/func2.0 211399 2010-08-16 17:18:08Z jilles $
 # The empty pairs of braces here are to test that this does not cause a crash.
 
 f() { }
 # The empty pairs of braces here are to test that this does not cause a crash.
 
 f() { }
index e0ed581f85eff6a28a8dfdcbcb46261514a2e171..209e25526c8ae576be06ea9b333915c4eee7a154 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/execution/func3.0 216398 2010-12-12 21:18:16Z jilles $
 
 # This may fail when parsing or when defining the function, or the definition
 # may silently do nothing. In no event may the function be executed.
 
 # This may fail when parsing or when defining the function, or the definition
 # may silently do nothing. In no event may the function be executed.
index a645c2aef73535e6d33879805103b2d1511bf949..d0192966255d8ebda637014d078789ab16f5acd7 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/execution/hash1.0 218323 2011-02-05 14:01:46Z jilles $
 
 T=`mktemp -d "${TMPDIR:-/tmp}/sh-test.XXXXXXXX"` || exit
 trap 'rm -rf "${T}"' 0
 
 T=`mktemp -d "${TMPDIR:-/tmp}/sh-test.XXXXXXXX"` || exit
 trap 'rm -rf "${T}"' 0
index a1f097b774d61c7378f62f9e46726f0cb35b5f08..e98046129bcdb13335c80856e689f73cf899a828 100644 (file)
@@ -1,3 +1,3 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/execution/int-cmd1.0 253271 2013-07-12 15:29:41Z jilles $
 
 ! echo echo bad | $SH -ic 'fi' 2>/dev/null
 
 ! echo echo bad | $SH -ic 'fi' 2>/dev/null
index 41d3e055723edf0b67f2a17d29b99c07e43f81fc..ef9221d8aa8d6a96e9b656505c702f75ed220c6b 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/execution/killed1.0 217557 2011-01-18 21:18:31Z jilles $
 # Sometimes the "Killed" message is not flushed soon enough and it
 # is redirected along with the output of a builtin.
 # Do not change the semicolon to a newline as it would hide the bug.
 # Sometimes the "Killed" message is not flushed soon enough and it
 # is redirected along with the output of a builtin.
 # Do not change the semicolon to a newline as it would hide the bug.
index 7ff3fe2900d19dc25f6d034d0447d5b734a8c159..4d6de1656e6af7a1340b6325ba0fa0a736a5b76c 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/execution/killed2.0 218105 2011-01-30 22:57:52Z jilles $
 # Most shells print a message when a foreground job is killed by a signal.
 # POSIX allows this, provided the message is sent to stderr, not stdout.
 # Some trickery is needed to capture the message as redirecting stderr of
 # Most shells print a message when a foreground job is killed by a signal.
 # POSIX allows this, provided the message is sent to stderr, not stdout.
 # Some trickery is needed to capture the message as redirecting stderr of
index 12c6265a92829b9352c1910a0f3b508178c7d334..c825e1327bbdc19641e31fbd6aee9d7786079ca8 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/execution/not1.0 249407 2013-04-12 15:19:35Z jilles $
 
 f() { ! return $1; }
 f 0 && ! f 1
 
 f() { ! return $1; }
 f 0 && ! f 1
index 1b128d0967164d79f6391ea18a34e0bf6ec72908..e4155a9348cb4bb4668dd1d7aab17943f706e6b2 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/execution/not2.0 249407 2013-04-12 15:19:35Z jilles $
 
 while :; do
        ! break
 
 while :; do
        ! break
index 50829d629a4d8f8999b785303218ad16a5f42417..3d5c67be1a5734f97fb5195472c5fbd996e04cbf 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/execution/path1.0 217206 2011-01-09 21:07:30Z jilles $
 # Some builtins should not be overridable via PATH.
 
 set -e
 # Some builtins should not be overridable via PATH.
 
 set -e
index dd0011f064b0d741102360dc2173d336a5a93e2b..6310478d4e3d3e352890df35f8e22c0fe6bd8090 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/execution/redir1.0 211408 2010-08-16 22:23:19Z jilles $
 trap ': $((brokenpipe+=1))' PIPE
 
 P=${TMPDIR:-/tmp}
 trap ': $((brokenpipe+=1))' PIPE
 
 P=${TMPDIR:-/tmp}
index 1588105f599a0a65cb2b926656527e007b43ae41..27509c71d6b6347ffcd09d2c2d94c30f620fe96b 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/execution/redir2.0 213738 2010-10-12 18:20:38Z obrien $
 trap ': $((brokenpipe+=1))' PIPE
 
 P=${TMPDIR:-/tmp}
 trap ': $((brokenpipe+=1))' PIPE
 
 P=${TMPDIR:-/tmp}
index d68e4504ed3d979b55c6f1500c37f7cd0ddd7ce5..1b7209838aedf4b7fd0b8c910ae27ac2bf37e35c 100644 (file)
@@ -1,3 +1,3 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/execution/redir3.0 214289 2010-10-24 19:56:34Z jilles $
 
 3>&- 3>&-
 
 3>&- 3>&-
index 57054c17c45f60e1d44a96bd4c9d14abaf52f6c2..01b1f87836e88ccde692c494226015315e7e5729 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/execution/redir4.0 214290 2010-10-24 20:09:49Z jilles $
 
 { echo bad 0>&3; } 2>/dev/null 3>/dev/null 3>&-
 exit 0
 
 { echo bad 0>&3; } 2>/dev/null 3>/dev/null 3>&-
 exit 0
index 707ca68f737a8e3826b4d4be4c310803914a169a..346c132dc849316a11d1d43ebe5732b73f68a067 100644 (file)
@@ -1,3 +1,3 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/execution/redir5.0 218325 2011-02-05 15:02:19Z jilles $
 
 { (echo bad) >/dev/null; } </dev/null
 
 { (echo bad) >/dev/null; } </dev/null
index 4e3ac0cae055d9bdb02b61eae96a683ed74ad3c5..f663e51c933a3ea0004ea2719f858d4f45fa120f 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/execution/redir6.0 220978 2011-04-23 22:28:56Z jilles $
 
 failures=0
 
 
 failures=0
 
index 2487bcf2fc0da606f318b7d41cd4e3f64c1b7318..0e309a7cfef68bf30b2ba2f7ffb810dec9d834d4 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/execution/redir7.0 220978 2011-04-23 22:28:56Z jilles $
 
 failures=0
 
 
 failures=0
 
index 14c9b9396ada6e64060bb370e6fe8086a70e146b..95eb98c2f44e79f9df4d487365cff6f4f9400112 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/execution/set-n1.0 222661 2011-06-03 21:17:42Z jilles $
 
 v=$( ($SH -n <<'EOF'
 for
 
 v=$( ($SH -n <<'EOF'
 for
index c7f31629f474984b4127b32eaa7f1d7defc0dfbd..d64fcca622f2207dcd358a505403b08887e75720 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/execution/set-n2.0 222661 2011-06-03 21:17:42Z jilles $
 
 $SH -n <<'EOF'
 echo bad
 
 $SH -n <<'EOF'
 echo bad
index 24a9159fdeb9e2a804c15abaae1c3c225d765995..5af1bc46975c476600d24055afe0ca14f7a31f39 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/execution/set-n3.0 222661 2011-06-03 21:17:42Z jilles $
 
 v=$( ($SH -nc 'for') 2>&1 >/dev/null)
 [ $? -ne 0 ] && [ -n "$v" ]
 
 v=$( ($SH -nc 'for') 2>&1 >/dev/null)
 [ $? -ne 0 ] && [ -n "$v" ]
index 36985084b26b0a6fcd91a2211c576d8bc129e4d2..2904a34e303569a3575049ee1efc99d72d0cc09e 100644 (file)
@@ -1,3 +1,3 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/execution/set-n4.0 222676 2011-06-04 11:28:42Z jilles $
 
 $SH -nc 'echo bad'
 
 $SH -nc 'echo bad'
index 7fe1dbf1076b1cf3dec6b490863b5f75a6e9bb42..e498a3f2eaa8df182896e1ff3a31a66505cfc567 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/execution/set-x1.0 222882 2011-06-08 21:58:19Z jilles $
 
 key='must_contain_this'
 { r=`set -x; { : "$key"; } 2>&1 >/dev/null`; } 2>/dev/null
 
 key='must_contain_this'
 { r=`set -x; { : "$key"; } 2>&1 >/dev/null`; } 2>/dev/null
index 56d54e38d2514d60e0de775e55d9e549002c1afd..42c66a6c9bf26d53030919d62555d38149b36f2b 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/execution/set-x2.0 222882 2011-06-08 21:58:19Z jilles $
 
 key='must contain this'
 PS4="$key+ "
 
 key='must contain this'
 PS4="$key+ "
index 1ca57aca6baa897f8ec2b11b556cf4592ac8d6ad..29a917ee8c55a703d689f613fb5283a7864aca04 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/execution/set-x3.0 222907 2011-06-09 23:12:23Z jilles $
 
 key='must contain this'
 PS4='$key+ '
 
 key='must contain this'
 PS4='$key+ '
index 0904766ccdd14ee588d993227daeb8ce18937d5e..90dd59a235a050d6bf7d7b2a49d7db9797d1e8a6 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/execution/set-x4.0 275766 2014-12-14 16:26:19Z jilles $
 
 key=`printf '\r\t\001\200\300'`
 r=`{ set -x; : "$key"; } 2>&1 >/dev/null`
 
 key=`printf '\r\t\001\200\300'`
 r=`{ set -x; : "$key"; } 2>&1 >/dev/null`
index 1326bc27f1c101bacc6cdf74aa6e28cf2cc888b2..5150b731ccb6fc7cd7b053a1242300ade7973bc7 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/execution/shellproc1.0 218205 2011-02-02 22:03:18Z jilles $
 
 T=`mktemp -d "${TMPDIR:-/tmp}/sh-test.XXXXXXXX"` || exit
 trap 'rm -rf "${T}"' 0
 
 T=`mktemp -d "${TMPDIR:-/tmp}/sh-test.XXXXXXXX"` || exit
 trap 'rm -rf "${T}"' 0
index 347806ed45aca35e3a25c7c6c615d5447467d168..68b0123dd6e873fac9d378f64f1b50c653854d46 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/execution/subshell1.0 245383 2013-01-13 19:39:13Z jilles $
 
 (eval "cd /
 v=$(printf %0100000d 1)
 
 (eval "cd /
 v=$(printf %0100000d 1)
index 32164495c9ca6c233043a972c988ecbe0ed86e7e..2d8773005f81f8b3760f96f3f78d95efc189478b 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/execution/subshell2.0 245383 2013-01-13 19:39:13Z jilles $
 
 f() {
        x=2
 
 f() {
        x=2
index 9a87acb15e1ccb7480ed864baaf8f351fee8e1d5..697ee0bdacd159e9bfe92574f5fcb41175644d96 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/execution/subshell3.0 245383 2013-01-13 19:39:13Z jilles $
 
 (false; exit) && exit 3
 exit 0
 
 (false; exit) && exit 3
 exit 0
index b39edb12eb2c73e8a1ae077841c0d633d1c2c266..009db3d0c3723833ab0bd14c8c4f8ad3bf2bcaa8 100644 (file)
@@ -1,3 +1,3 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/execution/subshell4.0 245383 2013-01-13 19:39:13Z jilles $
 
 (eval "set v=1"; false) && echo bad; :
 
 (eval "set v=1"; false) && echo bad; :
index 45f541e6eeea12a99ec3bfaf43a52185ba067326..dd4149ee95e95ad7e801cc349dad1a351098e826 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/execution/unknown1.0 197820 2009-10-06 22:00:14Z jilles $
 
 nosuchtool 2>/dev/null
 [ $? -ne 127 ] && exit 1
 
 nosuchtool 2>/dev/null
 [ $? -ne 127 ] && exit 1
index 26e54249c1cc422bf74d76a069774a3ad6c17c57..b75f96942a3e307e7003a5c994269e36f151dd19 100644 (file)
@@ -1,3 +1,3 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/execution/var-assign1.0 212467 2010-09-11 14:15:50Z jilles $
 
 [ "$(HOME=/etc HOME=/ cd && pwd)" = / ]
 
 [ "$(HOME=/etc HOME=/ cd && pwd)" = / ]
index e359ae7ee014b0236a945d877e91c70fc9016065..734d4f3021766c612e7df248eb3a94eec5a85409 100644 (file)
@@ -1,94 +1,96 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/Makefile 302937 2016-07-16 13:26:18Z ache $
+
+PACKAGE=       tests
 
 TESTSDIR=      ${TESTSBASE}/bin/sh/${.CURDIR:T}
 
 .PATH: ${.CURDIR:H}
 ATF_TESTS_SH=  functional_test
 
 
 TESTSDIR=      ${TESTSBASE}/bin/sh/${.CURDIR:T}
 
 .PATH: ${.CURDIR:H}
 ATF_TESTS_SH=  functional_test
 
-FILESDIR=      ${TESTSDIR}
-
-FILES=         arith1.0
-FILES+=                arith2.0
-FILES+=                arith3.0
-FILES+=                arith4.0
-FILES+=                arith5.0
-FILES+=                arith6.0
-FILES+=                arith7.0
-FILES+=                arith8.0
-FILES+=                arith9.0
-FILES+=                arith10.0
-FILES+=                arith11.0
-FILES+=                arith12.0
-FILES+=                arith13.0
-FILES+=                arith14.0
-FILES+=                assign1.0
-FILES+=                cmdsubst1.0
-FILES+=                cmdsubst2.0
-FILES+=                cmdsubst3.0
-FILES+=                cmdsubst4.0
-FILES+=                cmdsubst5.0
-FILES+=                cmdsubst6.0
-FILES+=                cmdsubst7.0
-FILES+=                cmdsubst8.0
-FILES+=                cmdsubst9.0
-FILES+=                cmdsubst10.0
-FILES+=                cmdsubst11.0
-FILES+=                cmdsubst12.0
-FILES+=                cmdsubst13.0
-FILES+=                cmdsubst14.0
-FILES+=                cmdsubst15.0
-FILES+=                cmdsubst16.0
-FILES+=                cmdsubst17.0
-FILES+=                export1.0
-FILES+=                export2.0
-FILES+=                export3.0
-FILES+=                heredoc1.0
-FILES+=                heredoc2.0
-FILES+=                ifs1.0
-FILES+=                ifs2.0
-FILES+=                ifs3.0
-FILES+=                ifs4.0
-FILES+=                ifs5.0
-FILES+=                ifs6.0
-FILES+=                ifs7.0
-FILES+=                length1.0
-FILES+=                length2.0
-FILES+=                length3.0
-FILES+=                length4.0
-FILES+=                length5.0
-FILES+=                length6.0
-FILES+=                length7.0
-FILES+=                length8.0
-FILES+=                local1.0
-FILES+=                local2.0
-FILES+=                pathname1.0
-FILES+=                pathname2.0
-FILES+=                pathname3.0
-FILES+=                pathname4.0
-FILES+=                pathname5.0
-FILES+=                plus-minus1.0
-FILES+=                plus-minus2.0
-FILES+=                plus-minus3.0
-FILES+=                plus-minus4.0
-FILES+=                plus-minus5.0
-FILES+=                plus-minus6.0
-FILES+=                plus-minus7.0
-FILES+=                plus-minus8.0
-FILES+=                question1.0
-FILES+=                readonly1.0
-FILES+=                redir1.0
-FILES+=                set-u1.0
-FILES+=                set-u2.0
-FILES+=                set-u3.0
-FILES+=                tilde1.0
-FILES+=                tilde2.0
-FILES+=                trim1.0
-FILES+=                trim2.0
-FILES+=                trim3.0
-FILES+=                trim4.0
-FILES+=                trim5.0
-FILES+=                trim6.0
-FILES+=                trim7.0
-FILES+=                trim8.0
+${PACKAGE}FILES+=      arith1.0
+${PACKAGE}FILES+=      arith2.0
+${PACKAGE}FILES+=      arith3.0
+${PACKAGE}FILES+=      arith4.0
+${PACKAGE}FILES+=      arith5.0
+${PACKAGE}FILES+=      arith6.0
+${PACKAGE}FILES+=      arith7.0
+${PACKAGE}FILES+=      arith8.0
+${PACKAGE}FILES+=      arith9.0
+${PACKAGE}FILES+=      arith10.0
+${PACKAGE}FILES+=      arith11.0
+${PACKAGE}FILES+=      arith12.0
+${PACKAGE}FILES+=      arith13.0
+${PACKAGE}FILES+=      arith14.0
+${PACKAGE}FILES+=      assign1.0
+${PACKAGE}FILES+=      cmdsubst1.0
+${PACKAGE}FILES+=      cmdsubst2.0
+${PACKAGE}FILES+=      cmdsubst3.0
+${PACKAGE}FILES+=      cmdsubst4.0
+${PACKAGE}FILES+=      cmdsubst5.0
+${PACKAGE}FILES+=      cmdsubst6.0
+${PACKAGE}FILES+=      cmdsubst7.0
+${PACKAGE}FILES+=      cmdsubst8.0
+${PACKAGE}FILES+=      cmdsubst9.0
+${PACKAGE}FILES+=      cmdsubst10.0
+${PACKAGE}FILES+=      cmdsubst11.0
+${PACKAGE}FILES+=      cmdsubst12.0
+${PACKAGE}FILES+=      cmdsubst13.0
+${PACKAGE}FILES+=      cmdsubst14.0
+${PACKAGE}FILES+=      cmdsubst15.0
+${PACKAGE}FILES+=      cmdsubst16.0
+${PACKAGE}FILES+=      cmdsubst17.0
+${PACKAGE}FILES+=      export1.0
+${PACKAGE}FILES+=      export2.0
+${PACKAGE}FILES+=      export3.0
+${PACKAGE}FILES+=      heredoc1.0
+${PACKAGE}FILES+=      heredoc2.0
+${PACKAGE}FILES+=      ifs1.0
+${PACKAGE}FILES+=      ifs2.0
+${PACKAGE}FILES+=      ifs3.0
+${PACKAGE}FILES+=      ifs4.0
+${PACKAGE}FILES+=      ifs5.0
+${PACKAGE}FILES+=      ifs6.0
+${PACKAGE}FILES+=      ifs7.0
+${PACKAGE}FILES+=      length1.0
+${PACKAGE}FILES+=      length2.0
+${PACKAGE}FILES+=      length3.0
+${PACKAGE}FILES+=      length4.0
+${PACKAGE}FILES+=      length5.0
+${PACKAGE}FILES+=      length6.0
+${PACKAGE}FILES+=      length7.0
+${PACKAGE}FILES+=      length8.0
+${PACKAGE}FILES+=      local1.0
+${PACKAGE}FILES+=      local2.0
+${PACKAGE}FILES+=      pathname1.0
+${PACKAGE}FILES+=      pathname2.0
+${PACKAGE}FILES+=      pathname3.0
+${PACKAGE}FILES+=      pathname4.0
+${PACKAGE}FILES+=      pathname5.0
+${PACKAGE}FILES+=      pathname6.0
+${PACKAGE}FILES+=      plus-minus1.0
+${PACKAGE}FILES+=      plus-minus2.0
+${PACKAGE}FILES+=      plus-minus3.0
+${PACKAGE}FILES+=      plus-minus4.0
+${PACKAGE}FILES+=      plus-minus5.0
+${PACKAGE}FILES+=      plus-minus6.0
+${PACKAGE}FILES+=      plus-minus7.0
+${PACKAGE}FILES+=      plus-minus8.0
+${PACKAGE}FILES+=      question1.0
+${PACKAGE}FILES+=      readonly1.0
+${PACKAGE}FILES+=      redir1.0
+${PACKAGE}FILES+=      set-u1.0
+${PACKAGE}FILES+=      set-u2.0
+${PACKAGE}FILES+=      set-u3.0
+${PACKAGE}FILES+=      tilde1.0
+${PACKAGE}FILES+=      tilde2.0
+${PACKAGE}FILES+=      trim1.0
+${PACKAGE}FILES+=      trim2.0
+${PACKAGE}FILES+=      trim3.0
+${PACKAGE}FILES+=      trim4.0
+${PACKAGE}FILES+=      trim5.0
+${PACKAGE}FILES+=      trim6.0
+${PACKAGE}FILES+=      trim7.0
+${PACKAGE}FILES+=      trim8.0
+${PACKAGE}FILES+=      trim9.0
 
 .include <bsd.test.mk>
 
 .include <bsd.test.mk>
diff --git a/sh/tests/expansion/Makefile.depend b/sh/tests/expansion/Makefile.depend
new file mode 100644 (file)
index 0000000..547cbb3
--- /dev/null
@@ -0,0 +1,11 @@
+# $FreeBSD: head/bin/sh/tests/expansion/Makefile.depend 296587 2016-03-09 22:46:01Z bdrewery $
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
index 118ba226568767ee3778e290ab4d2fbe676d03fd..c301600454bbd49613b109f5465dcf9202b8f7a5 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/arith1.0 201259 2009-12-30 15:59:40Z jilles $
 
 failures=0
 
 
 failures=0
 
index 1aaf6194fbaf70b269eb91d5c177eebfd959496c..9e3db285dedef6f6cdeb327003934633e1b4bcfe 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/arith10.0 218469 2011-02-08 23:23:55Z jilles $
 
 failures=0
 
 
 failures=0
 
index 6bc73697ffabfe31b2538891e9320cb51e625c3f..4a3383158699fe496c29c1038675df0f330af519 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/arith11.0 218626 2011-02-12 23:44:05Z jilles $
 # Try to divide the smallest integer by -1.
 # On amd64 this causes SIGFPE, so make sure the shell checks.
 
 # Try to divide the smallest integer by -1.
 # On amd64 this causes SIGFPE, so make sure the shell checks.
 
index cb7da3b2e21a3ca37ed530b79b7d5e5eb136bbed..7d79d7ec38aec62446d398817c167398a97c3793 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/arith12.0 232839 2012-03-11 22:12:05Z jilles $
 
 _x=4 y_=5 z_z=6
 [ "$((_x*100+y_*10+z_z))" = 456 ]
 
 _x=4 y_=5 z_z=6
 [ "$((_x*100+y_*10+z_z))" = 456 ]
index 207e4881935b32d457a8c8cf606d8aef886760a5..5421cb0bf8ea9baf35a3e49ff280e7b7b88023fa 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/arith13.0 254806 2013-08-24 20:06:00Z jilles $
 # Pre-increment and pre-decrement in arithmetic expansion are not in POSIX.
 # Require either an error or a correct implementation.
 
 # Pre-increment and pre-decrement in arithmetic expansion are not in POSIX.
 # Require either an error or a correct implementation.
 
index 836904335ef3d2016f45c31b8f48829985d72638..a51e91604fab2bb7c6f7c6bf521a11f0dd0efcfa 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/arith14.0 270029 2014-08-15 22:36:41Z jilles $
 # Check that <</>> use the low bits of the shift count.
 
 if [ $((1<<16<<16)) = 0 ]; then
 # Check that <</>> use the low bits of the shift count.
 
 if [ $((1<<16<<16)) = 0 ]; then
index 95b48a06aae675a5b5c5278e25fd218b294ef081..b5874e52902ff868aaac8d19b9e04c119ac39eda 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/arith2.0 209652 2010-07-02 21:31:24Z jilles $
 
 failures=0
 
 
 failures=0
 
index b69159d9b5b8c71286354d8a80cc06e90329ac16..6b60b518e6df9bdffe6d77598b2c86e96f72f8d9 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/arith3.0 204017 2010-02-17 22:25:22Z jilles $
 
 failures=0
 
 
 failures=0
 
index 610dad89e4dc6c3d956b8004b8387678d181a501..a41a0f73c58255a2bbed9c5de87e4ffc8d725f77 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/arith4.0 206167 2010-04-04 16:29:48Z jilles $
 
 failures=0
 
 
 failures=0
 
index d0f23312f9ca82808655255d6f88ff400038e908..1cd021f731584bf59576bd6d35b8730e54b2beb2 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/arith5.0 206168 2010-04-04 16:48:33Z jilles $
 
 failures=0
 
 
 failures=0
 
index fc4589c1bac5405181a1108917ea08d415005edc..528f4e822db9c0ad1cd14950544fb4fbfd401271 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/arith6.0 215550 2010-11-19 22:25:32Z jilles $
 
 v1=1\ +\ 1
 v2=D
 
 v1=1\ +\ 1
 v2=D
index 5aada2b865865ac0123827f55be8131fd0b973b9..f31dba1d4b479a971ce148baec24f7f0bfb84c62 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/arith7.0 216395 2010-12-12 16:56:16Z jilles $
 
 v=1+
 v=$v$v$v$v
 
 v=1+
 v=$v$v$v$v
index 2d03e503387dfebbe2849928d6c1dee8a4df110e..e0739f89cf857c34c961a207aa2f603abbda47f9 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/arith8.0 216547 2010-12-18 23:03:51Z jilles $
 
 v=$( (eval ': $((08))') 2>&1 >/dev/null)
 [ $? -ne 0 ] && [ -n "$v" ]
 
 v=$( (eval ': $((08))') 2>&1 >/dev/null)
 [ $? -ne 0 ] && [ -n "$v" ]
index cc8b597d475587976dfe60e94d332afce4a93783..e47d003d0633740753fea417f2eae9181ae956ec 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/arith9.0 218469 2011-02-08 23:23:55Z jilles $
 
 failures=0
 
 
 failures=0
 
index d4fa7727f593030bbbd931f3293eb88d10f499bf..ee4c0d890d65f3c7a4860e22bc31160257c756be 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/assign1.0 204842 2010-03-07 18:43:29Z jilles $
 
 e= q='?' a='*' t=texttext s='ast*que?non' p='/et[c]/' w='a b c' b='{{(#)}}'
 h='##'
 
 e= q='?' a='*' t=texttext s='ast*que?non' p='/et[c]/' w='a b c' b='{{(#)}}'
 h='##'
index 515c7da9aca1305e719af0e6dd1a1696dd01585d..ea89f42d313a013ea6ef35b29c30bcf10b5c33bc 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/cmdsubst1.0 201366 2010-01-01 18:17:46Z jilles $
 
 failures=0
 
 
 failures=0
 
index 7cf17a3e8fe1feac2a9a3e9cfb274583fbbc1f33..dc13d39cf08d2edc75bae0d5143782711dd2a829 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/cmdsubst10.0 216826 2010-12-30 22:33:55Z jilles $
 
 a1=$(alias)
 : $(alias testalias=abcd)
 
 a1=$(alias)
 : $(alias testalias=abcd)
index f1af547421f9e62b6a71fb0adebe04ad6f2d5e08..cb035aeb02d3687e1144f51d6f9c9fdc3ccc9c57 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/cmdsubst11.0 223163 2011-06-16 21:50:28Z jilles $
 
 # Not required by POSIX but useful for efficiency.
 
 
 # Not required by POSIX but useful for efficiency.
 
index 50394dbb00ca4ab1f65d8f4adddc468b246847f8..4d330efeea24a95ecf114a98556cfb9dbbb9ef03 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/cmdsubst12.0 230121 2012-01-14 23:10:18Z jilles $
 
 f() {
        echo x$(printf foo >&2)y
 
 f() {
        echo x$(printf foo >&2)y
index 7fdc5b217f196f0d4686376def5553714d70963f..d3fc3993d0d74934c1241feeeb70e4b98478f64e 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/cmdsubst13.0 230121 2012-01-14 23:10:18Z jilles $
 
 x=1 y=2
 [ "$(
 
 x=1 y=2
 [ "$(
index bdbbb823e2b245ad647789e8607c7660410b4067..8a916afe712bbb085c3a1b55e5ad32331dcb7eef 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/cmdsubst14.0 245381 2013-01-13 19:19:40Z jilles $
 
 ! v=`false
 
 
 ! v=`false
 
index 31d85d497e231482af12bb01c72799343ee3d9c0..9599ef8afee53f97b5ffedfa940a5dddd16cb166 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/cmdsubst15.0 245381 2013-01-13 19:19:40Z jilles $
 
 ! v=`false;
 
 
 ! v=`false;
 
index 71df562298e57e5bdfa9e4d7c0cde2c6845bc090..248360147a96bce11a880878a6e47de1b71bfcb9 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/cmdsubst16.0 245392 2013-01-13 22:35:51Z jilles $
 
 f() { return 3; }
 f
 
 f() { return 3; }
 f
index 8c29e8318327d2c3cdfce61f14ef2b7361e8ba84..d3a2b54f1671ac41e121ee5181fdc64b58a482b7 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/cmdsubst17.0 245422 2013-01-14 12:20:55Z jilles $
 
 f() { return 3; }
 f
 
 f() { return 3; }
 f
index b86776ed24b017c34b4503d9ed404a74087e0a06..35453bec3dfa33b504d7b252cb5fef64a25cec8b 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/cmdsubst2.0 205105 2010-03-12 23:23:46Z jilles $
 
 failures=0
 
 
 failures=0
 
index abb6b225a257caf9cd96a0ba3fe5848156a6a9e7..221b11b26b79b76f02e1f1d6a5b7ffa85d53bf62 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/cmdsubst3.0 218819 2011-02-18 20:37:09Z jilles $
 
 unset LC_ALL
 export LC_CTYPE=en_US.ISO8859-1
 
 unset LC_ALL
 export LC_CTYPE=en_US.ISO8859-1
index ee1ce73e7e387a6da1b26fa9130b190ec5a91742..4d5a13428b816aa27ee80174efb014c60b4064e5 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/cmdsubst4.0 216747 2010-12-27 23:56:03Z jilles $
 
 exec 2>/dev/null
 ! y=$(: </var/empty/nonexistent)
 
 exec 2>/dev/null
 ! y=$(: </var/empty/nonexistent)
index afca3719e8b0b66b4aae312721ef6ba87302c32b..70b42980adc8d1d04e244d79827b08bb01bd506b 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/cmdsubst5.0 216761 2010-12-28 13:28:24Z jilles $
 
 unset v
 exec 2>/dev/null
 
 unset v
 exec 2>/dev/null
index 6586f330db5b8251d3d85275ab609b2dd216ce6b..0e47bce3e2fd2794286915650f3f310caf75e874 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/cmdsubst6.0 216763 2010-12-28 14:58:08Z jilles $
 # This tests if the cmdsubst optimization is still used if possible.
 
 failures=''
 # This tests if the cmdsubst optimization is still used if possible.
 
 failures=''
index dbd1aec5f9dafc639ce5aada7fda992d7253b44b..6b4cd1d47608dcd1c141ac92d4dadd2390f51702 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/cmdsubst7.0 216778 2010-12-28 21:27:08Z jilles $
 
 failures=''
 ok=''
 
 failures=''
 ok=''
index 52adaea33b938b5702351e8ed9dbd36f78004306..19ff803969594757370c3f7299b970b8c0dc7603 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/cmdsubst8.0 216819 2010-12-30 15:04:59Z jilles $
 # Not required by POSIX (although referenced in a non-normative section),
 # but possibly useful.
 
 # Not required by POSIX (although referenced in a non-normative section),
 # but possibly useful.
 
index 0b1f81f3537a5c82be1e1d9147d5ff1d8ca26145..8bbf2b992974966441ed675f479c5920cf1cddd3 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/cmdsubst9.0 216819 2010-12-30 15:04:59Z jilles $
 
 set -e
 
 
 set -e
 
index 4ee3ef4ffa4179841c06d8336ea31e0a1cc4d21d..3286fb9169a48a32fd1b9d194c1ee8b0500fef6e 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/export1.0 238430 2012-07-13 22:29:02Z jilles $
 
 w='@ vv=6'
 
 
 w='@ vv=6'
 
index 57f64e7f7f7be997df05f8af8aa8b43b75fa06a0..e8862b8af2848d7fdc080b1426d32317e7806634 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/export2.0 238468 2012-07-15 10:19:43Z jilles $
 
 w='@ @'
 check() {
 
 w='@ @'
 check() {
index a1a0e6658a08026addbbe3624c32375cdc2b9227..b82fcc196fd0a4bf479d2aa672c172c727958105 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/export3.0 238468 2012-07-15 10:19:43Z jilles $
 
 w='@ @'
 check() {
 
 w='@ @'
 check() {
index a67b2da2e5f280e12849835c56ab0b6778a08bde..94328c0ae56f5b2bb903a418ef31da0ef659a5a2 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/heredoc1.0 222715 2011-06-05 12:46:26Z jilles $
 
 f() { return $1; }
 
 
 f() { return $1; }
 
index 255143296d4a3c1b59617b9847ffbac01ec49816..24c4cc6f6c5517239e92efef2930558a5c340df7 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/heredoc2.0 222716 2011-06-05 14:13:15Z jilles $
 
 f() { return $1; }
 
 
 f() { return $1; }
 
index e7f53c77a5f909fbd3accb207a59a7bff70770c8..4d5157a933f28a417f58986780f2fd1470ac0976 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/ifs1.0 194981 2009-06-25 17:36:08Z jilles $
 
 c=: e= s=' '
 failures=''
 
 c=: e= s=' '
 failures=''
index e91b8670718371f4e04b6656ea8001a7f5ae26ea..3d71b52bf3390488ecdc28e213bc728c13d8c580 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/ifs2.0 211341 2010-08-15 17:14:05Z jilles $
 
 failures=0
 i=1
 
 failures=0
 i=1
index 0569b5729cae7fd9f93688cd2884a021e68e5eb6..d034654179f0f3911aab3217452b2cb4ea996aa1 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/ifs3.0 211622 2010-08-22 13:09:12Z jilles $
 
 failures=0
 unset LC_ALL
 
 failures=0
 unset LC_ALL
index 5b896a25413b7d4c6fe45577ff97d60f91a5d7d7..a307ec577eb0b25c73ca0c0b7ce2285ed34cf96a 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/ifs4.0 222361 2011-05-27 15:56:13Z jilles $
 
 c=: e= s=' '
 failures=''
 
 c=: e= s=' '
 failures=''
index ab0e64662fdf9b130cb0c2fc8b25b9af2b3c082c..fc5b4b719f7f19375ee4fcb6d4dade97752ee060 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/ifs5.0 278806 2015-02-15 19:48:29Z jilles $
 
 set -- $(echo a b c d)
 [ "$#" = 4 ]
 
 set -- $(echo a b c d)
 [ "$#" = 4 ]
index be7794563085de3ef190b6a26aa0181c24a3db8d..3ec5dbc13398b2a1e60dd9e9d4a7d96d08bdc058 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/ifs6.0 280920 2015-03-31 20:59:37Z jilles $
 
 IFS=': '
 x=': :'
 
 IFS=': '
 x=': :'
index 0cc08348c04a399dc485f06ef785e095a0135bfe..a59f31388b40ff1e8fef44be02e36e872b6f28d7 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/ifs7.0 280920 2015-03-31 20:59:37Z jilles $
 
 IFS=2
 set -- $((123))
 
 IFS=2
 set -- $((123))
index 2aaebf9048a229261ed9a9a79bc64113f727cfd9..cee58080ce787ab0596db8414bbfb7b061d7f56f 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/length1.0 219611 2011-03-13 16:20:38Z jilles $
 
 v=abcd
 [ "${#v}" = 4 ] || echo '${#v} wrong'
 
 v=abcd
 [ "${#v}" = 4 ] || echo '${#v} wrong'
index d749b51f4b20ce06daa24b5df483fe96a562c162..77fd6ada9d628c09866b434558dee6c64812a8a8 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/length2.0 219611 2011-03-13 16:20:38Z jilles $
 
 v=$-
 [ "${#-}" = "${#v}" ] || echo '${#-} wrong'
 
 v=$-
 [ "${#-}" = "${#v}" ] || echo '${#-} wrong'
index 2093eed8bbd3c849f34c1ca40723eff660ffa8c9..27045b7c253dca4542637b5418f930470d907b84 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/length3.0 219611 2011-03-13 16:20:38Z jilles $
 
 set -- 1 2 3 4 5 6 7 8 9 10 11 12 13
 [ "$#" = 13 ] || echo '$# wrong'
 
 set -- 1 2 3 4 5 6 7 8 9 10 11 12 13
 [ "$#" = 13 ] || echo '$# wrong'
index 5348be511379f54d56106aa852a659f0b799dc97..c1ff0214ded3284256ebaf89afc2446d7fcb9488 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/length4.0 220655 2011-04-15 15:26:05Z jilles $
 
 # The construct ${#?} is ambiguous in POSIX.1-2008: it could be the length
 # of $? or it could be $# giving an error in the (impossible) case that it
 
 # The construct ${#?} is ambiguous in POSIX.1-2008: it could be the length
 # of $? or it could be $# giving an error in the (impossible) case that it
index 322ca162b0b694a27fcc7675a75210e0eb0d6316..da8ebb5dc5c32afdbdb0c4fab47d04d5d0b93505 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/length5.0 220656 2011-04-15 15:33:24Z jilles $
 
 unset LC_ALL
 LC_CTYPE=en_US.ISO8859-1
 
 unset LC_ALL
 LC_CTYPE=en_US.ISO8859-1
index 6b78309f6b81e914cf71ef30dc2d2995f6d62c66..8da2da80225fc0936777b15091bde678073f0fe4 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/length6.0 220903 2011-04-20 22:24:54Z jilles $
 
 x='!@#$%^&*()[]'
 [ ${#x} = 12 ] || echo bad 1
 
 x='!@#$%^&*()[]'
 [ ${#x} = 12 ] || echo bad 1
index b79b11616c1560f7eba946d17b7dba222b591bfc..500b7e7ee82c08b6438ba1be9927725a87766512 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/length7.0 221602 2011-05-07 14:32:16Z jilles $
 
 unset LC_ALL
 LC_CTYPE=en_US.UTF-8
 
 unset LC_ALL
 LC_CTYPE=en_US.UTF-8
index 3cc6c15e7ece5b7aad1194d81a65451f499096fd..d4f91d862d8ab7511348c2f6897d35dbf59a1eb4 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/length8.0 221602 2011-05-07 14:32:16Z jilles $
 
 unset LC_ALL
 LC_CTYPE=en_US.ISO8859-1
 
 unset LC_ALL
 LC_CTYPE=en_US.ISO8859-1
index 34778351f1f3d9f518adecf692d514ffc12192eb..9f16eb06839451c59bd05b790186daf85b6d4763 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/local1.0 238468 2012-07-15 10:19:43Z jilles $
 
 run_test() {
        w='@ @'
 
 run_test() {
        w='@ @'
index 19842900e0c1363e775d547abaa747dd085b0625..9d1a38ae65dd91adb4acb2b248eeee6719f855f5 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/local2.0 238468 2012-07-15 10:19:43Z jilles $
 
 run_test() {
        w='@ @'
 
 run_test() {
        w='@ @'
index 8c6b01c8356a981dcce1fdf0f80388d37b6f7a7c..6f40004d414b97a6d21c5d77632634098a1613c1 100644 (file)
@@ -1,4 +1,8 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/pathname1.0 302937 2016-07-16 13:26:18Z ache $
+
+unset LC_ALL
+LC_COLLATE=C
+export LC_COLLATE
 
 failures=0
 
 
 failures=0
 
index 8a884ff2901e8c3042f8a0947cda752d46a29a12..3efffb7652e6840d8ee5ffc8967c407711a7eb95 100644 (file)
@@ -1,4 +1,8 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/pathname2.0 302937 2016-07-16 13:26:18Z ache $
+
+unset LC_ALL
+LC_COLLATE=C
+export LC_COLLATE
 
 failures=0
 
 
 failures=0
 
index d1672e057ec56ba26d4b48235adb918d8d3537a3..80d6478631ebb6d46412fcabf7e01c19b68a083f 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/pathname3.0 211155 2010-08-10 22:45:59Z jilles $
 
 v=12345678
 v=$v$v$v$v
 
 v=12345678
 v=$v$v$v$v
index 18269c4318e62181358b66f429b98c3b3b0a9ff0..d316c0a881bdf961b2f91b4d22648ec5711732d7 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/pathname4.0 211646 2010-08-22 21:18:21Z jilles $
 
 failures=0
 
 
 failures=0
 
index bc278124de4f2ff11822cd2ffb0c8c9e3e4e0aa0..42cd1191f3cde2bf445b1d7f557193ff8f1fdf96 100644 (file)
@@ -1,3 +1,3 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/pathname5.0 278806 2015-02-15 19:48:29Z jilles $
 
 [ `echo '/[e]tc'` = /etc ]
 
 [ `echo '/[e]tc'` = /etc ]
diff --git a/sh/tests/expansion/pathname6.0 b/sh/tests/expansion/pathname6.0
new file mode 100644 (file)
index 0000000..e763c6a
--- /dev/null
@@ -0,0 +1,29 @@
+# $FreeBSD: head/bin/sh/tests/expansion/pathname6.0 302937 2016-07-16 13:26:18Z ache $
+
+unset LC_ALL
+LC_COLLATE=en_US.US-ASCII
+export LC_COLLATE
+
+failures=0
+
+check() {
+       testcase=$1
+       expect=$2
+       eval "set -- $testcase"
+       actual="$*"
+       if [ "$actual" != "$expect" ]; then
+               failures=$((failures+1))
+               printf '%s\n' "For $testcase, expected $expect actual $actual"
+       fi
+}
+
+set -e
+T=$(mktemp -d ${TMPDIR:-/tmp}/sh-test.XXXXXX)
+trap 'rm -rf $T' 0
+cd -P $T
+
+touch A B a b
+
+check '*' 'a A b B'
+
+exit $((failures != 0))
index 9a6a53a2414a13773c97f392a51a5aa2ae48b847..088ed7fd940ffb4faec3b528e332a0aac45096cd 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/plus-minus1.0 216738 2010-12-27 15:57:41Z emaste $
 
 e= q='?' a='*' t=texttext s='ast*que?non' p='/et[c]/' w='a b c' b='{{(#)}}'
 h='##'
 
 e= q='?' a='*' t=texttext s='ast*que?non' p='/et[c]/' w='a b c' b='{{(#)}}'
 h='##'
index f5a87525ae373c12c0663de20cf2fa5e4ac0b232..2f22988acee476ca6960e63e58fabac39baf37e7 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/plus-minus2.0 206145 2010-04-03 20:55:56Z jilles $
 
 e=
 test "${e:-\}}" = '}'
 
 e=
 test "${e:-\}}" = '}'
index 49fcdc2f8f562ee4ab3aac2c4d70076eca984544..d7fc9231ff7329b130071f7199b798b25fb0fd6b 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/plus-minus3.0 206817 2010-04-18 22:13:45Z jilles $
 
 e= q='?' a='*' t=texttext s='ast*que?non' p='/et[c]/' w='a b c' b='{{(#)}}'
 h='##'
 
 e= q='?' a='*' t=texttext s='ast*que?non' p='/et[c]/' w='a b c' b='{{(#)}}'
 h='##'
index 66dea3851efc86713bd5b7e95304f9904a07dd01..4d2d37d526fe63cf89ac7643a217a8cf587a9828 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/plus-minus4.0 211080 2010-08-08 17:03:23Z jilles $
 
 # These may be a bit unclear in the POSIX spec or the proposed revisions,
 # and conflict with bash's interpretation, but I think ksh93's interpretation
 
 # These may be a bit unclear in the POSIX spec or the proposed revisions,
 # and conflict with bash's interpretation, but I think ksh93's interpretation
index 0b25e53cf82a1e311e8a99b8d2c6cc9d10614ca4..02db26cd8b56887ebc57994d0ecbecae00a41e49 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/plus-minus5.0 214492 2010-10-28 22:34:49Z jilles $
 
 e= q='?' a='*' t=texttext s='ast*que?non' p='/et[c]/' w='a b c' b='{{(#)}}'
 h='##'
 
 e= q='?' a='*' t=texttext s='ast*que?non' p='/et[c]/' w='a b c' b='{{(#)}}'
 h='##'
index bc66805268235e468e5c68ad0538370509bf922b..1bd3f7a29410c9defab4cf8bb2438e1cbc53d98e 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/plus-minus6.0 214512 2010-10-29 13:42:18Z jilles $
 
 failures=0
 unset LC_ALL
 
 failures=0
 unset LC_ALL
index 9e81f58a0a992c5469d58b92c341449eb7c13b76..440cfddac15c6bf43612fd11e0ce55b907bed8e7 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/plus-minus7.0 216738 2010-12-27 15:57:41Z emaste $
 
 e= s='foo'
 failures=''
 
 e= s='foo'
 failures=''
index beba009b06601475e27d424b75a228149122dce4..dd7e7703fee15b98be27a50c50c54b583b023106 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/plus-minus8.0 219623 2011-03-13 20:02:39Z jilles $
 
 set -- 1 2 3 4 5 6 7 8 9 10 11 12 13
 [ "${#+hi}" = hi ] || echo '${#+hi} wrong'
 
 set -- 1 2 3 4 5 6 7 8 9 10 11 12 13
 [ "${#+hi}" = hi ] || echo '${#+hi} wrong'
index 663c68d2046d782efa08c39c7fd07df093feef2c..2f07597e0814a0b6b8230c55f7246b1e5f69591e 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/question1.0 213738 2010-10-12 18:20:38Z obrien $
 
 x=a\ b
 [ "$x" = "${x?}" ] || exit 1
 
 x=a\ b
 [ "$x" = "${x?}" ] || exit 1
index 5ad0e143f81f55e159daeda1425ded083c79c093..e1e950adc2859d8a30c39623ca1608485611b0d8 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/readonly1.0 238468 2012-07-15 10:19:43Z jilles $
 
 w='@ @'
 
 
 w='@ @'
 
index aa13e1561b688cddd0cacbad5e0ef48eaa2d368e..fd5c9810e3ab7bd463046104d02bad3850517eeb 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/redir1.0 273920 2014-10-31 22:28:10Z jilles $
 
 bad=0
 for i in 0 1 2 3; do
 
 bad=0
 for i in 0 1 2 3; do
index 763eb7dcfc8f71e061f1460e5aa500cf1865ff7f..045d6ad1801b1f5b7a987cc4bd182253abccf618 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/set-u1.0 213738 2010-10-12 18:20:38Z obrien $
 
 ${SH} -uc 'unset foo; echo $foo' 2>/dev/null && exit 1
 ${SH} -uc 'foo=; echo $foo' >/dev/null || exit 1
 
 ${SH} -uc 'unset foo; echo $foo' 2>/dev/null && exit 1
 ${SH} -uc 'foo=; echo $foo' >/dev/null || exit 1
index f81aa62cb6ba3c07af5c803e93f708c42a4bf000..55da8aa9b11c6c1c98faf15c30de3d3dafe4c4d0 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/set-u2.0 198454 2009-10-24 21:20:04Z jilles $
 
 set -u
 : $* $@ "$@" "$*"
 
 set -u
 : $* $@ "$@" "$*"
index 7f199b42c796e3a5b4c9f07a3cce699fae50a768..ea848f7d900b0cd84646a689afe80524b5e03e5c 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/set-u3.0 221463 2011-05-04 22:12:22Z jilles $
 
 set -u
 unset x
 
 set -u
 unset x
index 7d8581bbc8ee336ea7945b5061c6edf129a0d4af..c0a7f5b4ad914afd00b5d8c4035704157ae205ce 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/tilde1.0 206149 2010-04-03 21:56:24Z jilles $
 
 HOME=/tmp
 roothome=~root
 
 HOME=/tmp
 roothome=~root
index 4f8ed9b491c7c030964a52092ee5ff4bd0bdd88f..7827c228b07a47094c971723551a17b434033b35 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/tilde2.0 206150 2010-04-03 22:04:44Z jilles $
 
 HOME=/tmp
 roothome=~root
 
 HOME=/tmp
 roothome=~root
index b548e521792aafeb8a596f4233004cc0ec15f658..16dd838ca967f231646924e57841bd605c0ebb6a 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/trim1.0 206143 2010-04-03 20:14:10Z jilles $
 
 e= q='?' a='*' t=texttext s='ast*que?non' p='/et[c]/' w='a b c' b='{{(#)}}'
 h='##'
 
 e= q='?' a='*' t=texttext s='ast*que?non' p='/et[c]/' w='a b c' b='{{(#)}}'
 h='##'
index 619ef651cce68937ff562d181084478339190093..15651b98e2ba36e1d5709cc561cdc7b6828c9fb7 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/trim2.0 206147 2010-04-03 21:07:50Z jilles $
 
 e= q='?' a='*' t=texttext s='ast*que?non' p='/et[c]/' w='a b c' b='{{(#)}}'
 h='##'
 
 e= q='?' a='*' t=texttext s='ast*que?non' p='/et[c]/' w='a b c' b='{{(#)}}'
 h='##'
index b89a04140c37b8658cf773cfb46bb948b277f0a5..28c59aeed794485dac70434a8f32e64f1041f583 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/trim3.0 207127 2010-04-23 17:26:49Z jilles $
 
 e= q='?' a='*' t=texttext s='ast*que?non' p='/et[c]/' w='a b c' b='{{(#)}}'
 h='##' c='\\\\'
 
 e= q='?' a='*' t=texttext s='ast*que?non' p='/et[c]/' w='a b c' b='{{(#)}}'
 h='##' c='\\\\'
index 1000bd3d0245c19d3652280bb8660be7c768ea3a..f79b6fdf5da410fb81db2b11bdfe4d4afc166ed7 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/trim4.0 213814 2010-10-13 23:29:09Z obrien $
 
 v1=/homes/SOME_USER
 v2=
 
 v1=/homes/SOME_USER
 v2=
index 937ec9a708e0b5031b7536c0cade557c7d061f26..8045eb6adae0cdfbadb8a4c3a582f65a43bee58a 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/trim5.0 214490 2010-10-28 21:51:14Z jilles $
 
 e= q='?' a='*' t=texttext s='ast*que?non' p='/et[c]/' w='a b c' b='{{(#)}}'
 h='##'
 
 e= q='?' a='*' t=texttext s='ast*que?non' p='/et[c]/' w='a b c' b='{{(#)}}'
 h='##'
index 3f753c4113f67063679553ae9f9e2a8d64c4d88c..e34a09f50cdeb9d7684c2b7158bb41d4e561ff3d 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/trim6.0 214524 2010-10-29 19:34:57Z jilles $
 
 e=
 for i in 0 1 2 3; do
 
 e=
 for i in 0 1 2 3; do
index 352bdea920bfbc56a653e34d693e6f0c256c0131..4f237cc9c875b601c8879a3217cd844d01c26f66 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/trim7.0 219623 2011-03-13 20:02:39Z jilles $
 
 set -- 1 2 3 4 5 6 7 8 9 10 11 12 13
 [ "${##1}" = 3 ] || echo '${##1} wrong'
 
 set -- 1 2 3 4 5 6 7 8 9 10 11 12 13
 [ "${##1}" = 3 ] || echo '${##1} wrong'
index f7272f371dce7a2e45d97c383dfa18ddecf19c5d..c4b6ce4c7d3b7bb2e3063191fb10e3a9e8dc92fc 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/expansion/trim8.0 221646 2011-05-08 11:32:20Z jilles $
 
 unset LC_ALL
 LC_CTYPE=en_US.UTF-8
 
 unset LC_ALL
 LC_CTYPE=en_US.UTF-8
diff --git a/sh/tests/expansion/trim9.0 b/sh/tests/expansion/trim9.0
new file mode 100644 (file)
index 0000000..f0b08ab
--- /dev/null
@@ -0,0 +1,61 @@
+# $FreeBSD: head/bin/sh/tests/expansion/trim9.0 292758 2015-12-26 22:27:48Z jilles $
+
+# POSIX does not specify these but they occasionally occur in the wild.
+# This just serves to keep working what currently works.
+
+failures=''
+ok=''
+
+testcase() {
+       code="$1"
+       expected="$2"
+       oIFS="$IFS"
+       eval "$code"
+       IFS='|'
+       result="$#|$*"
+       IFS="$oIFS"
+       if [ "x$result" = "x$expected" ]; then
+               ok=x$ok
+       else
+               failures=x$failures
+               echo "For $code, expected $expected actual $result"
+       fi
+}
+
+testcase 'shift $#; set -- "${*#Q}"'           '1|'
+testcase 'shift $#; set -- "${*##Q}"'          '1|'
+testcase 'shift $#; set -- "${*%Q}"'           '1|'
+testcase 'shift $#; set -- "${*%%Q}"'          '1|'
+testcase 'set -- Q R; set -- "${*#Q}"'         '1| R'
+testcase 'set -- Q R; set -- "${*##Q}"'                '1| R'
+testcase 'set -- Q R; set -- "${*%R}"'         '1|Q '
+testcase 'set -- Q R; set -- "${*%%R}"'                '1|Q '
+testcase 'set -- Q R; set -- "${*#S}"'         '1|Q R'
+testcase 'set -- Q R; set -- "${*##S}"'                '1|Q R'
+testcase 'set -- Q R; set -- "${*%S}"'         '1|Q R'
+testcase 'set -- Q R; set -- "${*%%S}"'                '1|Q R'
+testcase 'set -- Q R; set -- ${*#Q}'           '1|R'
+testcase 'set -- Q R; set -- ${*##Q}'          '1|R'
+testcase 'set -- Q R; set -- ${*%R}'           '1|Q'
+testcase 'set -- Q R; set -- ${*%%R}'          '1|Q'
+testcase 'set -- Q R; set -- ${*#S}'           '2|Q|R'
+testcase 'set -- Q R; set -- ${*##S}'          '2|Q|R'
+testcase 'set -- Q R; set -- ${*%S}'           '2|Q|R'
+testcase 'set -- Q R; set -- ${*%%S}'          '2|Q|R'
+testcase 'set -- Q R; set -- ${@#Q}'           '1|R'
+testcase 'set -- Q R; set -- ${@##Q}'          '1|R'
+testcase 'set -- Q R; set -- ${@%R}'           '1|Q'
+testcase 'set -- Q R; set -- ${@%%R}'          '1|Q'
+testcase 'set -- Q R; set -- ${@#S}'           '2|Q|R'
+testcase 'set -- Q R; set -- ${@##S}'          '2|Q|R'
+testcase 'set -- Q R; set -- ${@%S}'           '2|Q|R'
+testcase 'set -- Q R; set -- ${@%%S}'          '2|Q|R'
+testcase 'set -- Q R; set -- "${@#Q}"'         '2||R'
+testcase 'set -- Q R; set -- "${@%R}"'         '2|Q|'
+testcase 'set -- Q R; set -- "${@%%R}"'                '2|Q|'
+testcase 'set -- Q R; set -- "${@#S}"'         '2|Q|R'
+testcase 'set -- Q R; set -- "${@##S}"'                '2|Q|R'
+testcase 'set -- Q R; set -- "${@%S}"'         '2|Q|R'
+testcase 'set -- Q R; set -- "${@%%S}"'                '2|Q|R'
+
+test "x$failures" = x
index 698053885adcec40d330fd82d783ed94a4348d81..c2a1f81804a67a8a548e3eccde5923e487debfd3 100755 (executable)
@@ -24,7 +24,7 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/functional_test.sh 270101 2014-08-17 14:26:12Z jilles $
 
 SRCDIR=$(atf_get_srcdir)
 
 
 SRCDIR=$(atf_get_srcdir)
 
index 231ed4dbb79d1025f43a72634ab13c3a19aabc2c..30708db7cc0a056e4f588868b587de621c386949 100644 (file)
@@ -1,26 +1,29 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parameters/Makefile 306843 2016-10-08 13:40:12Z jilles $
+
+PACKAGE=       tests
 
 TESTSDIR=      ${TESTSBASE}/bin/sh/${.CURDIR:T}
 
 .PATH: ${.CURDIR:H}
 ATF_TESTS_SH=  functional_test
 
 
 TESTSDIR=      ${TESTSBASE}/bin/sh/${.CURDIR:T}
 
 .PATH: ${.CURDIR:H}
 ATF_TESTS_SH=  functional_test
 
-FILESDIR=      ${TESTSDIR}
-
-FILES=         env1.0
-FILES+=                exitstatus1.0
-FILES+=                mail1.0
-FILES+=                mail2.0
-FILES+=                optind1.0
-FILES+=                optind2.0
-FILES+=                positional1.0
-FILES+=                positional2.0
-FILES+=                positional3.0
-FILES+=                positional4.0
-FILES+=                positional5.0
-FILES+=                positional6.0
-FILES+=                positional7.0
-FILES+=                pwd1.0
-FILES+=                pwd2.0
+${PACKAGE}FILES+=      env1.0
+${PACKAGE}FILES+=      exitstatus1.0
+${PACKAGE}FILES+=      ifs1.0
+${PACKAGE}FILES+=      mail1.0
+${PACKAGE}FILES+=      mail2.0
+${PACKAGE}FILES+=      optind1.0
+${PACKAGE}FILES+=      optind2.0
+${PACKAGE}FILES+=      positional1.0
+${PACKAGE}FILES+=      positional2.0
+${PACKAGE}FILES+=      positional3.0
+${PACKAGE}FILES+=      positional4.0
+${PACKAGE}FILES+=      positional5.0
+${PACKAGE}FILES+=      positional6.0
+${PACKAGE}FILES+=      positional7.0
+${PACKAGE}FILES+=      positional8.0
+${PACKAGE}FILES+=      positional9.0
+${PACKAGE}FILES+=      pwd1.0
+${PACKAGE}FILES+=      pwd2.0
 
 .include <bsd.test.mk>
 
 .include <bsd.test.mk>
diff --git a/sh/tests/parameters/Makefile.depend b/sh/tests/parameters/Makefile.depend
new file mode 100644 (file)
index 0000000..41114a3
--- /dev/null
@@ -0,0 +1,11 @@
+# $FreeBSD: head/bin/sh/tests/parameters/Makefile.depend 296587 2016-03-09 22:46:01Z bdrewery $
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
index c0d4a2cc914139371d4f3014f79cb86b4d2df7a3..08428567d73fca0d604501034aa000bd9438f5d0 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parameters/env1.0 222957 2011-06-10 22:42:00Z jilles $
 
 export key='must contain this'
 unset x
 
 export key='must contain this'
 unset x
index 696823d580432d4401b1fc8539f167390f2cd663..709600eb0cc6f3bb6fae06d77a28f54c8e7906a3 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parameters/exitstatus1.0 185232 2008-11-23 20:27:03Z stefanf $
 f() {
        [ $? = $1 ] || exit 1
 }
 f() {
        [ $? = $1 ] || exit 1
 }
diff --git a/sh/tests/parameters/ifs1.0 b/sh/tests/parameters/ifs1.0
new file mode 100644 (file)
index 0000000..e88d7a4
--- /dev/null
@@ -0,0 +1,10 @@
+# $FreeBSD: head/bin/sh/tests/parameters/ifs1.0 306843 2016-10-08 13:40:12Z jilles $
+
+env IFS=_ ${SH} -c '
+rc=2
+nosuchtool_function() {
+       rc=0
+}
+v=nosuchtool_function
+$v && exit "$rc"
+'
index 5791a5accc7cfb20fdea3e3052f18baa58b4472a..af69211959d233ea6d1d3025fb7070091c656ba1 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parameters/mail1.0 213738 2010-10-12 18:20:38Z obrien $
 # Test that a non-interactive shell does not access $MAIL.
 
 goodfile=/var/empty/sh-test-goodfile
 # Test that a non-interactive shell does not access $MAIL.
 
 goodfile=/var/empty/sh-test-goodfile
index 343c99de9b279b84544d7f6c9d56ef28cd518b8d..74dc416f2f67901c6695e76a2d0618236776ecdf 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parameters/mail2.0 213738 2010-10-12 18:20:38Z obrien $
 # Test that an interactive shell accesses $MAIL.
 
 goodfile=/var/empty/sh-test-goodfile
 # Test that an interactive shell accesses $MAIL.
 
 goodfile=/var/empty/sh-test-goodfile
index 33e0288e861f3912aaa12b9ee70ad56f9ef943b7..30fc9d8ff658174bee559578759e811c5472cb29 100644 (file)
@@ -1,3 +1,3 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parameters/optind1.0 227773 2011-11-20 21:48:50Z jilles $
 
 unset OPTIND && [ -z "$OPTIND" ]
 
 unset OPTIND && [ -z "$OPTIND" ]
index a7689f6841a5e69777f82a599cfb33e25ccab5a1..0837a17025bc6228708f43c21e8fcdfd24e4cb9c 100644 (file)
@@ -1,3 +1,3 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parameters/optind2.0 259846 2013-12-24 22:38:24Z jilles $
 
 [ "$(OPTIND=42 ${SH} -c 'printf %s "$OPTIND"')" = 1 ]
 
 [ "$(OPTIND=42 ${SH} -c 'printf %s "$OPTIND"')" = 1 ]
index 67d19516a5d99a5ee3d6ba2750d9707f15dd0636..ef95be397143c6c88910bd48a715c2820cda61c1 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parameters/positional1.0 222158 2011-05-21 14:52:26Z jilles $
 
 set -- a b c d e f g h i j
 [ "$1" = a ] || echo "error at line $LINENO"
 
 set -- a b c d e f g h i j
 [ "$1" = a ] || echo "error at line $LINENO"
index fcec2a4b676ee0f999006f864e872101e06cd042..ea2925067250bea923fd509051d9c647f9fb9346 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parameters/positional2.0 228873 2011-12-25 13:24:48Z jilles $
 
 failures=''
 ok=''
 
 failures=''
 ok=''
index 1200469b4e1258e13f6970a250a0686ff601daf1..d164ed9cf6c7f719efb8b215e589b338613158fc 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parameters/positional3.0 268436 2014-07-08 22:04:44Z jilles $
 
 r=$(${SH} -c 'echo ${01:+yes}${010:+yes}' '' a '' '' '' '' '' '' '' '' b)
 [ "$r" = yesyes ]
 
 r=$(${SH} -c 'echo ${01:+yes}${010:+yes}' '' a '' '' '' '' '' '' '' '' b)
 [ "$r" = yesyes ]
index c1c380c0feac7fc4612c034098b8208df3306917..48c2f01fccdf8317c245641c19f84d49c16fb55d 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parameters/positional4.0 268568 2014-07-12 10:27:30Z jilles $
 
 set -- "x$0" 2 3 4 5 6 7 8 9 "y$0"
 [ "${01}.${010}" = "$1.${10}" ]
 
 set -- "x$0" 2 3 4 5 6 7 8 9 "y$0"
 [ "${01}.${010}" = "$1.${10}" ]
index eeaaba5321ffdef97912daa529f4d4faed5498af..80ef80521d5f78f81d8c9939b440ba0369bcc892 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parameters/positional5.0 268576 2014-07-12 21:54:11Z jilles $
 
 i=1
 r=0
 
 i=1
 r=0
index 1410668b8a9f644a4698c4912240a8d73c1d4799..c1d5e4cb6a93d6a3fbea27dcd6994ee35ff478d8 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parameters/positional6.0 273802 2014-10-28 22:14:31Z jilles $
 
 IFS=?
 set p r
 
 IFS=?
 set p r
index f170ad343996f63625536696a6e5896752d9aa20..df36b6f529251ecdf370ad6f0450d3f31941af5f 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parameters/positional7.0 273802 2014-10-28 22:14:31Z jilles $
 
 set -- / ''
 IFS=*
 
 set -- / ''
 IFS=*
diff --git a/sh/tests/parameters/positional8.0 b/sh/tests/parameters/positional8.0
new file mode 100644 (file)
index 0000000..69717ce
--- /dev/null
@@ -0,0 +1,31 @@
+# $FreeBSD: head/bin/sh/tests/parameters/positional8.0 291025 2015-11-18 21:09:03Z jilles $
+
+failures=''
+ok=''
+
+testcase() {
+       code="$1"
+       expected="$2"
+       oIFS="$IFS"
+       eval "$code"
+       IFS='|'
+       result="$#|$*"
+       IFS="$oIFS"
+       if [ "x$result" = "x$expected" ]; then
+               ok=x$ok
+       else
+               failures=x$failures
+               echo "For $code, expected $expected actual $result"
+       fi
+}
+
+testcase 'shift $#; set -- ""$*'               '1|'
+testcase 'shift $#; set -- $*""'               '1|'
+testcase 'shift $#; set -- ""$@'               '1|'
+testcase 'shift $#; set -- $@""'               '1|'
+testcase 'shift $#; set -- """$*"'             '1|'
+testcase 'shift $#; set -- "$*"""'             '1|'
+testcase 'shift $#; set -- """$@"'             '1|'
+testcase 'shift $#; set -- "$@"""'             '1|'
+
+test "x$failures" = x
diff --git a/sh/tests/parameters/positional9.0 b/sh/tests/parameters/positional9.0
new file mode 100644 (file)
index 0000000..c353e85
--- /dev/null
@@ -0,0 +1,18 @@
+# $FreeBSD: head/bin/sh/tests/parameters/positional9.0 291903 2015-12-06 14:09:31Z jilles $
+# Although POSIX leaves the result of expanding ${#@} and ${#*} unspecified,
+# make sure it is at least numeric.
+
+set -- bb cc ddd
+set -f
+lengths=${#*}${#@}"${#*}${#@}"$(echo ${#*}${#@}"${#*}${#@}")
+IFS=
+lengths=$lengths${#*}${#@}"${#*}${#@}"$(echo ${#*}${#@}"${#*}${#@}")
+case $lengths in
+*[!0-9]*)
+       printf 'bad: %s\n' "$lengths"
+       exit 3 ;;
+????????????????*) ;;
+*)
+       printf 'too short: %s\n' "$lengths"
+       exit 3 ;;
+esac
index 0099379a9d3cd3752f0d1fb80ab5241ecc910ec5..8393ef63a49ba9dbb75fc90b2f355f09d066df37 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parameters/pwd1.0 213738 2010-10-12 18:20:38Z obrien $
 # Check that bogus PWD values are not accepted from the environment.
 
 cd / || exit 3
 # Check that bogus PWD values are not accepted from the environment.
 
 cd / || exit 3
index 2297f8b753d44df12c24508a98c2f138a5944da1..d0cecf562efb24efa8148fd6ef6cc76f7ae0d1f2 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parameters/pwd2.0 213738 2010-10-12 18:20:38Z obrien $
 # Check that PWD is exported and accepted from the environment.
 set -e
 
 # Check that PWD is exported and accepted from the environment.
 set -e
 
index 3c9e62c7a777210cae0c29aeafa27d30e915b8a3..4a9c7246fda24f9f4adc0ee3220f5de66f57725e 100644 (file)
@@ -1,78 +1,85 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/Makefile 299094 2016-05-04 23:20:53Z ngie $
+
+PACKAGE=       tests
 
 TESTSDIR=      ${TESTSBASE}/bin/sh/${.CURDIR:T}
 
 .PATH: ${.CURDIR:H}
 ATF_TESTS_SH=  functional_test
 
 
 TESTSDIR=      ${TESTSBASE}/bin/sh/${.CURDIR:T}
 
 .PATH: ${.CURDIR:H}
 ATF_TESTS_SH=  functional_test
 
-FILESDIR=      ${TESTSDIR}
-
-FILES=         alias1.0
-FILES+=                alias2.0
-FILES+=                alias3.0
-FILES+=                alias4.0
-FILES+=                alias5.0
-FILES+=                alias6.0
-FILES+=                alias7.0
-FILES+=                alias8.0
-FILES+=                alias9.0
-FILES+=                alias10.0
-FILES+=                alias11.0
-FILES+=                alias12.0
-FILES+=                alias13.0
-FILES+=                alias14.0
-FILES+=                alias15.0 alias15.0.stdout
-FILES+=                and-pipe-not.0
-FILES+=                case1.0
-FILES+=                case2.0
-FILES+=                dollar-quote1.0
-FILES+=                dollar-quote2.0
-FILES+=                dollar-quote3.0
-FILES+=                dollar-quote4.0
-FILES+=                dollar-quote5.0
-FILES+=                dollar-quote6.0
-FILES+=                dollar-quote7.0
-FILES+=                dollar-quote8.0
-FILES+=                dollar-quote9.0
-FILES+=                dollar-quote10.0
-FILES+=                dollar-quote11.0
-FILES+=                empty-braces1.0
-FILES+=                empty-cmd1.0
-FILES+=                for1.0
-FILES+=                for2.0
-FILES+=                func1.0
-FILES+=                func2.0
-FILES+=                func3.0
-FILES+=                heredoc1.0
-FILES+=                heredoc2.0
-FILES+=                heredoc3.0
-FILES+=                heredoc4.0
-FILES+=                heredoc5.0
-FILES+=                heredoc6.0
-FILES+=                heredoc7.0
-FILES+=                heredoc8.0
-FILES+=                heredoc9.0
-FILES+=                heredoc10.0
-FILES+=                heredoc11.0
-FILES+=                heredoc12.0
-FILES+=                line-cont1.0
-FILES+=                line-cont2.0
-FILES+=                line-cont3.0
-FILES+=                line-cont4.0
-FILES+=                line-cont5.0
-FILES+=                line-cont6.0
-FILES+=                line-cont7.0
-FILES+=                line-cont8.0
-FILES+=                line-cont9.0
-FILES+=                line-cont10.0
-FILES+=                line-cont11.0
-FILES+=                no-space1.0
-FILES+=                no-space2.0
-FILES+=                only-redir1.0
-FILES+=                only-redir2.0
-FILES+=                only-redir3.0
-FILES+=                only-redir4.0
-FILES+=                pipe-not1.0
-FILES+=                var-assign1.0
+${PACKAGE}FILES+=      alias1.0
+${PACKAGE}FILES+=      alias2.0
+${PACKAGE}FILES+=      alias3.0
+${PACKAGE}FILES+=      alias4.0
+${PACKAGE}FILES+=      alias5.0
+${PACKAGE}FILES+=      alias6.0
+${PACKAGE}FILES+=      alias7.0
+${PACKAGE}FILES+=      alias8.0
+${PACKAGE}FILES+=      alias9.0
+${PACKAGE}FILES+=      alias10.0
+${PACKAGE}FILES+=      alias11.0
+${PACKAGE}FILES+=      alias12.0
+${PACKAGE}FILES+=      alias13.0
+${PACKAGE}FILES+=      alias14.0
+${PACKAGE}FILES+=      alias15.0 alias15.0.stdout
+${PACKAGE}FILES+=      and-pipe-not.0
+${PACKAGE}FILES+=      case1.0
+${PACKAGE}FILES+=      case2.0
+${PACKAGE}FILES+=      comment1.0
+${PACKAGE}FILES+=      comment2.42
+${PACKAGE}FILES+=      dollar-quote1.0
+${PACKAGE}FILES+=      dollar-quote2.0
+${PACKAGE}FILES+=      dollar-quote3.0
+${PACKAGE}FILES+=      dollar-quote4.0
+${PACKAGE}FILES+=      dollar-quote5.0
+${PACKAGE}FILES+=      dollar-quote6.0
+${PACKAGE}FILES+=      dollar-quote7.0
+${PACKAGE}FILES+=      dollar-quote8.0
+${PACKAGE}FILES+=      dollar-quote9.0
+${PACKAGE}FILES+=      dollar-quote10.0
+${PACKAGE}FILES+=      dollar-quote11.0
+${PACKAGE}FILES+=      dollar-quote12.0
+${PACKAGE}FILES+=      dollar-quote13.0
+${PACKAGE}FILES+=      empty-braces1.0
+${PACKAGE}FILES+=      empty-cmd1.0
+${PACKAGE}FILES+=      for1.0
+${PACKAGE}FILES+=      for2.0
+${PACKAGE}FILES+=      func1.0
+${PACKAGE}FILES+=      func2.0
+${PACKAGE}FILES+=      func3.0
+${PACKAGE}FILES+=      heredoc1.0
+${PACKAGE}FILES+=      heredoc2.0
+${PACKAGE}FILES+=      heredoc3.0
+${PACKAGE}FILES+=      heredoc4.0
+${PACKAGE}FILES+=      heredoc5.0
+${PACKAGE}FILES+=      heredoc6.0
+${PACKAGE}FILES+=      heredoc7.0
+${PACKAGE}FILES+=      heredoc8.0
+${PACKAGE}FILES+=      heredoc9.0
+${PACKAGE}FILES+=      heredoc10.0
+${PACKAGE}FILES+=      heredoc11.0
+${PACKAGE}FILES+=      heredoc12.0
+${PACKAGE}FILES+=      heredoc13.0
+${PACKAGE}FILES+=      line-cont1.0
+${PACKAGE}FILES+=      line-cont2.0
+${PACKAGE}FILES+=      line-cont3.0
+${PACKAGE}FILES+=      line-cont4.0
+${PACKAGE}FILES+=      line-cont5.0
+${PACKAGE}FILES+=      line-cont6.0
+${PACKAGE}FILES+=      line-cont7.0
+${PACKAGE}FILES+=      line-cont8.0
+${PACKAGE}FILES+=      line-cont9.0
+${PACKAGE}FILES+=      line-cont10.0
+${PACKAGE}FILES+=      line-cont11.0
+${PACKAGE}FILES+=      no-space1.0
+${PACKAGE}FILES+=      no-space2.0
+${PACKAGE}FILES+=      nul1.0
+${PACKAGE}FILES+=      only-redir1.0
+${PACKAGE}FILES+=      only-redir2.0
+${PACKAGE}FILES+=      only-redir3.0
+${PACKAGE}FILES+=      only-redir4.0
+${PACKAGE}FILES+=      pipe-not1.0
+${PACKAGE}FILES+=      set-v1.0 set-v1.0.stderr
+${PACKAGE}FILES+=      var-assign1.0
 
 .include <bsd.test.mk>
 
 .include <bsd.test.mk>
diff --git a/sh/tests/parser/Makefile.depend b/sh/tests/parser/Makefile.depend
new file mode 100644 (file)
index 0000000..af589a4
--- /dev/null
@@ -0,0 +1,11 @@
+# $FreeBSD: head/bin/sh/tests/parser/Makefile.depend 296587 2016-03-09 22:46:01Z bdrewery $
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
index 75dd9ab9b8f16c56f24bade5a7441674f7892a1f..9b6721179230e84b2a4c3573b76c9d63f0f9fe74 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/alias1.0 214280 2010-10-24 16:55:17Z jilles $
 
 alias alias0=exit
 eval 'alias0 0'
 
 alias alias0=exit
 eval 'alias0 0'
index 30d99f49bbf4ad41a9920860d5d94ef1d1a3913e..b8684f4cefee702efc1de713bc3adb43ddceb862 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/alias10.0 243252 2012-11-18 23:15:22Z jilles $
 
 # This test may start consuming memory indefinitely if it fails.
 ulimit -t 5 2>/dev/null
 
 # This test may start consuming memory indefinitely if it fails.
 ulimit -t 5 2>/dev/null
index 522264ff823f597020599054ee713be087f335a6..10fd827ffad27d062d1a3a781db3916cf1cbb66b 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/alias11.0 261141 2014-01-24 23:00:35Z jilles $
 
 alias alias0=alias1
 alias alias1=exit
 
 alias alias0=alias1
 alias alias1=exit
index 2e4379155d4a057c9f647c4fb5c87795e4b063b5..52cc4b088e4b738af64714c39f95b8beb2ab80dd 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/alias12.0 261160 2014-01-25 14:59:08Z jilles $
 
 unalias -a
 alias alias0=command
 
 unalias -a
 alias alias0=command
index 53b949dc23e9b60865ec9e07bf3b25c914e6de65..9f450678fc80dfac91623d4add8cc605d0bb723b 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/alias13.0 261160 2014-01-25 14:59:08Z jilles $
 
 unalias -a
 alias command=command
 
 unalias -a
 alias command=command
index 1b92fc07d5b26f02bcb188f1fa418f9a11dc36ef..2d1bc51898e20dba8dad8594e542737b66ced2c8 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/alias14.0 261192 2014-01-26 21:19:33Z jilles $
 
 alias command='command '
 alias alias0=exit
 
 alias command='command '
 alias alias0=exit
index f0fbadbb20e7fc331b9ee94bc7ad80b5e99adbd8..c2e611779804b94a5ded1432c59e292837b9b5d2 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/alias15.0 261192 2014-01-26 21:19:33Z jilles $
 
 f_echoanddo() {
        printf '%s\n' "$*"
 
 f_echoanddo() {
        printf '%s\n' "$*"
index ae99b8a588c2320513c4f68922e860b73bf5053a..f4127568edba012c071c69da4efd0d33d9b8262e 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/alias2.0 214280 2010-10-24 16:55:17Z jilles $
 
 alias alias0=exit
 x=alias0
 
 alias alias0=exit
 x=alias0
index e0721e2aaa010d54b8cbc26b7e18b403010c737f..97aac198cbb727dccdf7c292a153efd1006e72f1 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/alias3.0 214709 2010-11-02 23:44:29Z jilles $
 
 alias alias0=exit
 x=alias0
 
 alias alias0=exit
 x=alias0
index 19332ed09056047996df60256a2a4070ce9cd5db..4c82c6cd037cc7a2bcf97855f10f705fe6f94f36 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/alias4.0 222165 2011-05-21 22:03:06Z jilles $
 
 alias alias0=exit
 eval 'x=1 alias0 0'
 
 alias alias0=exit
 eval 'x=1 alias0 0'
index 3d0205fd233239e281a837d3f4f6b98b9520a44c..c6495626804d87af54bdb50b2b33d247fc4ed90a 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/alias5.0 222165 2011-05-21 22:03:06Z jilles $
 
 alias alias0=exit
 eval '</dev/null alias0 0'
 
 alias alias0=exit
 eval '</dev/null alias0 0'
index c723d08ab3ebfecd23f0d378d0fcdc7673b35f0c..86e1bfb01b17c1d03cb51a6591a8a6c94786e186 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/alias6.0 224104 2011-07-16 16:14:14Z jilles $
 
 alias alias0='| cat >/dev/null'
 
 
 alias alias0='| cat >/dev/null'
 
index b26f0dd067cd384cca2b8ad43df4da607b9a4b5b..a5b90774037988879b8aca18c48db02fc41b6ca9 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/alias7.0 240825 2012-09-22 12:52:41Z jilles $
 
 alias echo='echo a'
 [ "`eval echo b`" = "a b" ]
 
 alias echo='echo a'
 [ "`eval echo b`" = "a b" ]
index 7fc2f15f0931d1024ce1d823fc017d5e787ad312..f22dfd417d67605cd0cce958c32b395553368c6f 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/alias8.0 240825 2012-09-22 12:52:41Z jilles $
 
 alias echo='echo'
 [ "`eval echo b`" = b ]
 
 alias echo='echo'
 [ "`eval echo b`" = b ]
index 6bd8808cc3790e79022456114b838c2d482a9ac5..bbcb4cebf521ca672a00ae6cd2769fe07b7dfebf 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/alias9.0 242721 2012-11-07 23:15:36Z jilles $
 
 alias alias0=:
 alias alias0=exit
 
 alias alias0=:
 alias alias0=exit
index 35b125c147672319e409d043ab89789ef3f668e9..fffb1d4c17922930df1214843d05621fde3c6fc3 100644 (file)
@@ -1,2 +1,2 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/and-pipe-not.0 191010 2009-04-13 19:12:28Z stefanf $
 true && ! true | false
 true && ! true | false
index 49b4c45155fa870d4aaeea538d082e6756e4a675..d146399441c7cff620804480834aee7bc650b899 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/case1.0 207824 2010-05-09 17:10:50Z jilles $
 
 keywords='if then else elif fi while until for do done { } case esac ! in'
 
 
 keywords='if then else elif fi while until for do done { } case esac ! in'
 
index 14610e415c1910fff3c3675c0a2a14dd05a23457..df5a3192e63820dac58a0cb6f8e8488f8f62081d 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/case2.0 207824 2010-05-09 17:10:50Z jilles $
 
 # Pretty much only ash derivatives can parse all of this.
 
 
 # Pretty much only ash derivatives can parse all of this.
 
diff --git a/sh/tests/parser/comment1.0 b/sh/tests/parser/comment1.0
new file mode 100644 (file)
index 0000000..bdf9c3b
--- /dev/null
@@ -0,0 +1,3 @@
+# $FreeBSD: head/bin/sh/tests/parser/comment1.0 295818 2016-02-19 16:56:07Z jilles $
+
+${SH} -c '#'
diff --git a/sh/tests/parser/comment2.42 b/sh/tests/parser/comment2.42
new file mode 100644 (file)
index 0000000..7e623c9
--- /dev/null
@@ -0,0 +1,4 @@
+# $FreeBSD: head/bin/sh/tests/parser/comment2.42 295818 2016-02-19 16:56:07Z jilles $
+
+${SH} -c '#
+exit 42'
index ad166da23ffee414c47da7d520139e3664b7ddb0..745d3aaa519cf2687bc2a366c0b37199cfd4efa4 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/dollar-quote10.0 221669 2011-05-08 17:40:10Z jilles $
 
 # a umlaut
 s=$(printf '\303\244')
 
 # a umlaut
 s=$(printf '\303\244')
index 2e872abfe5b09fd49d165b345d8f59fb8990bd3b..b9db067c1fc37878e1b07ab7a6b42da82db5918e 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/dollar-quote11.0 221669 2011-05-08 17:40:10Z jilles $
 
 # some sort of 't' outside BMP
 s=$s$(printf '\360\235\225\245')
 
 # some sort of 't' outside BMP
 s=$s$(printf '\360\235\225\245')
diff --git a/sh/tests/parser/dollar-quote12.0 b/sh/tests/parser/dollar-quote12.0
new file mode 100644 (file)
index 0000000..bb06e3c
--- /dev/null
@@ -0,0 +1,7 @@
+# $FreeBSD: head/bin/sh/tests/parser/dollar-quote12.0 286971 2015-08-20 21:31:36Z jilles $
+
+# \u without any digits at all remains invalid.
+# Our choice is a parse error.
+
+v=$( (eval ": \$'\u'") 2>&1 >/dev/null)
+[ $? -ne 0 ] && [ -n "$v" ]
diff --git a/sh/tests/parser/dollar-quote13.0 b/sh/tests/parser/dollar-quote13.0
new file mode 100644 (file)
index 0000000..fe31d9d
--- /dev/null
@@ -0,0 +1,8 @@
+# $FreeBSD: head/bin/sh/tests/parser/dollar-quote13.0 286973 2015-08-20 22:05:55Z jilles $
+
+# This Unicode escape sequence that has never been in range should either
+# fail to expand or expand to a fallback.
+
+c=$(eval printf %s \$\'\\Uffffff41\' 2>/dev/null)
+r=$(($? != 0))
+[ "$r.$c" = '1.' ] || [ "$r.$c" = '0.?' ] || [ "$r.$c" = $'0.\u2222' ]
index 5ab443c48d8a07268ab8cfb22d1d0f70d5d4f64c..4aac8062367d374506c8904a75630f18529fb1b0 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/empty-braces1.0 245382 2013-01-13 19:26:33Z jilles $
 
 # Unfortunately, some scripts depend on the extension of allowing an empty
 # pair of braces.
 
 # Unfortunately, some scripts depend on the extension of allowing an empty
 # pair of braces.
index f8b01e9c7997ed22749c18f4c31856f414657114..60aaa0029719e8a46d46853483e1696a48ed716a 100644 (file)
@@ -1,3 +1,3 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/empty-cmd1.0 254843 2013-08-25 10:57:48Z jilles $
 
 ! (eval ': || f()') 2>/dev/null
 
 ! (eval ': || f()') 2>/dev/null
index eb7c881237fdf2f52ebd5d65245d4b589d131a86..d863f0af5502c659ffe4a9685dae3c2dca0ce9be 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/for1.0 218889 2011-02-20 14:18:58Z jilles $
 
 nl='
 '
 
 nl='
 '
index 54ebfc3d719350ca9c122a6a28a255890a57c85c..8ed92dcb5a7e3abea8b3fda11382aad1330414c5 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/for2.0 218889 2011-02-20 14:18:58Z jilles $
 
 # Common extensions to the 'for' syntax.
 
 
 # Common extensions to the 'for' syntax.
 
index 4e887b25f2856060e9a3b43c31f8efabd784e846..4e82da47477aa50a7a8c00902534888ecab9aefb 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/func1.0 214291 2010-10-24 20:45:13Z jilles $
 # POSIX does not require these bytes to work in function names,
 # but making them all work seems a good goal.
 
 # POSIX does not require these bytes to work in function names,
 # but making them all work seems a good goal.
 
index 5fd4dda8cca9dbd5aff59d6db0a729360f4f97b4..5b865229d7140210496ec3a89d35c256aa5d95c5 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/func2.0 222512 2011-05-30 21:49:59Z jilles $
 
 f() { return 42; }
 f() { return 3; } &
 
 f() { return 42; }
 f() { return 3; } &
index dcac7323ad3fb6a85c7db6fadc072ca86d14ea1a..c4f4922c8dde8d43323282d2199a5094cede6848 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/func3.0 222512 2011-05-30 21:49:59Z jilles $
 
 name=/var/empty/nosuch
 f() { true; } <$name
 
 name=/var/empty/nosuch
 f() { true; } <$name
index 5ce38977d7f5aebde0cb8cb8bad2660ce594400b..4020249b332b57a3dc51115928e4aa1c17f23173 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/heredoc1.0 204836 2010-03-07 15:08:42Z jilles $
 
 failures=0
 
 
 failures=0
 
index 27369a0b1b4ccf966f86374a7543c399c5f71a88..f5133b9fc188d189dee743ff05e52b49f1cd0266 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/heredoc10.0 221887 2011-05-14 14:19:30Z jilles $
 
 # It may be argued that
 #   x=$(cat <<EOF
 
 # It may be argued that
 #   x=$(cat <<EOF
index 5839e46b36ce6591226855f4636e3057c4e239e4..3e74aead2e50dd4060e4c565a266a4fb3627d1f7 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/heredoc11.0 222134 2011-05-20 16:03:36Z jilles $
 
 failures=''
 
 
 failures=''
 
index 964838453237d3d544359fad905bfc216d353ec7..644cae131603a401e099abf682c28ebc340d88ec 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/heredoc12.0 271593 2014-09-14 16:46:30Z jilles $
 
 failures=0
 
 
 failures=0
 
diff --git a/sh/tests/parser/heredoc13.0 b/sh/tests/parser/heredoc13.0
new file mode 100644 (file)
index 0000000..4eb45e0
--- /dev/null
@@ -0,0 +1,21 @@
+# $FreeBSD: head/bin/sh/tests/parser/heredoc13.0 287408 2015-09-02 19:49:55Z jilles $
+
+failures=0
+
+check() {
+       if ! eval "[ $* ]"; then
+               echo "Failed: $*"
+               : $((failures += 1))
+       fi
+}
+
+check '"$(cat <<""
+
+echo yes)" = "yes"'
+
+check '"$(cat <<""
+yes
+
+)" = "yes"'
+
+exit $((failures != 0))
index 4bb85ad80c172ca44a55c58e9f5938e830291426..f07f5d4b9ae95c531f8a6a7fede213c809327e3b 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/heredoc2.0 211405 2010-08-16 21:14:49Z jilles $
 
 failures=0
 
 
 failures=0
 
index b250272f3319d0e96b310b889cb314f62ccad55c..15c0a1c499e0ef9938a1460061f8d7a5a5402898 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/heredoc3.0 207824 2010-05-09 17:10:50Z jilles $
 
 # This may be expected to work, but pretty much only ash derivatives allow it.
 
 
 # This may be expected to work, but pretty much only ash derivatives allow it.
 
index fa3af5fd5a9733a29c9a5d22876dd6ca71537397..a5443543f9981f79d15c25665a766e77e9358f63 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/heredoc4.0 208655 2010-05-30 14:11:27Z jilles $
 
 failures=0
 
 
 failures=0
 
index 84b0eb2705d4ee359a1183bfa37663c43268e5aa..0bcc6170a5d4f1bda08d97cceb164ed3d88b6933 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/heredoc5.0 208655 2010-05-30 14:11:27Z jilles $
 
 failures=0
 
 
 failures=0
 
index 3a634de167a76d771ca80a237ca5fa40bc01a40d..003f548e496e66496e9ba3ef0249de9d822d54b1 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/heredoc6.0 208656 2010-05-30 14:20:32Z jilles $
 
 r=
 ! command eval ": <<EOF; )" 2>/dev/null; command eval : hi \${r:=0}
 
 r=
 ! command eval ": <<EOF; )" 2>/dev/null; command eval : hi \${r:=0}
index a15010648780c74cb25149dc80fa32196b5fe0f8..28d867cbacbc28730ec0235afc0be107d244ade2 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/heredoc7.0 210488 2010-07-25 22:25:52Z jilles $
 
 # Some of these created malformed parse trees with null pointers for here
 # documents, causing the here document writing process to segfault.
 
 # Some of these created malformed parse trees with null pointers for here
 # documents, causing the here document writing process to segfault.
index 598358a0494b3032c5c555669ef0038d6115fec8..482c0600296449de52a5d0920881d40889ae7f7e 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/heredoc8.0 211405 2010-08-16 21:14:49Z jilles $
 
 failures=0
 
 
 failures=0
 
index 125a542ab717d7c67fff7f77e08c850388ba2386..bb4a04c1debf646caf484b4c26f4084dc87f15ce 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/heredoc9.0 221887 2011-05-14 14:19:30Z jilles $
 
 # It may be argued that
 #   x=$(cat <<EOF
 
 # It may be argued that
 #   x=$(cat <<EOF
index 7ef5eba82b1e15783ad467ffa4336b47f65c6aae..717c2c217a3789fe08f2b105140c67a2999fc2fb 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/line-cont1.0 273243 2014-10-17 21:52:57Z jilles $
 
 i\
 f
 
 i\
 f
index 1e74108757a0070df2f6872e2595bc704f2d476c..dbb064b4b2241b84e29fb0616131325b25951eef 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/line-cont10.0 273276 2014-10-19 11:59:15Z jilles $
 
 v=XaaaXbbbX
 [ "${v\
 
 v=XaaaXbbbX
 [ "${v\
index 22e49758dbc6d58fcff58c7d3066f9db36e9fff3..f398a98c25f80fb5965e156993a138d5e3c46482 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/line-cont11.0 273276 2014-10-19 11:59:15Z jilles $
 
 T=$(mktemp "${TMPDIR:-/tmp}/sh-test.XXXXXXXX") || exit
 trap 'rm -f -- "$T"' 0
 
 T=$(mktemp "${TMPDIR:-/tmp}/sh-test.XXXXXXXX") || exit
 trap 'rm -f -- "$T"' 0
index 9a293faf6bc2e9693bc0b70e25750372c202a81a..83928cf8fe367f08260f5cfe9e9d05c7f4e9304d 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/line-cont2.0 273243 2014-10-17 21:52:57Z jilles $
 
 [ "a\
 b" = ab ]
 
 [ "a\
 b" = ab ]
index 09d3aa8bba839d13ee6c8547a043f29a499cff29..cc2af7bf692ad9d7de34749bcd80152c03298297 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/line-cont3.0 273243 2014-10-17 21:52:57Z jilles $
 
 v=`printf %s 'a\
 b'`
 
 v=`printf %s 'a\
 b'`
index 5803276f2b3b8b67b3ce1ac77d641feb30f559b1..7d59c1965bd13d954daae6b0afdcb62a707857fe 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/line-cont4.0 273276 2014-10-19 11:59:15Z jilles $
 
 v=abcd
 [ "$\
 
 v=abcd
 [ "$\
index a7aa02688310a31ccecaed684e0c29bff9fd4c70..23a4d942db06a9e5c97f589e769172048a643c07 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/line-cont5.0 273276 2014-10-19 11:59:15Z jilles $
 
 bad=1
 case x in
 
 bad=1
 case x in
index b12125b929e563950e4ae067d4c46ae5c292f630..66838e1b9b4cd649d242f3abb8e0037d01123070 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/line-cont6.0 273276 2014-10-19 11:59:15Z jilles $
 
 v0\
 =abc
 
 v0\
 =abc
index 27f8aec9515c7acc83ebbb9cf3507baadf99fc41..6c48642af5f3f0149515dfeb1483c89e1bf2237c 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/line-cont7.0 273276 2014-10-19 11:59:15Z jilles $
 
 [ "$(\
 (
 
 [ "$(\
 (
index 88667760b47bc291f1b6f14f23473a1f8d8e904b..8fc84bbed202446c1de7e98373a473313a3b02ed 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/line-cont8.0 273276 2014-10-19 11:59:15Z jilles $
 
 set -- a b c d e f g h i j
 [ "${1\
 
 set -- a b c d e f g h i j
 [ "${1\
index 4e73c8f04abc79b57fa62f6a87dd1121374ad80c..9618ae2d0a1671438578ef6a14b1b34d671b50d3 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/line-cont9.0 273276 2014-10-19 11:59:15Z jilles $
 
 [ "${$\
 :\
 
 [ "${$\
 :\
index 6df9f6395ff68d80c697df1d0fa917ab212d04e1..5b15bfeb2fe1eb510d1f84f79e9d63c7e6fa0b5e 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/no-space1.0 218891 2011-02-20 17:28:58Z jilles $
 
 # These are ugly but are required to work.
 
 
 # These are ugly but are required to work.
 
index 4e8447b11e4c249f50175d437318479644c96f2c..0f63e6e4d8e992742a70ed3daa9328284f1e5afb 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/no-space2.0 218891 2011-02-20 17:28:58Z jilles $
 
 # This conflicts with ksh extended patterns but occurs in the wild.
 
 
 # This conflicts with ksh extended patterns but occurs in the wild.
 
diff --git a/sh/tests/parser/nul1.0 b/sh/tests/parser/nul1.0
new file mode 100644 (file)
index 0000000..bb5442e
--- /dev/null
@@ -0,0 +1,12 @@
+# $FreeBSD: head/bin/sh/tests/parser/nul1.0 295825 2016-02-19 21:53:12Z jilles $
+# Although POSIX does not specify the effect of NUL bytes in scripts,
+# we ignore them.
+
+{
+       printf 'v=%03000d\0%02000d' 7 2
+       dd if=/dev/zero bs=1000 count=1 status=none
+       printf '1 w=%03000d%02000d1\0\n' 7 2
+       printf '\0l\0v\0=\0$\0{\0#\0v\0}\n'
+       printf '\0l\0w\0=\0\0$\0{\0#\0w}\0\0\0\n'
+       printf '[ "$lv.$lw.$v" = "5001.5001.$w" ]\n'
+} | ${SH}
index 46076c882a5e2c481a08f6d72dcf0e56444a5a2e..7aedde76e2ca322b929da8fa860b6e13afca7779 100644 (file)
@@ -1,3 +1,3 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/only-redir1.0 210221 2010-07-18 12:45:31Z jilles $
 </dev/null &
 wait $!
 </dev/null &
 wait $!
index b9e9501c2027f26fd751d89311c5d57c34257ced..b55be164a838fbfb9b3a01ed63f53bcf89a36d93 100644 (file)
@@ -1,2 +1,2 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/only-redir2.0 254335 2013-08-14 19:34:13Z jilles $
 </dev/null | :
 </dev/null | :
index 128a48391dedc6abcf6c6b8116122e6e4c094a46..f51617b99a11d1288c65c80c7e7b212102357ef7 100644 (file)
@@ -1,2 +1,2 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/only-redir3.0 254335 2013-08-14 19:34:13Z jilles $
 case x in x) </dev/null ;; esac
 case x in x) </dev/null ;; esac
index d804e128debe42306ecd112456e05f6264aece57..a3ce8931001db70a3487240fdb0b75f3e8c37707 100644 (file)
@@ -1,2 +1,2 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/only-redir4.0 254335 2013-08-14 19:34:13Z jilles $
 case x in x) </dev/null ;& esac
 case x in x) </dev/null ;& esac
index 9842ff0afd05739e922128ed80cd52d39d55cc7c..421e23536b002d56907978e0cea0c482ff8a725e 100644 (file)
@@ -1,3 +1,3 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/pipe-not1.0 214281 2010-10-24 17:06:49Z jilles $
 
 : | ! : | false
 
 : | ! : | false
diff --git a/sh/tests/parser/set-v1.0 b/sh/tests/parser/set-v1.0
new file mode 100644 (file)
index 0000000..c5ed944
--- /dev/null
@@ -0,0 +1,8 @@
+# $FreeBSD: head/bin/sh/tests/parser/set-v1.0 295937 2016-02-23 22:44:01Z jilles $
+
+${SH} <<\EOF
+echo one >&2
+set -v
+echo two >&2
+echo three >&2
+EOF
diff --git a/sh/tests/parser/set-v1.0.stderr b/sh/tests/parser/set-v1.0.stderr
new file mode 100644 (file)
index 0000000..d904fa5
--- /dev/null
@@ -0,0 +1,5 @@
+one
+echo two >&2
+two
+echo three >&2
+three
index 1fd3b26f8a26475473d52678b9f4fd21dfe65dac..4949bfd37197a0340bea350e8a2e155d7b1a22fe 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/parser/var-assign1.0 257920 2013-11-10 18:46:59Z jilles $
 # In a variable assignment, both the name and the equals sign must be entirely
 # unquoted. Therefore, there is only one assignment below; the other words
 # containing equals signs are command words.
 # In a variable assignment, both the name and the equals sign must be entirely
 # unquoted. Therefore, there is only one assignment below; the other words
 # containing equals signs are command words.
index f733b60b1e182ea5de28d12bf0b05759463ead7b..2f13991e11cb6bb6cc96283391073c594a5808a2 100644 (file)
@@ -1,46 +1,46 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/set-e/Makefile 299094 2016-05-04 23:20:53Z ngie $
+
+PACKAGE=       tests
 
 TESTSDIR=      ${TESTSBASE}/bin/sh/${.CURDIR:T}
 
 .PATH: ${.CURDIR:H}
 ATF_TESTS_SH=  functional_test
 
 
 TESTSDIR=      ${TESTSBASE}/bin/sh/${.CURDIR:T}
 
 .PATH: ${.CURDIR:H}
 ATF_TESTS_SH=  functional_test
 
-FILESDIR=      ${TESTSDIR}
-
-FILES=         and1.0
-FILES+=                and2.1
-FILES+=                and3.0
-FILES+=                and4.0
-FILES+=                background1.0
-FILES+=                cmd1.0
-FILES+=                cmd2.1
-FILES+=                elif1.0
-FILES+=                elif2.0
-FILES+=                eval1.0
-FILES+=                eval2.1
-FILES+=                for1.0
-FILES+=                func1.0
-FILES+=                func2.1
-FILES+=                if1.0
-FILES+=                if2.0
-FILES+=                if3.0
-FILES+=                not1.0
-FILES+=                not2.0
-FILES+=                or1.0
-FILES+=                or2.0
-FILES+=                or3.1
-FILES+=                pipe1.1
-FILES+=                pipe2.0
-FILES+=                return1.0
-FILES+=                semi1.1
-FILES+=                semi2.1
-FILES+=                subshell1.0
-FILES+=                subshell2.1
-FILES+=                until1.0
-FILES+=                until2.0
-FILES+=                until3.0
-FILES+=                while1.0
-FILES+=                while2.0
-FILES+=                while3.0
+${PACKAGE}FILES+=      and1.0
+${PACKAGE}FILES+=      and2.1
+${PACKAGE}FILES+=      and3.0
+${PACKAGE}FILES+=      and4.0
+${PACKAGE}FILES+=      background1.0
+${PACKAGE}FILES+=      cmd1.0
+${PACKAGE}FILES+=      cmd2.1
+${PACKAGE}FILES+=      elif1.0
+${PACKAGE}FILES+=      elif2.0
+${PACKAGE}FILES+=      eval1.0
+${PACKAGE}FILES+=      eval2.1
+${PACKAGE}FILES+=      for1.0
+${PACKAGE}FILES+=      func1.0
+${PACKAGE}FILES+=      func2.1
+${PACKAGE}FILES+=      if1.0
+${PACKAGE}FILES+=      if2.0
+${PACKAGE}FILES+=      if3.0
+${PACKAGE}FILES+=      not1.0
+${PACKAGE}FILES+=      not2.0
+${PACKAGE}FILES+=      or1.0
+${PACKAGE}FILES+=      or2.0
+${PACKAGE}FILES+=      or3.1
+${PACKAGE}FILES+=      pipe1.1
+${PACKAGE}FILES+=      pipe2.0
+${PACKAGE}FILES+=      return1.0
+${PACKAGE}FILES+=      semi1.1
+${PACKAGE}FILES+=      semi2.1
+${PACKAGE}FILES+=      subshell1.0
+${PACKAGE}FILES+=      subshell2.1
+${PACKAGE}FILES+=      until1.0
+${PACKAGE}FILES+=      until2.0
+${PACKAGE}FILES+=      until3.0
+${PACKAGE}FILES+=      while1.0
+${PACKAGE}FILES+=      while2.0
+${PACKAGE}FILES+=      while3.0
 
 .include <bsd.test.mk>
 
 .include <bsd.test.mk>
diff --git a/sh/tests/set-e/Makefile.depend b/sh/tests/set-e/Makefile.depend
new file mode 100644 (file)
index 0000000..ea8dbbe
--- /dev/null
@@ -0,0 +1,11 @@
+# $FreeBSD: head/bin/sh/tests/set-e/Makefile.depend 296587 2016-03-09 22:46:01Z bdrewery $
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
index 607b7c3500203394585eea8d014335c613eaaa76..4518124b41e9a050b828c4aaa810765ed9bd61ad 100644 (file)
@@ -1,3 +1,3 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/set-e/and1.0 149781 2005-09-04 11:59:59Z stefanf $
 set -e
 true && true
 set -e
 true && true
index 78e203ab00590602cad7cb091f9babc4ec650bb0..2067f10e1a7a038795428c67471687476c0311a3 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/set-e/and2.1 149781 2005-09-04 11:59:59Z stefanf $
 set -e
 true && false
 exit 0
 set -e
 true && false
 exit 0
index 9fafb1c45dd84202536b6c3550e8d5cef135177e..59dccce26d24766f5b7e2f88bea06503e729facc 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/set-e/and3.0 149781 2005-09-04 11:59:59Z stefanf $
 set -e
 false && true
 exit 0
 set -e
 false && true
 exit 0
index 25d0e6147dea2586c155895b31a4150d8f3b20ee..fd1cc723bd89212bb725a4ad465aaec418e451aa 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/set-e/and4.0 149781 2005-09-04 11:59:59Z stefanf $
 set -e
 false && false
 exit 0
 set -e
 false && false
 exit 0
index 21577f4f78c7a865183130d1739763b5c0728e6b..e31b7a3a86520f9928053d4c0f0ca717c0a0f8a6 100644 (file)
@@ -1,3 +1,3 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/set-e/background1.0 149781 2005-09-04 11:59:59Z stefanf $
 set -e
 false &
 set -e
 false &
index 67fdcbc3d83e0887617a33c72d3961e8d2f11e40..7c6c843b4bb2fdb93915fb2d4bc69b56364e48c1 100644 (file)
@@ -1,3 +1,3 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/set-e/cmd1.0 149781 2005-09-04 11:59:59Z stefanf $
 set -e
 true
 set -e
 true
index 7cd8b09d64a865737c1e4626b451c73c6c03ef64..05a42437330601a490b4a54c48505b5b40eed00d 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/set-e/cmd2.1 149781 2005-09-04 11:59:59Z stefanf $
 set -e
 false
 exit 0
 set -e
 false
 exit 0
index 6a5937d496ae5f425288f80ac4f90f298600d97a..38ccaec6785b244d804a760e6f3176d1a2c598f8 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/set-e/elif1.0 211399 2010-08-16 17:18:08Z jilles $
 set -e
 if false; then
        :
 set -e
 if false; then
        :
index 9dbb4bf514af45b8ee6630c1473f727fb434dc5a..694b3f0cad5c4ddfe5a81502e24333bc7fbc80e5 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/set-e/elif2.0 211399 2010-08-16 17:18:08Z jilles $
 set -e
 if false; then
        :
 set -e
 if false; then
        :
index 9b7f67b6b0d4a692855c7f285af167f3190d50aa..cefaf91114ddfbc3b9e35f616bfaa525eb74831e 100644 (file)
@@ -1,3 +1,3 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/set-e/eval1.0 193178 2009-05-31 17:23:27Z stefanf $
 set -e
 eval false || true
 set -e
 eval false || true
index 8bb7f3a92fcb72bafe78e97f8f232ed2df6b9677..e396e1ce06f8115795413de50bbba0c5ad5db40c 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/set-e/eval2.1 193178 2009-05-31 17:23:27Z stefanf $
 set -e
 eval false
 exit 0
 set -e
 eval false
 exit 0
index 67eb718ee614c35a978601758027a0a9def77ebf..d0f7d8f6d2c9ae94c3a83f2ef475ff93611e8760 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/set-e/for1.0 149791 2005-09-05 09:42:10Z stefanf $
 set -e
 f() {
        for i in a b c; do
 set -e
 f() {
        for i in a b c; do
index 3c6b70492fa220c713abd0fc07678330cdf762e7..c76d689fadb5bde9be3e84b0cfe013866707f09f 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/set-e/func1.0 149791 2005-09-05 09:42:10Z stefanf $
 set -e
 f() {
        false
 set -e
 f() {
        false
index cc76d6edfa536f4e8f236219655d954035780c56..267966d0c7f2f84934c8a9338f7f84211bf06084 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/set-e/func2.1 149791 2005-09-05 09:42:10Z stefanf $
 set -e
 f() {
        false
 set -e
 f() {
        false
index 36aa4bdcbcd31a919f913c99e0fa307540d6380f..5697e2fdb1d2557f13fe02e5dd1f28bfa51e0bef 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/set-e/if1.0 211399 2010-08-16 17:18:08Z jilles $
 set -e
 if false; then
        :
 set -e
 if false; then
        :
index 4955408540994b688da3b1af40364fc6768321bb..188361bcac4e9506d3e1cd5dd60dbce48c3371be 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/set-e/if2.0 149781 2005-09-04 11:59:59Z stefanf $
 set -e
 # PR 28852
 if true; then
 set -e
 # PR 28852
 if true; then
index a4916a8426643c4fb6dc24a3543d5ed63b97df53..e3d8d6e73204ae96adb2d579d0ed58a5404c6433 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/set-e/if3.0 211399 2010-08-16 17:18:08Z jilles $
 set -e
 if false; false; then
        :
 set -e
 if false; false; then
        :
index 21c089a23221ff57a08847f9c843beb4671f47e0..b694be821a11fb8767628a159a1e2b985b1a9fc3 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/set-e/not1.0 149781 2005-09-04 11:59:59Z stefanf $
 set -e
 ! true
 exit 0
 set -e
 ! true
 exit 0
index 7d93b4d09e85b9219d053fcd4da8d4ef895db24c..d9ea5e90d7deb03531539c67eb171f62d5f42adb 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/set-e/not2.0 193178 2009-05-31 17:23:27Z stefanf $
 set -e
 ! false
 ! eval false
 set -e
 ! false
 ! eval false
index c2dcbe9b682a9fb4401b04f7729e28154cea93e3..5000f0b84f8c98803d5d27b0862c5383c60ab552 100644 (file)
@@ -1,3 +1,3 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/set-e/or1.0 149781 2005-09-04 11:59:59Z stefanf $
 set -e
 true || false
 set -e
 true || false
index 934e2a68de9e4d165fd9c0f8d3d13c22172547ad..696422018e80f496f6466fabadd1ec7dcfe46832 100644 (file)
@@ -1,3 +1,3 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/set-e/or2.0 149781 2005-09-04 11:59:59Z stefanf $
 set -e
 false || true
 set -e
 false || true
index 7a617a14b4a4c2ed28973abbf72dff164a16c610..29af2c2bfb0d717b73b698c477f279f092ea2daf 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/set-e/or3.1 149781 2005-09-04 11:59:59Z stefanf $
 set -e
 false || false
 exit 0
 set -e
 false || false
 exit 0
index c0bad0fa732dd0de5ab1540a4de372a32f7fe259..122af07e8ad1fbde33d6308354c6444c63fa210a 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/set-e/pipe1.1 149781 2005-09-04 11:59:59Z stefanf $
 set -e
 true | false
 exit 0
 set -e
 true | false
 exit 0
index 1e25566a156b21c86635485ce7a2db6e3c646220..d80fd93a01a5cd2b9d3d0dbe8adb93ec82fe5b09 100644 (file)
@@ -1,3 +1,3 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/set-e/pipe2.0 149781 2005-09-04 11:59:59Z stefanf $
 set -e
 false | true
 set -e
 false | true
index 961bd4120865158b044569a92e8bfc5d7a328d85..d157059422b2948fc3b0f4d419c428973c66ff91 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/set-e/return1.0 149788 2005-09-04 21:29:09Z stefanf $
 set -e
 
 # PR 77067, 85267
 set -e
 
 # PR 77067, 85267
index 90476a98f1ecd20dedaef97b23a3e2f3e10afbe7..5991f8d1d543691b431efef0f0da69011a7cbfbe 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/set-e/semi1.1 149781 2005-09-04 11:59:59Z stefanf $
 set -e
 false; true
 exit 0
 set -e
 false; true
 exit 0
index 8f510ac9c164e168665b1ee09ef81f0ddfe5ebbe..685170053749451d27724b36e9ee34fb75d08fb1 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/set-e/semi2.1 149781 2005-09-04 11:59:59Z stefanf $
 set -e
 true; false
 exit 0
 set -e
 true; false
 exit 0
index 8e5831bd19074c1ff5fca889189b0409c974e2f7..fa2ec820abd23a68afeb4b0001360dfbe0f4b222 100644 (file)
@@ -1,3 +1,3 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/set-e/subshell1.0 149781 2005-09-04 11:59:59Z stefanf $
 set -e
 (true)
 set -e
 (true)
index 619e98a7d2df86307f19473509e2a429e4825f12..03b09dc1801c37c4b22205f7fa7be1eba6b36d32 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/set-e/subshell2.1 149781 2005-09-04 11:59:59Z stefanf $
 set -e
 (false)
 exit 0
 set -e
 (false)
 exit 0
index 71ea7f2cf704659d43b48e8278f1c51fd07ffedb..c4d2edd74b7e3b118b53142b5a67ab20bbc5db05 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/set-e/until1.0 149781 2005-09-04 11:59:59Z stefanf $
 set -e
 until false; do
        break
 set -e
 until false; do
        break
index 24ea2760400b16910a4bfbc64d585c7ce6bc1400..d19a7408ca8d6e691a09702b717b2401e65ee121 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/set-e/until2.0 149781 2005-09-04 11:59:59Z stefanf $
 set -e
 until false; false; do
        break
 set -e
 until false; false; do
        break
index 597db593bdaf234ee7809a23c7e4b761157c5ed1..2f779033fe4c927822ceaa1544eb8ea09d767c9c 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/set-e/until3.0 149791 2005-09-05 09:42:10Z stefanf $
 set -e
 f() {
        until false; do
 set -e
 f() {
        until false; do
index 371c94a0440da8da30af10b2bd4c85c27e187f7f..6d7fe0a7d1291c02e234f85f600c09b41478dc72 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/set-e/while1.0 211399 2010-08-16 17:18:08Z jilles $
 set -e
 while false; do
        :
 set -e
 while false; do
        :
index 124966ca59e97a3aa73df642c464754f937371d5..fe2f2baad1970dc77dbfa7a7b269d8e06634729b 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/set-e/while2.0 211399 2010-08-16 17:18:08Z jilles $
 set -e
 while false; false; do
        :
 set -e
 while false; false; do
        :
index dd3c790252366ed523ca95c4650e64756f758387..bf871754ed6fe917662a71b888ecd2664c15b41e 100644 (file)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/tests/set-e/while3.0 149791 2005-09-05 09:42:10Z stefanf $
 set -e
 f() {
        while true; do
 set -e
 f() {
        while true; do
index b90fee8f3d0698db0b0e1abb59cc5d74aa0feb94..7a969ed623d209b7d3a76a0270db13201ad8ac49 100644 (file)
--- a/sh/trap.c
+++ b/sh/trap.c
@@ -36,7 +36,7 @@ static char sccsid[] = "@(#)trap.c    8.5 (Berkeley) 6/5/95";
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/bin/sh/trap.c 297360 2016-03-28 18:58:40Z jilles $");
 
 #include <signal.h>
 #include <unistd.h>
 
 #include <signal.h>
 #include <unistd.h>
@@ -415,6 +415,7 @@ onsig(int signo)
 void
 dotrap(void)
 {
 void
 dotrap(void)
 {
+       struct stackmark smark;
        int i;
        int savestatus, prev_evalskip, prev_skipcount;
 
        int i;
        int savestatus, prev_evalskip, prev_skipcount;
 
@@ -448,7 +449,9 @@ dotrap(void)
 
                                        last_trapsig = i;
                                        savestatus = exitstatus;
 
                                        last_trapsig = i;
                                        savestatus = exitstatus;
-                                       evalstring(trap[i], 0);
+                                       setstackmark(&smark);
+                                       evalstring(stsavestr(trap[i]), 0);
+                                       popstackmark(&smark);
 
                                        /*
                                         * If such a command was not
 
                                        /*
                                         * If such a command was not
index a27283926997fadc4d64fbe97f912638a704a923..a000647158e96b97dac67cef38448444fb43835c 100644 (file)
--- a/sh/trap.h
+++ b/sh/trap.h
@@ -30,7 +30,7 @@
  * SUCH DAMAGE.
  *
  *     @(#)trap.h      8.3 (Berkeley) 6/5/95
  * SUCH DAMAGE.
  *
  *     @(#)trap.h      8.3 (Berkeley) 6/5/95
- * $FreeBSD$
+ * $FreeBSD: head/bin/sh/trap.h 276038 2014-12-21 23:09:59Z jilles $
  */
 
 extern volatile sig_atomic_t pendingsig;
  */
 
 extern volatile sig_atomic_t pendingsig;
index f60dea16dfdf6096eec484966ea2c69549350677..5ff6d2076957aeee17523b1415d9515b943c7901 100644 (file)
--- a/sh/var.c
+++ b/sh/var.c
@@ -36,7 +36,7 @@ static char sccsid[] = "@(#)var.c     8.3 (Berkeley) 5/4/95";
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/bin/sh/var.c 306843 2016-10-08 13:40:12Z jilles $");
 
 #include <unistd.h>
 #include <stdlib.h>
 
 #include <unistd.h>
 #include <stdlib.h>
@@ -186,6 +186,7 @@ initvar(void)
                }
        }
        setvareq_const("OPTIND=1", 0);
                }
        }
        setvareq_const("OPTIND=1", 0);
+       setvareq_const("IFS= \t\n", 0);
 }
 
 /*
 }
 
 /*
@@ -330,7 +331,7 @@ setvareq(char *s, int flags)
                if (vp->flags & VREADONLY) {
                        if ((flags & (VTEXTFIXED|VSTACK)) == 0)
                                ckfree(s);
                if (vp->flags & VREADONLY) {
                        if ((flags & (VTEXTFIXED|VSTACK)) == 0)
                                ckfree(s);
-                       error("%.*s: is read only", vp->name_len, s);
+                       error("%.*s: is read only", vp->name_len, vp->text);
                }
                if (flags & VNOSET) {
                        if ((flags & (VTEXTFIXED|VSTACK)) == 0)
                }
                if (flags & VNOSET) {
                        if ((flags & (VTEXTFIXED|VSTACK)) == 0)
@@ -403,14 +404,13 @@ setvareq_const(const char *s, int flags)
  */
 
 void
  */
 
 void
-listsetvar(struct strlist *list, int flags)
+listsetvar(struct arglist *list, int flags)
 {
 {
-       struct strlist *lp;
+       int i;
 
        INTOFF;
 
        INTOFF;
-       for (lp = list ; lp ; lp = lp->next) {
-               setvareq(savestr(lp->text), flags);
-       }
+       for (i = 0; i < list->count; i++)
+               setvareq(savestr(list->args[i]), flags);
        INTON;
 }
 
        INTON;
 }
 
@@ -442,14 +442,14 @@ lookupvar(const char *name)
 char *
 bltinlookup(const char *name, int doall)
 {
 char *
 bltinlookup(const char *name, int doall)
 {
-       struct strlist *sp;
        struct var *v;
        char *result;
        struct var *v;
        char *result;
+       int i;
 
        result = NULL;
 
        result = NULL;
-       for (sp = cmdenviron ; sp ; sp = sp->next) {
-               if (varequal(sp->text, name))
-                       result = strchr(sp->text, '=') + 1;
+       if (cmdenviron) for (i = 0; i < cmdenviron->count; i++) {
+               if (varequal(cmdenviron->args[i], name))
+                       result = strchr(cmdenviron->args[i], '=') + 1;
        }
        if (result != NULL)
                return result;
        }
        if (result != NULL)
                return result;
@@ -468,13 +468,12 @@ bltinlookup(const char *name, int doall)
 void
 bltinsetlocale(void)
 {
 void
 bltinsetlocale(void)
 {
-       struct strlist *lp;
        int act = 0;
        char *loc, *locdef;
        int i;
 
        int act = 0;
        char *loc, *locdef;
        int i;
 
-       for (lp = cmdenviron ; lp ; lp = lp->next) {
-               if (localevar(lp->text)) {
+       if (cmdenviron) for (i = 0; i < cmdenviron->count; i++) {
+               if (localevar(cmdenviron->args[i])) {
                        act = 1;
                        break;
                }
                        act = 1;
                        break;
                }
@@ -507,11 +506,11 @@ bltinsetlocale(void)
 void
 bltinunsetlocale(void)
 {
 void
 bltinunsetlocale(void)
 {
-       struct strlist *lp;
+       int i;
 
        INTOFF;
 
        INTOFF;
-       for (lp = cmdenviron ; lp ; lp = lp->next) {
-               if (localevar(lp->text)) {
+       if (cmdenviron) for (i = 0; i < cmdenviron->count; i++) {
+               if (localevar(cmdenviron->args[i])) {
                        setlocale(LC_ALL, "");
                        updatecharset();
                        return;
                        setlocale(LC_ALL, "");
                        updatecharset();
                        return;
@@ -756,8 +755,8 @@ mklocal(char *name)
        INTOFF;
        lvp = ckmalloc(sizeof (struct localvar));
        if (name[0] == '-' && name[1] == '\0') {
        INTOFF;
        lvp = ckmalloc(sizeof (struct localvar));
        if (name[0] == '-' && name[1] == '\0') {
-               lvp->text = ckmalloc(sizeof optlist);
-               memcpy(lvp->text, optlist, sizeof optlist);
+               lvp->text = ckmalloc(sizeof optval);
+               memcpy(lvp->text, optval, sizeof optval);
                vp = NULL;
        } else {
                vp = find_var(name, &vpp, NULL);
                vp = NULL;
        } else {
                vp = find_var(name, &vpp, NULL);
@@ -793,22 +792,34 @@ poplocalvars(void)
 {
        struct localvar *lvp;
        struct var *vp;
 {
        struct localvar *lvp;
        struct var *vp;
+       int islocalevar;
 
        INTOFF;
        while ((lvp = localvars) != NULL) {
                localvars = lvp->next;
                vp = lvp->vp;
                if (vp == NULL) {       /* $- saved */
 
        INTOFF;
        while ((lvp = localvars) != NULL) {
                localvars = lvp->next;
                vp = lvp->vp;
                if (vp == NULL) {       /* $- saved */
-                       memcpy(optlist, lvp->text, sizeof optlist);
+                       memcpy(optval, lvp->text, sizeof optval);
                        ckfree(lvp->text);
                        optschanged();
                } else if ((lvp->flags & (VUNSET|VSTRFIXED)) == VUNSET) {
                        ckfree(lvp->text);
                        optschanged();
                } else if ((lvp->flags & (VUNSET|VSTRFIXED)) == VUNSET) {
+                       vp->flags &= ~VREADONLY;
                        (void)unsetvar(vp->text);
                } else {
                        (void)unsetvar(vp->text);
                } else {
+                       islocalevar = (vp->flags | lvp->flags) & VEXPORT &&
+                           localevar(lvp->text);
                        if ((vp->flags & VTEXTFIXED) == 0)
                                ckfree(vp->text);
                        vp->flags = lvp->flags;
                        vp->text = lvp->text;
                        if ((vp->flags & VTEXTFIXED) == 0)
                                ckfree(vp->text);
                        vp->flags = lvp->flags;
                        vp->text = lvp->text;
+                       if (vp->func)
+                               (*vp->func)(vp->text + vp->name_len + 1);
+                       if (islocalevar) {
+                               change_env(vp->text, vp->flags & VEXPORT &&
+                                   (vp->flags & VUNSET) == 0);
+                               setlocale(LC_ALL, "");
+                               updatecharset();
+                       }
                }
                ckfree(lvp);
        }
                }
                ckfree(lvp);
        }
index 6e831aef3fb05a20a4f224f01a9304f2026b8a60..7955c041f2730ceddd72f55cebc0118188d04b1e 100644 (file)
--- a/sh/var.h
+++ b/sh/var.h
@@ -30,7 +30,7 @@
  * SUCH DAMAGE.
  *
  *     @(#)var.h       8.2 (Berkeley) 5/4/95
  * SUCH DAMAGE.
  *
  *     @(#)var.h       8.2 (Berkeley) 5/4/95
- * $FreeBSD$
+ * $FreeBSD: head/bin/sh/var.h 289159 2015-10-11 21:33:00Z jilles $
  */
 
 /*
  */
 
 /*
@@ -114,8 +114,8 @@ extern int initial_localeisutf8;
 void initvar(void);
 void setvar(const char *, const char *, int);
 void setvareq(char *, int);
 void initvar(void);
 void setvar(const char *, const char *, int);
 void setvareq(char *, int);
-struct strlist;
-void listsetvar(struct strlist *, int);
+struct arglist;
+void listsetvar(struct arglist *, int);
 char *lookupvar(const char *);
 char *bltinlookup(const char *, int);
 void bltinsetlocale(void);
 char *lookupvar(const char *);
 char *bltinlookup(const char *, int);
 void bltinsetlocale(void);
index 26fdc28bcc66e2d712037cafe657fbe2be72f439..ec1e2314ce93aefb9b07614a51c0e82464ee7a96 100644 (file)
                FCE30EE014B536F200CC0294 /* locate.code.c in Sources */ = {isa = PBXBuildFile; fileRef = FCBA13A114A141A300AA698B /* locate.code.c */; };
                FCE30EE114B536F800CC0294 /* locate.code.8 in CopyFiles */ = {isa = PBXBuildFile; fileRef = FCBA13B114A141A300AA698B /* locate.code.8 */; };
                FCED3AF614B4FC1800C313C3 /* libpam.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = FCED3AF514B4FC1800C313C3 /* libpam.dylib */; };
                FCE30EE014B536F200CC0294 /* locate.code.c in Sources */ = {isa = PBXBuildFile; fileRef = FCBA13A114A141A300AA698B /* locate.code.c */; };
                FCE30EE114B536F800CC0294 /* locate.code.8 in CopyFiles */ = {isa = PBXBuildFile; fileRef = FCBA13B114A141A300AA698B /* locate.code.8 */; };
                FCED3AF614B4FC1800C313C3 /* libpam.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = FCED3AF514B4FC1800C313C3 /* libpam.dylib */; };
+               FD155C751D6E37E5005A53CA /* legacy_test.sh in CopyFiles */ = {isa = PBXBuildFile; fileRef = FD155C721D6E37B5005A53CA /* legacy_test.sh */; };
+               FD155C891D6E38C0005A53CA /* legacy_test.sh in CopyFiles */ = {isa = PBXBuildFile; fileRef = FD155C771D6E3847005A53CA /* legacy_test.sh */; };
+               FD155C8A1D6E38C0005A53CA /* regress.b.out in CopyFiles */ = {isa = PBXBuildFile; fileRef = FD155C7A1D6E3847005A53CA /* regress.b.out */; };
+               FD155C8B1D6E38C0005A53CA /* regress.d.out in CopyFiles */ = {isa = PBXBuildFile; fileRef = FD155C7B1D6E3847005A53CA /* regress.d.out */; };
+               FD155C8C1D6E38C0005A53CA /* regress.f.out in CopyFiles */ = {isa = PBXBuildFile; fileRef = FD155C7C1D6E3847005A53CA /* regress.f.out */; };
+               FD155C8D1D6E38C0005A53CA /* regress.l1.out in CopyFiles */ = {isa = PBXBuildFile; fileRef = FD155C7D1D6E3847005A53CA /* regress.l1.out */; };
+               FD155C8E1D6E38C0005A53CA /* regress.l2.out in CopyFiles */ = {isa = PBXBuildFile; fileRef = FD155C7E1D6E3847005A53CA /* regress.l2.out */; };
+               FD155C8F1D6E38C0005A53CA /* regress.m1.out in CopyFiles */ = {isa = PBXBuildFile; fileRef = FD155C7F1D6E3847005A53CA /* regress.m1.out */; };
+               FD155C901D6E38C0005A53CA /* regress.m2.out in CopyFiles */ = {isa = PBXBuildFile; fileRef = FD155C801D6E3847005A53CA /* regress.m2.out */; };
+               FD155C911D6E38C0005A53CA /* regress.m3.out in CopyFiles */ = {isa = PBXBuildFile; fileRef = FD155C811D6E3847005A53CA /* regress.m3.out */; };
+               FD155C921D6E38C0005A53CA /* regress.m4.out in CopyFiles */ = {isa = PBXBuildFile; fileRef = FD155C821D6E3847005A53CA /* regress.m4.out */; };
+               FD155C931D6E38C0005A53CA /* regress.m5.out in CopyFiles */ = {isa = PBXBuildFile; fileRef = FD155C831D6E3847005A53CA /* regress.m5.out */; };
+               FD155C941D6E38C0005A53CA /* regress.missingpos1.out in CopyFiles */ = {isa = PBXBuildFile; fileRef = FD155C841D6E3847005A53CA /* regress.missingpos1.out */; };
+               FD155C951D6E38C0005A53CA /* regress.s.out in CopyFiles */ = {isa = PBXBuildFile; fileRef = FD155C851D6E3847005A53CA /* regress.s.out */; };
+               FD155C961D6E38C0005A53CA /* regress.sh in CopyFiles */ = {isa = PBXBuildFile; fileRef = FD155C861D6E3847005A53CA /* regress.sh */; };
+               FD155C971D6E38C0005A53CA /* regress.zero.out in CopyFiles */ = {isa = PBXBuildFile; fileRef = FD155C871D6E3847005A53CA /* regress.zero.out */; };
                FD6060B51B7C0388004BCA6A /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = FD6060B41B7C0388004BCA6A /* main.c */; };
                FD6060D21B7C0471004BCA6A /* alias.c in Sources */ = {isa = PBXBuildFile; fileRef = FD6060BC1B7C0471004BCA6A /* alias.c */; };
                FD6060D31B7C0471004BCA6A /* arith_yacc.c in Sources */ = {isa = PBXBuildFile; fileRef = FD6060BD1B7C0471004BCA6A /* arith_yacc.c */; };
                FD6060B51B7C0388004BCA6A /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = FD6060B41B7C0388004BCA6A /* main.c */; };
                FD6060D21B7C0471004BCA6A /* alias.c in Sources */ = {isa = PBXBuildFile; fileRef = FD6060BC1B7C0471004BCA6A /* alias.c */; };
                FD6060D31B7C0471004BCA6A /* arith_yacc.c in Sources */ = {isa = PBXBuildFile; fileRef = FD6060BD1B7C0471004BCA6A /* arith_yacc.c */; };
                        );
                        runOnlyForDeploymentPostprocessing = 1;
                };
                        );
                        runOnlyForDeploymentPostprocessing = 1;
                };
+               FD155C741D6E37D7005A53CA /* CopyFiles */ = {
+                       isa = PBXCopyFilesBuildPhase;
+                       buildActionMask = 2147483647;
+                       dstPath = /AppleInternal/Tests/shell_cmds/test;
+                       dstSubfolderSpec = 0;
+                       files = (
+                               FD155C751D6E37E5005A53CA /* legacy_test.sh in CopyFiles */,
+                       );
+                       runOnlyForDeploymentPostprocessing = 0;
+               };
+               FD155C881D6E38AB005A53CA /* CopyFiles */ = {
+                       isa = PBXCopyFilesBuildPhase;
+                       buildActionMask = 2147483647;
+                       dstPath = /AppleInternal/Tests/shell_cmds/printf;
+                       dstSubfolderSpec = 0;
+                       files = (
+                               FD155C891D6E38C0005A53CA /* legacy_test.sh in CopyFiles */,
+                               FD155C8A1D6E38C0005A53CA /* regress.b.out in CopyFiles */,
+                               FD155C8B1D6E38C0005A53CA /* regress.d.out in CopyFiles */,
+                               FD155C8C1D6E38C0005A53CA /* regress.f.out in CopyFiles */,
+                               FD155C8D1D6E38C0005A53CA /* regress.l1.out in CopyFiles */,
+                               FD155C8E1D6E38C0005A53CA /* regress.l2.out in CopyFiles */,
+                               FD155C8F1D6E38C0005A53CA /* regress.m1.out in CopyFiles */,
+                               FD155C901D6E38C0005A53CA /* regress.m2.out in CopyFiles */,
+                               FD155C911D6E38C0005A53CA /* regress.m3.out in CopyFiles */,
+                               FD155C921D6E38C0005A53CA /* regress.m4.out in CopyFiles */,
+                               FD155C931D6E38C0005A53CA /* regress.m5.out in CopyFiles */,
+                               FD155C941D6E38C0005A53CA /* regress.missingpos1.out in CopyFiles */,
+                               FD155C951D6E38C0005A53CA /* regress.s.out in CopyFiles */,
+                               FD155C961D6E38C0005A53CA /* regress.sh in CopyFiles */,
+                               FD155C971D6E38C0005A53CA /* regress.zero.out in CopyFiles */,
+                       );
+                       runOnlyForDeploymentPostprocessing = 0;
+               };
 /* End PBXCopyFilesBuildPhase section */
 
 /* Begin PBXFileReference section */
 /* End PBXCopyFilesBuildPhase section */
 
 /* Begin PBXFileReference section */
                FCE30ED214B5368A00CC0294 /* locate.bigram */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = locate.bigram; sourceTree = BUILT_PRODUCTS_DIR; };
                FCE30EDE14B536C900CC0294 /* locate.code */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = locate.code; sourceTree = BUILT_PRODUCTS_DIR; };
                FCED3AF514B4FC1800C313C3 /* libpam.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libpam.dylib; path = /usr/lib/libpam.dylib; sourceTree = "<absolute>"; };
                FCE30ED214B5368A00CC0294 /* locate.bigram */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = locate.bigram; sourceTree = BUILT_PRODUCTS_DIR; };
                FCE30EDE14B536C900CC0294 /* locate.code */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = locate.code; sourceTree = BUILT_PRODUCTS_DIR; };
                FCED3AF514B4FC1800C313C3 /* libpam.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libpam.dylib; path = /usr/lib/libpam.dylib; sourceTree = "<absolute>"; };
+               FD155C721D6E37B5005A53CA /* legacy_test.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = legacy_test.sh; sourceTree = "<group>"; };
+               FD155C771D6E3847005A53CA /* legacy_test.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = legacy_test.sh; sourceTree = "<group>"; };
+               FD155C7A1D6E3847005A53CA /* regress.b.out */ = {isa = PBXFileReference; lastKnownFileType = text; path = regress.b.out; sourceTree = "<group>"; };
+               FD155C7B1D6E3847005A53CA /* regress.d.out */ = {isa = PBXFileReference; lastKnownFileType = text; path = regress.d.out; sourceTree = "<group>"; };
+               FD155C7C1D6E3847005A53CA /* regress.f.out */ = {isa = PBXFileReference; lastKnownFileType = text; path = regress.f.out; sourceTree = "<group>"; };
+               FD155C7D1D6E3847005A53CA /* regress.l1.out */ = {isa = PBXFileReference; lastKnownFileType = text; path = regress.l1.out; sourceTree = "<group>"; };
+               FD155C7E1D6E3847005A53CA /* regress.l2.out */ = {isa = PBXFileReference; lastKnownFileType = text; path = regress.l2.out; sourceTree = "<group>"; };
+               FD155C7F1D6E3847005A53CA /* regress.m1.out */ = {isa = PBXFileReference; lastKnownFileType = file; path = regress.m1.out; sourceTree = "<group>"; };
+               FD155C801D6E3847005A53CA /* regress.m2.out */ = {isa = PBXFileReference; lastKnownFileType = text; path = regress.m2.out; sourceTree = "<group>"; };
+               FD155C811D6E3847005A53CA /* regress.m3.out */ = {isa = PBXFileReference; lastKnownFileType = text; path = regress.m3.out; sourceTree = "<group>"; };
+               FD155C821D6E3847005A53CA /* regress.m4.out */ = {isa = PBXFileReference; lastKnownFileType = text; path = regress.m4.out; sourceTree = "<group>"; };
+               FD155C831D6E3847005A53CA /* regress.m5.out */ = {isa = PBXFileReference; lastKnownFileType = text; path = regress.m5.out; sourceTree = "<group>"; };
+               FD155C841D6E3847005A53CA /* regress.missingpos1.out */ = {isa = PBXFileReference; lastKnownFileType = text; path = regress.missingpos1.out; sourceTree = "<group>"; };
+               FD155C851D6E3847005A53CA /* regress.s.out */ = {isa = PBXFileReference; lastKnownFileType = text; path = regress.s.out; sourceTree = "<group>"; };
+               FD155C861D6E3847005A53CA /* regress.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = regress.sh; sourceTree = "<group>"; };
+               FD155C871D6E3847005A53CA /* regress.zero.out */ = {isa = PBXFileReference; lastKnownFileType = text; path = regress.zero.out; sourceTree = "<group>"; };
                FD6060B21B7C0388004BCA6A /* ash */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = ash; sourceTree = BUILT_PRODUCTS_DIR; };
                FD6060B41B7C0388004BCA6A /* main.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = main.c; sourceTree = "<group>"; };
                FD6060BC1B7C0471004BCA6A /* alias.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = alias.c; sourceTree = "<group>"; };
                FD6060B21B7C0388004BCA6A /* ash */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = ash; sourceTree = BUILT_PRODUCTS_DIR; };
                FD6060B41B7C0388004BCA6A /* main.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = main.c; sourceTree = "<group>"; };
                FD6060BC1B7C0471004BCA6A /* alias.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = alias.c; sourceTree = "<group>"; };
                        children = (
                                FCBA13D414A141A300AA698B /* printf.1 */,
                                FCBA13D514A141A300AA698B /* printf.c */,
                        children = (
                                FCBA13D414A141A300AA698B /* printf.1 */,
                                FCBA13D514A141A300AA698B /* printf.c */,
+                               FD155C761D6E3847005A53CA /* tests */,
                        );
                        path = printf;
                        sourceTree = "<group>";
                        );
                        path = printf;
                        sourceTree = "<group>";
                                FCBA13F814A141A300AA698B /* [.1 */,
                                FCBA13FA14A141A300AA698B /* test.1 */,
                                FCBA13FB14A141A300AA698B /* test.c */,
                                FCBA13F814A141A300AA698B /* [.1 */,
                                FCBA13FA14A141A300AA698B /* test.1 */,
                                FCBA13FB14A141A300AA698B /* test.c */,
+                               FD155C711D6E37B5005A53CA /* tests */,
                        );
                        path = test;
                        sourceTree = "<group>";
                        );
                        path = test;
                        sourceTree = "<group>";
                        path = yes;
                        sourceTree = "<group>";
                };
                        path = yes;
                        sourceTree = "<group>";
                };
+               FD155C711D6E37B5005A53CA /* tests */ = {
+                       isa = PBXGroup;
+                       children = (
+                               FD155C721D6E37B5005A53CA /* legacy_test.sh */,
+                       );
+                       path = tests;
+                       sourceTree = "<group>";
+               };
+               FD155C761D6E3847005A53CA /* tests */ = {
+                       isa = PBXGroup;
+                       children = (
+                               FD155C771D6E3847005A53CA /* legacy_test.sh */,
+                               FD155C7A1D6E3847005A53CA /* regress.b.out */,
+                               FD155C7B1D6E3847005A53CA /* regress.d.out */,
+                               FD155C7C1D6E3847005A53CA /* regress.f.out */,
+                               FD155C7D1D6E3847005A53CA /* regress.l1.out */,
+                               FD155C7E1D6E3847005A53CA /* regress.l2.out */,
+                               FD155C7F1D6E3847005A53CA /* regress.m1.out */,
+                               FD155C801D6E3847005A53CA /* regress.m2.out */,
+                               FD155C811D6E3847005A53CA /* regress.m3.out */,
+                               FD155C821D6E3847005A53CA /* regress.m4.out */,
+                               FD155C831D6E3847005A53CA /* regress.m5.out */,
+                               FD155C841D6E3847005A53CA /* regress.missingpos1.out */,
+                               FD155C851D6E3847005A53CA /* regress.s.out */,
+                               FD155C861D6E3847005A53CA /* regress.sh */,
+                               FD155C871D6E3847005A53CA /* regress.zero.out */,
+                       );
+                       path = tests;
+                       sourceTree = "<group>";
+               };
                FD6060B31B7C0388004BCA6A /* sh */ = {
                        isa = PBXGroup;
                        children = (
                FD6060B31B7C0388004BCA6A /* sh */ = {
                        isa = PBXGroup;
                        children = (
                                FCBA159F14A1459000AA698B /* Sources */,
                                FCBA15A014A1459000AA698B /* Frameworks */,
                                FCBA15A114A1459000AA698B /* CopyFiles */,
                                FCBA159F14A1459000AA698B /* Sources */,
                                FCBA15A014A1459000AA698B /* Frameworks */,
                                FCBA15A114A1459000AA698B /* CopyFiles */,
+                               FD155C881D6E38AB005A53CA /* CopyFiles */,
                        );
                        buildRules = (
                        );
                        );
                        buildRules = (
                        );
                                FCBA15E714A145AE00AA698B /* Sources */,
                                FCBA15E814A145AE00AA698B /* Frameworks */,
                                FCBA15E914A145AE00AA698B /* CopyFiles */,
                                FCBA15E714A145AE00AA698B /* Sources */,
                                FCBA15E814A145AE00AA698B /* Frameworks */,
                                FCBA15E914A145AE00AA698B /* CopyFiles */,
+                               FD155C741D6E37D7005A53CA /* CopyFiles */,
                        );
                        buildRules = (
                        );
                        );
                        buildRules = (
                        );
index 922955129d9fcde3e4766e389ab3da6f1ab7ee10..21c74a8c05fadaeafe86a7bbecd40330a8df102a 100644 (file)
@@ -30,6 +30,8 @@
 #
 # $FreeBSD$
 
 #
 # $FreeBSD$
 
+enable -n test
+
 # force a specified test program, e.g. `env test=/bin/test sh regress.sh'
 : ${test=test}         
 
 # force a specified test program, e.g. `env test=/bin/test sh regress.sh'
 : ${test=test}         
 
@@ -39,20 +41,25 @@ t ()
        # $2 -> $test expression
 
        count=$((count+1))
        # $2 -> $test expression
 
        count=$((count+1))
+       printf "[BEGIN] test $count\n"
        # check for syntax errors
        syntax="`eval $test $2 2>&1`"
        ret=$?
        if test -n "$syntax"; then
                printf "not ok %s - (syntax error)\n" "$count $2"
        # check for syntax errors
        syntax="`eval $test $2 2>&1`"
        ret=$?
        if test -n "$syntax"; then
                printf "not ok %s - (syntax error)\n" "$count $2"
+               printf "[FAIL] test $count\n"
        elif [ "$ret" != "$1" ]; then
                printf "not ok %s - (got $ret, expected $1)\n" "$count $2"
        elif [ "$ret" != "$1" ]; then
                printf "not ok %s - (got $ret, expected $1)\n" "$count $2"
+               printf "[FAIL] test $count\n"
        else
                printf "ok %s\n" "$count $2"
        else
                printf "ok %s\n" "$count $2"
+               printf "[PASS] test $count\n"
        fi
 }
 
 count=0
 echo "1..130"
        fi
 }
 
 count=0
 echo "1..130"
+printf "[TEST] shell_cmds: test\n"
 
 t 0 'b = b' 
 t 0 'b == b' 
 
 t 0 'b = b' 
 t 0 'b == b' 
diff --git a/tests/regress.m4 b/tests/regress.m4
new file mode 100644 (file)
index 0000000..c06caa1
--- /dev/null
@@ -0,0 +1,59 @@
+# $FreeBSD: head/usr.bin/tests/regress.m4 263227 2014-03-16 08:04:06Z jmmv $
+
+dnl A library of routines for doing regression tests for userland utilities.
+
+dnl Start up.  We initialise the exit status to 0 (no failure) and change
+dnl into the directory specified by our first argument, which is the
+dnl directory to run the tests inside.
+define(`REGRESSION_START',
+TESTDIR=$1
+if [ -z "$TESTDIR" ]; then
+  TESTDIR=.
+fi
+cd $TESTDIR
+
+STATUS=0)
+
+dnl Check $? to see if we passed or failed.  The first parameter is the test
+dnl which passed or failed.  It may be nil.
+define(`REGRESSION_PASSFAIL',
+if [ $? -eq 0 ]; then
+  echo "ok - $1 # Test detected no regression. (in $TESTDIR)"
+else
+  STATUS=$?
+  echo "not ok - $1 # Test failed: regression detected.  See above. (in $TESTDIR)"
+fi)
+
+dnl An actual test.  The first parameter is the test name.  The second is the
+dnl command/commands to execute for the actual test.  Their exit status is
+dnl checked.  It is assumed that the test will output to stdout, and that the
+dnl output to be used to check for regression will be in regress.TESTNAME.out.
+define(`REGRESSION_TEST',
+$2 | diff -u ${SRCDIR:-.}/regress.$1.out -
+REGRESSION_PASSFAIL($1))
+
+dnl A freeform regression test.  Only exit status is checked.
+define(`REGRESSION_TEST_FREEFORM',
+$2
+REGRESSION_PASSFAIL($1))
+
+dnl A regression test like REGRESSION_TEST, except only regress.out is used
+dnl for checking output differences.  The first argument is the command, the
+dnl second argument (which may be empty) is the test name.
+define(`REGRESSION_TEST_ONE',
+$1 | diff -u ${SRCDIR:-.}/regress.out -
+REGRESSION_PASSFAIL($2))
+
+dnl A fatal error.  This will exit with the given status (first argument) and
+dnl print the message (second argument) prefixed with the string "FATAL :" to
+dnl the error stream.
+define(`REGRESSION_FATAL',
+echo "Bail out! $2 (in $TESTDIR)" > /dev/stderr
+exit $1)
+
+dnl Cleanup.  Exit with the status code of the last failure.  Should probably
+dnl be the number of failed tests, but hey presto, this is what it does.  This
+dnl could also clean up potential droppings, if some forms of regression tests
+dnl end up using mktemp(1) or such.
+define(`REGRESSION_END',
+exit $STATUS)
diff --git a/tests/shell_cmds.plist b/tests/shell_cmds.plist
new file mode 100644 (file)
index 0000000..3794d3d
--- /dev/null
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>Project</key>
+       <string>libutil</string>
+       <key>Tests</key>
+       <array>
+               <dict>
+                       <key>Command</key>
+                       <array>
+                               <string>/bin/sh</string>
+                               <string>/AppleInternal/Tests/shell_cmds/printf/legacy_test.sh</string>
+                       </array>
+                       <key>IgnoreOutput</key>
+                       <true/>
+                       <key>TestName</key>
+                       <string>shell_cmds: printf</string>
+                       <key>WhenToRun</key>
+                       <array>
+                               <string>PRESUBMISSION</string>
+                               <string>NIGHTLY</string>
+                       </array>
+               </dict>
+               <dict>
+                       <key>Command</key>
+                       <array>
+                               <string>/bin/sh</string>
+                               <string>/AppleInternal/Tests/shell_cmds/test/legacy_test.sh</string>
+                       </array>
+                       <key>TestName</key>
+                       <string>shell_cmds: test</string>
+                       <key>WhenToRun</key>
+                       <array>
+                               <string>PRESUBMISSION</string>
+                               <string>NIGHTLY</string>
+                       </array>
+               </dict>
+       </array>
+       <key>Timeout</key>
+       <integer>30</integer>
+</dict>
+</plist>
index f889e0980141d01801e078841500d52d43dc5aa6..d0f2fcbf5e08242b483a8b2f4ddf9f98a18ba66e 100644 (file)
@@ -27,9 +27,9 @@
 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.\" $FreeBSD: src/usr.bin/which/which.1,v 1.25 2005/02/10 16:04:22 ru Exp $
+.\" $FreeBSD: head/usr.bin/which/which.1 267773 2014-06-23 08:23:05Z bapt $
 .\"
 .\"
-.Dd June 21, 2002
+.Dd December 13, 2006
 .Dt WHICH 1
 .Os
 .Sh NAME
 .Dt WHICH 1
 .Os
 .Sh NAME
@@ -52,8 +52,8 @@ The following options are available:
 List all instances of executables found (instead of just the first one
 of each).
 .It Fl s
 List all instances of executables found (instead of just the first one
 of each).
 .It Fl s
-No output, just return 0 if any of the executables are found, or 1 if
-none are found.
+No output, just return 0 if all of the executables are found, or 1 if
+some were not found.
 .El
 .Pp
 Some shells may provide a builtin
 .El
 .Pp
 Some shells may provide a builtin
@@ -78,8 +78,8 @@ command first appeared in
 The
 .Nm
 utility was originally written in Perl and was contributed by
 The
 .Nm
 utility was originally written in Perl and was contributed by
-.An Wolfram Schneider Aq wosch@FreeBSD.org .
+.An Wolfram Schneider Aq Mt wosch@FreeBSD.org .
 The current version of
 .Nm
 was rewritten in C by
 The current version of
 .Nm
 was rewritten in C by
-.An Daniel Papasian Aq dpapasia@andrew.cmu.edu .
+.An Daniel Papasian Aq Mt dpapasia@andrew.cmu.edu .
index e8ecea297b9740dd47cea6cabf3366ae37260195..7e9d662a45254eb41b3e428ecbf91a443771286f 100644 (file)
@@ -26,7 +26,7 @@
 
 #include <sys/cdefs.h>
 
 
 #include <sys/cdefs.h>
 
-__FBSDID("$FreeBSD: src/usr.bin/which/which.c,v 1.6 2005/02/10 16:04:22 ru Exp $");
+__FBSDID("$FreeBSD: head/usr.bin/which/which.c 227245 2011-11-06 18:50:26Z ed $");
 
 #include <sys/stat.h>
 #include <sys/param.h>
 
 #include <sys/stat.h>
 #include <sys/param.h>
@@ -40,8 +40,8 @@ __FBSDID("$FreeBSD: src/usr.bin/which/which.c,v 1.6 2005/02/10 16:04:22 ru Exp $
 static void     usage(void);
 static int      print_matches(char *, char *);
        
 static void     usage(void);
 static int      print_matches(char *, char *);
        
-int    silent;
-int    allpaths;
+static int      silent;
+static int      allpaths;
 
 int
 main(int argc, char **argv)
 
 int
 main(int argc, char **argv)
index 7d5b69d483a5da1bef02e27df54ce4225bf5edc0..11dcad9d2361ad322bb6b9eb4c0de911f0318e81 100644 (file)
@@ -50,3 +50,9 @@ echo ".so man8/locate.updatedb.8" > "$MANDIR"/man8/locate.mklocatedb.8
 
 install -d -o root -g wheel -m 0755 "$PAMDIR"
 install -c -o root -g wheel -m 0644 "$SRCROOT"/su/su.pam "$PAMDIR"/su
 
 install -d -o root -g wheel -m 0755 "$PAMDIR"
 install -c -o root -g wheel -m 0644 "$SRCROOT"/su/su.pam "$PAMDIR"/su
+
+install -d -o root -g wheel -m 0755 "$DSTROOT"/AppleInternal/Tests/shell_cmds
+install -o root -g wheel -m 0644 "$SRCROOT"/tests/regress.m4 "$DSTROOT"/AppleInternal/Tests/shell_cmds
+
+install -d -o root -g wheel -m 0755 "$DSTROOT"/AppleInternal/CoreOS/BATS/unit_tests
+install -o root -g wheel -m 0644 "$SRCROOT"/tests/shell_cmds.plist "$DSTROOT"/AppleInternal/CoreOS/BATS/unit_tests