aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rw-r--r--bin/Makefile5
-rw-r--r--bin/Makefile.inc2
-rw-r--r--bin/cat/Makefile4
-rw-r--r--bin/cat/Makefile.depend6
-rw-r--r--bin/cat/cat.15
-rw-r--r--bin/cat/cat.c98
-rw-r--r--bin/cat/tests/Makefile1
-rw-r--r--bin/cat/tests/Makefile.depend1
-rw-r--r--bin/chflags/Makefile2
-rw-r--r--bin/chflags/Makefile.depend2
-rw-r--r--bin/chflags/chflags.13
-rw-r--r--bin/chflags/chflags.c33
-rw-r--r--bin/chflags/tests/Makefile1
-rw-r--r--bin/chflags/tests/Makefile.depend1
-rw-r--r--bin/chflags/tests/chflags_test.sh1
-rw-r--r--bin/chio/Makefile2
-rw-r--r--bin/chio/Makefile.depend2
-rw-r--r--bin/chio/chio.12
-rw-r--r--bin/chio/chio.c18
-rw-r--r--bin/chio/defs.h1
-rw-r--r--bin/chio/pathnames.h1
-rw-r--r--bin/chmod/Makefile2
-rw-r--r--bin/chmod/Makefile.depend2
-rw-r--r--bin/chmod/chmod.13
-rw-r--r--bin/chmod/chmod.c16
-rw-r--r--bin/chmod/tests/Makefile1
-rw-r--r--bin/chmod/tests/Makefile.depend1
-rwxr-xr-xbin/chmod/tests/chmod_test.sh1
-rw-r--r--bin/cp/Makefile4
-rw-r--r--bin/cp/Makefile.depend2
-rw-r--r--bin/cp/cp.123
-rw-r--r--bin/cp/cp.c122
-rw-r--r--bin/cp/extern.h7
-rw-r--r--bin/cp/tests/Makefile3
-rwxr-xr-xbin/cp/tests/cp_test.sh209
-rw-r--r--bin/cp/tests/sparse.c73
-rw-r--r--bin/cp/utils.c262
-rw-r--r--bin/cpuset/Makefile8
-rw-r--r--bin/cpuset/Makefile.depend16
-rw-r--r--bin/cpuset/cpuset.1227
-rw-r--r--bin/cpuset/cpuset.c473
-rw-r--r--bin/csh/Makefile16
-rw-r--r--bin/csh/Makefile.depend5
-rw-r--r--bin/csh/config.h1
-rw-r--r--bin/csh/config_p.h1
-rw-r--r--bin/csh/csh.cshrc1
-rw-r--r--bin/csh/csh.login1
-rw-r--r--bin/csh/csh.logout1
-rw-r--r--bin/csh/dot.cshrc1
-rw-r--r--bin/csh/dot.login1
-rw-r--r--bin/csh/iconv_stub.c2
-rw-r--r--bin/csh/iconv_stub.h2
-rw-r--r--bin/date/Makefile2
-rw-r--r--bin/date/Makefile.depend2
-rw-r--r--bin/date/date.159
-rw-r--r--bin/date/date.c165
-rw-r--r--bin/date/tests/Makefile1
-rw-r--r--bin/date/tests/Makefile.depend1
-rwxr-xr-xbin/date/tests/format_string_test.sh18
-rw-r--r--bin/date/vary.c23
-rw-r--r--bin/date/vary.h2
-rw-r--r--bin/dd/Makefile2
-rw-r--r--bin/dd/Makefile.depend4
-rw-r--r--bin/dd/args.c8
-rw-r--r--bin/dd/conv.c8
-rw-r--r--bin/dd/conv_tab.c8
-rw-r--r--bin/dd/dd.13
-rw-r--r--bin/dd/dd.c29
-rw-r--r--bin/dd/dd.h3
-rw-r--r--bin/dd/extern.h8
-rw-r--r--bin/dd/gen.c2
-rw-r--r--bin/dd/misc.c64
-rw-r--r--bin/dd/position.c16
-rw-r--r--bin/dd/ref.ascii1
-rw-r--r--bin/dd/ref.ebcdic1
-rw-r--r--bin/dd/ref.ibm1
-rw-r--r--bin/dd/ref.lcase1
-rw-r--r--bin/dd/ref.obs_zeroes1
-rw-r--r--bin/dd/ref.oldascii1
-rw-r--r--bin/dd/ref.oldebcdic1
-rw-r--r--bin/dd/ref.oldibm1
-rw-r--r--bin/dd/ref.pareven1
-rw-r--r--bin/dd/ref.parnone1
-rw-r--r--bin/dd/ref.parodd1
-rw-r--r--bin/dd/ref.parset1
-rw-r--r--bin/dd/ref.swab1
-rw-r--r--bin/dd/ref.ucase1
-rw-r--r--bin/dd/tests/Makefile1
-rw-r--r--bin/dd/tests/Makefile.depend1
-rwxr-xr-xbin/dd/tests/dd2_test.sh92
-rw-r--r--bin/df/Makefile2
-rw-r--r--bin/df/Makefile.depend4
-rw-r--r--bin/df/df.120
-rw-r--r--bin/df/df.c30
-rw-r--r--bin/domainname/Makefile1
-rw-r--r--bin/domainname/Makefile.depend2
-rw-r--r--bin/domainname/domainname.15
-rw-r--r--bin/domainname/domainname.c16
-rw-r--r--bin/echo/Makefile2
-rw-r--r--bin/echo/Makefile.depend3
-rw-r--r--bin/echo/echo.132
-rw-r--r--bin/echo/echo.c14
-rw-r--r--bin/echo/tests/Makefile1
-rw-r--r--bin/echo/tests/Makefile.depend1
-rw-r--r--bin/echo/tests/echo_test.sh1
-rw-r--r--bin/ed/Makefile1
-rw-r--r--bin/ed/Makefile.depend3
-rw-r--r--bin/ed/POSIX1
-rw-r--r--bin/ed/README1
-rw-r--r--bin/ed/buf.c2
-rw-r--r--bin/ed/ed.15
-rw-r--r--bin/ed/ed.h3
-rw-r--r--bin/ed/glbl.c3
-rw-r--r--bin/ed/io.c2
-rw-r--r--bin/ed/main.c13
-rw-r--r--bin/ed/re.c2
-rw-r--r--bin/ed/sub.c2
-rw-r--r--bin/ed/test/Makefile1
-rw-r--r--bin/ed/test/README1
-rw-r--r--bin/ed/test/ckscripts.sh1
-rw-r--r--bin/ed/test/mkscripts.sh1
-rw-r--r--bin/ed/undo.c2
-rw-r--r--bin/expr/Makefile1
-rw-r--r--bin/expr/Makefile.depend2
-rw-r--r--bin/expr/expr.12
-rw-r--r--bin/expr/expr.y2
-rw-r--r--bin/expr/tests/Makefile1
-rw-r--r--bin/expr/tests/Makefile.depend1
-rw-r--r--bin/freebsd-version/Makefile1
-rw-r--r--bin/freebsd-version/Makefile.depend1
-rw-r--r--bin/freebsd-version/freebsd-version.14
-rw-r--r--bin/freebsd-version/freebsd-version.sh.in1
-rw-r--r--bin/getfacl/Makefile1
-rw-r--r--bin/getfacl/Makefile.depend2
-rw-r--r--bin/getfacl/getfacl.12
-rw-r--r--bin/getfacl/getfacl.c5
-rw-r--r--bin/hostname/Makefile6
-rw-r--r--bin/hostname/Makefile.depend2
-rw-r--r--bin/hostname/hostname.15
-rw-r--r--bin/hostname/hostname.c14
-rw-r--r--bin/hostname/tests/Makefile6
-rw-r--r--bin/hostname/tests/hostname_test.sh93
-rw-r--r--bin/kenv/Makefile1
-rw-r--r--bin/kenv/Makefile.depend2
-rw-r--r--bin/kenv/kenv.12
-rw-r--r--bin/kenv/kenv.c3
-rw-r--r--bin/kill/Makefile2
-rw-r--r--bin/kill/Makefile.depend2
-rw-r--r--bin/kill/kill.13
-rw-r--r--bin/kill/kill.c16
-rw-r--r--bin/ln/Makefile2
-rw-r--r--bin/ln/Makefile.depend2
-rw-r--r--bin/ln/ln.13
-rw-r--r--bin/ln/ln.c122
-rw-r--r--bin/ln/symlink.73
-rw-r--r--bin/ln/tests/Makefile1
-rw-r--r--bin/ln/tests/Makefile.depend1
-rw-r--r--bin/ln/tests/ln_test.sh151
-rw-r--r--bin/ls/Makefile2
-rw-r--r--bin/ls/Makefile.depend2
-rw-r--r--bin/ls/Makefile.depend.options1
-rw-r--r--bin/ls/cmp.c23
-rw-r--r--bin/ls/extern.h5
-rw-r--r--bin/ls/ls.150
-rw-r--r--bin/ls/ls.c53
-rw-r--r--bin/ls/ls.h4
-rw-r--r--bin/ls/print.c27
-rw-r--r--bin/ls/tests/Makefile1
-rw-r--r--bin/ls/tests/Makefile.depend1
-rwxr-xr-xbin/ls/tests/ls_tests.sh35
-rw-r--r--bin/ls/util.c12
-rw-r--r--bin/mkdir/Makefile2
-rw-r--r--bin/mkdir/Makefile.depend2
-rw-r--r--bin/mkdir/mkdir.13
-rw-r--r--bin/mkdir/mkdir.c14
-rw-r--r--bin/mkdir/tests/Makefile1
-rw-r--r--bin/mkdir/tests/Makefile.depend1
-rw-r--r--bin/mkdir/tests/mkdir_test.sh1
-rw-r--r--bin/mv/Makefile2
-rw-r--r--bin/mv/Makefile.depend2
-rw-r--r--bin/mv/mv.13
-rw-r--r--bin/mv/mv.c27
-rw-r--r--bin/mv/tests/Makefile1
-rw-r--r--bin/mv/tests/Makefile.depend1
-rw-r--r--bin/mv/tests/legacy_test.sh1
-rw-r--r--bin/nproc/Makefile4
-rw-r--r--bin/nproc/nproc.160
-rw-r--r--bin/nproc/nproc.c132
-rw-r--r--bin/pax/Makefile26
-rw-r--r--bin/pax/Makefile.depend2
-rw-r--r--bin/pax/ar_io.c34
-rw-r--r--bin/pax/ar_subs.c13
-rw-r--r--bin/pax/buf_subs.c10
-rw-r--r--bin/pax/cache.c16
-rw-r--r--bin/pax/cache.h3
-rw-r--r--bin/pax/cpio.c44
-rw-r--r--bin/pax/cpio.h3
-rw-r--r--bin/pax/extern.h5
-rw-r--r--bin/pax/file_subs.c12
-rw-r--r--bin/pax/ftree.c33
-rw-r--r--bin/pax/ftree.h3
-rw-r--r--bin/pax/gen_subs.c19
-rw-r--r--bin/pax/getoldopt.c3
-rw-r--r--bin/pax/options.c23
-rw-r--r--bin/pax/options.h3
-rw-r--r--bin/pax/pat_rep.c98
-rw-r--r--bin/pax/pat_rep.h7
-rw-r--r--bin/pax/pax.130
-rw-r--r--bin/pax/pax.c18
-rw-r--r--bin/pax/pax.h3
-rw-r--r--bin/pax/sel_subs.c134
-rw-r--r--bin/pax/sel_subs.h5
-rw-r--r--bin/pax/tables.c22
-rw-r--r--bin/pax/tables.h3
-rw-r--r--bin/pax/tar.c44
-rw-r--r--bin/pax/tar.h3
-rw-r--r--bin/pax/tests/Makefile1
-rw-r--r--bin/pax/tests/Makefile.depend1
-rw-r--r--bin/pax/tests/legacy_test.pl1
-rw-r--r--bin/pax/tty_subs.c8
-rw-r--r--bin/pkill/Makefile1
-rw-r--r--bin/pkill/Makefile.depend3
-rw-r--r--bin/pkill/pkill.12
-rw-r--r--bin/pkill/pkill.c43
-rw-r--r--bin/pkill/tests/Makefile23
-rw-r--r--bin/pkill/tests/Makefile.depend1
-rw-r--r--bin/pkill/tests/pgrep-_f_test.sh (renamed from bin/pkill/tests/pgrep-F_test.sh)1
-rw-r--r--bin/pkill/tests/pgrep-_g_test.sh1
-rw-r--r--bin/pkill/tests/pgrep-_lf_test.sh (renamed from bin/pkill/tests/pgrep-LF_test.sh)1
-rw-r--r--bin/pkill/tests/pgrep-_p_test.sh (renamed from bin/pkill/tests/pgrep-P_test.sh)1
-rw-r--r--bin/pkill/tests/pgrep-_s_test.sh1
-rw-r--r--bin/pkill/tests/pgrep-_u_test.sh (renamed from bin/pkill/tests/pgrep-U_test.sh)1
-rw-r--r--bin/pkill/tests/pgrep-f_test.sh57
-rw-r--r--bin/pkill/tests/pgrep-g_test.sh1
-rw-r--r--bin/pkill/tests/pgrep-i_test.sh1
-rw-r--r--bin/pkill/tests/pgrep-j_test.sh1
-rw-r--r--bin/pkill/tests/pgrep-l_test.sh1
-rw-r--r--bin/pkill/tests/pgrep-n_test.sh1
-rw-r--r--bin/pkill/tests/pgrep-o_test.sh1
-rw-r--r--bin/pkill/tests/pgrep-q_test.sh1
-rw-r--r--bin/pkill/tests/pgrep-s_test.sh1
-rw-r--r--bin/pkill/tests/pgrep-t_test.sh1
-rw-r--r--bin/pkill/tests/pgrep-v_test.sh1
-rw-r--r--bin/pkill/tests/pgrep-x_test.sh1
-rw-r--r--bin/pkill/tests/pkill-_f_test.sh (renamed from bin/pkill/tests/pkill-F_test.sh)1
-rw-r--r--bin/pkill/tests/pkill-_g_test.sh1
-rw-r--r--bin/pkill/tests/pkill-_lf_test.sh (renamed from bin/pkill/tests/pkill-LF_test.sh)1
-rw-r--r--bin/pkill/tests/pkill-_p_test.sh (renamed from bin/pkill/tests/pkill-P_test.sh)1
-rw-r--r--bin/pkill/tests/pkill-_u_test.sh (renamed from bin/pkill/tests/pkill-U_test.sh)1
-rw-r--r--bin/pkill/tests/pkill-g_test.sh1
-rw-r--r--bin/pkill/tests/pkill-i_test.sh1
-rw-r--r--bin/pkill/tests/pkill-j_test.sh1
-rw-r--r--bin/pkill/tests/pkill-s_test.sh1
-rw-r--r--bin/pkill/tests/pkill-t_test.sh1
-rw-r--r--bin/pkill/tests/pkill-x_test.sh1
-rw-r--r--bin/pkill/tests/spin_helper.c123
-rw-r--r--bin/ps/Makefile2
-rw-r--r--bin/ps/Makefile.depend6
-rw-r--r--bin/ps/extern.h3
-rw-r--r--bin/ps/fmt.c9
-rw-r--r--bin/ps/keyword.c8
-rw-r--r--bin/ps/nlist.c9
-rw-r--r--bin/ps/print.c9
-rw-r--r--bin/ps/ps.122
-rw-r--r--bin/ps/ps.c69
-rw-r--r--bin/ps/ps.h3
-rw-r--r--bin/pwait/Makefile1
-rw-r--r--bin/pwait/Makefile.depend2
-rw-r--r--bin/pwait/pwait.16
-rw-r--r--bin/pwait/pwait.c3
-rw-r--r--bin/pwait/tests/Makefile1
-rw-r--r--bin/pwait/tests/Makefile.depend1
-rw-r--r--bin/pwait/tests/pwait_test.sh1
-rw-r--r--bin/pwd/Makefile2
-rw-r--r--bin/pwd/Makefile.depend2
-rw-r--r--bin/pwd/pwd.115
-rw-r--r--bin/pwd/pwd.c14
-rw-r--r--bin/realpath/Makefile1
-rw-r--r--bin/realpath/Makefile.depend2
-rw-r--r--bin/realpath/realpath.13
-rw-r--r--bin/realpath/realpath.c3
-rw-r--r--bin/rm/Makefile2
-rw-r--r--bin/rm/Makefile.depend2
-rw-r--r--bin/rm/rm.13
-rw-r--r--bin/rm/rm.c14
-rw-r--r--bin/rm/tests/Makefile1
-rw-r--r--bin/rm/tests/Makefile.depend1
-rwxr-xr-xbin/rm/tests/rm_test.sh1
-rw-r--r--bin/rmail/Makefile4
-rw-r--r--bin/rmail/Makefile.depend2
-rw-r--r--bin/rmdir/Makefile2
-rw-r--r--bin/rmdir/Makefile.depend2
-rw-r--r--bin/rmdir/rmdir.13
-rw-r--r--bin/rmdir/rmdir.c16
-rw-r--r--bin/rmdir/tests/Makefile1
-rw-r--r--bin/rmdir/tests/Makefile.depend1
-rw-r--r--bin/rmdir/tests/rmdir_test.sh1
-rw-r--r--bin/setfacl/Makefile1
-rw-r--r--bin/setfacl/Makefile.depend2
-rw-r--r--bin/setfacl/file.c3
-rw-r--r--bin/setfacl/mask.c3
-rw-r--r--bin/setfacl/merge.c3
-rw-r--r--bin/setfacl/remove.c3
-rw-r--r--bin/setfacl/setfacl.16
-rw-r--r--bin/setfacl/setfacl.c4
-rw-r--r--bin/setfacl/setfacl.h2
-rw-r--r--bin/setfacl/util.c2
-rw-r--r--bin/sh/Makefile20
-rw-r--r--bin/sh/Makefile.depend5
-rw-r--r--bin/sh/TOUR2
-rw-r--r--bin/sh/alias.c37
-rw-r--r--bin/sh/alias.h4
-rw-r--r--bin/sh/arith.h3
-rw-r--r--bin/sh/arith_yacc.c2
-rw-r--r--bin/sh/arith_yacc.h2
-rw-r--r--bin/sh/arith_yylex.c2
-rw-r--r--bin/sh/bltin/bltin.h3
-rw-r--r--bin/sh/bltin/echo.c4
-rw-r--r--bin/sh/builtins.def3
-rw-r--r--bin/sh/cd.c8
-rw-r--r--bin/sh/cd.h2
-rw-r--r--bin/sh/dot.profile1
-rw-r--r--bin/sh/dot.shrc1
-rw-r--r--bin/sh/error.c8
-rw-r--r--bin/sh/error.h3
-rw-r--r--bin/sh/eval.c10
-rw-r--r--bin/sh/eval.h3
-rw-r--r--bin/sh/exec.c54
-rw-r--r--bin/sh/exec.h5
-rw-r--r--bin/sh/expand.c8
-rw-r--r--bin/sh/expand.h3
-rw-r--r--bin/sh/funcs/cmv3
-rw-r--r--bin/sh/funcs/dirs3
-rw-r--r--bin/sh/funcs/login3
-rw-r--r--bin/sh/funcs/newgrp3
-rw-r--r--bin/sh/funcs/popd3
-rw-r--r--bin/sh/funcs/pushd3
-rw-r--r--bin/sh/funcs/suspend3
-rw-r--r--bin/sh/histedit.c131
-rw-r--r--bin/sh/input.c8
-rw-r--r--bin/sh/input.h3
-rw-r--r--bin/sh/jobs.c10
-rw-r--r--bin/sh/jobs.h5
-rw-r--r--bin/sh/mail.c10
-rw-r--r--bin/sh/mail.h3
-rw-r--r--bin/sh/main.c22
-rw-r--r--bin/sh/main.h3
-rw-r--r--bin/sh/memalloc.c10
-rw-r--r--bin/sh/memalloc.h3
-rw-r--r--bin/sh/miscbltin.c8
-rwxr-xr-xbin/sh/mkbuiltins3
-rw-r--r--bin/sh/mknodes.c14
-rw-r--r--bin/sh/mksyntax.c14
-rw-r--r--bin/sh/mktokens3
-rw-r--r--bin/sh/myhistedit.h3
-rw-r--r--bin/sh/mystring.c8
-rw-r--r--bin/sh/mystring.h3
-rw-r--r--bin/sh/nodes.c.pat3
-rw-r--r--bin/sh/nodetypes3
-rw-r--r--bin/sh/options.c13
-rw-r--r--bin/sh/options.h3
-rw-r--r--bin/sh/output.c8
-rw-r--r--bin/sh/output.h3
-rw-r--r--bin/sh/parser.c263
-rw-r--r--bin/sh/parser.h3
-rw-r--r--bin/sh/profile21
-rw-r--r--bin/sh/redir.c8
-rw-r--r--bin/sh/redir.h3
-rw-r--r--bin/sh/sh.143
-rw-r--r--bin/sh/shell.h3
-rw-r--r--bin/sh/show.c8
-rw-r--r--bin/sh/show.h3
-rw-r--r--bin/sh/tests/Makefile1
-rw-r--r--bin/sh/tests/Makefile.depend1
-rw-r--r--bin/sh/tests/builtins/Makefile2
-rw-r--r--bin/sh/tests/builtins/Makefile.depend1
-rw-r--r--bin/sh/tests/builtins/alias.01
-rw-r--r--bin/sh/tests/builtins/alias.11
-rw-r--r--bin/sh/tests/builtins/alias3.01
-rw-r--r--bin/sh/tests/builtins/alias4.01
-rw-r--r--bin/sh/tests/builtins/break1.01
-rw-r--r--bin/sh/tests/builtins/break2.01
-rw-r--r--bin/sh/tests/builtins/break3.01
-rw-r--r--bin/sh/tests/builtins/break4.41
-rw-r--r--bin/sh/tests/builtins/break5.41
-rw-r--r--bin/sh/tests/builtins/break6.01
-rw-r--r--bin/sh/tests/builtins/builtin1.01
-rw-r--r--bin/sh/tests/builtins/case1.01
-rw-r--r--bin/sh/tests/builtins/case10.01
-rw-r--r--bin/sh/tests/builtins/case11.01
-rw-r--r--bin/sh/tests/builtins/case12.01
-rw-r--r--bin/sh/tests/builtins/case13.01
-rw-r--r--bin/sh/tests/builtins/case14.01
-rw-r--r--bin/sh/tests/builtins/case15.01
-rw-r--r--bin/sh/tests/builtins/case16.01
-rw-r--r--bin/sh/tests/builtins/case17.01
-rw-r--r--bin/sh/tests/builtins/case18.01
-rw-r--r--bin/sh/tests/builtins/case19.01
-rw-r--r--bin/sh/tests/builtins/case2.01
-rw-r--r--bin/sh/tests/builtins/case20.01
-rw-r--r--bin/sh/tests/builtins/case21.01
-rw-r--r--bin/sh/tests/builtins/case22.01
-rw-r--r--bin/sh/tests/builtins/case23.01
-rw-r--r--bin/sh/tests/builtins/case3.01
-rw-r--r--bin/sh/tests/builtins/case4.01
-rw-r--r--bin/sh/tests/builtins/case5.01
-rw-r--r--bin/sh/tests/builtins/case6.01
-rw-r--r--bin/sh/tests/builtins/case7.01
-rw-r--r--bin/sh/tests/builtins/case8.01
-rw-r--r--bin/sh/tests/builtins/case9.01
-rw-r--r--bin/sh/tests/builtins/cd1.01
-rw-r--r--bin/sh/tests/builtins/cd10.03
-rw-r--r--bin/sh/tests/builtins/cd11.01
-rw-r--r--bin/sh/tests/builtins/cd2.01
-rw-r--r--bin/sh/tests/builtins/cd3.01
-rw-r--r--bin/sh/tests/builtins/cd4.01
-rw-r--r--bin/sh/tests/builtins/cd5.01
-rw-r--r--bin/sh/tests/builtins/cd6.01
-rw-r--r--bin/sh/tests/builtins/cd7.01
-rw-r--r--bin/sh/tests/builtins/cd8.01
-rw-r--r--bin/sh/tests/builtins/cd9.01
-rw-r--r--bin/sh/tests/builtins/command1.01
-rw-r--r--bin/sh/tests/builtins/command10.01
-rw-r--r--bin/sh/tests/builtins/command11.01
-rw-r--r--bin/sh/tests/builtins/command12.01
-rw-r--r--bin/sh/tests/builtins/command13.01
-rw-r--r--bin/sh/tests/builtins/command14.01
-rw-r--r--bin/sh/tests/builtins/command2.01
-rw-r--r--bin/sh/tests/builtins/command3.01
-rw-r--r--bin/sh/tests/builtins/command4.01
-rw-r--r--bin/sh/tests/builtins/command5.01
-rw-r--r--bin/sh/tests/builtins/command6.01
-rw-r--r--bin/sh/tests/builtins/command7.01
-rw-r--r--bin/sh/tests/builtins/command8.01
-rw-r--r--bin/sh/tests/builtins/command9.01
-rw-r--r--bin/sh/tests/builtins/dot1.01
-rw-r--r--bin/sh/tests/builtins/dot2.01
-rw-r--r--bin/sh/tests/builtins/dot3.01
-rw-r--r--bin/sh/tests/builtins/dot4.01
-rw-r--r--bin/sh/tests/builtins/echo1.01
-rw-r--r--bin/sh/tests/builtins/echo2.01
-rw-r--r--bin/sh/tests/builtins/echo3.01
-rw-r--r--bin/sh/tests/builtins/eval1.01
-rw-r--r--bin/sh/tests/builtins/eval2.01
-rw-r--r--bin/sh/tests/builtins/eval3.01
-rw-r--r--bin/sh/tests/builtins/eval4.01
-rw-r--r--bin/sh/tests/builtins/eval5.01
-rw-r--r--bin/sh/tests/builtins/eval6.01
-rw-r--r--bin/sh/tests/builtins/eval7.01
-rw-r--r--bin/sh/tests/builtins/eval8.71
-rw-r--r--bin/sh/tests/builtins/exec1.01
-rw-r--r--bin/sh/tests/builtins/exec2.01
-rw-r--r--bin/sh/tests/builtins/exit1.01
-rw-r--r--bin/sh/tests/builtins/exit2.81
-rw-r--r--bin/sh/tests/builtins/exit3.01
-rw-r--r--bin/sh/tests/builtins/export1.01
-rw-r--r--bin/sh/tests/builtins/fc1.03
-rw-r--r--bin/sh/tests/builtins/fc2.01
-rw-r--r--bin/sh/tests/builtins/fc3.09
-rw-r--r--bin/sh/tests/builtins/fc3.0.stderr1
-rw-r--r--bin/sh/tests/builtins/fc3.0.stdout3
-rw-r--r--bin/sh/tests/builtins/for1.01
-rw-r--r--bin/sh/tests/builtins/for2.01
-rw-r--r--bin/sh/tests/builtins/for3.01
-rw-r--r--bin/sh/tests/builtins/getopts1.01
-rw-r--r--bin/sh/tests/builtins/getopts10.01
-rw-r--r--bin/sh/tests/builtins/getopts2.01
-rw-r--r--bin/sh/tests/builtins/getopts3.01
-rw-r--r--bin/sh/tests/builtins/getopts4.01
-rw-r--r--bin/sh/tests/builtins/getopts5.01
-rw-r--r--bin/sh/tests/builtins/getopts6.01
-rw-r--r--bin/sh/tests/builtins/getopts7.01
-rw-r--r--bin/sh/tests/builtins/getopts8.01
-rw-r--r--bin/sh/tests/builtins/getopts9.01
-rw-r--r--bin/sh/tests/builtins/hash1.01
-rw-r--r--bin/sh/tests/builtins/hash2.01
-rw-r--r--bin/sh/tests/builtins/hash3.01
-rw-r--r--bin/sh/tests/builtins/hash4.01
-rw-r--r--bin/sh/tests/builtins/jobid1.01
-rw-r--r--bin/sh/tests/builtins/jobid2.01
-rw-r--r--bin/sh/tests/builtins/kill1.01
-rw-r--r--bin/sh/tests/builtins/kill2.01
-rw-r--r--bin/sh/tests/builtins/lineno.01
-rw-r--r--bin/sh/tests/builtins/lineno.0.stdout4
-rw-r--r--bin/sh/tests/builtins/lineno2.01
-rw-r--r--bin/sh/tests/builtins/lineno3.01
-rw-r--r--bin/sh/tests/builtins/lineno3.0.stdout4
-rw-r--r--bin/sh/tests/builtins/local1.01
-rw-r--r--bin/sh/tests/builtins/local2.01
-rw-r--r--bin/sh/tests/builtins/local3.01
-rw-r--r--bin/sh/tests/builtins/local4.01
-rw-r--r--bin/sh/tests/builtins/local5.01
-rw-r--r--bin/sh/tests/builtins/local6.01
-rw-r--r--bin/sh/tests/builtins/local7.01
-rw-r--r--bin/sh/tests/builtins/locale1.01
-rw-r--r--bin/sh/tests/builtins/locale2.01
-rw-r--r--bin/sh/tests/builtins/printf1.01
-rw-r--r--bin/sh/tests/builtins/printf2.01
-rw-r--r--bin/sh/tests/builtins/printf3.01
-rw-r--r--bin/sh/tests/builtins/printf4.01
-rw-r--r--bin/sh/tests/builtins/read1.01
-rw-r--r--bin/sh/tests/builtins/read2.01
-rw-r--r--bin/sh/tests/builtins/read3.01
-rw-r--r--bin/sh/tests/builtins/read4.01
-rw-r--r--bin/sh/tests/builtins/read5.01
-rw-r--r--bin/sh/tests/builtins/read6.01
-rw-r--r--bin/sh/tests/builtins/read7.01
-rw-r--r--bin/sh/tests/builtins/read8.01
-rw-r--r--bin/sh/tests/builtins/read9.01
-rw-r--r--bin/sh/tests/builtins/return1.01
-rw-r--r--bin/sh/tests/builtins/return2.11
-rw-r--r--bin/sh/tests/builtins/return3.11
-rw-r--r--bin/sh/tests/builtins/return4.01
-rw-r--r--bin/sh/tests/builtins/return5.01
-rw-r--r--bin/sh/tests/builtins/return6.41
-rw-r--r--bin/sh/tests/builtins/return7.41
-rw-r--r--bin/sh/tests/builtins/return8.01
-rw-r--r--bin/sh/tests/builtins/set1.01
-rw-r--r--bin/sh/tests/builtins/set2.01
-rw-r--r--bin/sh/tests/builtins/set3.01
-rw-r--r--bin/sh/tests/builtins/trap1.01
-rw-r--r--bin/sh/tests/builtins/trap10.01
-rw-r--r--bin/sh/tests/builtins/trap11.01
-rw-r--r--bin/sh/tests/builtins/trap12.01
-rw-r--r--bin/sh/tests/builtins/trap13.01
-rw-r--r--bin/sh/tests/builtins/trap14.01
-rw-r--r--bin/sh/tests/builtins/trap15.01
-rw-r--r--bin/sh/tests/builtins/trap16.01
-rw-r--r--bin/sh/tests/builtins/trap17.01
-rw-r--r--bin/sh/tests/builtins/trap2.01
-rw-r--r--bin/sh/tests/builtins/trap3.01
-rw-r--r--bin/sh/tests/builtins/trap4.01
-rw-r--r--bin/sh/tests/builtins/trap5.01
-rw-r--r--bin/sh/tests/builtins/trap6.01
-rw-r--r--bin/sh/tests/builtins/trap7.01
-rw-r--r--bin/sh/tests/builtins/trap8.01
-rw-r--r--bin/sh/tests/builtins/trap9.01
-rw-r--r--bin/sh/tests/builtins/type1.01
-rw-r--r--bin/sh/tests/builtins/type2.01
-rw-r--r--bin/sh/tests/builtins/type3.01
-rw-r--r--bin/sh/tests/builtins/type4.01
-rw-r--r--bin/sh/tests/builtins/unalias.01
-rw-r--r--bin/sh/tests/builtins/var-assign.01
-rw-r--r--bin/sh/tests/builtins/var-assign2.01
-rw-r--r--bin/sh/tests/builtins/wait1.01
-rw-r--r--bin/sh/tests/builtins/wait10.01
-rw-r--r--bin/sh/tests/builtins/wait2.01
-rw-r--r--bin/sh/tests/builtins/wait3.01
-rw-r--r--bin/sh/tests/builtins/wait4.01
-rw-r--r--bin/sh/tests/builtins/wait5.01
-rw-r--r--bin/sh/tests/builtins/wait6.01
-rw-r--r--bin/sh/tests/builtins/wait7.01
-rw-r--r--bin/sh/tests/builtins/wait8.01
-rw-r--r--bin/sh/tests/builtins/wait9.1271
-rw-r--r--bin/sh/tests/errors/Makefile1
-rw-r--r--bin/sh/tests/errors/Makefile.depend1
-rw-r--r--bin/sh/tests/errors/assignment-error1.01
-rw-r--r--bin/sh/tests/errors/assignment-error2.01
-rw-r--r--bin/sh/tests/errors/backquote-error1.01
-rw-r--r--bin/sh/tests/errors/backquote-error2.01
-rw-r--r--bin/sh/tests/errors/bad-binary1.1261
-rw-r--r--bin/sh/tests/errors/bad-keyword1.01
-rw-r--r--bin/sh/tests/errors/bad-parm-exp1.01
-rw-r--r--bin/sh/tests/errors/bad-parm-exp2.21
-rw-r--r--bin/sh/tests/errors/bad-parm-exp3.21
-rw-r--r--bin/sh/tests/errors/bad-parm-exp4.21
-rw-r--r--bin/sh/tests/errors/bad-parm-exp5.21
-rw-r--r--bin/sh/tests/errors/bad-parm-exp6.21
-rw-r--r--bin/sh/tests/errors/bad-parm-exp7.01
-rw-r--r--bin/sh/tests/errors/bad-parm-exp8.01
-rw-r--r--bin/sh/tests/errors/option-error.01
-rw-r--r--bin/sh/tests/errors/redirection-error.01
-rw-r--r--bin/sh/tests/errors/redirection-error2.21
-rw-r--r--bin/sh/tests/errors/redirection-error3.01
-rw-r--r--bin/sh/tests/errors/redirection-error4.01
-rw-r--r--bin/sh/tests/errors/redirection-error5.01
-rw-r--r--bin/sh/tests/errors/redirection-error6.01
-rw-r--r--bin/sh/tests/errors/redirection-error7.01
-rw-r--r--bin/sh/tests/errors/redirection-error8.01
-rw-r--r--bin/sh/tests/errors/script-error1.01
-rw-r--r--bin/sh/tests/errors/write-error1.01
-rw-r--r--bin/sh/tests/execution/Makefile1
-rw-r--r--bin/sh/tests/execution/Makefile.depend1
-rw-r--r--bin/sh/tests/execution/bg1.01
-rw-r--r--bin/sh/tests/execution/bg10.01
-rw-r--r--bin/sh/tests/execution/bg11.01
-rw-r--r--bin/sh/tests/execution/bg12.01
-rw-r--r--bin/sh/tests/execution/bg13.01
-rw-r--r--bin/sh/tests/execution/bg2.01
-rw-r--r--bin/sh/tests/execution/bg3.01
-rw-r--r--bin/sh/tests/execution/bg4.01
-rw-r--r--bin/sh/tests/execution/bg5.01
-rw-r--r--bin/sh/tests/execution/bg6.01
-rw-r--r--bin/sh/tests/execution/bg7.01
-rw-r--r--bin/sh/tests/execution/bg8.01
-rw-r--r--bin/sh/tests/execution/bg9.01
-rw-r--r--bin/sh/tests/execution/env1.01
-rw-r--r--bin/sh/tests/execution/fork1.01
-rw-r--r--bin/sh/tests/execution/fork2.01
-rw-r--r--bin/sh/tests/execution/fork3.01
-rw-r--r--bin/sh/tests/execution/func1.01
-rw-r--r--bin/sh/tests/execution/func2.01
-rw-r--r--bin/sh/tests/execution/func3.01
-rw-r--r--bin/sh/tests/execution/hash1.01
-rw-r--r--bin/sh/tests/execution/int-cmd1.03
-rw-r--r--bin/sh/tests/execution/killed1.01
-rw-r--r--bin/sh/tests/execution/killed2.01
-rw-r--r--bin/sh/tests/execution/not1.01
-rw-r--r--bin/sh/tests/execution/not2.01
-rw-r--r--bin/sh/tests/execution/path1.01
-rw-r--r--bin/sh/tests/execution/pipefail1.01
-rw-r--r--bin/sh/tests/execution/pipefail2.421
-rw-r--r--bin/sh/tests/execution/pipefail3.421
-rw-r--r--bin/sh/tests/execution/pipefail4.421
-rw-r--r--bin/sh/tests/execution/pipefail5.421
-rw-r--r--bin/sh/tests/execution/pipefail6.421
-rw-r--r--bin/sh/tests/execution/pipefail7.01
-rw-r--r--bin/sh/tests/execution/redir1.01
-rw-r--r--bin/sh/tests/execution/redir2.01
-rw-r--r--bin/sh/tests/execution/redir3.01
-rw-r--r--bin/sh/tests/execution/redir4.01
-rw-r--r--bin/sh/tests/execution/redir5.01
-rw-r--r--bin/sh/tests/execution/redir6.01
-rw-r--r--bin/sh/tests/execution/redir7.01
-rw-r--r--bin/sh/tests/execution/set-C1.01
-rw-r--r--bin/sh/tests/execution/set-n1.01
-rw-r--r--bin/sh/tests/execution/set-n2.01
-rw-r--r--bin/sh/tests/execution/set-n3.01
-rw-r--r--bin/sh/tests/execution/set-n4.01
-rw-r--r--bin/sh/tests/execution/set-x1.01
-rw-r--r--bin/sh/tests/execution/set-x2.01
-rw-r--r--bin/sh/tests/execution/set-x3.01
-rw-r--r--bin/sh/tests/execution/set-x4.01
-rw-r--r--bin/sh/tests/execution/shellproc1.01
-rw-r--r--bin/sh/tests/execution/shellproc2.01
-rw-r--r--bin/sh/tests/execution/shellproc3.01
-rw-r--r--bin/sh/tests/execution/shellproc4.01
-rw-r--r--bin/sh/tests/execution/shellproc5.01
-rw-r--r--bin/sh/tests/execution/shellproc6.01
-rw-r--r--bin/sh/tests/execution/shellproc7.01
-rw-r--r--bin/sh/tests/execution/subshell1.01
-rw-r--r--bin/sh/tests/execution/subshell2.01
-rw-r--r--bin/sh/tests/execution/subshell3.01
-rw-r--r--bin/sh/tests/execution/subshell4.01
-rw-r--r--bin/sh/tests/execution/unknown1.01
-rw-r--r--bin/sh/tests/execution/unknown2.01
-rw-r--r--bin/sh/tests/execution/var-assign1.01
-rw-r--r--bin/sh/tests/expansion/Makefile1
-rw-r--r--bin/sh/tests/expansion/Makefile.depend1
-rw-r--r--bin/sh/tests/expansion/arith1.01
-rw-r--r--bin/sh/tests/expansion/arith10.01
-rw-r--r--bin/sh/tests/expansion/arith11.01
-rw-r--r--bin/sh/tests/expansion/arith12.01
-rw-r--r--bin/sh/tests/expansion/arith13.01
-rw-r--r--bin/sh/tests/expansion/arith14.01
-rw-r--r--bin/sh/tests/expansion/arith15.01
-rw-r--r--bin/sh/tests/expansion/arith16.01
-rw-r--r--bin/sh/tests/expansion/arith17.01
-rw-r--r--bin/sh/tests/expansion/arith2.01
-rw-r--r--bin/sh/tests/expansion/arith3.01
-rw-r--r--bin/sh/tests/expansion/arith4.01
-rw-r--r--bin/sh/tests/expansion/arith5.01
-rw-r--r--bin/sh/tests/expansion/arith6.01
-rw-r--r--bin/sh/tests/expansion/arith7.01
-rw-r--r--bin/sh/tests/expansion/arith8.01
-rw-r--r--bin/sh/tests/expansion/arith9.01
-rw-r--r--bin/sh/tests/expansion/assign1.01
-rw-r--r--bin/sh/tests/expansion/cmdsubst1.01
-rw-r--r--bin/sh/tests/expansion/cmdsubst10.01
-rw-r--r--bin/sh/tests/expansion/cmdsubst11.01
-rw-r--r--bin/sh/tests/expansion/cmdsubst12.01
-rw-r--r--bin/sh/tests/expansion/cmdsubst13.01
-rw-r--r--bin/sh/tests/expansion/cmdsubst14.01
-rw-r--r--bin/sh/tests/expansion/cmdsubst15.01
-rw-r--r--bin/sh/tests/expansion/cmdsubst16.01
-rw-r--r--bin/sh/tests/expansion/cmdsubst17.01
-rw-r--r--bin/sh/tests/expansion/cmdsubst18.01
-rw-r--r--bin/sh/tests/expansion/cmdsubst19.01
-rw-r--r--bin/sh/tests/expansion/cmdsubst2.01
-rw-r--r--bin/sh/tests/expansion/cmdsubst20.01
-rw-r--r--bin/sh/tests/expansion/cmdsubst21.01
-rw-r--r--bin/sh/tests/expansion/cmdsubst22.01
-rw-r--r--bin/sh/tests/expansion/cmdsubst23.01
-rw-r--r--bin/sh/tests/expansion/cmdsubst24.01
-rw-r--r--bin/sh/tests/expansion/cmdsubst25.01
-rw-r--r--bin/sh/tests/expansion/cmdsubst26.01
-rw-r--r--bin/sh/tests/expansion/cmdsubst3.01
-rw-r--r--bin/sh/tests/expansion/cmdsubst4.01
-rw-r--r--bin/sh/tests/expansion/cmdsubst5.01
-rw-r--r--bin/sh/tests/expansion/cmdsubst6.01
-rw-r--r--bin/sh/tests/expansion/cmdsubst7.01
-rw-r--r--bin/sh/tests/expansion/cmdsubst8.01
-rw-r--r--bin/sh/tests/expansion/cmdsubst9.01
-rw-r--r--bin/sh/tests/expansion/export1.01
-rw-r--r--bin/sh/tests/expansion/export2.01
-rw-r--r--bin/sh/tests/expansion/export3.01
-rw-r--r--bin/sh/tests/expansion/heredoc1.01
-rw-r--r--bin/sh/tests/expansion/heredoc2.01
-rw-r--r--bin/sh/tests/expansion/ifs1.01
-rw-r--r--bin/sh/tests/expansion/ifs2.01
-rw-r--r--bin/sh/tests/expansion/ifs3.01
-rw-r--r--bin/sh/tests/expansion/ifs4.01
-rw-r--r--bin/sh/tests/expansion/ifs5.01
-rw-r--r--bin/sh/tests/expansion/ifs6.01
-rw-r--r--bin/sh/tests/expansion/ifs7.01
-rw-r--r--bin/sh/tests/expansion/length1.01
-rw-r--r--bin/sh/tests/expansion/length2.01
-rw-r--r--bin/sh/tests/expansion/length3.01
-rw-r--r--bin/sh/tests/expansion/length4.01
-rw-r--r--bin/sh/tests/expansion/length5.01
-rw-r--r--bin/sh/tests/expansion/length6.01
-rw-r--r--bin/sh/tests/expansion/length7.01
-rw-r--r--bin/sh/tests/expansion/length8.01
-rw-r--r--bin/sh/tests/expansion/local1.01
-rw-r--r--bin/sh/tests/expansion/local2.01
-rw-r--r--bin/sh/tests/expansion/pathname1.01
-rw-r--r--bin/sh/tests/expansion/pathname2.01
-rw-r--r--bin/sh/tests/expansion/pathname3.01
-rw-r--r--bin/sh/tests/expansion/pathname4.01
-rw-r--r--bin/sh/tests/expansion/pathname5.01
-rw-r--r--bin/sh/tests/expansion/pathname6.01
-rw-r--r--bin/sh/tests/expansion/plus-minus1.01
-rw-r--r--bin/sh/tests/expansion/plus-minus2.01
-rw-r--r--bin/sh/tests/expansion/plus-minus3.01
-rw-r--r--bin/sh/tests/expansion/plus-minus4.01
-rw-r--r--bin/sh/tests/expansion/plus-minus5.01
-rw-r--r--bin/sh/tests/expansion/plus-minus6.01
-rw-r--r--bin/sh/tests/expansion/plus-minus7.01
-rw-r--r--bin/sh/tests/expansion/plus-minus8.01
-rw-r--r--bin/sh/tests/expansion/plus-minus9.01
-rw-r--r--bin/sh/tests/expansion/question1.01
-rw-r--r--bin/sh/tests/expansion/question2.01
-rw-r--r--bin/sh/tests/expansion/readonly1.01
-rw-r--r--bin/sh/tests/expansion/redir1.01
-rw-r--r--bin/sh/tests/expansion/set-u1.01
-rw-r--r--bin/sh/tests/expansion/set-u2.01
-rw-r--r--bin/sh/tests/expansion/set-u3.01
-rw-r--r--bin/sh/tests/expansion/tilde1.01
-rw-r--r--bin/sh/tests/expansion/tilde2.01
-rw-r--r--bin/sh/tests/expansion/trim1.01
-rw-r--r--bin/sh/tests/expansion/trim10.01
-rw-r--r--bin/sh/tests/expansion/trim11.01
-rw-r--r--bin/sh/tests/expansion/trim2.01
-rw-r--r--bin/sh/tests/expansion/trim3.01
-rw-r--r--bin/sh/tests/expansion/trim4.01
-rw-r--r--bin/sh/tests/expansion/trim5.01
-rw-r--r--bin/sh/tests/expansion/trim6.01
-rw-r--r--bin/sh/tests/expansion/trim7.01
-rw-r--r--bin/sh/tests/expansion/trim8.01
-rw-r--r--bin/sh/tests/expansion/trim9.01
-rwxr-xr-xbin/sh/tests/functional_test.sh1
-rw-r--r--bin/sh/tests/invocation/Makefile1
-rw-r--r--bin/sh/tests/invocation/Makefile.depend1
-rw-r--r--bin/sh/tests/invocation/sh-ac1.01
-rw-r--r--bin/sh/tests/invocation/sh-c-missing1.01
-rw-r--r--bin/sh/tests/invocation/sh-c1.01
-rw-r--r--bin/sh/tests/invocation/sh-ca1.01
-rw-r--r--bin/sh/tests/invocation/sh-fca1.01
-rw-r--r--bin/sh/tests/parameters/Makefile1
-rw-r--r--bin/sh/tests/parameters/Makefile.depend1
-rw-r--r--bin/sh/tests/parameters/env1.01
-rw-r--r--bin/sh/tests/parameters/exitstatus1.01
-rw-r--r--bin/sh/tests/parameters/ifs1.01
-rw-r--r--bin/sh/tests/parameters/mail1.01
-rw-r--r--bin/sh/tests/parameters/mail2.01
-rw-r--r--bin/sh/tests/parameters/optind1.01
-rw-r--r--bin/sh/tests/parameters/optind2.01
-rw-r--r--bin/sh/tests/parameters/positional1.01
-rw-r--r--bin/sh/tests/parameters/positional2.01
-rw-r--r--bin/sh/tests/parameters/positional3.01
-rw-r--r--bin/sh/tests/parameters/positional4.01
-rw-r--r--bin/sh/tests/parameters/positional5.01
-rw-r--r--bin/sh/tests/parameters/positional6.01
-rw-r--r--bin/sh/tests/parameters/positional7.01
-rw-r--r--bin/sh/tests/parameters/positional8.01
-rw-r--r--bin/sh/tests/parameters/positional9.01
-rw-r--r--bin/sh/tests/parameters/pwd1.01
-rw-r--r--bin/sh/tests/parameters/pwd2.01
-rw-r--r--bin/sh/tests/parser/Makefile1
-rw-r--r--bin/sh/tests/parser/Makefile.depend1
-rw-r--r--bin/sh/tests/parser/alias1.01
-rw-r--r--bin/sh/tests/parser/alias10.01
-rw-r--r--bin/sh/tests/parser/alias11.01
-rw-r--r--bin/sh/tests/parser/alias12.01
-rw-r--r--bin/sh/tests/parser/alias13.01
-rw-r--r--bin/sh/tests/parser/alias14.01
-rw-r--r--bin/sh/tests/parser/alias15.01
-rw-r--r--bin/sh/tests/parser/alias16.01
-rw-r--r--bin/sh/tests/parser/alias17.01
-rw-r--r--bin/sh/tests/parser/alias18.01
-rw-r--r--bin/sh/tests/parser/alias19.01
-rw-r--r--bin/sh/tests/parser/alias2.01
-rw-r--r--bin/sh/tests/parser/alias20.01
-rw-r--r--bin/sh/tests/parser/alias3.01
-rw-r--r--bin/sh/tests/parser/alias4.01
-rw-r--r--bin/sh/tests/parser/alias5.01
-rw-r--r--bin/sh/tests/parser/alias6.01
-rw-r--r--bin/sh/tests/parser/alias7.01
-rw-r--r--bin/sh/tests/parser/alias8.01
-rw-r--r--bin/sh/tests/parser/alias9.01
-rw-r--r--bin/sh/tests/parser/and-pipe-not.01
-rw-r--r--bin/sh/tests/parser/case1.01
-rw-r--r--bin/sh/tests/parser/case2.01
-rw-r--r--bin/sh/tests/parser/comment1.01
-rw-r--r--bin/sh/tests/parser/comment2.421
-rw-r--r--bin/sh/tests/parser/dollar-quote1.01
-rw-r--r--bin/sh/tests/parser/dollar-quote10.01
-rw-r--r--bin/sh/tests/parser/dollar-quote11.01
-rw-r--r--bin/sh/tests/parser/dollar-quote12.01
-rw-r--r--bin/sh/tests/parser/dollar-quote13.01
-rw-r--r--bin/sh/tests/parser/dollar-quote2.01
-rw-r--r--bin/sh/tests/parser/dollar-quote3.01
-rw-r--r--bin/sh/tests/parser/dollar-quote4.01
-rw-r--r--bin/sh/tests/parser/dollar-quote5.01
-rw-r--r--bin/sh/tests/parser/dollar-quote6.01
-rw-r--r--bin/sh/tests/parser/dollar-quote7.01
-rw-r--r--bin/sh/tests/parser/dollar-quote8.01
-rw-r--r--bin/sh/tests/parser/dollar-quote9.01
-rw-r--r--bin/sh/tests/parser/empty-braces1.01
-rw-r--r--bin/sh/tests/parser/empty-cmd1.01
-rw-r--r--bin/sh/tests/parser/for1.01
-rw-r--r--bin/sh/tests/parser/for2.01
-rw-r--r--bin/sh/tests/parser/func1.01
-rw-r--r--bin/sh/tests/parser/func2.01
-rw-r--r--bin/sh/tests/parser/func3.01
-rw-r--r--bin/sh/tests/parser/heredoc1.01
-rw-r--r--bin/sh/tests/parser/heredoc10.01
-rw-r--r--bin/sh/tests/parser/heredoc11.01
-rw-r--r--bin/sh/tests/parser/heredoc12.01
-rw-r--r--bin/sh/tests/parser/heredoc13.01
-rw-r--r--bin/sh/tests/parser/heredoc2.01
-rw-r--r--bin/sh/tests/parser/heredoc3.01
-rw-r--r--bin/sh/tests/parser/heredoc4.01
-rw-r--r--bin/sh/tests/parser/heredoc5.01
-rw-r--r--bin/sh/tests/parser/heredoc6.01
-rw-r--r--bin/sh/tests/parser/heredoc7.01
-rw-r--r--bin/sh/tests/parser/heredoc8.01
-rw-r--r--bin/sh/tests/parser/heredoc9.01
-rw-r--r--bin/sh/tests/parser/line-cont1.01
-rw-r--r--bin/sh/tests/parser/line-cont10.01
-rw-r--r--bin/sh/tests/parser/line-cont11.01
-rw-r--r--bin/sh/tests/parser/line-cont12.01
-rw-r--r--bin/sh/tests/parser/line-cont2.01
-rw-r--r--bin/sh/tests/parser/line-cont3.01
-rw-r--r--bin/sh/tests/parser/line-cont4.01
-rw-r--r--bin/sh/tests/parser/line-cont5.01
-rw-r--r--bin/sh/tests/parser/line-cont6.01
-rw-r--r--bin/sh/tests/parser/line-cont7.01
-rw-r--r--bin/sh/tests/parser/line-cont8.01
-rw-r--r--bin/sh/tests/parser/line-cont9.01
-rw-r--r--bin/sh/tests/parser/no-space1.01
-rw-r--r--bin/sh/tests/parser/no-space2.01
-rw-r--r--bin/sh/tests/parser/nul1.01
-rw-r--r--bin/sh/tests/parser/only-redir1.01
-rw-r--r--bin/sh/tests/parser/only-redir2.01
-rw-r--r--bin/sh/tests/parser/only-redir3.01
-rw-r--r--bin/sh/tests/parser/only-redir4.01
-rw-r--r--bin/sh/tests/parser/pipe-not1.01
-rw-r--r--bin/sh/tests/parser/set-v1.01
-rw-r--r--bin/sh/tests/parser/var-assign1.01
-rw-r--r--bin/sh/tests/set-e/Makefile1
-rw-r--r--bin/sh/tests/set-e/Makefile.depend1
-rw-r--r--bin/sh/tests/set-e/and1.01
-rw-r--r--bin/sh/tests/set-e/and2.11
-rw-r--r--bin/sh/tests/set-e/and3.01
-rw-r--r--bin/sh/tests/set-e/and4.01
-rw-r--r--bin/sh/tests/set-e/background1.01
-rw-r--r--bin/sh/tests/set-e/cmd1.01
-rw-r--r--bin/sh/tests/set-e/cmd2.11
-rw-r--r--bin/sh/tests/set-e/elif1.01
-rw-r--r--bin/sh/tests/set-e/elif2.01
-rw-r--r--bin/sh/tests/set-e/eval1.01
-rw-r--r--bin/sh/tests/set-e/eval2.11
-rw-r--r--bin/sh/tests/set-e/for1.01
-rw-r--r--bin/sh/tests/set-e/func1.01
-rw-r--r--bin/sh/tests/set-e/func2.11
-rw-r--r--bin/sh/tests/set-e/if1.01
-rw-r--r--bin/sh/tests/set-e/if2.01
-rw-r--r--bin/sh/tests/set-e/if3.01
-rw-r--r--bin/sh/tests/set-e/not1.01
-rw-r--r--bin/sh/tests/set-e/not2.01
-rw-r--r--bin/sh/tests/set-e/or1.01
-rw-r--r--bin/sh/tests/set-e/or2.01
-rw-r--r--bin/sh/tests/set-e/or3.11
-rw-r--r--bin/sh/tests/set-e/pipe1.11
-rw-r--r--bin/sh/tests/set-e/pipe2.01
-rw-r--r--bin/sh/tests/set-e/return1.01
-rw-r--r--bin/sh/tests/set-e/semi1.11
-rw-r--r--bin/sh/tests/set-e/semi2.11
-rw-r--r--bin/sh/tests/set-e/subshell1.01
-rw-r--r--bin/sh/tests/set-e/subshell2.11
-rw-r--r--bin/sh/tests/set-e/until1.01
-rw-r--r--bin/sh/tests/set-e/until2.01
-rw-r--r--bin/sh/tests/set-e/until3.01
-rw-r--r--bin/sh/tests/set-e/while1.01
-rw-r--r--bin/sh/tests/set-e/while2.01
-rw-r--r--bin/sh/tests/set-e/while3.01
-rw-r--r--bin/sh/trap.c8
-rw-r--r--bin/sh/trap.h3
-rw-r--r--bin/sh/var.c8
-rw-r--r--bin/sh/var.h3
-rw-r--r--bin/sleep/Makefile2
-rw-r--r--bin/sleep/Makefile.depend3
-rw-r--r--bin/sleep/sleep.180
-rw-r--r--bin/sleep/sleep.c125
-rw-r--r--bin/sleep/tests/Makefile1
-rw-r--r--bin/sleep/tests/Makefile.depend1
-rw-r--r--bin/stty/Makefile2
-rw-r--r--bin/stty/Makefile.depend2
-rw-r--r--bin/stty/cchar.c8
-rw-r--r--bin/stty/extern.h3
-rw-r--r--bin/stty/gfmt.c8
-rw-r--r--bin/stty/key.c8
-rw-r--r--bin/stty/modes.c10
-rw-r--r--bin/stty/print.c9
-rw-r--r--bin/stty/stty.134
-rw-r--r--bin/stty/stty.c14
-rw-r--r--bin/stty/stty.h3
-rw-r--r--bin/stty/util.c8
-rw-r--r--bin/sync/Makefile2
-rw-r--r--bin/sync/Makefile.depend2
-rw-r--r--bin/sync/sync.833
-rw-r--r--bin/sync/sync.c14
-rw-r--r--bin/test/Makefile2
-rw-r--r--bin/test/Makefile.depend2
-rw-r--r--bin/test/test.13
-rw-r--r--bin/test/test.c3
-rw-r--r--bin/test/tests/Makefile1
-rw-r--r--bin/test/tests/Makefile.depend1
-rw-r--r--bin/test/tests/legacy_test.sh1
-rw-r--r--bin/tests/Makefile1
-rw-r--r--bin/tests/Makefile.depend1
-rw-r--r--bin/timeout/Makefile11
-rw-r--r--bin/timeout/Makefile.depend16
-rw-r--r--bin/timeout/tests/Makefile4
-rw-r--r--bin/timeout/tests/Makefile.depend10
-rw-r--r--bin/timeout/tests/timeout_test.sh214
-rw-r--r--bin/timeout/timeout.1206
-rw-r--r--bin/timeout/timeout.c358
-rw-r--r--bin/uuidgen/Makefile2
-rw-r--r--bin/uuidgen/Makefile.depend5
-rw-r--r--bin/uuidgen/uuidgen.110
-rw-r--r--bin/uuidgen/uuidgen.c110
943 files changed, 4164 insertions, 3131 deletions
diff --git a/bin/Makefile b/bin/Makefile
index 3ad97ac8d624..bf352b4d78da 100644
--- a/bin/Makefile
+++ b/bin/Makefile
@@ -1,5 +1,3 @@
-# From: @(#)Makefile 8.1 (Berkeley) 5/31/93
-# $FreeBSD$
.include <src.opts.mk>
@@ -8,6 +6,7 @@ SUBDIR= cat \
chio \
chmod \
cp \
+ cpuset \
date \
dd \
df \
@@ -24,6 +23,7 @@ SUBDIR= cat \
ls \
mkdir \
mv \
+ nproc \
pax \
pkill \
ps \
@@ -38,6 +38,7 @@ SUBDIR= cat \
stty \
sync \
test \
+ timeout \
uuidgen
SUBDIR.${MK_SENDMAIL}+= rmail
diff --git a/bin/Makefile.inc b/bin/Makefile.inc
index 637d54f2a4ac..8f9ef366e9a4 100644
--- a/bin/Makefile.inc
+++ b/bin/Makefile.inc
@@ -1,5 +1,3 @@
-# @(#)Makefile.inc 8.1 (Berkeley) 5/31/93
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/bin/cat/Makefile b/bin/cat/Makefile
index 06bb071363f8..97b19e701e4f 100644
--- a/bin/cat/Makefile
+++ b/bin/cat/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.1 (Berkeley) 5/31/93
-# $FreeBSD$
.include <src.opts.mk>
@@ -22,7 +20,7 @@ SUBDIR.${MK_TESTS}+= tests
#LIBADD+= cap_net
#CFLAGS+=-DWITH_CASPER
#.endif
-# Depend on Makefile to rebiuld when WITH_CASPER changes
+# Depend on Makefile to rebuild when WITH_CASPER changes
cat.o: Makefile
.include <bsd.prog.mk>
diff --git a/bin/cat/Makefile.depend b/bin/cat/Makefile.depend
index 6cfaab1c3644..45b0188acd5c 100644
--- a/bin/cat/Makefile.depend
+++ b/bin/cat/Makefile.depend
@@ -1,12 +1,14 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
+ lib/libcapsicum \
+ lib/libcasper/libcasper \
+ lib/libcasper/services/cap_fileargs \
+ lib/libcasper/services/cap_net \
lib/libcompiler_rt \
diff --git a/bin/cat/cat.1 b/bin/cat/cat.1
index fd1f8c9730db..59e0dff80ed0 100644
--- a/bin/cat/cat.1
+++ b/bin/cat/cat.1
@@ -29,9 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)cat.1 8.3 (Berkeley) 5/2/95
-.\" $FreeBSD$
-.\"
.Dd January 29, 2013
.Dt CAT 1
.Os
@@ -155,7 +152,7 @@ character, print the contents of
read and output contents of the standard input again, then finally output
the contents of
.Pa file3 .
-Note that if the standard input referred to a file, the second dash
+Note that if the standard input refers to a file, the second dash
on the command-line would have no effect, since the entire contents of the file
would have already been read and printed by
.Nm
diff --git a/bin/cat/cat.c b/bin/cat/cat.c
index 5a1fab0c26a0..5dceb1cad94b 100644
--- a/bin/cat/cat.c
+++ b/bin/cat/cat.c
@@ -32,22 +32,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static char const copyright[] =
-"@(#) Copyright (c) 1989, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-#endif
-
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)cat.c 8.2 (Berkeley) 4/27/95";
-#endif
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/capsicum.h>
#include <sys/param.h>
#include <sys/stat.h>
@@ -83,6 +67,7 @@ static void usage(void) __dead2;
static void scanfiles(char *argv[], int cooked);
#ifndef BOOTSTRAP_CAT
static void cook_cat(FILE *);
+static ssize_t in_kernel_copy(int);
#endif
static void raw_cat(int);
@@ -156,7 +141,7 @@ init_casper(int argc, char *argv[])
err(EXIT_FAILURE, "unable to create Casper");
fa = fileargs_cinit(casper, argc, argv, O_RDONLY, 0,
- cap_rights_init(&rights, CAP_READ | CAP_FSTAT | CAP_FCNTL),
+ cap_rights_init(&rights, CAP_READ, CAP_FSTAT, CAP_FCNTL, CAP_SEEK),
FA_OPEN | FA_REALPATH);
if (fa == NULL)
err(EXIT_FAILURE, "unable to create fileargs");
@@ -280,7 +265,17 @@ scanfiles(char *argv[], int cooked __unused)
}
#endif
} else {
+#ifndef BOOTSTRAP_CAT
+ if (in_kernel_copy(fd) == -1) {
+ if (errno == EINVAL || errno == EBADF ||
+ errno == EISDIR)
+ raw_cat(fd);
+ else
+ err(1, "stdout");
+ }
+#else
raw_cat(fd);
+#endif
if (fd != STDIN_FILENO)
close(fd);
}
@@ -380,6 +375,21 @@ ilseq:
if (ferror(stdout))
err(1, "stdout");
}
+
+static ssize_t
+in_kernel_copy(int rfd)
+{
+ int wfd;
+ ssize_t ret;
+
+ wfd = fileno(stdout);
+ ret = 1;
+
+ while (ret > 0)
+ ret = copy_file_range(rfd, NULL, wfd, NULL, SSIZE_MAX, 0);
+
+ return (ret);
+}
#endif /* BOOTSTRAP_CAT */
static void
@@ -436,7 +446,6 @@ udom_open(const char *path, int flags)
*/
bzero(&hints, sizeof(hints));
hints.ai_family = AF_LOCAL;
- fd = -1;
if (fileargs_realpath(fa, path, rpath) == NULL)
return (-1);
@@ -449,6 +458,10 @@ udom_open(const char *path, int flags)
}
cap_rights_init(&rights, CAP_CONNECT, CAP_READ, CAP_WRITE,
CAP_SHUTDOWN, CAP_FSTAT, CAP_FCNTL);
+
+ /* Default error if something goes wrong. */
+ serrno = EINVAL;
+
for (res = res0; res != NULL; res = res->ai_next) {
fd = socket(res->ai_family, res->ai_socktype,
res->ai_protocol);
@@ -471,39 +484,40 @@ udom_open(const char *path, int flags)
else {
serrno = errno;
close(fd);
- fd = -1;
}
}
freeaddrinfo(res0);
+ if (res == NULL) {
+ errno = serrno;
+ return (-1);
+ }
+
/*
* handle the open flags by shutting down appropriate directions
*/
- if (fd >= 0) {
- switch(flags & O_ACCMODE) {
- case O_RDONLY:
- cap_rights_clear(&rights, CAP_WRITE);
- if (shutdown(fd, SHUT_WR) == -1)
- warn(NULL);
- break;
- case O_WRONLY:
- cap_rights_clear(&rights, CAP_READ);
- if (shutdown(fd, SHUT_RD) == -1)
- warn(NULL);
- break;
- default:
- break;
- }
- cap_rights_clear(&rights, CAP_CONNECT, CAP_SHUTDOWN);
- if (caph_rights_limit(fd, &rights) < 0) {
- serrno = errno;
- close(fd);
- errno = serrno;
- return (-1);
- }
- } else {
+ switch (flags & O_ACCMODE) {
+ case O_RDONLY:
+ cap_rights_clear(&rights, CAP_WRITE);
+ if (shutdown(fd, SHUT_WR) == -1)
+ warn(NULL);
+ break;
+ case O_WRONLY:
+ cap_rights_clear(&rights, CAP_READ);
+ if (shutdown(fd, SHUT_RD) == -1)
+ warn(NULL);
+ break;
+ default:
+ break;
+ }
+
+ cap_rights_clear(&rights, CAP_CONNECT, CAP_SHUTDOWN);
+ if (caph_rights_limit(fd, &rights) < 0) {
+ serrno = errno;
+ close(fd);
errno = serrno;
+ return (-1);
}
return (fd);
}
diff --git a/bin/cat/tests/Makefile b/bin/cat/tests/Makefile
index ebc313c5a091..83f93f5fc2db 100644
--- a/bin/cat/tests/Makefile
+++ b/bin/cat/tests/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE= tests
diff --git a/bin/cat/tests/Makefile.depend b/bin/cat/tests/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/bin/cat/tests/Makefile.depend
+++ b/bin/cat/tests/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/bin/chflags/Makefile b/bin/chflags/Makefile
index 1cee973c5655..fd19a4e4f848 100644
--- a/bin/chflags/Makefile
+++ b/bin/chflags/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.1 (Berkeley) 6/6/93
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/bin/chflags/Makefile.depend b/bin/chflags/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/bin/chflags/Makefile.depend
+++ b/bin/chflags/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/bin/chflags/chflags.1 b/bin/chflags/chflags.1
index 3160e3780f25..31a4211fb25c 100644
--- a/bin/chflags/chflags.1
+++ b/bin/chflags/chflags.1
@@ -29,9 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)chflags.1 8.4 (Berkeley) 5/2/95
-.\" $FreeBSD$
-.\"
.Dd June 12, 2018
.Dt CHFLAGS 1
.Os
diff --git a/bin/chflags/chflags.c b/bin/chflags/chflags.c
index 55dedfce53f1..a78ebbfd471d 100644
--- a/bin/chflags/chflags.c
+++ b/bin/chflags/chflags.c
@@ -29,21 +29,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1992, 1993, 1994\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif
-
-#ifndef lint
-static char sccsid[] = "@(#)chflags.c 8.5 (Berkeley) 4/1/94";
-#endif
-#endif
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/stat.h>
@@ -59,7 +44,7 @@ __FBSDID("$FreeBSD$");
static volatile sig_atomic_t siginfo;
-static void usage(void);
+static void usage(void) __dead2;
static void
siginfo_handler(int sig __unused)
@@ -76,7 +61,7 @@ main(int argc, char *argv[])
u_long clear, newflags, set;
long val;
int Hflag, Lflag, Rflag, fflag, hflag, vflag, xflag;
- int ch, fts_options, oct, rval;
+ int ch, e, fts_options, oct, rval;
char *flags, *ep;
Hflag = Lflag = Rflag = fflag = hflag = vflag = xflag = 0;
@@ -197,9 +182,17 @@ main(int argc, char *argv[])
if (newflags == p->fts_statp->st_flags)
continue;
if (chflagsat(AT_FDCWD, p->fts_accpath, newflags,
- atflag) == -1 && !fflag) {
- warn("%s", p->fts_path);
- rval = 1;
+ atflag) == -1) {
+ e = errno;
+ if (!fflag) {
+ warnc(e, "%s", p->fts_path);
+ rval = 1;
+ }
+ if (siginfo) {
+ (void)printf("%s: %s\n", p->fts_path,
+ strerror(e));
+ siginfo = 0;
+ }
} else if (vflag || siginfo) {
(void)printf("%s", p->fts_path);
if (vflag > 1 || siginfo)
diff --git a/bin/chflags/tests/Makefile b/bin/chflags/tests/Makefile
index e0737b090b95..eb2f870fd6aa 100644
--- a/bin/chflags/tests/Makefile
+++ b/bin/chflags/tests/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
ATF_TESTS_SH+= chflags_test
diff --git a/bin/chflags/tests/Makefile.depend b/bin/chflags/tests/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/bin/chflags/tests/Makefile.depend
+++ b/bin/chflags/tests/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/bin/chflags/tests/chflags_test.sh b/bin/chflags/tests/chflags_test.sh
index 5574e370d68d..0fb3f31259b0 100644
--- a/bin/chflags/tests/chflags_test.sh
+++ b/bin/chflags/tests/chflags_test.sh
@@ -23,7 +23,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
usage_output='usage: chflags'
diff --git a/bin/chio/Makefile b/bin/chio/Makefile
index a88e7df4604c..0783e1d8372d 100644
--- a/bin/chio/Makefile
+++ b/bin/chio/Makefile
@@ -1,5 +1,3 @@
-# $FreeBSD$
-# @(#)Makefile 8.1 (Berkeley) 6/6/93
PACKAGE=utilities
PROG= chio
diff --git a/bin/chio/Makefile.depend b/bin/chio/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/bin/chio/Makefile.depend
+++ b/bin/chio/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/bin/chio/chio.1 b/bin/chio/chio.1
index b177e45f4656..e455ee27270e 100644
--- a/bin/chio/chio.1
+++ b/bin/chio/chio.1
@@ -30,8 +30,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd October 5, 2016
.Dt CHIO 1
.Os
diff --git a/bin/chio/chio.c b/bin/chio/chio.c
index 3264db8bb18d..07def55ee88f 100644
--- a/bin/chio/chio.c
+++ b/bin/chio/chio.c
@@ -32,19 +32,9 @@
*/
/*
* Additional Copyright (c) 1997, by Matthew Jacob, for NASA/Ames Research Ctr.
- * Addidional Copyright (c) 2000, by C. Stephen Gunn, Waterspout Communications
+ * Additional Copyright (c) 2000, by C. Stephen Gunn, Waterspout Communications
*/
-#if 0
-#ifndef lint
-static const char copyright[] =
- "@(#) Copyright (c) 1996 Jason R. Thorpe. All rights reserved.";
-#endif /* not lint */
-#endif
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/chio.h>
#include <err.h>
@@ -60,7 +50,7 @@ __FBSDID("$FreeBSD$");
#include "defs.h"
#include "pathnames.h"
-static void usage(void);
+static void usage(void) __dead2;
static void cleanup(void);
static u_int16_t parse_element_type(char *);
static u_int16_t parse_element_unit(char *);
@@ -427,7 +417,7 @@ do_position(const char *cname, int argc, char **argv)
/* ARGSUSED */
static int
-do_params(const char *cname, int argc, char **argv)
+do_params(const char *cname, int argc, char **argv __unused)
{
struct changer_params data;
int picker;
@@ -470,7 +460,7 @@ do_params(const char *cname, int argc, char **argv)
/* ARGSUSED */
static int
-do_getpicker(const char *cname, int argc, char **argv)
+do_getpicker(const char *cname, int argc, char **argv __unused)
{
int picker;
diff --git a/bin/chio/defs.h b/bin/chio/defs.h
index 8f10c9d9243a..6b4381a3d447 100644
--- a/bin/chio/defs.h
+++ b/bin/chio/defs.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/*-
* Copyright (c) 1996 Jason R. Thorpe <thorpej@and.com>
diff --git a/bin/chio/pathnames.h b/bin/chio/pathnames.h
index 5b9b1e429dc2..a8308ed7b0ac 100644
--- a/bin/chio/pathnames.h
+++ b/bin/chio/pathnames.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/*-
* Copyright (c) 1996 Jason R. Thorpe <thorpej@and.com>
diff --git a/bin/chmod/Makefile b/bin/chmod/Makefile
index ffb3352ba553..e6de3a834c45 100644
--- a/bin/chmod/Makefile
+++ b/bin/chmod/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.1 (Berkeley) 5/31/93
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/bin/chmod/Makefile.depend b/bin/chmod/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/bin/chmod/Makefile.depend
+++ b/bin/chmod/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/bin/chmod/chmod.1 b/bin/chmod/chmod.1
index e6a5ff8f63cf..b4c79d0f037a 100644
--- a/bin/chmod/chmod.1
+++ b/bin/chmod/chmod.1
@@ -29,9 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)chmod.1 8.4 (Berkeley) 3/31/94
-.\" $FreeBSD$
-.\"
.Dd January 7, 2017
.Dt CHMOD 1
.Os
diff --git a/bin/chmod/chmod.c b/bin/chmod/chmod.c
index e8657af0d97b..78bf3137b9ed 100644
--- a/bin/chmod/chmod.c
+++ b/bin/chmod/chmod.c
@@ -29,20 +29,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static char const copyright[] =
-"@(#) Copyright (c) 1989, 1993, 1994\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "@(#)chmod.c 8.8 (Berkeley) 4/1/94";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/stat.h>
@@ -59,7 +45,7 @@ __FBSDID("$FreeBSD$");
static volatile sig_atomic_t siginfo;
-static void usage(void);
+static void usage(void) __dead2;
static int may_have_nfs4acl(const FTSENT *ent, int hflag);
static void
diff --git a/bin/chmod/tests/Makefile b/bin/chmod/tests/Makefile
index 1cf107f9d35b..ebd96181cee4 100644
--- a/bin/chmod/tests/Makefile
+++ b/bin/chmod/tests/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
ATF_TESTS_SH+= chmod_test
diff --git a/bin/chmod/tests/Makefile.depend b/bin/chmod/tests/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/bin/chmod/tests/Makefile.depend
+++ b/bin/chmod/tests/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/bin/chmod/tests/chmod_test.sh b/bin/chmod/tests/chmod_test.sh
index 8cd766327fa8..b1db336b13c4 100755
--- a/bin/chmod/tests/chmod_test.sh
+++ b/bin/chmod/tests/chmod_test.sh
@@ -23,7 +23,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
get_filesystem()
{
diff --git a/bin/cp/Makefile b/bin/cp/Makefile
index 0c4c7b5eff53..6da92d982f63 100644
--- a/bin/cp/Makefile
+++ b/bin/cp/Makefile
@@ -1,12 +1,10 @@
-# @(#)Makefile 8.1 (Berkeley) 5/31/93
-# $FreeBSD$
.include <src.opts.mk>
PACKAGE=runtime
PROG= cp
SRCS= cp.c utils.c
-CFLAGS+= -DVM_AND_BUFFER_CACHE_SYNCHRONIZED -D_ACL_PRIVATE
+CFLAGS+= -D_ACL_PRIVATE
HAS_TESTS=
SUBDIR.${MK_TESTS}= tests
diff --git a/bin/cp/Makefile.depend b/bin/cp/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/bin/cp/Makefile.depend
+++ b/bin/cp/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/bin/cp/cp.1 b/bin/cp/cp.1
index f6ff23a16f41..d37776dda4d3 100644
--- a/bin/cp/cp.1
+++ b/bin/cp/cp.1
@@ -29,10 +29,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)cp.1 8.3 (Berkeley) 4/18/94
-.\" $FreeBSD$
-.\"
-.Dd February 23, 2022
+.Dd March 28, 2024
.Dt CP 1
.Os
.Sh NAME
@@ -45,7 +42,7 @@
.Op Fl H | Fl L | Fl P
.Oc
.Op Fl f | i | n
-.Op Fl alpsvx
+.Op Fl alNpsvx
.Ar source_file target_file
.Nm
.Oo
@@ -53,15 +50,15 @@
.Op Fl H | Fl L | Fl P
.Oc
.Op Fl f | i | n
-.Op Fl alpsvx
+.Op Fl alNpsvx
.Ar source_file ... target_directory
.Nm
.Op Fl f | i | n
-.Op Fl alPpsvx
+.Op Fl alNPpsvx
.Ar source_file target_file
.Nm
.Op Fl f | i | n
-.Op Fl alPpsvx
+.Op Fl alNPpsvx
.Ar source_file ... target_directory
.Sh DESCRIPTION
In the first synopsis form, the
@@ -158,6 +155,10 @@ or
options.)
.It Fl l
Create hard links to regular files in a hierarchy instead of copying.
+.It Fl N
+When used with
+.Fl p ,
+suppress copying file flags.
.It Fl n
Do not overwrite an existing file.
(The
@@ -308,12 +309,14 @@ differ as they copy special files as normal
files while recreating a hierarchy.
.Pp
The
+.Fl a ,
.Fl l ,
+.Fl N ,
+.Fl n ,
.Fl s ,
.Fl v ,
-.Fl x
and
-.Fl n
+.Fl x
options are non-standard and their use in scripts is not recommended.
.Sh SEE ALSO
.Xr mv 1 ,
diff --git a/bin/cp/cp.c b/bin/cp/cp.c
index dbae4b535843..823376964bd1 100644
--- a/bin/cp/cp.c
+++ b/bin/cp/cp.c
@@ -32,20 +32,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static char const copyright[] =
-"@(#) Copyright (c) 1988, 1993, 1994\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "@(#)cp.c 8.2 (Berkeley) 4/1/94";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* Cp copies source files to target files.
*
@@ -86,8 +72,8 @@ static char emptystring[] = "";
PATH_T to = { to.p_path, emptystring, "" };
-int fflag, iflag, lflag, nflag, pflag, sflag, vflag;
-static int Hflag, Lflag, Rflag, rflag;
+int Nflag, fflag, iflag, lflag, nflag, pflag, sflag, vflag;
+static int Hflag, Lflag, Pflag, Rflag, rflag;
volatile sig_atomic_t info;
enum op { FILE_TO_FILE, FILE_TO_DIR, DIR_TO_DNE };
@@ -100,12 +86,11 @@ main(int argc, char *argv[])
{
struct stat to_stat, tmp_stat;
enum op type;
- int Pflag, ch, fts_options, r, have_trailing_slash;
+ int ch, fts_options, r, have_trailing_slash;
char *target;
fts_options = FTS_NOCHDIR | FTS_PHYSICAL;
- Pflag = 0;
- while ((ch = getopt(argc, argv, "HLPRafilnprsvx")) != -1)
+ while ((ch = getopt(argc, argv, "HLPRafilNnprsvx")) != -1)
switch (ch) {
case 'H':
Hflag = 1;
@@ -139,6 +124,9 @@ main(int argc, char *argv[])
case 'l':
lflag = 1;
break;
+ case 'N':
+ Nflag = 1;
+ break;
case 'n':
nflag = 1;
fflag = iflag = 0;
@@ -161,7 +149,6 @@ main(int argc, char *argv[])
break;
default:
usage();
- break;
}
argc -= optind;
argv += optind;
@@ -273,22 +260,6 @@ main(int argc, char *argv[])
&to_stat)));
}
-/* Does the right thing based on -R + -H/-L/-P */
-static int
-copy_stat(const char *path, struct stat *sb)
-{
-
- /*
- * For -R -H/-P, we need to lstat() instead; copy() cares about the link
- * itself rather than the target if we're not following links during the
- * traversal.
- */
- if (!Rflag || Lflag)
- return (stat(path, sb));
- return (lstat(path, sb));
-}
-
-
static int
copy(char *argv[], enum op type, int fts_options, struct stat *root_stat)
{
@@ -311,14 +282,12 @@ copy(char *argv[], enum op type, int fts_options, struct stat *root_stat)
recurse_path = NULL;
if ((ftsp = fts_open(argv, fts_options, NULL)) == NULL)
err(1, "fts_open");
- for (badcp = rval = 0; errno = 0, (curr = fts_read(ftsp)) != NULL;
- badcp = 0) {
+ for (badcp = rval = 0; (curr = fts_read(ftsp)) != NULL; badcp = 0) {
switch (curr->fts_info) {
case FTS_NS:
case FTS_DNR:
case FTS_ERR:
- warnx("%s: %s",
- curr->fts_path, strerror(curr->fts_errno));
+ warnc(curr->fts_errno, "%s", curr->fts_path);
badcp = rval = 1;
continue;
case FTS_DC: /* Warn, continue. */
@@ -417,7 +386,6 @@ copy(char *argv[], enum op type, int fts_options, struct stat *root_stat)
continue;
}
-
if (asprintf(&recurse_path, "%s/%s", to.p_path,
rootname) == -1)
err(1, "asprintf");
@@ -466,39 +434,36 @@ copy(char *argv[], enum op type, int fts_options, struct stat *root_stat)
continue;
}
- /* Not an error but need to remember it happened. */
- if (copy_stat(to.p_path, &to_stat) == -1)
- dne = 1;
- else {
- if (to_stat.st_dev == curr->fts_statp->st_dev &&
- to_stat.st_ino == curr->fts_statp->st_ino) {
- warnx("%s and %s are identical (not copied).",
- to.p_path, curr->fts_path);
- badcp = rval = 1;
- if (S_ISDIR(curr->fts_statp->st_mode))
- (void)fts_set(ftsp, curr, FTS_SKIP);
- continue;
- }
- if (!S_ISDIR(curr->fts_statp->st_mode) &&
- S_ISDIR(to_stat.st_mode)) {
- warnx("cannot overwrite directory %s with "
- "non-directory %s",
- to.p_path, curr->fts_path);
- badcp = rval = 1;
- continue;
- }
- dne = 0;
+ /* Check if source and destination are identical. */
+ if (stat(to.p_path, &to_stat) == 0 &&
+ to_stat.st_dev == curr->fts_statp->st_dev &&
+ to_stat.st_ino == curr->fts_statp->st_ino) {
+ warnx("%s and %s are identical (not copied).",
+ to.p_path, curr->fts_path);
+ badcp = rval = 1;
+ if (S_ISDIR(curr->fts_statp->st_mode))
+ (void)fts_set(ftsp, curr, FTS_SKIP);
+ continue;
}
+ /* Not an error but need to remember it happened. */
+ dne = lstat(to.p_path, &to_stat) != 0;
+
switch (curr->fts_statp->st_mode & S_IFMT) {
case S_IFLNK:
- /* Catch special case of a non-dangling symlink. */
if ((fts_options & FTS_LOGICAL) ||
((fts_options & FTS_COMFOLLOW) &&
curr->fts_level == 0)) {
+ /*
+ * We asked FTS to follow links but got
+ * here anyway, which means the target is
+ * nonexistent or inaccessible. Let
+ * copy_file() deal with the error.
+ */
if (copy_file(curr, dne))
badcp = rval = 1;
- } else {
+ } else {
+ /* Copy the link. */
if (copy_link(curr, !dne))
badcp = rval = 1;
}
@@ -520,9 +485,13 @@ copy(char *argv[], enum op type, int fts_options, struct stat *root_stat)
* umask blocks owner writes, we fail.
*/
if (dne) {
- if (mkdir(to.p_path,
- curr->fts_statp->st_mode | S_IRWXU) < 0)
- err(1, "%s", to.p_path);
+ mode = curr->fts_statp->st_mode | S_IRWXU;
+ if (mkdir(to.p_path, mode) != 0) {
+ warn("%s", to.p_path);
+ (void)fts_set(ftsp, curr, FTS_SKIP);
+ badcp = rval = 1;
+ break;
+ }
/*
* First DNE with a NULL root_stat is the root
* path, so set root_stat. We can't really
@@ -531,14 +500,19 @@ copy(char *argv[], enum op type, int fts_options, struct stat *root_stat)
* first directory we created and use that.
*/
if (root_stat == NULL &&
- stat(to.p_path, &created_root_stat) == -1) {
- err(1, "stat");
- } else if (root_stat == NULL) {
- root_stat = &created_root_stat;
+ stat(to.p_path, &created_root_stat) != 0) {
+ warn("%s", to.p_path);
+ (void)fts_set(ftsp, curr, FTS_SKIP);
+ badcp = rval = 1;
+ break;
}
+ if (root_stat == NULL)
+ root_stat = &created_root_stat;
} else if (!S_ISDIR(to_stat.st_mode)) {
- errno = ENOTDIR;
- err(1, "%s", to.p_path);
+ warnc(ENOTDIR, "%s", to.p_path);
+ (void)fts_set(ftsp, curr, FTS_SKIP);
+ badcp = rval = 1;
+ break;
}
/*
* Arrange to correct directory attributes later
diff --git a/bin/cp/extern.h b/bin/cp/extern.h
index 65360ccaf6c1..272454bb5871 100644
--- a/bin/cp/extern.h
+++ b/bin/cp/extern.h
@@ -27,9 +27,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * @(#)extern.h 8.2 (Berkeley) 4/1/94
- * $FreeBSD$
*/
typedef struct {
@@ -39,7 +36,7 @@ typedef struct {
} PATH_T;
extern PATH_T to;
-extern int fflag, iflag, lflag, nflag, pflag, sflag, vflag;
+extern int Nflag, fflag, iflag, lflag, nflag, pflag, sflag, vflag;
extern volatile sig_atomic_t info;
__BEGIN_DECLS
@@ -50,5 +47,5 @@ int copy_special(struct stat *, int);
int setfile(struct stat *, int);
int preserve_dir_acls(struct stat *, char *, char *);
int preserve_fd_acls(int, int);
-void usage(void);
+void usage(void) __dead2;
__END_DECLS
diff --git a/bin/cp/tests/Makefile b/bin/cp/tests/Makefile
index faad22df713a..36cf247ceae1 100644
--- a/bin/cp/tests/Makefile
+++ b/bin/cp/tests/Makefile
@@ -1,7 +1,8 @@
-# $FreeBSD$
PACKAGE= tests
ATF_TESTS_SH= cp_test
+PROGS+= sparse
+BINDIR= ${TESTSDIR}
.include <bsd.test.mk>
diff --git a/bin/cp/tests/cp_test.sh b/bin/cp/tests/cp_test.sh
index 7362168d7303..5c581e06ab8e 100755
--- a/bin/cp/tests/cp_test.sh
+++ b/bin/cp/tests/cp_test.sh
@@ -1,5 +1,5 @@
#
-# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+# SPDX-License-Identifier: BSD-2-Clause
#
# Copyright (c) 2020 Kyle Evans <kevans@FreeBSD.org>
#
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
check_size()
{
@@ -52,10 +51,7 @@ basic_symlink_body()
atf_check cp baz foo
atf_check test '!' -L foo
- atf_check -e inline:"cp: baz and baz are identical (not copied).\n" \
- -s exit:1 cp baz baz
- atf_check -e inline:"cp: bar and baz are identical (not copied).\n" \
- -s exit:1 cp baz bar
+ atf_check cmp foo bar
}
atf_test_case chrdev
@@ -72,6 +68,35 @@ chrdev_body()
check_size trunc 0
}
+atf_test_case hardlink
+hardlink_body()
+{
+ echo "foo" >foo
+ atf_check cp -l foo bar
+ atf_check -o inline:"foo\n" cat bar
+ atf_check_equal "$(stat -f%d,%i foo)" "$(stat -f%d,%i bar)"
+}
+
+atf_test_case hardlink_exists
+hardlink_exists_body()
+{
+ echo "foo" >foo
+ echo "bar" >bar
+ atf_check -s not-exit:0 -e match:exists cp -l foo bar
+ atf_check -o inline:"bar\n" cat bar
+ atf_check_not_equal "$(stat -f%d,%i foo)" "$(stat -f%d,%i bar)"
+}
+
+atf_test_case hardlink_exists_force
+hardlink_exists_force_body()
+{
+ echo "foo" >foo
+ echo "bar" >bar
+ atf_check cp -fl foo bar
+ atf_check -o inline:"foo\n" cat bar
+ atf_check_equal "$(stat -f%d,%i foo)" "$(stat -f%d,%i bar)"
+}
+
atf_test_case matching_srctgt
matching_srctgt_body()
{
@@ -199,6 +224,107 @@ recursive_link_Lflag_body()
'(' ! -L foo-mirror/foo/baz ')'
}
+atf_test_case samefile
+samefile_body()
+{
+ echo "foo" >foo
+ ln foo bar
+ ln -s bar baz
+ atf_check -e match:"baz and baz are identical" \
+ -s exit:1 cp baz baz
+ atf_check -e match:"bar and baz are identical" \
+ -s exit:1 cp baz bar
+ atf_check -e match:"foo and baz are identical" \
+ -s exit:1 cp baz foo
+ atf_check -e match:"bar and foo are identical" \
+ -s exit:1 cp foo bar
+}
+
+file_is_sparse()
+{
+ atf_check ${0%/*}/sparse "$1"
+}
+
+files_are_equal()
+{
+ atf_check_not_equal "$(stat -f%d,%i "$1")" "$(stat -f%d,%i "$2")"
+ atf_check cmp "$1" "$2"
+}
+
+atf_test_case sparse_leading_hole
+sparse_leading_hole_body()
+{
+ # A 16-megabyte hole followed by one megabyte of data
+ truncate -s 16M foo
+ seq -f%015g 65536 >>foo
+ file_is_sparse foo
+
+ atf_check cp foo bar
+ files_are_equal foo bar
+ file_is_sparse bar
+}
+
+atf_test_case sparse_multiple_holes
+sparse_multiple_holes_body()
+{
+ # Three one-megabyte blocks of data preceded, separated, and
+ # followed by 16-megabyte holes
+ truncate -s 16M foo
+ seq -f%015g 65536 >>foo
+ truncate -s 33M foo
+ seq -f%015g 65536 >>foo
+ truncate -s 50M foo
+ seq -f%015g 65536 >>foo
+ truncate -s 67M foo
+ file_is_sparse foo
+
+ atf_check cp foo bar
+ files_are_equal foo bar
+ file_is_sparse bar
+}
+
+atf_test_case sparse_only_hole
+sparse_only_hole_body()
+{
+ # A 16-megabyte hole
+ truncate -s 16M foo
+ file_is_sparse foo
+
+ atf_check cp foo bar
+ files_are_equal foo bar
+ file_is_sparse bar
+}
+
+atf_test_case sparse_to_dev
+sparse_to_dev_body()
+{
+ # Three one-megabyte blocks of data preceded, separated, and
+ # followed by 16-megabyte holes
+ truncate -s 16M foo
+ seq -f%015g 65536 >>foo
+ truncate -s 33M foo
+ seq -f%015g 65536 >>foo
+ truncate -s 50M foo
+ seq -f%015g 65536 >>foo
+ truncate -s 67M foo
+ file_is_sparse foo
+
+ atf_check -o file:foo cp foo /dev/stdout
+}
+
+atf_test_case sparse_trailing_hole
+sparse_trailing_hole_body()
+{
+ # One megabyte of data followed by a 16-megabyte hole
+ seq -f%015g 65536 >foo
+ truncate -s 17M foo
+ file_is_sparse foo
+
+ atf_check cp foo bar
+ files_are_equal foo bar
+ file_is_sparse bar
+}
+
atf_test_case standalone_Pflag
standalone_Pflag_body()
{
@@ -209,11 +335,71 @@ standalone_Pflag_body()
atf_check -o inline:'Symbolic Link\n' stat -f %SHT baz
}
+atf_test_case symlink
+symlink_body()
+{
+ echo "foo" >foo
+ atf_check cp -s foo bar
+ atf_check -o inline:"foo\n" cat bar
+ atf_check -o inline:"foo\n" readlink bar
+}
+
+atf_test_case symlink_exists
+symlink_exists_body()
+{
+ echo "foo" >foo
+ echo "bar" >bar
+ atf_check -s not-exit:0 -e match:exists cp -s foo bar
+ atf_check -o inline:"bar\n" cat bar
+}
+
+atf_test_case symlink_exists_force
+symlink_exists_force_body()
+{
+ echo "foo" >foo
+ echo "bar" >bar
+ atf_check cp -fs foo bar
+ atf_check -o inline:"foo\n" cat bar
+ atf_check -o inline:"foo\n" readlink bar
+}
+
+atf_test_case directory_to_symlink
+directory_to_symlink_body()
+{
+ mkdir -p foo
+ ln -s .. foo/bar
+ mkdir bar
+ touch bar/baz
+ atf_check -s not-exit:0 -e match:"Not a directory" \
+ cp -R bar foo
+ atf_check -s not-exit:0 -e match:"Not a directory" \
+ cp -r bar foo
+}
+
+atf_test_case overwrite_directory
+overwrite_directory_body()
+{
+ mkdir -p foo/bar/baz
+ touch bar
+ atf_check -s not-exit:0 -e match:"Is a directory" \
+ cp bar foo
+ rm bar
+ mkdir bar
+ touch bar/baz
+ atf_check -s not-exit:0 -e match:"Is a directory" \
+ cp -R bar foo
+ atf_check -s not-exit:0 -e match:"Is a directory" \
+ cp -r bar foo
+}
+
atf_init_test_cases()
{
atf_add_test_case basic
atf_add_test_case basic_symlink
atf_add_test_case chrdev
+ atf_add_test_case hardlink
+ atf_add_test_case hardlink_exists
+ atf_add_test_case hardlink_exists_force
atf_add_test_case matching_srctgt
atf_add_test_case matching_srctgt_contained
atf_add_test_case matching_srctgt_link
@@ -221,5 +407,16 @@ atf_init_test_cases()
atf_add_test_case recursive_link_dflt
atf_add_test_case recursive_link_Hflag
atf_add_test_case recursive_link_Lflag
+ atf_add_test_case samefile
+ atf_add_test_case sparse_leading_hole
+ atf_add_test_case sparse_multiple_holes
+ atf_add_test_case sparse_only_hole
+ atf_add_test_case sparse_to_dev
+ atf_add_test_case sparse_trailing_hole
atf_add_test_case standalone_Pflag
+ atf_add_test_case symlink
+ atf_add_test_case symlink_exists
+ atf_add_test_case symlink_exists_force
+ atf_add_test_case directory_to_symlink
+ atf_add_test_case overwrite_directory
}
diff --git a/bin/cp/tests/sparse.c b/bin/cp/tests/sparse.c
new file mode 100644
index 000000000000..78957581a56c
--- /dev/null
+++ b/bin/cp/tests/sparse.c
@@ -0,0 +1,73 @@
+/*-
+ * Copyright (c) 2023 Klara, Inc.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <err.h>
+#include <fcntl.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sysexits.h>
+#include <unistd.h>
+
+static bool verbose;
+
+/*
+ * Returns true if the file named by its argument is sparse, i.e. if
+ * seeking to SEEK_HOLE returns a different value than seeking to
+ * SEEK_END.
+ */
+static bool
+sparse(const char *filename)
+{
+ off_t hole, end;
+ int fd;
+
+ if ((fd = open(filename, O_RDONLY)) < 0 ||
+ (hole = lseek(fd, 0, SEEK_HOLE)) < 0 ||
+ (end = lseek(fd, 0, SEEK_END)) < 0)
+ err(1, "%s", filename);
+ close(fd);
+ if (end > hole) {
+ if (verbose)
+ printf("%s: hole at %zu\n", filename, (size_t)hole);
+ return (true);
+ }
+ return (false);
+}
+
+static void
+usage(void)
+{
+
+ fprintf(stderr, "usage: sparse [-v] file [...]\n");
+ exit(EX_USAGE);
+}
+
+int
+main(int argc, char *argv[])
+{
+ int opt, rv;
+
+ while ((opt = getopt(argc, argv, "v")) != -1) {
+ switch (opt) {
+ case 'v':
+ verbose = true;
+ break;
+ default:
+ usage();
+ break;
+ }
+ }
+ argc -= optind;
+ argv += optind;
+ if (argc == 0)
+ usage();
+ rv = EXIT_SUCCESS;
+ while (argc-- > 0)
+ if (!sparse(*argv++))
+ rv = EXIT_FAILURE;
+ exit(rv);
+}
diff --git a/bin/cp/utils.c b/bin/cp/utils.c
index e7ae0c9dd733..d102fb076139 100644
--- a/bin/cp/utils.c
+++ b/bin/cp/utils.c
@@ -29,21 +29,9 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)utils.c 8.3 (Berkeley) 4/1/94";
-#endif
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/types.h>
-#include <sys/acl.h>
#include <sys/param.h>
+#include <sys/acl.h>
#include <sys/stat.h>
-#ifdef VM_AND_BUFFER_CACHE_SYNCHRONIZED
-#include <sys/mman.h>
-#endif
#include <err.h>
#include <errno.h>
@@ -74,12 +62,28 @@ __FBSDID("$FreeBSD$");
*/
#define BUFSIZE_SMALL (MAXPHYS)
+/*
+ * Prompt used in -i case.
+ */
+#define YESNO "(y/n [n]) "
+
static ssize_t
-copy_fallback(int from_fd, int to_fd, char *buf, size_t bufsize)
+copy_fallback(int from_fd, int to_fd)
{
+ static char *buf = NULL;
+ static size_t bufsize;
ssize_t rcount, wresid, wcount = 0;
char *bufp;
+ if (buf == NULL) {
+ if (sysconf(_SC_PHYS_PAGES) > PHYSPAGES_THRESHOLD)
+ bufsize = MIN(BUFSIZE_MAX, MAXPHYS * 8);
+ else
+ bufsize = BUFSIZE_SMALL;
+ buf = malloc(bufsize);
+ if (buf == NULL)
+ err(1, "Not enough memory");
+ }
rcount = read(from_fd, buf, bufsize);
if (rcount <= 0)
return (rcount);
@@ -87,7 +91,7 @@ copy_fallback(int from_fd, int to_fd, char *buf, size_t bufsize)
wcount = write(to_fd, bufp, wresid);
if (wcount <= 0)
break;
- if (wcount >= (ssize_t)wresid)
+ if (wcount >= wresid)
break;
}
return (wcount < 0 ? wcount : rcount);
@@ -96,28 +100,34 @@ copy_fallback(int from_fd, int to_fd, char *buf, size_t bufsize)
int
copy_file(const FTSENT *entp, int dne)
{
- static char *buf = NULL;
- static size_t bufsize;
- struct stat *fs;
- ssize_t rcount, wcount;
- size_t wresid;
+ struct stat sb, *fs;
+ ssize_t wcount;
off_t wtotal;
int ch, checkch, from_fd, rval, to_fd;
- char *bufp;
-#ifdef VM_AND_BUFFER_CACHE_SYNCHRONIZED
- char *p;
-#endif
int use_copy_file_range = 1;
+ fs = entp->fts_statp;
from_fd = to_fd = -1;
- if (!lflag && !sflag &&
- (from_fd = open(entp->fts_path, O_RDONLY, 0)) == -1) {
- warn("%s", entp->fts_path);
- return (1);
+ if (!lflag && !sflag) {
+ if ((from_fd = open(entp->fts_path, O_RDONLY, 0)) < 0 ||
+ fstat(from_fd, &sb) != 0) {
+ warn("%s", entp->fts_path);
+ return (1);
+ }
+ /*
+ * Check that the file hasn't been replaced with one of a
+ * different type. This can happen if we've been asked to
+ * copy something which is actively being modified and
+ * lost the race, or if we've been asked to copy something
+ * like /proc/X/fd/Y which stat(2) reports as S_IFREG but
+ * is actually something else once you open it.
+ */
+ if ((sb.st_mode & S_IFMT) != (fs->st_mode & S_IFMT)) {
+ warnx("%s: File changed", entp->fts_path);
+ return (1);
+ }
}
- fs = entp->fts_statp;
-
/*
* If the file exists and we're interactive, verify with the user.
* If the file DNE, set the mode to be the from file, minus setuid
@@ -127,7 +137,6 @@ copy_file(const FTSENT *entp, int dne)
* modified by the umask.)
*/
if (!dne) {
-#define YESNO "(y/n [n]) "
if (nflag) {
if (vflag)
printf("%s not overwritten\n", to.p_path);
@@ -147,128 +156,69 @@ copy_file(const FTSENT *entp, int dne)
}
if (fflag) {
- /*
- * Remove existing destination file name create a new
- * file.
- */
+ /* remove existing destination file */
(void)unlink(to.p_path);
- if (!lflag && !sflag) {
- to_fd = open(to.p_path,
- O_WRONLY | O_TRUNC | O_CREAT,
- fs->st_mode & ~(S_ISUID | S_ISGID));
- }
- } else if (!lflag && !sflag) {
- /* Overwrite existing destination file name. */
- to_fd = open(to.p_path, O_WRONLY | O_TRUNC, 0);
+ dne = 1;
+ }
+ }
+
+ rval = 0;
+
+ if (lflag) {
+ if (link(entp->fts_path, to.p_path) != 0) {
+ warn("%s", to.p_path);
+ rval = 1;
+ }
+ goto done;
+ }
+
+ if (sflag) {
+ if (symlink(entp->fts_path, to.p_path) != 0) {
+ warn("%s", to.p_path);
+ rval = 1;
}
- } else if (!lflag && !sflag) {
+ goto done;
+ }
+
+ if (!dne) {
+ /* overwrite existing destination file */
+ to_fd = open(to.p_path, O_WRONLY | O_TRUNC, 0);
+ } else {
+ /* create new destination file */
to_fd = open(to.p_path, O_WRONLY | O_TRUNC | O_CREAT,
fs->st_mode & ~(S_ISUID | S_ISGID));
}
-
- if (!lflag && !sflag && to_fd == -1) {
+ if (to_fd == -1) {
warn("%s", to.p_path);
rval = 1;
goto done;
}
- rval = 0;
-
- if (!lflag && !sflag) {
- /*
- * Mmap and write if less than 8M (the limit is so we don't
- * totally trash memory on big files. This is really a minor
- * hack, but it wins some CPU back.
- * Some filesystems, such as smbnetfs, don't support mmap,
- * so this is a best-effort attempt.
- */
-#ifdef VM_AND_BUFFER_CACHE_SYNCHRONIZED
- if (S_ISREG(fs->st_mode) && fs->st_size > 0 &&
- fs->st_size <= 8 * 1024 * 1024 &&
- (p = mmap(NULL, (size_t)fs->st_size, PROT_READ,
- MAP_SHARED, from_fd, (off_t)0)) != MAP_FAILED) {
- wtotal = 0;
- for (bufp = p, wresid = fs->st_size; ;
- bufp += wcount, wresid -= (size_t)wcount) {
- wcount = write(to_fd, bufp, wresid);
- if (wcount <= 0)
- break;
- wtotal += wcount;
- if (info) {
- info = 0;
- (void)fprintf(stderr,
- "%s -> %s %3d%%\n",
- entp->fts_path, to.p_path,
- cp_pct(wtotal, fs->st_size));
- }
- if (wcount >= (ssize_t)wresid)
- break;
- }
- if (wcount != (ssize_t)wresid) {
- warn("%s", to.p_path);
- rval = 1;
- }
- /* Some systems don't unmap on close(2). */
- if (munmap(p, fs->st_size) < 0) {
- warn("%s", entp->fts_path);
- rval = 1;
- }
- } else
-#endif
- {
- if (buf == NULL) {
- /*
- * Note that buf and bufsize are static. If
- * malloc() fails, it will fail at the start
- * and not copy only some files.
- */
- if (sysconf(_SC_PHYS_PAGES) >
- PHYSPAGES_THRESHOLD)
- bufsize = MIN(BUFSIZE_MAX, MAXPHYS * 8);
- else
- bufsize = BUFSIZE_SMALL;
- buf = malloc(bufsize);
- if (buf == NULL)
- err(1, "Not enough memory");
- }
- wtotal = 0;
- do {
- if (use_copy_file_range) {
- rcount = copy_file_range(from_fd, NULL,
- to_fd, NULL, SSIZE_MAX, 0);
- if (rcount < 0 && errno == EINVAL) {
- /* Prob a non-seekable FD */
- use_copy_file_range = 0;
- }
- }
- if (!use_copy_file_range) {
- rcount = copy_fallback(from_fd, to_fd,
- buf, bufsize);
- }
- wtotal += rcount;
- if (info) {
- info = 0;
- (void)fprintf(stderr,
- "%s -> %s %3d%%\n",
- entp->fts_path, to.p_path,
- cp_pct(wtotal, fs->st_size));
- }
- } while (rcount > 0);
- if (rcount < 0) {
- warn("%s", entp->fts_path);
- rval = 1;
+ wtotal = 0;
+ do {
+ if (use_copy_file_range) {
+ wcount = copy_file_range(from_fd, NULL,
+ to_fd, NULL, SSIZE_MAX, 0);
+ if (wcount < 0 && errno == EINVAL) {
+ /* probably a non-seekable descriptor */
+ use_copy_file_range = 0;
}
}
- } else if (lflag) {
- if (link(entp->fts_path, to.p_path)) {
- warn("%s", to.p_path);
- rval = 1;
+ if (!use_copy_file_range) {
+ wcount = copy_fallback(from_fd, to_fd);
}
- } else if (sflag) {
- if (symlink(entp->fts_path, to.p_path)) {
- warn("%s", to.p_path);
- rval = 1;
+ wtotal += wcount;
+ if (info) {
+ info = 0;
+ (void)fprintf(stderr,
+ "%s -> %s %3d%%\n",
+ entp->fts_path, to.p_path,
+ cp_pct(wtotal, fs->st_size));
}
+ } while (wcount > 0);
+ if (wcount < 0) {
+ warn("%s", entp->fts_path);
+ rval = 1;
}
/*
@@ -277,16 +227,13 @@ copy_file(const FTSENT *entp, int dne)
* or its contents might be irreplaceable. It would only be safe
* to remove it if we created it and its length is 0.
*/
-
- if (!lflag && !sflag) {
- if (pflag && setfile(fs, to_fd))
- rval = 1;
- if (pflag && preserve_fd_acls(from_fd, to_fd) != 0)
- rval = 1;
- if (close(to_fd)) {
- warn("%s", to.p_path);
- rval = 1;
- }
+ if (pflag && setfile(fs, to_fd))
+ rval = 1;
+ if (pflag && preserve_fd_acls(from_fd, to_fd) != 0)
+ rval = 1;
+ if (close(to_fd)) {
+ warn("%s", to.p_path);
+ rval = 1;
}
done:
@@ -298,7 +245,7 @@ done:
int
copy_link(const FTSENT *p, int exists)
{
- int len;
+ ssize_t len;
char llink[PATH_MAX];
if (exists && nflag) {
@@ -415,13 +362,22 @@ setfile(struct stat *fs, int fd)
rval = 1;
}
- if (!gotstat || fs->st_flags != ts.st_flags)
+ if (!Nflag && (!gotstat || fs->st_flags != ts.st_flags))
if (fdval ?
fchflags(fd, fs->st_flags) :
(islink ? lchflags(to.p_path, fs->st_flags) :
chflags(to.p_path, fs->st_flags))) {
- warn("chflags: %s", to.p_path);
- rval = 1;
+ /*
+ * NFS doesn't support chflags; ignore errors unless
+ * there's reason to believe we're losing bits. (Note,
+ * this still won't be right if the server supports
+ * flags and we were trying to *remove* flags on a file
+ * that we copied, i.e., that we didn't create.)
+ */
+ if (errno != EOPNOTSUPP || fs->st_flags != 0) {
+ warn("chflags: %s", to.p_path);
+ rval = 1;
+ }
}
return (rval);
diff --git a/bin/cpuset/Makefile b/bin/cpuset/Makefile
new file mode 100644
index 000000000000..6e88614a6a6e
--- /dev/null
+++ b/bin/cpuset/Makefile
@@ -0,0 +1,8 @@
+
+PROG= cpuset
+
+LIBADD= jail
+
+SYMLINKS+= ../..${BINDIR}/cpuset /usr/bin/cpuset
+
+.include <bsd.prog.mk>
diff --git a/bin/cpuset/Makefile.depend b/bin/cpuset/Makefile.depend
new file mode 100644
index 000000000000..2f6b4a414fb5
--- /dev/null
+++ b/bin/cpuset/Makefile.depend
@@ -0,0 +1,16 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libcompiler_rt \
+ lib/libjail \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/bin/cpuset/cpuset.1 b/bin/cpuset/cpuset.1
new file mode 100644
index 000000000000..7636e720d623
--- /dev/null
+++ b/bin/cpuset/cpuset.1
@@ -0,0 +1,227 @@
+.\" Copyright (c) 2008 Christian Brueffer
+.\" Copyright (c) 2008 Jeffrey Roberson
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.Dd July 3, 2018
+.Dt CPUSET 1
+.Os
+.Sh NAME
+.Nm cpuset
+.Nd "configure processor sets"
+.Sh SYNOPSIS
+.Nm
+.Op Fl l Ar cpu-list
+.Op Fl n Ar policy:domain-list
+.Op Fl s Ar setid
+.Ar cmd ...
+.Nm
+.Op Fl l Ar cpu-list
+.Op Fl n Ar policy:domain-list
+.Op Fl s Ar setid
+.Fl p Ar pid
+.Nm
+.Op Fl c
+.Op Fl l Ar cpu-list
+.Op Fl n Ar policy:domain-list
+.Fl C
+.Fl p Ar pid
+.Nm
+.Op Fl c
+.Op Fl l Ar cpu-list
+.Op Fl n Ar policy:domain-list
+.Op Fl j Ar jail | Fl p Ar pid | Fl t Ar tid | Fl s Ar setid | Fl x Ar irq
+.Nm
+.Fl g
+.Op Fl cir
+.Op Fl d Ar domain | Fl j Ar jail | Fl p Ar pid | Fl t Ar tid | Fl s Ar setid | Fl x Ar irq
+.Sh DESCRIPTION
+The
+.Nm
+command can be used to assign processor sets to processes, run commands
+constrained to a given set or list of processors and memory domains, and query
+information about processor binding, memory binding and policy, sets, and
+available processors and memory domains in the system.
+.Pp
+.Nm
+requires a target to modify or query.
+The target may be specified as a command, process id, thread id, a
+cpuset id, an irq, a jail, or a NUMA domain.
+Using
+.Fl g
+the target's set id or mask may be queried.
+Using
+.Fl l
+or
+.Fl s
+the target's CPU mask or set id may be set.
+If no target is specified,
+.Nm
+operates on itself.
+Not all combinations of operations and targets are supported.
+For example,
+you may not set the id of an existing set or query and launch a command
+at the same time.
+.Pp
+There are two sets applicable to each process and one private mask per thread.
+Every process in the system belongs to a cpuset.
+By default processes are started in set 1.
+The mask or id may be queried using
+.Fl c .
+Each thread also has a private mask of CPUs it is allowed to run
+on that must be a subset of the assigned set.
+And finally, there is a root set, numbered 0, that is immutable.
+This last set is the list of all possible CPUs in the system and is
+queried using
+.Fl r .
+.Pp
+Most sets include NUMA memory domain and policy information.
+This can be inspected with
+.Fl g
+and set with
+.Fl n .
+This will specify which NUMA domains are visible to the process and
+affect where anonymous memory and file pages will be stored on first access.
+Files accessed first by other processes may specify conflicting policy.
+.Pp
+When running a command it may join a set specified with
+.Fl s
+otherwise a new set is created.
+In addition, a mask for the command may be specified using
+.Fl l .
+When used in conjunction with
+.Fl c
+the mask modifies the supplied or created set rather than the private mask
+for the thread.
+.Pp
+The options are as follows:
+.Bl -tag -width ".Fl l Ar cpu-list"
+.It Fl C
+Create a new cpuset and assign the target process to that set.
+.It Fl c
+The requested operation should reference the cpuset available via the
+target specifier.
+.It Fl d Ar domain
+Specifies a NUMA domain id as the target of the operation.
+This can only be used to query the cpus visible in each numberd domain.
+.It Fl g
+Causes
+.Nm
+to print either a list of valid CPUs or, using
+.Fl i ,
+the id of the target.
+.It Fl i
+When used with the
+.Fl g
+option print the id rather than the valid mask of the target.
+.It Fl j Ar jail
+Specifies a jail id or name as the target of the operation.
+.It Fl l Ar cpu-list
+Specifies a list of CPUs to apply to a target.
+Specification may include
+numbers separated by '-' for ranges and commas separating individual numbers.
+A special list of
+.Dq all
+may be specified in which case the list includes all CPUs from the root set.
+.It Fl n Ar policy:domain-list
+Specifies a list of domains and allocation policy to apply to a target.
+Ranges may be specified as in
+.Fl l .
+Valid policies include first-touch (ft), round-robin (rr), prefer and
+interleave (il).
+First-touch allocates on the local domain when memory is available.
+Round-robin alternates between every possible domain page at a time.
+The prefer policy accepts only a single domain in the set.
+The parent of the set is consulted if the preferred domain is unavailable.
+Interleave operates like round-robin with an implementation defined stripe
+width.
+See
+.Xr domainset 9
+for more details on policies.
+.It Fl p Ar pid
+Specifies a pid as the target of the operation.
+.It Fl s Ar setid
+Specifies a set id as the target of the operation.
+.It Fl r
+The requested operation should reference the root set available via the
+target specifier.
+.It Fl t Ar tid
+Specifies a thread id as the target of the operation.
+.It Fl x Ar irq
+Specifies an irq as the target of the operation.
+.El
+.Sh EXIT STATUS
+.Ex -std
+.Sh EXAMPLES
+Create a new group with CPUs 0-4 inclusive and run
+.Pa /bin/sh
+on it:
+.Dl cpuset -c -l 0-4 /bin/sh
+.Pp
+Query the mask of CPUs the
+.Aq sh pid
+is allowed to run on:
+.Dl cpuset -g -p <sh pid>
+.Pp
+Restrict
+.Pa /bin/sh
+to run on CPUs 0 and 2 while its group is still allowed to run on
+CPUs 0-4:
+.Dl cpuset -l 0,2 -p <sh pid>
+.Pp
+Modify the cpuset
+.Pa /bin/sh
+belongs to restricting it to CPUs 0 and 2:
+.Dl cpuset -l 0,2 -c -p <sh pid>
+.Pp
+Modify the cpuset all threads are in by default to contain only
+the first 4 CPUs, leaving the rest idle:
+.Dl cpuset -l 0-3 -s 1
+.Pp
+Print the id of the cpuset
+.Pa /bin/sh
+is in:
+.Dl cpuset -g -i -p <sh pid>
+.Pp
+Move the
+.Ar pid
+into the specified cpuset
+.Ar setid
+so it may be managed with other pids in that set:
+.Dl cpuset -s <setid> -p <pid>
+.Pp
+Create a new cpuset that is restricted to CPUs 0 and 2 and move
+.Ar pid
+into the new set:
+.Dl cpuset -C -c -l 0,2 -p <pid>
+.Sh SEE ALSO
+.Xr nproc 1 ,
+.Xr cpuset 2 ,
+.Xr rctl 8
+.Sh HISTORY
+The
+.Nm
+command first appeared in
+.Fx 7.1 .
+.Sh AUTHORS
+.An Jeffrey Roberson Aq Mt jeff@FreeBSD.org
diff --git a/bin/cpuset/cpuset.c b/bin/cpuset/cpuset.c
new file mode 100644
index 000000000000..82ffcaeec252
--- /dev/null
+++ b/bin/cpuset/cpuset.c
@@ -0,0 +1,473 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2007, 2008 Jeffrey Roberson <jeff@freebsd.org>
+ * All rights reserved.
+ *
+ * Copyright (c) 2008 Nokia Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#define _WANT_FREEBSD_BITSET
+
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <sys/cpuset.h>
+#include <sys/domainset.h>
+
+#include <ctype.h>
+#include <err.h>
+#include <errno.h>
+#include <jail.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <unistd.h>
+#include <string.h>
+
+static int Cflag;
+static int cflag;
+static int dflag;
+static int gflag;
+static int iflag;
+static int jflag;
+static int lflag;
+static int nflag;
+static int pflag;
+static int rflag;
+static int sflag;
+static int tflag;
+static int xflag;
+static id_t id;
+static cpulevel_t level;
+static cpuwhich_t which;
+
+static void usage(void) __dead2;
+
+struct numa_policy {
+ const char *name;
+ int policy;
+};
+
+static struct numa_policy policies[] = {
+ { "round-robin", DOMAINSET_POLICY_ROUNDROBIN },
+ { "rr", DOMAINSET_POLICY_ROUNDROBIN },
+ { "first-touch", DOMAINSET_POLICY_FIRSTTOUCH },
+ { "ft", DOMAINSET_POLICY_FIRSTTOUCH },
+ { "prefer", DOMAINSET_POLICY_PREFER },
+ { "interleave", DOMAINSET_POLICY_INTERLEAVE},
+ { "il", DOMAINSET_POLICY_INTERLEAVE},
+ { NULL, DOMAINSET_POLICY_INVALID }
+};
+
+static void printset(struct bitset *mask, int size);
+
+static void
+parselist(char *list, struct bitset *mask, int size)
+{
+ enum { NONE, NUM, DASH } state;
+ int lastnum;
+ int curnum;
+ char *l;
+
+ state = NONE;
+ curnum = lastnum = 0;
+ for (l = list; *l != '\0';) {
+ if (isdigit(*l)) {
+ curnum = atoi(l);
+ if (curnum >= size)
+ errx(EXIT_FAILURE,
+ "List entry %d exceeds maximum of %d",
+ curnum, size - 1);
+ while (isdigit(*l))
+ l++;
+ switch (state) {
+ case NONE:
+ lastnum = curnum;
+ state = NUM;
+ break;
+ case DASH:
+ for (; lastnum <= curnum; lastnum++)
+ BIT_SET(size, lastnum, mask);
+ state = NONE;
+ break;
+ case NUM:
+ default:
+ goto parserr;
+ }
+ continue;
+ }
+ switch (*l) {
+ case ',':
+ switch (state) {
+ case NONE:
+ break;
+ case NUM:
+ BIT_SET(size, curnum, mask);
+ state = NONE;
+ break;
+ case DASH:
+ goto parserr;
+ break;
+ }
+ break;
+ case '-':
+ if (state != NUM)
+ goto parserr;
+ state = DASH;
+ break;
+ default:
+ goto parserr;
+ }
+ l++;
+ }
+ switch (state) {
+ case NONE:
+ break;
+ case NUM:
+ BIT_SET(size, curnum, mask);
+ break;
+ case DASH:
+ goto parserr;
+ }
+ return;
+parserr:
+ errx(EXIT_FAILURE, "Malformed list %s", list);
+}
+
+static void
+parsecpulist(char *list, cpuset_t *mask)
+{
+
+ if (strcasecmp(list, "all") == 0) {
+ if (cpuset_getaffinity(CPU_LEVEL_ROOT, CPU_WHICH_PID, -1,
+ sizeof(*mask), mask) != 0)
+ err(EXIT_FAILURE, "getaffinity");
+ return;
+ }
+ parselist(list, (struct bitset *)mask, CPU_SETSIZE);
+}
+
+/*
+ * permissively parse policy:domain list
+ * allow:
+ * round-robin:0-4 explicit
+ * round-robin:all explicit root domains
+ * 0-4 implicit root policy
+ * round-robin implicit root domains
+ * all explicit root domains and implicit policy
+ */
+static void
+parsedomainlist(char *list, domainset_t *mask, int *policyp)
+{
+ domainset_t rootmask;
+ struct numa_policy *policy;
+ char *l;
+ int p;
+
+ /*
+ * Use the rootset's policy as the default for unspecified policies.
+ */
+ if (cpuset_getdomain(CPU_LEVEL_ROOT, CPU_WHICH_PID, -1,
+ sizeof(rootmask), &rootmask, &p) != 0)
+ err(EXIT_FAILURE, "getdomain");
+
+ l = list;
+ for (policy = &policies[0]; policy->name != NULL; policy++) {
+ if (strncasecmp(l, policy->name, strlen(policy->name)) == 0) {
+ p = policy->policy;
+ l += strlen(policy->name);
+ if (*l != ':' && *l != '\0')
+ errx(EXIT_FAILURE, "Malformed list %s", list);
+ if (*l == ':')
+ l++;
+ break;
+ }
+ }
+ *policyp = p;
+ if (strcasecmp(l, "all") == 0 || *l == '\0') {
+ DOMAINSET_COPY(&rootmask, mask);
+ return;
+ }
+ parselist(l, (struct bitset *)mask, DOMAINSET_SETSIZE);
+}
+
+static void
+printset(struct bitset *mask, int size)
+{
+ int once;
+ int bit;
+
+ for (once = 0, bit = 0; bit < size; bit++) {
+ if (BIT_ISSET(size, bit, mask)) {
+ if (once == 0) {
+ printf("%d", bit);
+ once = 1;
+ } else
+ printf(", %d", bit);
+ }
+ }
+ printf("\n");
+}
+
+static const char *whichnames[] = { NULL, "tid", "pid", "cpuset", "irq", "jail",
+ "domain" };
+static const char *levelnames[] = { NULL, " root", " cpuset", "" };
+static const char *policynames[] = { "invalid", "round-robin", "first-touch",
+ "prefer", "interleave" };
+
+static void
+printaffinity(void)
+{
+ domainset_t domain;
+ cpuset_t mask;
+ int policy;
+
+ if (cpuset_getaffinity(level, which, id, sizeof(mask), &mask) != 0)
+ err(EXIT_FAILURE, "getaffinity");
+ printf("%s %jd%s mask: ", whichnames[which], (intmax_t)id,
+ levelnames[level]);
+ printset((struct bitset *)&mask, CPU_SETSIZE);
+ if (dflag || xflag)
+ goto out;
+ if (cpuset_getdomain(level, which, id, sizeof(domain), &domain,
+ &policy) != 0)
+ err(EXIT_FAILURE, "getdomain");
+ printf("%s %jd%s domain policy: %s mask: ", whichnames[which],
+ (intmax_t)id, levelnames[level], policynames[policy]);
+ printset((struct bitset *)&domain, DOMAINSET_SETSIZE);
+out:
+ exit(EXIT_SUCCESS);
+}
+
+static void
+printsetid(void)
+{
+ cpusetid_t setid;
+
+ /*
+ * Only LEVEL_WHICH && WHICH_CPUSET has a numbered id.
+ */
+ if (level == CPU_LEVEL_WHICH && !sflag)
+ level = CPU_LEVEL_CPUSET;
+ if (cpuset_getid(level, which, id, &setid))
+ err(errno, "getid");
+ printf("%s %jd%s id: %d\n", whichnames[which], (intmax_t)id,
+ levelnames[level], setid);
+}
+
+int
+main(int argc, char *argv[])
+{
+ domainset_t domains;
+ cpusetid_t setid;
+ cpuset_t mask;
+ int policy;
+ lwpid_t tid;
+ pid_t pid;
+ int ch;
+
+ CPU_ZERO(&mask);
+ DOMAINSET_ZERO(&domains);
+ policy = DOMAINSET_POLICY_INVALID;
+ level = CPU_LEVEL_WHICH;
+ which = CPU_WHICH_PID;
+ id = pid = tid = setid = -1;
+ while ((ch = getopt(argc, argv, "Ccd:gij:l:n:p:rs:t:x:")) != -1) {
+ switch (ch) {
+ case 'C':
+ Cflag = 1;
+ break;
+ case 'c':
+ cflag = 1;
+ level = CPU_LEVEL_CPUSET;
+ break;
+ case 'd':
+ dflag = 1;
+ which = CPU_WHICH_DOMAIN;
+ id = atoi(optarg);
+ break;
+ case 'g':
+ gflag = 1;
+ break;
+ case 'i':
+ iflag = 1;
+ break;
+ case 'j':
+ jflag = 1;
+ which = CPU_WHICH_JAIL;
+ id = jail_getid(optarg);
+ if (id < 0)
+ errx(EXIT_FAILURE, "%s", jail_errmsg);
+ break;
+ case 'l':
+ lflag = 1;
+ parsecpulist(optarg, &mask);
+ break;
+ case 'n':
+ nflag = 1;
+ parsedomainlist(optarg, &domains, &policy);
+ break;
+ case 'p':
+ pflag = 1;
+ which = CPU_WHICH_PID;
+ id = pid = atoi(optarg);
+ break;
+ case 'r':
+ level = CPU_LEVEL_ROOT;
+ rflag = 1;
+ break;
+ case 's':
+ sflag = 1;
+ which = CPU_WHICH_CPUSET;
+ id = setid = atoi(optarg);
+ break;
+ case 't':
+ tflag = 1;
+ which = CPU_WHICH_TID;
+ id = tid = atoi(optarg);
+ break;
+ case 'x':
+ xflag = 1;
+ which = CPU_WHICH_IRQ;
+ id = atoi(optarg);
+ break;
+ default:
+ usage();
+ }
+ }
+ argc -= optind;
+ argv += optind;
+ if (gflag) {
+ if (argc || Cflag || lflag || nflag)
+ usage();
+ /* Only one identity specifier. */
+ if (dflag + jflag + xflag + sflag + pflag + tflag > 1)
+ usage();
+ if (iflag)
+ printsetid();
+ else
+ printaffinity();
+ exit(EXIT_SUCCESS);
+ }
+
+ if (dflag || iflag || rflag)
+ usage();
+ /*
+ * The user wants to run a command with a set and possibly cpumask.
+ */
+ if (argc) {
+ if (Cflag || pflag || tflag || xflag || jflag)
+ usage();
+ if (sflag) {
+ if (cpuset_setid(CPU_WHICH_PID, -1, setid))
+ err(argc, "setid");
+ } else {
+ if (cpuset(&setid))
+ err(argc, "newid");
+ }
+ if (lflag) {
+ if (cpuset_setaffinity(level, CPU_WHICH_PID,
+ -1, sizeof(mask), &mask) != 0)
+ err(EXIT_FAILURE, "setaffinity");
+ }
+ if (nflag) {
+ if (cpuset_setdomain(level, CPU_WHICH_PID,
+ -1, sizeof(domains), &domains, policy) != 0)
+ err(EXIT_FAILURE, "setdomain");
+ }
+ errno = 0;
+ execvp(*argv, argv);
+ err(errno == ENOENT ? 127 : 126, "%s", *argv);
+ }
+ /*
+ * We're modifying something that presently exists.
+ */
+ if (Cflag && (jflag || !pflag || sflag || tflag || xflag))
+ usage();
+ if ((!lflag && !nflag) && cflag)
+ usage();
+ if ((!lflag && !nflag) && !(Cflag || sflag))
+ usage();
+ /* You can only set a mask on a thread. */
+ if (tflag && (sflag | pflag | xflag | jflag))
+ usage();
+ /* You can only set a mask on an irq. */
+ if (xflag && (jflag | pflag | sflag | tflag))
+ usage();
+ if (Cflag) {
+ /*
+ * Create a new cpuset and move the specified process
+ * into the set.
+ */
+ if (cpuset(&setid) < 0)
+ err(EXIT_FAILURE, "newid");
+ sflag = 1;
+ }
+ if (pflag && sflag) {
+ if (cpuset_setid(CPU_WHICH_PID, pid, setid))
+ err(EXIT_FAILURE, "setid");
+ /*
+ * If the user specifies a set and a list we want the mask
+ * to effect the pid and not the set.
+ */
+ which = CPU_WHICH_PID;
+ id = pid;
+ }
+ if (lflag) {
+ if (cpuset_setaffinity(level, which, id, sizeof(mask),
+ &mask) != 0)
+ err(EXIT_FAILURE, "setaffinity");
+ }
+ if (nflag) {
+ if (cpuset_setdomain(level, which, id, sizeof(domains),
+ &domains, policy) != 0)
+ err(EXIT_FAILURE, "setdomain");
+ }
+
+ exit(EXIT_SUCCESS);
+}
+
+static void
+usage(void)
+{
+
+ fprintf(stderr,
+ "usage: cpuset [-l cpu-list] [-n policy:domain-list] [-s setid] cmd ...\n");
+ fprintf(stderr,
+ " cpuset [-l cpu-list] [-n policy:domain-list] [-s setid] -p pid\n");
+ fprintf(stderr,
+ " cpuset [-c] [-l cpu-list] [-n policy:domain-list] -C -p pid\n");
+ fprintf(stderr,
+ " cpuset [-c] [-l cpu-list] [-n policy:domain-list]\n"
+ " [-j jailid | -p pid | -t tid | -s setid | -x irq]\n");
+ fprintf(stderr,
+ " cpuset -g [-cir]\n"
+ " [-d domain | -j jailid | -p pid | -t tid | -s setid | -x irq]\n");
+ exit(1);
+}
diff --git a/bin/csh/Makefile b/bin/csh/Makefile
index 2281c11538d0..d9f40f180343 100644
--- a/bin/csh/Makefile
+++ b/bin/csh/Makefile
@@ -1,6 +1,3 @@
-# $FreeBSD$
-# @(#)Makefile 8.1 (Berkeley) 5/31/93
-#
# C Shell with process control; VM/UNIX VAX Makefile
# Bill Joy UC Berkeley; Jim Kulp IIASA, Austria
#
@@ -16,6 +13,7 @@ ROOTPACKAGE= csh
ETC= csh.cshrc csh.login csh.logout
ROOT= dot.cshrc dot.login
ROOTDIR= /root
+ROOTDIR_MODE= 0750
ROOTNAME_dot.cshrc= .cshrc
ROOTNAME_dot.login= .login
TCSHDIR= ${SRCTOP}/contrib/tcsh
@@ -118,15 +116,18 @@ NLSSRCFILES_${catalog:C/.*://}!= cd ${NLSSRCDIR_${catalog:C/.*://}}; echo charse
csh.1: tcsh.man
cat ${.ALLSRC} > ${.TARGET}
+.if ${MACHINE} == "host" || ${MK_DIRDEPS_BUILD} == "no"
build-tools: gethost
+tc.defs.c: gethost
DEPENDOBJS+= gethost
gethost: gethost.c sh.err.h tc.const.h sh.h ${BUILD_TOOLS_META}
@rm -f ${.TARGET}
- ${CC:N${CCACHE_BIN}} -o gethost ${LDFLAGS} ${CFLAGS:C/-DHAVE_ICONV//} \
+ ${HOST_CC:N${CCACHE_BIN}} -o gethost ${LDFLAGS} ${CFLAGS:C/-DHAVE_ICONV//} \
${TCSHDIR}/gethost.c
+.endif
-tc.defs.c: gethost ${TCSHDIR}/host.defs
+tc.defs.c: ${TCSHDIR}/host.defs
@rm -f ${.TARGET}
@echo "/* Do not edit this file, make creates it */" > ${.TARGET}
${BTOOLSPATH:U.}/gethost ${TCSHDIR}/host.defs >> ${.TARGET}
@@ -162,6 +163,9 @@ beforeinstallconfig:
rm -f ${DESTDIR}/.cshrc
afterinstallconfig:
- ${INSTALL_LINK} ${TAG_ARGS} ${DESTDIR}/root/.cshrc ${DESTDIR}/.cshrc
+ # XXX Set link mode explicitly via -m. We cannot use LINKMODE for this
+ # link, as it would also apply to the tcsh link above.
+ ${INSTALL_LINK} ${TAG_ARGS} -m ${CONFMODE} ${DESTDIR}/root/.cshrc \
+ ${DESTDIR}/.cshrc
.include <bsd.prog.mk>
diff --git a/bin/csh/Makefile.depend b/bin/csh/Makefile.depend
index 05f33d1d7799..604ca4ffe0ea 100644
--- a/bin/csh/Makefile.depend
+++ b/bin/csh/Makefile.depend
@@ -1,8 +1,7 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
+ bin/csh.host \
include \
include/arpa \
include/xlocale \
@@ -10,7 +9,7 @@ DIRDEPS = \
lib/libc \
lib/libcompiler_rt \
lib/libcrypt \
- lib/ncurses/ncursesw \
+ lib/ncurses/tinfo \
.include <dirdeps.mk>
diff --git a/bin/csh/config.h b/bin/csh/config.h
index 103ceb604062..6705cc58f5bd 100644
--- a/bin/csh/config.h
+++ b/bin/csh/config.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.in by autoheader. */
diff --git a/bin/csh/config_p.h b/bin/csh/config_p.h
index c25e87a903ea..8b7ecd20de19 100644
--- a/bin/csh/config_p.h
+++ b/bin/csh/config_p.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/*
* config.h -- configure various defines for tcsh
*
diff --git a/bin/csh/csh.cshrc b/bin/csh/csh.cshrc
index f4f775ae6ada..b08603404cf9 100644
--- a/bin/csh/csh.cshrc
+++ b/bin/csh/csh.cshrc
@@ -1,3 +1,2 @@
-# $FreeBSD$
#
# System-wide .cshrc file for csh(1).
diff --git a/bin/csh/csh.login b/bin/csh/csh.login
index b55ae087590a..ec1b70451236 100644
--- a/bin/csh/csh.login
+++ b/bin/csh/csh.login
@@ -1,4 +1,3 @@
-# $FreeBSD$
#
# System-wide .login file for csh(1).
#
diff --git a/bin/csh/csh.logout b/bin/csh/csh.logout
index 6b0584f49984..73103d8096d8 100644
--- a/bin/csh/csh.logout
+++ b/bin/csh/csh.logout
@@ -1,3 +1,2 @@
-# $FreeBSD$
#
# System-wide .logout file for csh(1).
diff --git a/bin/csh/dot.cshrc b/bin/csh/dot.cshrc
index 2465cf42da6c..3d1ddb094c72 100644
--- a/bin/csh/dot.cshrc
+++ b/bin/csh/dot.cshrc
@@ -1,4 +1,3 @@
-# $FreeBSD$
#
# .cshrc - csh resource script, read at beginning of execution by each shell
#
diff --git a/bin/csh/dot.login b/bin/csh/dot.login
index 8d87604f4f7d..a18fc8c78001 100644
--- a/bin/csh/dot.login
+++ b/bin/csh/dot.login
@@ -1,4 +1,3 @@
-# $FreeBSD$
#
# .login - csh login script, read by login shell, after `.cshrc' at login.
#
diff --git a/bin/csh/iconv_stub.c b/bin/csh/iconv_stub.c
index e20608c60616..67659d9f20a3 100644
--- a/bin/csh/iconv_stub.c
+++ b/bin/csh/iconv_stub.c
@@ -22,8 +22,6 @@
* LIABILITY, OR TORT (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$
*/
#include <dlfcn.h>
diff --git a/bin/csh/iconv_stub.h b/bin/csh/iconv_stub.h
index a3e069a06e31..d85bcf3b113b 100644
--- a/bin/csh/iconv_stub.h
+++ b/bin/csh/iconv_stub.h
@@ -22,8 +22,6 @@
* LIABILITY, OR TORT (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$
*/
#ifndef _ICONV_H_
diff --git a/bin/date/Makefile b/bin/date/Makefile
index c7807eb7a760..85c269aa10b1 100644
--- a/bin/date/Makefile
+++ b/bin/date/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.1 (Berkeley) 5/31/93
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/bin/date/Makefile.depend b/bin/date/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/bin/date/Makefile.depend
+++ b/bin/date/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/bin/date/date.1 b/bin/date/date.1
index 53a5d441099f..afa6d555a503 100644
--- a/bin/date/date.1
+++ b/bin/date/date.1
@@ -29,10 +29,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)date.1 8.3 (Berkeley) 4/28/95
-.\" $FreeBSD$
-.\"
-.Dd July 28, 2022
+.Dd April 26, 2024
.Dt DATE 1
.Os
.Sh NAME
@@ -42,6 +39,7 @@
.\" Display time.
.Nm
.Op Fl nRu
+.Op Fl z Ar output_zone
.Op Fl I Ns Op Ar FMT
.Op Fl r Ar filename
.Op Fl r Ar seconds
@@ -56,6 +54,7 @@
.\" Set time with the default input format.
.Nm
.Op Fl jnRu
+.Op Fl z Ar output_zone
.Op Fl I Ns Op Ar FMT
.Oo
.Sm off
@@ -77,6 +76,7 @@
.\" Set time with the user-provided input format.
.Nm
.Op Fl jnRu
+.Op Fl z Ar output_zone
.Op Fl I Ns Op Ar FMT
.Oo
.Sm off
@@ -141,17 +141,19 @@ values are
.Cm date ,
.Cm hours ,
.Cm minutes ,
+.Cm seconds ,
and
-.Cm seconds .
+.Cm ns No Pq for nanoseconds .
The date and time is formatted to the specified precision.
When
.Ar FMT
is
.Cm hours
-(or the more precise
-.Cm minutes
+.Po or the more precise
+.Cm minutes ,
+.Cm seconds ,
or
-.Cm seconds ) ,
+.Cm ns Pc ,
the
.St -iso8601
format includes the timezone.
@@ -202,6 +204,14 @@ displays the time in the time zone described by
or the
.Ev TZ
environment variable.
+.It Fl z Ar output_zone
+Just before printing the time, change to the specified timezone;
+see the description of
+.Ev TZ
+below.
+This can be used with
+.Fl j
+to easily convert time specifications from one zone to another.
.It Xo
.Fl v
.Sm off
@@ -215,8 +225,8 @@ day, week day, month or year according to
.Ar val .
If
.Ar val
-is preceded with a plus or minus sign,
-the date is adjusted forwards or backwards according to the remaining string,
+is preceded by a plus or minus sign,
+the date is adjusted forward or backward according to the remaining string,
otherwise the relevant part of the date is set.
The date can be adjusted as many times as required using these flags.
Flags are processed in the order given.
@@ -276,7 +286,7 @@ will be necessary to reach October 29, 2:30.
.Pp
When the date is adjusted to a specific value that does not actually exist
(for example March 26, 1:30 BST 2000 in the Europe/London timezone),
-the date will be silently adjusted forwards in units of one hour until it
+the date will be silently adjusted forward in units of one hour until it
reaches a valid time.
When the date is adjusted to a specific value that occurs twice
(for example October 29, 1:30 2000),
@@ -317,7 +327,9 @@ which specifies the format in which to display the date and time.
The format string may contain any of the conversion specifications
described in the
.Xr strftime 3
-manual page, as well as any arbitrary text.
+manual page and
+.Ql %N
+for nanoseconds, as well as any arbitrary text.
A newline
.Pq Ql \en
character is always output after the characters specified by
@@ -514,13 +526,20 @@ will display
.Pp
.Dl "2018-08-04T13:42:19-07:00"
.Pp
-Finally the command:
+The command:
.Pp
-.Dl "date -j -f ""%a %b %d %T %Z %Y"" ""`LC_ALL=C date`"" ""+%s"""
+.Dl "env LC_ALL=C date -j -f ""%a %b %d %T %Z %Y"" ""`env LC_ALL=C date`"" ""+%s"""
.Pp
can be used to parse the output from
.Nm
and express it in Epoch time.
+.Pp
+Finally the command
+.Pp
+.Dl "TZ=America/Los_Angeles date -z Europe/Paris -j 0900"
+.Pp
+will print the time in the "Europe/Paris" timezone when it is 9:00 in The
+America/Los_Angeles timezone.
.Sh DIAGNOSTICS
It is invalid to combine the
.Fl I
@@ -536,6 +555,7 @@ prints:
and exits with status 1.
.Sh SEE ALSO
.Xr locale 1 ,
+.Xr clock_gettime 2 ,
.Xr gettimeofday 2 ,
.Xr getutxent 3 ,
.Xr strftime 3 ,
@@ -566,6 +586,12 @@ The format selected by the
.Fl I
flag is compatible with
.St -iso8601 .
+.Pp
+The
+.Ql %N
+conversion specification for nanoseconds is a non-standard extension.
+It is compatible with GNU date's
+.Ql %N .
.Sh HISTORY
A
.Nm
@@ -584,3 +610,8 @@ The
.Fl I
flag was added in
.Fx 12.0 .
+.Pp
+The
+.Ql %N
+conversion specification was added in
+.Fx 15.0 .
diff --git a/bin/date/date.c b/bin/date/date.c
index 4dc5df0dccfc..718c94601dd6 100644
--- a/bin/date/date.c
+++ b/bin/date/date.c
@@ -29,27 +29,13 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static char const copyright[] =
-"@(#) Copyright (c) 1985, 1987, 1988, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#if 0
-#ifndef lint
-static char sccsid[] = "@(#)date.c 8.2 (Berkeley) 4/28/95";
-#endif /* not lint */
-#endif
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <ctype.h>
#include <err.h>
+#include <errno.h>
#include <locale.h>
#include <stdbool.h>
#include <stdio.h>
@@ -65,15 +51,15 @@ __FBSDID("$FreeBSD$");
#define TM_YEAR_BASE 1900
#endif
-static time_t tval;
-
static void badformat(void);
-static void iso8601_usage(const char *);
+static void iso8601_usage(const char *) __dead2;
static void multipleformats(void);
static void printdate(const char *);
-static void printisodate(struct tm *);
-static void setthetime(const char *, const char *, int);
-static void usage(void);
+static void printisodate(struct tm *, long);
+static void setthetime(const char *, const char *, int, struct timespec *);
+static size_t strftime_ns(char * __restrict, size_t, const char * __restrict,
+ const struct tm * __restrict, long);
+static void usage(void) __dead2;
static const struct iso8601_fmt {
const char *refname;
@@ -83,6 +69,7 @@ static const struct iso8601_fmt {
{ "hours", "T%H" },
{ "minutes", ":%M" },
{ "seconds", ":%S" },
+ { "ns", ",%N" },
};
static const struct iso8601_fmt *iso8601_selected;
@@ -91,11 +78,12 @@ static const char *rfc2822_format = "%a, %d %b %Y %T %z";
int
main(int argc, char *argv[])
{
+ struct timespec ts;
int ch, rflag;
bool Iflag, jflag, Rflag;
const char *format;
char buf[1024];
- char *fmt;
+ char *fmt, *outzone = NULL;
char *tmp;
struct vary *v;
const struct vary *badv;
@@ -108,7 +96,9 @@ main(int argc, char *argv[])
(void) setlocale(LC_TIME, "");
rflag = 0;
Iflag = jflag = Rflag = 0;
- while ((ch = getopt(argc, argv, "f:I::jnRr:uv:")) != -1)
+ ts.tv_sec = 0;
+ ts.tv_nsec = 0;
+ while ((ch = getopt(argc, argv, "f:I::jnRr:uv:z:")) != -1)
switch((char)ch) {
case 'f':
fmt = optarg;
@@ -141,17 +131,21 @@ main(int argc, char *argv[])
break;
case 'r': /* user specified seconds */
rflag = 1;
- tval = strtoq(optarg, &tmp, 0);
+ ts.tv_sec = strtoq(optarg, &tmp, 0);
if (*tmp != 0) {
- if (stat(optarg, &sb) == 0)
- tval = sb.st_mtim.tv_sec;
- else
+ if (stat(optarg, &sb) == 0) {
+ ts.tv_sec = sb.st_mtim.tv_sec;
+ ts.tv_nsec = sb.st_mtim.tv_nsec;
+ } else
usage();
}
break;
case 'u': /* do everything in UTC */
(void)setenv("TZ", "UTC0", 1);
break;
+ case 'z':
+ outzone = optarg;
+ break;
case 'v':
v = vary_append(v, optarg);
break;
@@ -161,8 +155,8 @@ main(int argc, char *argv[])
argc -= optind;
argv += optind;
- if (!rflag && time(&tval) == -1)
- err(1, "time");
+ if (!rflag && clock_gettime(CLOCK_REALTIME, &ts) == -1)
+ err(1, "clock_gettime");
format = "%+";
@@ -178,7 +172,7 @@ main(int argc, char *argv[])
}
if (*argv) {
- setthetime(fmt, *argv, jflag);
+ setthetime(fmt, *argv, jflag, &ts);
++argv;
} else if (fmt != NULL)
usage();
@@ -189,7 +183,9 @@ main(int argc, char *argv[])
format = *argv + 1;
}
- lt = localtime(&tval);
+ if (outzone != NULL && setenv("TZ", outzone, 1) != 0)
+ err(1, "setenv(TZ)");
+ lt = localtime(&ts.tv_sec);
if (lt == NULL)
errx(1, "invalid time");
badv = vary_apply(v, lt);
@@ -202,7 +198,7 @@ main(int argc, char *argv[])
vary_destroy(v);
if (Iflag)
- printisodate(lt);
+ printisodate(lt, ts.tv_nsec);
if (format == rfc2822_format)
/*
@@ -211,7 +207,8 @@ main(int argc, char *argv[])
*/
setlocale(LC_TIME, "C");
- (void)strftime(buf, sizeof(buf), format, lt);
+
+ (void)strftime_ns(buf, sizeof(buf), format, lt, ts.tv_nsec);
printdate(buf);
}
@@ -225,19 +222,19 @@ printdate(const char *buf)
}
static void
-printisodate(struct tm *lt)
+printisodate(struct tm *lt, long nsec)
{
const struct iso8601_fmt *it;
- char fmtbuf[32], buf[32], tzbuf[8];
+ char fmtbuf[64], buf[64], tzbuf[8];
fmtbuf[0] = 0;
for (it = iso8601_fmts; it <= iso8601_selected; it++)
strlcat(fmtbuf, it->format_string, sizeof(fmtbuf));
- (void)strftime(buf, sizeof(buf), fmtbuf, lt);
+ (void)strftime_ns(buf, sizeof(buf), fmtbuf, lt, nsec);
if (iso8601_selected > iso8601_fmts) {
- (void)strftime(tzbuf, sizeof(tzbuf), "%z", lt);
+ (void)strftime_ns(tzbuf, sizeof(tzbuf), "%z", lt, nsec);
memmove(&tzbuf[4], &tzbuf[3], 3);
tzbuf[3] = ':';
strlcat(buf, tzbuf, sizeof(buf));
@@ -249,15 +246,14 @@ printisodate(struct tm *lt)
#define ATOI2(s) ((s) += 2, ((s)[-2] - '0') * 10 + ((s)[-1] - '0'))
static void
-setthetime(const char *fmt, const char *p, int jflag)
+setthetime(const char *fmt, const char *p, int jflag, struct timespec *ts)
{
struct utmpx utx;
struct tm *lt;
- struct timeval tv;
const char *dot, *t;
int century;
- lt = localtime(&tval);
+ lt = localtime(&ts->tv_sec);
if (lt == NULL)
errx(1, "invalid time");
lt->tm_isdst = -1; /* divine correct DST */
@@ -338,18 +334,17 @@ setthetime(const char *fmt, const char *p, int jflag)
}
/* convert broken-down time to GMT clock time */
- if ((tval = mktime(lt)) == -1)
+ if ((ts->tv_sec = mktime(lt)) == -1)
errx(1, "nonexistent time");
+ ts->tv_nsec = 0;
if (!jflag) {
utx.ut_type = OLD_TIME;
memset(utx.ut_id, 0, sizeof(utx.ut_id));
(void)gettimeofday(&utx.ut_tv, NULL);
pututxline(&utx);
- tv.tv_sec = tval;
- tv.tv_usec = 0;
- if (settimeofday(&tv, NULL) != 0)
- err(1, "settimeofday (timeval)");
+ if (clock_settime(CLOCK_REALTIME, ts) != 0)
+ err(1, "clock_settime");
utx.ut_type = NEW_TIME;
(void)gettimeofday(&utx.ut_tv, NULL);
pututxline(&utx);
@@ -360,6 +355,82 @@ setthetime(const char *fmt, const char *p, int jflag)
}
}
+/*
+ * The strftime_ns function is a wrapper around strftime(3), which adds support
+ * for features absent from strftime(3). Currently, the only extra feature is
+ * support for %N, the nanosecond conversion specification.
+ *
+ * The functions scans the format string for the non-standard conversion
+ * specifications and replaces them with the date and time values before
+ * passing the format string to strftime(3). The handling of the non-standard
+ * conversion specifications happens before the call to strftime(3) to handle
+ * cases like "%%N" correctly ("%%N" should yield "%N" instead of nanoseconds).
+ */
+static size_t
+strftime_ns(char * __restrict s, size_t maxsize, const char * __restrict format,
+ const struct tm * __restrict t, long nsec)
+{
+ size_t prefixlen;
+ size_t ret;
+ char *newformat;
+ char *oldformat;
+ const char *prefix;
+ const char *suffix;
+ const char *tok;
+ bool seen_percent;
+
+ seen_percent = false;
+ if (asprintf(&newformat, "%s", format) < 0)
+ err(1, "asprintf");
+ tok = newformat;
+ for (tok = newformat; *tok != '\0'; tok++) {
+ switch (*tok) {
+ case '%':
+ /*
+ * If the previous token was a percent sign,
+ * then there are two percent tokens in a row.
+ */
+ if (seen_percent)
+ seen_percent = false;
+ else
+ seen_percent = true;
+ break;
+ case 'N':
+ if (seen_percent) {
+ oldformat = newformat;
+ prefix = oldformat;
+ prefixlen = tok - oldformat - 1;
+ suffix = tok + 1;
+ /*
+ * Construct a new format string from the
+ * prefix (i.e., the part of the old fromat
+ * from its beginning to the currently handled
+ * "%N" conversion specification, the
+ * nanoseconds, and the suffix (i.e., the part
+ * of the old format from the next token to the
+ * end).
+ */
+ if (asprintf(&newformat, "%.*s%.9ld%s",
+ (int)prefixlen, prefix, nsec,
+ suffix) < 0) {
+ err(1, "asprintf");
+ }
+ free(oldformat);
+ tok = newformat + prefixlen + 9;
+ }
+ seen_percent = false;
+ break;
+ default:
+ seen_percent = false;
+ break;
+ }
+ }
+
+ ret = strftime(s, maxsize, newformat, t);
+ free(newformat);
+ return (ret);
+}
+
static void
badformat(void)
{
@@ -383,9 +454,9 @@ static void
usage(void)
{
(void)fprintf(stderr, "%s\n%s\n%s\n",
- "usage: date [-jnRu] [-I[date|hours|minutes|seconds]] [-f input_fmt]",
+ "usage: date [-jnRu] [-I[date|hours|minutes|seconds|ns]] [-f input_fmt]",
" "
- "[-r filename|seconds] [-v[+|-]val[y|m|w|d|H|M|S]]",
+ "[ -z output_zone ] [-r filename|seconds] [-v[+|-]val[y|m|w|d|H|M|S]]",
" "
"[[[[[[cc]yy]mm]dd]HH]MM[.SS] | new_date] [+output_fmt]"
);
diff --git a/bin/date/tests/Makefile b/bin/date/tests/Makefile
index 64d86d23bee6..02675a3dc8a5 100644
--- a/bin/date/tests/Makefile
+++ b/bin/date/tests/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
ATF_TESTS_SH= format_string_test
diff --git a/bin/date/tests/Makefile.depend b/bin/date/tests/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/bin/date/tests/Makefile.depend
+++ b/bin/date/tests/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/bin/date/tests/format_string_test.sh b/bin/date/tests/format_string_test.sh
index 7ae323b50adc..c2fe2111373f 100755
--- a/bin/date/tests/format_string_test.sh
+++ b/bin/date/tests/format_string_test.sh
@@ -3,7 +3,6 @@
#
# Submitted by Edwin Groothuis <edwin@FreeBSD.org>
#
-# $FreeBSD$
#
#
@@ -31,6 +30,17 @@ check()
date -r ${TEST2} +%${format_string}
}
+atf_test_case flag_r_file_test
+flag_r_file_test_body()
+{
+ local file
+
+ file="./testfile"
+ touch "$file"
+ atf_check -o "inline:$(stat -f '%9Fm' "$file")\n" \
+ date -r "$file" +%s.%N
+}
+
format_string_test()
{
local desc exp_output_1 exp_output_2 flag
@@ -99,6 +109,8 @@ iso8601_${desc}_parity_body() {
atf_init_test_cases()
{
+ atf_add_test_case flag_r_file_test
+
format_string_test A A Saturday Monday
format_string_test a a Sat Mon
format_string_test B B February November
@@ -119,6 +131,7 @@ atf_init_test_cases()
format_string_test l l " 7" " 9"
format_string_test M M 04 20
format_string_test m m 02 11
+ format_string_test N N 000000000 000000000
format_string_test p p AM PM
format_string_test R R 07:04 21:20
format_string_test r r "07:04:03 AM" "09:20:00 PM"
@@ -144,6 +157,5 @@ atf_init_test_cases()
iso8601_string_test hours hours "" "1970-02-07T07+00:00" "2001-11-12T21+00:00"
iso8601_string_test minutes minutes "" "1970-02-07T07:04+00:00" "2001-11-12T21:20+00:00"
iso8601_string_test seconds seconds "" "1970-02-07T07:04:03+00:00" "2001-11-12T21:20:00+00:00"
- # BSD date(1) does not support fractional seconds at this time.
- #iso8601_string_test ns ns "" "1970-02-07T07:04:03,000000000+00:00" "2001-11-12T21:20:00,000000000+00:00"
+ iso8601_string_test ns ns "" "1970-02-07T07:04:03,000000000+00:00" "2001-11-12T21:20:00,000000000+00:00"
}
diff --git a/bin/date/vary.c b/bin/date/vary.c
index 5f0123110ee3..ec556139c201 100644
--- a/bin/date/vary.c
+++ b/bin/date/vary.c
@@ -25,16 +25,15 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <err.h>
#include <time.h>
+#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include "vary.h"
struct trans {
- int val;
+ int64_t val;
const char *str;
};
@@ -52,7 +51,7 @@ static struct trans trans_wday[] = {
};
static char digits[] = "0123456789";
-static int adjhour(struct tm *, char, int, int);
+static int adjhour(struct tm *, char, int64_t, int);
static int
domktime(struct tm *t, char type)
@@ -125,7 +124,7 @@ daysinmonth(const struct tm *t)
static int
-adjyear(struct tm *t, char type, int val, int mk)
+adjyear(struct tm *t, char type, int64_t val, int mk)
{
switch (type) {
case '+':
@@ -146,7 +145,7 @@ adjyear(struct tm *t, char type, int val, int mk)
}
static int
-adjmon(struct tm *t, char type, int val, int istext, int mk)
+adjmon(struct tm *t, char type, int64_t val, int istext, int mk)
{
int lmdays;
@@ -206,7 +205,7 @@ adjmon(struct tm *t, char type, int val, int istext, int mk)
}
static int
-adjday(struct tm *t, char type, int val, int mk)
+adjday(struct tm *t, char type, int64_t val, int mk)
{
int lmdays;
@@ -250,7 +249,7 @@ adjday(struct tm *t, char type, int val, int mk)
}
static int
-adjwday(struct tm *t, char type, int val, int istext, int mk)
+adjwday(struct tm *t, char type, int64_t val, int istext, int mk)
{
if (val < 0)
return 0;
@@ -286,7 +285,7 @@ adjwday(struct tm *t, char type, int val, int istext, int mk)
}
static int
-adjhour(struct tm *t, char type, int val, int mk)
+adjhour(struct tm *t, char type, int64_t val, int mk)
{
if (val < 0)
return 0;
@@ -331,7 +330,7 @@ adjhour(struct tm *t, char type, int val, int mk)
}
static int
-adjmin(struct tm *t, char type, int val, int mk)
+adjmin(struct tm *t, char type, int64_t val, int mk)
{
if (val < 0)
return 0;
@@ -372,7 +371,7 @@ adjmin(struct tm *t, char type, int val, int mk)
}
static int
-adjsec(struct tm *t, char type, int val, int mk)
+adjsec(struct tm *t, char type, int64_t val, int mk)
{
if (val < 0)
return 0;
@@ -419,7 +418,7 @@ vary_apply(const struct vary *v, struct tm *t)
char which;
char *arg;
size_t len;
- int val;
+ int64_t val;
for (; v; v = v->next) {
type = *v->arg;
diff --git a/bin/date/vary.h b/bin/date/vary.h
index b39306a2bb23..a63ee64db055 100644
--- a/bin/date/vary.h
+++ b/bin/date/vary.h
@@ -22,8 +22,6 @@
* LIABILITY, OR TORT (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$
*/
struct vary {
diff --git a/bin/dd/Makefile b/bin/dd/Makefile
index 9088112536dd..fde8e08db42a 100644
--- a/bin/dd/Makefile
+++ b/bin/dd/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.1 (Berkeley) 5/31/93
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/bin/dd/Makefile.depend b/bin/dd/Makefile.depend
index 1adfc08a54d6..ad56045f44d3 100644
--- a/bin/dd/Makefile.depend
+++ b/bin/dd/Makefile.depend
@@ -1,14 +1,14 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
lib/libcapsicum \
+ lib/libcasper/libcasper \
lib/libcompiler_rt \
+ lib/libutil \
.include <dirdeps.mk>
diff --git a/bin/dd/args.c b/bin/dd/args.c
index 35a076175a93..10bb89e632b0 100644
--- a/bin/dd/args.c
+++ b/bin/dd/args.c
@@ -33,14 +33,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)args.c 8.3 (Berkeley) 4/2/94";
-#endif
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <ctype.h>
diff --git a/bin/dd/conv.c b/bin/dd/conv.c
index ef5194ee1e08..d64d57040fca 100644
--- a/bin/dd/conv.c
+++ b/bin/dd/conv.c
@@ -33,14 +33,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)conv.c 8.3 (Berkeley) 4/2/94";
-#endif
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <err.h>
diff --git a/bin/dd/conv_tab.c b/bin/dd/conv_tab.c
index 36e23531bbbb..feba45826e03 100644
--- a/bin/dd/conv_tab.c
+++ b/bin/dd/conv_tab.c
@@ -33,14 +33,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)conv_tab.c 8.1 (Berkeley) 5/31/93";
-#endif
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <signal.h>
diff --git a/bin/dd/dd.1 b/bin/dd/dd.1
index 8bd5fa662ac6..fa04b3673d39 100644
--- a/bin/dd/dd.1
+++ b/bin/dd/dd.1
@@ -29,9 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)dd.1 8.2 (Berkeley) 1/13/94
-.\" $FreeBSD$
-.\"
.Dd June 4, 2020
.Dt DD 1
.Os
diff --git a/bin/dd/dd.c b/bin/dd/dd.c
index c43645fa0073..ca79b684bf1e 100644
--- a/bin/dd/dd.c
+++ b/bin/dd/dd.c
@@ -33,20 +33,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static char const copyright[] =
-"@(#) Copyright (c) 1991, 1993, 1994\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "@(#)dd.c 8.5 (Berkeley) 4/2/94";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/capsicum.h>
@@ -64,6 +50,7 @@ __FBSDID("$FreeBSD$");
#include <fcntl.h>
#include <inttypes.h>
#include <locale.h>
+#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -91,12 +78,15 @@ char fill_char; /* Character to fill with if defined */
size_t speed = 0; /* maximum speed, in bytes per second */
volatile sig_atomic_t need_summary;
volatile sig_atomic_t need_progress;
+volatile sig_atomic_t kill_signal;
int
main(int argc __unused, char *argv[])
{
struct itimerval itv = { { 1, 0 }, { 1, 0 } }; /* SIGALARM every second, if needed */
+ prepare_io();
+
(void)setlocale(LC_CTYPE, "");
jcl(argv);
setup();
@@ -110,7 +100,6 @@ main(int argc __unused, char *argv[])
(void)signal(SIGALRM, sigalarm_handler);
setitimer(ITIMER_REAL, &itv, NULL);
}
- (void)signal(SIGINT, terminate);
atexit(summary);
@@ -154,7 +143,9 @@ setup(void)
iflags = 0;
if (ddflags & C_IDIRECT)
iflags |= O_DIRECT;
+ before_io();
in.fd = open(in.name, O_RDONLY | iflags, 0);
+ after_io();
if (in.fd == -1)
err(1, "%s", in.name);
}
@@ -191,14 +182,18 @@ setup(void)
oflags |= O_FSYNC;
if (ddflags & C_ODIRECT)
oflags |= O_DIRECT;
+ before_io();
out.fd = open(out.name, O_RDWR | oflags, DEFFILEMODE);
+ after_io();
/*
* May not have read access, so try again with write only.
* Without read we may have a problem if output also does
* not support seeks.
*/
if (out.fd == -1) {
+ before_io();
out.fd = open(out.name, O_WRONLY | oflags, DEFFILEMODE);
+ after_io();
out.flags |= NOREAD;
cap_rights_clear(&rights, CAP_READ);
}
@@ -415,7 +410,9 @@ dd_in(void)
in.dbrcnt = 0;
fill:
+ before_io();
n = read(in.fd, in.dbp + in.dbrcnt, in.dbsz - in.dbrcnt);
+ after_io();
/* EOF */
if (n == 0 && in.dbrcnt == 0)
@@ -596,7 +593,9 @@ dd_out(int force)
pending = 0;
}
if (cnt) {
+ before_io();
nw = write(out.fd, outp, cnt);
+ after_io();
out.seek_offset = 0;
} else {
return;
diff --git a/bin/dd/dd.h b/bin/dd/dd.h
index ea606f288f3f..d2d564494a54 100644
--- a/bin/dd/dd.h
+++ b/bin/dd/dd.h
@@ -31,9 +31,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * @(#)dd.h 8.3 (Berkeley) 4/2/94
- * $FreeBSD$
*/
/* Input/output stream state. */
diff --git a/bin/dd/extern.h b/bin/dd/extern.h
index 07c08e2ef8f2..505f107221c4 100644
--- a/bin/dd/extern.h
+++ b/bin/dd/extern.h
@@ -31,9 +31,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * @(#)extern.h 8.3 (Berkeley) 4/2/94
- * $FreeBSD$
*/
void block(void);
@@ -49,7 +46,9 @@ void progress(void);
void summary(void);
void sigalarm_handler(int);
void siginfo_handler(int);
-void terminate(int);
+void prepare_io(void);
+void before_io(void);
+void after_io(void);
void unblock(void);
void unblock_close(void);
@@ -69,3 +68,4 @@ extern u_char casetab[];
extern char fill_char;
extern volatile sig_atomic_t need_summary;
extern volatile sig_atomic_t need_progress;
+extern volatile sig_atomic_t kill_signal;
diff --git a/bin/dd/gen.c b/bin/dd/gen.c
index d53d8fb2b5ac..01e0f61b27b1 100644
--- a/bin/dd/gen.c
+++ b/bin/dd/gen.c
@@ -1,7 +1,5 @@
/*-
* This program is in the public domain
- *
- * $FreeBSD$
*/
#include <stdio.h>
diff --git a/bin/dd/misc.c b/bin/dd/misc.c
index 405448eb1cb0..05c19b5b2073 100644
--- a/bin/dd/misc.c
+++ b/bin/dd/misc.c
@@ -33,14 +33,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)misc.c 8.3 (Berkeley) 4/2/94";
-#endif
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <err.h>
@@ -48,6 +40,7 @@ __FBSDID("$FreeBSD$");
#include <inttypes.h>
#include <libutil.h>
#include <signal.h>
+#include <stdatomic.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -147,11 +140,58 @@ sigalarm_handler(int signo __unused)
need_progress = 1;
}
-/* ARGSUSED */
+static void terminate(int signo) __dead2;
+static void
+terminate(int signo)
+{
+ kill_signal = signo;
+ summary();
+ (void)fflush(stderr);
+ raise(kill_signal);
+ /* NOT REACHED */
+ _exit(1);
+}
+
+static sig_atomic_t in_io = 0;
+static sig_atomic_t sigint_seen = 0;
+
+static void
+sigint_handler(int signo __unused)
+{
+ atomic_signal_fence(memory_order_acquire);
+ if (in_io)
+ terminate(SIGINT);
+ sigint_seen = 1;
+}
+
void
-terminate(int sig)
+prepare_io(void)
{
+ struct sigaction sa;
+ int error;
+
+ memset(&sa, 0, sizeof(sa));
+ sa.sa_flags = SA_NODEFER | SA_RESETHAND;
+ sa.sa_handler = sigint_handler;
+ error = sigaction(SIGINT, &sa, 0);
+ if (error != 0)
+ err(1, "sigaction");
+}
- summary();
- _exit(sig == 0 ? 0 : 1);
+void
+before_io(void)
+{
+ in_io = 1;
+ atomic_signal_fence(memory_order_seq_cst);
+ if (sigint_seen)
+ terminate(SIGINT);
+}
+
+void
+after_io(void)
+{
+ in_io = 0;
+ atomic_signal_fence(memory_order_seq_cst);
+ if (sigint_seen)
+ terminate(SIGINT);
}
diff --git a/bin/dd/position.c b/bin/dd/position.c
index 21a100cd3b24..c092b5c5f8db 100644
--- a/bin/dd/position.c
+++ b/bin/dd/position.c
@@ -33,14 +33,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)position.c 8.3 (Berkeley) 4/2/94";
-#endif
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/mtio.h>
@@ -191,9 +183,11 @@ pos_out(void)
/* Read it. */
for (cnt = 0; cnt < out.offset; ++cnt) {
- if ((n = read(out.fd, out.db, out.dbsz)) > 0)
+ before_io();
+ n = read(out.fd, out.db, out.dbsz);
+ after_io();
+ if (n > 0)
continue;
-
if (n == -1)
err(1, "%s", out.name);
@@ -208,7 +202,9 @@ pos_out(void)
err(1, "%s", out.name);
while (cnt++ < out.offset) {
+ before_io();
n = write(out.fd, out.db, out.dbsz);
+ after_io();
if (n == -1)
err(1, "%s", out.name);
if (n != out.dbsz)
diff --git a/bin/dd/ref.ascii b/bin/dd/ref.ascii
index 7ff13e5a80ed..a8299b6cb056 100644
--- a/bin/dd/ref.ascii
+++ b/bin/dd/ref.ascii
@@ -1,4 +1,3 @@
-$FreeBSD$
00000000 00 01 02 03 9c 09 86 7f 97 8d 8e 0b 0c 0d 0e 0f |................|
00000010 10 11 12 13 9d 85 08 87 18 19 92 8f 1c 1d 1e 1f |................|
00000020 80 81 82 83 84 0a 17 1b 88 89 8a 8b 8c 05 06 07 |................|
diff --git a/bin/dd/ref.ebcdic b/bin/dd/ref.ebcdic
index 605716552cab..b2428c8517ce 100644
--- a/bin/dd/ref.ebcdic
+++ b/bin/dd/ref.ebcdic
@@ -1,4 +1,3 @@
-$FreeBSD$
00000000 00 01 02 03 37 2d 2e 2f 16 05 25 0b 0c 0d 0e 0f |....7-./..%.....|
00000010 10 11 12 13 3c 3d 32 26 18 19 3f 27 1c 1d 1e 1f |....<=2&..?'....|
00000020 40 5a 7f 7b 5b 6c 50 7d 4d 5d 5c 4e 6b 60 4b 61 |@Z.{[lP}M]\Nk`Ka|
diff --git a/bin/dd/ref.ibm b/bin/dd/ref.ibm
index 4836baf221aa..3d05cf9a9ef0 100644
--- a/bin/dd/ref.ibm
+++ b/bin/dd/ref.ibm
@@ -1,4 +1,3 @@
-$FreeBSD$
00000000 00 01 02 03 37 2d 2e 2f 16 05 25 0b 0c 0d 0e 0f |....7-./..%.....|
00000010 10 11 12 13 3c 3d 32 26 18 19 3f 27 1c 1d 1e 1f |....<=2&..?'....|
00000020 40 5a 7f 7b 5b 6c 50 7d 4d 5d 5c 4e 6b 60 4b 61 |@Z.{[lP}M]\Nk`Ka|
diff --git a/bin/dd/ref.lcase b/bin/dd/ref.lcase
index 9f9567296468..a653527f8c63 100644
--- a/bin/dd/ref.lcase
+++ b/bin/dd/ref.lcase
@@ -1,4 +1,3 @@
-$FreeBSD$
00000000 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f |................|
00000010 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f |................|
00000020 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f | !"#$%&'()*+,-./|
diff --git a/bin/dd/ref.obs_zeroes b/bin/dd/ref.obs_zeroes
index 473ff7cc4108..e26380a1e7d3 100644
--- a/bin/dd/ref.obs_zeroes
+++ b/bin/dd/ref.obs_zeroes
@@ -1,3 +1,2 @@
-$FreeBSD$
00000000 41 42 43 44 45 46 47 48 00 00 00 00 00 00 00 00 |ABCDEFGH........|
00000010
diff --git a/bin/dd/ref.oldascii b/bin/dd/ref.oldascii
index bb1ad0a7242b..a748a9d6361f 100644
--- a/bin/dd/ref.oldascii
+++ b/bin/dd/ref.oldascii
@@ -1,4 +1,3 @@
-$FreeBSD$
00000000 00 01 02 03 9c 09 86 7f 97 8d 8e 0b 0c 0d 0e 0f |................|
00000010 10 11 12 13 9d 85 08 87 18 19 92 8f 1c 1d 1e 1f |................|
00000020 80 81 82 83 84 0a 17 1b 88 89 8a 8b 8c 05 06 07 |................|
diff --git a/bin/dd/ref.oldebcdic b/bin/dd/ref.oldebcdic
index 4a7fde7e65b6..122f463b5cf4 100644
--- a/bin/dd/ref.oldebcdic
+++ b/bin/dd/ref.oldebcdic
@@ -1,4 +1,3 @@
-$FreeBSD$
00000000 00 01 02 03 37 2d 2e 2f 16 05 25 0b 0c 0d 0e 0f |....7-./..%.....|
00000010 10 11 12 13 3c 3d 32 26 18 19 3f 27 1c 1d 1e 1f |....<=2&..?'....|
00000020 40 4f 7f 7b 5b 6c 50 7d 4d 5d 5c 4e 6b 60 4b 61 |@O.{[lP}M]\Nk`Ka|
diff --git a/bin/dd/ref.oldibm b/bin/dd/ref.oldibm
index 4836baf221aa..3d05cf9a9ef0 100644
--- a/bin/dd/ref.oldibm
+++ b/bin/dd/ref.oldibm
@@ -1,4 +1,3 @@
-$FreeBSD$
00000000 00 01 02 03 37 2d 2e 2f 16 05 25 0b 0c 0d 0e 0f |....7-./..%.....|
00000010 10 11 12 13 3c 3d 32 26 18 19 3f 27 1c 1d 1e 1f |....<=2&..?'....|
00000020 40 5a 7f 7b 5b 6c 50 7d 4d 5d 5c 4e 6b 60 4b 61 |@Z.{[lP}M]\Nk`Ka|
diff --git a/bin/dd/ref.pareven b/bin/dd/ref.pareven
index c64e63e30660..3c7c240d6f2f 100644
--- a/bin/dd/ref.pareven
+++ b/bin/dd/ref.pareven
@@ -1,4 +1,3 @@
-$FreeBSD$
00000000 00 81 82 03 84 05 06 87 88 09 0a 8b 0c 8d 8e 0f |................|
00000010 90 11 12 93 14 95 96 17 18 99 9a 1b 9c 1d 1e 9f |................|
00000020 a0 21 22 a3 24 a5 a6 27 28 a9 aa 2b ac 2d 2e af |.!".$..'(..+.-..|
diff --git a/bin/dd/ref.parnone b/bin/dd/ref.parnone
index fba31c142448..c6e394f59d8c 100644
--- a/bin/dd/ref.parnone
+++ b/bin/dd/ref.parnone
@@ -1,4 +1,3 @@
-$FreeBSD$
00000000 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f |................|
00000010 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f |................|
00000020 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f | !"#$%&'()*+,-./|
diff --git a/bin/dd/ref.parodd b/bin/dd/ref.parodd
index f0bc449e3648..ada582f87265 100644
--- a/bin/dd/ref.parodd
+++ b/bin/dd/ref.parodd
@@ -1,4 +1,3 @@
-$FreeBSD$
00000000 80 01 02 83 04 85 86 07 08 89 8a 0b 8c 0d 0e 8f |................|
00000010 10 91 92 13 94 15 16 97 98 19 1a 9b 1c 9d 9e 1f |................|
00000020 20 a1 a2 23 a4 25 26 a7 a8 29 2a ab 2c ad ae 2f | ..#.%&..)*.,../|
diff --git a/bin/dd/ref.parset b/bin/dd/ref.parset
index baa1c57163a2..742ed22642d8 100644
--- a/bin/dd/ref.parset
+++ b/bin/dd/ref.parset
@@ -1,4 +1,3 @@
-$FreeBSD$
00000000 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f |................|
00000010 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f |................|
00000020 a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af |................|
diff --git a/bin/dd/ref.swab b/bin/dd/ref.swab
index 79e57b79b738..07cf9ffafa8f 100644
--- a/bin/dd/ref.swab
+++ b/bin/dd/ref.swab
@@ -1,4 +1,3 @@
-$FreeBSD$
00000000 01 00 03 02 05 04 07 06 09 08 0b 0a 0d 0c 0f 0e |................|
00000010 11 10 13 12 15 14 17 16 19 18 1b 1a 1d 1c 1f 1e |................|
00000020 21 20 23 22 25 24 27 26 29 28 2b 2a 2d 2c 2f 2e |! #"%$'&)(+*-,/.|
diff --git a/bin/dd/ref.ucase b/bin/dd/ref.ucase
index 70d8a903c354..a761c99431f5 100644
--- a/bin/dd/ref.ucase
+++ b/bin/dd/ref.ucase
@@ -1,4 +1,3 @@
-$FreeBSD$
00000000 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f |................|
00000010 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f |................|
00000020 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f | !"#$%&'()*+,-./|
diff --git a/bin/dd/tests/Makefile b/bin/dd/tests/Makefile
index 029808e6eb28..e0d924f6d13f 100644
--- a/bin/dd/tests/Makefile
+++ b/bin/dd/tests/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
ATF_TESTS_SH= dd2_test
NETBSD_ATF_TESTS_SH= dd_test
diff --git a/bin/dd/tests/Makefile.depend b/bin/dd/tests/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/bin/dd/tests/Makefile.depend
+++ b/bin/dd/tests/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/bin/dd/tests/dd2_test.sh b/bin/dd/tests/dd2_test.sh
index c0b33fc17226..c4a3065763cd 100755
--- a/bin/dd/tests/dd2_test.sh
+++ b/bin/dd/tests/dd2_test.sh
@@ -1,30 +1,9 @@
#
# Copyright (c) 2017 Spectra Logic Corporation
-# All rights reserved.
+# Copyright (c) 2023 Klara, Inc.
#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
+# SPDX-License-Identifier: BSD-2-Clause
#
-# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
-# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
-# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-# CONTRACT, STRICT LIABILITY, OR TORT (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$
-
atf_test_case max_seek
max_seek_head()
@@ -33,17 +12,23 @@ max_seek_head()
}
max_seek_body()
{
- case `df -T . | tail -n 1 | cut -wf 2` in
- "ufs")
- atf_skip "UFS's maximum file size is too small";;
- "zfs") ;; # ZFS is fine
- "tmpfs")
- atf_skip "tmpfs can't create arbitrarily large spare files";;
- *) atf_skip "Unknown file system";;
+ case $(df -T . | tail -n 1 | cut -wf 2) in
+ "ufs")
+ atf_skip "UFS's maximum file size is too small"
+ ;;
+ "zfs")
+ # ZFS is fine
+ ;;
+ "tmpfs")
+ atf_skip "tmpfs can't create arbitrarily large sparse files"
+ ;;
+ *)
+ atf_skip "Unknown file system"
+ ;;
esac
touch f.in
- seek=`echo "2^63 / 4096 - 1" | bc`
+ seek=$(bc -e "2^63 / 4096 - 1")
atf_check -s exit:0 -e ignore dd if=f.in of=f.out bs=4096 seek=$seek
}
@@ -55,15 +40,58 @@ seek_overflow_head()
seek_overflow_body()
{
touch f.in
- seek=`echo "2^63 / 4096" | bc`
+ seek=$(bc -e "2^63 / 4096")
atf_check -s not-exit:0 -e match:"seek offsets cannot be larger than" \
dd if=f.in of=f.out bs=4096 seek=$seek
atf_check -s not-exit:0 -e match:"seek offsets cannot be larger than" \
dd if=f.in of=f.out bs=4096 seek=-1
}
+atf_test_case sigint
+sigint_open_head()
+{
+ atf_set "descr" "SIGINT while opening destination"
+}
+sigint_open_body()
+{
+ atf_check mkfifo fifo
+ set -m
+ dd if=fifo of=/dev/null 2>stderr &
+ pid=$!
+ sleep 3
+ kill -INT $pid
+ wait $pid
+ rv=$?
+ atf_check test "$rv" -gt 128
+ atf_check -o inline:"INT\n" kill -l $((rv-128))
+ atf_check test -s stderr
+}
+
+atf_test_case sigint
+sigint_read_head()
+{
+ atf_set "descr" "SIGINT while reading source"
+}
+sigint_read_body()
+{
+ atf_check mkfifo fifo
+ (sleep 30 >fifo &) # ensures that dd does not block on open
+ set -m
+ dd if=fifo of=/dev/null 2>stderr &
+ pid=$!
+ sleep 3
+ kill -INT $pid
+ wait $pid
+ rv=$?
+ atf_check test "$rv" -gt 128
+ atf_check -o inline:"INT\n" kill -l $((rv-128))
+ atf_check test -s stderr
+}
+
atf_init_test_cases()
{
atf_add_test_case max_seek
atf_add_test_case seek_overflow
+ atf_add_test_case sigint_open
+ atf_add_test_case sigint_read
}
diff --git a/bin/df/Makefile b/bin/df/Makefile
index 9e875613c9c9..6584f8901cfc 100644
--- a/bin/df/Makefile
+++ b/bin/df/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.3 (Berkeley) 5/8/95
-# $FreeBSD$
PACKAGE=runtime
diff --git a/bin/df/Makefile.depend b/bin/df/Makefile.depend
index 5770a091f2a6..b915f0b12d3b 100644
--- a/bin/df/Makefile.depend
+++ b/bin/df/Makefile.depend
@@ -1,15 +1,13 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
lib/libutil \
- lib/libxo \
+ lib/libxo/libxo \
.include <dirdeps.mk>
diff --git a/bin/df/df.1 b/bin/df/df.1
index 64e471fedc42..ceb1bb45babf 100644
--- a/bin/df/df.1
+++ b/bin/df/df.1
@@ -26,10 +26,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)df.1 8.3 (Berkeley) 5/8/95
-.\" $FreeBSD$
-.\"
-.Dd March 11, 2022
+.Dd March 29, 2023
.Dt DF 1
.Os
.Sh NAME
@@ -120,10 +117,10 @@ option and any
.Ev BLOCKSIZE
specification from the environment.
.It Fl l
-Select locally-mounted file system for display.
+Select a locally-mounted file system for display.
If used in combination with the
.Fl t Ar type
-option, file system types will be added or excluded acccording to the
+option, file system types will be added or excluded according to the
parameters of that option.
.It Fl m
Use 1048576 byte (1 Mebibyte) blocks rather than the default.
@@ -246,6 +243,17 @@ $ df -h /dev/ada1p2
Filesystem Size Used Avail Capacity Mounted on
/dev/ada1p2 213G 152G 44G 78% /
.Ed
+.Sh NOTES
+For non-Unix file systems, the reported values of used and free inodes
+may have a different meaning than that of used and available files and
+directories.
+An example is msdosfs, which in the case of FAT12 or FAT16 file systems
+reports the number of available and free root directory entries instead
+of inodes
+.Po
+where 1 to 21 such directory entries are required to store
+each file or directory name or disk label
+.Pc .
.Sh SEE ALSO
.Xr lsvfs 1 ,
.Xr quota 1 ,
diff --git a/bin/df/df.c b/bin/df/df.c
index 627d8b1c861d..db5b8b18beae 100644
--- a/bin/df/df.c
+++ b/bin/df/df.c
@@ -34,25 +34,10 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1980, 1990, 1993, 1994\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "@(#)df.c 8.9 (Berkeley) 5/8/95";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/mount.h>
#include <sys/sysctl.h>
-#include <err.h>
#include <getopt.h>
#include <libutil.h>
#include <locale.h>
@@ -204,7 +189,7 @@ main(int argc, char *argv[])
argc -= optind;
argv += optind;
- rv = 0;
+ rv = EXIT_SUCCESS;
if (!*argv) {
/* everything (modulo -t) */
mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
@@ -226,14 +211,14 @@ main(int argc, char *argv[])
if (stat(*argv, &stbuf) < 0) {
if ((mntpt = getmntpt(*argv)) == NULL) {
xo_warn("%s", *argv);
- rv = 1;
+ rv = EXIT_FAILURE;
continue;
}
} else if (S_ISCHR(stbuf.st_mode)) {
mntpt = getmntpt(*argv);
if (mntpt == NULL) {
xo_warnx("%s: not mounted", *argv);
- rv = 1;
+ rv = EXIT_FAILURE;
continue;
}
} else {
@@ -246,7 +231,7 @@ main(int argc, char *argv[])
*/
if (statfs(mntpt, &statfsbuf) < 0) {
xo_warn("%s", mntpt);
- rv = 1;
+ rv = EXIT_FAILURE;
continue;
}
@@ -257,7 +242,7 @@ main(int argc, char *argv[])
* we've been given (-l, -t, etc.).
*/
if (checkvfsselected(statfsbuf.f_fstypename) != 0) {
- rv = 1;
+ rv = EXIT_FAILURE;
continue;
}
@@ -286,7 +271,8 @@ main(int argc, char *argv[])
prtstat(&totalbuf, &maxwidths);
xo_close_container("storage-system-information");
- xo_finish();
+ if (xo_finish() < 0)
+ rv = EXIT_FAILURE;
exit(rv);
}
@@ -322,7 +308,7 @@ makevfslist(char *fslist, int *skip)
if (*nextcp == ',')
i++;
if ((av = malloc((size_t)(i + 2) * sizeof(char *))) == NULL) {
- warnx("malloc failed");
+ xo_warnx("malloc failed");
return (NULL);
}
nextcp = fslist;
diff --git a/bin/domainname/Makefile b/bin/domainname/Makefile
index 7275af2ac56f..7f68f14eccd6 100644
--- a/bin/domainname/Makefile
+++ b/bin/domainname/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE=yp
PROG= domainname
diff --git a/bin/domainname/Makefile.depend b/bin/domainname/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/bin/domainname/Makefile.depend
+++ b/bin/domainname/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/bin/domainname/domainname.1 b/bin/domainname/domainname.1
index 5729578f6336..bdadef416ce8 100644
--- a/bin/domainname/domainname.1
+++ b/bin/domainname/domainname.1
@@ -26,9 +26,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" From: @(#)hostname.1 8.1 (Berkeley) 5/31/93
-.\" $FreeBSD$
-.\"
.Dd April 22, 2013
.Dt DOMAINNAME 1
.Os
@@ -47,7 +44,7 @@ set the domain name by supplying an argument; this is usually done with the
.Va nisdomainname
variable in the
.Pa /etc/rc.conf
-file, normally run at boot
+file, normally runs at boot
time.
.Sh NOTES
The YP/NIS (formerly ``Yellow Pages'' but renamed for legal reasons)
diff --git a/bin/domainname/domainname.c b/bin/domainname/domainname.c
index cd14778221c3..dbf8f9b8d29b 100644
--- a/bin/domainname/domainname.c
+++ b/bin/domainname/domainname.c
@@ -29,20 +29,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static char const copyright[] =
-"@(#) Copyright (c) 1988, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char const sccsid[] = "From: @(#)hostname.c 8.1 (Berkeley) 5/31/93";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <err.h>
@@ -51,7 +37,7 @@ __FBSDID("$FreeBSD$");
#include <string.h>
#include <unistd.h>
-static void usage(void);
+static void usage(void) __dead2;
int
main(int argc, char *argv[])
diff --git a/bin/echo/Makefile b/bin/echo/Makefile
index bd4455395ac4..385e459f81cb 100644
--- a/bin/echo/Makefile
+++ b/bin/echo/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.1 (Berkeley) 5/31/93
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/bin/echo/Makefile.depend b/bin/echo/Makefile.depend
index 1adfc08a54d6..38d979787478 100644
--- a/bin/echo/Makefile.depend
+++ b/bin/echo/Makefile.depend
@@ -1,13 +1,12 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
lib/libcapsicum \
+ lib/libcasper/libcasper \
lib/libcompiler_rt \
diff --git a/bin/echo/echo.1 b/bin/echo/echo.1
index ea8957c15c5a..cb60bdcc88dd 100644
--- a/bin/echo/echo.1
+++ b/bin/echo/echo.1
@@ -29,9 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)echo.1 8.1 (Berkeley) 7/22/93
-.\" $FreeBSD$
-.\"
.Dd October 5, 2016
.Dt ECHO 1
.Os
@@ -92,6 +89,24 @@ Consult the
manual page.
.Sh EXIT STATUS
.Ex -std
+.Sh EXAMPLES
+Special treatment of options and backslashes:
+.Bd -literal -offset indent
+$ /bin/echo "-hello\\tworld"
+-hello\tworld
+.Ed
+.Pp
+Avoid new line character:
+.Bd -literal -offset indent
+$ /bin/echo -n hello;/bin/echo world
+helloworld
+.Ed
+.Pp
+Or to achieve the same result:
+.Bd -literal -offset indent
+$ /bin/echo "hello\\c";/bin/echo world
+helloworld
+.Ed
.Sh SEE ALSO
.Xr builtin 1 ,
.Xr csh 1 ,
@@ -108,3 +123,14 @@ The
.Nm
command appeared in
.At v2 .
+.Sh CAVEATS
+The
+.Nm
+command behaves differently with regards to the built-in
+.Nm
+shell command in a number of ways including escaped characters handling.
+It also differs in behavior between different systems hence complicating writing
+portable scripts.
+It is advised to use the
+.Xr printf 1
+command to avoid these shortcomings.
diff --git a/bin/echo/echo.c b/bin/echo/echo.c
index 46796ad1a27d..b8f7507c416e 100644
--- a/bin/echo/echo.c
+++ b/bin/echo/echo.c
@@ -29,20 +29,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static char const copyright[] =
-"@(#) Copyright (c) 1989, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "@(#)echo.c 8.1 (Berkeley) 5/31/93";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/uio.h>
diff --git a/bin/echo/tests/Makefile b/bin/echo/tests/Makefile
index 5957ecbc1fa1..1725e32671a3 100644
--- a/bin/echo/tests/Makefile
+++ b/bin/echo/tests/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
ATF_TESTS_SH+= echo_test
diff --git a/bin/echo/tests/Makefile.depend b/bin/echo/tests/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/bin/echo/tests/Makefile.depend
+++ b/bin/echo/tests/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/bin/echo/tests/echo_test.sh b/bin/echo/tests/echo_test.sh
index 5c5fc1f92d8b..ab18f11d685e 100644
--- a/bin/echo/tests/echo_test.sh
+++ b/bin/echo/tests/echo_test.sh
@@ -23,7 +23,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
atf_test_case n_output
diff --git a/bin/ed/Makefile b/bin/ed/Makefile
index 1d4b7685c025..776979f04e47 100644
--- a/bin/ed/Makefile
+++ b/bin/ed/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/bin/ed/Makefile.depend b/bin/ed/Makefile.depend
index cdd96948933d..6ef78fac5cbf 100644
--- a/bin/ed/Makefile.depend
+++ b/bin/ed/Makefile.depend
@@ -1,14 +1,11 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
- secure/lib/libcrypto \
.include <dirdeps.mk>
diff --git a/bin/ed/POSIX b/bin/ed/POSIX
index 53d6b5328ca5..1c8ac2b3b212 100644
--- a/bin/ed/POSIX
+++ b/bin/ed/POSIX
@@ -1,4 +1,3 @@
-$FreeBSD$
This version of ed(1) is not strictly POSIX compliant, as described in
the POSIX 1003.2 document. The following is a summary of the omissions,
diff --git a/bin/ed/README b/bin/ed/README
index da11f9b0f32a..8f5234179119 100644
--- a/bin/ed/README
+++ b/bin/ed/README
@@ -1,4 +1,3 @@
-$FreeBSD$
ed is an 8-bit-clean, POSIX-compliant line editor. It should work with
any regular expression package that conforms to the POSIX interface
diff --git a/bin/ed/buf.c b/bin/ed/buf.c
index 68594a8ebb2d..1f111e7d513d 100644
--- a/bin/ed/buf.c
+++ b/bin/ed/buf.c
@@ -27,8 +27,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/file.h>
#include <sys/stat.h>
diff --git a/bin/ed/ed.1 b/bin/ed/ed.1
index 9ced0f96a872..0db9f8d76bb8 100644
--- a/bin/ed/ed.1
+++ b/bin/ed/ed.1
@@ -1,4 +1,3 @@
-.\" $FreeBSD$
.Dd April 9, 2021
.Dt ED 1
.Os
@@ -721,7 +720,7 @@ with
By default, only the first match in each line is replaced.
If the
.Em g
-(global) suffix is given, then every match to be replaced.
+(global) suffix is given, then every match is to be replaced.
The
.Em n
suffix, where
@@ -833,7 +832,7 @@ Write the addressed lines to
.Ar file .
Any previous contents of
.Ar file
-is lost without warning.
+are lost without warning.
If there is no default filename, then the default filename is set to
.Ar file ,
otherwise it is unchanged.
diff --git a/bin/ed/ed.h b/bin/ed/ed.h
index 4dcf5eb36f37..788106e68b51 100644
--- a/bin/ed/ed.h
+++ b/bin/ed/ed.h
@@ -23,9 +23,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * @(#)ed.h,v 1.5 1994/02/01 00:34:39 alm Exp
- * $FreeBSD$
*/
#include <sys/param.h>
diff --git a/bin/ed/glbl.c b/bin/ed/glbl.c
index d3677989235e..d0a1d570ee16 100644
--- a/bin/ed/glbl.c
+++ b/bin/ed/glbl.c
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/wait.h>
diff --git a/bin/ed/io.c b/bin/ed/io.c
index 697e0a4c7ab5..fda3f5d55fd6 100644
--- a/bin/ed/io.c
+++ b/bin/ed/io.c
@@ -26,8 +26,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "ed.h"
/* read_file: read a named file/pipe into the buffer; return line count */
diff --git a/bin/ed/main.c b/bin/ed/main.c
index 82ab6d195038..57f1faba29c4 100644
--- a/bin/ed/main.c
+++ b/bin/ed/main.c
@@ -26,17 +26,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static const char copyright[] =
-"@(#) Copyright (c) 1993 Andrew Moore, Talke Studio. \n\
- All rights reserved.\n";
-#endif
-#endif /* not lint */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* CREDITS
*
@@ -1300,7 +1289,7 @@ has_trailing_escape(char *s, char *t)
}
-/* strip_escapes: return copy of escaped string of at most length PATH_MAX */
+/* strip_escapes: return a copy of escaped string of at most length PATH_MAX */
char *
strip_escapes(char *s)
{
diff --git a/bin/ed/re.c b/bin/ed/re.c
index 03a343657bbf..3dacb619a2bc 100644
--- a/bin/ed/re.c
+++ b/bin/ed/re.c
@@ -27,8 +27,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "ed.h"
const char *errmsg = "";
diff --git a/bin/ed/sub.c b/bin/ed/sub.c
index d12a5c9e1402..2bf70b8ac4bf 100644
--- a/bin/ed/sub.c
+++ b/bin/ed/sub.c
@@ -27,8 +27,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "ed.h"
diff --git a/bin/ed/test/Makefile b/bin/ed/test/Makefile
index aedfb698f131..4a339d030291 100644
--- a/bin/ed/test/Makefile
+++ b/bin/ed/test/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
SHELL= /bin/sh
ED= ${.OBJDIR}/ed
diff --git a/bin/ed/test/README b/bin/ed/test/README
index 74c4826a269d..6e0cee437b37 100644
--- a/bin/ed/test/README
+++ b/bin/ed/test/README
@@ -1,4 +1,3 @@
-# $FreeBSD$
The files in this directory with suffixes `.t', `.d', `.r' and `.err' are
used for testing ed. To run the tests, set the ED variable in the Makefile
diff --git a/bin/ed/test/ckscripts.sh b/bin/ed/test/ckscripts.sh
index deab47555f7a..ce02e18f53bc 100644
--- a/bin/ed/test/ckscripts.sh
+++ b/bin/ed/test/ckscripts.sh
@@ -3,7 +3,6 @@
# and compares their output against the .r files, which contain
# the correct output
#
-# $FreeBSD$
PATH="/bin:/usr/bin:/usr/local/bin/:."
ED=$1
diff --git a/bin/ed/test/mkscripts.sh b/bin/ed/test/mkscripts.sh
index 1b8b3ee53182..811a11d15be7 100644
--- a/bin/ed/test/mkscripts.sh
+++ b/bin/ed/test/mkscripts.sh
@@ -1,7 +1,6 @@
#!/bin/sh -
# This script generates ed test scripts (.ed) from .t files
#
-# $FreeBSD$
PATH="/bin:/usr/bin:/usr/local/bin/:."
ED=$1
diff --git a/bin/ed/undo.c b/bin/ed/undo.c
index 603e39f1ca53..d5f56833ec66 100644
--- a/bin/ed/undo.c
+++ b/bin/ed/undo.c
@@ -26,8 +26,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "ed.h"
diff --git a/bin/expr/Makefile b/bin/expr/Makefile
index dd74272e97b2..5386ec538684 100644
--- a/bin/expr/Makefile
+++ b/bin/expr/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/bin/expr/Makefile.depend b/bin/expr/Makefile.depend
index d084433f911c..c2fea3d32305 100644
--- a/bin/expr/Makefile.depend
+++ b/bin/expr/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/bin/expr/expr.1 b/bin/expr/expr.1
index 88b7171f164f..72830a55ec66 100644
--- a/bin/expr/expr.1
+++ b/bin/expr/expr.1
@@ -28,8 +28,6 @@
.\" (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$
-.\"
.Dd October 5, 2016
.Dt EXPR 1
.Os
diff --git a/bin/expr/expr.y b/bin/expr/expr.y
index 4f07275031a3..629ff8d7b9e8 100644
--- a/bin/expr/expr.y
+++ b/bin/expr/expr.y
@@ -4,8 +4,6 @@
* and placed in the public domain.
*
* Largely rewritten by J.T. Conklin (jtc@wimsey.com)
- *
- * $FreeBSD$
*/
#include <sys/types.h>
diff --git a/bin/expr/tests/Makefile b/bin/expr/tests/Makefile
index 21b0e993fedc..8f32a5ea560f 100644
--- a/bin/expr/tests/Makefile
+++ b/bin/expr/tests/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
NETBSD_ATF_TESTS_SH= expr_test
diff --git a/bin/expr/tests/Makefile.depend b/bin/expr/tests/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/bin/expr/tests/Makefile.depend
+++ b/bin/expr/tests/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/bin/freebsd-version/Makefile b/bin/freebsd-version/Makefile
index 7dcaf8a1eff0..6efe04a196c2 100644
--- a/bin/freebsd-version/Makefile
+++ b/bin/freebsd-version/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE=runtime
SCRIPTS = freebsd-version
diff --git a/bin/freebsd-version/Makefile.depend b/bin/freebsd-version/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/bin/freebsd-version/Makefile.depend
+++ b/bin/freebsd-version/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/bin/freebsd-version/freebsd-version.1 b/bin/freebsd-version/freebsd-version.1
index b580c580fcbc..82ea9c707d69 100644
--- a/bin/freebsd-version/freebsd-version.1
+++ b/bin/freebsd-version/freebsd-version.1
@@ -23,8 +23,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd October 1, 2021
.Dt FREEBSD-VERSION 1
.Os
@@ -113,7 +111,7 @@ To determine the version of the currently running userland:
/bin/freebsd-version -u
.Ed
.Pp
-To inspect a system being repaired using a live CD:
+To inspect a system being repaired using a live system:
.Bd -literal -offset indent
mount -rt ufs /dev/ada0p2 /mnt
env ROOT=/mnt /mnt/bin/freebsd-version -ku
diff --git a/bin/freebsd-version/freebsd-version.sh.in b/bin/freebsd-version/freebsd-version.sh.in
index be1be366f652..157294dfa582 100644
--- a/bin/freebsd-version/freebsd-version.sh.in
+++ b/bin/freebsd-version/freebsd-version.sh.in
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
set -e
diff --git a/bin/getfacl/Makefile b/bin/getfacl/Makefile
index 7b3f057fecca..803c0cb2f07a 100644
--- a/bin/getfacl/Makefile
+++ b/bin/getfacl/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE=runtime
PROG= getfacl
diff --git a/bin/getfacl/Makefile.depend b/bin/getfacl/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/bin/getfacl/Makefile.depend
+++ b/bin/getfacl/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/bin/getfacl/getfacl.1 b/bin/getfacl/getfacl.1
index c44974128be3..f8ff3df432a1 100644
--- a/bin/getfacl/getfacl.1
+++ b/bin/getfacl/getfacl.1
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.\" Developed by the TrustedBSD Project.
.\" Support for POSIX.1e access control lists.
.\"
diff --git a/bin/getfacl/getfacl.c b/bin/getfacl/getfacl.c
index ecdc73f74fbc..3ac9e61555de 100644
--- a/bin/getfacl/getfacl.c
+++ b/bin/getfacl/getfacl.c
@@ -30,10 +30,6 @@
* and send the results to stdout
*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/param.h>
#include <sys/acl.h>
@@ -157,6 +153,7 @@ print_acl(char *path, acl_type_t type, int hflag, int iflag, int nflag,
acl_text = acl_to_text_np(acl, 0, flags);
if (!acl_text) {
warn("%s: acl_to_text_np() failed", path);
+ (void)acl_free(acl);
return(-1);
}
diff --git a/bin/hostname/Makefile b/bin/hostname/Makefile
index 9b0ecd7e4c4a..14628b7850d4 100644
--- a/bin/hostname/Makefile
+++ b/bin/hostname/Makefile
@@ -1,7 +1,9 @@
-# @(#)Makefile 8.1 (Berkeley) 5/31/93
-# $FreeBSD$
+.include <src.opts.mk>
PACKAGE=runtime
PROG= hostname
+HAS_TESTS=
+SUBDIR.${MK_TESTS}= tests
+
.include <bsd.prog.mk>
diff --git a/bin/hostname/Makefile.depend b/bin/hostname/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/bin/hostname/Makefile.depend
+++ b/bin/hostname/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/bin/hostname/hostname.1 b/bin/hostname/hostname.1
index 45e5e14f4464..16f3dd468300 100644
--- a/bin/hostname/hostname.1
+++ b/bin/hostname/hostname.1
@@ -26,15 +26,12 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)hostname.1 8.2 (Berkeley) 4/28/95
-.\" $FreeBSD$
-.\"
.Dd October 5, 2020
.Dt HOSTNAME 1
.Os
.Sh NAME
.Nm hostname
-.Nd set or print name of current host system
+.Nd set or print the name of current host system
.Sh SYNOPSIS
.Nm
.Op Fl f
diff --git a/bin/hostname/hostname.c b/bin/hostname/hostname.c
index 3dbafa9d3566..c122656ec237 100644
--- a/bin/hostname/hostname.c
+++ b/bin/hostname/hostname.c
@@ -29,20 +29,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static char const copyright[] =
-"@(#) Copyright (c) 1988, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "@(#)hostname.c 8.1 (Berkeley) 5/31/93";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <err.h>
diff --git a/bin/hostname/tests/Makefile b/bin/hostname/tests/Makefile
new file mode 100644
index 000000000000..87295101392f
--- /dev/null
+++ b/bin/hostname/tests/Makefile
@@ -0,0 +1,6 @@
+PACKAGE= tests
+
+ATF_TESTS_SH= hostname_test
+BINDIR= ${TESTSDIR}
+
+.include <bsd.test.mk>
diff --git a/bin/hostname/tests/hostname_test.sh b/bin/hostname/tests/hostname_test.sh
new file mode 100644
index 000000000000..a4d4d54bb052
--- /dev/null
+++ b/bin/hostname/tests/hostname_test.sh
@@ -0,0 +1,93 @@
+#-
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# Copyright (c) 2024 Lin Lee <leelin2602@gmail.com>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+
+#
+# These tests need to run in a multibyte locale with non-localized
+# error messages.
+#
+export LC_CTYPE=C.UTF-8
+export LC_MESSAGES=C
+
+test_jail_name="test-hostname-jail"
+
+test_jail_conf='%%test_jail_name%% {
+ host.hostname = "test-hostname.example.org";
+ path = "/";
+ persist;
+}'
+
+init()
+{
+ if ! which -s jail; then
+ atf_skip "This test requires jail"
+ fi
+ echo "${test_jail_conf}" | \
+ sed -e "s/%%test_jail_name%%/${test_jail_name}/" > "./jail.conf"
+ jail -f "./jail.conf" -c ${test_jail_name}
+}
+
+recycle()
+{
+ jail -f "./jail.conf" -r ${test_jail_name}
+ rm "./jail.conf"
+}
+
+atf_test_case basic cleanup
+basic_head()
+{
+ atf_set require.user root
+ atf_set "descr" "basic test for getting hostname"
+}
+basic_body()
+{
+ init
+
+ result=$(jexec ${test_jail_name} "hostname")
+ atf_check_equal "test-hostname.example.org" "${result}"
+
+ result=$(jexec ${test_jail_name} "hostname" -s)
+ atf_check_equal "test-hostname" "${result}"
+
+ result=$(jexec ${test_jail_name} "hostname" -d)
+ atf_check_equal "example.org" "${result}"
+
+ jexec ${test_jail_name} "hostname" "test-bsd2"
+ result=$(jexec ${test_jail_name} "hostname")
+ atf_check_equal "test-bsd2" "${result}"
+}
+basic_cleanup()
+{
+ if ! which -s jail; then
+ atf_skip "This test requires jail"
+ fi
+ recycle
+}
+
+atf_init_test_cases()
+{
+ atf_add_test_case basic
+}
diff --git a/bin/kenv/Makefile b/bin/kenv/Makefile
index 9c1924ad4b32..5727aab93da2 100644
--- a/bin/kenv/Makefile
+++ b/bin/kenv/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE=runtime
PROG= kenv
diff --git a/bin/kenv/Makefile.depend b/bin/kenv/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/bin/kenv/Makefile.depend
+++ b/bin/kenv/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/bin/kenv/kenv.1 b/bin/kenv/kenv.1
index 980bec117515..9b6d0e0b33f2 100644
--- a/bin/kenv/kenv.1
+++ b/bin/kenv/kenv.1
@@ -22,8 +22,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd June 20, 2021
.Dt KENV 1
.Os
diff --git a/bin/kenv/kenv.c b/bin/kenv/kenv.c
index ecf30ee6b617..fe7ec4236bfb 100644
--- a/bin/kenv/kenv.c
+++ b/bin/kenv/kenv.c
@@ -23,9 +23,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/sysctl.h>
#include <err.h>
diff --git a/bin/kill/Makefile b/bin/kill/Makefile
index 4c9cddacd9a4..4023586d2aa7 100644
--- a/bin/kill/Makefile
+++ b/bin/kill/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.1 (Berkeley) 5/31/93
-# $FreeBSD$
PACKAGE=runtime
PROG= kill
diff --git a/bin/kill/Makefile.depend b/bin/kill/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/bin/kill/Makefile.depend
+++ b/bin/kill/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/bin/kill/kill.1 b/bin/kill/kill.1
index b42b0ee5f67c..ce9cb06382f8 100644
--- a/bin/kill/kill.1
+++ b/bin/kill/kill.1
@@ -29,9 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)kill.1 8.2 (Berkeley) 4/28/95
-.\" $FreeBSD$
-.\"
.Dd October 3, 2016
.Dt KILL 1
.Os
diff --git a/bin/kill/kill.c b/bin/kill/kill.c
index 201ab9aaf3e9..f3d323a1ff49 100644
--- a/bin/kill/kill.c
+++ b/bin/kill/kill.c
@@ -33,20 +33,6 @@
* as a builtin for /bin/sh (#define SHELL).
*/
-#if 0
-#ifndef lint
-static char const copyright[] =
-"@(#) Copyright (c) 1988, 1993, 1994\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "@(#)kill.c 8.4 (Berkeley) 4/28/95";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <ctype.h>
#include <err.h>
#include <errno.h>
@@ -63,7 +49,7 @@ __FBSDID("$FreeBSD$");
static void nosig(const char *);
static void printsignals(FILE *);
static int signame_to_signum(const char *);
-static void usage(void);
+static void usage(void) __dead2;
int
main(int argc, char *argv[])
diff --git a/bin/ln/Makefile b/bin/ln/Makefile
index dfabafa09a5c..141aa57aab5b 100644
--- a/bin/ln/Makefile
+++ b/bin/ln/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.2 (Berkeley) 5/31/93
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/bin/ln/Makefile.depend b/bin/ln/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/bin/ln/Makefile.depend
+++ b/bin/ln/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/bin/ln/ln.1 b/bin/ln/ln.1
index 9f8819e0f95a..43522e0c1cb8 100644
--- a/bin/ln/ln.1
+++ b/bin/ln/ln.1
@@ -29,9 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)ln.1 8.2 (Berkeley) 12/30/93
-.\" $FreeBSD$
-.\"
.Dd June 12, 2017
.Dt LN 1
.Os
diff --git a/bin/ln/ln.c b/bin/ln/ln.c
index e37dee361b19..6300658effa1 100644
--- a/bin/ln/ln.c
+++ b/bin/ln/ln.c
@@ -29,20 +29,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static char const copyright[] =
-"@(#) Copyright (c) 1987, 1993, 1994\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "@(#)ln.c 8.2 (Berkeley) 3/31/94";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/stat.h>
@@ -51,30 +37,32 @@ __FBSDID("$FreeBSD$");
#include <fcntl.h>
#include <libgen.h>
#include <limits.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-static int fflag; /* Unlink existing files. */
-static int Fflag; /* Remove empty directories also. */
-static int hflag; /* Check new name for symlink first. */
-static int iflag; /* Interactive mode. */
-static int Pflag; /* Create hard links to symlinks. */
-static int sflag; /* Symbolic, not hard, link. */
-static int vflag; /* Verbose output. */
-static int wflag; /* Warn if symlink target does not
+static bool fflag; /* Unlink existing files. */
+static bool Fflag; /* Remove empty directories also. */
+static bool hflag; /* Check new name for symlink first. */
+static bool iflag; /* Interactive mode. */
+static bool Pflag; /* Create hard links to symlinks. */
+static bool sflag; /* Symbolic, not hard, link. */
+static bool vflag; /* Verbose output. */
+static bool wflag; /* Warn if symlink target does not
* exist, and -f is not enabled. */
static char linkch;
-static int linkit(const char *, const char *, int);
-static void usage(void);
+static int linkit(const char *, const char *, bool);
+static void link_usage(void) __dead2;
+static void usage(void) __dead2;
int
main(int argc, char *argv[])
{
struct stat sb;
- char *p, *targetdir;
+ char *targetdir;
int ch, exitval;
/*
@@ -82,52 +70,55 @@ main(int argc, char *argv[])
* "link", for which the functionality provided is greatly
* simplified.
*/
- if ((p = strrchr(argv[0], '/')) == NULL)
- p = argv[0];
- else
- ++p;
- if (strcmp(p, "link") == 0) {
+ if (strcmp(getprogname(), "link") == 0) {
while (getopt(argc, argv, "") != -1)
- usage();
+ link_usage();
argc -= optind;
argv += optind;
if (argc != 2)
- usage();
- exit(linkit(argv[0], argv[1], 0));
+ link_usage();
+ if (lstat(argv[1], &sb) == 0)
+ errc(1, EEXIST, "%s", argv[1]);
+ /*
+ * We could simply call link(2) here, but linkit()
+ * performs additional checks and gives better
+ * diagnostics.
+ */
+ exit(linkit(argv[0], argv[1], false));
}
while ((ch = getopt(argc, argv, "FLPfhinsvw")) != -1)
switch (ch) {
case 'F':
- Fflag = 1;
+ Fflag = true;
break;
case 'L':
- Pflag = 0;
+ Pflag = false;
break;
case 'P':
- Pflag = 1;
+ Pflag = true;
break;
case 'f':
- fflag = 1;
- iflag = 0;
- wflag = 0;
+ fflag = true;
+ iflag = false;
+ wflag = false;
break;
case 'h':
case 'n':
- hflag = 1;
+ hflag = true;
break;
case 'i':
- iflag = 1;
- fflag = 0;
+ iflag = true;
+ fflag = false;
break;
case 's':
- sflag = 1;
+ sflag = true;
break;
case 'v':
- vflag = 1;
+ vflag = true;
break;
case 'w':
- wflag = 1;
+ wflag = true;
break;
case '?':
default:
@@ -138,21 +129,21 @@ main(int argc, char *argv[])
argc -= optind;
linkch = sflag ? '-' : '=';
- if (sflag == 0)
- Fflag = 0;
- if (Fflag == 1 && iflag == 0) {
- fflag = 1;
- wflag = 0; /* Implied when fflag != 0 */
+ if (!sflag)
+ Fflag = false;
+ if (Fflag && !iflag) {
+ fflag = true;
+ wflag = false; /* Implied when fflag is true */
}
- switch(argc) {
+ switch (argc) {
case 0:
usage();
/* NOTREACHED */
case 1: /* ln source */
- exit(linkit(argv[0], ".", 1));
+ exit(linkit(argv[0], ".", true));
case 2: /* ln source target */
- exit(linkit(argv[0], argv[1], 0));
+ exit(linkit(argv[0], argv[1], false));
default:
;
}
@@ -171,7 +162,7 @@ main(int argc, char *argv[])
if (!S_ISDIR(sb.st_mode))
usage();
for (exitval = 0; *argv != targetdir; ++argv)
- exitval |= linkit(*argv, targetdir, 1);
+ exitval |= linkit(*argv, targetdir, true);
exit(exitval);
}
@@ -222,14 +213,15 @@ samedirent(const char *path1, const char *path2)
}
static int
-linkit(const char *source, const char *target, int isdir)
+linkit(const char *source, const char *target, bool isdir)
{
- struct stat sb;
- const char *p;
- int ch, exists, first;
char path[PATH_MAX];
char wbuf[PATH_MAX];
char bbuf[PATH_MAX];
+ struct stat sb;
+ const char *p;
+ int ch, first;
+ bool exists;
if (!sflag) {
/* If source doesn't exist, quit now. */
@@ -292,7 +284,7 @@ linkit(const char *source, const char *target, int isdir)
/*
* If the file exists, first check it is not the same directory entry.
*/
- exists = !lstat(target, &sb);
+ exists = lstat(target, &sb) == 0;
if (exists) {
if (!sflag && samedirent(source, target)) {
warnx("%s and %s are the same directory entry",
@@ -350,11 +342,17 @@ linkit(const char *source, const char *target, int isdir)
}
static void
+link_usage(void)
+{
+ (void)fprintf(stderr, "usage: link source_file target_file\n");
+ exit(1);
+}
+
+static void
usage(void)
{
- (void)fprintf(stderr, "%s\n%s\n%s\n",
+ (void)fprintf(stderr, "%s\n%s\n",
"usage: ln [-s [-F] | -L | -P] [-f | -i] [-hnv] source_file [target_file]",
- " ln [-s [-F] | -L | -P] [-f | -i] [-hnv] source_file ... target_dir",
- " link source_file target_file");
+ " ln [-s [-F] | -L | -P] [-f | -i] [-hnv] source_file ... target_dir");
exit(1);
}
diff --git a/bin/ln/symlink.7 b/bin/ln/symlink.7
index b3488ea37ae1..1789cbe5bc80 100644
--- a/bin/ln/symlink.7
+++ b/bin/ln/symlink.7
@@ -26,9 +26,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)symlink.7 8.3 (Berkeley) 3/31/94
-.\" $FreeBSD$
-.\"
.Dd February 16, 2015
.Dt SYMLINK 7
.Os
diff --git a/bin/ln/tests/Makefile b/bin/ln/tests/Makefile
index 7ac99a947560..5da5c54adfad 100644
--- a/bin/ln/tests/Makefile
+++ b/bin/ln/tests/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
ATF_TESTS_SH+= ln_test
diff --git a/bin/ln/tests/Makefile.depend b/bin/ln/tests/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/bin/ln/tests/Makefile.depend
+++ b/bin/ln/tests/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/bin/ln/tests/ln_test.sh b/bin/ln/tests/ln_test.sh
index e1f5b47c262e..82bc556842d8 100644
--- a/bin/ln/tests/ln_test.sh
+++ b/bin/ln/tests/ln_test.sh
@@ -1,4 +1,6 @@
#
+# SPDX-License-Identifier: BSD-2-Clause
+#
# Copyright 2017 Shivansh Rai
# All rights reserved.
#
@@ -23,14 +25,15 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
-#
-set_umask()
+atf_check_same_file()
+{
+ atf_check_equal "$(stat -f %d,%i "$1")" "$(stat -f %d,%i "$2")"
+}
+
+atf_check_symlink_to()
{
- if ! umask 022; then
- atf_fail "setting umask failed"
- fi
+ atf_check -o inline:"$1\n" readlink "$2"
}
atf_test_case L_flag
@@ -40,18 +43,13 @@ L_flag_head()
"symbolic link, '-L' option creates a hard" \
"link to the target of the symbolic link"
}
-
L_flag_body()
{
- set_umask
atf_check touch A
atf_check ln -s A B
atf_check ln -L B C
- stat_A=$(stat -f %i A)
- stat_C=$(stat -f %i C)
- atf_check_equal "$stat_A" "$stat_C"
- atf_check -o inline:'Symbolic Link\n' stat -f %SHT B
- atf_check -o inline:'A\n' readlink B
+ atf_check_same_file A C
+ atf_check_symlink_to A B
}
atf_test_case P_flag
@@ -61,16 +59,12 @@ P_flag_head()
"symbolic link, '-P' option creates a hard " \
"link to the symbolic link itself"
}
-
P_flag_body()
{
- set_umask
atf_check touch A
atf_check ln -s A B
atf_check ln -P B C
- stat_B=$(stat -f %i B)
- stat_C=$(stat -f %i C)
- atf_check_equal "$stat_B" "$stat_C"
+ atf_check_same_file B C
}
atf_test_case f_flag
@@ -79,15 +73,11 @@ f_flag_head()
atf_set "descr" "Verify that if the target file already exists, " \
"'-f' option unlinks it so that link may occur"
}
-
f_flag_body()
{
- set_umask
atf_check touch A B
atf_check ln -f A B
- stat_A=$(stat -f %i A)
- stat_B=$(stat -f %i B)
- atf_check_equal "$stat_A" "$stat_B"
+ atf_check_same_file A B
}
atf_test_case target_exists_hard
@@ -96,13 +86,11 @@ target_exists_hard_head()
atf_set "descr" "Verify whether creating a hard link fails if the " \
"target file already exists"
}
-
target_exists_hard_body()
{
- set_umask
atf_check touch A B
atf_check -s exit:1 -e inline:'ln: B: File exists\n' \
- ln A B
+ ln A B
}
atf_test_case target_exists_symbolic
@@ -111,13 +99,11 @@ target_exists_symbolic_head()
atf_set "descr" "Verify whether creating a symbolic link fails if " \
"the target file already exists"
}
-
target_exists_symbolic_body()
{
- set_umask
atf_check touch A B
atf_check -s exit:1 -e inline:'ln: B: File exists\n' \
- ln -s A B
+ ln -s A B
}
atf_test_case shf_flag_dir
@@ -125,13 +111,12 @@ shf_flag_dir_head() {
atf_set "descr" "Verify that if the target directory is a symbolic " \
"link, '-shf' option prevents following the link"
}
-
shf_flag_dir_body()
{
atf_check mkdir -m 0777 A B
atf_check ln -s A C
atf_check ln -shf B C
- atf_check -o inline:'Symbolic Link\n' stat -f %SHT C
+ atf_check test -L C
atf_check -o inline:'B\n' readlink C
}
@@ -140,14 +125,12 @@ snf_flag_dir_head() {
atf_set "descr" "Verify that if the target directory is a symbolic " \
"link, '-snf' option prevents following the link"
}
-
snf_flag_dir_body()
{
atf_check mkdir -m 0777 A B
atf_check ln -s A C
atf_check ln -snf B C
- atf_check -o inline:'Symbolic Link\n' stat -f %SHT C
- atf_check -o inline:'B\n' readlink C
+ atf_check_symlink_to B C
}
atf_test_case sF_flag
@@ -157,13 +140,11 @@ sF_flag_head()
"and is a directory, then '-sF' option removes " \
"it so that the link may occur"
}
-
sF_flag_body()
{
atf_check mkdir A B
atf_check ln -sF A B
- atf_check -o inline:'Symbolic Link\n' stat -f %SHT B
- atf_check -o inline:'A\n' readlink B
+ atf_check_symlink_to A B
}
atf_test_case sf_flag
@@ -173,14 +154,27 @@ sf_flag_head()
"'-sf' option unlinks it and creates a symbolic link " \
"to the source file"
}
-
sf_flag_body()
{
- set_umask
atf_check touch A B
atf_check ln -sf A B
- atf_check -o inline:'Symbolic Link\n' stat -f %SHT B
- atf_check -o inline:'A\n' readlink B
+ atf_check_symlink_to A B
+}
+
+atf_test_case sfF_flag
+sfF_flag_head()
+{
+ atf_set "descr" "Verify that if the target file already exists " \
+ "and is a symlink, then '-sfF' option removes " \
+ "it so that the link may occur"
+}
+sfF_flag_body()
+{
+ atf_check mkdir A B C
+ atf_check ln -sF A C
+ atf_check_symlink_to A C
+ atf_check ln -sfF B C
+ atf_check_symlink_to B C
}
atf_test_case s_flag
@@ -188,14 +182,11 @@ s_flag_head()
{
atf_set "descr" "Verify that '-s' option creates a symbolic link"
}
-
s_flag_body()
{
- set_umask
atf_check touch A
atf_check ln -s A B
- atf_check -o inline:'Symbolic Link\n' stat -f %SHT B
- atf_check -o inline:'A\n' readlink B
+ atf_check_symlink_to A B
}
atf_test_case s_flag_broken
@@ -204,12 +195,10 @@ s_flag_broken_head()
atf_set "descr" "Verify that if the source file does not exists, '-s' " \
"option creates a broken symbolic link to the source file"
}
-
s_flag_broken_body()
{
atf_check ln -s A B
- atf_check -o inline:'Symbolic Link\n' stat -f %SHT B
- atf_check -o inline:'A\n' readlink B
+ atf_check_symlink_to A B
}
atf_test_case sw_flag
@@ -218,13 +207,66 @@ sw_flag_head()
atf_set "descr" "Verify that '-sw' option produces a warning if the " \
"source of a symbolic link does not currently exist"
}
-
sw_flag_body()
{
atf_check -s exit:0 -e inline:'ln: warning: A: No such file or directory\n' \
- ln -sw A B
- atf_check -o inline:'Symbolic Link\n' stat -f %SHT B
- atf_check -o inline:'A\n' readlink B
+ ln -sw A B
+ atf_check_symlink_to A B
+}
+
+atf_test_case link_argc
+link_argc_head() {
+ atf_set "descr" "Verify that link(1) requires exactly two arguments"
+}
+link_argc_body() {
+ atf_check -s exit:1 -e match:"usage: link" \
+ link foo
+ atf_check -s exit:1 -e match:"No such file" \
+ link foo bar
+ atf_check -s exit:1 -e match:"No such file" \
+ link -- foo bar
+ atf_check -s exit:1 -e match:"usage: link" \
+ link foo bar baz
+}
+
+atf_test_case link_basic
+link_basic_head() {
+ atf_set "descr" "Verify that link(1) creates a link"
+}
+link_basic_body() {
+ touch foo
+ atf_check link foo bar
+ atf_check_same_file foo bar
+ rm bar
+ ln -s foo bar
+ atf_check link bar baz
+ atf_check_same_file foo baz
+}
+
+atf_test_case link_eexist
+link_eexist_head() {
+ atf_set "descr" "Verify that link(1) fails if the target exists"
+}
+link_eexist_body() {
+ touch foo bar
+ atf_check -s exit:1 -e match:"bar.*exists" \
+ link foo bar
+ ln -s non-existent baz
+ atf_check -s exit:1 -e match:"baz.*exists" \
+ link foo baz
+}
+
+atf_test_case link_eisdir
+link_eisdir_head() {
+ atf_set "descr" "Verify that link(1) fails if the source is a directory"
+}
+link_eisdir_body() {
+ mkdir foo
+ atf_check -s exit:1 -e match:"foo.*directory" \
+ link foo bar
+ ln -s foo bar
+ atf_check -s exit:1 -e match:"bar.*directory" \
+ link bar baz
}
atf_init_test_cases()
@@ -238,7 +280,12 @@ atf_init_test_cases()
atf_add_test_case snf_flag_dir
atf_add_test_case sF_flag
atf_add_test_case sf_flag
+ atf_add_test_case sfF_flag
atf_add_test_case s_flag
atf_add_test_case s_flag_broken
atf_add_test_case sw_flag
+ atf_add_test_case link_argc
+ atf_add_test_case link_basic
+ atf_add_test_case link_eexist
+ atf_add_test_case link_eisdir
}
diff --git a/bin/ls/Makefile b/bin/ls/Makefile
index b4076d3a30a1..b9aa06775e7f 100644
--- a/bin/ls/Makefile
+++ b/bin/ls/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.1 (Berkeley) 6/2/93
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/bin/ls/Makefile.depend b/bin/ls/Makefile.depend
index bcfa88f57adf..307d2b3370ba 100644
--- a/bin/ls/Makefile.depend
+++ b/bin/ls/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
@@ -8,6 +7,7 @@ DIRDEPS = \
lib/libc \
lib/libcompiler_rt \
lib/libutil \
+ lib/ncurses/tinfo \
.include <dirdeps.mk>
diff --git a/bin/ls/Makefile.depend.options b/bin/ls/Makefile.depend.options
index 1c27178e9964..b8115550385a 100644
--- a/bin/ls/Makefile.depend.options
+++ b/bin/ls/Makefile.depend.options
@@ -1,4 +1,3 @@
-# $FreeBSD$
# This file is not autogenerated - take care!
DIRDEPS_OPTIONS= LS_COLORS
diff --git a/bin/ls/cmp.c b/bin/ls/cmp.c
index 13ba3ff47a99..4c60506f3456 100644
--- a/bin/ls/cmp.c
+++ b/bin/ls/cmp.c
@@ -32,15 +32,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static char sccsid[] = "@(#)cmp.c 8.1 (Berkeley) 5/31/93";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-
#include <sys/types.h>
#include <sys/stat.h>
@@ -65,6 +56,20 @@ revnamecmp(const FTSENT *a, const FTSENT *b)
}
int
+verscmp(const FTSENT *a, const FTSENT *b)
+{
+
+ return (strverscmp(a->fts_name, b->fts_name));
+}
+
+int
+revverscmp(const FTSENT *a, const FTSENT *b)
+{
+
+ return (strverscmp(b->fts_name, a->fts_name));
+}
+
+int
modcmp(const FTSENT *a, const FTSENT *b)
{
diff --git a/bin/ls/extern.h b/bin/ls/extern.h
index 247c2c4a1d5b..fd9a3f111a47 100644
--- a/bin/ls/extern.h
+++ b/bin/ls/extern.h
@@ -27,9 +27,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * from: @(#)extern.h 8.1 (Berkeley) 5/31/93
- * $FreeBSD$
*/
#include <stdbool.h>
@@ -42,6 +39,8 @@ int modcmp(const FTSENT *, const FTSENT *);
int revmodcmp(const FTSENT *, const FTSENT *);
int namecmp(const FTSENT *, const FTSENT *);
int revnamecmp(const FTSENT *, const FTSENT *);
+int verscmp(const FTSENT *, const FTSENT *);
+int revverscmp(const FTSENT *, const FTSENT *);
int statcmp(const FTSENT *, const FTSENT *);
int revstatcmp(const FTSENT *, const FTSENT *);
int sizecmp(const FTSENT *, const FTSENT *);
diff --git a/bin/ls/ls.1 b/bin/ls/ls.1
index ef412dd2927d..9d4c55b9b17d 100644
--- a/bin/ls/ls.1
+++ b/bin/ls/ls.1
@@ -29,10 +29,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)ls.1 8.7 (Berkeley) 7/29/94
-.\" $FreeBSD$
-.\"
-.Dd August 31, 2020
+.Dd February 21, 2024
.Dt LS 1
.Os
.Sh NAME
@@ -40,7 +37,7 @@
.Nd list directory contents
.Sh SYNOPSIS
.Nm
-.Op Fl ABCFGHILPRSTUWZabcdfghiklmnopqrstuwxy1\&,
+.Op Fl ABCFGHILPRSTUWZabcdfghiklmnopqrstuvwxy1\&,
.Op Fl -color Ns = Ns Ar when
.Op Fl D Ar format
.Op Ar
@@ -247,9 +244,11 @@ but only if
.Dv stdout
is a tty and either the
.Fl G
-flag is specified or the
+flag is specified or one of the environment variables
.Ev COLORTERM
-environment variable is set and not empty.
+or
+.Ev CLICOLOR
+is set and not empty.
.Pp
.Cm never
will disable color regardless of environment variables.
@@ -301,14 +300,9 @@ and
.Fl s
options.
.It Fl g
-This option has no effect.
-It is only available for compatibility with
-.Bx 4.3 ,
-where it was used to display the group name in the long
+Display the long
.Pq Fl l
-format output.
-This option is incompatible with
-.St -p1003.1-2008 .
+format output without the file owner's name or number.
.It Fl h
When used with the
.Fl l
@@ -399,6 +393,15 @@ of the file for sorting
.Pq Fl t
or printing
.Pq Fl l .
+.It Fl v
+Sort following a natural ordering, using
+.Xr strverscmp 3
+instead of
+.Xr strcoll 3
+as the comparison function.
+E.g., files lexicographically ordered
+"bloem1", "bloem10", and "bloem9" would instead be ordered
+"bloem1", "bloem9", and "bloem10", as one would perhaps expect.
.It Fl w
Force raw printing of non-printable characters.
This is the default
@@ -456,9 +459,9 @@ options all override each other; the last one specified determines
the file time used.
.Pp
The
-.Fl S
+.Fl S , t
and
-.Fl t
+.Fl v
options override each other; the last one specified determines
the sort order used.
.Pp
@@ -678,7 +681,7 @@ The default
.Dq Li cons25
console has the proper capabilities,
but to display the colors in an
-.Xr xterm 1 ,
+.Xr xterm 1 Pq Pa ports/x11/xterm ,
for example,
the
.Ev TERM
@@ -740,7 +743,7 @@ where
is the foreground color and
.Ar b
is the background color.
-When the background color is capitalized, the text will underlined.
+When the background color is capitalized, the text is underlined.
.Pp
The color designators are as follows:
.Pp
@@ -881,10 +884,12 @@ specification.
.Xr chmod 1 ,
.Xr getfacl 1 ,
.Xr sort 1 ,
-.Xr xterm 1 ,
+.Xr xterm 1 Pq Pa ports/x11/xterm ,
.Xr localeconv 3 ,
+.Xr strcoll 3 ,
.Xr strftime 3 ,
.Xr strmode 3 ,
+.Xr strverscmp 3 ,
.Xr termcap 5 ,
.Xr maclabel 7 ,
.Xr sticky 7 ,
@@ -902,7 +907,7 @@ utility conforms to
and
.St -p1003.1-2008 .
The options
-.Fl B , D , G , I , T , U , W , Z , b , h , w , y
+.Fl B , D , G , I , T , U , W , Z , b , h , v , w , y
and
.Fl ,
are non-standard extensions.
@@ -918,6 +923,11 @@ An
.Nm
command appeared in
.At v1 .
+.Pp
+The
+.Fl v
+option was added in
+.Fx 13.2 .
.Sh BUGS
To maintain backward compatibility, the relationships between the many
options are quite complex.
diff --git a/bin/ls/ls.c b/bin/ls/ls.c
index 8a30dd326b4e..b5e3578f27bb 100644
--- a/bin/ls/ls.c
+++ b/bin/ls/ls.c
@@ -32,20 +32,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1989, 1993, 1994\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#if 0
-#ifndef lint
-static char sccsid[] = "@(#)ls.c 8.5 (Berkeley) 4/2/94";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
@@ -136,6 +122,7 @@ static int f_numericonly; /* don't convert uid/gid to name */
int f_octal_escape; /* like f_octal but use C escapes if possible */
static int f_recursive; /* ls subdirectories also */
static int f_reversesort; /* reverse whatever sort is used */
+static int f_verssort; /* sort names using strverscmp(3) rather than strcoll(3) */
int f_samesort; /* sort time and name in same direction */
int f_sectime; /* print full time information */
static int f_singlecol; /* use single column output */
@@ -143,6 +130,7 @@ static int f_singlecol; /* use single column output */
static int f_sizesort;
int f_slash; /* similar to f_type, but only for dirs */
int f_sortacross; /* sort across rows, not down columns */
+ int f_sowner; /* disable showing owner's name */
int f_statustime; /* use time of last mode change */
static int f_stream; /* stream the output, separate with commas */
int f_thousands; /* show file sizes with thousands separators */
@@ -275,7 +263,7 @@ main(int argc, char *argv[])
colorflag = COLORFLAG_AUTO;
#endif
while ((ch = getopt_long(argc, argv,
- "+1ABCD:FGHILPRSTUWXZabcdfghiklmnopqrstuwxy,", long_opts,
+ "+1ABCD:FGHILPRSTUWXZabcdfghiklmnopqrstuvwxy,", long_opts,
NULL)) != -1) {
switch (ch) {
/*
@@ -325,14 +313,21 @@ main(int argc, char *argv[])
case 'A':
f_listdot = 1;
break;
- /* The -t and -S options override each other. */
+ /* The -S, -t and -v options override each other. */
case 'S':
f_sizesort = 1;
f_timesort = 0;
+ f_verssort = 0;
break;
case 't':
f_timesort = 1;
f_sizesort = 0;
+ f_verssort = 0;
+ break;
+ case 'v':
+ f_verssort = 1;
+ f_sizesort = 0;
+ f_timesort = 0;
break;
/* Other flags. Please keep alphabetic. */
case ',':
@@ -401,7 +396,11 @@ main(int argc, char *argv[])
f_listdir = 1;
f_recursive = 0;
break;
- case 'g': /* Compatibility with 4.3BSD. */
+ case 'g':
+ f_longform = 1;
+ f_singlecol = 0;
+ f_stream = 0;
+ f_sowner = 1;
break;
case 'h':
f_humanval = 1;
@@ -420,6 +419,9 @@ main(int argc, char *argv[])
break;
case 'n':
f_numericonly = 1;
+ f_longform = 1;
+ f_singlecol = 0;
+ f_stream = 0;
break;
case 'o':
f_flags = 1;
@@ -564,12 +566,15 @@ main(int argc, char *argv[])
blocksize /= 512;
}
}
+
/* Select a sort function. */
if (f_reversesort) {
- if (!f_timesort && !f_sizesort)
- sortfcn = revnamecmp;
- else if (f_sizesort)
+ if (f_sizesort)
sortfcn = revsizecmp;
+ else if (f_verssort)
+ sortfcn = revverscmp;
+ else if (!f_timesort)
+ sortfcn = revnamecmp;
else if (f_accesstime)
sortfcn = revacccmp;
else if (f_birthtime)
@@ -579,10 +584,12 @@ main(int argc, char *argv[])
else /* Use modification time. */
sortfcn = revmodcmp;
} else {
- if (!f_timesort && !f_sizesort)
- sortfcn = namecmp;
- else if (f_sizesort)
+ if (f_sizesort)
sortfcn = sizecmp;
+ else if (f_verssort)
+ sortfcn = verscmp;
+ else if (!f_timesort)
+ sortfcn = namecmp;
else if (f_accesstime)
sortfcn = acccmp;
else if (f_birthtime)
diff --git a/bin/ls/ls.h b/bin/ls/ls.h
index 410246ec9903..1c3c1cb786f6 100644
--- a/bin/ls/ls.h
+++ b/bin/ls/ls.h
@@ -30,9 +30,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * from: @(#)ls.h 8.1 (Berkeley) 5/31/93
- * $FreeBSD$
*/
#define NO_PRINT 1
@@ -56,6 +53,7 @@ extern int f_sectime; /* print the real time for all files */
extern int f_size; /* list size in short listing */
extern int f_slash; /* append a '/' if the file is a directory */
extern int f_sortacross; /* sort across rows, not down columns */
+extern int f_sowner; /* disable showing the owner's name */
extern int f_statustime; /* use time of last mode change */
extern int f_thousands; /* show file sizes with thousands separators */
extern char *f_timeformat; /* user-specified time format */
diff --git a/bin/ls/print.c b/bin/ls/print.c
index bbe5c6f8a6f6..979ad0ffc43e 100644
--- a/bin/ls/print.c
+++ b/bin/ls/print.c
@@ -32,14 +32,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static char sccsid[] = "@(#)print.c 8.4 (Berkeley) 4/17/94";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/acl.h>
@@ -234,9 +226,11 @@ printlong(const DISPLAY *dp)
strmode(sp->st_mode, buf);
aclmode(buf, p);
np = p->fts_pointer;
- (void)printf("%s %*ju %-*s %-*s ", buf, dp->s_nlink,
- (uintmax_t)sp->st_nlink, dp->s_user, np->user, dp->s_group,
- np->group);
+ (void)printf("%s %*ju ", buf, dp->s_nlink,
+ (uintmax_t)sp->st_nlink);
+ if (!f_sowner)
+ (void)printf("%-*s ", dp->s_user, np->user);
+ (void)printf("%-*s ", dp->s_group, np->group);
if (f_flags)
(void)printf("%-*s ", dp->s_flags, np->flags);
if (f_label)
@@ -432,18 +426,17 @@ printdev(size_t width, dev_t dev)
(void)printf("%#*jx ", (u_int)width, (uintmax_t)dev);
}
-static size_t
+static void
ls_strftime(char *str, size_t len, const char *fmt, const struct tm *tm)
{
char *posb, nfmt[BUFSIZ];
const char *format = fmt;
- size_t ret;
if ((posb = strstr(fmt, "%b")) != NULL) {
if (month_max_size == 0) {
compute_abbreviated_month_size();
}
- if (month_max_size > 0) {
+ if (month_max_size > 0 && tm != NULL) {
snprintf(nfmt, sizeof(nfmt), "%.*s%s%*s%s",
(int)(posb - fmt), fmt,
get_abmon(tm->tm_mon),
@@ -453,8 +446,10 @@ ls_strftime(char *str, size_t len, const char *fmt, const struct tm *tm)
format = nfmt;
}
}
- ret = strftime(str, len, format, tm);
- return (ret);
+ if (tm != NULL)
+ strftime(str, len, format, tm);
+ else
+ strlcpy(str, "bad date val", len);
}
static void
diff --git a/bin/ls/tests/Makefile b/bin/ls/tests/Makefile
index 89a2e8cf1dca..f7121982a7b8 100644
--- a/bin/ls/tests/Makefile
+++ b/bin/ls/tests/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
ATF_TESTS_SH+= ls_tests
# This seems like overkill, but the idea in mind is that all of the testcases
diff --git a/bin/ls/tests/Makefile.depend b/bin/ls/tests/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/bin/ls/tests/Makefile.depend
+++ b/bin/ls/tests/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/bin/ls/tests/ls_tests.sh b/bin/ls/tests/ls_tests.sh
index 14f7895e699c..c82b4e8c8851 100755
--- a/bin/ls/tests/ls_tests.sh
+++ b/bin/ls/tests/ls_tests.sh
@@ -24,7 +24,6 @@
# (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$
#
create_test_dir()
@@ -525,18 +524,19 @@ f_flag_body()
atf_test_case g_flag
g_flag_head()
{
- atf_set "descr" "Verify that -g does nothing (compatibility flag)"
+ atf_set "descr" "Verify that -g implies -l but omits the owner name field"
}
g_flag_body()
{
- create_test_inputs2
- for file in $files; do
- atf_check -e empty -o match:"$(ls -a $file)" -s exit:0 \
- ls -ag $file
- atf_check -e empty -o match:"$(ls -la $file)" -s exit:0 \
- ls -alg $file
- done
+ atf_check -e empty -o empty -s exit:0 touch a.file
+
+ mtime_in_secs=$(stat -f "%m" -t "%s" a.file)
+ mtime=$(date -j -f "%s" $mtime_in_secs +"%b[[:space:]]+%e[[:space:]]+%H:%M")
+
+ expected_output=$(stat -f "%Sp[[:space:]]+%l[[:space:]]+%Sg[[:space:]]+%z[[:space:]]+$mtime[[:space:]]+a\\.file" a.file)
+
+ atf_check -e empty -o match:"$expected_output" -s exit:0 ls -g a.file
}
atf_test_case h_flag
@@ -689,7 +689,7 @@ n_flag_body()
atf_check -e empty \
-o match:'\-rw\-r\-\-r\-\-[[:space:]]+1[[:space:]]+'"$nobody_uid[[:space:]]+$daemon_gid"'[[:space:]]+.+a\.file' \
- ls -ln a.file
+ ls -n a.file
}
@@ -846,6 +846,20 @@ u_flag_body()
atf_check -e empty -o match:'a\.file.*b\.file' -s exit:0 ls -Cu
}
+atf_test_case v_flag
+v_flag_head()
+{
+ atf_set "descr" "Verify that the output from ls -v sorts based on strverscmp(3)"
+}
+
+v_flag_body()
+{
+ create_test_dir
+
+ atf_check -e empty -o empty -s exit:0 touch 000 00 01 010 09 0 1 9 10
+ atf_check -e empty -o match:"000.00.01.010.09.0.1.9.10" -s exit:0 sh -c 'ls -Cv'
+}
+
atf_test_case x_flag
x_flag_head()
{
@@ -960,6 +974,7 @@ atf_init_test_cases()
atf_add_test_case s_flag
atf_add_test_case t_flag
atf_add_test_case u_flag
+ atf_add_test_case v_flag
atf_add_test_case x_flag
atf_add_test_case y_flag
atf_add_test_case 1_flag
diff --git a/bin/ls/util.c b/bin/ls/util.c
index 44012de58bba..40610faa5fae 100644
--- a/bin/ls/util.c
+++ b/bin/ls/util.c
@@ -32,14 +32,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static char sccsid[] = "@(#)util.c 8.3 (Berkeley) 4/2/94";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/stat.h>
@@ -227,9 +219,9 @@ usage(void)
{
(void)fprintf(stderr,
#ifdef COLORLS
- "usage: ls [-ABCFGHILPRSTUWZabcdfghiklmnopqrstuwxy1,] [--color=when] [-D format]"
+ "usage: ls [-ABCFGHILPRSTUWZabcdfghiklmnopqrstuvwxy1,] [--color=when] [-D format]"
#else
- "usage: ls [-ABCFHILPRSTUWZabcdfghiklmnopqrstuwxy1,] [-D format]"
+ "usage: ls [-ABCFHILPRSTUWZabcdfghiklmnopqrstuvwxy1,] [-D format]"
#endif
" [file ...]\n");
exit(1);
diff --git a/bin/mkdir/Makefile b/bin/mkdir/Makefile
index 79ed25fdc204..8bf3cfb0e081 100644
--- a/bin/mkdir/Makefile
+++ b/bin/mkdir/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.1 (Berkeley) 5/31/93
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/bin/mkdir/Makefile.depend b/bin/mkdir/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/bin/mkdir/Makefile.depend
+++ b/bin/mkdir/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/bin/mkdir/mkdir.1 b/bin/mkdir/mkdir.1
index 0b6c2cbfff97..599ac7e4a7ff 100644
--- a/bin/mkdir/mkdir.1
+++ b/bin/mkdir/mkdir.1
@@ -29,9 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)mkdir.1 8.2 (Berkeley) 1/25/94
-.\" $FreeBSD$
-.\"
.Dd March 15, 2013
.Dt MKDIR 1
.Os
diff --git a/bin/mkdir/mkdir.c b/bin/mkdir/mkdir.c
index cc699d3893dc..e67c99ce2a3a 100644
--- a/bin/mkdir/mkdir.c
+++ b/bin/mkdir/mkdir.c
@@ -29,20 +29,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static char const copyright[] =
-"@(#) Copyright (c) 1983, 1992, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "@(#)mkdir.c 8.2 (Berkeley) 1/25/94";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/stat.h>
diff --git a/bin/mkdir/tests/Makefile b/bin/mkdir/tests/Makefile
index 3b28a958bea0..64ac0d723529 100644
--- a/bin/mkdir/tests/Makefile
+++ b/bin/mkdir/tests/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
ATF_TESTS_SH+= mkdir_test
diff --git a/bin/mkdir/tests/Makefile.depend b/bin/mkdir/tests/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/bin/mkdir/tests/Makefile.depend
+++ b/bin/mkdir/tests/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/bin/mkdir/tests/mkdir_test.sh b/bin/mkdir/tests/mkdir_test.sh
index 985a486d2075..a113baaa5312 100644
--- a/bin/mkdir/tests/mkdir_test.sh
+++ b/bin/mkdir/tests/mkdir_test.sh
@@ -23,7 +23,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
usage_output='usage: mkdir'
diff --git a/bin/mv/Makefile b/bin/mv/Makefile
index e16243f06c3b..2413f572874f 100644
--- a/bin/mv/Makefile
+++ b/bin/mv/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.2 (Berkeley) 4/2/94
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/bin/mv/Makefile.depend b/bin/mv/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/bin/mv/Makefile.depend
+++ b/bin/mv/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/bin/mv/mv.1 b/bin/mv/mv.1
index 24cc61ba2b52..138ce99f586f 100644
--- a/bin/mv/mv.1
+++ b/bin/mv/mv.1
@@ -29,9 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)mv.1 8.1 (Berkeley) 5/31/93
-.\" $FreeBSD$
-.\"
.Dd March 15, 2013
.Dt MV 1
.Os
diff --git a/bin/mv/mv.c b/bin/mv/mv.c
index 01d88ff625b7..8aea4bbf567c 100644
--- a/bin/mv/mv.c
+++ b/bin/mv/mv.c
@@ -32,20 +32,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static char const copyright[] =
-"@(#) Copyright (c) 1989, 1993, 1994\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "@(#)mv.c 8.2 (Berkeley) 4/2/94";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/acl.h>
#include <sys/param.h>
@@ -186,7 +172,7 @@ do_move(const char *from, const char *to)
*/
if (!fflg && !access(to, F_OK)) {
- /* prompt only if source exist */
+ /* prompt only if source exists */
if (lstat(from, &sb) == -1) {
warn("%s", from);
return (1);
@@ -333,6 +319,12 @@ err: if (unlink(to))
*/
preserve_fd_acls(from_fd, to_fd, from, to);
(void)close(from_fd);
+
+ ts[0] = sbp->st_atim;
+ ts[1] = sbp->st_mtim;
+ if (futimens(to_fd, ts))
+ warn("%s: set times", to);
+
/*
* XXX
* NFS doesn't support chflags; ignore errors unless there's reason
@@ -353,11 +345,6 @@ err: if (unlink(to))
} else
warn("%s: cannot stat", to);
- ts[0] = sbp->st_atim;
- ts[1] = sbp->st_mtim;
- if (futimens(to_fd, ts))
- warn("%s: set times", to);
-
if (close(to_fd)) {
warn("%s", to);
return (1);
diff --git a/bin/mv/tests/Makefile b/bin/mv/tests/Makefile
index 229d96e5766a..1785fa6c5149 100644
--- a/bin/mv/tests/Makefile
+++ b/bin/mv/tests/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <bsd.own.mk>
diff --git a/bin/mv/tests/Makefile.depend b/bin/mv/tests/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/bin/mv/tests/Makefile.depend
+++ b/bin/mv/tests/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/bin/mv/tests/legacy_test.sh b/bin/mv/tests/legacy_test.sh
index d0a5e83440c6..8af025a0d011 100644
--- a/bin/mv/tests/legacy_test.sh
+++ b/bin/mv/tests/legacy_test.sh
@@ -1,5 +1,4 @@
#!/bin/sh
-# $FreeBSD$
# A directory in a device different from that where the tests are run
TMPDIR=/tmp/regress.$$
diff --git a/bin/nproc/Makefile b/bin/nproc/Makefile
new file mode 100644
index 000000000000..2a57083b9d40
--- /dev/null
+++ b/bin/nproc/Makefile
@@ -0,0 +1,4 @@
+PACKAGE=runtime
+PROG= nproc
+
+.include <bsd.prog.mk>
diff --git a/bin/nproc/nproc.1 b/bin/nproc/nproc.1
new file mode 100644
index 000000000000..bf4a24e4ae53
--- /dev/null
+++ b/bin/nproc/nproc.1
@@ -0,0 +1,60 @@
+.\"-
+.\" * Copyright (c) 2023 Piotr Paweł Stefaniak
+.\"
+.\" * SPDX-License-Identifier: BSD-2-Clause
+.\"
+.Dd June 2, 2023
+.Dt NPROC 1
+.Os
+.Sh NAME
+.Nm nproc
+.Nd print the number of processors
+.Sh SYNOPSIS
+.Nm
+.Op Fl -all
+.Op Fl -ignore Ns = Ns Ar count
+.Nm Fl -help
+.Nm Fl -version
+.Sh DESCRIPTION
+The
+.Nm
+utility is used to print the number of processors limited to the
+.Xr cpuset 2
+of the current process, unless the
+.Fl -all
+flag is specified.
+.Pp
+The available flags are:
+.Bl -tag -width Ds
+.It Fl -all
+Count all processors currently online.
+.It Fl -ignore Ns = Ns Ar count
+The result is decreased by
+.Ar count ,
+but never below 1.
+.It Fl -version
+Print the current program version and exit.
+Do not use this option.
+.It Fl -help
+Print usage information and exit.
+.El
+.Sh COMPATIBILITY
+This program is intended to be compatible with nproc as found in GNU coreutils.
+.Sh BUGS
+If HyperThreading is enabled in BIOS and disabled in the kernel, the
+.Fl -all
+option on Linux will still report all possible CPU threads.
+On FreeBSD only active threads will be reported.
+.Sh SEE ALSO
+.Xr cpuset 1
+.Sh HISTORY
+The
+.Nm
+utility first appeared in
+.Fx 13.2 .
+.Sh AUTHORS
+.An -nosplit
+.An Mateusz Guzik Aq Mt mjg@FreeBSD.org
+wrote the program and
+.An Piotr Paweł Stefaniak Aq Mt pstef@FreeBSD.org
+wrote this page.
diff --git a/bin/nproc/nproc.c b/bin/nproc/nproc.c
new file mode 100644
index 000000000000..d8affe11b796
--- /dev/null
+++ b/bin/nproc/nproc.c
@@ -0,0 +1,132 @@
+/*-
+ * Copyright (c) 2023 Mateusz Guzik
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+/*
+ * This program is intended to be compatible with nproc as found in GNU
+ * coreutils.
+ *
+ * In order to maintain that, do not add any features here if they are not
+ * present in said program. If you are looking for anything more advanced you
+ * probably should patch cpuset(1) instead.
+ */
+
+#include <sys/param.h>
+#include <sys/cpuset.h>
+
+#include <err.h>
+#include <errno.h>
+#include <getopt.h>
+#include <limits.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sysexits.h>
+#include <unistd.h>
+
+#define OPT_ALL (CHAR_MAX + 1)
+#define OPT_IGNORE (CHAR_MAX + 2)
+#define OPT_VERSION (CHAR_MAX + 3)
+#define OPT_HELP (CHAR_MAX + 4)
+
+static struct option long_opts[] = {
+ { "all", no_argument, NULL, OPT_ALL },
+ { "ignore", required_argument, NULL, OPT_IGNORE },
+ { "version", no_argument, NULL, OPT_VERSION },
+ { "help", no_argument, NULL, OPT_HELP },
+ { NULL, 0, NULL, 0 }
+};
+
+static void
+help(void)
+{
+ fprintf(stderr,
+ "usage: nproc [--all] [--ignore=count]\n");
+ fprintf(stderr,
+ " nproc --help\n");
+ fprintf(stderr,
+ " nproc --version\n");
+}
+
+static void
+usage(void)
+{
+ help();
+ exit(EX_USAGE);
+}
+
+/*
+ * GNU variant ships with the --version switch.
+ *
+ * While we don't have anything to put there, print something which is
+ * whitespace-compatible with the original. Version number was taken
+ * from coreutils this code is in sync with.
+ */
+static void
+version(void)
+{
+ printf("nproc (neither_GNU nor_coreutils) 8.32\n");
+ exit(EXIT_SUCCESS);
+}
+
+int
+main(int argc, char *argv[])
+{
+ const char *errstr;
+ cpuset_t mask;
+ int ch, cpus, ignore;
+ bool all_flag;
+
+ ignore = 0;
+ all_flag = false;
+
+ while ((ch = getopt_long(argc, argv, "", long_opts, NULL)) != -1) {
+ switch (ch) {
+ case OPT_ALL:
+ all_flag = true;
+ break;
+ case OPT_IGNORE:
+ ignore = strtonum(optarg, 0, INT_MAX, &errstr);
+ if (errstr)
+ errx(1, "bad ignore count: %s", errstr);
+ break;
+ case OPT_VERSION:
+ version();
+ __unreachable();
+ case OPT_HELP:
+ help();
+ exit(EXIT_SUCCESS);
+ default:
+ usage();
+ }
+ }
+
+ argc -= optind;
+ argv += optind;
+
+ if (argc != 0)
+ usage();
+
+ if (all_flag) {
+ cpus = sysconf(_SC_NPROCESSORS_CONF);
+ if (cpus == -1)
+ err(1, "sysconf");
+ } else {
+ CPU_ZERO(&mask);
+ if (cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_TID, -1,
+ sizeof(mask), &mask) != 0)
+ err(1, "cpuset_getaffinity");
+ cpus = CPU_COUNT(&mask);
+ }
+
+ if (ignore >= cpus)
+ cpus = 1;
+ else
+ cpus -= ignore;
+
+ printf("%u\n", cpus);
+
+ exit(EXIT_SUCCESS);
+}
diff --git a/bin/pax/Makefile b/bin/pax/Makefile
index d0772ee49766..6b40986ce3a9 100644
--- a/bin/pax/Makefile
+++ b/bin/pax/Makefile
@@ -1,32 +1,6 @@
-# @(#)Makefile 8.1 (Berkeley) 5/31/93
-# $FreeBSD$
.include <src.opts.mk>
-# To install on versions prior to BSD 4.4 the following may have to be
-# defined with CFLAGS +=
-#
-# -DNET2_STAT Use NET2 or older stat structure. The version of the
-# stat structure is easily determined by looking at the
-# basic type of an off_t (often defined in the file:
-# /usr/include/sys/types.h). If off_t is a long (and is
-# NOT A quad) then you must define NET2_STAT.
-# This define is important, as if you do have a quad_t
-# off_t and define NET2_STAT, pax will compile but will
-# NOT RUN PROPERLY.
-#
-# -DNET2_FTS Use the older NET2 fts. To identify the version,
-# examine the file: /usr/include/fts.h. If FTS_COMFOLLOW
-# is not defined then you must define NET2_FTS.
-# Pax may not compile if this not (un)defined properly.
-#
-# -DNET2_REGEX Use the older regexp.h not regex.h. The regex version
-# is determined by looking at the value returned by
-# regexec() (man 3 regexec). If regexec return a 1 for
-# success (and NOT a 0 for success) you have the older
-# regex routines and must define NET2_REGEX.
-# Pax may not compile if this not (un)defined properly.
-
PACKAGE=runtime
PROG= pax
SRCS= ar_io.c ar_subs.c buf_subs.c cache.c cpio.c file_subs.c ftree.c \
diff --git a/bin/pax/Makefile.depend b/bin/pax/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/bin/pax/Makefile.depend
+++ b/bin/pax/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/bin/pax/ar_io.c b/bin/pax/ar_io.c
index 6271944703ff..c595870aaa5e 100644
--- a/bin/pax/ar_io.c
+++ b/bin/pax/ar_io.c
@@ -33,14 +33,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)ar_io.c 8.2 (Berkeley) 4/18/94";
-#endif
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/mtio.h>
@@ -206,7 +198,7 @@ ar_open(const char *name)
* set default blksz on read. APPNDs writes rdblksz on the last volume
* On all new archive volumes, we shift to wrblksz (if the user
* specified one, otherwise we will continue to use rdblksz). We
- * must to set blocksize based on what kind of device the archive is
+ * must set blocksize based on what kind of device the archive is
* stored.
*/
switch(artyp) {
@@ -286,7 +278,7 @@ ar_open(const char *name)
break;
default:
/*
- * should never happen, worse case, slow...
+ * should never happen, worst case, slow...
*/
blksz = rdblksz = BLKMULT;
break;
@@ -386,13 +378,8 @@ ar_close(void)
* could have written anything yet.
*/
if (frmt == NULL) {
-# ifdef NET2_STAT
- (void)fprintf(listf, "%s: unknown format, %lu bytes skipped.\n",
- argv0, rdcnt);
-# else
(void)fprintf(listf, "%s: unknown format, %ju bytes skipped.\n",
argv0, (uintmax_t)rdcnt);
-# endif
(void)fflush(listf);
flcnt = 0;
return;
@@ -403,14 +390,9 @@ ar_close(void)
(unsigned long long)((rdcnt ? rdcnt : wrcnt) / 5120));
else if (strcmp(NM_TAR, argv0) != 0)
(void)fprintf(listf,
-# ifdef NET2_STAT
- "%s: %s vol %d, %lu files, %lu bytes read, %lu bytes written.\n",
- argv0, frmt->name, arvol-1, flcnt, rdcnt, wrcnt);
-# else
"%s: %s vol %d, %ju files, %ju bytes read, %ju bytes written.\n",
argv0, frmt->name, arvol-1, (uintmax_t)flcnt,
(uintmax_t)rdcnt, (uintmax_t)wrcnt);
-# endif
(void)fflush(listf);
flcnt = 0;
}
@@ -543,10 +525,10 @@ ar_read(char *buf, int cnt)
io_ok = 1;
if (res != rdblksz) {
/*
- * Record size changed. If this is happens on
+ * Record size changed. If this happens on
* any record after the first, we probably have
* a tape drive which has a fixed record size
- * we are getting multiple records in a single
+ * (we are getting multiple records in a single
* read). Watch out for record blocking that
* violates pax spec (must be a multiple of
* BLKMULT).
@@ -726,7 +708,7 @@ ar_rdsync(void)
struct mtop mb;
/*
- * Fail resync attempts at user request (done) or this is going to be
+ * Fail resync attempts at user request (done) or if this is going to be
* an update/append to an existing archive. If last i/o hit media end,
* we need to go to the next volume not try a resync.
*/
@@ -932,12 +914,12 @@ ar_rev(off_t sksz)
break;
case ISTAPE:
/*
- * Calculate and move the proper number of PHYSICAL tape
+ * Calculate and move the proper number of PHYSICAL tape
* blocks. If the sksz is not an even multiple of the physical
* tape size, we cannot do the move (this should never happen).
- * (We also cannot handler trailers spread over two vols).
+ * (We also cannot handle trailers spread over two vols).
* get_phys() also makes sure we are in front of the filemark.
- */
+ */
if ((phyblk = get_phys()) <= 0) {
lstrval = -1;
return(-1);
diff --git a/bin/pax/ar_subs.c b/bin/pax/ar_subs.c
index b18dc3710942..8f8a5b842626 100644
--- a/bin/pax/ar_subs.c
+++ b/bin/pax/ar_subs.c
@@ -33,14 +33,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)ar_subs.c 8.2 (Berkeley) 4/18/94";
-#endif
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/time.h>
#include <sys/stat.h>
@@ -202,7 +194,7 @@ extract(void)
/*
* with -u or -D only extract when the archive member is newer
- * than the file with the same name in the file system (nos
+ * than the file with the same name in the file system (no
* test of being the same type is required).
* NOTE: this test is done BEFORE name modifications as
* specified by pax. this operation can be confusing to the
@@ -387,7 +379,8 @@ wr_archive(ARCHD *arcn, int is_app)
return;
/*
- * if this not append, and there are no files, we do no write a trailer
+ * if this is not append, and there are no files, we do not write a
+ * trailer
*/
wr_one = is_app;
diff --git a/bin/pax/buf_subs.c b/bin/pax/buf_subs.c
index 6d50a280f29c..7f9b31881d56 100644
--- a/bin/pax/buf_subs.c
+++ b/bin/pax/buf_subs.c
@@ -33,14 +33,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)buf_subs.c 8.2 (Berkeley) 4/18/94";
-#endif
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
@@ -199,7 +191,7 @@ cp_start(void)
* A major problem is rewriting this last record. For archives stored
* on disk files, this is trivial. However, many devices are really picky
* about the conditions under which they will allow a write to occur.
- * Often devices restrict the conditions where writes can be made writes,
+ * Often devices restrict the conditions where writes can be made,
* so it may not be feasible to append archives stored on all types of
* devices.
* Return:
diff --git a/bin/pax/cache.c b/bin/pax/cache.c
index 980d7bccc217..d15c9c223447 100644
--- a/bin/pax/cache.c
+++ b/bin/pax/cache.c
@@ -33,14 +33,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)cache.c 8.1 (Berkeley) 5/31/93";
-#endif
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
@@ -211,12 +203,8 @@ name_uid(uid_t uid, int frc)
return("");
ptr->uid = uid;
ptr->valid = INVALID;
-# ifdef NET2_STAT
- (void)snprintf(ptr->name, sizeof(ptr->name), "%u", uid);
-# else
(void)snprintf(ptr->name, sizeof(ptr->name), "%lu",
(unsigned long)uid);
-# endif
if (frc == 0)
return("");
} else {
@@ -282,12 +270,8 @@ name_gid(gid_t gid, int frc)
return("");
ptr->gid = gid;
ptr->valid = INVALID;
-# ifdef NET2_STAT
- (void)snprintf(ptr->name, sizeof(ptr->name), "%u", gid);
-# else
(void)snprintf(ptr->name, sizeof(ptr->name), "%lu",
(unsigned long)gid);
-# endif
if (frc == 0)
return("");
} else {
diff --git a/bin/pax/cache.h b/bin/pax/cache.h
index 8a7cca9f457a..266aacbe7ce9 100644
--- a/bin/pax/cache.h
+++ b/bin/pax/cache.h
@@ -31,9 +31,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * @(#)cache.h 8.1 (Berkeley) 5/31/93
- * $FreeBSD$
*/
/*
diff --git a/bin/pax/cpio.c b/bin/pax/cpio.c
index a47b7fd7a823..8ae40f461343 100644
--- a/bin/pax/cpio.c
+++ b/bin/pax/cpio.c
@@ -33,14 +33,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)cpio.c 8.1 (Berkeley) 5/31/93";
-#endif
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/time.h>
#include <sys/stat.h>
@@ -149,7 +141,7 @@ com_rd(ARCHD *arcn)
}
/*
- * cpio_end_wr()
+ * cpio_endwr()
* write the special file with the name trailer in the proper format
* Return:
* result of the write of the trailer from the cpio specific write func
@@ -216,13 +208,8 @@ rd_ln_nm(ARCHD *arcn)
*/
if ((arcn->sb.st_size == 0) ||
((size_t)arcn->sb.st_size >= sizeof(arcn->ln_name))) {
-# ifdef NET2_STAT
- paxwarn(1, "Cpio link name length is invalid: %lu",
- arcn->sb.st_size);
-# else
paxwarn(1, "Cpio link name length is invalid: %ju",
(uintmax_t)arcn->sb.st_size);
-# endif
return(-1);
}
@@ -302,21 +289,11 @@ cpio_rd(ARCHD *arcn, char *buf)
arcn->sb.st_nlink = (nlink_t)asc_ul(hd->c_nlink, sizeof(hd->c_nlink),
OCT);
arcn->sb.st_rdev = (dev_t)asc_ul(hd->c_rdev, sizeof(hd->c_rdev), OCT);
-#ifdef NET2_STAT
- arcn->sb.st_mtime = (time_t)asc_ul(hd->c_mtime, sizeof(hd->c_mtime),
- OCT);
-#else
arcn->sb.st_mtime = (time_t)asc_uqd(hd->c_mtime, sizeof(hd->c_mtime),
OCT);
-#endif
arcn->sb.st_ctime = arcn->sb.st_atime = arcn->sb.st_mtime;
-#ifdef NET2_STAT
- arcn->sb.st_size = (off_t)asc_ul(hd->c_filesize,sizeof(hd->c_filesize),
- OCT);
-#else
arcn->sb.st_size = (off_t)asc_uqd(hd->c_filesize,sizeof(hd->c_filesize),
OCT);
-#endif
/*
* check name size and if valid, read in the name of this entry (name
@@ -411,13 +388,8 @@ cpio_wr(ARCHD *arcn)
/*
* set data size for file data
*/
-# ifdef NET2_STAT
- if (ul_asc((u_long)arcn->sb.st_size, hd->c_filesize,
- sizeof(hd->c_filesize), OCT)) {
-# else
if (uqd_asc((u_quad_t)arcn->sb.st_size, hd->c_filesize,
sizeof(hd->c_filesize), OCT)) {
-# endif
paxwarn(1,"File is too large for cpio format %s",
arcn->org_name);
return(1);
@@ -593,19 +565,10 @@ vcpio_rd(ARCHD *arcn, char *buf)
arcn->sb.st_mode = (mode_t)asc_ul(hd->c_mode, sizeof(hd->c_mode), HEX);
arcn->sb.st_uid = (uid_t)asc_ul(hd->c_uid, sizeof(hd->c_uid), HEX);
arcn->sb.st_gid = (gid_t)asc_ul(hd->c_gid, sizeof(hd->c_gid), HEX);
-#ifdef NET2_STAT
- arcn->sb.st_mtime = (time_t)asc_ul(hd->c_mtime,sizeof(hd->c_mtime),HEX);
-#else
arcn->sb.st_mtime = (time_t)asc_uqd(hd->c_mtime,sizeof(hd->c_mtime),HEX);
-#endif
arcn->sb.st_ctime = arcn->sb.st_atime = arcn->sb.st_mtime;
-#ifdef NET2_STAT
- arcn->sb.st_size = (off_t)asc_ul(hd->c_filesize,
- sizeof(hd->c_filesize), HEX);
-#else
arcn->sb.st_size = (off_t)asc_uqd(hd->c_filesize,
sizeof(hd->c_filesize), HEX);
-#endif
arcn->sb.st_nlink = (nlink_t)asc_ul(hd->c_nlink, sizeof(hd->c_nlink),
HEX);
devmajor = (dev_t)asc_ul(hd->c_maj, sizeof(hd->c_maj), HEX);
@@ -740,13 +703,8 @@ vcpio_wr(ARCHD *arcn)
* much to pad.
*/
arcn->pad = VCPIO_PAD(arcn->sb.st_size);
-# ifdef NET2_STAT
- if (ul_asc((u_long)arcn->sb.st_size, hd->c_filesize,
- sizeof(hd->c_filesize), HEX)) {
-# else
if (uqd_asc((u_quad_t)arcn->sb.st_size, hd->c_filesize,
sizeof(hd->c_filesize), HEX)) {
-# endif
paxwarn(1,"File is too large for sv4cpio format %s",
arcn->org_name);
return(1);
diff --git a/bin/pax/cpio.h b/bin/pax/cpio.h
index e5d61dea36fb..fba965f64a82 100644
--- a/bin/pax/cpio.h
+++ b/bin/pax/cpio.h
@@ -31,9 +31,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * @(#)cpio.h 8.1 (Berkeley) 5/31/93
- * $FreeBSD$
*/
/*
diff --git a/bin/pax/extern.h b/bin/pax/extern.h
index ec171f2d177c..26e5f6b6151b 100644
--- a/bin/pax/extern.h
+++ b/bin/pax/extern.h
@@ -31,9 +31,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * @(#)extern.h 8.2 (Berkeley) 4/18/94
- * $FreeBSD$
*/
/*
@@ -169,10 +166,8 @@ void ls_tty(ARCHD *);
int l_strncpy(char *, const char *, int);
u_long asc_ul(char *, int, int);
int ul_asc(u_long, char *, int, int);
-#ifndef NET2_STAT
u_quad_t asc_uqd(char *, int, int);
int uqd_asc(u_quad_t, char *, int, int);
-#endif
/*
* getoldopt.c
diff --git a/bin/pax/file_subs.c b/bin/pax/file_subs.c
index 31fb9112c586..7214de337ec4 100644
--- a/bin/pax/file_subs.c
+++ b/bin/pax/file_subs.c
@@ -33,14 +33,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)file_subs.c 8.1 (Berkeley) 5/31/93";
-#endif
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/time.h>
#include <sys/stat.h>
@@ -623,7 +615,7 @@ chk_path( char *name, uid_t st_uid, gid_t st_gid)
* non-zero we force these times to be set even if the user did not
* request access and/or modification time preservation (this is also
* used by -t to reset access times).
- * When ign is zero, only those times the user has asked for are set, the
+ * When frc is zero, only those times the user has asked for are set, the
* other ones are left alone. We do not assume the un-documented feature
* of many lutimes() implementations that consider a 0 time value as a do
* not set request.
@@ -724,7 +716,7 @@ set_pmode(char *fnm, mode_t mode)
* block boundaries significantly reduces the overhead when copying files
* that are NOT very sparse. This overhead (when compared to a write) is
* almost below the measurement resolution on many systems. Without it,
- * files with holes cannot be safely copied. It does has a side effect as
+ * files with holes cannot be safely copied. It does have a side effect as
* it can put holes into files that did not have them before, but that is
* not a problem since the file contents are unchanged (in fact it saves
* file space). (Except on paging files for diskless clients. But since we
diff --git a/bin/pax/ftree.c b/bin/pax/ftree.c
index 26df8164bc2d..400eb2faad30 100644
--- a/bin/pax/ftree.c
+++ b/bin/pax/ftree.c
@@ -33,14 +33,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)ftree.c 8.2 (Berkeley) 4/18/94";
-#endif
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/time.h>
#include <sys/stat.h>
@@ -115,11 +107,7 @@ ftree_start(void)
else
ftsopts |= FTS_PHYSICAL;
if (Hflag)
-# ifdef NET2_FTS
- paxwarn(0, "The -H flag is not supported on this version");
-# else
ftsopts |= FTS_COMFOLLOW;
-# endif
if (Xflag)
ftsopts |= FTS_XDEV;
@@ -402,13 +390,8 @@ next_file(ARCHD *arcn)
* remember to force the time (this is -t on a read
* directory, not a created directory).
*/
-# ifdef NET2_FTS
- if (!tflag || (get_atdir(ftent->fts_statb.st_dev,
- ftent->fts_statb.st_ino, &mtime, &atime) < 0))
-# else
if (!tflag || (get_atdir(ftent->fts_statp->st_dev,
ftent->fts_statp->st_ino, &mtime, &atime) < 0))
-# endif
continue;
set_ftime(ftent->fts_path, mtime, atime, 1);
continue;
@@ -419,28 +402,16 @@ next_file(ARCHD *arcn)
paxwarn(1,"File system cycle found at %s",ftent->fts_path);
continue;
case FTS_DNR:
-# ifdef NET2_FTS
- syswarn(1, errno,
-# else
syswarn(1, ftent->fts_errno,
-# endif
"Unable to read directory %s", ftent->fts_path);
continue;
case FTS_ERR:
-# ifdef NET2_FTS
- syswarn(1, errno,
-# else
syswarn(1, ftent->fts_errno,
-# endif
"File system traversal error");
continue;
case FTS_NS:
case FTS_NSOK:
-# ifdef NET2_FTS
- syswarn(1, errno,
-# else
syswarn(1, ftent->fts_errno,
-# endif
"Unable to access %s", ftent->fts_path);
continue;
}
@@ -453,11 +424,7 @@ next_file(ARCHD *arcn)
arcn->pad = 0;
arcn->ln_nlen = 0;
arcn->ln_name[0] = '\0';
-# ifdef NET2_FTS
- arcn->sb = ftent->fts_statb;
-# else
arcn->sb = *(ftent->fts_statp);
-# endif
/*
* file type based set up and copy into the arcn struct
diff --git a/bin/pax/ftree.h b/bin/pax/ftree.h
index 8e0a710e4ca9..500893096599 100644
--- a/bin/pax/ftree.h
+++ b/bin/pax/ftree.h
@@ -31,9 +31,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * @(#)ftree.h 8.1 (Berkeley) 5/31/93
- * $FreeBSD$
*/
/*
diff --git a/bin/pax/gen_subs.c b/bin/pax/gen_subs.c
index f91aaff7b809..a92303f63106 100644
--- a/bin/pax/gen_subs.c
+++ b/bin/pax/gen_subs.c
@@ -33,14 +33,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)gen_subs.c 8.1 (Berkeley) 5/31/93";
-#endif
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/time.h>
#include <sys/stat.h>
@@ -119,19 +111,10 @@ ls_list(ARCHD *arcn, time_t now, FILE *fp)
* print device id's for devices, or sizes for other nodes
*/
if ((arcn->type == PAX_CHR) || (arcn->type == PAX_BLK))
-# ifdef NET2_STAT
- (void)fprintf(fp, "%4u,%4u ", MAJOR(sbp->st_rdev),
- MINOR(sbp->st_rdev));
-# else
(void)fprintf(fp, "%4lu,%4lu ", (unsigned long)MAJOR(sbp->st_rdev),
(unsigned long)MINOR(sbp->st_rdev));
-# endif
else {
-# ifdef NET2_STAT
- (void)fprintf(fp, "%9lu ", sbp->st_size);
-# else
(void)fprintf(fp, "%9ju ", (uintmax_t)sbp->st_size);
-# endif
}
/*
@@ -300,7 +283,6 @@ ul_asc(u_long val, char *str, int len, int base)
return(0);
}
-#ifndef NET2_STAT
/*
* asc_uqd()
* convert hex/octal character string into a u_quad_t. We do not have to
@@ -396,4 +378,3 @@ uqd_asc(u_quad_t val, char *str, int len, int base)
return(-1);
return(0);
}
-#endif
diff --git a/bin/pax/getoldopt.c b/bin/pax/getoldopt.c
index 838ff54d4a88..6b0e83c23a24 100644
--- a/bin/pax/getoldopt.c
+++ b/bin/pax/getoldopt.c
@@ -10,9 +10,6 @@
* in the Public Domain for your edification and enjoyment.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
diff --git a/bin/pax/options.c b/bin/pax/options.c
index 4ec02d80d55c..3567820acced 100644
--- a/bin/pax/options.c
+++ b/bin/pax/options.c
@@ -33,15 +33,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static char sccsid[] = "@(#)options.c 8.2 (Berkeley) 4/18/94";
-#endif /* not lint */
-#endif
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mtio.h>
@@ -87,7 +78,7 @@ char *chdname;
#define GZIP_CMD "gzip" /* command to run as gzip */
#define COMPRESS_CMD "compress" /* command to run as compress */
-#define BZIP2_CMD "bzip2" /* command to run as gzip */
+#define BZIP2_CMD "bzip2" /* command to run as bzip2 */
/*
* Format specific routine table - MUST BE IN SORTED ORDER BY NAME
@@ -131,17 +122,18 @@ FSUB fsub[] = {
};
#define F_OCPIO 0 /* format when called as cpio -6 */
#define F_ACPIO 1 /* format when called as cpio -c */
+#define F_SCPIO 2 /* format when called with -x sv4cpio */
#define F_CPIO 3 /* format when called as cpio */
#define F_OTAR 4 /* format when called as tar -o */
#define F_TAR 5 /* format when called as tar */
-#define DEFLT 5 /* default write format from list above */
+#define DEFLT F_TAR /* default write format from list above */
/*
* ford is the archive search order used by get_arc() to determine what kind
* of archive we are dealing with. This helps to properly id archive formats
* some formats may be subsets of others....
*/
-int ford[] = {5, 4, 3, 2, 1, 0, -1 };
+int ford[] = {F_TAR, F_OTAR, F_CPIO, F_SCPIO, F_ACPIO, F_OCPIO, -1 };
/*
* options()
@@ -308,7 +300,7 @@ pax_options(int argc, char **argv)
break;
case 'p':
/*
- * preserver file mode bits
+ * preserve file mode bits
*/
pmode = 1;
break;
@@ -1434,13 +1426,8 @@ str_offt(char *val)
char *expr;
off_t num, t;
-# ifdef NET2_STAT
- num = strtol(val, &expr, 0);
- if ((num == LONG_MAX) || (num <= 0) || (expr == val))
-# else
num = strtoq(val, &expr, 0);
if ((num == QUAD_MAX) || (num <= 0) || (expr == val))
-# endif
return(0);
switch(*expr) {
diff --git a/bin/pax/options.h b/bin/pax/options.h
index 973ea0bd5467..49fef7bb7531 100644
--- a/bin/pax/options.h
+++ b/bin/pax/options.h
@@ -31,9 +31,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * @(#)options.h 8.2 (Berkeley) 4/18/94
- * $FreeBSD$
*/
/*
diff --git a/bin/pax/pat_rep.c b/bin/pax/pat_rep.c
index 0dfa630050ea..0c416741f5d8 100644
--- a/bin/pax/pat_rep.c
+++ b/bin/pax/pat_rep.c
@@ -33,24 +33,12 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)pat_rep.c 8.2 (Berkeley) 4/18/94";
-#endif
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
-#ifdef NET2_REGEX
-#include <regexp.h>
-#else
#include <regex.h>
-#endif
#include "pax.h"
#include "pat_rep.h"
#include "extern.h"
@@ -73,11 +61,7 @@ static int tty_rename(ARCHD *);
static int fix_path(char *, int *, char *, int);
static int fn_match(char *, char *, char **);
static char * range_match(char *, int);
-#ifdef NET2_REGEX
-static int resub(regexp *, char *, char *, char *);
-#else
static int resub(regex_t *, regmatch_t *, char *, char *, char *, char *);
-#endif
/*
* rep_add()
@@ -101,10 +85,8 @@ rep_add(char *str)
char *pt1;
char *pt2;
REPLACE *rep;
-# ifndef NET2_REGEX
int res;
char rebuf[BUFSIZ];
-# endif
/*
* throw out the bad parameters
@@ -133,13 +115,9 @@ rep_add(char *str)
}
*pt1 = '\0';
-# ifdef NET2_REGEX
- if ((rep->rcmp = regcomp(str+1)) == NULL) {
-# else
if ((res = regcomp(&(rep->rcmp), str+1, 0)) != 0) {
regerror(res, &(rep->rcmp), rebuf, sizeof(rebuf));
paxwarn(1, "%s while compiling regular expression %s", rebuf, str);
-# endif
free(rep);
return(-1);
}
@@ -151,11 +129,7 @@ rep_add(char *str)
*/
*pt1++ = *str;
if ((pt2 = strchr(pt1, *str)) == NULL) {
-# ifdef NET2_REGEX
- free(rep->rcmp);
-# else
regfree(&rep->rcmp);
-# endif
free(rep);
paxwarn(1, "Invalid replacement string %s", str);
return(-1);
@@ -180,11 +154,7 @@ rep_add(char *str)
rep->flgs |= PRNT;
break;
default:
-# ifdef NET2_REGEX
- free(rep->rcmp);
-# else
regfree(&rep->rcmp);
-# endif
free(rep);
*pt1 = *str;
paxwarn(1, "Invalid replacement string option %s", str);
@@ -865,9 +835,7 @@ rep_name(char *name, int *nlen, int prnt)
char *rpt;
int found = 0;
int res;
-# ifndef NET2_REGEX
regmatch_t pm[MAXSUBEXP];
-# endif
char nname[PAXPATHLEN+1]; /* final result of all replacements */
char buf1[PAXPATHLEN+1]; /* where we work on the name */
@@ -894,11 +862,7 @@ rep_name(char *name, int *nlen, int prnt)
* check for a successful substitution, if not go to
* the next pattern, or cleanup if we were global
*/
-# ifdef NET2_REGEX
- if (regexec(pt->rcmp, inpt) == 0)
-# else
if (regexec(&(pt->rcmp), inpt, MAXSUBEXP, pm, 0) != 0)
-# endif
break;
/*
@@ -909,11 +873,7 @@ rep_name(char *name, int *nlen, int prnt)
* do not create a string too long).
*/
found = 1;
-# ifdef NET2_REGEX
- rpt = pt->rcmp->startp[0];
-# else
rpt = inpt + pm[0].rm_so;
-# endif
while ((inpt < rpt) && (outpt < endpt))
*outpt++ = *inpt++;
@@ -926,12 +886,8 @@ rep_name(char *name, int *nlen, int prnt)
* replacement string and place it the prefix in the
* final output. If we have problems, skip it.
*/
-# ifdef NET2_REGEX
- if ((res = resub(pt->rcmp,pt->nstr,outpt,endpt)) < 0) {
-# else
if ((res = resub(&(pt->rcmp),pm,inpt,pt->nstr,outpt,endpt))
< 0) {
-# endif
if (prnt)
paxwarn(1, "Replacement name error %s",
name);
@@ -949,11 +905,7 @@ rep_name(char *name, int *nlen, int prnt)
* the final result. Make sure we do not overrun the
* output buffer
*/
-# ifdef NET2_REGEX
- inpt = pt->rcmp->endp[0];
-# else
inpt += pm[0].rm_eo - pm[0].rm_so;
-# endif
if ((outpt == endpt) || (*inpt == '\0'))
break;
@@ -1012,55 +964,6 @@ rep_name(char *name, int *nlen, int prnt)
return(0);
}
-#ifdef NET2_REGEX
-/*
- * resub()
- * apply the replacement to the matched expression. expand out the old
- * style ed(1) subexpression expansion.
- * Return:
- * -1 if error, or the number of characters added to the destination.
- */
-
-static int
-resub(regexp *prog, char *src, char *dest, char *destend)
-{
- char *spt;
- char *dpt;
- char c;
- int no;
- int len;
-
- spt = src;
- dpt = dest;
- while ((dpt < destend) && ((c = *spt++) != '\0')) {
- if (c == '&')
- no = 0;
- else if ((c == '\\') && (*spt >= '0') && (*spt <= '9'))
- no = *spt++ - '0';
- else {
- if ((c == '\\') && ((*spt == '\\') || (*spt == '&')))
- c = *spt++;
- *dpt++ = c;
- continue;
- }
- if ((prog->startp[no] == NULL) || (prog->endp[no] == NULL) ||
- ((len = prog->endp[no] - prog->startp[no]) <= 0))
- continue;
-
- /*
- * copy the subexpression to the destination.
- * fail if we run out of space or the match string is damaged
- */
- if (len > (destend - dpt))
- len = destend - dpt;
- if (l_strncpy(dpt, prog->startp[no], len) != len)
- return(-1);
- dpt += len;
- }
- return(dpt - dest);
-}
-
-#else
/*
* resub()
@@ -1127,4 +1030,3 @@ resub(regex_t *rp, regmatch_t *pm, char *orig, char *src, char *dest,
}
return(dpt - dest);
}
-#endif
diff --git a/bin/pax/pat_rep.h b/bin/pax/pat_rep.h
index 7def28d36e30..8560bfb77cf1 100644
--- a/bin/pax/pat_rep.h
+++ b/bin/pax/pat_rep.h
@@ -31,9 +31,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * @(#)pat_rep.h 8.1 (Berkeley) 5/31/93
- * $FreeBSD$
*/
/*
@@ -41,11 +38,7 @@
*/
typedef struct replace {
char *nstr; /* the new string we will substitute with */
-# ifdef NET2_REGEX
- regexp *rcmp; /* compiled regular expression used to match */
-# else
regex_t rcmp; /* compiled regular expression used to match */
-# endif
int flgs; /* print conversions? global in operation? */
#define PRNT 0x1
#define GLOB 0x2
diff --git a/bin/pax/pax.1 b/bin/pax/pax.1
index 2cc7a694a710..0981e9c0ae77 100644
--- a/bin/pax/pax.1
+++ b/bin/pax/pax.1
@@ -30,10 +30,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)pax.1 8.4 (Berkeley) 4/18/94
-.\" $FreeBSD$
-.\"
-.Dd December 29, 2018
+.Dd October 19, 2022
.Dt PAX 1
.Os
.Sh NAME
@@ -800,7 +797,7 @@ option is also used, the resulting file may contain fewer
.Ar bytes ,
according to the compressibility of the archive contents.
See
-.Xr zip 1
+.Xr zip 1 Pq Pa ports/archivers/zip
if compressed volumes of predictable size are required.
.Pp
.Em Warning :
@@ -933,28 +930,31 @@ changed during a specified time range will be archived).
A time range is made up of six different fields and each field must contain two
digits.
The format is:
-.Dl [yy[mm[dd[hh]]]]mm[.ss]
+.Pp
+.Dl [[[[[cc]yy]mm]dd]HH]MM[.SS]
+.Pp
Where
-.Cm yy
+.Ar cc
+is the first two digits of the year (the century),
+.Ar yy
is the last two digits of the year,
the first
-.Cm mm
+.Ar mm
is the month (from 01 to 12),
-.Cm dd
+.Ar dd
is the day of the month (from 01 to 31),
-.Cm hh
+.Ar HH
is the hour of the day (from 00 to 23),
-the second
-.Cm mm
+.Ar MM
is the minute (from 00 to 59),
and
-.Cm ss
+.Ar SS
is the seconds (from 00 to 59).
The minute field
-.Cm mm
+.Ar MM
is required, while the other fields are optional and must be added in the
following order:
-.Dl Cm hh , dd , mm , yy .
+.Ar HH , dd , mm , yy , cc .
The
.Cm ss
field may be added independently of the other fields.
diff --git a/bin/pax/pax.c b/bin/pax/pax.c
index 4f7456f31a78..e8e758f16650 100644
--- a/bin/pax/pax.c
+++ b/bin/pax/pax.c
@@ -33,20 +33,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static char const copyright[] =
-"@(#) Copyright (c) 1992, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "@(#)pax.c 8.2 (Berkeley) 4/18/94";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
@@ -83,7 +69,7 @@ int nflag; /* select first archive member match */
int tflag; /* restore access time after read */
int uflag; /* ignore older modification time files */
int vflag; /* produce verbose output */
-int Dflag; /* same as uflag except inode change time */
+int Dflag; /* same as uflag except for inode change time */
int Hflag; /* follow command line symlinks (write only) */
int Lflag; /* follow symlinks when writing */
int Oflag; /* limit to single volume */
@@ -392,7 +378,7 @@ gen_init(void)
/*
* signal handling to reset stored directory times and modes. Since
* we deal with broken pipes via failed writes we ignore it. We also
- * deal with any file size limit thorough failed writes. Cpu time
+ * deal with any file size limit through failed writes. Cpu time
* limits are caught and a cleanup is forced.
*/
if ((sigemptyset(&s_mask) < 0) || (sigaddset(&s_mask, SIGTERM) < 0) ||
diff --git a/bin/pax/pax.h b/bin/pax/pax.h
index 530f8aa0d33d..a50da55a921c 100644
--- a/bin/pax/pax.h
+++ b/bin/pax/pax.h
@@ -31,9 +31,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * @(#)pax.h 8.2 (Berkeley) 4/18/94
- * $FreeBSD$
*/
/*
diff --git a/bin/pax/sel_subs.c b/bin/pax/sel_subs.c
index 4c0d09e4eb7f..ccbb77ccbb5c 100644
--- a/bin/pax/sel_subs.c
+++ b/bin/pax/sel_subs.c
@@ -33,28 +33,23 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)sel_subs.c 8.1 (Berkeley) 5/31/93";
-#endif
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/time.h>
#include <sys/stat.h>
-#include <pwd.h>
+
+#include <ctype.h>
#include <grp.h>
+#include <pwd.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <strings.h>
-#include <stdlib.h>
+
#include "pax.h"
#include "sel_subs.h"
#include "extern.h"
-static int str_sec(char *, time_t *);
+static int str_sec(const char *, time_t *);
static int usr_match(ARCHD *);
static int grp_match(ARCHD *);
static int trng_match(ARCHD *);
@@ -89,7 +84,7 @@ sel_chk(ARCHD *arcn)
* User/group selection routines
*
* Routines to handle user selection of files based on the file uid/gid. To
- * add an entry, the user supplies either then name or the uid/gid starting with
+ * add an entry, the user supplies either the name or the uid/gid starting with
* a # on the command line. A \# will escape the #.
*/
@@ -134,11 +129,7 @@ usr_add(char *str)
}
uid = (uid_t)pw->pw_uid;
} else
-# ifdef NET2_STAT
- uid = (uid_t)atoi(str+1);
-# else
uid = (uid_t)strtoul(str+1, NULL, 10);
-# endif
endpwent();
/*
@@ -235,11 +226,7 @@ grp_add(char *str)
}
gid = gr->gr_gid;
} else
-# ifdef NET2_STAT
- gid = (gid_t)atoi(str+1);
-# else
gid = (gid_t)strtoul(str+1, NULL, 10);
-# endif
endgrent();
/*
@@ -317,7 +304,7 @@ grp_match(ARCHD *arcn)
* trng_add()
* add a time range match to the time range list.
* This is a non-standard pax option. Lower and upper ranges are in the
- * format: [yy[mm[dd[hh]]]]mm[.ss] and are comma separated.
+ * format: [[[[[cc]yy]mm]dd]HH]MM[.SS] and are comma separated.
* Time ranges are based on current time, so 1234 would specify a time of
* 12:34 today.
* Return:
@@ -454,7 +441,7 @@ trng_add(char *str)
return(0);
out:
- paxwarn(1, "Time range format is: [yy[mm[dd[hh]]]]mm[.ss][/[c][m]]");
+ paxwarn(1, "Time range format is: [[[[[cc]yy]mm]dd]HH]MM[.SS][/[c][m]]");
return(-1);
}
@@ -528,80 +515,87 @@ trng_match(ARCHD *arcn)
/*
* str_sec()
- * Convert a time string in the format of [yy[mm[dd[hh]]]]mm[.ss] to gmt
- * seconds. Tval already has current time loaded into it at entry.
+ * Convert a time string in the format of [[[[[cc]yy]mm]dd]HH]MM[.SS] to
+ * seconds UTC. Tval already has current time loaded into it at entry.
* Return:
* 0 if converted ok, -1 otherwise
*/
static int
-str_sec(char *str, time_t *tval)
+str_sec(const char *p, time_t *tval)
{
struct tm *lt;
- char *dot = NULL;
+ const char *dot, *t;
+ size_t len;
+ int bigyear;
+ int yearset;
+
+ yearset = 0;
+ len = strlen(p);
+
+ for (t = p, dot = NULL; *t; ++t) {
+ if (isdigit((unsigned char)*t))
+ continue;
+ if (*t == '.' && dot == NULL) {
+ dot = t;
+ continue;
+ }
+ return(-1);
+ }
lt = localtime(tval);
- if ((dot = strchr(str, '.')) != NULL) {
- /*
- * seconds (.ss)
- */
- *dot++ = '\0';
- if (strlen(dot) != 2)
+
+ if (dot != NULL) { /* .SS */
+ if (strlen(++dot) != 2)
return(-1);
- if ((lt->tm_sec = ATOI2(dot)) > 61)
+ lt->tm_sec = ATOI2(dot);
+ if (lt->tm_sec > 61)
return(-1);
+ len -= 3;
} else
lt->tm_sec = 0;
- switch (strlen(str)) {
- case 10:
- /*
- * year (yy)
- * watch out for year 2000
- */
- if ((lt->tm_year = ATOI2(str)) < 69)
- lt->tm_year += 100;
- str += 2;
+ switch (len) {
+ case 12: /* cc */
+ bigyear = ATOI2(p);
+ lt->tm_year = (bigyear * 100) - 1900;
+ yearset = 1;
/* FALLTHROUGH */
- case 8:
- /*
- * month (mm)
- * watch out months are from 0 - 11 internally
- */
- if ((lt->tm_mon = ATOI2(str)) > 12)
+ case 10: /* yy */
+ if (yearset) {
+ lt->tm_year += ATOI2(p);
+ } else {
+ lt->tm_year = ATOI2(p);
+ if (lt->tm_year < 69) /* hack for 2000 ;-} */
+ lt->tm_year += (2000 - 1900);
+ }
+ /* FALLTHROUGH */
+ case 8: /* mm */
+ lt->tm_mon = ATOI2(p);
+ if ((lt->tm_mon > 12) || !lt->tm_mon)
return(-1);
- --lt->tm_mon;
- str += 2;
+ --lt->tm_mon; /* time struct is 0 - 11 */
/* FALLTHROUGH */
- case 6:
- /*
- * day (dd)
- */
- if ((lt->tm_mday = ATOI2(str)) > 31)
+ case 6: /* dd */
+ lt->tm_mday = ATOI2(p);
+ if ((lt->tm_mday > 31) || !lt->tm_mday)
return(-1);
- str += 2;
/* FALLTHROUGH */
- case 4:
- /*
- * hour (hh)
- */
- if ((lt->tm_hour = ATOI2(str)) > 23)
+ case 4: /* HH */
+ lt->tm_hour = ATOI2(p);
+ if (lt->tm_hour > 23)
return(-1);
- str += 2;
/* FALLTHROUGH */
- case 2:
- /*
- * minute (mm)
- */
- if ((lt->tm_min = ATOI2(str)) > 59)
+ case 2: /* MM */
+ lt->tm_min = ATOI2(p);
+ if (lt->tm_min > 59)
return(-1);
break;
default:
return(-1);
}
- /*
- * convert broken-down time to GMT clock time seconds
- */
+
+ /* convert broken-down time to UTC clock time seconds */
if ((*tval = mktime(lt)) == -1)
return(-1);
return(0);
diff --git a/bin/pax/sel_subs.h b/bin/pax/sel_subs.h
index 7e1ddeedcb87..55f672b4eed3 100644
--- a/bin/pax/sel_subs.h
+++ b/bin/pax/sel_subs.h
@@ -31,9 +31,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * @(#)sel_subs.h 8.1 (Berkeley) 5/31/93
- * $FreeBSD$
*/
/*
@@ -57,7 +54,7 @@ typedef struct grpt {
* data structure for storing user supplied time ranges (-T option)
*/
-#define ATOI2(s) ((((s)[0] - '0') * 10) + ((s)[1] - '0'))
+#define ATOI2(ar) ((ar)[0] - '0') * 10 + ((ar)[1] - '0'); (ar) += 2;
typedef struct time_rng {
time_t low_time; /* lower inclusive time limit */
diff --git a/bin/pax/tables.c b/bin/pax/tables.c
index 97d430cb742f..e1e7b7d6d43e 100644
--- a/bin/pax/tables.c
+++ b/bin/pax/tables.c
@@ -33,14 +33,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)tables.c 8.1 (Berkeley) 5/31/93";
-#endif
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/time.h>
#include <sys/stat.h>
@@ -65,7 +57,7 @@ __FBSDID("$FreeBSD$");
* large archives. These database routines carefully combine memory usage and
* temporary file storage in ways which will not significantly impact runtime
* performance while allowing the largest possible archives to be handled.
- * Trying to force the fit to the POSIX databases routines was not considered
+ * Trying to force the fit to the POSIX database routines was not considered
* time well spent.
*/
@@ -311,9 +303,9 @@ lnk_end(void)
* are stored in a scratch file and indexed by an in memory hash table. The
* hash table is indexed by hashing the file path. The nodes in the table store
* the length of the filename and the lseek offset within the scratch file
- * where the actual name is stored. Since there are never any deletions to this
- * table, fragmentation of the scratch file is never an issue. Lookups seem to
- * not exhibit any locality at all (files in the database are rarely
+ * where the actual name is stored. Since there are never any deletions from
+ * this table, fragmentation of the scratch file is never an issue. Lookups
+ * seem to not exhibit any locality at all (files in the database are rarely
* looked up more than once...). So caching is just a waste of memory. The
* only limitation is the amount of scratch file space available to store the
* path names.
@@ -880,14 +872,14 @@ map_dev(ARCHD *arcn, u_long dev_mask, u_long ino_mask)
/*
* directory access/mod time reset table routines (for directories READ by pax)
*
- * The pax -t flag requires that access times of archive files to be the same
+ * The pax -t flag requires that access times of archive files be the same
* before being read by pax. For regular files, access time is restored after
* the file has been copied. This database provides the same functionality for
* directories read during file tree traversal. Restoring directory access time
* is more complex than files since directories may be read several times until
* all the descendants in their subtree are visited by fts. Directory access
* and modification times are stored during the fts pre-order visit (done
- * before any descendants in the subtree is visited) and restored after the
+ * before any descendants in the subtree are visited) and restored after the
* fts post-order visit (after all the descendants have been visited). In the
* case of premature exit from a subtree (like from the effects of -n), any
* directory entries left in this database are reset during final cleanup
@@ -966,7 +958,7 @@ add_atdir(char *fname, dev_t dev, ino_t ino, time_t mtime, time_t atime)
* return (the older entry always has the correct time). The only
* way this will happen is when the same subtree can be traversed by
* different args to pax and the -n option is aborting fts out of a
- * subtree before all the post-order visits have been made).
+ * subtree before all the post-order visits have been made.
*/
indx = ((unsigned)ino) % A_TAB_SZ;
if ((pt = atab[indx]) != NULL) {
diff --git a/bin/pax/tables.h b/bin/pax/tables.h
index fb5bc437b0a0..9c6f2f48ba89 100644
--- a/bin/pax/tables.h
+++ b/bin/pax/tables.h
@@ -31,9 +31,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * @(#)tables.h 8.1 (Berkeley) 5/31/93
- * $FreeBSD$
*/
/*
diff --git a/bin/pax/tar.c b/bin/pax/tar.c
index 3a458223bddd..50a9a41623ca 100644
--- a/bin/pax/tar.c
+++ b/bin/pax/tar.c
@@ -33,14 +33,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)tar.c 8.2 (Berkeley) 4/18/94";
-#endif
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/time.h>
#include <sys/stat.h>
@@ -57,9 +49,7 @@ __FBSDID("$FreeBSD$");
static u_long tar_chksm(char *, int);
static char *name_split(char *, int);
static int ul_oct(u_long, char *, int, int);
-#ifndef NET2_STAT
static int uqd_oct(u_quad_t, char *, int, int);
-#endif
/*
* Routines common to all versions of tar
@@ -190,7 +180,6 @@ ul_oct(u_long val, char *str, int len, int term)
return(0);
}
-#ifndef NET2_STAT
/*
* uqd_oct()
* convert an u_quad_t to an octal string. one of many oddball field
@@ -244,7 +233,6 @@ uqd_oct(u_quad_t val, char *str, int len, int term)
return(-1);
return(0);
}
-#endif
/*
* tar_chksm()
@@ -399,13 +387,8 @@ tar_rd(ARCHD *arcn, char *buf)
0xfff);
arcn->sb.st_uid = (uid_t)asc_ul(hd->uid, sizeof(hd->uid), OCT);
arcn->sb.st_gid = (gid_t)asc_ul(hd->gid, sizeof(hd->gid), OCT);
-#ifdef NET2_STAT
- arcn->sb.st_size = (off_t)asc_ul(hd->size, sizeof(hd->size), OCT);
- arcn->sb.st_mtime = (time_t)asc_ul(hd->mtime, sizeof(hd->mtime), OCT);
-#else
arcn->sb.st_size = (off_t)asc_uqd(hd->size, sizeof(hd->size), OCT);
arcn->sb.st_mtime = (time_t)asc_uqd(hd->mtime, sizeof(hd->mtime), OCT);
-#endif
arcn->sb.st_ctime = arcn->sb.st_atime = arcn->sb.st_mtime;
/*
@@ -562,12 +545,12 @@ tar_wr(ARCHD *arcn)
}
/*
- * copy the data out of the ARCHD into the tar header based on the type
- * of the file. Remember many tar readers want the unused fields to be
- * padded with zero. We set the linkflag field (type), the linkname
- * (or zero if not used),the size, and set the padding (if any) to be
- * added after the file data (0 for all other types, as they only have
- * a header)
+ * Copy the data out of the ARCHD into the tar header based on the type
+ * of the file. Remember, many tar readers want all fields to be
+ * padded with zero so we zero the header first. We then set the
+ * linkflag field (type), the linkname, the size, and set the padding
+ * (if any) to be added after the file data (0 for all other types,
+ * as they only have a header).
*/
hd = &hdblk;
l_strncpy(hd->name, arcn->name, sizeof(hd->name) - 1);
@@ -609,13 +592,8 @@ tar_wr(ARCHD *arcn)
*/
hd->linkflag = AREGTYPE;
memset(hd->linkname, 0, sizeof(hd->linkname));
-# ifdef NET2_STAT
- if (ul_oct((u_long)arcn->sb.st_size, hd->size,
- sizeof(hd->size), 1)) {
-# else
if (uqd_oct((u_quad_t)arcn->sb.st_size, hd->size,
sizeof(hd->size), 1)) {
-# endif
paxwarn(1,"File is too large for tar %s", arcn->org_name);
return(1);
}
@@ -776,13 +754,8 @@ ustar_rd(ARCHD *arcn, char *buf)
*/
arcn->sb.st_mode = (mode_t)(asc_ul(hd->mode, sizeof(hd->mode), OCT) &
0xfff);
-#ifdef NET2_STAT
- arcn->sb.st_size = (off_t)asc_ul(hd->size, sizeof(hd->size), OCT);
- arcn->sb.st_mtime = (time_t)asc_ul(hd->mtime, sizeof(hd->mtime), OCT);
-#else
arcn->sb.st_size = (off_t)asc_uqd(hd->size, sizeof(hd->size), OCT);
arcn->sb.st_mtime = (time_t)asc_uqd(hd->mtime, sizeof(hd->mtime), OCT);
-#endif
arcn->sb.st_ctime = arcn->sb.st_atime = arcn->sb.st_mtime;
/*
@@ -1011,13 +984,8 @@ ustar_wr(ARCHD *arcn)
memset(hd->devmajor, 0, sizeof(hd->devmajor));
memset(hd->devminor, 0, sizeof(hd->devminor));
arcn->pad = TAR_PAD(arcn->sb.st_size);
-# ifdef NET2_STAT
- if (ul_oct((u_long)arcn->sb.st_size, hd->size,
- sizeof(hd->size), 3)) {
-# else
if (uqd_oct((u_quad_t)arcn->sb.st_size, hd->size,
sizeof(hd->size), 3)) {
-# endif
paxwarn(1,"File is too long for ustar %s",arcn->org_name);
return(1);
}
diff --git a/bin/pax/tar.h b/bin/pax/tar.h
index 91c2400e35ca..806a9e9ef12c 100644
--- a/bin/pax/tar.h
+++ b/bin/pax/tar.h
@@ -31,9 +31,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * @(#)tar.h 8.2 (Berkeley) 4/18/94
- * $FreeBSD$
*/
/*
diff --git a/bin/pax/tests/Makefile b/bin/pax/tests/Makefile
index 8334fea3c747..622e59c57d10 100644
--- a/bin/pax/tests/Makefile
+++ b/bin/pax/tests/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <bsd.own.mk>
diff --git a/bin/pax/tests/Makefile.depend b/bin/pax/tests/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/bin/pax/tests/Makefile.depend
+++ b/bin/pax/tests/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/bin/pax/tests/legacy_test.pl b/bin/pax/tests/legacy_test.pl
index dabba42b3f31..1f41e93e5969 100644
--- a/bin/pax/tests/legacy_test.pl
+++ b/bin/pax/tests/legacy_test.pl
@@ -1,4 +1,3 @@
-# $FreeBSD$
use strict;
use warnings;
diff --git a/bin/pax/tty_subs.c b/bin/pax/tty_subs.c
index ea524c451007..73424e12389a 100644
--- a/bin/pax/tty_subs.c
+++ b/bin/pax/tty_subs.c
@@ -33,14 +33,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)tty_subs.c 8.2 (Berkeley) 4/18/94";
-#endif
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
diff --git a/bin/pkill/Makefile b/bin/pkill/Makefile
index bd755b822b7e..b4a8754d231f 100644
--- a/bin/pkill/Makefile
+++ b/bin/pkill/Makefile
@@ -1,5 +1,4 @@
# $NetBSD: Makefile,v 1.1 2002/03/01 11:21:58 ad Exp $
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/bin/pkill/Makefile.depend b/bin/pkill/Makefile.depend
index 6f5a5f79bf30..73bd22d39dcc 100644
--- a/bin/pkill/Makefile.depend
+++ b/bin/pkill/Makefile.depend
@@ -1,14 +1,11 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
- lib/libelf \
lib/libjail \
lib/libkvm \
diff --git a/bin/pkill/pkill.1 b/bin/pkill/pkill.1
index db9283de26a3..f06b448b5df8 100644
--- a/bin/pkill/pkill.1
+++ b/bin/pkill/pkill.1
@@ -1,7 +1,5 @@
.\" $NetBSD: pkill.1,v 1.8 2003/02/14 15:59:18 grant Exp $
.\"
-.\" $FreeBSD$
-.\"
.\" Copyright (c) 2002 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
diff --git a/bin/pkill/pkill.c b/bin/pkill/pkill.c
index 0ffa5ababaac..4b894a986062 100644
--- a/bin/pkill/pkill.c
+++ b/bin/pkill/pkill.c
@@ -1,7 +1,7 @@
/* $NetBSD: pkill.c,v 1.16 2005/10/10 22:13:20 kleink Exp $ */
/*-
- * SPDX-License-Identifier: BSD-2-Clause-NetBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2002 The NetBSD Foundation, Inc.
* Copyright (c) 2005 Pawel Jakub Dawidek <pjd@FreeBSD.org>
@@ -32,9 +32,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/param.h>
#include <sys/sysctl.h>
@@ -133,8 +130,9 @@ static int takepid(const char *, int);
int
main(int argc, char **argv)
{
- char buf[_POSIX2_LINE_MAX], *mstr, **pargv, *p, *q, *pidfile;
+ char *buf, *mstr, **pargv, *p, *q, *pidfile;
const char *execf, *coref;
+ size_t bufsz;
int ancestors, debug_opt, did_action;
int i, ch, bestidx, rv, criteria, pidfromfile, pidfilelock;
size_t jsz;
@@ -177,6 +175,7 @@ main(int argc, char **argv)
}
}
+ buf = NULL;
ancestors = 0;
criteria = 0;
debug_opt = 0;
@@ -312,6 +311,31 @@ main(int argc, char **argv)
mypid = getpid();
/*
+ * If we're not matching args, we only need a buffer large enough to
+ * hold some relatively short error strings. Otherwise, we have to
+ * assume we'll need up to ARG_MAX bytes for arguments.
+ */
+ bufsz = _POSIX2_LINE_MAX;
+ if (matchargs) {
+ long arg_max;
+
+ arg_max = sysconf(_SC_ARG_MAX);
+ if (arg_max == -1)
+ arg_max = ARG_MAX;
+
+ /*
+ * The absolute worst case scenario is ARG_MAX single-byte
+ * arguments which we'll then separate with spaces and NUL
+ * terminate.
+ */
+ bufsz = (arg_max * 2) + 1;
+ }
+
+ buf = malloc(bufsz);
+ if (buf == NULL)
+ err(STATUS_ERROR, "malloc");
+
+ /*
* Retrieve the list of running processes from the kernel.
*/
kd = kvm_openfiles(execf, coref, NULL, O_RDONLY, buf);
@@ -346,7 +370,7 @@ main(int argc, char **argv)
*/
for (; *argv != NULL; argv++) {
if ((rv = regcomp(&reg, *argv, cflags)) != 0) {
- regerror(rv, &reg, buf, sizeof(buf));
+ regerror(rv, &reg, buf, bufsz);
errx(STATUS_BADUSAGE,
"Cannot compile regular expression `%s' (%s)",
*argv, buf);
@@ -363,9 +387,9 @@ main(int argc, char **argv)
if (matchargs &&
(pargv = kvm_getargv(kd, kp, 0)) != NULL) {
jsz = 0;
- while (jsz < sizeof(buf) && *pargv != NULL) {
+ while (jsz < bufsz && *pargv != NULL) {
jsz += snprintf(buf + jsz,
- sizeof(buf) - jsz,
+ bufsz - jsz,
pargv[1] != NULL ? "%s " : "%s",
pargv[0]);
pargv++;
@@ -384,7 +408,7 @@ main(int argc, char **argv)
} else
selected[i] = 1;
} else if (rv != REG_NOMATCH) {
- regerror(rv, &reg, buf, sizeof(buf));
+ regerror(rv, &reg, buf, bufsz);
errx(STATUS_ERROR,
"Regular expression evaluation error (%s)",
buf);
@@ -576,6 +600,7 @@ main(int argc, char **argv)
fprintf(stderr,
"No matching processes belonging to you were found\n");
+ free(buf);
exit(rv ? STATUS_MATCH : STATUS_NOMATCH);
}
diff --git a/bin/pkill/tests/Makefile b/bin/pkill/tests/Makefile
index be467074651f..d92b08724561 100644
--- a/bin/pkill/tests/Makefile
+++ b/bin/pkill/tests/Makefile
@@ -1,15 +1,20 @@
-# $FreeBSD$
.include <bsd.own.mk>
-TAP_TESTS_SH= pgrep-F_test
-TAP_TESTS_SH+= pgrep-LF_test
-TAP_TESTS_SH+= pgrep-P_test
-TAP_TESTS_SH+= pgrep-U_test
+PACKAGE= tests
+
+PROGS+= spin_helper
+BINDIR= ${TESTSDIR}
+
+TAP_TESTS_SH= pgrep-_f_test
+TAP_TESTS_SH+= pgrep-_lf_test
+TAP_TESTS_SH+= pgrep-_p_test
+TAP_TESTS_SH+= pgrep-_u_test
TAP_TESTS_SH+= pgrep-_g_test
TAP_TESTS_SH+= pgrep-_s_test
TAP_TESTS_SH+= pgrep-g_test
TAP_TESTS_SH+= pgrep-i_test
+TAP_TESTS_SH+= pgrep-f_test
TAP_TESTS_SH+= pgrep-j_test
TEST_METADATA.pgrep-j_test+= required_user="root"
TEST_METADATA.pgrep-j_test+= required_programs="jail jls"
@@ -21,10 +26,10 @@ TAP_TESTS_SH+= pgrep-s_test
TAP_TESTS_SH+= pgrep-t_test
TAP_TESTS_SH+= pgrep-v_test
TAP_TESTS_SH+= pgrep-x_test
-TAP_TESTS_SH+= pkill-F_test
-TAP_TESTS_SH+= pkill-LF_test
-TAP_TESTS_SH+= pkill-P_test
-TAP_TESTS_SH+= pkill-U_test
+TAP_TESTS_SH+= pkill-_f_test
+TAP_TESTS_SH+= pkill-_lf_test
+TAP_TESTS_SH+= pkill-_p_test
+TAP_TESTS_SH+= pkill-_u_test
TAP_TESTS_SH+= pkill-_g_test
TAP_TESTS_SH+= pkill-g_test
TAP_TESTS_SH+= pkill-i_test
diff --git a/bin/pkill/tests/Makefile.depend b/bin/pkill/tests/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/bin/pkill/tests/Makefile.depend
+++ b/bin/pkill/tests/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/bin/pkill/tests/pgrep-F_test.sh b/bin/pkill/tests/pgrep-_f_test.sh
index 4d8feaa34eb2..41fcc9b678e5 100644
--- a/bin/pkill/tests/pgrep-F_test.sh
+++ b/bin/pkill/tests/pgrep-_f_test.sh
@@ -1,5 +1,4 @@
#!/bin/sh
-# $FreeBSD$
base=`basename $0`
diff --git a/bin/pkill/tests/pgrep-_g_test.sh b/bin/pkill/tests/pgrep-_g_test.sh
index fbe7b08161a0..65ad5f5c579b 100644
--- a/bin/pkill/tests/pgrep-_g_test.sh
+++ b/bin/pkill/tests/pgrep-_g_test.sh
@@ -1,5 +1,4 @@
#!/bin/sh
-# $FreeBSD$
base=`basename $0`
diff --git a/bin/pkill/tests/pgrep-LF_test.sh b/bin/pkill/tests/pgrep-_lf_test.sh
index 4818869d8d6e..a9b4b8f08a74 100644
--- a/bin/pkill/tests/pgrep-LF_test.sh
+++ b/bin/pkill/tests/pgrep-_lf_test.sh
@@ -1,5 +1,4 @@
#!/bin/sh
-# $FreeBSD$
base=`basename $0`
diff --git a/bin/pkill/tests/pgrep-P_test.sh b/bin/pkill/tests/pgrep-_p_test.sh
index 5a5cdcf8e97c..e38e490d5f88 100644
--- a/bin/pkill/tests/pgrep-P_test.sh
+++ b/bin/pkill/tests/pgrep-_p_test.sh
@@ -1,5 +1,4 @@
#!/bin/sh
-# $FreeBSD$
base=`basename $0`
diff --git a/bin/pkill/tests/pgrep-_s_test.sh b/bin/pkill/tests/pgrep-_s_test.sh
index ce0bde3d8d12..d151ce51018f 100644
--- a/bin/pkill/tests/pgrep-_s_test.sh
+++ b/bin/pkill/tests/pgrep-_s_test.sh
@@ -1,5 +1,4 @@
#!/bin/sh
-# $FreeBSD$
base=`basename $0`
diff --git a/bin/pkill/tests/pgrep-U_test.sh b/bin/pkill/tests/pgrep-_u_test.sh
index 2e7f24d94659..96e34b7e3666 100644
--- a/bin/pkill/tests/pgrep-U_test.sh
+++ b/bin/pkill/tests/pgrep-_u_test.sh
@@ -1,5 +1,4 @@
#!/bin/sh
-# $FreeBSD$
base=`basename $0`
diff --git a/bin/pkill/tests/pgrep-f_test.sh b/bin/pkill/tests/pgrep-f_test.sh
new file mode 100644
index 000000000000..e92e09ebde0c
--- /dev/null
+++ b/bin/pkill/tests/pgrep-f_test.sh
@@ -0,0 +1,57 @@
+#!/bin/sh
+
+: ${ARG_MAX:=524288}
+base=$(dirname $(realpath "$0"))
+
+echo "1..2"
+
+waitfor() {
+ flagfile=$1
+
+ iter=0
+
+ while [ ! -f ${flagfile} ] && [ ${iter} -lt 50 ]; do
+ sleep 0.10
+ iter=$((iter + 1))
+ done
+
+ if [ ! -f ${flagfile} ]; then
+ return 1
+ fi
+}
+
+sentinel="findme=test-$$"
+sentinelsz=$(printf "${sentinel}" | wc -c | tr -d '[[:space:]]')
+name="pgrep -f"
+spin="${base}/spin_helper"
+flagfile="pgrep_f_short.flag"
+
+${spin} --short ${flagfile} ${sentinel} &
+chpid=$!
+if ! waitfor ${flagfile}; then
+ echo "not ok - $name"
+else
+ pid=$(pgrep -f ${sentinel})
+ if [ "$pid" = "$chpid" ]; then
+ echo "ok - $name"
+ else
+ echo "not ok - $name"
+ fi
+fi
+kill $chpid
+
+name="pgrep -f long args"
+flagfile="pgrep_f_long.flag"
+${spin} --long ${flagfile} ${sentinel} &
+chpid=$!
+if ! waitfor ${flagfile}; then
+ echo "not ok - $name"
+else
+ pid=$(pgrep -f ${sentinel})
+ if [ "$pid" = "$chpid" ]; then
+ echo "ok - $name"
+ else
+ echo "not ok - $name"
+ fi
+fi
+kill $chpid
diff --git a/bin/pkill/tests/pgrep-g_test.sh b/bin/pkill/tests/pgrep-g_test.sh
index 14149082338f..b4cb7ffa4137 100644
--- a/bin/pkill/tests/pgrep-g_test.sh
+++ b/bin/pkill/tests/pgrep-g_test.sh
@@ -1,5 +1,4 @@
#!/bin/sh
-# $FreeBSD$
base=`basename $0`
diff --git a/bin/pkill/tests/pgrep-i_test.sh b/bin/pkill/tests/pgrep-i_test.sh
index b9ecfbc1511d..902a4c0ef045 100644
--- a/bin/pkill/tests/pgrep-i_test.sh
+++ b/bin/pkill/tests/pgrep-i_test.sh
@@ -1,5 +1,4 @@
#!/bin/sh
-# $FreeBSD$
base=`basename $0`
diff --git a/bin/pkill/tests/pgrep-j_test.sh b/bin/pkill/tests/pgrep-j_test.sh
index 5f44109d41b3..cbeb417f6769 100644
--- a/bin/pkill/tests/pgrep-j_test.sh
+++ b/bin/pkill/tests/pgrep-j_test.sh
@@ -1,5 +1,4 @@
#!/bin/sh
-# $FreeBSD$
jail_name_to_jid()
{
diff --git a/bin/pkill/tests/pgrep-l_test.sh b/bin/pkill/tests/pgrep-l_test.sh
index 49273b315b6c..65e9727aead8 100644
--- a/bin/pkill/tests/pgrep-l_test.sh
+++ b/bin/pkill/tests/pgrep-l_test.sh
@@ -1,5 +1,4 @@
#!/bin/sh
-# $FreeBSD$
base=`basename $0`
diff --git a/bin/pkill/tests/pgrep-n_test.sh b/bin/pkill/tests/pgrep-n_test.sh
index 1b6fe8302867..578b76b3af91 100644
--- a/bin/pkill/tests/pgrep-n_test.sh
+++ b/bin/pkill/tests/pgrep-n_test.sh
@@ -1,5 +1,4 @@
#!/bin/sh
-# $FreeBSD$
base=`basename $0`
diff --git a/bin/pkill/tests/pgrep-o_test.sh b/bin/pkill/tests/pgrep-o_test.sh
index 250f230ec84f..d5d95d6ab00b 100644
--- a/bin/pkill/tests/pgrep-o_test.sh
+++ b/bin/pkill/tests/pgrep-o_test.sh
@@ -1,5 +1,4 @@
#!/bin/sh
-# $FreeBSD$
base=`basename $0`
diff --git a/bin/pkill/tests/pgrep-q_test.sh b/bin/pkill/tests/pgrep-q_test.sh
index 2626a5e6bbac..e42acf11a053 100644
--- a/bin/pkill/tests/pgrep-q_test.sh
+++ b/bin/pkill/tests/pgrep-q_test.sh
@@ -1,5 +1,4 @@
#!/bin/sh
-# $FreeBSD$
base=`basename $0`
diff --git a/bin/pkill/tests/pgrep-s_test.sh b/bin/pkill/tests/pgrep-s_test.sh
index 82c1ef98ddb1..9a6d503347b8 100644
--- a/bin/pkill/tests/pgrep-s_test.sh
+++ b/bin/pkill/tests/pgrep-s_test.sh
@@ -1,5 +1,4 @@
#!/bin/sh
-# $FreeBSD$
base=`basename $0`
diff --git a/bin/pkill/tests/pgrep-t_test.sh b/bin/pkill/tests/pgrep-t_test.sh
index a8527d5be611..304cc51bbeaf 100644
--- a/bin/pkill/tests/pgrep-t_test.sh
+++ b/bin/pkill/tests/pgrep-t_test.sh
@@ -1,5 +1,4 @@
#!/bin/sh
-# $FreeBSD$
base=`basename $0`
diff --git a/bin/pkill/tests/pgrep-v_test.sh b/bin/pkill/tests/pgrep-v_test.sh
index b9835bc29f0e..8dce1d37d0c3 100644
--- a/bin/pkill/tests/pgrep-v_test.sh
+++ b/bin/pkill/tests/pgrep-v_test.sh
@@ -1,5 +1,4 @@
#!/bin/sh
-# $FreeBSD$
base=`basename $0`
diff --git a/bin/pkill/tests/pgrep-x_test.sh b/bin/pkill/tests/pgrep-x_test.sh
index 1defde23d962..10a865aeafdf 100644
--- a/bin/pkill/tests/pgrep-x_test.sh
+++ b/bin/pkill/tests/pgrep-x_test.sh
@@ -1,5 +1,4 @@
#!/bin/sh
-# $FreeBSD$
base=`basename $0`
diff --git a/bin/pkill/tests/pkill-F_test.sh b/bin/pkill/tests/pkill-_f_test.sh
index 48ad47456839..c19d3807deb3 100644
--- a/bin/pkill/tests/pkill-F_test.sh
+++ b/bin/pkill/tests/pkill-_f_test.sh
@@ -1,5 +1,4 @@
#!/bin/sh
-# $FreeBSD$
base=`basename $0`
diff --git a/bin/pkill/tests/pkill-_g_test.sh b/bin/pkill/tests/pkill-_g_test.sh
index 1739ac88efa3..34a1edbd0dee 100644
--- a/bin/pkill/tests/pkill-_g_test.sh
+++ b/bin/pkill/tests/pkill-_g_test.sh
@@ -1,5 +1,4 @@
#!/bin/sh
-# $FreeBSD$
base=`basename $0`
diff --git a/bin/pkill/tests/pkill-LF_test.sh b/bin/pkill/tests/pkill-_lf_test.sh
index fcafd0a1ee2a..38bddbcf81df 100644
--- a/bin/pkill/tests/pkill-LF_test.sh
+++ b/bin/pkill/tests/pkill-_lf_test.sh
@@ -1,5 +1,4 @@
#!/bin/sh
-# $FreeBSD$
base=`basename $0`
diff --git a/bin/pkill/tests/pkill-P_test.sh b/bin/pkill/tests/pkill-_p_test.sh
index 2030710af659..7fb46c5c5407 100644
--- a/bin/pkill/tests/pkill-P_test.sh
+++ b/bin/pkill/tests/pkill-_p_test.sh
@@ -1,5 +1,4 @@
#!/bin/sh
-# $FreeBSD$
base=`basename $0`
diff --git a/bin/pkill/tests/pkill-U_test.sh b/bin/pkill/tests/pkill-_u_test.sh
index 04395e559387..5ea4c7257437 100644
--- a/bin/pkill/tests/pkill-U_test.sh
+++ b/bin/pkill/tests/pkill-_u_test.sh
@@ -1,5 +1,4 @@
#!/bin/sh
-# $FreeBSD$
base=`basename $0`
diff --git a/bin/pkill/tests/pkill-g_test.sh b/bin/pkill/tests/pkill-g_test.sh
index 29d6ab77b6ab..2148f4489f0a 100644
--- a/bin/pkill/tests/pkill-g_test.sh
+++ b/bin/pkill/tests/pkill-g_test.sh
@@ -1,5 +1,4 @@
#!/bin/sh
-# $FreeBSD$
base=`basename $0`
diff --git a/bin/pkill/tests/pkill-i_test.sh b/bin/pkill/tests/pkill-i_test.sh
index b9b8df8be459..ae9240596102 100644
--- a/bin/pkill/tests/pkill-i_test.sh
+++ b/bin/pkill/tests/pkill-i_test.sh
@@ -1,5 +1,4 @@
#!/bin/sh
-# $FreeBSD$
base=`basename $0`
diff --git a/bin/pkill/tests/pkill-j_test.sh b/bin/pkill/tests/pkill-j_test.sh
index 1710ca04f653..f279a3ede2f3 100644
--- a/bin/pkill/tests/pkill-j_test.sh
+++ b/bin/pkill/tests/pkill-j_test.sh
@@ -1,5 +1,4 @@
#!/bin/sh
-# $FreeBSD$
jail_name_to_jid()
{
diff --git a/bin/pkill/tests/pkill-s_test.sh b/bin/pkill/tests/pkill-s_test.sh
index 0a9587ba6f16..05b1fe3301f6 100644
--- a/bin/pkill/tests/pkill-s_test.sh
+++ b/bin/pkill/tests/pkill-s_test.sh
@@ -1,5 +1,4 @@
#!/bin/sh
-# $FreeBSD$
base=`basename $0`
diff --git a/bin/pkill/tests/pkill-t_test.sh b/bin/pkill/tests/pkill-t_test.sh
index 07f511bd1ad7..2be1089692e6 100644
--- a/bin/pkill/tests/pkill-t_test.sh
+++ b/bin/pkill/tests/pkill-t_test.sh
@@ -1,5 +1,4 @@
#!/bin/sh
-# $FreeBSD$
base=`basename $0`
diff --git a/bin/pkill/tests/pkill-x_test.sh b/bin/pkill/tests/pkill-x_test.sh
index 5ff0d680a83a..9247a85863c0 100644
--- a/bin/pkill/tests/pkill-x_test.sh
+++ b/bin/pkill/tests/pkill-x_test.sh
@@ -1,5 +1,4 @@
#!/bin/sh
-# $FreeBSD$
base=`basename $0`
diff --git a/bin/pkill/tests/spin_helper.c b/bin/pkill/tests/spin_helper.c
new file mode 100644
index 000000000000..10541ad12516
--- /dev/null
+++ b/bin/pkill/tests/spin_helper.c
@@ -0,0 +1,123 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2023 Klara, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#include <sys/cdefs.h>
+
+#include <err.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <unistd.h>
+
+static int
+exec_shortargs(char *argv[])
+{
+ char *flag_arg = argv[2];
+ char *sentinel = argv[3];
+ char * nargv[] = { argv[0], __DECONST(char *, "--spin"), flag_arg,
+ sentinel, NULL };
+ char * const nenvp[] = { NULL };
+
+ execve(argv[0], nargv, nenvp);
+ err(1, "execve");
+}
+
+static int
+exec_largeargs(char *argv[])
+{
+ char *flag_arg = argv[2];
+ char *sentinel = argv[3];
+ /*
+ * Account for each argument and their NUL terminator, as well as an
+ * extra NUL terminator.
+ */
+ size_t bufsz = ARG_MAX -
+ ((strlen(argv[0]) + 1) + sizeof("--spin") + (strlen(flag_arg) + 1) +
+ (strlen(sentinel) + 1) + 1);
+ char *s = NULL;
+ char * nargv[] = { argv[0], __DECONST(char *, "--spin"), flag_arg, NULL,
+ sentinel, NULL };
+ char * const nenvp[] = { NULL };
+
+ /*
+ * Our heuristic may or may not be accurate, we'll keep trying with
+ * smaller argument sizes as needed until we stop getting E2BIG.
+ */
+ do {
+ if (s == NULL)
+ s = malloc(bufsz + 1);
+ else
+ s = realloc(s, bufsz + 1);
+ if (s == NULL)
+ abort();
+ memset(s, 'x', bufsz);
+ s[bufsz] = '\0';
+ nargv[3] = s;
+
+ execve(argv[0], nargv, nenvp);
+ bufsz--;
+ } while (errno == E2BIG);
+ err(1, "execve");
+}
+
+int
+main(int argc, char *argv[])
+{
+
+ if (argc > 1 && strcmp(argv[1], "--spin") == 0) {
+ int fd;
+
+ if (argc < 4) {
+ fprintf(stderr, "usage: %s --spin flagfile ...\n", argv[0]);
+ return (1);
+ }
+
+ fd = open(argv[2], O_RDWR | O_CREAT, 0755);
+ if (fd < 0)
+ err(1, "%s", argv[2]);
+ close(fd);
+
+ for (;;) {
+ sleep(1);
+ }
+
+ return (1);
+ }
+
+ if (argc != 4) {
+ fprintf(stderr, "usage: %s [--short | --long] flagfile sentinel\n",
+ argv[0]);
+ return (1);
+ }
+
+ if (strcmp(argv[1], "--short") == 0)
+ exec_shortargs(argv);
+ else
+ exec_largeargs(argv);
+}
diff --git a/bin/ps/Makefile b/bin/ps/Makefile
index 596aa57fd2df..23183e4e66b7 100644
--- a/bin/ps/Makefile
+++ b/bin/ps/Makefile
@@ -1,5 +1,3 @@
-# $FreeBSD$
-# @(#)Makefile 8.1 (Berkeley) 6/2/93
PACKAGE=runtime
PROG= ps
diff --git a/bin/ps/Makefile.depend b/bin/ps/Makefile.depend
index eefffb37d491..521210d8ba8e 100644
--- a/bin/ps/Makefile.depend
+++ b/bin/ps/Makefile.depend
@@ -1,18 +1,14 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
- lib/libelf \
lib/libjail \
lib/libkvm \
- lib/libutil \
- lib/libxo \
+ lib/libxo/libxo \
lib/msun \
diff --git a/bin/ps/extern.h b/bin/ps/extern.h
index ea4362eeadd9..9d4630adfdd6 100644
--- a/bin/ps/extern.h
+++ b/bin/ps/extern.h
@@ -27,9 +27,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * @(#)extern.h 8.3 (Berkeley) 4/2/94
- * $FreeBSD$
*/
struct kinfo;
diff --git a/bin/ps/fmt.c b/bin/ps/fmt.c
index c89ea78d7373..87e2e0f49a34 100644
--- a/bin/ps/fmt.c
+++ b/bin/ps/fmt.c
@@ -29,15 +29,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static char sccsid[] = "@(#)fmt.c 8.4 (Berkeley) 4/15/94";
-#endif
-#endif
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
diff --git a/bin/ps/keyword.c b/bin/ps/keyword.c
index e78cf984e455..82c08d3e75f1 100644
--- a/bin/ps/keyword.c
+++ b/bin/ps/keyword.c
@@ -29,14 +29,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static char sccsid[] = "@(#)keyword.c 8.5 (Berkeley) 4/2/94";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/time.h>
#include <sys/resource.h>
diff --git a/bin/ps/nlist.c b/bin/ps/nlist.c
index 5ef56c9dfabc..8c6a4814e4d5 100644
--- a/bin/ps/nlist.c
+++ b/bin/ps/nlist.c
@@ -29,15 +29,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static char sccsid[] = "@(#)nlist.c 8.4 (Berkeley) 4/2/94";
-#endif /* not lint */
-#endif
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/sysctl.h>
diff --git a/bin/ps/print.c b/bin/ps/print.c
index d4dbd9624011..fc6f7ab25428 100644
--- a/bin/ps/print.c
+++ b/bin/ps/print.c
@@ -29,15 +29,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94";
-#endif /* not lint */
-#endif
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/time.h>
#include <sys/resource.h>
diff --git a/bin/ps/ps.1 b/bin/ps/ps.1
index 25373adb7d73..21def154ec00 100644
--- a/bin/ps/ps.1
+++ b/bin/ps/ps.1
@@ -26,10 +26,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)ps.1 8.3 (Berkeley) 4/18/94
-.\" $FreeBSD$
-.\"
-.Dd June 27, 2020
+.Dd November 11, 2023
.Dt PS 1
.Os
.Sh NAME
@@ -40,6 +37,7 @@
.Op Fl -libxo
.Op Fl aCcdefHhjlmrSTuvwXxZ
.Op Fl O Ar fmt | Fl o Ar fmt
+.Op Fl D Ar up | down | both
.Op Fl G Ar gid Ns Op , Ns Ar gid Ns Ar ...
.Op Fl J Ar jid Ns Op , Ns Ar jid Ns Ar ...
.Op Fl M Ar core
@@ -49,7 +47,7 @@
.Op Fl U Ar user Ns Op , Ns Ar user Ns Ar ...
.Nm
.Op Fl -libxo
-.Op Fl L
+.Fl L
.Sh DESCRIPTION
The
.Nm
@@ -65,7 +63,7 @@ will also display processes that do not have controlling terminals.
.Pp
A different set of processes can be selected for display by using any
combination of the
-.Fl a , G , J , p , T , t ,
+.Fl a , D , G , J , p , T , t ,
and
.Fl U
options.
@@ -147,6 +145,18 @@ relative to each other.
Note that this option has no effect if the
.Dq command
column is not the last column displayed.
+.It Fl D
+Expand the list of selected processes based on the process tree.
+.Dq UP
+will add the ancestor processes,
+.Dq DOWN
+will add the descendant processes, and
+.Dq BOTH
+will add both the ancestor and the descendant processes.
+.Fl D
+does not imply
+.Fl d ,
+but works well with it.
.It Fl e
Display the environment as well.
.It Fl f
diff --git a/bin/ps/ps.c b/bin/ps/ps.c
index 89d90b78f2b0..cbee10c20d53 100644
--- a/bin/ps/ps.c
+++ b/bin/ps/ps.c
@@ -36,21 +36,6 @@
* ------+---------+---------+-------- + --------+---------+---------+---------*
*/
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1990, 1993, 1994\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#if 0
-#ifndef lint
-static char sccsid[] = "@(#)ps.c 8.4 (Berkeley) 4/2/94";
-#endif /* not lint */
-#endif
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/jail.h>
#include <sys/proc.h>
@@ -114,7 +99,7 @@ static int needcomm; /* -o "command" */
static int needenv; /* -e */
static int needuser; /* -o "user" */
static int optfatal; /* Fatal error parsing some list-option. */
-static int pid_max; /* kern.max_pid */
+static int pid_max; /* kern.pid_max */
static enum sort { DEFAULT, SORTMEM, SORTCPU } sortby = DEFAULT;
@@ -170,7 +155,7 @@ static char vfmt[] = "pid,state,time,sl,re,pagein,vsz,rss,lim,tsiz,"
"%cpu,%mem,command";
static char Zfmt[] = "label";
-#define PS_ARGS "AaCcde" OPT_LAZY_f "G:gHhjJ:LlM:mN:O:o:p:rSTt:U:uvwXxZ"
+#define PS_ARGS "AaCcD:de" OPT_LAZY_f "G:gHhjJ:LlM:mN:O:o:p:rSTt:U:uvwXxZ"
int
main(int argc, char *argv[])
@@ -190,6 +175,8 @@ main(int argc, char *argv[])
int fwidthmin, fwidthmax;
char errbuf[_POSIX2_LINE_MAX];
char fmtbuf[_POSIX2_LINE_MAX];
+ enum { NONE = 0, UP = 1, DOWN = 2, BOTH = 1 | 2 } directions = NONE;
+ struct { int traversed; int initial; } pid_count;
(void) setlocale(LC_ALL, "");
time(&now); /* Used by routines in print.c. */
@@ -264,6 +251,20 @@ main(int argc, char *argv[])
case 'c':
cflag = 1;
break;
+ case 'D': {
+ size_t len = strlen(optarg);
+
+ if (len <= 2 &&
+ strncasecmp(optarg, "up", len) == 0)
+ directions |= UP;
+ else if (len <= 4 &&
+ strncasecmp(optarg, "down", len) == 0)
+ directions |= DOWN;
+ else if (len <= 4 &&
+ strncasecmp(optarg, "both", len) == 0)
+ directions |= BOTH;
+ break;
+ }
case 'd':
descendancy = 1;
break;
@@ -504,7 +505,7 @@ main(int argc, char *argv[])
what = KERN_PROC_PGRP | showthreads;
flag = *pgrplist.l.pids;
nselectors = 0;
- } else if (pidlist.count == 1 && !descendancy) {
+ } else if (pidlist.count == 1 && directions == NONE) {
what = KERN_PROC_PID | showthreads;
flag = *pidlist.l.pids;
nselectors = 0;
@@ -539,14 +540,33 @@ main(int argc, char *argv[])
if ((kp == NULL && errno != ESRCH) || (kp != NULL && nentries < 0))
xo_errx(1, "%s", kvm_geterr(kd));
nkept = 0;
- if (descendancy)
+ pid_count.initial = pidlist.count;
+ if (directions & DOWN)
for (elem = 0; elem < pidlist.count; elem++)
- for (i = 0; i < nentries; i++)
+ for (i = 0; i < nentries; i++) {
+ if (kp[i].ki_ppid == kp[i].ki_pid)
+ continue;
if (kp[i].ki_ppid == pidlist.l.pids[elem]) {
if (pidlist.count >= pidlist.maxcount)
expand_list(&pidlist);
pidlist.l.pids[pidlist.count++] = kp[i].ki_pid;
}
+ }
+ pid_count.traversed = pidlist.count;
+ if (directions & UP)
+ for (elem = 0; elem < pidlist.count; elem++) {
+ if (elem >= pid_count.initial && elem < pid_count.traversed)
+ continue;
+ for (i = 0; i < nentries; i++) {
+ if (kp[i].ki_ppid == kp[i].ki_pid)
+ continue;
+ if (kp[i].ki_pid == pidlist.l.pids[elem]) {
+ if (pidlist.count >= pidlist.maxcount)
+ expand_list(&pidlist);
+ pidlist.l.pids[pidlist.count++] = kp[i].ki_ppid;
+ }
+ }
+ }
if (nentries > 0) {
if ((kinfo = malloc(nentries * sizeof(*kinfo))) == NULL)
xo_errx(1, "malloc failed");
@@ -1458,10 +1478,11 @@ usage(void)
{
#define SINGLE_OPTS "[-aCcde" OPT_LAZY_f "HhjlmrSTuvwXxZ]"
- (void)xo_error("%s\n%s\n%s\n%s\n",
- "usage: ps " SINGLE_OPTS " [-O fmt | -o fmt] [-G gid[,gid...]]",
- " [-J jid[,jid...]] [-M core] [-N system]",
+ (void)xo_error("%s\n%s\n%s\n%s\n%s\n",
+ "usage: ps [--libxo] " SINGLE_OPTS " [-O fmt | -o fmt]",
+ " [-G gid[,gid...]] [-J jid[,jid...]] [-M core] [-N system]",
" [-p pid[,pid...]] [-t tty[,tty...]] [-U user[,user...]]",
- " ps [-L]");
+ " [-D up | down | both]",
+ " ps [--libxo] -L");
exit(1);
}
diff --git a/bin/ps/ps.h b/bin/ps/ps.h
index 03e38af9d517..521027427036 100644
--- a/bin/ps/ps.h
+++ b/bin/ps/ps.h
@@ -27,9 +27,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * @(#)ps.h 8.1 (Berkeley) 5/31/93
- * $FreeBSD$
*/
#include <sys/queue.h>
diff --git a/bin/pwait/Makefile b/bin/pwait/Makefile
index 210ae3cdb918..de3d5481fd40 100644
--- a/bin/pwait/Makefile
+++ b/bin/pwait/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/bin/pwait/Makefile.depend b/bin/pwait/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/bin/pwait/Makefile.depend
+++ b/bin/pwait/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/bin/pwait/pwait.1 b/bin/pwait/pwait.1
index b9b651bfc905..83ac8bcef317 100644
--- a/bin/pwait/pwait.1
+++ b/bin/pwait/pwait.1
@@ -30,8 +30,6 @@
.\" USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
.\" OF SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd January 21, 2021
.Dt PWAIT 1
.Os
@@ -99,7 +97,7 @@ $ sleep 30 & sleep 3600 &
[1] 1646
[2] 1647
$ pwait -o -t5 1646 1647
-$?
+$ echo $?
124
.Ed
.Pp
@@ -113,7 +111,7 @@ $ sleep 30 & sleep 3600 &
[2] 1653
$ pwait -v -t 5 1652 1653
timeout
-$?
+$ echo $?
124
.Ed
.Pp
diff --git a/bin/pwait/pwait.c b/bin/pwait/pwait.c
index 66919ffa1c42..0fae22562607 100644
--- a/bin/pwait/pwait.c
+++ b/bin/pwait/pwait.c
@@ -31,9 +31,6 @@
* OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/event.h>
#include <sys/time.h>
diff --git a/bin/pwait/tests/Makefile b/bin/pwait/tests/Makefile
index db05b1f1051c..8e916ae47b38 100644
--- a/bin/pwait/tests/Makefile
+++ b/bin/pwait/tests/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
ATF_TESTS_SH= pwait_test
diff --git a/bin/pwait/tests/Makefile.depend b/bin/pwait/tests/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/bin/pwait/tests/Makefile.depend
+++ b/bin/pwait/tests/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/bin/pwait/tests/pwait_test.sh b/bin/pwait/tests/pwait_test.sh
index 07ed21706fd5..a726c467f57e 100644
--- a/bin/pwait/tests/pwait_test.sh
+++ b/bin/pwait/tests/pwait_test.sh
@@ -1,4 +1,3 @@
-# $FreeBSD$
atf_test_case basic
basic_head()
diff --git a/bin/pwd/Makefile b/bin/pwd/Makefile
index 2a623a16b3ae..b46f7c19f6a0 100644
--- a/bin/pwd/Makefile
+++ b/bin/pwd/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.1 (Berkeley) 5/31/93
-# $FreeBSD$
PACKAGE=runtime
PROG= pwd
diff --git a/bin/pwd/Makefile.depend b/bin/pwd/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/bin/pwd/Makefile.depend
+++ b/bin/pwd/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/bin/pwd/pwd.1 b/bin/pwd/pwd.1
index 2c27fcff9467..ce81e443d98e 100644
--- a/bin/pwd/pwd.1
+++ b/bin/pwd/pwd.1
@@ -29,10 +29,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)pwd.1 8.2 (Berkeley) 4/28/95
-.\" $FreeBSD$
-.\"
-.Dd October 24, 2020
+.Dd May 22, 2023
.Dt PWD 1
.Os
.Sh NAME
@@ -78,20 +75,20 @@ Logical current working directory.
Show current working directory with symbolic links resolved:
.Bd -literal -offset indent
$ /bin/pwd
-/usr/home/fernape
+/usr/src/sys/kern
.Ed
.Pp
Show the logical current directory.
Then use
.Xr file 1
to inspect the
-.Pa /home
+.Pa /sys
directory:
.Bd -literal -offset indent
$ /bin/pwd -L
-/home/fernape
-$ file /home
-/home: symbolic link to usr/home
+/sys/kern
+$ file /sys
+/sys: symbolic link to usr/src/sys
.Ed
.Sh SEE ALSO
.Xr builtin 1 ,
diff --git a/bin/pwd/pwd.c b/bin/pwd/pwd.c
index cfa6c0b909b2..a49c638b1dee 100644
--- a/bin/pwd/pwd.c
+++ b/bin/pwd/pwd.c
@@ -29,20 +29,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static char const copyright[] =
-"@(#) Copyright (c) 1991, 1993, 1994\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "@(#)pwd.c 8.3 (Berkeley) 4/1/94";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/types.h>
diff --git a/bin/realpath/Makefile b/bin/realpath/Makefile
index 71381f3359d0..bda6bff8a66b 100644
--- a/bin/realpath/Makefile
+++ b/bin/realpath/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE=runtime
PROG= realpath
diff --git a/bin/realpath/Makefile.depend b/bin/realpath/Makefile.depend
index cae7e645ef6a..93249906da4f 100644
--- a/bin/realpath/Makefile.depend
+++ b/bin/realpath/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
lib/${CSU_DIR} \
lib/libc \
diff --git a/bin/realpath/realpath.1 b/bin/realpath/realpath.1
index f9ba929d7fc6..96b70f2ac928 100644
--- a/bin/realpath/realpath.1
+++ b/bin/realpath/realpath.1
@@ -28,10 +28,7 @@
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
-.\"
-.\" @(#)pwd.1 8.2 (Berkeley) 4/28/95
.\" From: src/bin/pwd/pwd.1,v 1.11 2000/11/20 11:39:39 ru Exp
-.\" $FreeBSD$
.\"
.Dd June 21, 2011
.Dt REALPATH 1
diff --git a/bin/realpath/realpath.c b/bin/realpath/realpath.c
index bc060bf1453c..9ee7f3126003 100644
--- a/bin/realpath/realpath.c
+++ b/bin/realpath/realpath.c
@@ -29,9 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <err.h>
diff --git a/bin/rm/Makefile b/bin/rm/Makefile
index b044ba86e55e..777254eb548a 100644
--- a/bin/rm/Makefile
+++ b/bin/rm/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.1 (Berkeley) 5/31/93
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/bin/rm/Makefile.depend b/bin/rm/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/bin/rm/Makefile.depend
+++ b/bin/rm/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/bin/rm/rm.1 b/bin/rm/rm.1
index 7566a89a725f..8b8677e4a170 100644
--- a/bin/rm/rm.1
+++ b/bin/rm/rm.1
@@ -29,9 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)rm.1 8.5 (Berkeley) 12/5/94
-.\" $FreeBSD$
-.\"
.Dd November 10, 2018
.Dt RM 1
.Os
diff --git a/bin/rm/rm.c b/bin/rm/rm.c
index 111f4a1326c4..16bbf7403fd4 100644
--- a/bin/rm/rm.c
+++ b/bin/rm/rm.c
@@ -29,20 +29,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1990, 1993, 1994\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "@(#)rm.c 8.5 (Berkeley) 4/18/94";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/stat.h>
#include <sys/param.h>
#include <sys/mount.h>
diff --git a/bin/rm/tests/Makefile b/bin/rm/tests/Makefile
index aa0984b529d5..7ff149da0ab1 100644
--- a/bin/rm/tests/Makefile
+++ b/bin/rm/tests/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
ATF_TESTS_SH+= rm_test
diff --git a/bin/rm/tests/Makefile.depend b/bin/rm/tests/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/bin/rm/tests/Makefile.depend
+++ b/bin/rm/tests/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/bin/rm/tests/rm_test.sh b/bin/rm/tests/rm_test.sh
index 31ee64961a97..0bb8497b6092 100755
--- a/bin/rm/tests/rm_test.sh
+++ b/bin/rm/tests/rm_test.sh
@@ -22,7 +22,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
atf_test_case unlink_dash_filename
diff --git a/bin/rmail/Makefile b/bin/rmail/Makefile
index 21f3ceb16582..1d0b26eb66d4 100644
--- a/bin/rmail/Makefile
+++ b/bin/rmail/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.1 (Berkeley) 5/31/93
-# $FreeBSD$
PACKAGE=sendmail
SENDMAIL_DIR=${SRCTOP}/contrib/sendmail
@@ -34,3 +32,5 @@ sm_os.h: ${SENDMAIL_DIR}/include/sm/os/sm_os_freebsd.h .NOMETA
ln -sf ${.ALLSRC} ${.TARGET}
.include <bsd.prog.mk>
+
+CWARNFLAGS+= ${NO_WDEPRECATED_NON_PROTOTYPE}
diff --git a/bin/rmail/Makefile.depend b/bin/rmail/Makefile.depend
index e07330e48118..edde60b1dd6a 100644
--- a/bin/rmail/Makefile.depend
+++ b/bin/rmail/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/bin/rmdir/Makefile b/bin/rmdir/Makefile
index 9a081323f813..319d89ff7117 100644
--- a/bin/rmdir/Makefile
+++ b/bin/rmdir/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.1 (Berkeley) 5/31/93
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/bin/rmdir/Makefile.depend b/bin/rmdir/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/bin/rmdir/Makefile.depend
+++ b/bin/rmdir/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/bin/rmdir/rmdir.1 b/bin/rmdir/rmdir.1
index f71f4bb404f4..87ca1f1547f0 100644
--- a/bin/rmdir/rmdir.1
+++ b/bin/rmdir/rmdir.1
@@ -29,9 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)rmdir.1 8.1 (Berkeley) 5/31/93
-.\" $FreeBSD$
-.\"
.Dd March 15, 2013
.Dt RMDIR 1
.Os
diff --git a/bin/rmdir/rmdir.c b/bin/rmdir/rmdir.c
index 22f1141e14ec..c5d3db831309 100644
--- a/bin/rmdir/rmdir.c
+++ b/bin/rmdir/rmdir.c
@@ -29,20 +29,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static char const copyright[] =
-"@(#) Copyright (c) 1992, 1993, 1994\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "@(#)rmdir.c 8.3 (Berkeley) 4/2/94";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
@@ -50,7 +36,7 @@ __FBSDID("$FreeBSD$");
#include <unistd.h>
static int rm_path(char *);
-static void usage(void);
+static void usage(void) __dead2;
static int pflag;
static int vflag;
diff --git a/bin/rmdir/tests/Makefile b/bin/rmdir/tests/Makefile
index abf3a1e02a37..b8be667b83a0 100644
--- a/bin/rmdir/tests/Makefile
+++ b/bin/rmdir/tests/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
ATF_TESTS_SH+= rmdir_test
diff --git a/bin/rmdir/tests/Makefile.depend b/bin/rmdir/tests/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/bin/rmdir/tests/Makefile.depend
+++ b/bin/rmdir/tests/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/bin/rmdir/tests/rmdir_test.sh b/bin/rmdir/tests/rmdir_test.sh
index 204039c28311..d443849258b6 100644
--- a/bin/rmdir/tests/rmdir_test.sh
+++ b/bin/rmdir/tests/rmdir_test.sh
@@ -23,7 +23,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
usage_output='usage: rmdir'
diff --git a/bin/setfacl/Makefile b/bin/setfacl/Makefile
index 378541398e5b..5b9d615caf80 100644
--- a/bin/setfacl/Makefile
+++ b/bin/setfacl/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE=runtime
PROG= setfacl
diff --git a/bin/setfacl/Makefile.depend b/bin/setfacl/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/bin/setfacl/Makefile.depend
+++ b/bin/setfacl/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/bin/setfacl/file.c b/bin/setfacl/file.c
index f7e9672c3ce8..24ef3869cf4c 100644
--- a/bin/setfacl/file.c
+++ b/bin/setfacl/file.c
@@ -24,9 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/acl.h>
diff --git a/bin/setfacl/mask.c b/bin/setfacl/mask.c
index 4dd85f039d0f..5154b17fb5bc 100644
--- a/bin/setfacl/mask.c
+++ b/bin/setfacl/mask.c
@@ -24,9 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/acl.h>
#include <sys/stat.h>
diff --git a/bin/setfacl/merge.c b/bin/setfacl/merge.c
index 604e6fb693c2..d77a52ed2f25 100644
--- a/bin/setfacl/merge.c
+++ b/bin/setfacl/merge.c
@@ -24,9 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/acl.h>
#include <sys/stat.h>
diff --git a/bin/setfacl/remove.c b/bin/setfacl/remove.c
index 9c86096da41d..5bfab9c2ec9d 100644
--- a/bin/setfacl/remove.c
+++ b/bin/setfacl/remove.c
@@ -24,9 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/acl.h>
#include <sys/stat.h>
diff --git a/bin/setfacl/setfacl.1 b/bin/setfacl/setfacl.1
index 31040a61558c..b021f850913a 100644
--- a/bin/setfacl/setfacl.1
+++ b/bin/setfacl/setfacl.1
@@ -24,9 +24,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
-.Dd October 26, 2018
+.Dd April 29, 2023
.Dt SETFACL 1
.Os
.Sh NAME
@@ -331,7 +329,7 @@ In entries whose tag type is one of
.Dq Li group@ ,
or
.Dq Li everyone@ ,
-this field is omitted altogether, including the trailing comma.
+this field is omitted altogether, including the trailing colon.
.It Ar "access permissions"
Access permissions may be specified in either short or long form.
Short and long forms may not be mixed.
diff --git a/bin/setfacl/setfacl.c b/bin/setfacl/setfacl.c
index 033f9d2572ca..ef3f58b326a3 100644
--- a/bin/setfacl/setfacl.c
+++ b/bin/setfacl/setfacl.c
@@ -24,9 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/acl.h>
#include <sys/queue.h>
@@ -462,7 +459,6 @@ main(int argc, char *argv[])
break;
default:
usage();
- break;
}
argc -= optind;
argv += optind;
diff --git a/bin/setfacl/setfacl.h b/bin/setfacl/setfacl.h
index 5ea794d44c74..b7e7cfd8ca1d 100644
--- a/bin/setfacl/setfacl.h
+++ b/bin/setfacl/setfacl.h
@@ -22,8 +22,6 @@
* LIABILITY, OR TORT (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$
*/
#ifndef _SETFACL_H
diff --git a/bin/setfacl/util.c b/bin/setfacl/util.c
index 8a78259c1ae7..ee28b9d5503e 100644
--- a/bin/setfacl/util.c
+++ b/bin/setfacl/util.c
@@ -25,8 +25,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <err.h>
#include <stdlib.h>
diff --git a/bin/sh/Makefile b/bin/sh/Makefile
index b074121d0ecd..d2043ecad269 100644
--- a/bin/sh/Makefile
+++ b/bin/sh/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.4 (Berkeley) 5/5/95
-# $FreeBSD$
.include <src.opts.mk>
@@ -7,6 +5,7 @@ CONFGROUPS= ETC ROOT
ETC= profile
ROOT= dot.shrc dot.profile
ROOTDIR= /root
+ROOTDIR_MODE= 0750
ROOTNAME_dot.shrc= .shrc
ROOTNAME_dot.profile= .profile
PACKAGE=runtime
@@ -39,24 +38,30 @@ CFLAGS+=-DSHELL -I. -I${.CURDIR}
CLEANFILES+= mknodes mksyntax
CLEANFILES+= ${GENSRCS} ${GENHDRS}
+.if ${MACHINE} == "host" || ${MK_DIRDEPS_BUILD} == "no"
build-tools: mknodes mksyntax
+DEPENDOBJS+= mknodes mksyntax
+mknodes mksyntax: ${BUILD_TOOLS_META}
+builtins.c builtins.h: mkbuiltins
+syntax.c syntax.h: mksyntax
+nodes.c nodes.h: mknodes
+.endif
+
.ORDER: builtins.c builtins.h
builtins.h: .NOMETA
-builtins.c builtins.h: mkbuiltins builtins.def
+builtins.c builtins.h: builtins.def
sh ${.CURDIR}/mkbuiltins ${.CURDIR}
-DEPENDOBJS+= mknodes mksyntax
-mknodes mksyntax: ${BUILD_TOOLS_META}
.ORDER: nodes.c nodes.h
nodes.h: .NOMETA
-nodes.c nodes.h: mknodes nodetypes nodes.c.pat
+nodes.c nodes.h: nodetypes nodes.c.pat
${BTOOLSPATH:U.}/mknodes ${.CURDIR}/nodetypes ${.CURDIR}/nodes.c.pat
.ORDER: syntax.c syntax.h
syntax.h: .NOMETA
-syntax.c syntax.h: mksyntax
+syntax.c syntax.h:
${BTOOLSPATH:U.}/mksyntax
token.h: mktokens
@@ -68,6 +73,7 @@ SUBDIR.${MK_TESTS}+= tests
beforeinstallconfig:
rm -f ${DESTDIR}/.profile
+LINKMODE=${CONFMODE}
afterinstallconfig:
${INSTALL_LINK} ${TAG_ARGS} ${DESTDIR}/root/.profile ${DESTDIR}/.profile
diff --git a/bin/sh/Makefile.depend b/bin/sh/Makefile.depend
index 0e0490b10835..17be3d459f0c 100644
--- a/bin/sh/Makefile.depend
+++ b/bin/sh/Makefile.depend
@@ -1,15 +1,14 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
+ bin/sh.host \
include \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
lib/libedit \
- lib/ncurses/ncursesw \
+ usr.bin/awk.host \
.include <dirdeps.mk>
diff --git a/bin/sh/TOUR b/bin/sh/TOUR
index 8f7a741ba5c4..37bed64b4080 100644
--- a/bin/sh/TOUR
+++ b/bin/sh/TOUR
@@ -1,5 +1,3 @@
-# @(#)TOUR 8.1 (Berkeley) 5/31/93
-# $FreeBSD$
NOTE -- This is the original TOUR paper distributed with ash and
does not represent the current state of the shell. It is provided anyway
diff --git a/bin/sh/alias.c b/bin/sh/alias.c
index bbcf5fbe17e3..a02554d66e24 100644
--- a/bin/sh/alias.c
+++ b/bin/sh/alias.c
@@ -30,14 +30,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)alias.c 8.3 (Berkeley) 5/4/95";
-#endif
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <stdlib.h>
#include "shell.h"
#include "output.h"
@@ -55,7 +47,7 @@ static int aliases;
static void setalias(const char *, const char *);
static int unalias(const char *);
-static struct alias **hashalias(const char *);
+static size_t hashalias(const char *);
static
void
@@ -64,7 +56,7 @@ setalias(const char *name, const char *val)
struct alias *ap, **app;
unalias(name);
- app = hashalias(name);
+ app = &atab[hashalias(name)];
INTOFF;
ap = ckmalloc(sizeof (struct alias));
ap->name = savestr(name);
@@ -89,7 +81,7 @@ unalias(const char *name)
{
struct alias *ap, **app;
- app = hashalias(name);
+ app = &atab[hashalias(name)];
for (ap = *app; ap; app = &(ap->next), ap = ap->next) {
if (equal(name, ap->name)) {
@@ -147,7 +139,7 @@ lookupalias(const char *name, int check)
if (aliases == 0)
return (NULL);
- for (ap = *hashalias(name); ap; ap = ap->next) {
+ for (ap = atab[hashalias(name)]; ap; ap = ap->next) {
if (equal(name, ap->name)) {
if (check && (ap->flag & ALIASINUSE))
return (NULL);
@@ -244,7 +236,7 @@ unaliascmd(int argc __unused, char **argv __unused)
return (i);
}
-static struct alias **
+static size_t
hashalias(const char *p)
{
unsigned int hashval;
@@ -252,5 +244,22 @@ hashalias(const char *p)
hashval = (unsigned char)*p << 4;
while (*p)
hashval+= *p++;
- return &atab[hashval % ATABSIZE];
+ return (hashval % ATABSIZE);
+}
+
+const struct alias *
+iteralias(const struct alias *index)
+{
+ size_t i = 0;
+
+ if (index != NULL) {
+ if (index->next != NULL)
+ return (index->next);
+ i = hashalias(index->name) + 1;
+ }
+ for (; i < ATABSIZE; i++)
+ if (atab[i] != NULL)
+ return (atab[i]);
+
+ return (NULL);
}
diff --git a/bin/sh/alias.h b/bin/sh/alias.h
index 92de705bc963..d0644b317472 100644
--- a/bin/sh/alias.h
+++ b/bin/sh/alias.h
@@ -28,9 +28,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * @(#)alias.h 8.2 (Berkeley) 5/4/95
- * $FreeBSD$
*/
#define ALIASINUSE 1
@@ -43,3 +40,4 @@ struct alias {
};
struct alias *lookupalias(const char *, int);
+const struct alias *iteralias(const struct alias *);
diff --git a/bin/sh/arith.h b/bin/sh/arith.h
index 569d0c58651f..3a7521956c09 100644
--- a/bin/sh/arith.h
+++ b/bin/sh/arith.h
@@ -25,9 +25,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * @(#)arith.h 1.1 (Berkeley) 5/4/95
- * $FreeBSD$
*/
#include "shell.h"
diff --git a/bin/sh/arith_yacc.c b/bin/sh/arith_yacc.c
index a08163bdc29b..cb88cdb4cbea 100644
--- a/bin/sh/arith_yacc.c
+++ b/bin/sh/arith_yacc.c
@@ -33,8 +33,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <limits.h>
#include <errno.h>
#include <inttypes.h>
diff --git a/bin/sh/arith_yacc.h b/bin/sh/arith_yacc.h
index 7fdd99b75b57..3203c664a8a8 100644
--- a/bin/sh/arith_yacc.h
+++ b/bin/sh/arith_yacc.h
@@ -30,8 +30,6 @@
* LIABILITY, OR TORT (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$
*/
#define ARITH_ASS 1
diff --git a/bin/sh/arith_yylex.c b/bin/sh/arith_yylex.c
index 9f320dbcb585..68a641d807af 100644
--- a/bin/sh/arith_yylex.c
+++ b/bin/sh/arith_yylex.c
@@ -33,8 +33,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <ctype.h>
#include <errno.h>
#include <inttypes.h>
diff --git a/bin/sh/bltin/bltin.h b/bin/sh/bltin/bltin.h
index 8149895815dd..8d541ed1e138 100644
--- a/bin/sh/bltin/bltin.h
+++ b/bin/sh/bltin/bltin.h
@@ -30,9 +30,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * @(#)bltin.h 8.2 (Berkeley) 5/4/95
- * $FreeBSD$
*/
/*
diff --git a/bin/sh/bltin/echo.c b/bin/sh/bltin/echo.c
index e8046c7615ec..648965ba78fa 100644
--- a/bin/sh/bltin/echo.c
+++ b/bin/sh/bltin/echo.c
@@ -30,13 +30,9 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * @(#)echo.c 8.2 (Berkeley) 5/4/95
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* Echo command.
*/
diff --git a/bin/sh/builtins.def b/bin/sh/builtins.def
index f38af0f24dce..00f363bfb1c7 100644
--- a/bin/sh/builtins.def
+++ b/bin/sh/builtins.def
@@ -30,9 +30,6 @@
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
-#
-# @(#)builtins.def 8.4 (Berkeley) 5/4/95
-# $FreeBSD$
#
# This file lists all the builtin commands. The first column is the name
diff --git a/bin/sh/cd.c b/bin/sh/cd.c
index 66eee00b2c24..b908c4320c04 100644
--- a/bin/sh/cd.c
+++ b/bin/sh/cd.c
@@ -30,14 +30,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)cd.c 8.2 (Berkeley) 5/4/95";
-#endif
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
diff --git a/bin/sh/cd.h b/bin/sh/cd.h
index a82d6370d57c..e2f8ca54748e 100644
--- a/bin/sh/cd.h
+++ b/bin/sh/cd.h
@@ -25,8 +25,6 @@
* LIABILITY, OR TORT (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$
*/
void pwd_init(int);
diff --git a/bin/sh/dot.profile b/bin/sh/dot.profile
index e296a360bcc7..d27a2ae2fdbe 100644
--- a/bin/sh/dot.profile
+++ b/bin/sh/dot.profile
@@ -1,4 +1,3 @@
-# $FreeBSD$
#
HOME=/root
export HOME
diff --git a/bin/sh/dot.shrc b/bin/sh/dot.shrc
index 75d0ec047734..2bcedf44a40e 100644
--- a/bin/sh/dot.shrc
+++ b/bin/sh/dot.shrc
@@ -1,4 +1,3 @@
-# $FreeBSD$
#
# .shrc - bourne shell startup file
#
diff --git a/bin/sh/error.c b/bin/sh/error.c
index a6b407907e20..fcc2f309ccbc 100644
--- a/bin/sh/error.c
+++ b/bin/sh/error.c
@@ -30,14 +30,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)error.c 8.2 (Berkeley) 5/4/95";
-#endif
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* Errors and exceptions.
*/
diff --git a/bin/sh/error.h b/bin/sh/error.h
index 3a79dec81b9d..cb64ec85c09f 100644
--- a/bin/sh/error.h
+++ b/bin/sh/error.h
@@ -28,9 +28,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * @(#)error.h 8.2 (Berkeley) 5/4/95
- * $FreeBSD$
*/
/*
diff --git a/bin/sh/eval.c b/bin/sh/eval.c
index 58cfc522bb14..fdc7a2560694 100644
--- a/bin/sh/eval.c
+++ b/bin/sh/eval.c
@@ -30,14 +30,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)eval.c 8.9 (Berkeley) 6/8/95";
-#endif
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <paths.h>
#include <signal.h>
#include <stdlib.h>
@@ -907,7 +899,7 @@ evalcommand(union node *cmd, int flags, struct backcmd *backcmd)
* so we just delete the hash before and after
* the command runs. Partly deleting like
* changepatch() does doesn't seem worth the
- * bookinging effort, since most such runs add
+ * booking effort, since most such runs add
* directories in front of the new PATH.
*/
clearcmdentry();
diff --git a/bin/sh/eval.h b/bin/sh/eval.h
index d8a12eb79c7f..9a47e9a8db23 100644
--- a/bin/sh/eval.h
+++ b/bin/sh/eval.h
@@ -28,9 +28,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * @(#)eval.h 8.2 (Berkeley) 5/4/95
- * $FreeBSD$
*/
extern char *commandname; /* currently executing command */
diff --git a/bin/sh/exec.c b/bin/sh/exec.c
index 43095a252a35..f7788d0758e3 100644
--- a/bin/sh/exec.c
+++ b/bin/sh/exec.c
@@ -30,14 +30,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)exec.c 8.4 (Berkeley) 6/8/95";
-#endif
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
@@ -547,6 +539,19 @@ clearcmdentry(void)
}
+static unsigned int
+hashname(const char *p)
+{
+ unsigned int hashval;
+
+ hashval = (unsigned char)*p << 4;
+ while (*p)
+ hashval += *p++;
+
+ return (hashval % CMDTABLESIZE);
+}
+
+
/*
* Locate a command in the command hash table. If "add" is nonzero,
* add the command to the table if it is not already present. The
@@ -561,17 +566,11 @@ static struct tblentry **lastcmdentry;
static struct tblentry *
cmdlookup(const char *name, int add)
{
- unsigned int hashval;
- const char *p;
struct tblentry *cmdp;
struct tblentry **pp;
size_t len;
- p = name;
- hashval = (unsigned char)*p << 4;
- while (*p)
- hashval += *p++;
- pp = &cmdtable[hashval % CMDTABLESIZE];
+ pp = &cmdtable[hashname(name)];
for (cmdp = *pp ; cmdp ; cmdp = cmdp->next) {
if (equal(cmdp->cmdname, name))
break;
@@ -590,6 +589,31 @@ cmdlookup(const char *name, int add)
return cmdp;
}
+const void *
+itercmd(const void *entry, struct cmdentry *result)
+{
+ const struct tblentry *e = entry;
+ size_t i = 0;
+
+ if (e != NULL) {
+ if (e->next != NULL) {
+ e = e->next;
+ goto success;
+ }
+ i = hashname(e->cmdname) + 1;
+ }
+ for (; i < CMDTABLESIZE; i++)
+ if ((e = cmdtable[i]) != NULL)
+ goto success;
+
+ return (NULL);
+success:
+ result->cmdtype = e->cmdtype;
+ result->cmdname = e->cmdname;
+
+ return (e);
+}
+
/*
* Delete the command entry returned on the last lookup.
*/
diff --git a/bin/sh/exec.h b/bin/sh/exec.h
index 03e7e6ab0b0c..ff4d5b3c20bc 100644
--- a/bin/sh/exec.h
+++ b/bin/sh/exec.h
@@ -28,9 +28,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * @(#)exec.h 8.3 (Berkeley) 6/8/95
- * $FreeBSD$
*/
/* values of cmdtype */
@@ -54,6 +51,7 @@ struct cmdentry {
struct funcdef *func;
} u;
int special;
+ const char *cmdname;
};
@@ -72,3 +70,4 @@ int unsetfunc(const char *);
int isfunc(const char *);
int typecmd_impl(int, char **, int, const char *);
void clearcmdentry(void);
+const void *itercmd(const void *, struct cmdentry *);
diff --git a/bin/sh/expand.c b/bin/sh/expand.c
index 922bf5c3c4e8..dfafe35fbaca 100644
--- a/bin/sh/expand.c
+++ b/bin/sh/expand.c
@@ -34,14 +34,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)expand.c 8.5 (Berkeley) 5/15/95";
-#endif
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/time.h>
#include <sys/stat.h>
diff --git a/bin/sh/expand.h b/bin/sh/expand.h
index a60ea29514d2..972032583958 100644
--- a/bin/sh/expand.h
+++ b/bin/sh/expand.h
@@ -28,9 +28,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * @(#)expand.h 8.2 (Berkeley) 5/4/95
- * $FreeBSD$
*/
struct arglist {
diff --git a/bin/sh/funcs/cmv b/bin/sh/funcs/cmv
index 815861eb5ebb..a87fcf8b7757 100644
--- a/bin/sh/funcs/cmv
+++ b/bin/sh/funcs/cmv
@@ -30,9 +30,6 @@
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
-#
-# @(#)cmv 8.2 (Berkeley) 5/4/95
-# $FreeBSD$
# Conditional move--don't replace an existing file.
diff --git a/bin/sh/funcs/dirs b/bin/sh/funcs/dirs
index cac4c59af088..816230386725 100644
--- a/bin/sh/funcs/dirs
+++ b/bin/sh/funcs/dirs
@@ -30,9 +30,6 @@
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
-#
-# @(#)dirs 8.2 (Berkeley) 5/4/95
-# $FreeBSD$
# pushd, popd, and dirs --- written by Chris Bertin
# Pixel Computer Inc. ...!wjh12!pixel!pixutl!chris
diff --git a/bin/sh/funcs/login b/bin/sh/funcs/login
index 055bbe5a8fad..1569f88cb6be 100644
--- a/bin/sh/funcs/login
+++ b/bin/sh/funcs/login
@@ -30,9 +30,6 @@
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
-#
-# @(#)login 8.2 (Berkeley) 5/4/95
-# $FreeBSD$
# replaces the login builtin in the BSD shell
login () exec login "$@"
diff --git a/bin/sh/funcs/newgrp b/bin/sh/funcs/newgrp
index d1f8b84800d8..ab7d202940e5 100644
--- a/bin/sh/funcs/newgrp
+++ b/bin/sh/funcs/newgrp
@@ -30,8 +30,5 @@
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
-#
-# @(#)newgrp 8.2 (Berkeley) 5/4/95
-# $FreeBSD$
newgrp() exec newgrp "$@"
diff --git a/bin/sh/funcs/popd b/bin/sh/funcs/popd
index 805a4aff4f94..816230386725 100644
--- a/bin/sh/funcs/popd
+++ b/bin/sh/funcs/popd
@@ -30,9 +30,6 @@
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
-#
-# @(#)popd 8.2 (Berkeley) 5/4/95
-# $FreeBSD$
# pushd, popd, and dirs --- written by Chris Bertin
# Pixel Computer Inc. ...!wjh12!pixel!pixutl!chris
diff --git a/bin/sh/funcs/pushd b/bin/sh/funcs/pushd
index 12b6fcf71d13..816230386725 100644
--- a/bin/sh/funcs/pushd
+++ b/bin/sh/funcs/pushd
@@ -30,9 +30,6 @@
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
-#
-# @(#)pushd 8.2 (Berkeley) 5/4/95
-# $FreeBSD$
# pushd, popd, and dirs --- written by Chris Bertin
# Pixel Computer Inc. ...!wjh12!pixel!pixutl!chris
diff --git a/bin/sh/funcs/suspend b/bin/sh/funcs/suspend
index aaa2f7370cde..fd54c7050ddf 100644
--- a/bin/sh/funcs/suspend
+++ b/bin/sh/funcs/suspend
@@ -28,9 +28,6 @@
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
-#
-# @(#)suspend 8.2 (Berkeley) 5/4/95
-# $FreeBSD$
suspend() {
local -
diff --git a/bin/sh/histedit.c b/bin/sh/histedit.c
index 453260a27e54..5aea58650c67 100644
--- a/bin/sh/histedit.c
+++ b/bin/sh/histedit.c
@@ -30,14 +30,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)histedit.c 8.2 (Berkeley) 5/4/95";
-#endif
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/stat.h>
#include <dirent.h>
@@ -52,6 +44,8 @@ __FBSDID("$FreeBSD$");
/*
* Editline and history functions (and glue).
*/
+#include "alias.h"
+#include "exec.h"
#include "shell.h"
#include "parser.h"
#include "var.h"
@@ -90,7 +84,7 @@ get_histfile(void)
const char *histfile;
/* don't try to save if the history size is 0 */
- if (hist == NULL || histsizeval() == 0)
+ if (hist == NULL || !strcmp(histsizeval(), "0"))
return (NULL);
histfile = expandstr("${HISTFILE-${HOME-}/.sh_history}");
@@ -190,7 +184,7 @@ histedit(void)
if (el != NULL) {
if (hist)
el_set(el, EL_HIST, history, hist);
- el_set(el, EL_PROMPT, getprompt);
+ el_set(el, EL_PROMPT_ESC, getprompt, '\001');
el_set(el, EL_ADDFN, "sh-complete",
"Filename completion",
sh_complete);
@@ -255,7 +249,6 @@ setterm(const char *term)
int
histcmd(int argc, char **argv __unused)
{
- int ch;
const char *editor = NULL;
HistEvent he;
int lflg = 0, nflg = 0, rflg = 0, sflg = 0;
@@ -277,25 +270,29 @@ histcmd(int argc, char **argv __unused)
if (argc == 1)
error("missing history argument");
- while (not_fcnumber(*argptr) && (ch = nextopt("e:lnrs")) != '\0')
- switch ((char)ch) {
- case 'e':
- editor = shoptarg;
- break;
- case 'l':
- lflg = 1;
- break;
- case 'n':
- nflg = 1;
- break;
- case 'r':
- rflg = 1;
- break;
- case 's':
- sflg = 1;
- break;
- }
-
+ while (not_fcnumber(*argptr))
+ do {
+ switch (nextopt("e:lnrs")) {
+ case 'e':
+ editor = shoptarg;
+ break;
+ case 'l':
+ lflg = 1;
+ break;
+ case 'n':
+ nflg = 1;
+ break;
+ case 'r':
+ rflg = 1;
+ break;
+ case 's':
+ sflg = 1;
+ break;
+ case '\0':
+ goto operands;
+ }
+ } while (nextopt_optptr != NULL);
+operands:
savehandler = handler;
/*
* If executing...
@@ -586,24 +583,40 @@ static int
comparator(const void *a, const void *b, void *thunk)
{
size_t curpos = (intptr_t)thunk;
+
return (strcmp(*(char *const *)a + curpos,
*(char *const *)b + curpos));
}
+static char
+**add_match(char **matches, size_t i, size_t *size, char *match_copy)
+{
+ if (match_copy == NULL)
+ return (NULL);
+ matches[i] = match_copy;
+ if (i >= *size - 1) {
+ *size *= 2;
+ matches = reallocarray(matches, *size, sizeof(matches[0]));
+ }
+
+ return (matches);
+}
+
/*
- * This function is passed to libedit's fn_complete2(). The library will
- * use it instead of its standard function that finds matching files in
- * current directory. If we're at the start of the line, we want to look
- * for available commands from all paths in $PATH.
+ * This function is passed to libedit's fn_complete2(). The library will use
+ * it instead of its standard function that finds matching files in current
+ * directory. If we're at the start of the line, we want to look for
+ * available commands from all paths in $PATH.
*/
static char
**sh_matches(const char *text, int start, int end)
{
char *free_path = NULL, *path;
const char *dirname;
- char **matches = NULL;
+ char **matches = NULL, **rmatches;
size_t i = 0, size = 16, uniq;
size_t curpos = end - start, lcstring = -1;
+ struct cmdentry e;
in_command_completion = false;
if (start > 0 || memchr("/.~", text[0], 3) != NULL)
@@ -627,7 +640,6 @@ static char
}
while ((entry = readdir(dir)) != NULL) {
struct stat statb;
- char **rmatches;
if (strncmp(entry->d_name, text, curpos) != 0)
continue;
@@ -638,11 +650,8 @@ static char
continue;
} else if (entry->d_type != DT_REG)
continue;
- matches[++i] = strdup(entry->d_name);
- if (i < size - 1)
- continue;
- size *= 2;
- rmatches = reallocarray(matches, size, sizeof(matches[0]));
+ rmatches = add_match(matches, ++i, &size,
+ strdup(entry->d_name));
if (rmatches == NULL) {
closedir(dir);
goto out;
@@ -651,6 +660,32 @@ static char
}
closedir(dir);
}
+ for (const unsigned char *bp = builtincmd; *bp != 0; bp += 2 + bp[0]) {
+ if (curpos > bp[0] || memcmp(bp + 2, text, curpos) != 0)
+ continue;
+ rmatches = add_match(matches, ++i, &size, strndup(bp + 2, bp[0]));
+ if (rmatches == NULL)
+ goto out;
+ matches = rmatches;
+ }
+ for (const struct alias *ap = NULL; (ap = iteralias(ap)) != NULL;) {
+ if (strncmp(ap->name, text, curpos) != 0)
+ continue;
+ rmatches = add_match(matches, ++i, &size, strdup(ap->name));
+ if (rmatches == NULL)
+ goto out;
+ matches = rmatches;
+ }
+ for (const void *a = NULL; (a = itercmd(a, &e)) != NULL;) {
+ if (e.cmdtype != CMDFUNCTION)
+ continue;
+ if (strncmp(e.cmdname, text, curpos) != 0)
+ continue;
+ rmatches = add_match(matches, ++i, &size, strdup(e.cmdname));
+ if (rmatches == NULL)
+ goto out;
+ matches = rmatches;
+ }
out:
free(free_path);
if (i == 0) {
@@ -678,13 +713,13 @@ out:
}
matches[uniq + 1] = NULL;
/*
- * matches[0] is special: it's not a real matching file name but a common
- * prefix for all matching names. It can't be null, unlike any other
- * element of the array. When strings matches[0] and matches[1] compare
- * equal and matches[2] is null that means to libedit that there is only
- * a single match. It will then replace user input with possibly escaped
- * string in matches[0] which is the reason to copy the full name of the
- * only match.
+ * matches[0] is special: it's not a real matching file name but
+ * a common prefix for all matching names. It can't be null, unlike
+ * any other element of the array. When strings matches[0] and
+ * matches[1] compare equal and matches[2] is null that means to
+ * libedit that there is only a single match. It will then replace
+ * user input with possibly escaped string in matches[0] which is the
+ * reason to copy the full name of the only match.
*/
if (uniq == 1)
matches[0] = strdup(matches[1]);
diff --git a/bin/sh/input.c b/bin/sh/input.c
index 12faa33d0f1b..26f233ebf7b6 100644
--- a/bin/sh/input.c
+++ b/bin/sh/input.c
@@ -30,14 +30,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)input.c 8.3 (Berkeley) 6/9/95";
-#endif
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <stdio.h> /* defines BUFSIZ */
#include <fcntl.h>
#include <errno.h>
diff --git a/bin/sh/input.h b/bin/sh/input.h
index edb622b6ec2e..8cf4df1e4044 100644
--- a/bin/sh/input.h
+++ b/bin/sh/input.h
@@ -28,9 +28,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * @(#)input.h 8.2 (Berkeley) 5/4/95
- * $FreeBSD$
*/
/* PEOF (the end of file marker) is defined in syntax.h */
diff --git a/bin/sh/jobs.c b/bin/sh/jobs.c
index ff36bfa6d999..1328ae50edef 100644
--- a/bin/sh/jobs.c
+++ b/bin/sh/jobs.c
@@ -30,14 +30,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)jobs.c 8.5 (Berkeley) 5/4/95";
-#endif
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/ioctl.h>
#include <sys/param.h>
#include <sys/resource.h>
@@ -101,7 +93,7 @@ struct job {
short nprocs; /* number of processes */
pid_t pgrp; /* process group of this job */
char state; /* true if job is finished */
- char used; /* true if this entry is in used */
+ char used; /* true if this entry is in use */
char changed; /* true if status has changed */
char foreground; /* true if running in the foreground */
char remembered; /* true if $! referenced */
diff --git a/bin/sh/jobs.h b/bin/sh/jobs.h
index d0caf0638617..149b85d7df80 100644
--- a/bin/sh/jobs.h
+++ b/bin/sh/jobs.h
@@ -28,9 +28,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * @(#)jobs.h 8.2 (Berkeley) 5/4/95
- * $FreeBSD$
*/
/* Mode argument to forkshell. Don't change FORK_FG or FORK_BG. */
@@ -55,7 +52,7 @@ void setjobctl(int);
void showjobs(int, int);
struct job *makejob(union node *, int);
pid_t forkshell(struct job *, union node *, int);
-pid_t vforkexecshell(struct job *, char **, char **, const char *, int, int []);
+pid_t vforkexecshell(struct job *, char **, char **, const char *, int, int [2]);
int waitforjob(struct job *, int *);
int stoppedjobs(void);
int backgndpidset(void);
diff --git a/bin/sh/mail.c b/bin/sh/mail.c
index 194f654484db..be5e76c221f8 100644
--- a/bin/sh/mail.c
+++ b/bin/sh/mail.c
@@ -30,14 +30,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)mail.c 8.2 (Berkeley) 5/4/95";
-#endif
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* Routines to check for mail. (Perhaps make part of main.c?)
*/
@@ -63,7 +55,7 @@ static time_t mailtime[MAXMBOXES]; /* times of mailboxes */
/*
* Print appropriate message(s) if mail has arrived. If the argument is
- * nozero, then the value of MAIL has changed, so we just update the
+ * non-zero, then the value of MAIL has changed, so we just update the
* values.
*/
diff --git a/bin/sh/mail.h b/bin/sh/mail.h
index 0bb565209c7f..fd05aaddf7af 100644
--- a/bin/sh/mail.h
+++ b/bin/sh/mail.h
@@ -30,9 +30,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * @(#)mail.h 8.2 (Berkeley) 5/4/95
- * $FreeBSD$
*/
void chkmail(int);
diff --git a/bin/sh/main.c b/bin/sh/main.c
index bc87440807b2..23147c1db0be 100644
--- a/bin/sh/main.c
+++ b/bin/sh/main.c
@@ -32,20 +32,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static char const copyright[] =
-"@(#) Copyright (c) 1991, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/28/95";
-#endif
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <stdio.h>
#include <signal.h>
#include <sys/stat.h>
@@ -100,7 +86,13 @@ static char *find_dot_file(char *);
int
main(int argc, char *argv[])
{
- struct stackmark smark, smark2;
+ /*
+ * As smark is accessed after a longjmp, it cannot be a local in main().
+ * The C standard specifies that the values of non-volatile local
+ * variables are unspecified after a jump if modified between the
+ * setjmp and longjmp.
+ */
+ static struct stackmark smark, smark2;
volatile int state;
char *shinit;
diff --git a/bin/sh/main.h b/bin/sh/main.h
index d12c7ab77fed..68a3ddc33126 100644
--- a/bin/sh/main.h
+++ b/bin/sh/main.h
@@ -30,9 +30,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * @(#)main.h 8.2 (Berkeley) 5/4/95
- * $FreeBSD$
*/
extern int rootpid; /* pid of main shell */
diff --git a/bin/sh/memalloc.c b/bin/sh/memalloc.c
index 7ea31af050e5..9c50156e8e00 100644
--- a/bin/sh/memalloc.c
+++ b/bin/sh/memalloc.c
@@ -32,14 +32,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)memalloc.c 8.3 (Berkeley) 5/4/95";
-#endif
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include "shell.h"
#include "output.h"
@@ -291,7 +283,7 @@ growstackblock(int min)
/*
- * The following routines are somewhat easier to use that the above.
+ * The following routines are somewhat easier to use than the above.
* The user declares a variable of type STACKSTR, which may be declared
* to be a register. The macro STARTSTACKSTR initializes things. Then
* the user uses the macro STPUTC to add characters to the string. In
diff --git a/bin/sh/memalloc.h b/bin/sh/memalloc.h
index 6cb7bd818fb5..ef090d51896d 100644
--- a/bin/sh/memalloc.h
+++ b/bin/sh/memalloc.h
@@ -30,9 +30,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * @(#)memalloc.h 8.2 (Berkeley) 5/4/95
- * $FreeBSD$
*/
#include <string.h>
diff --git a/bin/sh/miscbltin.c b/bin/sh/miscbltin.c
index 79d7dc097b5c..6364bd10a584 100644
--- a/bin/sh/miscbltin.c
+++ b/bin/sh/miscbltin.c
@@ -32,14 +32,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)miscbltin.c 8.4 (Berkeley) 5/4/95";
-#endif
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* Miscellaneous builtins.
*/
diff --git a/bin/sh/mkbuiltins b/bin/sh/mkbuiltins
index a04a796e275f..e0f997ba50ae 100755
--- a/bin/sh/mkbuiltins
+++ b/bin/sh/mkbuiltins
@@ -30,9 +30,6 @@
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
-#
-# @(#)mkbuiltins 8.2 (Berkeley) 5/4/95
-# $FreeBSD$
temp=`mktemp -t ka`
srcdir=$1
diff --git a/bin/sh/mknodes.c b/bin/sh/mknodes.c
index 5b923b7fe0c5..0c5dfb1accfb 100644
--- a/bin/sh/mknodes.c
+++ b/bin/sh/mknodes.c
@@ -32,20 +32,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static char const copyright[] =
-"@(#) Copyright (c) 1991, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "@(#)mknodes.c 8.2 (Berkeley) 5/4/95";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* This program reads the nodetypes file and nodes.c.pat file. It generates
* the files nodes.h and nodes.c.
diff --git a/bin/sh/mksyntax.c b/bin/sh/mksyntax.c
index 24b118f64cbf..60570d0f60a4 100644
--- a/bin/sh/mksyntax.c
+++ b/bin/sh/mksyntax.c
@@ -32,20 +32,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static char const copyright[] =
-"@(#) Copyright (c) 1991, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "@(#)mksyntax.c 8.2 (Berkeley) 5/4/95";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* This program creates syntax.h and syntax.c.
*/
diff --git a/bin/sh/mktokens b/bin/sh/mktokens
index b7213e6831f6..1b0b0b9a586a 100644
--- a/bin/sh/mktokens
+++ b/bin/sh/mktokens
@@ -30,9 +30,6 @@
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
-#
-# @(#)mktokens 8.1 (Berkeley) 5/31/93
-# $FreeBSD$
# 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
diff --git a/bin/sh/myhistedit.h b/bin/sh/myhistedit.h
index 1f513f0ae206..64539fc06c18 100644
--- a/bin/sh/myhistedit.h
+++ b/bin/sh/myhistedit.h
@@ -27,9 +27,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * @(#)myhistedit.h 8.2 (Berkeley) 5/4/95
- * $FreeBSD$
*/
#include <histedit.h>
diff --git a/bin/sh/mystring.c b/bin/sh/mystring.c
index 716f00345961..9ac590d39f64 100644
--- a/bin/sh/mystring.c
+++ b/bin/sh/mystring.c
@@ -32,14 +32,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)mystring.c 8.2 (Berkeley) 5/4/95";
-#endif
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* String functions.
*
diff --git a/bin/sh/mystring.h b/bin/sh/mystring.h
index ff4384d21c35..d51d22de83a1 100644
--- a/bin/sh/mystring.h
+++ b/bin/sh/mystring.h
@@ -30,9 +30,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * @(#)mystring.h 8.2 (Berkeley) 5/4/95
- * $FreeBSD$
*/
#include <string.h>
diff --git a/bin/sh/nodes.c.pat b/bin/sh/nodes.c.pat
index 43fa515fe905..9cee0715d4fc 100644
--- a/bin/sh/nodes.c.pat
+++ b/bin/sh/nodes.c.pat
@@ -28,9 +28,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * @(#)nodes.c.pat 8.2 (Berkeley) 5/4/95
- * $FreeBSD$
*/
#include <sys/param.h>
diff --git a/bin/sh/nodetypes b/bin/sh/nodetypes
index 0d0d657d67e8..1507a7ae847e 100644
--- a/bin/sh/nodetypes
+++ b/bin/sh/nodetypes
@@ -28,9 +28,6 @@
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
-#
-# @(#)nodetypes 8.2 (Berkeley) 5/4/95
-# $FreeBSD$
# This file describes the nodes used in parse trees. Unindented lines
# contain a node type followed by a structure tag. Subsequent indented
diff --git a/bin/sh/options.c b/bin/sh/options.c
index 97171d32bff1..2dab8f4ea998 100644
--- a/bin/sh/options.c
+++ b/bin/sh/options.c
@@ -32,14 +32,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)options.c 8.2 (Berkeley) 5/4/95";
-#endif
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <signal.h>
#include <unistd.h>
#include <stdlib.h>
@@ -589,6 +581,9 @@ nextopt(const char *optstring)
shoptarg = p;
p = NULL;
}
- nextopt_optptr = p;
+ if (p != NULL && *p != '\0')
+ nextopt_optptr = p;
+ else
+ nextopt_optptr = NULL;
return c;
}
diff --git a/bin/sh/options.h b/bin/sh/options.h
index 7c9c4513aa33..206d32c8a706 100644
--- a/bin/sh/options.h
+++ b/bin/sh/options.h
@@ -30,9 +30,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * @(#)options.h 8.2 (Berkeley) 5/4/95
- * $FreeBSD$
*/
struct shparam {
diff --git a/bin/sh/output.c b/bin/sh/output.c
index c01ddd5acb83..baf4b8b7cc17 100644
--- a/bin/sh/output.c
+++ b/bin/sh/output.c
@@ -32,14 +32,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)output.c 8.2 (Berkeley) 5/4/95";
-#endif
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* Shell output routines. We use our own output routines because:
* When a builtin command is interrupted we have to discard
diff --git a/bin/sh/output.h b/bin/sh/output.h
index 62f006d32a36..3afc3f289ad6 100644
--- a/bin/sh/output.h
+++ b/bin/sh/output.h
@@ -30,9 +30,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * @(#)output.h 8.2 (Berkeley) 5/4/95
- * $FreeBSD$
*/
#ifndef OUTPUT_INCL
diff --git a/bin/sh/parser.c b/bin/sh/parser.c
index e75798800edf..0c1b7a91c257 100644
--- a/bin/sh/parser.c
+++ b/bin/sh/parser.c
@@ -32,19 +32,12 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)parser.c 8.7 (Berkeley) 5/16/95";
-#endif
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <pwd.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
+#include <time.h>
#include "shell.h"
#include "parser.h"
@@ -70,7 +63,7 @@ __FBSDID("$FreeBSD$");
* Shell command parser.
*/
-#define PROMPTLEN 128
+#define PROMPTLEN 192
/* values of checkkwd variable */
#define CHKALIAS 0x1
@@ -2056,104 +2049,182 @@ getprompt(void *unused __unused)
/*
* Format prompt string.
*/
- for (i = 0; (i < PROMPTLEN - 1) && (*fmt != '\0'); i++, fmt++)
- if (*fmt == '\\')
- switch (*++fmt) {
+ for (i = 0; (i < PROMPTLEN - 1) && (*fmt != '\0'); i++, fmt++) {
+ if (*fmt != '\\') {
+ ps[i] = *fmt;
+ continue;
+ }
- /*
- * Hostname.
- *
- * \h specifies just the local hostname,
- * \H specifies fully-qualified hostname.
- */
- case 'h':
- case 'H':
- ps[i] = '\0';
- gethostname(&ps[i], PROMPTLEN - i - 1);
- ps[PROMPTLEN - 1] = '\0';
- /* Skip to end of hostname. */
- trim = (*fmt == 'h') ? '.' : '\0';
- while ((ps[i] != '\0') && (ps[i] != trim))
- i++;
- --i;
- break;
+ switch (*++fmt) {
- /*
- * User name.
- */
- case 'u':
- ps[i] = '\0';
- getusername(&ps[i], PROMPTLEN - i);
- /* Skip to end of username. */
- while (ps[i + 1] != '\0')
- i++;
- break;
+ /*
+ * Non-printing sequence begin and end.
+ */
+ case '[':
+ case ']':
+ ps[i] = '\001';
+ break;
- /*
- * Working directory.
- *
- * \W specifies just the final component,
- * \w specifies the entire path.
- */
- case 'W':
- case 'w':
- pwd = lookupvar("PWD");
- if (pwd == NULL || *pwd == '\0')
- pwd = "?";
- if (*fmt == 'W' &&
- *pwd == '/' && pwd[1] != '\0')
- strlcpy(&ps[i], strrchr(pwd, '/') + 1,
- PROMPTLEN - i);
- else {
- home = lookupvar("HOME");
- if (home != NULL)
- homelen = strlen(home);
- if (home != NULL &&
- strcmp(home, "/") != 0 &&
- strncmp(pwd, home, homelen) == 0 &&
- (pwd[homelen] == '/' ||
- pwd[homelen] == '\0')) {
- strlcpy(&ps[i], "~",
- PROMPTLEN - i);
- strlcpy(&ps[i + 1],
- pwd + homelen,
- PROMPTLEN - i - 1);
- } else {
- strlcpy(&ps[i], pwd, PROMPTLEN - i);
- }
- }
- /* Skip to end of path. */
- while (ps[i + 1] != '\0')
- i++;
- break;
+ /*
+ * Literal \ and some ASCII characters:
+ * \a BEL
+ * \e ESC
+ * \r CR
+ */
+ case '\\':
+ case 'a':
+ case 'e':
+ case 'r':
+ if (*fmt == 'a')
+ ps[i] = '\007';
+ else if (*fmt == 'e')
+ ps[i] = '\033';
+ else if (*fmt == 'r')
+ ps[i] = '\r';
+ else
+ ps[i] = '\\';
+ break;
- /*
- * Superuser status.
- *
- * '$' for normal users, '#' for root.
- */
- case '$':
- ps[i] = (geteuid() != 0) ? '$' : '#';
- break;
+ /*
+ * CRLF sequence
+ */
+ case 'n':
+ if (i < PROMPTLEN - 3) {
+ ps[i++] = '\r';
+ ps[i] = '\n';
+ }
+ break;
- /*
- * A literal \.
- */
- case '\\':
- ps[i] = '\\';
- break;
+ /*
+ * Print the current time as per provided strftime format.
+ */
+ case 'D': {
+ char tfmt[128] = "%X"; /* \D{} means %X. */
+ struct tm *now;
+ if (fmt[1] != '{') {
/*
- * Emit unrecognized formats verbatim.
+ * "\D" but not "\D{", so treat the '\'
+ * literally and rewind fmt to treat 'D'
+ * literally next iteration.
*/
- default:
ps[i] = '\\';
- if (i < PROMPTLEN - 2)
- ps[++i] = *fmt;
+ fmt--;
break;
}
- else
- ps[i] = *fmt;
+ fmt += 2; /* Consume "D{". */
+ if (fmt[0] != '}') {
+ char *end;
+
+ end = memccpy(tfmt, fmt, '}', sizeof(tfmt));
+ if (end == NULL) {
+ /*
+ * Format too long or no '}', so
+ * ignore "\D{" altogether.
+ * The loop will do i++, but nothing
+ * was written to ps, so do i-- here.
+ * Rewind fmt for similar reason.
+ */
+ i--;
+ fmt--;
+ break;
+ }
+ *--end = '\0'; /* Ignore the copy of '}'. */
+ fmt += end - tfmt;
+ }
+ now = localtime(&(time_t){time(NULL)});
+ i += strftime(&ps[i], PROMPTLEN - i - 1, tfmt, now);
+ i--; /* The loop will do i++. */
+ break;
+ }
+
+ /*
+ * Hostname.
+ *
+ * \h specifies just the local hostname,
+ * \H specifies fully-qualified hostname.
+ */
+ case 'h':
+ case 'H':
+ ps[i] = '\0';
+ gethostname(&ps[i], PROMPTLEN - i - 1);
+ ps[PROMPTLEN - 1] = '\0';
+ /* Skip to end of hostname. */
+ trim = (*fmt == 'h') ? '.' : '\0';
+ while ((ps[i] != '\0') && (ps[i] != trim))
+ i++;
+ --i;
+ break;
+
+ /*
+ * User name.
+ */
+ case 'u':
+ ps[i] = '\0';
+ getusername(&ps[i], PROMPTLEN - i);
+ /* Skip to end of username. */
+ while (ps[i + 1] != '\0')
+ i++;
+ break;
+
+ /*
+ * Working directory.
+ *
+ * \W specifies just the final component,
+ * \w specifies the entire path.
+ */
+ case 'W':
+ case 'w':
+ pwd = lookupvar("PWD");
+ if (pwd == NULL || *pwd == '\0')
+ pwd = "?";
+ if (*fmt == 'W' &&
+ *pwd == '/' && pwd[1] != '\0')
+ strlcpy(&ps[i], strrchr(pwd, '/') + 1,
+ PROMPTLEN - i);
+ else {
+ home = lookupvar("HOME");
+ if (home != NULL)
+ homelen = strlen(home);
+ if (home != NULL &&
+ strcmp(home, "/") != 0 &&
+ strncmp(pwd, home, homelen) == 0 &&
+ (pwd[homelen] == '/' ||
+ pwd[homelen] == '\0')) {
+ strlcpy(&ps[i], "~",
+ PROMPTLEN - i);
+ strlcpy(&ps[i + 1],
+ pwd + homelen,
+ PROMPTLEN - i - 1);
+ } else {
+ strlcpy(&ps[i], pwd, PROMPTLEN - i);
+ }
+ }
+ /* Skip to end of path. */
+ while (ps[i + 1] != '\0')
+ i++;
+ break;
+
+ /*
+ * Superuser status.
+ *
+ * '$' for normal users, '#' for root.
+ */
+ case '$':
+ ps[i] = (geteuid() != 0) ? '$' : '#';
+ break;
+
+ /*
+ * Emit unrecognized formats verbatim.
+ */
+ default:
+ ps[i] = '\\';
+ if (i < PROMPTLEN - 2)
+ ps[++i] = *fmt;
+ break;
+ }
+
+ }
ps[i] = '\0';
return (ps);
}
diff --git a/bin/sh/parser.h b/bin/sh/parser.h
index aee8244ecf09..933066be87f0 100644
--- a/bin/sh/parser.h
+++ b/bin/sh/parser.h
@@ -30,9 +30,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * @(#)parser.h 8.3 (Berkeley) 5/4/95
- * $FreeBSD$
*/
/* control characters in argument strings */
diff --git a/bin/sh/profile b/bin/sh/profile
index b77c8787c79d..ee0879a13e0b 100644
--- a/bin/sh/profile
+++ b/bin/sh/profile
@@ -1,4 +1,3 @@
-# $FreeBSD$
#
# System-wide .profile file for sh(1).
#
@@ -12,3 +11,23 @@
# msgs -q
# Allow terminal messages
# mesg y
+
+# Load each .sh file in /etc/profile.d/, then /usr/local/etc/profile,
+# then each .sh file in /usr/local/etc/profile.d/.
+_loaded=${_loaded:-/etc/profile}
+export _loaded
+for _dir in /etc /usr/local/etc ; do
+ for _file in "${_dir}"/profile "${_dir}"/profile.d/*.sh ; do
+ if [ -f "${_file}" ] ; then
+ case :${_loaded}: in
+ *:"${_file}":*)
+ ;;
+ *)
+ _loaded="${_loaded:+${_loaded}:}${_file}"
+ . "${_file}"
+ ;;
+ esac
+ fi
+ done
+done
+unset _loaded _dir _file
diff --git a/bin/sh/redir.c b/bin/sh/redir.c
index e820fd2c05f7..eb0fc618a73e 100644
--- a/bin/sh/redir.c
+++ b/bin/sh/redir.c
@@ -32,14 +32,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)redir.c 8.2 (Berkeley) 5/4/95";
-#endif
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/stat.h>
#include <signal.h>
diff --git a/bin/sh/redir.h b/bin/sh/redir.h
index 08c52359c59e..de780f0c1bfc 100644
--- a/bin/sh/redir.h
+++ b/bin/sh/redir.h
@@ -30,9 +30,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * @(#)redir.h 8.2 (Berkeley) 5/4/95
- * $FreeBSD$
*/
/* flags passed to redirect */
diff --git a/bin/sh/sh.1 b/bin/sh/sh.1
index 9b1968373ec9..849133540cdd 100644
--- a/bin/sh/sh.1
+++ b/bin/sh/sh.1
@@ -29,10 +29,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" from: @(#)sh.1 8.6 (Berkeley) 5/4/95
-.\" $FreeBSD$
-.\"
-.Dd May 10, 2021
+.Dd December 14, 2022
.Dt SH 1
.Os
.Sh NAME
@@ -214,7 +211,7 @@ Do not overwrite existing files with
.Ql > .
.It Fl E Li emacs
Enable the built-in
-.Xr emacs 1
+.Xr emacs 1 Pq Pa ports/editors/emacs
command line editor (disables the
.Fl V
option if it has been set;
@@ -359,8 +356,8 @@ This option only has a long name.
Set
.Dv O_VERIFY
when sourcing files or loading profiles.
-See also
-.Xr mac_veriexec 4 .
+.\" See also
+.\" .Xr mac_veriexec 4 . TODO Does not exist; write it.
.El
.Pp
The
@@ -378,7 +375,7 @@ to be enabled or disabled.
For example, the following two invocations of
.Nm
both enable the built-in
-.Xr emacs 1
+.Xr emacs 1 Pq Pa ports/editors/emacs
command line editor:
.Bd -literal -offset indent
set -E
@@ -1428,6 +1425,16 @@ unless you are the superuser, in which case it defaults to
may include any of the following formatting sequences,
which are replaced by the given information:
.Bl -tag -width indent
+.It Li \eD{format}
+The current time in
+.Xr strftime 3
+.Ar format .
+The braces are required.
+Empty
+.Ar format
+is equivalent to
+\&%X,
+national representation of the time.
.It Li \eH
This system's fully-qualified hostname (FQDN).
.It Li \eh
@@ -1446,6 +1453,24 @@ for normal users and
for superusers.
.It Li \e\e
A literal backslash.
+.It Li \e[
+Start of a sequence of non-printing characters (used, for example,
+to embed ANSI CSI sequences into the prompt).
+.It Li \e]
+End of a sequence of non-printing characters.
+.El
+.Pp
+The following special and non-printing characters are supported
+within the sequence of non-printing characters:
+.Bl -tag -width indent
+.It Li \ea
+Emits ASCII BEL (0x07, 007) character.
+.It Li \ee
+Emits ASCII ESC (0x1b, 033) character.
+.It Li \er
+Emits ASCII CR (0x0d, 015) character.
+.It Li \en
+Emits CRLF sequence.
.El
.It Va PS2
The secondary prompt string, which defaults to
@@ -2869,7 +2894,7 @@ will return the argument.
.Xr chsh 1 ,
.Xr echo 1 ,
.Xr ed 1 ,
-.Xr emacs 1 ,
+.Xr emacs 1 Pq Pa ports/editors/emacs ,
.Xr kill 1 ,
.Xr printf 1 ,
.Xr pwd 1 ,
diff --git a/bin/sh/shell.h b/bin/sh/shell.h
index 536efe6ce228..4b598899dee1 100644
--- a/bin/sh/shell.h
+++ b/bin/sh/shell.h
@@ -30,9 +30,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * @(#)shell.h 8.2 (Berkeley) 5/4/95
- * $FreeBSD$
*/
#ifndef SHELL_H_
diff --git a/bin/sh/show.c b/bin/sh/show.c
index 01035d76093d..1ccd4583d3a9 100644
--- a/bin/sh/show.c
+++ b/bin/sh/show.c
@@ -32,14 +32,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)show.c 8.3 (Berkeley) 5/4/95";
-#endif
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/bin/sh/show.h b/bin/sh/show.h
index 790a62e2942c..d57ba9aee8c0 100644
--- a/bin/sh/show.h
+++ b/bin/sh/show.h
@@ -27,9 +27,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * @(#)show.h 1.1 (Berkeley) 5/4/95
- * $FreeBSD$
*/
void showtree(union node *);
diff --git a/bin/sh/tests/Makefile b/bin/sh/tests/Makefile
index 59835cb73520..ea28b9d39bd8 100644
--- a/bin/sh/tests/Makefile
+++ b/bin/sh/tests/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <bsd.own.mk>
diff --git a/bin/sh/tests/Makefile.depend b/bin/sh/tests/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/bin/sh/tests/Makefile.depend
+++ b/bin/sh/tests/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/bin/sh/tests/builtins/Makefile b/bin/sh/tests/builtins/Makefile
index f9b464a6da4b..c3ed122791b5 100644
--- a/bin/sh/tests/builtins/Makefile
+++ b/bin/sh/tests/builtins/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE= tests
@@ -94,6 +93,7 @@ ${PACKAGE}FILES+= exit3.0
${PACKAGE}FILES+= export1.0
${PACKAGE}FILES+= fc1.0
${PACKAGE}FILES+= fc2.0
+${PACKAGE}FILES+= fc3.0 fc3.0.stdout fc3.0.stderr
${PACKAGE}FILES+= for1.0
${PACKAGE}FILES+= for2.0
${PACKAGE}FILES+= for3.0
diff --git a/bin/sh/tests/builtins/Makefile.depend b/bin/sh/tests/builtins/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/bin/sh/tests/builtins/Makefile.depend
+++ b/bin/sh/tests/builtins/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/bin/sh/tests/builtins/alias.0 b/bin/sh/tests/builtins/alias.0
index d9b27969cfd6..0da2587e3b52 100644
--- a/bin/sh/tests/builtins/alias.0
+++ b/bin/sh/tests/builtins/alias.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -e
unalias -a
diff --git a/bin/sh/tests/builtins/alias.1 b/bin/sh/tests/builtins/alias.1
index 31403dc760bf..755d1f59aeae 100644
--- a/bin/sh/tests/builtins/alias.1
+++ b/bin/sh/tests/builtins/alias.1
@@ -1,3 +1,2 @@
-# $FreeBSD$
unalias -a
alias foo
diff --git a/bin/sh/tests/builtins/alias3.0 b/bin/sh/tests/builtins/alias3.0
index fe65e31f5f03..b0edcbc1b814 100644
--- a/bin/sh/tests/builtins/alias3.0
+++ b/bin/sh/tests/builtins/alias3.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -e
unalias -a
diff --git a/bin/sh/tests/builtins/alias4.0 b/bin/sh/tests/builtins/alias4.0
index 3d5efeccf2c7..0e93513546f0 100644
--- a/bin/sh/tests/builtins/alias4.0
+++ b/bin/sh/tests/builtins/alias4.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
unalias -a
alias --
diff --git a/bin/sh/tests/builtins/break1.0 b/bin/sh/tests/builtins/break1.0
index ba0cbb4bd268..910a003c609e 100644
--- a/bin/sh/tests/builtins/break1.0
+++ b/bin/sh/tests/builtins/break1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
if [ "$1" != nested ]; then
while :; do
diff --git a/bin/sh/tests/builtins/break2.0 b/bin/sh/tests/builtins/break2.0
index ff52dd321469..43d037c10ee7 100644
--- a/bin/sh/tests/builtins/break2.0
+++ b/bin/sh/tests/builtins/break2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# It is not immediately obvious that this should work, and someone probably
# relies on it.
diff --git a/bin/sh/tests/builtins/break3.0 b/bin/sh/tests/builtins/break3.0
index 10a5ca88edff..fe73dac6befe 100644
--- a/bin/sh/tests/builtins/break3.0
+++ b/bin/sh/tests/builtins/break3.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# We accept this and people might rely on it.
# However, various other shells do not accept it.
diff --git a/bin/sh/tests/builtins/break4.4 b/bin/sh/tests/builtins/break4.4
index d52ff52be4d4..24f804cff385 100644
--- a/bin/sh/tests/builtins/break4.4
+++ b/bin/sh/tests/builtins/break4.4
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Although this is not specified by POSIX, some configure scripts (gawk 4.1.0)
# appear to depend on it.
diff --git a/bin/sh/tests/builtins/break5.4 b/bin/sh/tests/builtins/break5.4
index 7df8e186311c..161c376823bb 100644
--- a/bin/sh/tests/builtins/break5.4
+++ b/bin/sh/tests/builtins/break5.4
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Although this is not specified by POSIX, some configure scripts (gawk 4.1.0)
# appear to depend on it.
diff --git a/bin/sh/tests/builtins/break6.0 b/bin/sh/tests/builtins/break6.0
index 09fc0d85eaa3..6d8a0f2b3f97 100644
--- a/bin/sh/tests/builtins/break6.0
+++ b/bin/sh/tests/builtins/break6.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Per POSIX, this need only work if LONG_MAX > 4294967295.
while :; do
diff --git a/bin/sh/tests/builtins/builtin1.0 b/bin/sh/tests/builtins/builtin1.0
index b6083858f671..e52abf27c78a 100644
--- a/bin/sh/tests/builtins/builtin1.0
+++ b/bin/sh/tests/builtins/builtin1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
failures=0
diff --git a/bin/sh/tests/builtins/case1.0 b/bin/sh/tests/builtins/case1.0
index 860fc67dacda..3a89fd2c3729 100644
--- a/bin/sh/tests/builtins/case1.0
+++ b/bin/sh/tests/builtins/case1.0
@@ -1,4 +1,3 @@
-#$FreeBSD$
f()
{
false
diff --git a/bin/sh/tests/builtins/case10.0 b/bin/sh/tests/builtins/case10.0
index a627b5cd996f..a0f2a988294e 100644
--- a/bin/sh/tests/builtins/case10.0
+++ b/bin/sh/tests/builtins/case10.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
case ! in
[\!!]) ;;
diff --git a/bin/sh/tests/builtins/case11.0 b/bin/sh/tests/builtins/case11.0
index 0e66e11f0dee..50acd5db8e5b 100644
--- a/bin/sh/tests/builtins/case11.0
+++ b/bin/sh/tests/builtins/case11.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
false
case x in
diff --git a/bin/sh/tests/builtins/case12.0 b/bin/sh/tests/builtins/case12.0
index 2a442ba7993a..9a4975b819c3 100644
--- a/bin/sh/tests/builtins/case12.0
+++ b/bin/sh/tests/builtins/case12.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
false
case x in
diff --git a/bin/sh/tests/builtins/case13.0 b/bin/sh/tests/builtins/case13.0
index 78f4e9bdffde..83a26869da87 100644
--- a/bin/sh/tests/builtins/case13.0
+++ b/bin/sh/tests/builtins/case13.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
case ^ in
[\^^]) ;;
diff --git a/bin/sh/tests/builtins/case14.0 b/bin/sh/tests/builtins/case14.0
index 0338e8a224e3..b3cf26c922a2 100644
--- a/bin/sh/tests/builtins/case14.0
+++ b/bin/sh/tests/builtins/case14.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
case `false` in
no) exit 3 ;;
diff --git a/bin/sh/tests/builtins/case15.0 b/bin/sh/tests/builtins/case15.0
index 09b0e1133544..e0b2d70e5832 100644
--- a/bin/sh/tests/builtins/case15.0
+++ b/bin/sh/tests/builtins/case15.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
case x in
`false`) exit 3 ;;
diff --git a/bin/sh/tests/builtins/case16.0 b/bin/sh/tests/builtins/case16.0
index 24303027ba91..e1ec8f1c9272 100644
--- a/bin/sh/tests/builtins/case16.0
+++ b/bin/sh/tests/builtins/case16.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
f() { return 42; }
f
diff --git a/bin/sh/tests/builtins/case17.0 b/bin/sh/tests/builtins/case17.0
index ed1d25f0277a..42ff0ee4a90f 100644
--- a/bin/sh/tests/builtins/case17.0
+++ b/bin/sh/tests/builtins/case17.0
@@ -1,3 +1,2 @@
-# $FreeBSD$
! case x in x) false ;& y) esac
diff --git a/bin/sh/tests/builtins/case18.0 b/bin/sh/tests/builtins/case18.0
index 470253f622ea..76f4d6743503 100644
--- a/bin/sh/tests/builtins/case18.0
+++ b/bin/sh/tests/builtins/case18.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
case x$(false) in
x) ;&
diff --git a/bin/sh/tests/builtins/case19.0 b/bin/sh/tests/builtins/case19.0
index 215066ad6321..2e8a2ec77f53 100644
--- a/bin/sh/tests/builtins/case19.0
+++ b/bin/sh/tests/builtins/case19.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
[ "`case x in
x) false ;&
diff --git a/bin/sh/tests/builtins/case2.0 b/bin/sh/tests/builtins/case2.0
index e319148cdf5d..37d5f8c28503 100644
--- a/bin/sh/tests/builtins/case2.0
+++ b/bin/sh/tests/builtins/case2.0
@@ -1,5 +1,4 @@
# Generated by ./test-fnmatch -s 1, do not edit.
-# $FreeBSD$
failures=
failed() { printf '%s\n' "Failed: $1 '$2' '$3'"; failures=x$failures; }
testmatch() { eval "case \$2 in ''$1) ;; *) failed testmatch \"\$@\";; esac"; }
diff --git a/bin/sh/tests/builtins/case20.0 b/bin/sh/tests/builtins/case20.0
index 03a4eb2c9a23..800afa0db9fd 100644
--- a/bin/sh/tests/builtins/case20.0
+++ b/bin/sh/tests/builtins/case20.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# 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
diff --git a/bin/sh/tests/builtins/case21.0 b/bin/sh/tests/builtins/case21.0
index ea7fb054a546..426ce8b4b08c 100644
--- a/bin/sh/tests/builtins/case21.0
+++ b/bin/sh/tests/builtins/case21.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
case 5 in
[0$((-9))]) ;;
diff --git a/bin/sh/tests/builtins/case22.0 b/bin/sh/tests/builtins/case22.0
index ddc80051fa0a..5c36c483da44 100644
--- a/bin/sh/tests/builtins/case22.0
+++ b/bin/sh/tests/builtins/case22.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
case 5 in
[0"$((-9))"]) echo bad1 ;;
diff --git a/bin/sh/tests/builtins/case23.0 b/bin/sh/tests/builtins/case23.0
index ce03cf96d62e..27fc79a65a68 100644
--- a/bin/sh/tests/builtins/case23.0
+++ b/bin/sh/tests/builtins/case23.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
case [ in
[[:alpha:]]) echo bad
diff --git a/bin/sh/tests/builtins/case3.0 b/bin/sh/tests/builtins/case3.0
index 42e53d62a3cb..06080f9ec3dc 100644
--- a/bin/sh/tests/builtins/case3.0
+++ b/bin/sh/tests/builtins/case3.0
@@ -1,5 +1,4 @@
# Generated by ./test-fnmatch -s 2, do not edit.
-# $FreeBSD$
failures=
failed() { printf '%s\n' "Failed: $1 '$2' '$3'"; failures=x$failures; }
# We do not treat a backslash specially in this case,
diff --git a/bin/sh/tests/builtins/case4.0 b/bin/sh/tests/builtins/case4.0
index 18219f51ee09..abac705a8491 100644
--- a/bin/sh/tests/builtins/case4.0
+++ b/bin/sh/tests/builtins/case4.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -- "*"
case x in
diff --git a/bin/sh/tests/builtins/case5.0 b/bin/sh/tests/builtins/case5.0
index 8c6db5ab8e57..118e001b8aa7 100644
--- a/bin/sh/tests/builtins/case5.0
+++ b/bin/sh/tests/builtins/case5.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
unset LC_ALL
LC_CTYPE=en_US.UTF-8
diff --git a/bin/sh/tests/builtins/case6.0 b/bin/sh/tests/builtins/case6.0
index 8d791831c3d8..2ea777aa7ea8 100644
--- a/bin/sh/tests/builtins/case6.0
+++ b/bin/sh/tests/builtins/case6.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
unset LC_ALL
LC_CTYPE=de_DE.ISO8859-1
diff --git a/bin/sh/tests/builtins/case7.0 b/bin/sh/tests/builtins/case7.0
index 96b9de66fe27..6c8e632fbda9 100644
--- a/bin/sh/tests/builtins/case7.0
+++ b/bin/sh/tests/builtins/case7.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Character ranges in a locale other than the POSIX locale, not specified
# by POSIX.
diff --git a/bin/sh/tests/builtins/case8.0 b/bin/sh/tests/builtins/case8.0
index 8d9f8b604d88..01b5fdf35a7b 100644
--- a/bin/sh/tests/builtins/case8.0
+++ b/bin/sh/tests/builtins/case8.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
case aZ_ in
[[:alpha:]_][[:upper:]_][[:alpha:]_]) ;;
diff --git a/bin/sh/tests/builtins/case9.0 b/bin/sh/tests/builtins/case9.0
index 476caec261ba..7719ba195126 100644
--- a/bin/sh/tests/builtins/case9.0
+++ b/bin/sh/tests/builtins/case9.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
errors=0
diff --git a/bin/sh/tests/builtins/cd1.0 b/bin/sh/tests/builtins/cd1.0
index bc5108e6be3b..52d165df5ae2 100644
--- a/bin/sh/tests/builtins/cd1.0
+++ b/bin/sh/tests/builtins/cd1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -e
P=${TMPDIR:-/tmp}
diff --git a/bin/sh/tests/builtins/cd10.0 b/bin/sh/tests/builtins/cd10.0
index f4b5e0ffca5c..07396e8e0411 100644
--- a/bin/sh/tests/builtins/cd10.0
+++ b/bin/sh/tests/builtins/cd10.0
@@ -1,6 +1,5 @@
-# $FreeBSD$
# Precondition
(cd /bin) || exit
# Verify write error is ignored.
-$SH +m -ic 'CDPATH=/:; cd bin 1</dev/null'
+ENV= $SH +m -ic 'CDPATH=/:; cd bin 1</dev/null'
diff --git a/bin/sh/tests/builtins/cd11.0 b/bin/sh/tests/builtins/cd11.0
index 53e63f736f30..04e3469f8f3e 100644
--- a/bin/sh/tests/builtins/cd11.0
+++ b/bin/sh/tests/builtins/cd11.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -e
T=$(mktemp -d "${TMPDIR:-/tmp}/sh-test.XXXXXX")
diff --git a/bin/sh/tests/builtins/cd2.0 b/bin/sh/tests/builtins/cd2.0
index f2b6416a12ec..eea39115c3de 100644
--- a/bin/sh/tests/builtins/cd2.0
+++ b/bin/sh/tests/builtins/cd2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -e
L=$(getconf PATH_MAX / 2>/dev/null) || L=4096
diff --git a/bin/sh/tests/builtins/cd3.0 b/bin/sh/tests/builtins/cd3.0
index 7729c54a6895..d7211f5c5084 100644
--- a/bin/sh/tests/builtins/cd3.0
+++ b/bin/sh/tests/builtins/cd3.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# If fully successful, cd -Pe must be like cd -P.
diff --git a/bin/sh/tests/builtins/cd4.0 b/bin/sh/tests/builtins/cd4.0
index df3a9a48961c..33cf73632247 100644
--- a/bin/sh/tests/builtins/cd4.0
+++ b/bin/sh/tests/builtins/cd4.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# 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
diff --git a/bin/sh/tests/builtins/cd5.0 b/bin/sh/tests/builtins/cd5.0
index 3dff604583c9..ecb0d55a850b 100644
--- a/bin/sh/tests/builtins/cd5.0
+++ b/bin/sh/tests/builtins/cd5.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -e
T=$(mktemp -d "${TMPDIR:-/tmp}/sh-test.XXXXXX")
diff --git a/bin/sh/tests/builtins/cd6.0 b/bin/sh/tests/builtins/cd6.0
index 083a06190e64..27f14172be65 100644
--- a/bin/sh/tests/builtins/cd6.0
+++ b/bin/sh/tests/builtins/cd6.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -e
cd -P /bin
diff --git a/bin/sh/tests/builtins/cd7.0 b/bin/sh/tests/builtins/cd7.0
index 9adda86c1aed..5b656f422f02 100644
--- a/bin/sh/tests/builtins/cd7.0
+++ b/bin/sh/tests/builtins/cd7.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -e
cd /usr/bin
diff --git a/bin/sh/tests/builtins/cd8.0 b/bin/sh/tests/builtins/cd8.0
index a68f77f26f75..3aff675d8dce 100644
--- a/bin/sh/tests/builtins/cd8.0
+++ b/bin/sh/tests/builtins/cd8.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# The exact wording of the error message is not standardized, but giving
# a description of the errno is useful.
diff --git a/bin/sh/tests/builtins/cd9.0 b/bin/sh/tests/builtins/cd9.0
index 78bcdff9a933..811d75fff03d 100644
--- a/bin/sh/tests/builtins/cd9.0
+++ b/bin/sh/tests/builtins/cd9.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
cd /dev
cd /bin
diff --git a/bin/sh/tests/builtins/command1.0 b/bin/sh/tests/builtins/command1.0
index fd0afdfa0300..2f2b36bb6d2a 100644
--- a/bin/sh/tests/builtins/command1.0
+++ b/bin/sh/tests/builtins/command1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
true() {
false
}
diff --git a/bin/sh/tests/builtins/command10.0 b/bin/sh/tests/builtins/command10.0
index 2c1adf1eb0bd..add9e8372b0e 100644
--- a/bin/sh/tests/builtins/command10.0
+++ b/bin/sh/tests/builtins/command10.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
failures=0
diff --git a/bin/sh/tests/builtins/command11.0 b/bin/sh/tests/builtins/command11.0
index 10c86479d81b..9dc793d2f4f3 100644
--- a/bin/sh/tests/builtins/command11.0
+++ b/bin/sh/tests/builtins/command11.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
failures=0
diff --git a/bin/sh/tests/builtins/command12.0 b/bin/sh/tests/builtins/command12.0
index f981db324946..a602a48cfcca 100644
--- a/bin/sh/tests/builtins/command12.0
+++ b/bin/sh/tests/builtins/command12.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
alias aa=echo\ \'\"\'
cmd=$(command -v aa)
diff --git a/bin/sh/tests/builtins/command13.0 b/bin/sh/tests/builtins/command13.0
index 7c011c938a47..668664780ad0 100644
--- a/bin/sh/tests/builtins/command13.0
+++ b/bin/sh/tests/builtins/command13.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
failures=0
diff --git a/bin/sh/tests/builtins/command14.0 b/bin/sh/tests/builtins/command14.0
index 5f6f4447ef61..6e4f0fd5822d 100644
--- a/bin/sh/tests/builtins/command14.0
+++ b/bin/sh/tests/builtins/command14.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
r=`cd /bin && PATH=. command -V ls`
case $r in
diff --git a/bin/sh/tests/builtins/command2.0 b/bin/sh/tests/builtins/command2.0
index ff7b5f2c8dc8..0f6c76bf895f 100644
--- a/bin/sh/tests/builtins/command2.0
+++ b/bin/sh/tests/builtins/command2.0
@@ -1,3 +1,2 @@
-# $FreeBSD$
PATH=
command -p cat < /dev/null
diff --git a/bin/sh/tests/builtins/command3.0 b/bin/sh/tests/builtins/command3.0
index 9d4ae89e0e2e..d9e85caff744 100644
--- a/bin/sh/tests/builtins/command3.0
+++ b/bin/sh/tests/builtins/command3.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
command -v ls
command -v true
command -v /bin/ls
diff --git a/bin/sh/tests/builtins/command4.0 b/bin/sh/tests/builtins/command4.0
index 3e496137ff58..b2b0146fb56a 100644
--- a/bin/sh/tests/builtins/command4.0
+++ b/bin/sh/tests/builtins/command4.0
@@ -1,2 +1 @@
-# $FreeBSD$
! command -v nonexisting
diff --git a/bin/sh/tests/builtins/command5.0 b/bin/sh/tests/builtins/command5.0
index 13b3fe1fe3f4..050b44913f2d 100644
--- a/bin/sh/tests/builtins/command5.0
+++ b/bin/sh/tests/builtins/command5.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
command -V ls
command -V true
command -V /bin/ls
diff --git a/bin/sh/tests/builtins/command6.0 b/bin/sh/tests/builtins/command6.0
index 5b63bfecc0f0..56d65a095ab4 100644
--- a/bin/sh/tests/builtins/command6.0
+++ b/bin/sh/tests/builtins/command6.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
PATH=/var/empty
case $(command -pV ls) in
*/var/empty/ls*)
diff --git a/bin/sh/tests/builtins/command7.0 b/bin/sh/tests/builtins/command7.0
index fc652f207584..f45809ddc86b 100644
--- a/bin/sh/tests/builtins/command7.0
+++ b/bin/sh/tests/builtins/command7.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
failures=0
diff --git a/bin/sh/tests/builtins/command8.0 b/bin/sh/tests/builtins/command8.0
index 9e3a2b645fbb..df50cb4f973b 100644
--- a/bin/sh/tests/builtins/command8.0
+++ b/bin/sh/tests/builtins/command8.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
IFS=,
SPECIAL="break,\
diff --git a/bin/sh/tests/builtins/command9.0 b/bin/sh/tests/builtins/command9.0
index 212e52aafc98..3dbc1e0a433b 100644
--- a/bin/sh/tests/builtins/command9.0
+++ b/bin/sh/tests/builtins/command9.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
failures=0
diff --git a/bin/sh/tests/builtins/dot1.0 b/bin/sh/tests/builtins/dot1.0
index 43eab0ddeb33..0ecfb7ef4886 100644
--- a/bin/sh/tests/builtins/dot1.0
+++ b/bin/sh/tests/builtins/dot1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
failures=
failure() {
diff --git a/bin/sh/tests/builtins/dot2.0 b/bin/sh/tests/builtins/dot2.0
index ed6379b993c3..497e2139513a 100644
--- a/bin/sh/tests/builtins/dot2.0
+++ b/bin/sh/tests/builtins/dot2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
failures=
failure() {
diff --git a/bin/sh/tests/builtins/dot3.0 b/bin/sh/tests/builtins/dot3.0
index b337f0f6d338..9017a52d816b 100644
--- a/bin/sh/tests/builtins/dot3.0
+++ b/bin/sh/tests/builtins/dot3.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# . should return 0 if no command was executed.
diff --git a/bin/sh/tests/builtins/dot4.0 b/bin/sh/tests/builtins/dot4.0
index b898131c0e1c..c9cf7ec67f6f 100644
--- a/bin/sh/tests/builtins/dot4.0
+++ b/bin/sh/tests/builtins/dot4.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
v=abcd
v=$v$v$v$v
diff --git a/bin/sh/tests/builtins/echo1.0 b/bin/sh/tests/builtins/echo1.0
index 75ed8fbbc45f..6b9b14da832e 100644
--- a/bin/sh/tests/builtins/echo1.0
+++ b/bin/sh/tests/builtins/echo1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Not specified by POSIX.
diff --git a/bin/sh/tests/builtins/echo2.0 b/bin/sh/tests/builtins/echo2.0
index 254b5c4dca4f..9d8d9817e9a8 100644
--- a/bin/sh/tests/builtins/echo2.0
+++ b/bin/sh/tests/builtins/echo2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Not specified by POSIX.
diff --git a/bin/sh/tests/builtins/echo3.0 b/bin/sh/tests/builtins/echo3.0
index ff8f6c2f26e4..a56d3da07aad 100644
--- a/bin/sh/tests/builtins/echo3.0
+++ b/bin/sh/tests/builtins/echo3.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Not specified by POSIX.
diff --git a/bin/sh/tests/builtins/eval1.0 b/bin/sh/tests/builtins/eval1.0
index 04606a4a87fe..9019d3b9bb98 100644
--- a/bin/sh/tests/builtins/eval1.0
+++ b/bin/sh/tests/builtins/eval1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -e
eval
diff --git a/bin/sh/tests/builtins/eval2.0 b/bin/sh/tests/builtins/eval2.0
index bf06b6e14e0c..b762ac2eea76 100644
--- a/bin/sh/tests/builtins/eval2.0
+++ b/bin/sh/tests/builtins/eval2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
eval '
false
diff --git a/bin/sh/tests/builtins/eval3.0 b/bin/sh/tests/builtins/eval3.0
index dfb8357c727c..12f36dc00dfd 100644
--- a/bin/sh/tests/builtins/eval3.0
+++ b/bin/sh/tests/builtins/eval3.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
eval 'false;' && exit 1
eval 'true;' || exit 1
diff --git a/bin/sh/tests/builtins/eval4.0 b/bin/sh/tests/builtins/eval4.0
index 67da2f5c832d..3eb4e3679fe7 100644
--- a/bin/sh/tests/builtins/eval4.0
+++ b/bin/sh/tests/builtins/eval4.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# eval should preserve $? from command substitutions when starting
# the parsed command.
diff --git a/bin/sh/tests/builtins/eval5.0 b/bin/sh/tests/builtins/eval5.0
index 3e86de92fbae..44d125408deb 100644
--- a/bin/sh/tests/builtins/eval5.0
+++ b/bin/sh/tests/builtins/eval5.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# eval should return 0 if no command was executed.
eval $(false)
diff --git a/bin/sh/tests/builtins/eval6.0 b/bin/sh/tests/builtins/eval6.0
index 6752bb65ad4d..84584f1c1bf3 100644
--- a/bin/sh/tests/builtins/eval6.0
+++ b/bin/sh/tests/builtins/eval6.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# eval should preserve $? from command substitutions when starting
# the parsed command.
diff --git a/bin/sh/tests/builtins/eval7.0 b/bin/sh/tests/builtins/eval7.0
index a309c917b102..238353fb5c5d 100644
--- a/bin/sh/tests/builtins/eval7.0
+++ b/bin/sh/tests/builtins/eval7.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Assumes that break can break out of a loop outside eval.
while :; do
diff --git a/bin/sh/tests/builtins/eval8.7 b/bin/sh/tests/builtins/eval8.7
index af6064c388df..671fcb5cb190 100644
--- a/bin/sh/tests/builtins/eval8.7
+++ b/bin/sh/tests/builtins/eval8.7
@@ -1,4 +1,3 @@
-# $FreeBSD$
f() {
eval "return 7
diff --git a/bin/sh/tests/builtins/exec1.0 b/bin/sh/tests/builtins/exec1.0
index dd30a4c9aa93..a3d993a739eb 100644
--- a/bin/sh/tests/builtins/exec1.0
+++ b/bin/sh/tests/builtins/exec1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
failures=
failure() {
diff --git a/bin/sh/tests/builtins/exec2.0 b/bin/sh/tests/builtins/exec2.0
index 3dcb6c41156a..9ed1013acd92 100644
--- a/bin/sh/tests/builtins/exec2.0
+++ b/bin/sh/tests/builtins/exec2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
failures=
failure() {
diff --git a/bin/sh/tests/builtins/exit1.0 b/bin/sh/tests/builtins/exit1.0
index 496d448761cc..fb6486cebeac 100644
--- a/bin/sh/tests/builtins/exit1.0
+++ b/bin/sh/tests/builtins/exit1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# exit with an argument should overwrite the exit status in an EXIT trap.
diff --git a/bin/sh/tests/builtins/exit2.8 b/bin/sh/tests/builtins/exit2.8
index 124c32e01a3c..327b620c3fa6 100644
--- a/bin/sh/tests/builtins/exit2.8
+++ b/bin/sh/tests/builtins/exit2.8
@@ -1,4 +1,3 @@
-# $FreeBSD$
# exit without arguments is the same as exit $? outside a trap.
diff --git a/bin/sh/tests/builtins/exit3.0 b/bin/sh/tests/builtins/exit3.0
index 80655ac539c5..996074c10182 100644
--- a/bin/sh/tests/builtins/exit3.0
+++ b/bin/sh/tests/builtins/exit3.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# exit without arguments differs from exit $? in an EXIT trap.
diff --git a/bin/sh/tests/builtins/export1.0 b/bin/sh/tests/builtins/export1.0
index 7b08c9de4349..e2802c4f8e89 100644
--- a/bin/sh/tests/builtins/export1.0
+++ b/bin/sh/tests/builtins/export1.0
@@ -1,3 +1,2 @@
-# $FreeBSD$
env @badness=1 ${SH} -c 'v=`export -p`; eval "$v"'
diff --git a/bin/sh/tests/builtins/fc1.0 b/bin/sh/tests/builtins/fc1.0
index ab7a387b5077..c84fb0549012 100644
--- a/bin/sh/tests/builtins/fc1.0
+++ b/bin/sh/tests/builtins/fc1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -e
trap 'echo Broken pipe -- test failed' PIPE
@@ -8,7 +7,7 @@ T=$(mktemp -d sh-test.XXXXXX)
cd $T
mkfifo input output error
-HISTFILE=/dev/null ${SH} +m -i <input >output 2>error &
+ENV= HISTFILE=/dev/null ${SH} +m -i <input >output 2>error &
{
# Syntax error
echo ')' >&3
diff --git a/bin/sh/tests/builtins/fc2.0 b/bin/sh/tests/builtins/fc2.0
index 7eb92acc2cdf..53c0f786cda2 100644
--- a/bin/sh/tests/builtins/fc2.0
+++ b/bin/sh/tests/builtins/fc2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -e
trap 'echo Broken pipe -- test failed' PIPE
diff --git a/bin/sh/tests/builtins/fc3.0 b/bin/sh/tests/builtins/fc3.0
new file mode 100644
index 000000000000..daa615bcc3ca
--- /dev/null
+++ b/bin/sh/tests/builtins/fc3.0
@@ -0,0 +1,9 @@
+export PS1='_ ' # cannot predict whether ran by root or not
+
+echo ': command1
+: command2
+: command3
+: command4
+fc -l -n -1
+fc -ln 2 3
+' | ENV= HISTFILE=/dev/null ${SH} +m -i
diff --git a/bin/sh/tests/builtins/fc3.0.stderr b/bin/sh/tests/builtins/fc3.0.stderr
new file mode 100644
index 000000000000..e05147fb8209
--- /dev/null
+++ b/bin/sh/tests/builtins/fc3.0.stderr
@@ -0,0 +1 @@
+_ _ _ _ _ _ _ _
diff --git a/bin/sh/tests/builtins/fc3.0.stdout b/bin/sh/tests/builtins/fc3.0.stdout
new file mode 100644
index 000000000000..8c23c913635d
--- /dev/null
+++ b/bin/sh/tests/builtins/fc3.0.stdout
@@ -0,0 +1,3 @@
+: command4
+: command2
+: command3
diff --git a/bin/sh/tests/builtins/for1.0 b/bin/sh/tests/builtins/for1.0
index cd55e2ca029e..f1a64f412bc4 100644
--- a/bin/sh/tests/builtins/for1.0
+++ b/bin/sh/tests/builtins/for1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
false
for i in `false`; do exit 3; done
diff --git a/bin/sh/tests/builtins/for2.0 b/bin/sh/tests/builtins/for2.0
index 48c22ce71119..0ed4e1158eaa 100644
--- a/bin/sh/tests/builtins/for2.0
+++ b/bin/sh/tests/builtins/for2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
r=x
f() { return 42; }
diff --git a/bin/sh/tests/builtins/for3.0 b/bin/sh/tests/builtins/for3.0
index cc37238abbc6..010606b16c75 100644
--- a/bin/sh/tests/builtins/for3.0
+++ b/bin/sh/tests/builtins/for3.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
r=x
f() { return 42; }
diff --git a/bin/sh/tests/builtins/getopts1.0 b/bin/sh/tests/builtins/getopts1.0
index 10d2b59208e5..928f472900e6 100644
--- a/bin/sh/tests/builtins/getopts1.0
+++ b/bin/sh/tests/builtins/getopts1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
printf -- '-1-\n'
set -- -abc
diff --git a/bin/sh/tests/builtins/getopts10.0 b/bin/sh/tests/builtins/getopts10.0
index a88e6ca3e85e..5182da24a0b0 100644
--- a/bin/sh/tests/builtins/getopts10.0
+++ b/bin/sh/tests/builtins/getopts10.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -- -x arg
opt=not
diff --git a/bin/sh/tests/builtins/getopts2.0 b/bin/sh/tests/builtins/getopts2.0
index 1bd2c32db81c..b12813e6247d 100644
--- a/bin/sh/tests/builtins/getopts2.0
+++ b/bin/sh/tests/builtins/getopts2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set - -ax
getopts ax option
set -C
diff --git a/bin/sh/tests/builtins/getopts3.0 b/bin/sh/tests/builtins/getopts3.0
index d02469b20469..c52e60ada860 100644
--- a/bin/sh/tests/builtins/getopts3.0
+++ b/bin/sh/tests/builtins/getopts3.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
shift $#
getopts x opt
diff --git a/bin/sh/tests/builtins/getopts4.0 b/bin/sh/tests/builtins/getopts4.0
index 61d5c2b6b15c..f4df551cb571 100644
--- a/bin/sh/tests/builtins/getopts4.0
+++ b/bin/sh/tests/builtins/getopts4.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -- -x
opt=not
diff --git a/bin/sh/tests/builtins/getopts5.0 b/bin/sh/tests/builtins/getopts5.0
index 666ee7652de5..d037b9705882 100644
--- a/bin/sh/tests/builtins/getopts5.0
+++ b/bin/sh/tests/builtins/getopts5.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -- -x arg
opt=not
diff --git a/bin/sh/tests/builtins/getopts6.0 b/bin/sh/tests/builtins/getopts6.0
index 1d3c39ba953e..5cf2bc462915 100644
--- a/bin/sh/tests/builtins/getopts6.0
+++ b/bin/sh/tests/builtins/getopts6.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -- -x -y
getopts :x var || echo "First getopts bad: $?"
diff --git a/bin/sh/tests/builtins/getopts7.0 b/bin/sh/tests/builtins/getopts7.0
index 3745555f8c1a..5dd5ed593c27 100644
--- a/bin/sh/tests/builtins/getopts7.0
+++ b/bin/sh/tests/builtins/getopts7.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -- -x
getopts :x: var
diff --git a/bin/sh/tests/builtins/getopts8.0 b/bin/sh/tests/builtins/getopts8.0
index da4af6bd0b56..30b36630c7b0 100644
--- a/bin/sh/tests/builtins/getopts8.0
+++ b/bin/sh/tests/builtins/getopts8.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -- -yz -wx
opt=wrong1 OPTARG=wrong2
diff --git a/bin/sh/tests/builtins/getopts9.0 b/bin/sh/tests/builtins/getopts9.0
index 1c35fc68c2d1..5e91f92614dd 100644
--- a/bin/sh/tests/builtins/getopts9.0
+++ b/bin/sh/tests/builtins/getopts9.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
args='-ab'
getopts ab opt $args
diff --git a/bin/sh/tests/builtins/hash1.0 b/bin/sh/tests/builtins/hash1.0
index 45cc3003fb59..750fd40cafe5 100644
--- a/bin/sh/tests/builtins/hash1.0
+++ b/bin/sh/tests/builtins/hash1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
cat /dev/null
hash
hash -r
diff --git a/bin/sh/tests/builtins/hash2.0 b/bin/sh/tests/builtins/hash2.0
index e5cd21bc57dd..ec072b93a1a2 100644
--- a/bin/sh/tests/builtins/hash2.0
+++ b/bin/sh/tests/builtins/hash2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
hash
hash cat
hash
diff --git a/bin/sh/tests/builtins/hash3.0 b/bin/sh/tests/builtins/hash3.0
index eade0b319546..3ef33dc4bb3a 100644
--- a/bin/sh/tests/builtins/hash3.0
+++ b/bin/sh/tests/builtins/hash3.0
@@ -1,3 +1,2 @@
-# $FreeBSD$
hash -v cat
hash
diff --git a/bin/sh/tests/builtins/hash4.0 b/bin/sh/tests/builtins/hash4.0
index dec584c4538f..3e99930bad47 100644
--- a/bin/sh/tests/builtins/hash4.0
+++ b/bin/sh/tests/builtins/hash4.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
exec 3>&1
m=`hash nosuchtool 2>&1 >&3`
diff --git a/bin/sh/tests/builtins/jobid1.0 b/bin/sh/tests/builtins/jobid1.0
index 483fda20743c..093b2c210778 100644
--- a/bin/sh/tests/builtins/jobid1.0
+++ b/bin/sh/tests/builtins/jobid1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Non-standard builtin.
: &
diff --git a/bin/sh/tests/builtins/jobid2.0 b/bin/sh/tests/builtins/jobid2.0
index 101831a2e4b8..bf3de17d01cf 100644
--- a/bin/sh/tests/builtins/jobid2.0
+++ b/bin/sh/tests/builtins/jobid2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
: &
p1=$(jobid)
diff --git a/bin/sh/tests/builtins/kill1.0 b/bin/sh/tests/builtins/kill1.0
index c1b85503848e..85b8b579b3ad 100644
--- a/bin/sh/tests/builtins/kill1.0
+++ b/bin/sh/tests/builtins/kill1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
: &
p1=$!
diff --git a/bin/sh/tests/builtins/kill2.0 b/bin/sh/tests/builtins/kill2.0
index 31e0ba362b80..13d2a4a896c1 100644
--- a/bin/sh/tests/builtins/kill2.0
+++ b/bin/sh/tests/builtins/kill2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
sleep 1 | sleep 1 &
kill %+
diff --git a/bin/sh/tests/builtins/lineno.0 b/bin/sh/tests/builtins/lineno.0
index c9311f82d253..d314eef0f85c 100644
--- a/bin/sh/tests/builtins/lineno.0
+++ b/bin/sh/tests/builtins/lineno.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
echo $LINENO
echo $LINENO
diff --git a/bin/sh/tests/builtins/lineno.0.stdout b/bin/sh/tests/builtins/lineno.0.stdout
index 82583a93c82e..ab5ad9cbef51 100644
--- a/bin/sh/tests/builtins/lineno.0.stdout
+++ b/bin/sh/tests/builtins/lineno.0.stdout
@@ -1,9 +1,9 @@
+1
2
-3
2
3
+11
12
-13
foo
foo
2
diff --git a/bin/sh/tests/builtins/lineno2.0 b/bin/sh/tests/builtins/lineno2.0
index ddbd10433a36..db2a6c8c7b4f 100644
--- a/bin/sh/tests/builtins/lineno2.0
+++ b/bin/sh/tests/builtins/lineno2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
f() {
: ${LINENO+${x?}}
diff --git a/bin/sh/tests/builtins/lineno3.0 b/bin/sh/tests/builtins/lineno3.0
index eb8f9ab7db94..66ede861dc75 100644
--- a/bin/sh/tests/builtins/lineno3.0
+++ b/bin/sh/tests/builtins/lineno3.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
echo before: $LINENO
dummy=$'a\0
diff --git a/bin/sh/tests/builtins/lineno3.0.stdout b/bin/sh/tests/builtins/lineno3.0.stdout
index 6e0e4ac8ca57..f8b44636cb5d 100644
--- a/bin/sh/tests/builtins/lineno3.0.stdout
+++ b/bin/sh/tests/builtins/lineno3.0.stdout
@@ -1,2 +1,2 @@
-before: 3
-after: 6
+before: 2
+after: 5
diff --git a/bin/sh/tests/builtins/local1.0 b/bin/sh/tests/builtins/local1.0
index b28837ec005f..e5278d492639 100644
--- a/bin/sh/tests/builtins/local1.0
+++ b/bin/sh/tests/builtins/local1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# A commonly used but non-POSIX builtin.
f() {
diff --git a/bin/sh/tests/builtins/local2.0 b/bin/sh/tests/builtins/local2.0
index cc8c10f40618..24cef4c1bc3a 100644
--- a/bin/sh/tests/builtins/local2.0
+++ b/bin/sh/tests/builtins/local2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
f() {
local -
diff --git a/bin/sh/tests/builtins/local3.0 b/bin/sh/tests/builtins/local3.0
index 39ee370099e7..e947b7c495f6 100644
--- a/bin/sh/tests/builtins/local3.0
+++ b/bin/sh/tests/builtins/local3.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
f() {
local "$@"
diff --git a/bin/sh/tests/builtins/local4.0 b/bin/sh/tests/builtins/local4.0
index 3955aaa12f1a..bd5a5765192b 100644
--- a/bin/sh/tests/builtins/local4.0
+++ b/bin/sh/tests/builtins/local4.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
f() {
local -- x
diff --git a/bin/sh/tests/builtins/local5.0 b/bin/sh/tests/builtins/local5.0
index 2f2a14e110ae..82b4014e8e4b 100644
--- a/bin/sh/tests/builtins/local5.0
+++ b/bin/sh/tests/builtins/local5.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
f() {
local PATH IFS elem
diff --git a/bin/sh/tests/builtins/local6.0 b/bin/sh/tests/builtins/local6.0
index 017bb1234c8c..f179fe00f95d 100644
--- a/bin/sh/tests/builtins/local6.0
+++ b/bin/sh/tests/builtins/local6.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
f() {
local x
diff --git a/bin/sh/tests/builtins/local7.0 b/bin/sh/tests/builtins/local7.0
index f7e6fc0aae97..591606d9bd93 100644
--- a/bin/sh/tests/builtins/local7.0
+++ b/bin/sh/tests/builtins/local7.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
f() {
local x
diff --git a/bin/sh/tests/builtins/locale1.0 b/bin/sh/tests/builtins/locale1.0
index 90b10944c5a5..f81dbac4f342 100644
--- a/bin/sh/tests/builtins/locale1.0
+++ b/bin/sh/tests/builtins/locale1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Note: this test depends on strerror() using locale.
failures=0
diff --git a/bin/sh/tests/builtins/locale2.0 b/bin/sh/tests/builtins/locale2.0
index 86dd237ff54a..050d7fc9fbfc 100644
--- a/bin/sh/tests/builtins/locale2.0
+++ b/bin/sh/tests/builtins/locale2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
$SH -c 'LC_ALL=C true; kill -INT $$; echo continued'
r=$?
diff --git a/bin/sh/tests/builtins/printf1.0 b/bin/sh/tests/builtins/printf1.0
index 99a82d014794..1dfbf7a9be4a 100644
--- a/bin/sh/tests/builtins/printf1.0
+++ b/bin/sh/tests/builtins/printf1.0
@@ -1,3 +1,2 @@
-# $FreeBSD$
[ "$(printf '%c\0%s%d' x '\' 010 | tr '\0' Z)" = 'xZ\8' ]
diff --git a/bin/sh/tests/builtins/printf2.0 b/bin/sh/tests/builtins/printf2.0
index 7763d6fe9636..8376505c9df5 100644
--- a/bin/sh/tests/builtins/printf2.0
+++ b/bin/sh/tests/builtins/printf2.0
@@ -1,3 +1,2 @@
-# $FreeBSD$
[ "$(printf '%cZ%s%d' x '\' 010)" = 'xZ\8' ]
diff --git a/bin/sh/tests/builtins/printf3.0 b/bin/sh/tests/builtins/printf3.0
index 0e7ea85cddb4..b431cc6d3d18 100644
--- a/bin/sh/tests/builtins/printf3.0
+++ b/bin/sh/tests/builtins/printf3.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -e
v=$(! printf "%d" @wrong 2>/dev/null)
diff --git a/bin/sh/tests/builtins/printf4.0 b/bin/sh/tests/builtins/printf4.0
index 2dd3e729574a..15d57f782789 100644
--- a/bin/sh/tests/builtins/printf4.0
+++ b/bin/sh/tests/builtins/printf4.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -e
v=$(! printf "%d" 4wrong 2>/dev/null)
diff --git a/bin/sh/tests/builtins/read1.0 b/bin/sh/tests/builtins/read1.0
index 06a68faa32a3..b1617c7f48bf 100644
--- a/bin/sh/tests/builtins/read1.0
+++ b/bin/sh/tests/builtins/read1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -e
echo "1 2 3" | { read a; echo "x${a}x"; }
diff --git a/bin/sh/tests/builtins/read2.0 b/bin/sh/tests/builtins/read2.0
index fc7451191586..da7c48553ab0 100644
--- a/bin/sh/tests/builtins/read2.0
+++ b/bin/sh/tests/builtins/read2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -e
{
diff --git a/bin/sh/tests/builtins/read3.0 b/bin/sh/tests/builtins/read3.0
index c6ae9c1023c0..3674ec9f4055 100644
--- a/bin/sh/tests/builtins/read3.0
+++ b/bin/sh/tests/builtins/read3.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
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"; }
diff --git a/bin/sh/tests/builtins/read4.0 b/bin/sh/tests/builtins/read4.0
index 7204a35aa0a5..4856feddb5c8 100644
--- a/bin/sh/tests/builtins/read4.0
+++ b/bin/sh/tests/builtins/read4.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
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"; }
diff --git a/bin/sh/tests/builtins/read5.0 b/bin/sh/tests/builtins/read5.0
index 7d83391cba22..bbdf246287bd 100644
--- a/bin/sh/tests/builtins/read5.0
+++ b/bin/sh/tests/builtins/read5.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
unset LC_ALL
LC_CTYPE=en_US.ISO8859-1
diff --git a/bin/sh/tests/builtins/read6.0 b/bin/sh/tests/builtins/read6.0
index 2168e10c841a..60df35f7ee1f 100644
--- a/bin/sh/tests/builtins/read6.0
+++ b/bin/sh/tests/builtins/read6.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
: | read x
r=$?
diff --git a/bin/sh/tests/builtins/read7.0 b/bin/sh/tests/builtins/read7.0
index e78f887b60b4..1e159dca6160 100644
--- a/bin/sh/tests/builtins/read7.0
+++ b/bin/sh/tests/builtins/read7.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
{ errmsg=`read x <&- 2>&1 >&3`; } 3>&1
r=$?
diff --git a/bin/sh/tests/builtins/read8.0 b/bin/sh/tests/builtins/read8.0
index fb786ff008b9..3de0f72c4694 100644
--- a/bin/sh/tests/builtins/read8.0
+++ b/bin/sh/tests/builtins/read8.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
read a b c <<\EOF
\
diff --git a/bin/sh/tests/builtins/read9.0 b/bin/sh/tests/builtins/read9.0
index 080549889839..23d814934d3c 100644
--- a/bin/sh/tests/builtins/read9.0
+++ b/bin/sh/tests/builtins/read9.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
empty=''
read a b c <<EOF
diff --git a/bin/sh/tests/builtins/return1.0 b/bin/sh/tests/builtins/return1.0
index 787e892a7698..b3820b4597a8 100644
--- a/bin/sh/tests/builtins/return1.0
+++ b/bin/sh/tests/builtins/return1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
f() {
return 0
exit 1
diff --git a/bin/sh/tests/builtins/return2.1 b/bin/sh/tests/builtins/return2.1
index 0ef817179d73..8cd5ca58a42d 100644
--- a/bin/sh/tests/builtins/return2.1
+++ b/bin/sh/tests/builtins/return2.1
@@ -1,4 +1,3 @@
-# $FreeBSD$
f() {
true && return 1
return 0
diff --git a/bin/sh/tests/builtins/return3.1 b/bin/sh/tests/builtins/return3.1
index 605ec680d66a..e871c055afce 100644
--- a/bin/sh/tests/builtins/return3.1
+++ b/bin/sh/tests/builtins/return3.1
@@ -1,3 +1,2 @@
-# $FreeBSD$
return 1
exit 0
diff --git a/bin/sh/tests/builtins/return4.0 b/bin/sh/tests/builtins/return4.0
index be5582b458b4..a2edab53c222 100644
--- a/bin/sh/tests/builtins/return4.0
+++ b/bin/sh/tests/builtins/return4.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
failures=
failure() {
diff --git a/bin/sh/tests/builtins/return5.0 b/bin/sh/tests/builtins/return5.0
index 6e4b7bd751a8..46243b6b20c6 100644
--- a/bin/sh/tests/builtins/return5.0
+++ b/bin/sh/tests/builtins/return5.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
if [ "$1" != nested ]; then
f() {
diff --git a/bin/sh/tests/builtins/return6.4 b/bin/sh/tests/builtins/return6.4
index e4d8e0d641a1..172459f40c68 100644
--- a/bin/sh/tests/builtins/return6.4
+++ b/bin/sh/tests/builtins/return6.4
@@ -1,3 +1,2 @@
-# $FreeBSD$
while return 4; do exit 3; done
diff --git a/bin/sh/tests/builtins/return7.4 b/bin/sh/tests/builtins/return7.4
index 2047373473ab..9f914d70e928 100644
--- a/bin/sh/tests/builtins/return7.4
+++ b/bin/sh/tests/builtins/return7.4
@@ -1,4 +1,3 @@
-# $FreeBSD$
f() {
while return 4; do exit 3; done
diff --git a/bin/sh/tests/builtins/return8.0 b/bin/sh/tests/builtins/return8.0
index f00e859a74ce..c9f5b0a03c2f 100644
--- a/bin/sh/tests/builtins/return8.0
+++ b/bin/sh/tests/builtins/return8.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
if [ "$1" = nested ]; then
return 17
diff --git a/bin/sh/tests/builtins/set1.0 b/bin/sh/tests/builtins/set1.0
index fc39fade6270..3f311fc0287d 100644
--- a/bin/sh/tests/builtins/set1.0
+++ b/bin/sh/tests/builtins/set1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set +C
set +f
diff --git a/bin/sh/tests/builtins/set2.0 b/bin/sh/tests/builtins/set2.0
index ad13eab0a7b8..f959cf797fe2 100644
--- a/bin/sh/tests/builtins/set2.0
+++ b/bin/sh/tests/builtins/set2.0
@@ -1,3 +1,2 @@
-# $FreeBSD$
! env @badness=1 ${SH} -c 'v=`set`; eval "$v"' 2>&1 | grep @badness
diff --git a/bin/sh/tests/builtins/set3.0 b/bin/sh/tests/builtins/set3.0
index c5536e96b7a1..44255adc4bda 100644
--- a/bin/sh/tests/builtins/set3.0
+++ b/bin/sh/tests/builtins/set3.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
settings1=$(set +o) && set -o nolog && settings2=$(set +o) &&
[ "$settings1" != "$settings2" ]
diff --git a/bin/sh/tests/builtins/trap1.0 b/bin/sh/tests/builtins/trap1.0
index 313f6a387678..7f39faba319a 100644
--- a/bin/sh/tests/builtins/trap1.0
+++ b/bin/sh/tests/builtins/trap1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
test "$(trap 'echo trapped' EXIT; :)" = trapped || exit 1
diff --git a/bin/sh/tests/builtins/trap10.0 b/bin/sh/tests/builtins/trap10.0
index fa0e35d6a6b2..96baa6532224 100644
--- a/bin/sh/tests/builtins/trap10.0
+++ b/bin/sh/tests/builtins/trap10.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Check that the return statement will not break the EXIT trap, ie. all
# trap commands are executed before the script exits.
diff --git a/bin/sh/tests/builtins/trap11.0 b/bin/sh/tests/builtins/trap11.0
index cfeea9ed9ded..354698d90ea3 100644
--- a/bin/sh/tests/builtins/trap11.0
+++ b/bin/sh/tests/builtins/trap11.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Check that the return statement will not break the USR1 trap, ie. all
# trap commands are executed before the script resumes.
diff --git a/bin/sh/tests/builtins/trap12.0 b/bin/sh/tests/builtins/trap12.0
index 8c62ffd2b570..87592af250ad 100644
--- a/bin/sh/tests/builtins/trap12.0
+++ b/bin/sh/tests/builtins/trap12.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
f() {
trap 'return 42' USR1
diff --git a/bin/sh/tests/builtins/trap13.0 b/bin/sh/tests/builtins/trap13.0
index d90eb08eb242..81db991a4978 100644
--- a/bin/sh/tests/builtins/trap13.0
+++ b/bin/sh/tests/builtins/trap13.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
{
trap 'exit 0' INT
diff --git a/bin/sh/tests/builtins/trap14.0 b/bin/sh/tests/builtins/trap14.0
index 97cce8d0d244..cf22b15b4677 100644
--- a/bin/sh/tests/builtins/trap14.0
+++ b/bin/sh/tests/builtins/trap14.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
{
trap - INT
diff --git a/bin/sh/tests/builtins/trap15.0 b/bin/sh/tests/builtins/trap15.0
index 6b9857df3d1a..a7e8d6475f10 100644
--- a/bin/sh/tests/builtins/trap15.0
+++ b/bin/sh/tests/builtins/trap15.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
(${SH} -c 'term(){ exit 5;}; trap term TERM; kill -TERM $$') &
wait >/dev/null 2>&1 $!
diff --git a/bin/sh/tests/builtins/trap16.0 b/bin/sh/tests/builtins/trap16.0
index 3d70cce8a721..23c615ab41e3 100644
--- a/bin/sh/tests/builtins/trap16.0
+++ b/bin/sh/tests/builtins/trap16.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
traps=$(${SH} -c 'trap "echo bad" 0; trap - 0; trap')
[ -z "$traps" ] || exit 1
diff --git a/bin/sh/tests/builtins/trap17.0 b/bin/sh/tests/builtins/trap17.0
index 89be893edd1a..580c41fc2498 100644
--- a/bin/sh/tests/builtins/trap17.0
+++ b/bin/sh/tests/builtins/trap17.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# This use-after-free bug probably needs non-default settings to show up.
v1=nothing v2=nothing
diff --git a/bin/sh/tests/builtins/trap2.0 b/bin/sh/tests/builtins/trap2.0
index a05287a16771..d2ea0599940b 100644
--- a/bin/sh/tests/builtins/trap2.0
+++ b/bin/sh/tests/builtins/trap2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# This is really a test for outqstr(), which is readily accessible via trap.
runtest()
diff --git a/bin/sh/tests/builtins/trap3.0 b/bin/sh/tests/builtins/trap3.0
index 81607293531e..5f6bd73654ec 100644
--- a/bin/sh/tests/builtins/trap3.0
+++ b/bin/sh/tests/builtins/trap3.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
{
trap '' garbage && exit 3
diff --git a/bin/sh/tests/builtins/trap4.0 b/bin/sh/tests/builtins/trap4.0
index 7f2080ee4dca..52ca5c777381 100644
--- a/bin/sh/tests/builtins/trap4.0
+++ b/bin/sh/tests/builtins/trap4.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
T=$(mktemp -d ${TMPDIR:-/tmp}/sh-test.XXXXXX)
trap 'rm -rf $T' 0
diff --git a/bin/sh/tests/builtins/trap5.0 b/bin/sh/tests/builtins/trap5.0
index 56e0fb1b89fe..7dd9bffa1f96 100644
--- a/bin/sh/tests/builtins/trap5.0
+++ b/bin/sh/tests/builtins/trap5.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -e
trap - USR1
diff --git a/bin/sh/tests/builtins/trap6.0 b/bin/sh/tests/builtins/trap6.0
index bd2bf7efe769..aca7e4c633d0 100644
--- a/bin/sh/tests/builtins/trap6.0
+++ b/bin/sh/tests/builtins/trap6.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
v=$(
${SH} -c 'trap "echo ok; exit" USR1; kill -USR1 $$' &
diff --git a/bin/sh/tests/builtins/trap7.0 b/bin/sh/tests/builtins/trap7.0
index 35529b80f4bf..0f208551017b 100644
--- a/bin/sh/tests/builtins/trap7.0
+++ b/bin/sh/tests/builtins/trap7.0
@@ -1,3 +1,2 @@
-# $FreeBSD$
[ "$(trap 'echo trapped' EXIT)" = trapped ]
diff --git a/bin/sh/tests/builtins/trap8.0 b/bin/sh/tests/builtins/trap8.0
index cdce976e36da..b04f53079e9d 100644
--- a/bin/sh/tests/builtins/trap8.0
+++ b/bin/sh/tests/builtins/trap8.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# I am not sure if POSIX requires the shell to continue processing
# further trap names in the same trap command after an invalid one.
diff --git a/bin/sh/tests/builtins/trap9.0 b/bin/sh/tests/builtins/trap9.0
index 0f584ecec584..187249bf7ed0 100644
--- a/bin/sh/tests/builtins/trap9.0
+++ b/bin/sh/tests/builtins/trap9.0
@@ -1,3 +1,2 @@
-# $FreeBSD$
test "$(trap 'printf trap; echo ped' EXIT; f() { :; }; f)" = trapped || exit 1
diff --git a/bin/sh/tests/builtins/type1.0 b/bin/sh/tests/builtins/type1.0
index c5e456437946..35c9f7bed236 100644
--- a/bin/sh/tests/builtins/type1.0
+++ b/bin/sh/tests/builtins/type1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
command -v not-here && exit 1
command -v /not-here && exit 1
command -V not-here && exit 1
diff --git a/bin/sh/tests/builtins/type2.0 b/bin/sh/tests/builtins/type2.0
index fe44d957fc0a..79b912a52070 100644
--- a/bin/sh/tests/builtins/type2.0
+++ b/bin/sh/tests/builtins/type2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
failures=0
diff --git a/bin/sh/tests/builtins/type3.0 b/bin/sh/tests/builtins/type3.0
index 87cccdd812cc..ccca26b2d741 100644
--- a/bin/sh/tests/builtins/type3.0
+++ b/bin/sh/tests/builtins/type3.0
@@ -1,3 +1,2 @@
-# $FreeBSD$
[ "$(type type)" = "$(type -- type)" ]
diff --git a/bin/sh/tests/builtins/type4.0 b/bin/sh/tests/builtins/type4.0
index 5b5f96c5078d..570c67d52cd7 100644
--- a/bin/sh/tests/builtins/type4.0
+++ b/bin/sh/tests/builtins/type4.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
r=`cd /bin && PATH=. type ls`
case $r in
diff --git a/bin/sh/tests/builtins/unalias.0 b/bin/sh/tests/builtins/unalias.0
index 34d8d6e07d2e..3e5ae88e5432 100644
--- a/bin/sh/tests/builtins/unalias.0
+++ b/bin/sh/tests/builtins/unalias.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -e
alias false=true
diff --git a/bin/sh/tests/builtins/var-assign.0 b/bin/sh/tests/builtins/var-assign.0
index efeb4bd130ac..06b13875e6ae 100644
--- a/bin/sh/tests/builtins/var-assign.0
+++ b/bin/sh/tests/builtins/var-assign.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
IFS=,
SPECIAL="break,\
diff --git a/bin/sh/tests/builtins/var-assign2.0 b/bin/sh/tests/builtins/var-assign2.0
index eafec89a681b..e8b14d3832b4 100644
--- a/bin/sh/tests/builtins/var-assign2.0
+++ b/bin/sh/tests/builtins/var-assign2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
IFS=,
SPECIAL="break,\
diff --git a/bin/sh/tests/builtins/wait1.0 b/bin/sh/tests/builtins/wait1.0
index 1ca85308c9ac..8bd48fefde25 100644
--- a/bin/sh/tests/builtins/wait1.0
+++ b/bin/sh/tests/builtins/wait1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
failures=
failure() {
diff --git a/bin/sh/tests/builtins/wait10.0 b/bin/sh/tests/builtins/wait10.0
index 864fc7817276..e45d08727205 100644
--- a/bin/sh/tests/builtins/wait10.0
+++ b/bin/sh/tests/builtins/wait10.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Init cannot be a child of the shell.
exit 49 & p49=$!
wait 1 "$p49"
diff --git a/bin/sh/tests/builtins/wait2.0 b/bin/sh/tests/builtins/wait2.0
index e61455cf5f0e..97632575213b 100644
--- a/bin/sh/tests/builtins/wait2.0
+++ b/bin/sh/tests/builtins/wait2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
failures=
failure() {
diff --git a/bin/sh/tests/builtins/wait3.0 b/bin/sh/tests/builtins/wait3.0
index 1ed52999630d..4b62c1b897b6 100644
--- a/bin/sh/tests/builtins/wait3.0
+++ b/bin/sh/tests/builtins/wait3.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
failures=
failure() {
diff --git a/bin/sh/tests/builtins/wait4.0 b/bin/sh/tests/builtins/wait4.0
index 79351315d384..972a27e3c3d4 100644
--- a/bin/sh/tests/builtins/wait4.0
+++ b/bin/sh/tests/builtins/wait4.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
T=`mktemp -d ${TMPDIR:-/tmp}/sh-test.XXXXXX`
trap 'rm -rf $T' 0
diff --git a/bin/sh/tests/builtins/wait5.0 b/bin/sh/tests/builtins/wait5.0
index 6874bf669302..71ecbe51639c 100644
--- a/bin/sh/tests/builtins/wait5.0
+++ b/bin/sh/tests/builtins/wait5.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
T=`mktemp -d ${TMPDIR:-/tmp}/sh-test.XXXXXX`
trap 'rm -rf $T' 0
diff --git a/bin/sh/tests/builtins/wait6.0 b/bin/sh/tests/builtins/wait6.0
index 20e3c6808679..757fee5ce5cf 100644
--- a/bin/sh/tests/builtins/wait6.0
+++ b/bin/sh/tests/builtins/wait6.0
@@ -1,3 +1,2 @@
-# $FreeBSD$
wait --
diff --git a/bin/sh/tests/builtins/wait7.0 b/bin/sh/tests/builtins/wait7.0
index 0fb092f8f614..db535e1c40d1 100644
--- a/bin/sh/tests/builtins/wait7.0
+++ b/bin/sh/tests/builtins/wait7.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
: &
wait -- $!
diff --git a/bin/sh/tests/builtins/wait8.0 b/bin/sh/tests/builtins/wait8.0
index b59ff59622eb..3f6cdc72abc7 100644
--- a/bin/sh/tests/builtins/wait8.0
+++ b/bin/sh/tests/builtins/wait8.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
exit 44 & p44=$!
exit 45 & p45=$!
diff --git a/bin/sh/tests/builtins/wait9.127 b/bin/sh/tests/builtins/wait9.127
index 661f275421f8..676973dc97dd 100644
--- a/bin/sh/tests/builtins/wait9.127
+++ b/bin/sh/tests/builtins/wait9.127
@@ -1,3 +1,2 @@
-# $FreeBSD$
# Init cannot be a child of the shell.
wait 1
diff --git a/bin/sh/tests/errors/Makefile b/bin/sh/tests/errors/Makefile
index 5f8d16d22295..27e4f7143de5 100644
--- a/bin/sh/tests/errors/Makefile
+++ b/bin/sh/tests/errors/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE= tests
diff --git a/bin/sh/tests/errors/Makefile.depend b/bin/sh/tests/errors/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/bin/sh/tests/errors/Makefile.depend
+++ b/bin/sh/tests/errors/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/bin/sh/tests/errors/assignment-error1.0 b/bin/sh/tests/errors/assignment-error1.0
index 00eaed9b8671..27f3b06fbc98 100644
--- a/bin/sh/tests/errors/assignment-error1.0
+++ b/bin/sh/tests/errors/assignment-error1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
IFS=,
SPECIAL="break,\
diff --git a/bin/sh/tests/errors/assignment-error2.0 b/bin/sh/tests/errors/assignment-error2.0
index ff4e62995262..d9844b25cdc3 100644
--- a/bin/sh/tests/errors/assignment-error2.0
+++ b/bin/sh/tests/errors/assignment-error2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -e
HOME=/
diff --git a/bin/sh/tests/errors/backquote-error1.0 b/bin/sh/tests/errors/backquote-error1.0
index 43e33034af9f..c4bdb6722dc4 100644
--- a/bin/sh/tests/errors/backquote-error1.0
+++ b/bin/sh/tests/errors/backquote-error1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
echo 'echo `for` echo ".BAD"CODE.' | ${SH} +m -i 2>&1 | grep -q BADCODE && exit 1
exit 0
diff --git a/bin/sh/tests/errors/backquote-error2.0 b/bin/sh/tests/errors/backquote-error2.0
index 5b49e2be17ce..05fcd96bb101 100644
--- a/bin/sh/tests/errors/backquote-error2.0
+++ b/bin/sh/tests/errors/backquote-error2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
${SH} -c 'echo `echo .BA"DCODE.`
echo ".BAD"CODE.' 2>&1 | grep -q BADCODE && exit 1
diff --git a/bin/sh/tests/errors/bad-binary1.126 b/bin/sh/tests/errors/bad-binary1.126
index d92e9ded5689..76ab2aa5a8fe 100644
--- a/bin/sh/tests/errors/bad-binary1.126
+++ b/bin/sh/tests/errors/bad-binary1.126
@@ -1,4 +1,3 @@
-# $FreeBSD$
# 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 ")")
diff --git a/bin/sh/tests/errors/bad-keyword1.0 b/bin/sh/tests/errors/bad-keyword1.0
index ac0153655f8d..f754e02c122a 100644
--- a/bin/sh/tests/errors/bad-keyword1.0
+++ b/bin/sh/tests/errors/bad-keyword1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
echo ':; fi' | ${SH} -n 2>/dev/null && exit 1
exit 0
diff --git a/bin/sh/tests/errors/bad-parm-exp1.0 b/bin/sh/tests/errors/bad-parm-exp1.0
index 6e949945f9f3..0cefdac9ea5d 100644
--- a/bin/sh/tests/errors/bad-parm-exp1.0
+++ b/bin/sh/tests/errors/bad-parm-exp1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
false && {
${}
${foo/}
diff --git a/bin/sh/tests/errors/bad-parm-exp2.2 b/bin/sh/tests/errors/bad-parm-exp2.2
index a0826ecf9a8b..1de22a5c20d1 100644
--- a/bin/sh/tests/errors/bad-parm-exp2.2
+++ b/bin/sh/tests/errors/bad-parm-exp2.2
@@ -1,2 +1 @@
-# $FreeBSD$
eval '${}'
diff --git a/bin/sh/tests/errors/bad-parm-exp3.2 b/bin/sh/tests/errors/bad-parm-exp3.2
index bb41208f258d..6f7b9347567f 100644
--- a/bin/sh/tests/errors/bad-parm-exp3.2
+++ b/bin/sh/tests/errors/bad-parm-exp3.2
@@ -1,2 +1 @@
-# $FreeBSD$
eval '${foo/}'
diff --git a/bin/sh/tests/errors/bad-parm-exp4.2 b/bin/sh/tests/errors/bad-parm-exp4.2
index 2837f9b5be9e..9f4efa88c4b5 100644
--- a/bin/sh/tests/errors/bad-parm-exp4.2
+++ b/bin/sh/tests/errors/bad-parm-exp4.2
@@ -1,2 +1 @@
-# $FreeBSD$
eval '${foo:@abc}'
diff --git a/bin/sh/tests/errors/bad-parm-exp5.2 b/bin/sh/tests/errors/bad-parm-exp5.2
index 1ba343bb710d..3c0d10296f6b 100644
--- a/bin/sh/tests/errors/bad-parm-exp5.2
+++ b/bin/sh/tests/errors/bad-parm-exp5.2
@@ -1,2 +1 @@
-# $FreeBSD$
eval '${/}'
diff --git a/bin/sh/tests/errors/bad-parm-exp6.2 b/bin/sh/tests/errors/bad-parm-exp6.2
index b53a91b364b5..179aa5d06bb4 100644
--- a/bin/sh/tests/errors/bad-parm-exp6.2
+++ b/bin/sh/tests/errors/bad-parm-exp6.2
@@ -1,2 +1 @@
-# $FreeBSD$
eval '${#foo^}'
diff --git a/bin/sh/tests/errors/bad-parm-exp7.0 b/bin/sh/tests/errors/bad-parm-exp7.0
index b8562fbed47b..d82b2eade819 100644
--- a/bin/sh/tests/errors/bad-parm-exp7.0
+++ b/bin/sh/tests/errors/bad-parm-exp7.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
v=1
eval ": $(printf '${v-${\372}}')"
diff --git a/bin/sh/tests/errors/bad-parm-exp8.0 b/bin/sh/tests/errors/bad-parm-exp8.0
index 28f00cde0f9f..9f983f1dad55 100644
--- a/bin/sh/tests/errors/bad-parm-exp8.0
+++ b/bin/sh/tests/errors/bad-parm-exp8.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
v=1
eval ": $(printf '${v-${w\372}}')"
diff --git a/bin/sh/tests/errors/option-error.0 b/bin/sh/tests/errors/option-error.0
index b4b44c4a4062..d5eac6f4c0c3 100644
--- a/bin/sh/tests/errors/option-error.0
+++ b/bin/sh/tests/errors/option-error.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
IFS=,
SPECIAL="break abc,\
diff --git a/bin/sh/tests/errors/redirection-error.0 b/bin/sh/tests/errors/redirection-error.0
index cb8c0b113c13..dfb9f1bfb100 100644
--- a/bin/sh/tests/errors/redirection-error.0
+++ b/bin/sh/tests/errors/redirection-error.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
IFS=,
SPECIAL="break,\
diff --git a/bin/sh/tests/errors/redirection-error2.2 b/bin/sh/tests/errors/redirection-error2.2
index 32bccd8e784a..0fb47d20917b 100644
--- a/bin/sh/tests/errors/redirection-error2.2
+++ b/bin/sh/tests/errors/redirection-error2.2
@@ -1,4 +1,3 @@
-# $FreeBSD$
# sh should fail gracefully on this bad redirect
${SH} -c 'echo 1 >&$a' 2>/dev/null
diff --git a/bin/sh/tests/errors/redirection-error3.0 b/bin/sh/tests/errors/redirection-error3.0
index 8a07d037baec..d37ba8213547 100644
--- a/bin/sh/tests/errors/redirection-error3.0
+++ b/bin/sh/tests/errors/redirection-error3.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
IFS=,
SPECIAL="break,\
diff --git a/bin/sh/tests/errors/redirection-error4.0 b/bin/sh/tests/errors/redirection-error4.0
index 206097478e35..b7ce514a9fbc 100644
--- a/bin/sh/tests/errors/redirection-error4.0
+++ b/bin/sh/tests/errors/redirection-error4.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# A redirection error should not abort the shell if there is no command word.
exec 2>/dev/null
</var/empty/x
diff --git a/bin/sh/tests/errors/redirection-error5.0 b/bin/sh/tests/errors/redirection-error5.0
index 1fcd47eebf96..1af2937839c2 100644
--- a/bin/sh/tests/errors/redirection-error5.0
+++ b/bin/sh/tests/errors/redirection-error5.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# A redirection error on a subshell should not abort the shell.
exec 2>/dev/null
( echo bad ) </var/empty/x
diff --git a/bin/sh/tests/errors/redirection-error6.0 b/bin/sh/tests/errors/redirection-error6.0
index 17d1109b390f..f0ac4a5025a5 100644
--- a/bin/sh/tests/errors/redirection-error6.0
+++ b/bin/sh/tests/errors/redirection-error6.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# A redirection error on a compound command should not abort the shell.
exec 2>/dev/null
{ echo bad; } </var/empty/x
diff --git a/bin/sh/tests/errors/redirection-error7.0 b/bin/sh/tests/errors/redirection-error7.0
index 5b20f04beb83..d853aee52fe2 100644
--- a/bin/sh/tests/errors/redirection-error7.0
+++ b/bin/sh/tests/errors/redirection-error7.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
! dummy=$(
exec 3>&1 >&2 2>&3
diff --git a/bin/sh/tests/errors/redirection-error8.0 b/bin/sh/tests/errors/redirection-error8.0
index 91595457831e..4d2693f26319 100644
--- a/bin/sh/tests/errors/redirection-error8.0
+++ b/bin/sh/tests/errors/redirection-error8.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
$SH -c '{ { :; } </var/empty/x; } 2>/dev/null || kill -INT $$; echo continued'
r=$?
diff --git a/bin/sh/tests/errors/script-error1.0 b/bin/sh/tests/errors/script-error1.0
index 558d9007353f..0020218cfd24 100644
--- a/bin/sh/tests/errors/script-error1.0
+++ b/bin/sh/tests/errors/script-error1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
{ stderr=$(${SH} /var/empty/nosuchscript 2>&1 >&3); } 3>&1
r=$?
diff --git a/bin/sh/tests/errors/write-error1.0 b/bin/sh/tests/errors/write-error1.0
index fcb52e74178c..027108f9ec51 100644
--- a/bin/sh/tests/errors/write-error1.0
+++ b/bin/sh/tests/errors/write-error1.0
@@ -1,3 +1,2 @@
-# $FreeBSD$
! echo >&- 2>/dev/null
diff --git a/bin/sh/tests/execution/Makefile b/bin/sh/tests/execution/Makefile
index ab5218b10a0c..2b4f88db989c 100644
--- a/bin/sh/tests/execution/Makefile
+++ b/bin/sh/tests/execution/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE= tests
diff --git a/bin/sh/tests/execution/Makefile.depend b/bin/sh/tests/execution/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/bin/sh/tests/execution/Makefile.depend
+++ b/bin/sh/tests/execution/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/bin/sh/tests/execution/bg1.0 b/bin/sh/tests/execution/bg1.0
index edb92ae2ddd0..eae1e2a6eece 100644
--- a/bin/sh/tests/execution/bg1.0
+++ b/bin/sh/tests/execution/bg1.0
@@ -1,3 +1,2 @@
-# $FreeBSD$
: `false` &
diff --git a/bin/sh/tests/execution/bg10.0 b/bin/sh/tests/execution/bg10.0
index 44a25dc23b2e..3e825d9eda20 100644
--- a/bin/sh/tests/execution/bg10.0
+++ b/bin/sh/tests/execution/bg10.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# The redirection overrides the </dev/null implicit in a background command.
echo yes | ${SH} -c '{ cat & wait; } <&0'
diff --git a/bin/sh/tests/execution/bg11.0 b/bin/sh/tests/execution/bg11.0
index e0c48ed16076..380d2180fe79 100644
--- a/bin/sh/tests/execution/bg11.0
+++ b/bin/sh/tests/execution/bg11.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
T=`mktemp -d ${TMPDIR:-/tmp}/sh-test.XXXXXXXX`
trap 'rm -rf $T' 0
diff --git a/bin/sh/tests/execution/bg12.0 b/bin/sh/tests/execution/bg12.0
index a9bde6cac8a3..ed1e0065b226 100644
--- a/bin/sh/tests/execution/bg12.0
+++ b/bin/sh/tests/execution/bg12.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
T=`mktemp -d ${TMPDIR:-/tmp}/sh-test.XXXXXXXX`
trap 'rm -rf $T' 0
diff --git a/bin/sh/tests/execution/bg13.0 b/bin/sh/tests/execution/bg13.0
index 37a4ad864ded..7f6fb87af665 100644
--- a/bin/sh/tests/execution/bg13.0
+++ b/bin/sh/tests/execution/bg13.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
T=`mktemp -d ${TMPDIR:-/tmp}/sh-test.XXXXXXXX`
trap 'rm -rf $T' 0
diff --git a/bin/sh/tests/execution/bg2.0 b/bin/sh/tests/execution/bg2.0
index 2e2fbc53bd26..29bdffb0b105 100644
--- a/bin/sh/tests/execution/bg2.0
+++ b/bin/sh/tests/execution/bg2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
f() { return 42; }
f
diff --git a/bin/sh/tests/execution/bg3.0 b/bin/sh/tests/execution/bg3.0
index 359fc6f476e6..0a411f611e1f 100644
--- a/bin/sh/tests/execution/bg3.0
+++ b/bin/sh/tests/execution/bg3.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
f() { return 42; }
f
diff --git a/bin/sh/tests/execution/bg4.0 b/bin/sh/tests/execution/bg4.0
index 25e4f4e34fa5..4d63fa8b455f 100644
--- a/bin/sh/tests/execution/bg4.0
+++ b/bin/sh/tests/execution/bg4.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
x=''
: ${x:=1} &
diff --git a/bin/sh/tests/execution/bg5.0 b/bin/sh/tests/execution/bg5.0
index cc9ceaa41d4e..94c45dba370b 100644
--- a/bin/sh/tests/execution/bg5.0
+++ b/bin/sh/tests/execution/bg5.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# A background command has an implicit </dev/null redirection.
echo bad | ${SH} -c '{ cat & wait; }'
diff --git a/bin/sh/tests/execution/bg6.0 b/bin/sh/tests/execution/bg6.0
index b0faf9e73708..ce6d88461f97 100644
--- a/bin/sh/tests/execution/bg6.0
+++ b/bin/sh/tests/execution/bg6.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# The redirection overrides the </dev/null implicit in a background command.
echo yes | ${SH} -c '{ cat & wait; } </dev/stdin'
diff --git a/bin/sh/tests/execution/bg7.0 b/bin/sh/tests/execution/bg7.0
index f771edc56cde..01a0a1a333f3 100644
--- a/bin/sh/tests/execution/bg7.0
+++ b/bin/sh/tests/execution/bg7.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# The redirection does not apply to the background command, and therefore
# does not override the implicit </dev/null.
diff --git a/bin/sh/tests/execution/bg8.0 b/bin/sh/tests/execution/bg8.0
index 33667cb1922b..4eeb235411f3 100644
--- a/bin/sh/tests/execution/bg8.0
+++ b/bin/sh/tests/execution/bg8.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# The redirection does not apply to the background command, and therefore
# does not override the implicit </dev/null.
diff --git a/bin/sh/tests/execution/bg9.0 b/bin/sh/tests/execution/bg9.0
index 64fde3e3e333..805c90a9caba 100644
--- a/bin/sh/tests/execution/bg9.0
+++ b/bin/sh/tests/execution/bg9.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# The redirection does not apply to the background command, and therefore
# does not override the implicit </dev/null.
diff --git a/bin/sh/tests/execution/env1.0 b/bin/sh/tests/execution/env1.0
index 7eb8abbd5247..f1abad21bade 100644
--- a/bin/sh/tests/execution/env1.0
+++ b/bin/sh/tests/execution/env1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
unset somestrangevar
export somestrangevar
diff --git a/bin/sh/tests/execution/fork1.0 b/bin/sh/tests/execution/fork1.0
index 2eeac79ae8c3..bf47ca044306 100644
--- a/bin/sh/tests/execution/fork1.0
+++ b/bin/sh/tests/execution/fork1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
shname=${SH%% *}
shname=${shname##*/}
diff --git a/bin/sh/tests/execution/fork2.0 b/bin/sh/tests/execution/fork2.0
index 62a25379123c..1b2ed28672ca 100644
--- a/bin/sh/tests/execution/fork2.0
+++ b/bin/sh/tests/execution/fork2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
result=$(${SH} -c '(/bin/sleep 1)& sleep 0.1; ps -p $! -o comm=; kill $!')
test "$result" = sleep || exit 1
diff --git a/bin/sh/tests/execution/fork3.0 b/bin/sh/tests/execution/fork3.0
index 3cb678c2d08a..d9b2efb235bd 100644
--- a/bin/sh/tests/execution/fork3.0
+++ b/bin/sh/tests/execution/fork3.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
result=$(${SH} -c 'f() { ps -p $$ -o comm=; }; f')
test "$result" = "ps"
diff --git a/bin/sh/tests/execution/func1.0 b/bin/sh/tests/execution/func1.0
index 29fcc077b592..0dfd341f9099 100644
--- a/bin/sh/tests/execution/func1.0
+++ b/bin/sh/tests/execution/func1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
MALLOC_OPTIONS=J ${SH} -c 'g() { g() { :; }; :; }; g' &&
MALLOC_OPTIONS=J ${SH} -c 'g() { unset -f g; :; }; g'
diff --git a/bin/sh/tests/execution/func2.0 b/bin/sh/tests/execution/func2.0
index 9830b5e8a7cf..d0f505e30481 100644
--- a/bin/sh/tests/execution/func2.0
+++ b/bin/sh/tests/execution/func2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# The empty pairs of braces here are to test that this does not cause a crash.
f() { }
diff --git a/bin/sh/tests/execution/func3.0 b/bin/sh/tests/execution/func3.0
index e0ed581f85ef..51e70bfa8ac2 100644
--- a/bin/sh/tests/execution/func3.0
+++ b/bin/sh/tests/execution/func3.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# 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.
diff --git a/bin/sh/tests/execution/hash1.0 b/bin/sh/tests/execution/hash1.0
index a645c2aef735..f41d38eb4a3c 100644
--- a/bin/sh/tests/execution/hash1.0
+++ b/bin/sh/tests/execution/hash1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
T=`mktemp -d "${TMPDIR:-/tmp}/sh-test.XXXXXXXX"` || exit
trap 'rm -rf "${T}"' 0
diff --git a/bin/sh/tests/execution/int-cmd1.0 b/bin/sh/tests/execution/int-cmd1.0
index a1f097b774d6..05d08dc3d62d 100644
--- a/bin/sh/tests/execution/int-cmd1.0
+++ b/bin/sh/tests/execution/int-cmd1.0
@@ -1,3 +1,2 @@
-# $FreeBSD$
-! echo echo bad | $SH -ic 'fi' 2>/dev/null
+! echo echo bad | ENV= $SH -ic 'fi' 2>/dev/null
diff --git a/bin/sh/tests/execution/killed1.0 b/bin/sh/tests/execution/killed1.0
index 41d3e055723e..a3977b6ce10c 100644
--- a/bin/sh/tests/execution/killed1.0
+++ b/bin/sh/tests/execution/killed1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# 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.
diff --git a/bin/sh/tests/execution/killed2.0 b/bin/sh/tests/execution/killed2.0
index 7ff3fe2900d1..2b9a8fa628e1 100644
--- a/bin/sh/tests/execution/killed2.0
+++ b/bin/sh/tests/execution/killed2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# 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
diff --git a/bin/sh/tests/execution/not1.0 b/bin/sh/tests/execution/not1.0
index 12c6265a9282..86bd3fbe04d3 100644
--- a/bin/sh/tests/execution/not1.0
+++ b/bin/sh/tests/execution/not1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
f() { ! return $1; }
f 0 && ! f 1
diff --git a/bin/sh/tests/execution/not2.0 b/bin/sh/tests/execution/not2.0
index 1b128d096716..896f59528c60 100644
--- a/bin/sh/tests/execution/not2.0
+++ b/bin/sh/tests/execution/not2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
while :; do
! break
diff --git a/bin/sh/tests/execution/path1.0 b/bin/sh/tests/execution/path1.0
index 50829d629a4d..72537dac4973 100644
--- a/bin/sh/tests/execution/path1.0
+++ b/bin/sh/tests/execution/path1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Some builtins should not be overridable via PATH.
set -e
diff --git a/bin/sh/tests/execution/pipefail1.0 b/bin/sh/tests/execution/pipefail1.0
index df23a012ca07..d3ce51b3042b 100644
--- a/bin/sh/tests/execution/pipefail1.0
+++ b/bin/sh/tests/execution/pipefail1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -o pipefail
: && : | : && : | : | : && : | : | : | :
diff --git a/bin/sh/tests/execution/pipefail2.42 b/bin/sh/tests/execution/pipefail2.42
index b9092661c76e..93eded1deda3 100644
--- a/bin/sh/tests/execution/pipefail2.42
+++ b/bin/sh/tests/execution/pipefail2.42
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -o pipefail
(exit 42) | :
diff --git a/bin/sh/tests/execution/pipefail3.42 b/bin/sh/tests/execution/pipefail3.42
index d96602b57f02..996a404a294c 100644
--- a/bin/sh/tests/execution/pipefail3.42
+++ b/bin/sh/tests/execution/pipefail3.42
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -o pipefail
: | (exit 42)
diff --git a/bin/sh/tests/execution/pipefail4.42 b/bin/sh/tests/execution/pipefail4.42
index 3399dd8c4452..d18d36bf470b 100644
--- a/bin/sh/tests/execution/pipefail4.42
+++ b/bin/sh/tests/execution/pipefail4.42
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -o pipefail
(exit 43) | (exit 42)
diff --git a/bin/sh/tests/execution/pipefail5.42 b/bin/sh/tests/execution/pipefail5.42
index 4effb2b3301e..3ccfb5d24940 100644
--- a/bin/sh/tests/execution/pipefail5.42
+++ b/bin/sh/tests/execution/pipefail5.42
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -o pipefail
(exit 42) | : &
diff --git a/bin/sh/tests/execution/pipefail6.42 b/bin/sh/tests/execution/pipefail6.42
index 7395d8c785a6..4fbca1b09ad8 100644
--- a/bin/sh/tests/execution/pipefail6.42
+++ b/bin/sh/tests/execution/pipefail6.42
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -o pipefail
(exit 42) | : &
diff --git a/bin/sh/tests/execution/pipefail7.0 b/bin/sh/tests/execution/pipefail7.0
index 797d485f3c61..84c551bdb6a3 100644
--- a/bin/sh/tests/execution/pipefail7.0
+++ b/bin/sh/tests/execution/pipefail7.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
(exit 42) | : &
set -o pipefail
diff --git a/bin/sh/tests/execution/redir1.0 b/bin/sh/tests/execution/redir1.0
index dd0011f064b0..ffdc9c82a23d 100644
--- a/bin/sh/tests/execution/redir1.0
+++ b/bin/sh/tests/execution/redir1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
trap ': $((brokenpipe+=1))' PIPE
P=${TMPDIR:-/tmp}
diff --git a/bin/sh/tests/execution/redir2.0 b/bin/sh/tests/execution/redir2.0
index 1588105f599a..4eb44aa3a5bf 100644
--- a/bin/sh/tests/execution/redir2.0
+++ b/bin/sh/tests/execution/redir2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
trap ': $((brokenpipe+=1))' PIPE
P=${TMPDIR:-/tmp}
diff --git a/bin/sh/tests/execution/redir3.0 b/bin/sh/tests/execution/redir3.0
index d68e4504ed3d..3129abbee0b3 100644
--- a/bin/sh/tests/execution/redir3.0
+++ b/bin/sh/tests/execution/redir3.0
@@ -1,3 +1,2 @@
-# $FreeBSD$
3>&- 3>&-
diff --git a/bin/sh/tests/execution/redir4.0 b/bin/sh/tests/execution/redir4.0
index 57054c17c45f..bee2bd78f5b2 100644
--- a/bin/sh/tests/execution/redir4.0
+++ b/bin/sh/tests/execution/redir4.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
{ echo bad 0>&3; } 2>/dev/null 3>/dev/null 3>&-
exit 0
diff --git a/bin/sh/tests/execution/redir5.0 b/bin/sh/tests/execution/redir5.0
index 707ca68f737a..d810475bfb1a 100644
--- a/bin/sh/tests/execution/redir5.0
+++ b/bin/sh/tests/execution/redir5.0
@@ -1,3 +1,2 @@
-# $FreeBSD$
{ (echo bad) >/dev/null; } </dev/null
diff --git a/bin/sh/tests/execution/redir6.0 b/bin/sh/tests/execution/redir6.0
index 4e3ac0cae055..d9a90a97523c 100644
--- a/bin/sh/tests/execution/redir6.0
+++ b/bin/sh/tests/execution/redir6.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
failures=0
diff --git a/bin/sh/tests/execution/redir7.0 b/bin/sh/tests/execution/redir7.0
index 2487bcf2fc0d..59abf0698493 100644
--- a/bin/sh/tests/execution/redir7.0
+++ b/bin/sh/tests/execution/redir7.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
failures=0
diff --git a/bin/sh/tests/execution/set-C1.0 b/bin/sh/tests/execution/set-C1.0
index 7877a33989b7..50ce8483c2d6 100644
--- a/bin/sh/tests/execution/set-C1.0
+++ b/bin/sh/tests/execution/set-C1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
T=$(mktemp -d "${TMPDIR:-/tmp}/sh-test.XXXXXXXX") || exit
trap 'rm -rf "$T"' 0
diff --git a/bin/sh/tests/execution/set-n1.0 b/bin/sh/tests/execution/set-n1.0
index 14c9b9396ada..e3ee7d2c103d 100644
--- a/bin/sh/tests/execution/set-n1.0
+++ b/bin/sh/tests/execution/set-n1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
v=$( ($SH -n <<'EOF'
for
diff --git a/bin/sh/tests/execution/set-n2.0 b/bin/sh/tests/execution/set-n2.0
index c7f31629f474..1f309d59f619 100644
--- a/bin/sh/tests/execution/set-n2.0
+++ b/bin/sh/tests/execution/set-n2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
$SH -n <<'EOF'
echo bad
diff --git a/bin/sh/tests/execution/set-n3.0 b/bin/sh/tests/execution/set-n3.0
index 24a9159fdeb9..362dd121a1fe 100644
--- a/bin/sh/tests/execution/set-n3.0
+++ b/bin/sh/tests/execution/set-n3.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
v=$( ($SH -nc 'for') 2>&1 >/dev/null)
[ $? -ne 0 ] && [ -n "$v" ]
diff --git a/bin/sh/tests/execution/set-n4.0 b/bin/sh/tests/execution/set-n4.0
index 36985084b26b..80a8c2bbcc46 100644
--- a/bin/sh/tests/execution/set-n4.0
+++ b/bin/sh/tests/execution/set-n4.0
@@ -1,3 +1,2 @@
-# $FreeBSD$
$SH -nc 'echo bad'
diff --git a/bin/sh/tests/execution/set-x1.0 b/bin/sh/tests/execution/set-x1.0
index 7fe1dbf1076b..31dffe45d84d 100644
--- a/bin/sh/tests/execution/set-x1.0
+++ b/bin/sh/tests/execution/set-x1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
key='must_contain_this'
{ r=`set -x; { : "$key"; } 2>&1 >/dev/null`; } 2>/dev/null
diff --git a/bin/sh/tests/execution/set-x2.0 b/bin/sh/tests/execution/set-x2.0
index 56d54e38d251..a1b8d6d37f79 100644
--- a/bin/sh/tests/execution/set-x2.0
+++ b/bin/sh/tests/execution/set-x2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
key='must contain this'
PS4="$key+ "
diff --git a/bin/sh/tests/execution/set-x3.0 b/bin/sh/tests/execution/set-x3.0
index 1ca57aca6baa..11f79ea5fcb9 100644
--- a/bin/sh/tests/execution/set-x3.0
+++ b/bin/sh/tests/execution/set-x3.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
key='must contain this'
PS4='$key+ '
diff --git a/bin/sh/tests/execution/set-x4.0 b/bin/sh/tests/execution/set-x4.0
index 0904766ccdd1..495a2d9c304c 100644
--- a/bin/sh/tests/execution/set-x4.0
+++ b/bin/sh/tests/execution/set-x4.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
key=`printf '\r\t\001\200\300'`
r=`{ set -x; : "$key"; } 2>&1 >/dev/null`
diff --git a/bin/sh/tests/execution/shellproc1.0 b/bin/sh/tests/execution/shellproc1.0
index 1326bc27f1c1..125a177f8418 100644
--- a/bin/sh/tests/execution/shellproc1.0
+++ b/bin/sh/tests/execution/shellproc1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
T=`mktemp -d "${TMPDIR:-/tmp}/sh-test.XXXXXXXX"` || exit
trap 'rm -rf "${T}"' 0
diff --git a/bin/sh/tests/execution/shellproc2.0 b/bin/sh/tests/execution/shellproc2.0
index 85e768070022..b599d16527be 100644
--- a/bin/sh/tests/execution/shellproc2.0
+++ b/bin/sh/tests/execution/shellproc2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# This tests a quality of implementation issue.
# Shells are not required to reject executing binary files as shell scripts
# but executing, for example, ELF files for a different architecture as
diff --git a/bin/sh/tests/execution/shellproc3.0 b/bin/sh/tests/execution/shellproc3.0
index 6ad455f2cd77..17026480a90a 100644
--- a/bin/sh/tests/execution/shellproc3.0
+++ b/bin/sh/tests/execution/shellproc3.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# This tests a quality of implementation issue.
# Shells are not required to reject executing binary files as shell scripts
# but executing, for example, ELF files for a different architecture as
diff --git a/bin/sh/tests/execution/shellproc4.0 b/bin/sh/tests/execution/shellproc4.0
index fcc72eef073c..4aa944b55a86 100644
--- a/bin/sh/tests/execution/shellproc4.0
+++ b/bin/sh/tests/execution/shellproc4.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# This tests a quality of implementation issue.
# Shells are not required to reject executing binary files as shell scripts
# but executing, for example, ELF files for a different architecture as
diff --git a/bin/sh/tests/execution/shellproc5.0 b/bin/sh/tests/execution/shellproc5.0
index c25ffe3e4693..535e5dabc4d9 100644
--- a/bin/sh/tests/execution/shellproc5.0
+++ b/bin/sh/tests/execution/shellproc5.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# This tests a quality of implementation issue.
# Shells are not required to reject executing binary files as shell scripts
# but executing, for example, ELF files for a different architecture as
diff --git a/bin/sh/tests/execution/shellproc6.0 b/bin/sh/tests/execution/shellproc6.0
index 1c06bc3b05a9..f1527f6d854d 100644
--- a/bin/sh/tests/execution/shellproc6.0
+++ b/bin/sh/tests/execution/shellproc6.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
T=`mktemp -d "${TMPDIR:-/tmp}/sh-test.XXXXXXXX"` || exit
trap 'rm -rf "${T}"' 0
diff --git a/bin/sh/tests/execution/shellproc7.0 b/bin/sh/tests/execution/shellproc7.0
index 2a99ae74c151..b5e543826c8a 100644
--- a/bin/sh/tests/execution/shellproc7.0
+++ b/bin/sh/tests/execution/shellproc7.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Non-POSIX trickery that is widely supported,
# used by https://justine.lol/ape.html
diff --git a/bin/sh/tests/execution/subshell1.0 b/bin/sh/tests/execution/subshell1.0
index 347806ed45ac..ddff2fee4999 100644
--- a/bin/sh/tests/execution/subshell1.0
+++ b/bin/sh/tests/execution/subshell1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
(eval "cd /
v=$(printf %0100000d 1)
diff --git a/bin/sh/tests/execution/subshell2.0 b/bin/sh/tests/execution/subshell2.0
index 32164495c9ca..ad5a3b87af47 100644
--- a/bin/sh/tests/execution/subshell2.0
+++ b/bin/sh/tests/execution/subshell2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
f() {
x=2
diff --git a/bin/sh/tests/execution/subshell3.0 b/bin/sh/tests/execution/subshell3.0
index 9a87acb15e1c..4d1916dfa18e 100644
--- a/bin/sh/tests/execution/subshell3.0
+++ b/bin/sh/tests/execution/subshell3.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
(false; exit) && exit 3
exit 0
diff --git a/bin/sh/tests/execution/subshell4.0 b/bin/sh/tests/execution/subshell4.0
index b39edb12eb2c..841186b5e619 100644
--- a/bin/sh/tests/execution/subshell4.0
+++ b/bin/sh/tests/execution/subshell4.0
@@ -1,3 +1,2 @@
-# $FreeBSD$
(eval "set v=1"; false) && echo bad; :
diff --git a/bin/sh/tests/execution/unknown1.0 b/bin/sh/tests/execution/unknown1.0
index 45f541e6eeea..c41243454dbc 100644
--- a/bin/sh/tests/execution/unknown1.0
+++ b/bin/sh/tests/execution/unknown1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
nosuchtool 2>/dev/null
[ $? -ne 127 ] && exit 1
diff --git a/bin/sh/tests/execution/unknown2.0 b/bin/sh/tests/execution/unknown2.0
index d316e01949f6..eb7ab0175a65 100644
--- a/bin/sh/tests/execution/unknown2.0
+++ b/bin/sh/tests/execution/unknown2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
{
: $(/var/empty/nosuchtool)
diff --git a/bin/sh/tests/execution/var-assign1.0 b/bin/sh/tests/execution/var-assign1.0
index 26e54249c1cc..8d49498d848e 100644
--- a/bin/sh/tests/execution/var-assign1.0
+++ b/bin/sh/tests/execution/var-assign1.0
@@ -1,3 +1,2 @@
-# $FreeBSD$
[ "$(HOME=/etc HOME=/ cd && pwd)" = / ]
diff --git a/bin/sh/tests/expansion/Makefile b/bin/sh/tests/expansion/Makefile
index 58df967304f5..d38fd49e14ee 100644
--- a/bin/sh/tests/expansion/Makefile
+++ b/bin/sh/tests/expansion/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE= tests
diff --git a/bin/sh/tests/expansion/Makefile.depend b/bin/sh/tests/expansion/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/bin/sh/tests/expansion/Makefile.depend
+++ b/bin/sh/tests/expansion/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/bin/sh/tests/expansion/arith1.0 b/bin/sh/tests/expansion/arith1.0
index 118ba2265687..c1338fc34962 100644
--- a/bin/sh/tests/expansion/arith1.0
+++ b/bin/sh/tests/expansion/arith1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
failures=0
diff --git a/bin/sh/tests/expansion/arith10.0 b/bin/sh/tests/expansion/arith10.0
index 1aaf6194fbaf..1e0c10dfda5e 100644
--- a/bin/sh/tests/expansion/arith10.0
+++ b/bin/sh/tests/expansion/arith10.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
failures=0
diff --git a/bin/sh/tests/expansion/arith11.0 b/bin/sh/tests/expansion/arith11.0
index 6bc73697ffab..52c5a4420eb6 100644
--- a/bin/sh/tests/expansion/arith11.0
+++ b/bin/sh/tests/expansion/arith11.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Try to divide the smallest integer by -1.
# On amd64 this causes SIGFPE, so make sure the shell checks.
diff --git a/bin/sh/tests/expansion/arith12.0 b/bin/sh/tests/expansion/arith12.0
index cb7da3b2e21a..3d54970d84b1 100644
--- a/bin/sh/tests/expansion/arith12.0
+++ b/bin/sh/tests/expansion/arith12.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
_x=4 y_=5 z_z=6
[ "$((_x*100+y_*10+z_z))" = 456 ]
diff --git a/bin/sh/tests/expansion/arith13.0 b/bin/sh/tests/expansion/arith13.0
index 207e4881935b..897e55f70206 100644
--- a/bin/sh/tests/expansion/arith13.0
+++ b/bin/sh/tests/expansion/arith13.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Pre-increment and pre-decrement in arithmetic expansion are not in POSIX.
# Require either an error or a correct implementation.
diff --git a/bin/sh/tests/expansion/arith14.0 b/bin/sh/tests/expansion/arith14.0
index 836904335ef3..73f4ef3cab50 100644
--- a/bin/sh/tests/expansion/arith14.0
+++ b/bin/sh/tests/expansion/arith14.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Check that <</>> use the low bits of the shift count.
if [ $((1<<16<<16)) = 0 ]; then
diff --git a/bin/sh/tests/expansion/arith15.0 b/bin/sh/tests/expansion/arith15.0
index 32b35bb907cd..198004aedbd4 100644
--- a/bin/sh/tests/expansion/arith15.0
+++ b/bin/sh/tests/expansion/arith15.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
failures=0
diff --git a/bin/sh/tests/expansion/arith16.0 b/bin/sh/tests/expansion/arith16.0
index b764e3c216f8..4956aebbc665 100644
--- a/bin/sh/tests/expansion/arith16.0
+++ b/bin/sh/tests/expansion/arith16.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
failures=0
diff --git a/bin/sh/tests/expansion/arith17.0 b/bin/sh/tests/expansion/arith17.0
index 0a9260886ddb..72e0eec8a183 100644
--- a/bin/sh/tests/expansion/arith17.0
+++ b/bin/sh/tests/expansion/arith17.0
@@ -1,3 +1,2 @@
-# $FreeBSD$
[ $((9223372036854775809)) -gt 0 ]
diff --git a/bin/sh/tests/expansion/arith2.0 b/bin/sh/tests/expansion/arith2.0
index 95b48a06aae6..46aa968aa0a5 100644
--- a/bin/sh/tests/expansion/arith2.0
+++ b/bin/sh/tests/expansion/arith2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
failures=0
diff --git a/bin/sh/tests/expansion/arith3.0 b/bin/sh/tests/expansion/arith3.0
index b69159d9b5b8..622f8d1c8fef 100644
--- a/bin/sh/tests/expansion/arith3.0
+++ b/bin/sh/tests/expansion/arith3.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
failures=0
diff --git a/bin/sh/tests/expansion/arith4.0 b/bin/sh/tests/expansion/arith4.0
index 610dad89e4dc..5a7e4d419c57 100644
--- a/bin/sh/tests/expansion/arith4.0
+++ b/bin/sh/tests/expansion/arith4.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
failures=0
diff --git a/bin/sh/tests/expansion/arith5.0 b/bin/sh/tests/expansion/arith5.0
index d0f23312f9ca..c290a2426f10 100644
--- a/bin/sh/tests/expansion/arith5.0
+++ b/bin/sh/tests/expansion/arith5.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
failures=0
diff --git a/bin/sh/tests/expansion/arith6.0 b/bin/sh/tests/expansion/arith6.0
index fc4589c1bac5..f3d7ca10b5e0 100644
--- a/bin/sh/tests/expansion/arith6.0
+++ b/bin/sh/tests/expansion/arith6.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
v1=1\ +\ 1
v2=D
diff --git a/bin/sh/tests/expansion/arith7.0 b/bin/sh/tests/expansion/arith7.0
index 5aada2b86586..8578436cb635 100644
--- a/bin/sh/tests/expansion/arith7.0
+++ b/bin/sh/tests/expansion/arith7.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
v=1+
v=$v$v$v$v
diff --git a/bin/sh/tests/expansion/arith8.0 b/bin/sh/tests/expansion/arith8.0
index 2d03e503387d..7c77f3e7e456 100644
--- a/bin/sh/tests/expansion/arith8.0
+++ b/bin/sh/tests/expansion/arith8.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
v=$( (eval ': $((08))') 2>&1 >/dev/null)
[ $? -ne 0 ] && [ -n "$v" ]
diff --git a/bin/sh/tests/expansion/arith9.0 b/bin/sh/tests/expansion/arith9.0
index cc8b597d4755..94da20b17761 100644
--- a/bin/sh/tests/expansion/arith9.0
+++ b/bin/sh/tests/expansion/arith9.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
failures=0
diff --git a/bin/sh/tests/expansion/assign1.0 b/bin/sh/tests/expansion/assign1.0
index d4fa7727f593..16bca926bc1d 100644
--- a/bin/sh/tests/expansion/assign1.0
+++ b/bin/sh/tests/expansion/assign1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
e= q='?' a='*' t=texttext s='ast*que?non' p='/et[c]/' w='a b c' b='{{(#)}}'
h='##'
diff --git a/bin/sh/tests/expansion/cmdsubst1.0 b/bin/sh/tests/expansion/cmdsubst1.0
index 515c7da9aca1..dd0a3f2f16b1 100644
--- a/bin/sh/tests/expansion/cmdsubst1.0
+++ b/bin/sh/tests/expansion/cmdsubst1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
failures=0
diff --git a/bin/sh/tests/expansion/cmdsubst10.0 b/bin/sh/tests/expansion/cmdsubst10.0
index 7cf17a3e8fe1..da78234418f7 100644
--- a/bin/sh/tests/expansion/cmdsubst10.0
+++ b/bin/sh/tests/expansion/cmdsubst10.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
a1=$(alias)
: $(alias testalias=abcd)
diff --git a/bin/sh/tests/expansion/cmdsubst11.0 b/bin/sh/tests/expansion/cmdsubst11.0
index f1af547421f9..57d0114b19a4 100644
--- a/bin/sh/tests/expansion/cmdsubst11.0
+++ b/bin/sh/tests/expansion/cmdsubst11.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Not required by POSIX but useful for efficiency.
diff --git a/bin/sh/tests/expansion/cmdsubst12.0 b/bin/sh/tests/expansion/cmdsubst12.0
index 50394dbb00ca..3f4947dff788 100644
--- a/bin/sh/tests/expansion/cmdsubst12.0
+++ b/bin/sh/tests/expansion/cmdsubst12.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
f() {
echo x$(printf foo >&2)y
diff --git a/bin/sh/tests/expansion/cmdsubst13.0 b/bin/sh/tests/expansion/cmdsubst13.0
index 7fdc5b217f19..d6b55ea8a3d4 100644
--- a/bin/sh/tests/expansion/cmdsubst13.0
+++ b/bin/sh/tests/expansion/cmdsubst13.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
x=1 y=2
[ "$(
diff --git a/bin/sh/tests/expansion/cmdsubst14.0 b/bin/sh/tests/expansion/cmdsubst14.0
index bdbbb823e2b2..b09a6b0a254b 100644
--- a/bin/sh/tests/expansion/cmdsubst14.0
+++ b/bin/sh/tests/expansion/cmdsubst14.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
! v=`false
diff --git a/bin/sh/tests/expansion/cmdsubst15.0 b/bin/sh/tests/expansion/cmdsubst15.0
index 31d85d497e23..b9857775a376 100644
--- a/bin/sh/tests/expansion/cmdsubst15.0
+++ b/bin/sh/tests/expansion/cmdsubst15.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
! v=`false;
diff --git a/bin/sh/tests/expansion/cmdsubst16.0 b/bin/sh/tests/expansion/cmdsubst16.0
index 71df562298e5..bbce408f4c74 100644
--- a/bin/sh/tests/expansion/cmdsubst16.0
+++ b/bin/sh/tests/expansion/cmdsubst16.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
f() { return 3; }
f
diff --git a/bin/sh/tests/expansion/cmdsubst17.0 b/bin/sh/tests/expansion/cmdsubst17.0
index 8c29e8318327..8157a730f1b9 100644
--- a/bin/sh/tests/expansion/cmdsubst17.0
+++ b/bin/sh/tests/expansion/cmdsubst17.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
f() { return 3; }
f
diff --git a/bin/sh/tests/expansion/cmdsubst18.0 b/bin/sh/tests/expansion/cmdsubst18.0
index a9791b3acae6..f320ca01f006 100644
--- a/bin/sh/tests/expansion/cmdsubst18.0
+++ b/bin/sh/tests/expansion/cmdsubst18.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
x=X
unset n
diff --git a/bin/sh/tests/expansion/cmdsubst19.0 b/bin/sh/tests/expansion/cmdsubst19.0
index ae6619a775f7..d4ae49e54de1 100644
--- a/bin/sh/tests/expansion/cmdsubst19.0
+++ b/bin/sh/tests/expansion/cmdsubst19.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
b=200 c=30 d=5 x=4
r=$(echo a)$(($(echo b) + ${x+$(echo c)} + ${x-$(echo d)}))$(echo e)
diff --git a/bin/sh/tests/expansion/cmdsubst2.0 b/bin/sh/tests/expansion/cmdsubst2.0
index b86776ed24b0..af4b594c6f25 100644
--- a/bin/sh/tests/expansion/cmdsubst2.0
+++ b/bin/sh/tests/expansion/cmdsubst2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
failures=0
diff --git a/bin/sh/tests/expansion/cmdsubst20.0 b/bin/sh/tests/expansion/cmdsubst20.0
index 33932487b89f..8b759f46a01b 100644
--- a/bin/sh/tests/expansion/cmdsubst20.0
+++ b/bin/sh/tests/expansion/cmdsubst20.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -T
trapped=''
diff --git a/bin/sh/tests/expansion/cmdsubst21.0 b/bin/sh/tests/expansion/cmdsubst21.0
index 87ff6a9db4ad..ed38a4e1d70e 100644
--- a/bin/sh/tests/expansion/cmdsubst21.0
+++ b/bin/sh/tests/expansion/cmdsubst21.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -T
trapped=''
diff --git a/bin/sh/tests/expansion/cmdsubst22.0 b/bin/sh/tests/expansion/cmdsubst22.0
index 97c6c98dff87..c647fb205fa8 100644
--- a/bin/sh/tests/expansion/cmdsubst22.0
+++ b/bin/sh/tests/expansion/cmdsubst22.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -T
trapped=''
diff --git a/bin/sh/tests/expansion/cmdsubst23.0 b/bin/sh/tests/expansion/cmdsubst23.0
index cde86981f461..97fcad3f9b32 100644
--- a/bin/sh/tests/expansion/cmdsubst23.0
+++ b/bin/sh/tests/expansion/cmdsubst23.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
unset n
x=abcd
diff --git a/bin/sh/tests/expansion/cmdsubst24.0 b/bin/sh/tests/expansion/cmdsubst24.0
index 4b34247d6805..baf7841a491a 100644
--- a/bin/sh/tests/expansion/cmdsubst24.0
+++ b/bin/sh/tests/expansion/cmdsubst24.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# POSIX leaves the effect of NUL bytes in command substitution output
# unspecified but we have always discarded them.
diff --git a/bin/sh/tests/expansion/cmdsubst25.0 b/bin/sh/tests/expansion/cmdsubst25.0
index 83cca7d0b97e..4804602b9c54 100644
--- a/bin/sh/tests/expansion/cmdsubst25.0
+++ b/bin/sh/tests/expansion/cmdsubst25.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
IFS=' '
set -- `printf '\n '`
diff --git a/bin/sh/tests/expansion/cmdsubst26.0 b/bin/sh/tests/expansion/cmdsubst26.0
index 68a624b12471..25aa4b5a6ecc 100644
--- a/bin/sh/tests/expansion/cmdsubst26.0
+++ b/bin/sh/tests/expansion/cmdsubst26.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
nl='
'
diff --git a/bin/sh/tests/expansion/cmdsubst3.0 b/bin/sh/tests/expansion/cmdsubst3.0
index abb6b225a257..b6a09a24bc91 100644
--- a/bin/sh/tests/expansion/cmdsubst3.0
+++ b/bin/sh/tests/expansion/cmdsubst3.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
unset LC_ALL
export LC_CTYPE=en_US.ISO8859-1
diff --git a/bin/sh/tests/expansion/cmdsubst4.0 b/bin/sh/tests/expansion/cmdsubst4.0
index ee1ce73e7e38..95db034ba7a8 100644
--- a/bin/sh/tests/expansion/cmdsubst4.0
+++ b/bin/sh/tests/expansion/cmdsubst4.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
exec 2>/dev/null
! y=$(: </var/empty/nonexistent)
diff --git a/bin/sh/tests/expansion/cmdsubst5.0 b/bin/sh/tests/expansion/cmdsubst5.0
index afca3719e8b0..a6b467ebf986 100644
--- a/bin/sh/tests/expansion/cmdsubst5.0
+++ b/bin/sh/tests/expansion/cmdsubst5.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
unset v
exec 2>/dev/null
diff --git a/bin/sh/tests/expansion/cmdsubst6.0 b/bin/sh/tests/expansion/cmdsubst6.0
index 6586f330db5b..43a5d6240fec 100644
--- a/bin/sh/tests/expansion/cmdsubst6.0
+++ b/bin/sh/tests/expansion/cmdsubst6.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# This tests if the cmdsubst optimization is still used if possible.
failures=''
diff --git a/bin/sh/tests/expansion/cmdsubst7.0 b/bin/sh/tests/expansion/cmdsubst7.0
index dbd1aec5f9da..c767ac465f35 100644
--- a/bin/sh/tests/expansion/cmdsubst7.0
+++ b/bin/sh/tests/expansion/cmdsubst7.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
failures=''
ok=''
diff --git a/bin/sh/tests/expansion/cmdsubst8.0 b/bin/sh/tests/expansion/cmdsubst8.0
index 52adaea33b93..fe8330a1bd10 100644
--- a/bin/sh/tests/expansion/cmdsubst8.0
+++ b/bin/sh/tests/expansion/cmdsubst8.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Not required by POSIX (although referenced in a non-normative section),
# but possibly useful.
diff --git a/bin/sh/tests/expansion/cmdsubst9.0 b/bin/sh/tests/expansion/cmdsubst9.0
index 0b1f81f3537a..e512c6b86952 100644
--- a/bin/sh/tests/expansion/cmdsubst9.0
+++ b/bin/sh/tests/expansion/cmdsubst9.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -e
diff --git a/bin/sh/tests/expansion/export1.0 b/bin/sh/tests/expansion/export1.0
index 4ee3ef4ffa41..6b969c79e3bd 100644
--- a/bin/sh/tests/expansion/export1.0
+++ b/bin/sh/tests/expansion/export1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
w='@ vv=6'
diff --git a/bin/sh/tests/expansion/export2.0 b/bin/sh/tests/expansion/export2.0
index 57f64e7f7f7b..2959e5684af5 100644
--- a/bin/sh/tests/expansion/export2.0
+++ b/bin/sh/tests/expansion/export2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
w='@ @'
check() {
diff --git a/bin/sh/tests/expansion/export3.0 b/bin/sh/tests/expansion/export3.0
index a1a0e6658a08..94f55c9bd66c 100644
--- a/bin/sh/tests/expansion/export3.0
+++ b/bin/sh/tests/expansion/export3.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
w='@ @'
check() {
diff --git a/bin/sh/tests/expansion/heredoc1.0 b/bin/sh/tests/expansion/heredoc1.0
index a67b2da2e5f2..ade91b091b54 100644
--- a/bin/sh/tests/expansion/heredoc1.0
+++ b/bin/sh/tests/expansion/heredoc1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
f() { return $1; }
diff --git a/bin/sh/tests/expansion/heredoc2.0 b/bin/sh/tests/expansion/heredoc2.0
index 255143296d4a..b8ce6055909b 100644
--- a/bin/sh/tests/expansion/heredoc2.0
+++ b/bin/sh/tests/expansion/heredoc2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
f() { return $1; }
diff --git a/bin/sh/tests/expansion/ifs1.0 b/bin/sh/tests/expansion/ifs1.0
index e7f53c77a5f9..e803d63ce6fe 100644
--- a/bin/sh/tests/expansion/ifs1.0
+++ b/bin/sh/tests/expansion/ifs1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
c=: e= s=' '
failures=''
diff --git a/bin/sh/tests/expansion/ifs2.0 b/bin/sh/tests/expansion/ifs2.0
index e91b86707183..35e76943deb3 100644
--- a/bin/sh/tests/expansion/ifs2.0
+++ b/bin/sh/tests/expansion/ifs2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
failures=0
i=1
diff --git a/bin/sh/tests/expansion/ifs3.0 b/bin/sh/tests/expansion/ifs3.0
index 0569b5729cae..fdf4e2f9d9b7 100644
--- a/bin/sh/tests/expansion/ifs3.0
+++ b/bin/sh/tests/expansion/ifs3.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
failures=0
unset LC_ALL
diff --git a/bin/sh/tests/expansion/ifs4.0 b/bin/sh/tests/expansion/ifs4.0
index 5b896a25413b..6ce097ede67d 100644
--- a/bin/sh/tests/expansion/ifs4.0
+++ b/bin/sh/tests/expansion/ifs4.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
c=: e= s=' '
failures=''
diff --git a/bin/sh/tests/expansion/ifs5.0 b/bin/sh/tests/expansion/ifs5.0
index ab0e64662fdf..6fdf6ebbdf41 100644
--- a/bin/sh/tests/expansion/ifs5.0
+++ b/bin/sh/tests/expansion/ifs5.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -- $(echo a b c d)
[ "$#" = 4 ]
diff --git a/bin/sh/tests/expansion/ifs6.0 b/bin/sh/tests/expansion/ifs6.0
index be7794563085..e11a678cf41a 100644
--- a/bin/sh/tests/expansion/ifs6.0
+++ b/bin/sh/tests/expansion/ifs6.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
IFS=': '
x=': :'
diff --git a/bin/sh/tests/expansion/ifs7.0 b/bin/sh/tests/expansion/ifs7.0
index 0cc08348c04a..13e9419ce495 100644
--- a/bin/sh/tests/expansion/ifs7.0
+++ b/bin/sh/tests/expansion/ifs7.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
IFS=2
set -- $((123))
diff --git a/bin/sh/tests/expansion/length1.0 b/bin/sh/tests/expansion/length1.0
index 2aaebf9048a2..48317c44f8b5 100644
--- a/bin/sh/tests/expansion/length1.0
+++ b/bin/sh/tests/expansion/length1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
v=abcd
[ "${#v}" = 4 ] || echo '${#v} wrong'
diff --git a/bin/sh/tests/expansion/length2.0 b/bin/sh/tests/expansion/length2.0
index d749b51f4b20..1e74564eba64 100644
--- a/bin/sh/tests/expansion/length2.0
+++ b/bin/sh/tests/expansion/length2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
v=$-
[ "${#-}" = "${#v}" ] || echo '${#-} wrong'
diff --git a/bin/sh/tests/expansion/length3.0 b/bin/sh/tests/expansion/length3.0
index 2093eed8bbd3..fe3e38e5c35a 100644
--- a/bin/sh/tests/expansion/length3.0
+++ b/bin/sh/tests/expansion/length3.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -- 1 2 3 4 5 6 7 8 9 10 11 12 13
[ "$#" = 13 ] || echo '$# wrong'
diff --git a/bin/sh/tests/expansion/length4.0 b/bin/sh/tests/expansion/length4.0
index 5348be511379..5c032d47ff91 100644
--- a/bin/sh/tests/expansion/length4.0
+++ b/bin/sh/tests/expansion/length4.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# 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
diff --git a/bin/sh/tests/expansion/length5.0 b/bin/sh/tests/expansion/length5.0
index 322ca162b0b6..b2483127e441 100644
--- a/bin/sh/tests/expansion/length5.0
+++ b/bin/sh/tests/expansion/length5.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
unset LC_ALL
LC_CTYPE=en_US.ISO8859-1
diff --git a/bin/sh/tests/expansion/length6.0 b/bin/sh/tests/expansion/length6.0
index 6b78309f6b81..be719874dc10 100644
--- a/bin/sh/tests/expansion/length6.0
+++ b/bin/sh/tests/expansion/length6.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
x='!@#$%^&*()[]'
[ ${#x} = 12 ] || echo bad 1
diff --git a/bin/sh/tests/expansion/length7.0 b/bin/sh/tests/expansion/length7.0
index b79b11616c15..8bb128ba26d5 100644
--- a/bin/sh/tests/expansion/length7.0
+++ b/bin/sh/tests/expansion/length7.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
unset LC_ALL
LC_CTYPE=en_US.UTF-8
diff --git a/bin/sh/tests/expansion/length8.0 b/bin/sh/tests/expansion/length8.0
index 3cc6c15e7ece..1aae6d1a8cf9 100644
--- a/bin/sh/tests/expansion/length8.0
+++ b/bin/sh/tests/expansion/length8.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
unset LC_ALL
LC_CTYPE=en_US.ISO8859-1
diff --git a/bin/sh/tests/expansion/local1.0 b/bin/sh/tests/expansion/local1.0
index 34778351f1f3..745f49f2d5dd 100644
--- a/bin/sh/tests/expansion/local1.0
+++ b/bin/sh/tests/expansion/local1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
run_test() {
w='@ @'
diff --git a/bin/sh/tests/expansion/local2.0 b/bin/sh/tests/expansion/local2.0
index 19842900e0c1..365366e39905 100644
--- a/bin/sh/tests/expansion/local2.0
+++ b/bin/sh/tests/expansion/local2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
run_test() {
w='@ @'
diff --git a/bin/sh/tests/expansion/pathname1.0 b/bin/sh/tests/expansion/pathname1.0
index a4bb0938837f..1a3227d0d5d0 100644
--- a/bin/sh/tests/expansion/pathname1.0
+++ b/bin/sh/tests/expansion/pathname1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
unset LC_ALL
LC_COLLATE=C
diff --git a/bin/sh/tests/expansion/pathname2.0 b/bin/sh/tests/expansion/pathname2.0
index 5643cf907c87..69b8f7050cbc 100644
--- a/bin/sh/tests/expansion/pathname2.0
+++ b/bin/sh/tests/expansion/pathname2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
unset LC_ALL
LC_COLLATE=C
diff --git a/bin/sh/tests/expansion/pathname3.0 b/bin/sh/tests/expansion/pathname3.0
index d1672e057ec5..51f223dcf787 100644
--- a/bin/sh/tests/expansion/pathname3.0
+++ b/bin/sh/tests/expansion/pathname3.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
v=12345678
v=$v$v$v$v
diff --git a/bin/sh/tests/expansion/pathname4.0 b/bin/sh/tests/expansion/pathname4.0
index 18269c4318e6..5f6b54174332 100644
--- a/bin/sh/tests/expansion/pathname4.0
+++ b/bin/sh/tests/expansion/pathname4.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
failures=0
diff --git a/bin/sh/tests/expansion/pathname5.0 b/bin/sh/tests/expansion/pathname5.0
index bc278124de4f..7277f7bc1e3c 100644
--- a/bin/sh/tests/expansion/pathname5.0
+++ b/bin/sh/tests/expansion/pathname5.0
@@ -1,3 +1,2 @@
-# $FreeBSD$
[ `echo '/[e]tc'` = /etc ]
diff --git a/bin/sh/tests/expansion/pathname6.0 b/bin/sh/tests/expansion/pathname6.0
index dc425ce64950..f607c9a351ca 100644
--- a/bin/sh/tests/expansion/pathname6.0
+++ b/bin/sh/tests/expansion/pathname6.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
unset LC_ALL
LC_COLLATE=en_US.US-ASCII
diff --git a/bin/sh/tests/expansion/plus-minus1.0 b/bin/sh/tests/expansion/plus-minus1.0
index 9a6a53a2414a..6b7f22f61287 100644
--- a/bin/sh/tests/expansion/plus-minus1.0
+++ b/bin/sh/tests/expansion/plus-minus1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
e= q='?' a='*' t=texttext s='ast*que?non' p='/et[c]/' w='a b c' b='{{(#)}}'
h='##'
diff --git a/bin/sh/tests/expansion/plus-minus2.0 b/bin/sh/tests/expansion/plus-minus2.0
index f5a87525ae37..b2794c5e7069 100644
--- a/bin/sh/tests/expansion/plus-minus2.0
+++ b/bin/sh/tests/expansion/plus-minus2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
e=
test "${e:-\}}" = '}'
diff --git a/bin/sh/tests/expansion/plus-minus3.0 b/bin/sh/tests/expansion/plus-minus3.0
index 49fcdc2f8f56..59c4326bbffe 100644
--- a/bin/sh/tests/expansion/plus-minus3.0
+++ b/bin/sh/tests/expansion/plus-minus3.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
e= q='?' a='*' t=texttext s='ast*que?non' p='/et[c]/' w='a b c' b='{{(#)}}'
h='##'
diff --git a/bin/sh/tests/expansion/plus-minus4.0 b/bin/sh/tests/expansion/plus-minus4.0
index 66dea3851efc..fc845418b0e8 100644
--- a/bin/sh/tests/expansion/plus-minus4.0
+++ b/bin/sh/tests/expansion/plus-minus4.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# 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
diff --git a/bin/sh/tests/expansion/plus-minus5.0 b/bin/sh/tests/expansion/plus-minus5.0
index 0b25e53cf82a..aa717c74ab34 100644
--- a/bin/sh/tests/expansion/plus-minus5.0
+++ b/bin/sh/tests/expansion/plus-minus5.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
e= q='?' a='*' t=texttext s='ast*que?non' p='/et[c]/' w='a b c' b='{{(#)}}'
h='##'
diff --git a/bin/sh/tests/expansion/plus-minus6.0 b/bin/sh/tests/expansion/plus-minus6.0
index bc6680526823..dd959a9a894c 100644
--- a/bin/sh/tests/expansion/plus-minus6.0
+++ b/bin/sh/tests/expansion/plus-minus6.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
failures=0
unset LC_ALL
diff --git a/bin/sh/tests/expansion/plus-minus7.0 b/bin/sh/tests/expansion/plus-minus7.0
index 9e81f58a0a99..65c6eb98a338 100644
--- a/bin/sh/tests/expansion/plus-minus7.0
+++ b/bin/sh/tests/expansion/plus-minus7.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
e= s='foo'
failures=''
diff --git a/bin/sh/tests/expansion/plus-minus8.0 b/bin/sh/tests/expansion/plus-minus8.0
index beba009b0660..ef8de8a46909 100644
--- a/bin/sh/tests/expansion/plus-minus8.0
+++ b/bin/sh/tests/expansion/plus-minus8.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -- 1 2 3 4 5 6 7 8 9 10 11 12 13
[ "${#+hi}" = hi ] || echo '${#+hi} wrong'
diff --git a/bin/sh/tests/expansion/plus-minus9.0 b/bin/sh/tests/expansion/plus-minus9.0
index bd2629ad9a76..1fa2c92d14cd 100644
--- a/bin/sh/tests/expansion/plus-minus9.0
+++ b/bin/sh/tests/expansion/plus-minus9.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
a=1
b=${a+
diff --git a/bin/sh/tests/expansion/question1.0 b/bin/sh/tests/expansion/question1.0
index 663c68d2046d..b9d1b72be648 100644
--- a/bin/sh/tests/expansion/question1.0
+++ b/bin/sh/tests/expansion/question1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
x=a\ b
[ "$x" = "${x?}" ] || exit 1
diff --git a/bin/sh/tests/expansion/question2.0 b/bin/sh/tests/expansion/question2.0
index 592385d1df02..af7d0db99271 100644
--- a/bin/sh/tests/expansion/question2.0
+++ b/bin/sh/tests/expansion/question2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
unset dummyvar
msg=`(: ${dummyvar?}) 2>&1`
diff --git a/bin/sh/tests/expansion/readonly1.0 b/bin/sh/tests/expansion/readonly1.0
index 5ad0e143f81f..5ced727a4fd6 100644
--- a/bin/sh/tests/expansion/readonly1.0
+++ b/bin/sh/tests/expansion/readonly1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
w='@ @'
diff --git a/bin/sh/tests/expansion/redir1.0 b/bin/sh/tests/expansion/redir1.0
index aa13e1561b68..50b841e47439 100644
--- a/bin/sh/tests/expansion/redir1.0
+++ b/bin/sh/tests/expansion/redir1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
bad=0
for i in 0 1 2 3; do
diff --git a/bin/sh/tests/expansion/set-u1.0 b/bin/sh/tests/expansion/set-u1.0
index 763eb7dcfc8f..da31fe6bac18 100644
--- a/bin/sh/tests/expansion/set-u1.0
+++ b/bin/sh/tests/expansion/set-u1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
${SH} -uc 'unset foo; echo $foo' 2>/dev/null && exit 1
${SH} -uc 'foo=; echo $foo' >/dev/null || exit 1
diff --git a/bin/sh/tests/expansion/set-u2.0 b/bin/sh/tests/expansion/set-u2.0
index f81aa62cb6ba..138f7bc27558 100644
--- a/bin/sh/tests/expansion/set-u2.0
+++ b/bin/sh/tests/expansion/set-u2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -u
: $* $@ "$@" "$*"
diff --git a/bin/sh/tests/expansion/set-u3.0 b/bin/sh/tests/expansion/set-u3.0
index 7f199b42c796..bd3644503515 100644
--- a/bin/sh/tests/expansion/set-u3.0
+++ b/bin/sh/tests/expansion/set-u3.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -u
unset x
diff --git a/bin/sh/tests/expansion/tilde1.0 b/bin/sh/tests/expansion/tilde1.0
index 7d8581bbc8ee..66af698016d1 100644
--- a/bin/sh/tests/expansion/tilde1.0
+++ b/bin/sh/tests/expansion/tilde1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
HOME=/tmp
roothome=~root
diff --git a/bin/sh/tests/expansion/tilde2.0 b/bin/sh/tests/expansion/tilde2.0
index 4f8ed9b491c7..0d0cb1c95d76 100644
--- a/bin/sh/tests/expansion/tilde2.0
+++ b/bin/sh/tests/expansion/tilde2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
HOME=/tmp
roothome=~root
diff --git a/bin/sh/tests/expansion/trim1.0 b/bin/sh/tests/expansion/trim1.0
index b548e521792a..186c087062bd 100644
--- a/bin/sh/tests/expansion/trim1.0
+++ b/bin/sh/tests/expansion/trim1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
e= q='?' a='*' t=texttext s='ast*que?non' p='/et[c]/' w='a b c' b='{{(#)}}'
h='##'
diff --git a/bin/sh/tests/expansion/trim10.0 b/bin/sh/tests/expansion/trim10.0
index 7860485ed00a..1814af1b1793 100644
--- a/bin/sh/tests/expansion/trim10.0
+++ b/bin/sh/tests/expansion/trim10.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
a='z
'
diff --git a/bin/sh/tests/expansion/trim11.0 b/bin/sh/tests/expansion/trim11.0
index 904914789911..041095b66e57 100644
--- a/bin/sh/tests/expansion/trim11.0
+++ b/bin/sh/tests/expansion/trim11.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
a='z
'
diff --git a/bin/sh/tests/expansion/trim2.0 b/bin/sh/tests/expansion/trim2.0
index 619ef651cce6..337bbd4e46cc 100644
--- a/bin/sh/tests/expansion/trim2.0
+++ b/bin/sh/tests/expansion/trim2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
e= q='?' a='*' t=texttext s='ast*que?non' p='/et[c]/' w='a b c' b='{{(#)}}'
h='##'
diff --git a/bin/sh/tests/expansion/trim3.0 b/bin/sh/tests/expansion/trim3.0
index b89a04140c37..d58ae50c7824 100644
--- a/bin/sh/tests/expansion/trim3.0
+++ b/bin/sh/tests/expansion/trim3.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
e= q='?' a='*' t=texttext s='ast*que?non' p='/et[c]/' w='a b c' b='{{(#)}}'
h='##' c='\\\\'
diff --git a/bin/sh/tests/expansion/trim4.0 b/bin/sh/tests/expansion/trim4.0
index 1000bd3d0245..2b0766abcdfd 100644
--- a/bin/sh/tests/expansion/trim4.0
+++ b/bin/sh/tests/expansion/trim4.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
v1=/homes/SOME_USER
v2=
diff --git a/bin/sh/tests/expansion/trim5.0 b/bin/sh/tests/expansion/trim5.0
index 937ec9a708e0..a6131b321e21 100644
--- a/bin/sh/tests/expansion/trim5.0
+++ b/bin/sh/tests/expansion/trim5.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
e= q='?' a='*' t=texttext s='ast*que?non' p='/et[c]/' w='a b c' b='{{(#)}}'
h='##'
diff --git a/bin/sh/tests/expansion/trim6.0 b/bin/sh/tests/expansion/trim6.0
index 3f753c4113f6..b0566b90d4b3 100644
--- a/bin/sh/tests/expansion/trim6.0
+++ b/bin/sh/tests/expansion/trim6.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
e=
for i in 0 1 2 3; do
diff --git a/bin/sh/tests/expansion/trim7.0 b/bin/sh/tests/expansion/trim7.0
index 352bdea920bf..2fcb41535c68 100644
--- a/bin/sh/tests/expansion/trim7.0
+++ b/bin/sh/tests/expansion/trim7.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -- 1 2 3 4 5 6 7 8 9 10 11 12 13
[ "${##1}" = 3 ] || echo '${##1} wrong'
diff --git a/bin/sh/tests/expansion/trim8.0 b/bin/sh/tests/expansion/trim8.0
index f7272f371dce..579d78012c40 100644
--- a/bin/sh/tests/expansion/trim8.0
+++ b/bin/sh/tests/expansion/trim8.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
unset LC_ALL
LC_CTYPE=en_US.UTF-8
diff --git a/bin/sh/tests/expansion/trim9.0 b/bin/sh/tests/expansion/trim9.0
index 47c825a52c3a..a6314381d362 100644
--- a/bin/sh/tests/expansion/trim9.0
+++ b/bin/sh/tests/expansion/trim9.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# POSIX does not specify these but they occasionally occur in the wild.
# This just serves to keep working what currently works.
diff --git a/bin/sh/tests/functional_test.sh b/bin/sh/tests/functional_test.sh
index 698053885adc..3a43ccbd1a17 100755
--- a/bin/sh/tests/functional_test.sh
+++ b/bin/sh/tests/functional_test.sh
@@ -24,7 +24,6 @@
# (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$
SRCDIR=$(atf_get_srcdir)
diff --git a/bin/sh/tests/invocation/Makefile b/bin/sh/tests/invocation/Makefile
index b0bf97be9e69..6c892026ec75 100644
--- a/bin/sh/tests/invocation/Makefile
+++ b/bin/sh/tests/invocation/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE= tests
diff --git a/bin/sh/tests/invocation/Makefile.depend b/bin/sh/tests/invocation/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/bin/sh/tests/invocation/Makefile.depend
+++ b/bin/sh/tests/invocation/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/bin/sh/tests/invocation/sh-ac1.0 b/bin/sh/tests/invocation/sh-ac1.0
index 0e0818b8a2c4..8386679a6653 100644
--- a/bin/sh/tests/invocation/sh-ac1.0
+++ b/bin/sh/tests/invocation/sh-ac1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Test that attached options before c are processed
case `${SH} -ac 'echo $-:$0' moo` in
diff --git a/bin/sh/tests/invocation/sh-c-missing1.0 b/bin/sh/tests/invocation/sh-c-missing1.0
index 6089a6df3eb1..630158a754fd 100644
--- a/bin/sh/tests/invocation/sh-c-missing1.0
+++ b/bin/sh/tests/invocation/sh-c-missing1.0
@@ -1,3 +1,2 @@
-# $FreeBSD$
! echo echo bad | ${SH} -c 2>/dev/null
diff --git a/bin/sh/tests/invocation/sh-c1.0 b/bin/sh/tests/invocation/sh-c1.0
index 6bda19837b90..07dc0d840145 100644
--- a/bin/sh/tests/invocation/sh-c1.0
+++ b/bin/sh/tests/invocation/sh-c1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Test that -c executes command_string with the given name and arg
${SH} -c 'echo $0 $@' moo foo | grep -qx -- "moo foo"
diff --git a/bin/sh/tests/invocation/sh-ca1.0 b/bin/sh/tests/invocation/sh-ca1.0
index 188b6453db2a..6fe78f1c57aa 100644
--- a/bin/sh/tests/invocation/sh-ca1.0
+++ b/bin/sh/tests/invocation/sh-ca1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Test that attached options after c are processed
case `${SH} -ca 'echo $-:$0' moo` in
diff --git a/bin/sh/tests/invocation/sh-fca1.0 b/bin/sh/tests/invocation/sh-fca1.0
index c010a5ebacdf..f31312d779d0 100644
--- a/bin/sh/tests/invocation/sh-fca1.0
+++ b/bin/sh/tests/invocation/sh-fca1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Test that attached options before and after c are processed
case `${SH} -fca 'echo $-:$-:$0:$@' foo -bar` in
diff --git a/bin/sh/tests/parameters/Makefile b/bin/sh/tests/parameters/Makefile
index 939bd199a72b..0d6722b1d65a 100644
--- a/bin/sh/tests/parameters/Makefile
+++ b/bin/sh/tests/parameters/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE= tests
diff --git a/bin/sh/tests/parameters/Makefile.depend b/bin/sh/tests/parameters/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/bin/sh/tests/parameters/Makefile.depend
+++ b/bin/sh/tests/parameters/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/bin/sh/tests/parameters/env1.0 b/bin/sh/tests/parameters/env1.0
index c0d4a2cc9141..ade1ed6249c6 100644
--- a/bin/sh/tests/parameters/env1.0
+++ b/bin/sh/tests/parameters/env1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
export key='must contain this'
unset x
diff --git a/bin/sh/tests/parameters/exitstatus1.0 b/bin/sh/tests/parameters/exitstatus1.0
index 696823d58043..f3243926813c 100644
--- a/bin/sh/tests/parameters/exitstatus1.0
+++ b/bin/sh/tests/parameters/exitstatus1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
f() {
[ $? = $1 ] || exit 1
}
diff --git a/bin/sh/tests/parameters/ifs1.0 b/bin/sh/tests/parameters/ifs1.0
index b93d99a8a8c7..9462a46e1ae9 100644
--- a/bin/sh/tests/parameters/ifs1.0
+++ b/bin/sh/tests/parameters/ifs1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
env IFS=_ ${SH} -c '
rc=2
diff --git a/bin/sh/tests/parameters/mail1.0 b/bin/sh/tests/parameters/mail1.0
index 5791a5accc7c..09102d811513 100644
--- a/bin/sh/tests/parameters/mail1.0
+++ b/bin/sh/tests/parameters/mail1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Test that a non-interactive shell does not access $MAIL.
goodfile=/var/empty/sh-test-goodfile
diff --git a/bin/sh/tests/parameters/mail2.0 b/bin/sh/tests/parameters/mail2.0
index 343c99de9b27..d594c4a74356 100644
--- a/bin/sh/tests/parameters/mail2.0
+++ b/bin/sh/tests/parameters/mail2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Test that an interactive shell accesses $MAIL.
goodfile=/var/empty/sh-test-goodfile
diff --git a/bin/sh/tests/parameters/optind1.0 b/bin/sh/tests/parameters/optind1.0
index 33e0288e861f..516f124c38a7 100644
--- a/bin/sh/tests/parameters/optind1.0
+++ b/bin/sh/tests/parameters/optind1.0
@@ -1,3 +1,2 @@
-# $FreeBSD$
unset OPTIND && [ -z "$OPTIND" ]
diff --git a/bin/sh/tests/parameters/optind2.0 b/bin/sh/tests/parameters/optind2.0
index a7689f6841a5..3ca60ba6f78d 100644
--- a/bin/sh/tests/parameters/optind2.0
+++ b/bin/sh/tests/parameters/optind2.0
@@ -1,3 +1,2 @@
-# $FreeBSD$
[ "$(OPTIND=42 ${SH} -c 'printf %s "$OPTIND"')" = 1 ]
diff --git a/bin/sh/tests/parameters/positional1.0 b/bin/sh/tests/parameters/positional1.0
index 67d19516a5d9..0186ffbd6d55 100644
--- a/bin/sh/tests/parameters/positional1.0
+++ b/bin/sh/tests/parameters/positional1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -- a b c d e f g h i j
[ "$1" = a ] || echo "error at line $LINENO"
diff --git a/bin/sh/tests/parameters/positional2.0 b/bin/sh/tests/parameters/positional2.0
index fcec2a4b676e..88bd93dcfe6c 100644
--- a/bin/sh/tests/parameters/positional2.0
+++ b/bin/sh/tests/parameters/positional2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
failures=''
ok=''
diff --git a/bin/sh/tests/parameters/positional3.0 b/bin/sh/tests/parameters/positional3.0
index 1200469b4e12..28311fa2ee1a 100644
--- a/bin/sh/tests/parameters/positional3.0
+++ b/bin/sh/tests/parameters/positional3.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
r=$(${SH} -c 'echo ${01:+yes}${010:+yes}' '' a '' '' '' '' '' '' '' '' b)
[ "$r" = yesyes ]
diff --git a/bin/sh/tests/parameters/positional4.0 b/bin/sh/tests/parameters/positional4.0
index c1c380c0feac..1b290b99da0c 100644
--- a/bin/sh/tests/parameters/positional4.0
+++ b/bin/sh/tests/parameters/positional4.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -- "x$0" 2 3 4 5 6 7 8 9 "y$0"
[ "${01}.${010}" = "$1.${10}" ]
diff --git a/bin/sh/tests/parameters/positional5.0 b/bin/sh/tests/parameters/positional5.0
index eeaaba5321ff..ac6471ed57fd 100644
--- a/bin/sh/tests/parameters/positional5.0
+++ b/bin/sh/tests/parameters/positional5.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
i=1
r=0
diff --git a/bin/sh/tests/parameters/positional6.0 b/bin/sh/tests/parameters/positional6.0
index 1410668b8a9f..43df962106b3 100644
--- a/bin/sh/tests/parameters/positional6.0
+++ b/bin/sh/tests/parameters/positional6.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
IFS=?
set p r
diff --git a/bin/sh/tests/parameters/positional7.0 b/bin/sh/tests/parameters/positional7.0
index f170ad343996..8a21da97973e 100644
--- a/bin/sh/tests/parameters/positional7.0
+++ b/bin/sh/tests/parameters/positional7.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -- / ''
IFS=*
diff --git a/bin/sh/tests/parameters/positional8.0 b/bin/sh/tests/parameters/positional8.0
index 4c4dbd5cf1a6..1b1b941c8ee6 100644
--- a/bin/sh/tests/parameters/positional8.0
+++ b/bin/sh/tests/parameters/positional8.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
failures=''
ok=''
diff --git a/bin/sh/tests/parameters/positional9.0 b/bin/sh/tests/parameters/positional9.0
index 8571bfaf6135..823995f0c783 100644
--- a/bin/sh/tests/parameters/positional9.0
+++ b/bin/sh/tests/parameters/positional9.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Although POSIX leaves the result of expanding ${#@} and ${#*} unspecified,
# make sure it is at least numeric.
diff --git a/bin/sh/tests/parameters/pwd1.0 b/bin/sh/tests/parameters/pwd1.0
index 0099379a9d3c..cd0d8329cd8c 100644
--- a/bin/sh/tests/parameters/pwd1.0
+++ b/bin/sh/tests/parameters/pwd1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Check that bogus PWD values are not accepted from the environment.
cd / || exit 3
diff --git a/bin/sh/tests/parameters/pwd2.0 b/bin/sh/tests/parameters/pwd2.0
index 2297f8b753d4..69ab5c896f9e 100644
--- a/bin/sh/tests/parameters/pwd2.0
+++ b/bin/sh/tests/parameters/pwd2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Check that PWD is exported and accepted from the environment.
set -e
diff --git a/bin/sh/tests/parser/Makefile b/bin/sh/tests/parser/Makefile
index 3239f5bccd84..812edafa7ca8 100644
--- a/bin/sh/tests/parser/Makefile
+++ b/bin/sh/tests/parser/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE= tests
diff --git a/bin/sh/tests/parser/Makefile.depend b/bin/sh/tests/parser/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/bin/sh/tests/parser/Makefile.depend
+++ b/bin/sh/tests/parser/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/bin/sh/tests/parser/alias1.0 b/bin/sh/tests/parser/alias1.0
index 75dd9ab9b8f1..2380bb95e449 100644
--- a/bin/sh/tests/parser/alias1.0
+++ b/bin/sh/tests/parser/alias1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
alias alias0=exit
eval 'alias0 0'
diff --git a/bin/sh/tests/parser/alias10.0 b/bin/sh/tests/parser/alias10.0
index 30d99f49bbf4..d8c77691b2b8 100644
--- a/bin/sh/tests/parser/alias10.0
+++ b/bin/sh/tests/parser/alias10.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# This test may start consuming memory indefinitely if it fails.
ulimit -t 5 2>/dev/null
diff --git a/bin/sh/tests/parser/alias11.0 b/bin/sh/tests/parser/alias11.0
index 522264ff823f..286323028a2c 100644
--- a/bin/sh/tests/parser/alias11.0
+++ b/bin/sh/tests/parser/alias11.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
alias alias0=alias1
alias alias1=exit
diff --git a/bin/sh/tests/parser/alias12.0 b/bin/sh/tests/parser/alias12.0
index 2e4379155d4a..30be135c0cd1 100644
--- a/bin/sh/tests/parser/alias12.0
+++ b/bin/sh/tests/parser/alias12.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
unalias -a
alias alias0=command
diff --git a/bin/sh/tests/parser/alias13.0 b/bin/sh/tests/parser/alias13.0
index 53b949dc23e9..df35c5045aa5 100644
--- a/bin/sh/tests/parser/alias13.0
+++ b/bin/sh/tests/parser/alias13.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
unalias -a
alias command=command
diff --git a/bin/sh/tests/parser/alias14.0 b/bin/sh/tests/parser/alias14.0
index 1b92fc07d5b2..20acd59d4d4c 100644
--- a/bin/sh/tests/parser/alias14.0
+++ b/bin/sh/tests/parser/alias14.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
alias command='command '
alias alias0=exit
diff --git a/bin/sh/tests/parser/alias15.0 b/bin/sh/tests/parser/alias15.0
index f0fbadbb20e7..19a1a36eaaff 100644
--- a/bin/sh/tests/parser/alias15.0
+++ b/bin/sh/tests/parser/alias15.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
f_echoanddo() {
printf '%s\n' "$*"
diff --git a/bin/sh/tests/parser/alias16.0 b/bin/sh/tests/parser/alias16.0
index 2df9c254e57d..b611c69ab04f 100644
--- a/bin/sh/tests/parser/alias16.0
+++ b/bin/sh/tests/parser/alias16.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
v=1
alias a='unalias a
diff --git a/bin/sh/tests/parser/alias17.0 b/bin/sh/tests/parser/alias17.0
index 005eeb72dee4..c2e24c68aa5f 100644
--- a/bin/sh/tests/parser/alias17.0
+++ b/bin/sh/tests/parser/alias17.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
v=1
alias a='unalias -a
diff --git a/bin/sh/tests/parser/alias18.0 b/bin/sh/tests/parser/alias18.0
index 74234fe72c05..05117c5a830f 100644
--- a/bin/sh/tests/parser/alias18.0
+++ b/bin/sh/tests/parser/alias18.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
v=1
alias a='alias a=v=2
diff --git a/bin/sh/tests/parser/alias19.0 b/bin/sh/tests/parser/alias19.0
index d086f652fea5..c35930e9835d 100644
--- a/bin/sh/tests/parser/alias19.0
+++ b/bin/sh/tests/parser/alias19.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
alias begin={ end=}
begin
diff --git a/bin/sh/tests/parser/alias2.0 b/bin/sh/tests/parser/alias2.0
index ae99b8a588c2..e92d62eaefdc 100644
--- a/bin/sh/tests/parser/alias2.0
+++ b/bin/sh/tests/parser/alias2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
alias alias0=exit
x=alias0
diff --git a/bin/sh/tests/parser/alias20.0 b/bin/sh/tests/parser/alias20.0
index 0eedd5214016..7e1767eaccd8 100644
--- a/bin/sh/tests/parser/alias20.0
+++ b/bin/sh/tests/parser/alias20.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
alias begin={ end=}
: <<EOF &&
diff --git a/bin/sh/tests/parser/alias3.0 b/bin/sh/tests/parser/alias3.0
index e0721e2aaa01..4651ba149c60 100644
--- a/bin/sh/tests/parser/alias3.0
+++ b/bin/sh/tests/parser/alias3.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
alias alias0=exit
x=alias0
diff --git a/bin/sh/tests/parser/alias4.0 b/bin/sh/tests/parser/alias4.0
index 19332ed09056..a46923d1ebdd 100644
--- a/bin/sh/tests/parser/alias4.0
+++ b/bin/sh/tests/parser/alias4.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
alias alias0=exit
eval 'x=1 alias0 0'
diff --git a/bin/sh/tests/parser/alias5.0 b/bin/sh/tests/parser/alias5.0
index 3d0205fd2332..4c393cd116d9 100644
--- a/bin/sh/tests/parser/alias5.0
+++ b/bin/sh/tests/parser/alias5.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
alias alias0=exit
eval '</dev/null alias0 0'
diff --git a/bin/sh/tests/parser/alias6.0 b/bin/sh/tests/parser/alias6.0
index c723d08ab3eb..23c3d39de002 100644
--- a/bin/sh/tests/parser/alias6.0
+++ b/bin/sh/tests/parser/alias6.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
alias alias0='| cat >/dev/null'
diff --git a/bin/sh/tests/parser/alias7.0 b/bin/sh/tests/parser/alias7.0
index b26f0dd067cd..f644ceaa7abd 100644
--- a/bin/sh/tests/parser/alias7.0
+++ b/bin/sh/tests/parser/alias7.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
alias echo='echo a'
[ "`eval echo b`" = "a b" ]
diff --git a/bin/sh/tests/parser/alias8.0 b/bin/sh/tests/parser/alias8.0
index 7fc2f15f0931..c71997f362cf 100644
--- a/bin/sh/tests/parser/alias8.0
+++ b/bin/sh/tests/parser/alias8.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
alias echo='echo'
[ "`eval echo b`" = b ]
diff --git a/bin/sh/tests/parser/alias9.0 b/bin/sh/tests/parser/alias9.0
index 6bd8808cc379..50fe86e2b8fd 100644
--- a/bin/sh/tests/parser/alias9.0
+++ b/bin/sh/tests/parser/alias9.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
alias alias0=:
alias alias0=exit
diff --git a/bin/sh/tests/parser/and-pipe-not.0 b/bin/sh/tests/parser/and-pipe-not.0
index 35b125c14767..90889bfe62f6 100644
--- a/bin/sh/tests/parser/and-pipe-not.0
+++ b/bin/sh/tests/parser/and-pipe-not.0
@@ -1,2 +1 @@
-# $FreeBSD$
true && ! true | false
diff --git a/bin/sh/tests/parser/case1.0 b/bin/sh/tests/parser/case1.0
index 49b4c45155fa..8b4e1c342a68 100644
--- a/bin/sh/tests/parser/case1.0
+++ b/bin/sh/tests/parser/case1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
keywords='if then else elif fi while until for do done { } case esac ! in'
diff --git a/bin/sh/tests/parser/case2.0 b/bin/sh/tests/parser/case2.0
index 14610e415c19..578187a5a320 100644
--- a/bin/sh/tests/parser/case2.0
+++ b/bin/sh/tests/parser/case2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Pretty much only ash derivatives can parse all of this.
diff --git a/bin/sh/tests/parser/comment1.0 b/bin/sh/tests/parser/comment1.0
index 21e7ade957bc..59904fb98ced 100644
--- a/bin/sh/tests/parser/comment1.0
+++ b/bin/sh/tests/parser/comment1.0
@@ -1,3 +1,2 @@
-# $FreeBSD$
${SH} -c '#'
diff --git a/bin/sh/tests/parser/comment2.42 b/bin/sh/tests/parser/comment2.42
index 196b73354493..30ab4c4d1df5 100644
--- a/bin/sh/tests/parser/comment2.42
+++ b/bin/sh/tests/parser/comment2.42
@@ -1,4 +1,3 @@
-# $FreeBSD$
${SH} -c '#
exit 42'
diff --git a/bin/sh/tests/parser/dollar-quote1.0 b/bin/sh/tests/parser/dollar-quote1.0
index 12061417e108..2862b8a20b09 100644
--- a/bin/sh/tests/parser/dollar-quote1.0
+++ b/bin/sh/tests/parser/dollar-quote1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -e
diff --git a/bin/sh/tests/parser/dollar-quote10.0 b/bin/sh/tests/parser/dollar-quote10.0
index ad166da23ffe..e28ea482ac23 100644
--- a/bin/sh/tests/parser/dollar-quote10.0
+++ b/bin/sh/tests/parser/dollar-quote10.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# a umlaut
s=$(printf '\303\244')
diff --git a/bin/sh/tests/parser/dollar-quote11.0 b/bin/sh/tests/parser/dollar-quote11.0
index 2e872abfe5b0..de567ebeed43 100644
--- a/bin/sh/tests/parser/dollar-quote11.0
+++ b/bin/sh/tests/parser/dollar-quote11.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# some sort of 't' outside BMP
s=$s$(printf '\360\235\225\245')
diff --git a/bin/sh/tests/parser/dollar-quote12.0 b/bin/sh/tests/parser/dollar-quote12.0
index 838e27cda706..a6207d29a2ba 100644
--- a/bin/sh/tests/parser/dollar-quote12.0
+++ b/bin/sh/tests/parser/dollar-quote12.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# \u without any digits at all remains invalid.
# Our choice is a parse error.
diff --git a/bin/sh/tests/parser/dollar-quote13.0 b/bin/sh/tests/parser/dollar-quote13.0
index 2247da7abbc9..d042ad741646 100644
--- a/bin/sh/tests/parser/dollar-quote13.0
+++ b/bin/sh/tests/parser/dollar-quote13.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# This Unicode escape sequence that has never been in range should either
# fail to expand or expand to a fallback.
diff --git a/bin/sh/tests/parser/dollar-quote2.0 b/bin/sh/tests/parser/dollar-quote2.0
index 4617ed8d9086..87a1b39a62ba 100644
--- a/bin/sh/tests/parser/dollar-quote2.0
+++ b/bin/sh/tests/parser/dollar-quote2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# This depends on the ASCII character set.
diff --git a/bin/sh/tests/parser/dollar-quote3.0 b/bin/sh/tests/parser/dollar-quote3.0
index a7e68527791c..9ac5afb6d2bc 100644
--- a/bin/sh/tests/parser/dollar-quote3.0
+++ b/bin/sh/tests/parser/dollar-quote3.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
unset LC_ALL
LC_CTYPE=en_US.ISO8859-1
diff --git a/bin/sh/tests/parser/dollar-quote4.0 b/bin/sh/tests/parser/dollar-quote4.0
index f620af5b12c2..be0de8bbb508 100644
--- a/bin/sh/tests/parser/dollar-quote4.0
+++ b/bin/sh/tests/parser/dollar-quote4.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
unset LC_ALL
LC_CTYPE=en_US.ISO8859-1
diff --git a/bin/sh/tests/parser/dollar-quote5.0 b/bin/sh/tests/parser/dollar-quote5.0
index c2c44ca620e5..2bf6a0ea2183 100644
--- a/bin/sh/tests/parser/dollar-quote5.0
+++ b/bin/sh/tests/parser/dollar-quote5.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# This depends on the ASCII character set.
diff --git a/bin/sh/tests/parser/dollar-quote6.0 b/bin/sh/tests/parser/dollar-quote6.0
index a4b1e3f48729..dc6f8ab45cf2 100644
--- a/bin/sh/tests/parser/dollar-quote6.0
+++ b/bin/sh/tests/parser/dollar-quote6.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# This depends on the ASCII character set.
diff --git a/bin/sh/tests/parser/dollar-quote7.0 b/bin/sh/tests/parser/dollar-quote7.0
index c866b1af68bb..5108fd4eb146 100644
--- a/bin/sh/tests/parser/dollar-quote7.0
+++ b/bin/sh/tests/parser/dollar-quote7.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -e
diff --git a/bin/sh/tests/parser/dollar-quote8.0 b/bin/sh/tests/parser/dollar-quote8.0
index 8f0b41a0a3f7..81dcb9b394f7 100644
--- a/bin/sh/tests/parser/dollar-quote8.0
+++ b/bin/sh/tests/parser/dollar-quote8.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
[ $'hello\0' = hello ]
[ $'hello\0world' = hello ]
diff --git a/bin/sh/tests/parser/dollar-quote9.0 b/bin/sh/tests/parser/dollar-quote9.0
index df64b7dfc0b1..845f8c284326 100644
--- a/bin/sh/tests/parser/dollar-quote9.0
+++ b/bin/sh/tests/parser/dollar-quote9.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# POSIX and C99 say D800-DFFF are undefined in a universal character name.
# We reject this but many other shells expand to something that looks like
diff --git a/bin/sh/tests/parser/empty-braces1.0 b/bin/sh/tests/parser/empty-braces1.0
index 5ab443c48d8a..11032811c80e 100644
--- a/bin/sh/tests/parser/empty-braces1.0
+++ b/bin/sh/tests/parser/empty-braces1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Unfortunately, some scripts depend on the extension of allowing an empty
# pair of braces.
diff --git a/bin/sh/tests/parser/empty-cmd1.0 b/bin/sh/tests/parser/empty-cmd1.0
index f8b01e9c7997..15f4f4ac995b 100644
--- a/bin/sh/tests/parser/empty-cmd1.0
+++ b/bin/sh/tests/parser/empty-cmd1.0
@@ -1,3 +1,2 @@
-# $FreeBSD$
! (eval ': || f()') 2>/dev/null
diff --git a/bin/sh/tests/parser/for1.0 b/bin/sh/tests/parser/for1.0
index eb7c881237fd..1633385068c2 100644
--- a/bin/sh/tests/parser/for1.0
+++ b/bin/sh/tests/parser/for1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
nl='
'
diff --git a/bin/sh/tests/parser/for2.0 b/bin/sh/tests/parser/for2.0
index 54ebfc3d7193..2dd2d5acd1c3 100644
--- a/bin/sh/tests/parser/for2.0
+++ b/bin/sh/tests/parser/for2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Common extensions to the 'for' syntax.
diff --git a/bin/sh/tests/parser/func1.0 b/bin/sh/tests/parser/func1.0
index 4e887b25f285..93381364aa6c 100644
--- a/bin/sh/tests/parser/func1.0
+++ b/bin/sh/tests/parser/func1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# POSIX does not require these bytes to work in function names,
# but making them all work seems a good goal.
diff --git a/bin/sh/tests/parser/func2.0 b/bin/sh/tests/parser/func2.0
index 5fd4dda8cca9..dc9eb6ed1579 100644
--- a/bin/sh/tests/parser/func2.0
+++ b/bin/sh/tests/parser/func2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
f() { return 42; }
f() { return 3; } &
diff --git a/bin/sh/tests/parser/func3.0 b/bin/sh/tests/parser/func3.0
index dcac7323ad3f..c1462a33c80c 100644
--- a/bin/sh/tests/parser/func3.0
+++ b/bin/sh/tests/parser/func3.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
name=/var/empty/nosuch
f() { true; } <$name
diff --git a/bin/sh/tests/parser/heredoc1.0 b/bin/sh/tests/parser/heredoc1.0
index 5ce38977d7f5..6bfee605633a 100644
--- a/bin/sh/tests/parser/heredoc1.0
+++ b/bin/sh/tests/parser/heredoc1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
failures=0
diff --git a/bin/sh/tests/parser/heredoc10.0 b/bin/sh/tests/parser/heredoc10.0
index 27369a0b1b4c..95e280381bd3 100644
--- a/bin/sh/tests/parser/heredoc10.0
+++ b/bin/sh/tests/parser/heredoc10.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# It may be argued that
# x=$(cat <<EOF
diff --git a/bin/sh/tests/parser/heredoc11.0 b/bin/sh/tests/parser/heredoc11.0
index 5839e46b36ce..71bf7c017df4 100644
--- a/bin/sh/tests/parser/heredoc11.0
+++ b/bin/sh/tests/parser/heredoc11.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
failures=''
diff --git a/bin/sh/tests/parser/heredoc12.0 b/bin/sh/tests/parser/heredoc12.0
index 964838453237..0209a94d5f40 100644
--- a/bin/sh/tests/parser/heredoc12.0
+++ b/bin/sh/tests/parser/heredoc12.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
failures=0
diff --git a/bin/sh/tests/parser/heredoc13.0 b/bin/sh/tests/parser/heredoc13.0
index 225d4f08f492..1a3de0572142 100644
--- a/bin/sh/tests/parser/heredoc13.0
+++ b/bin/sh/tests/parser/heredoc13.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
failures=0
diff --git a/bin/sh/tests/parser/heredoc2.0 b/bin/sh/tests/parser/heredoc2.0
index 4bb85ad80c17..8b936bcb3799 100644
--- a/bin/sh/tests/parser/heredoc2.0
+++ b/bin/sh/tests/parser/heredoc2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
failures=0
diff --git a/bin/sh/tests/parser/heredoc3.0 b/bin/sh/tests/parser/heredoc3.0
index b250272f3319..dabd0650bd56 100644
--- a/bin/sh/tests/parser/heredoc3.0
+++ b/bin/sh/tests/parser/heredoc3.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# This may be expected to work, but pretty much only ash derivatives allow it.
diff --git a/bin/sh/tests/parser/heredoc4.0 b/bin/sh/tests/parser/heredoc4.0
index fa3af5fd5a97..46262887d707 100644
--- a/bin/sh/tests/parser/heredoc4.0
+++ b/bin/sh/tests/parser/heredoc4.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
failures=0
diff --git a/bin/sh/tests/parser/heredoc5.0 b/bin/sh/tests/parser/heredoc5.0
index 84b0eb2705d4..a336205acf75 100644
--- a/bin/sh/tests/parser/heredoc5.0
+++ b/bin/sh/tests/parser/heredoc5.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
failures=0
diff --git a/bin/sh/tests/parser/heredoc6.0 b/bin/sh/tests/parser/heredoc6.0
index 3a634de167a7..24570bcfd42f 100644
--- a/bin/sh/tests/parser/heredoc6.0
+++ b/bin/sh/tests/parser/heredoc6.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
r=
! command eval ": <<EOF; )" 2>/dev/null; command eval : hi \${r:=0}
diff --git a/bin/sh/tests/parser/heredoc7.0 b/bin/sh/tests/parser/heredoc7.0
index a15010648780..821e89700389 100644
--- a/bin/sh/tests/parser/heredoc7.0
+++ b/bin/sh/tests/parser/heredoc7.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Some of these created malformed parse trees with null pointers for here
# documents, causing the here document writing process to segfault.
diff --git a/bin/sh/tests/parser/heredoc8.0 b/bin/sh/tests/parser/heredoc8.0
index 598358a0494b..673fc270fa32 100644
--- a/bin/sh/tests/parser/heredoc8.0
+++ b/bin/sh/tests/parser/heredoc8.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
failures=0
diff --git a/bin/sh/tests/parser/heredoc9.0 b/bin/sh/tests/parser/heredoc9.0
index 125a542ab717..d071bf51ef15 100644
--- a/bin/sh/tests/parser/heredoc9.0
+++ b/bin/sh/tests/parser/heredoc9.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# It may be argued that
# x=$(cat <<EOF
diff --git a/bin/sh/tests/parser/line-cont1.0 b/bin/sh/tests/parser/line-cont1.0
index 7ef5eba82b1e..c130070e3769 100644
--- a/bin/sh/tests/parser/line-cont1.0
+++ b/bin/sh/tests/parser/line-cont1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
i\
f
diff --git a/bin/sh/tests/parser/line-cont10.0 b/bin/sh/tests/parser/line-cont10.0
index 1e74108757a0..d416e4241468 100644
--- a/bin/sh/tests/parser/line-cont10.0
+++ b/bin/sh/tests/parser/line-cont10.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
v=XaaaXbbbX
[ "${v\
diff --git a/bin/sh/tests/parser/line-cont11.0 b/bin/sh/tests/parser/line-cont11.0
index 22e49758dbc6..e1c2245b7566 100644
--- a/bin/sh/tests/parser/line-cont11.0
+++ b/bin/sh/tests/parser/line-cont11.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
T=$(mktemp "${TMPDIR:-/tmp}/sh-test.XXXXXXXX") || exit
trap 'rm -f -- "$T"' 0
diff --git a/bin/sh/tests/parser/line-cont12.0 b/bin/sh/tests/parser/line-cont12.0
index 27f8260feee9..2028a2ee6def 100644
--- a/bin/sh/tests/parser/line-cont12.0
+++ b/bin/sh/tests/parser/line-cont12.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
[ '\
' = "\\
diff --git a/bin/sh/tests/parser/line-cont2.0 b/bin/sh/tests/parser/line-cont2.0
index 9a293faf6bc2..d5f7ae903748 100644
--- a/bin/sh/tests/parser/line-cont2.0
+++ b/bin/sh/tests/parser/line-cont2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
[ "a\
b" = ab ]
diff --git a/bin/sh/tests/parser/line-cont3.0 b/bin/sh/tests/parser/line-cont3.0
index 09d3aa8bba83..3f9d83a14105 100644
--- a/bin/sh/tests/parser/line-cont3.0
+++ b/bin/sh/tests/parser/line-cont3.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
v=`printf %s 'a\
b'`
diff --git a/bin/sh/tests/parser/line-cont4.0 b/bin/sh/tests/parser/line-cont4.0
index 5803276f2b3b..0a58847b2c35 100644
--- a/bin/sh/tests/parser/line-cont4.0
+++ b/bin/sh/tests/parser/line-cont4.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
v=abcd
[ "$\
diff --git a/bin/sh/tests/parser/line-cont5.0 b/bin/sh/tests/parser/line-cont5.0
index a7aa02688310..d8b5f08d7bbb 100644
--- a/bin/sh/tests/parser/line-cont5.0
+++ b/bin/sh/tests/parser/line-cont5.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
bad=1
case x in
diff --git a/bin/sh/tests/parser/line-cont6.0 b/bin/sh/tests/parser/line-cont6.0
index b12125b929e5..c5da14929ec0 100644
--- a/bin/sh/tests/parser/line-cont6.0
+++ b/bin/sh/tests/parser/line-cont6.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
v0\
=abc
diff --git a/bin/sh/tests/parser/line-cont7.0 b/bin/sh/tests/parser/line-cont7.0
index 27f8aec9515c..ccc7fe4f0239 100644
--- a/bin/sh/tests/parser/line-cont7.0
+++ b/bin/sh/tests/parser/line-cont7.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
[ "$(\
(
diff --git a/bin/sh/tests/parser/line-cont8.0 b/bin/sh/tests/parser/line-cont8.0
index 88667760b47b..7db2c9d65386 100644
--- a/bin/sh/tests/parser/line-cont8.0
+++ b/bin/sh/tests/parser/line-cont8.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -- a b c d e f g h i j
[ "${1\
diff --git a/bin/sh/tests/parser/line-cont9.0 b/bin/sh/tests/parser/line-cont9.0
index 4e73c8f04abc..e0f8c2b0616c 100644
--- a/bin/sh/tests/parser/line-cont9.0
+++ b/bin/sh/tests/parser/line-cont9.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
[ "${$\
:\
diff --git a/bin/sh/tests/parser/no-space1.0 b/bin/sh/tests/parser/no-space1.0
index 6df9f6395ff6..2baba775200b 100644
--- a/bin/sh/tests/parser/no-space1.0
+++ b/bin/sh/tests/parser/no-space1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# These are ugly but are required to work.
diff --git a/bin/sh/tests/parser/no-space2.0 b/bin/sh/tests/parser/no-space2.0
index 4e8447b11e4c..d03d7aa81568 100644
--- a/bin/sh/tests/parser/no-space2.0
+++ b/bin/sh/tests/parser/no-space2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# This conflicts with ksh extended patterns but occurs in the wild.
diff --git a/bin/sh/tests/parser/nul1.0 b/bin/sh/tests/parser/nul1.0
index 49c5ab1b0cfb..292669003acd 100644
--- a/bin/sh/tests/parser/nul1.0
+++ b/bin/sh/tests/parser/nul1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Although POSIX does not specify the effect of NUL bytes in scripts,
# we ignore them.
diff --git a/bin/sh/tests/parser/only-redir1.0 b/bin/sh/tests/parser/only-redir1.0
index 46076c882a5e..1d8aff62e78c 100644
--- a/bin/sh/tests/parser/only-redir1.0
+++ b/bin/sh/tests/parser/only-redir1.0
@@ -1,3 +1,2 @@
-# $FreeBSD$
</dev/null &
wait $!
diff --git a/bin/sh/tests/parser/only-redir2.0 b/bin/sh/tests/parser/only-redir2.0
index b9e9501c2027..efe4c3947dde 100644
--- a/bin/sh/tests/parser/only-redir2.0
+++ b/bin/sh/tests/parser/only-redir2.0
@@ -1,2 +1 @@
-# $FreeBSD$
</dev/null | :
diff --git a/bin/sh/tests/parser/only-redir3.0 b/bin/sh/tests/parser/only-redir3.0
index 128a48391ded..549873d15b1a 100644
--- a/bin/sh/tests/parser/only-redir3.0
+++ b/bin/sh/tests/parser/only-redir3.0
@@ -1,2 +1 @@
-# $FreeBSD$
case x in x) </dev/null ;; esac
diff --git a/bin/sh/tests/parser/only-redir4.0 b/bin/sh/tests/parser/only-redir4.0
index d804e128debe..f85e9da727c5 100644
--- a/bin/sh/tests/parser/only-redir4.0
+++ b/bin/sh/tests/parser/only-redir4.0
@@ -1,2 +1 @@
-# $FreeBSD$
case x in x) </dev/null ;& esac
diff --git a/bin/sh/tests/parser/pipe-not1.0 b/bin/sh/tests/parser/pipe-not1.0
index 9842ff0afd05..12ad17288182 100644
--- a/bin/sh/tests/parser/pipe-not1.0
+++ b/bin/sh/tests/parser/pipe-not1.0
@@ -1,3 +1,2 @@
-# $FreeBSD$
: | ! : | false
diff --git a/bin/sh/tests/parser/set-v1.0 b/bin/sh/tests/parser/set-v1.0
index 687cb8317557..65106bc70b93 100644
--- a/bin/sh/tests/parser/set-v1.0
+++ b/bin/sh/tests/parser/set-v1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
${SH} <<\EOF
echo one >&2
diff --git a/bin/sh/tests/parser/var-assign1.0 b/bin/sh/tests/parser/var-assign1.0
index 1fd3b26f8a26..55034f2ccc4d 100644
--- a/bin/sh/tests/parser/var-assign1.0
+++ b/bin/sh/tests/parser/var-assign1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
# 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.
diff --git a/bin/sh/tests/set-e/Makefile b/bin/sh/tests/set-e/Makefile
index 211fc95d326a..0d72e148da2c 100644
--- a/bin/sh/tests/set-e/Makefile
+++ b/bin/sh/tests/set-e/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE= tests
diff --git a/bin/sh/tests/set-e/Makefile.depend b/bin/sh/tests/set-e/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/bin/sh/tests/set-e/Makefile.depend
+++ b/bin/sh/tests/set-e/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/bin/sh/tests/set-e/and1.0 b/bin/sh/tests/set-e/and1.0
index 607b7c350020..c5b91a5fafb5 100644
--- a/bin/sh/tests/set-e/and1.0
+++ b/bin/sh/tests/set-e/and1.0
@@ -1,3 +1,2 @@
-# $FreeBSD$
set -e
true && true
diff --git a/bin/sh/tests/set-e/and2.1 b/bin/sh/tests/set-e/and2.1
index 78e203ab0059..c6994aaa1bc4 100644
--- a/bin/sh/tests/set-e/and2.1
+++ b/bin/sh/tests/set-e/and2.1
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -e
true && false
exit 0
diff --git a/bin/sh/tests/set-e/and3.0 b/bin/sh/tests/set-e/and3.0
index 9fafb1c45dd8..da983d7a24a2 100644
--- a/bin/sh/tests/set-e/and3.0
+++ b/bin/sh/tests/set-e/and3.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -e
false && true
exit 0
diff --git a/bin/sh/tests/set-e/and4.0 b/bin/sh/tests/set-e/and4.0
index 25d0e6147dea..1ca44a840dcb 100644
--- a/bin/sh/tests/set-e/and4.0
+++ b/bin/sh/tests/set-e/and4.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -e
false && false
exit 0
diff --git a/bin/sh/tests/set-e/background1.0 b/bin/sh/tests/set-e/background1.0
index 21577f4f78c7..288f9c4076fb 100644
--- a/bin/sh/tests/set-e/background1.0
+++ b/bin/sh/tests/set-e/background1.0
@@ -1,3 +1,2 @@
-# $FreeBSD$
set -e
false &
diff --git a/bin/sh/tests/set-e/cmd1.0 b/bin/sh/tests/set-e/cmd1.0
index 67fdcbc3d83e..5f06bd404ae8 100644
--- a/bin/sh/tests/set-e/cmd1.0
+++ b/bin/sh/tests/set-e/cmd1.0
@@ -1,3 +1,2 @@
-# $FreeBSD$
set -e
true
diff --git a/bin/sh/tests/set-e/cmd2.1 b/bin/sh/tests/set-e/cmd2.1
index 7cd8b09d64a8..1f677ce66b4f 100644
--- a/bin/sh/tests/set-e/cmd2.1
+++ b/bin/sh/tests/set-e/cmd2.1
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -e
false
exit 0
diff --git a/bin/sh/tests/set-e/elif1.0 b/bin/sh/tests/set-e/elif1.0
index 6a5937d496ae..5f438bab1c84 100644
--- a/bin/sh/tests/set-e/elif1.0
+++ b/bin/sh/tests/set-e/elif1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -e
if false; then
:
diff --git a/bin/sh/tests/set-e/elif2.0 b/bin/sh/tests/set-e/elif2.0
index 9dbb4bf514af..f691da558387 100644
--- a/bin/sh/tests/set-e/elif2.0
+++ b/bin/sh/tests/set-e/elif2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -e
if false; then
:
diff --git a/bin/sh/tests/set-e/eval1.0 b/bin/sh/tests/set-e/eval1.0
index 9b7f67b6b0d4..60bb4e237a82 100644
--- a/bin/sh/tests/set-e/eval1.0
+++ b/bin/sh/tests/set-e/eval1.0
@@ -1,3 +1,2 @@
-# $FreeBSD$
set -e
eval false || true
diff --git a/bin/sh/tests/set-e/eval2.1 b/bin/sh/tests/set-e/eval2.1
index 8bb7f3a92fcb..83171c5aedcd 100644
--- a/bin/sh/tests/set-e/eval2.1
+++ b/bin/sh/tests/set-e/eval2.1
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -e
eval false
exit 0
diff --git a/bin/sh/tests/set-e/for1.0 b/bin/sh/tests/set-e/for1.0
index 67eb718ee614..345bf14bda3c 100644
--- a/bin/sh/tests/set-e/for1.0
+++ b/bin/sh/tests/set-e/for1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -e
f() {
for i in a b c; do
diff --git a/bin/sh/tests/set-e/func1.0 b/bin/sh/tests/set-e/func1.0
index 3c6b70492fa2..a06e7978bc40 100644
--- a/bin/sh/tests/set-e/func1.0
+++ b/bin/sh/tests/set-e/func1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -e
f() {
false
diff --git a/bin/sh/tests/set-e/func2.1 b/bin/sh/tests/set-e/func2.1
index cc76d6edfa53..9fb0ee3919ea 100644
--- a/bin/sh/tests/set-e/func2.1
+++ b/bin/sh/tests/set-e/func2.1
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -e
f() {
false
diff --git a/bin/sh/tests/set-e/if1.0 b/bin/sh/tests/set-e/if1.0
index 36aa4bdcbcd3..a4bd95763b25 100644
--- a/bin/sh/tests/set-e/if1.0
+++ b/bin/sh/tests/set-e/if1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -e
if false; then
:
diff --git a/bin/sh/tests/set-e/if2.0 b/bin/sh/tests/set-e/if2.0
index 495540854099..2323448ef752 100644
--- a/bin/sh/tests/set-e/if2.0
+++ b/bin/sh/tests/set-e/if2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -e
# PR 28852
if true; then
diff --git a/bin/sh/tests/set-e/if3.0 b/bin/sh/tests/set-e/if3.0
index a4916a842664..3dd39380a747 100644
--- a/bin/sh/tests/set-e/if3.0
+++ b/bin/sh/tests/set-e/if3.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -e
if false; false; then
:
diff --git a/bin/sh/tests/set-e/not1.0 b/bin/sh/tests/set-e/not1.0
index 21c089a23221..eba0792db738 100644
--- a/bin/sh/tests/set-e/not1.0
+++ b/bin/sh/tests/set-e/not1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -e
! true
exit 0
diff --git a/bin/sh/tests/set-e/not2.0 b/bin/sh/tests/set-e/not2.0
index 7d93b4d09e85..40a551c664a6 100644
--- a/bin/sh/tests/set-e/not2.0
+++ b/bin/sh/tests/set-e/not2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -e
! false
! eval false
diff --git a/bin/sh/tests/set-e/or1.0 b/bin/sh/tests/set-e/or1.0
index c2dcbe9b682a..b556313d4b29 100644
--- a/bin/sh/tests/set-e/or1.0
+++ b/bin/sh/tests/set-e/or1.0
@@ -1,3 +1,2 @@
-# $FreeBSD$
set -e
true || false
diff --git a/bin/sh/tests/set-e/or2.0 b/bin/sh/tests/set-e/or2.0
index 934e2a68de9e..3606cc173c37 100644
--- a/bin/sh/tests/set-e/or2.0
+++ b/bin/sh/tests/set-e/or2.0
@@ -1,3 +1,2 @@
-# $FreeBSD$
set -e
false || true
diff --git a/bin/sh/tests/set-e/or3.1 b/bin/sh/tests/set-e/or3.1
index 7a617a14b4a4..ae6c5cdd64da 100644
--- a/bin/sh/tests/set-e/or3.1
+++ b/bin/sh/tests/set-e/or3.1
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -e
false || false
exit 0
diff --git a/bin/sh/tests/set-e/pipe1.1 b/bin/sh/tests/set-e/pipe1.1
index c0bad0fa732d..ce3f84861e70 100644
--- a/bin/sh/tests/set-e/pipe1.1
+++ b/bin/sh/tests/set-e/pipe1.1
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -e
true | false
exit 0
diff --git a/bin/sh/tests/set-e/pipe2.0 b/bin/sh/tests/set-e/pipe2.0
index 1e25566a156b..987d0f1a3ce9 100644
--- a/bin/sh/tests/set-e/pipe2.0
+++ b/bin/sh/tests/set-e/pipe2.0
@@ -1,3 +1,2 @@
-# $FreeBSD$
set -e
false | true
diff --git a/bin/sh/tests/set-e/return1.0 b/bin/sh/tests/set-e/return1.0
index 961bd4120865..66a58cba78b3 100644
--- a/bin/sh/tests/set-e/return1.0
+++ b/bin/sh/tests/set-e/return1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -e
# PR 77067, 85267
diff --git a/bin/sh/tests/set-e/semi1.1 b/bin/sh/tests/set-e/semi1.1
index 90476a98f1ec..74a6a0d725f4 100644
--- a/bin/sh/tests/set-e/semi1.1
+++ b/bin/sh/tests/set-e/semi1.1
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -e
false; true
exit 0
diff --git a/bin/sh/tests/set-e/semi2.1 b/bin/sh/tests/set-e/semi2.1
index 8f510ac9c164..3a37f73fbf23 100644
--- a/bin/sh/tests/set-e/semi2.1
+++ b/bin/sh/tests/set-e/semi2.1
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -e
true; false
exit 0
diff --git a/bin/sh/tests/set-e/subshell1.0 b/bin/sh/tests/set-e/subshell1.0
index 8e5831bd1907..10561215e644 100644
--- a/bin/sh/tests/set-e/subshell1.0
+++ b/bin/sh/tests/set-e/subshell1.0
@@ -1,3 +1,2 @@
-# $FreeBSD$
set -e
(true)
diff --git a/bin/sh/tests/set-e/subshell2.1 b/bin/sh/tests/set-e/subshell2.1
index 619e98a7d2df..e5d2976d3566 100644
--- a/bin/sh/tests/set-e/subshell2.1
+++ b/bin/sh/tests/set-e/subshell2.1
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -e
(false)
exit 0
diff --git a/bin/sh/tests/set-e/until1.0 b/bin/sh/tests/set-e/until1.0
index 71ea7f2cf704..6a6c10dbfcf1 100644
--- a/bin/sh/tests/set-e/until1.0
+++ b/bin/sh/tests/set-e/until1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -e
until false; do
break
diff --git a/bin/sh/tests/set-e/until2.0 b/bin/sh/tests/set-e/until2.0
index 24ea2760400b..628ebb27b1bc 100644
--- a/bin/sh/tests/set-e/until2.0
+++ b/bin/sh/tests/set-e/until2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -e
until false; false; do
break
diff --git a/bin/sh/tests/set-e/until3.0 b/bin/sh/tests/set-e/until3.0
index 597db593bdaf..54f233537d80 100644
--- a/bin/sh/tests/set-e/until3.0
+++ b/bin/sh/tests/set-e/until3.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -e
f() {
until false; do
diff --git a/bin/sh/tests/set-e/while1.0 b/bin/sh/tests/set-e/while1.0
index 371c94a0440d..367609b6929f 100644
--- a/bin/sh/tests/set-e/while1.0
+++ b/bin/sh/tests/set-e/while1.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -e
while false; do
:
diff --git a/bin/sh/tests/set-e/while2.0 b/bin/sh/tests/set-e/while2.0
index 124966ca59e9..7ec5dff28391 100644
--- a/bin/sh/tests/set-e/while2.0
+++ b/bin/sh/tests/set-e/while2.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -e
while false; false; do
:
diff --git a/bin/sh/tests/set-e/while3.0 b/bin/sh/tests/set-e/while3.0
index dd3c79025236..b0cf7ab17117 100644
--- a/bin/sh/tests/set-e/while3.0
+++ b/bin/sh/tests/set-e/while3.0
@@ -1,4 +1,3 @@
-# $FreeBSD$
set -e
f() {
while true; do
diff --git a/bin/sh/trap.c b/bin/sh/trap.c
index 7a6ed2f4368a..2863026a4794 100644
--- a/bin/sh/trap.c
+++ b/bin/sh/trap.c
@@ -32,14 +32,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)trap.c 8.5 (Berkeley) 6/5/95";
-#endif
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <signal.h>
#include <unistd.h>
#include <stdlib.h>
diff --git a/bin/sh/trap.h b/bin/sh/trap.h
index fdc4b7a9683a..c7da30326911 100644
--- a/bin/sh/trap.h
+++ b/bin/sh/trap.h
@@ -30,9 +30,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * @(#)trap.h 8.3 (Berkeley) 6/5/95
- * $FreeBSD$
*/
extern volatile sig_atomic_t pendingsig;
diff --git a/bin/sh/var.c b/bin/sh/var.c
index 0758289151ba..2f9820a91bdd 100644
--- a/bin/sh/var.c
+++ b/bin/sh/var.c
@@ -32,14 +32,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 5/4/95";
-#endif
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <unistd.h>
#include <stdlib.h>
#include <paths.h>
diff --git a/bin/sh/var.h b/bin/sh/var.h
index eaf4f427f63b..800f7bcc0390 100644
--- a/bin/sh/var.h
+++ b/bin/sh/var.h
@@ -30,9 +30,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * @(#)var.h 8.2 (Berkeley) 5/4/95
- * $FreeBSD$
*/
/*
diff --git a/bin/sleep/Makefile b/bin/sleep/Makefile
index 8521a918f9c5..8cece2dbc312 100644
--- a/bin/sleep/Makefile
+++ b/bin/sleep/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.1 (Berkeley) 5/31/93
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/bin/sleep/Makefile.depend b/bin/sleep/Makefile.depend
index 1adfc08a54d6..38d979787478 100644
--- a/bin/sleep/Makefile.depend
+++ b/bin/sleep/Makefile.depend
@@ -1,13 +1,12 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
lib/libcapsicum \
+ lib/libcasper/libcasper \
lib/libcompiler_rt \
diff --git a/bin/sleep/sleep.1 b/bin/sleep/sleep.1
index 73fa4854d1a6..c9069a015706 100644
--- a/bin/sleep/sleep.1
+++ b/bin/sleep/sleep.1
@@ -29,10 +29,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)sleep.1 8.3 (Berkeley) 4/18/94
-.\" $FreeBSD$
-.\"
-.Dd May 25, 2022
+.Dd March 22, 2024
.Dt SLEEP 1
.Os
.Sh NAME
@@ -41,21 +38,26 @@
.Sh SYNOPSIS
.Nm
.Ar number Ns Op Ar unit
-.Ar ...
+.Op ...
.Sh DESCRIPTION
The
.Nm
command suspends execution for a minimum of
.Ar number
seconds (the default, or unit
-.Cm s ) ,
+.Li s ) ,
minutes (unit
-.Cm m ) ,
+.Li m ) ,
hours (unit
-.Cm h ) ,
+.Li h ) ,
or days (unit
-.Cm d ) .
-If multiple arguments are passed, the delay will be the sum of all values.
+.Li d ) .
+Intervals can be written in any form allowed by
+.Xr strtod 3 .
+If multiple intervals are given, they are added together.
+If the final sum is zero or negative,
+.Nm
+exits immediately.
.Pp
If the
.Nm
@@ -68,57 +70,49 @@ sleep is printed on the standard output.
The
.Dv SIGALRM
signal is not handled specially by this implementation.
-.Pp
-The
-.Nm
-command supports other time units than seconds,
-honors a non-integer number of time units to sleep in any form acceptable by
-.Xr strtod 3 ,
-and accepts more than one delay value.
-These are non-portable extensions, but they have also been implemented
-in GNU sh-utils since version 2.0a (released in 2002).
.Sh EXIT STATUS
.Ex -std
.Sh EXAMPLES
-To schedule the execution of a command for
-.Va x
-number seconds later (with
-.Xr csh 1 ) :
+To run a command after half an hour:
.Pp
-.Dl (sleep 1800; sh command_file >& errors)&
+.Dl (sleep 0.5h; sh command_file >out 2>err)&
.Pp
-This incantation would wait a half hour before
-running the script command_file.
-(See the
+This incantation would wait half an hour before
+running the script
+.Pa command_file .
+See the
.Xr at 1
-utility.)
+utility for another way to do this.
.Pp
-To reiteratively run a command (with the
-.Xr csh 1 ) :
+To reiteratively run a command:
.Pp
.Bd -literal -offset indent -compact
-while (1)
- if (! -r zzz.rawdata) then
- sleep 300
+while :; do
+ if ! [ -r zzz.rawdata ] ; then
+ sleep 5m
else
- foreach i (`ls *.rawdata`)
+ for i in *.rawdata ; do
sleep 70
- awk -f collapse_data $i >> results
- end
+ awk -f collapse_data "$i"
+ done >results
break
- endif
-end
+ fi
+done
.Ed
.Pp
The scenario for a script such as this might be: a program currently
running is taking longer than expected to process a series of
files, and it would be nice to have
another program start processing the files created by the first
-program as soon as it is finished (when zzz.rawdata is created).
-The script checks every five minutes for the file zzz.rawdata,
+program as soon as it is finished (when
+.Pa zzz.rawdata
+is created).
+The script checks every five minutes for the file
+.Pa zzz.rawdata ,
when the file is found, then another portion processing
is done courteously by sleeping for 70 seconds in between each
-awk job.
+.Xr awk 1
+job.
.Sh SEE ALSO
.Xr nanosleep 2 ,
.Xr sleep 3
@@ -128,6 +122,10 @@ The
command is expected to be
.St -p1003.2
compatible.
+.Pp
+Support for non-integer intervals, units other than seconds, and
+multiple intervals which are added together are non-portable
+extensions first introduced in GNU sh-utils 2.0a (released in 2002).
.Sh HISTORY
A
.Nm
diff --git a/bin/sleep/sleep.c b/bin/sleep/sleep.c
index 55e0aba9871a..34d335cf4736 100644
--- a/bin/sleep/sleep.c
+++ b/bin/sleep/sleep.c
@@ -27,111 +27,104 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static char const copyright[] =
-"@(#) Copyright (c) 1988, 1993, 1994\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "@(#)sleep.c 8.3 (Berkeley) 4/2/94";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <capsicum_helpers.h>
#include <err.h>
#include <errno.h>
#include <limits.h>
+#include <math.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
-
-static void usage(void);
+#include <unistd.h>
static volatile sig_atomic_t report_requested;
+
static void
report_request(int signo __unused)
{
-
report_requested = 1;
}
+static void __dead2
+usage(void)
+{
+ fprintf(stderr, "usage: sleep number[unit] [...]\n"
+ "Unit can be 's' (seconds, the default), "
+ "m (minutes), h (hours), or d (days).\n");
+ exit(1);
+}
+
+static double
+parse_interval(const char *arg)
+{
+ double num;
+ char unit, extra;
+
+ switch (sscanf(arg, "%lf%c%c", &num, &unit, &extra)) {
+ case 2:
+ switch (unit) {
+ case 'd':
+ num *= 24;
+ /* FALLTHROUGH */
+ case 'h':
+ num *= 60;
+ /* FALLTHROUGH */
+ case 'm':
+ num *= 60;
+ /* FALLTHROUGH */
+ case 's':
+ if (!isnan(num))
+ return (num);
+ }
+ break;
+ case 1:
+ if (!isnan(num))
+ return (num);
+ }
+ warnx("invalid time interval: %s", arg);
+ return (INFINITY);
+}
+
int
main(int argc, char *argv[])
{
struct timespec time_to_sleep;
- double d, seconds;
+ double seconds;
time_t original;
- char unit;
- char buf[2];
- int i, matches;
if (caph_limit_stdio() < 0 || caph_enter() < 0)
err(1, "capsicum");
- if (argc < 2)
+ while (getopt(argc, argv, "") != -1)
+ usage();
+ argc -= optind;
+ argv += optind;
+ if (argc < 1)
usage();
seconds = 0;
- for (i = 1; i < argc; i++) {
- matches = sscanf(argv[i], "%lf%c%1s", &d, &unit, buf);
- if (matches == 2)
- switch(unit) {
- case 'd':
- d *= 24;
- /* FALLTHROUGH */
- case 'h':
- d *= 60;
- /* FALLTHROUGH */
- case 'm':
- d *= 60;
- /* FALLTHROUGH */
- case 's':
- break;
- default:
- usage();
- }
- else
- if (matches != 1)
- usage();
- seconds += d;
- }
+ while (argc--)
+ seconds += parse_interval(*argv++);
if (seconds > INT_MAX)
usage();
- if (seconds <= 0)
- return (0);
+ if (seconds < 1e-9)
+ exit(0);
original = time_to_sleep.tv_sec = (time_t)seconds;
time_to_sleep.tv_nsec = 1e9 * (seconds - time_to_sleep.tv_sec);
signal(SIGINFO, report_request);
- /*
- * Note: [EINTR] is supposed to happen only when a signal was handled
- * but the kernel also returns it when a ptrace-based debugger
- * attaches. This is a bug but it is hard to fix.
- */
while (nanosleep(&time_to_sleep, &time_to_sleep) != 0) {
+ if (errno != EINTR)
+ err(1, "nanosleep");
if (report_requested) {
/* Reporting does not bother with nanoseconds. */
- warnx("about %d second(s) left out of the original %d",
- (int)time_to_sleep.tv_sec, (int)original);
+ warnx("about %ld second(s) left out of the original %ld",
+ (long)time_to_sleep.tv_sec, (long)original);
report_requested = 0;
- } else if (errno != EINTR)
- err(1, "nanosleep");
+ }
}
- return (0);
-}
-
-static void
-usage(void)
-{
- fprintf(stderr, "usage: sleep number[unit] ...\n");
- fprintf(stderr, "Unit can be 's' (seconds, the default), "
- "m (minutes), h (hours), or d (days).\n");
- exit(1);
+ exit(0);
}
diff --git a/bin/sleep/tests/Makefile b/bin/sleep/tests/Makefile
index 6fc95f39ccb1..0f15dd5a4b9d 100644
--- a/bin/sleep/tests/Makefile
+++ b/bin/sleep/tests/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <bsd.own.mk>
diff --git a/bin/sleep/tests/Makefile.depend b/bin/sleep/tests/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/bin/sleep/tests/Makefile.depend
+++ b/bin/sleep/tests/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/bin/stty/Makefile b/bin/stty/Makefile
index b10b8951b487..d0fb28137ce4 100644
--- a/bin/stty/Makefile
+++ b/bin/stty/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.1 (Berkeley) 5/31/93
-# $FreeBSD$
PACKAGE=runtime
PROG= stty
diff --git a/bin/stty/Makefile.depend b/bin/stty/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/bin/stty/Makefile.depend
+++ b/bin/stty/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/bin/stty/cchar.c b/bin/stty/cchar.c
index ecefbb2bc8f3..4a65d1b518d5 100644
--- a/bin/stty/cchar.c
+++ b/bin/stty/cchar.c
@@ -27,14 +27,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)cchar.c 8.5 (Berkeley) 4/2/94";
-#endif
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <err.h>
diff --git a/bin/stty/extern.h b/bin/stty/extern.h
index 88b58890f7d1..b6029396445f 100644
--- a/bin/stty/extern.h
+++ b/bin/stty/extern.h
@@ -25,9 +25,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * @(#)extern.h 8.1 (Berkeley) 5/31/93
- * $FreeBSD$
*/
int c_cchars(const void *, const void *);
diff --git a/bin/stty/gfmt.c b/bin/stty/gfmt.c
index 12ed2a2d3500..fbd21382dd82 100644
--- a/bin/stty/gfmt.c
+++ b/bin/stty/gfmt.c
@@ -27,14 +27,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)gfmt.c 8.6 (Berkeley) 4/2/94";
-#endif
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <err.h>
diff --git a/bin/stty/key.c b/bin/stty/key.c
index 4514a0ea1c04..6e8f635ac237 100644
--- a/bin/stty/key.c
+++ b/bin/stty/key.c
@@ -27,14 +27,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)key.c 8.3 (Berkeley) 4/2/94";
-#endif
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <err.h>
diff --git a/bin/stty/modes.c b/bin/stty/modes.c
index 5cd3061aa449..d63b958680de 100644
--- a/bin/stty/modes.c
+++ b/bin/stty/modes.c
@@ -27,14 +27,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)modes.c 8.3 (Berkeley) 4/2/94";
-#endif
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <string.h>
#include "stty.h"
@@ -128,6 +120,8 @@ static const struct modes imodes[] = {
{ "-decctlq", IXANY, 0 },
{ "imaxbel", IMAXBEL, 0 },
{ "-imaxbel", 0, IMAXBEL },
+ { "iutf8", IUTF8, 0 },
+ { "-iutf8", 0, IUTF8 },
{ NULL, 0, 0 },
};
diff --git a/bin/stty/print.c b/bin/stty/print.c
index a76cd46b765e..d7ab2abbcf14 100644
--- a/bin/stty/print.c
+++ b/bin/stty/print.c
@@ -27,14 +27,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94";
-#endif
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <stddef.h>
@@ -129,6 +121,7 @@ print(struct termios *tp, struct winsize *wp, int ldisc, enum FMT fmt)
put("-inpck", INPCK, 0);
put("-ignpar", IGNPAR, 0);
put("-parmrk", PARMRK, 0);
+ put("-iutf8", IUTF8, 1);
/* output flags */
tmp = tp->c_oflag;
diff --git a/bin/stty/stty.1 b/bin/stty/stty.1
index 67a32c089150..4f0126dde275 100644
--- a/bin/stty/stty.1
+++ b/bin/stty/stty.1
@@ -29,10 +29,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)stty.1 8.4 (Berkeley) 4/18/94
-.\" $FreeBSD$
-.\"
-.Dd May 24, 2022
+.Dd September 27, 2022
.Dt STTY 1
.Os
.Sh NAME
@@ -225,6 +222,9 @@ if
.Cm imaxbel
is unset and the input queue is full, the next input character causes
the entire input and output queues to be discarded.
+.It Cm iutf8 Pq Fl iutf8
+Assume that input characters are UTF-8 encoded. Setting this flag
+causes backspace to properly delete multibyte characters in canonical mode.
.El
.Ss Output Modes:
This corresponds to the c_oflag of the termios structure.
@@ -594,6 +594,32 @@ Same as the control character
Same as the control character
.Cm reprint .
.El
+.Sh INTERACTION WITH JOB CONTROL
+Modifications to the terminal settings are treated by job control
+(see
+.Xr termios 4 )
+same as writes.
+When the
+.Nm
+utility is executing in a background process group,
+such attempts result in the kernel sending the
+.Dv SIGTTOU
+signal and stopping the process until its group is returned
+to foreground.
+The non-blocking open of the terminal device with the
+.Fl f
+option to
+.Nm
+does not affect the behavior.
+If it is desirable to modify the settings from the background,
+.Xr sh 1
+users might utilize the following idiom:
+.Bd -literal
+(trap '' TTOU; stty -f /dev/tty sane)
+.Ed
+.Pp
+Note that changing terminal settings for a running foreground
+job that is not prepared for it might cause inconsistencies.
.Sh EXIT STATUS
.Ex -std
.Sh SEE ALSO
diff --git a/bin/stty/stty.c b/bin/stty/stty.c
index 9aa2f51aa81f..38834aaccea0 100644
--- a/bin/stty/stty.c
+++ b/bin/stty/stty.c
@@ -27,20 +27,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static char const copyright[] =
-"@(#) Copyright (c) 1989, 1991, 1993, 1994\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "@(#)stty.c 8.3 (Berkeley) 4/2/94";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <ctype.h>
diff --git a/bin/stty/stty.h b/bin/stty/stty.h
index d48ccaa20b6e..64ad2945cfa9 100644
--- a/bin/stty/stty.h
+++ b/bin/stty/stty.h
@@ -25,9 +25,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * @(#)stty.h 8.1 (Berkeley) 5/31/93
- * $FreeBSD$
*/
#include <sys/ioctl.h>
diff --git a/bin/stty/util.c b/bin/stty/util.c
index 19898ba9805f..4077ee354f8e 100644
--- a/bin/stty/util.c
+++ b/bin/stty/util.c
@@ -27,14 +27,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)util.c 8.3 (Berkeley) 4/2/94";
-#endif
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/stat.h>
diff --git a/bin/sync/Makefile b/bin/sync/Makefile
index 8b56d6af4b88..8da077108aec 100644
--- a/bin/sync/Makefile
+++ b/bin/sync/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.1 (Berkeley) 5/31/93
-# $FreeBSD$
PACKAGE=runtime
PROG= sync
diff --git a/bin/sync/Makefile.depend b/bin/sync/Makefile.depend
index cae7e645ef6a..93249906da4f 100644
--- a/bin/sync/Makefile.depend
+++ b/bin/sync/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
lib/${CSU_DIR} \
lib/libc \
diff --git a/bin/sync/sync.8 b/bin/sync/sync.8
index 7f331f1222e3..fcd07ca72240 100644
--- a/bin/sync/sync.8
+++ b/bin/sync/sync.8
@@ -26,10 +26,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)sync.8 8.1 (Berkeley) 5/31/93
-.\" $FreeBSD$
-.\"
-.Dd May 31, 1993
+.Dd April 25, 2024
.Dt SYNC 8
.Os
.Sh NAME
@@ -72,3 +69,31 @@ A
.Nm
utility appeared in
.At v4 .
+.Pp
+On systems older than
+.Bx 4.0 ,
+commands like
+.Xr reboot 8
+and
+.Xr halt 8
+were unavailable.
+The shutdown procedure involved running
+.Nm ,
+waiting for the lights to stop,
+and turning off the machine.
+.Pp
+Issuing three separate
+.Nm
+commands (one line each) was a placebo that would generally suffice in
+.At v7
+machines that were otherwise quiesced systems.
+It replaced the one-per-line
+.Nm
+as a substitute for waiting.
+.Pp
+.Bx 4.0
+introduced
+.Xr reboot 2
+and
+.Xr sync 2
+which rendered this trick obsolete.
diff --git a/bin/sync/sync.c b/bin/sync/sync.c
index 6855193a0476..7560e794d35f 100644
--- a/bin/sync/sync.c
+++ b/bin/sync/sync.c
@@ -27,20 +27,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static char const copyright[] =
-"@(#) Copyright (c) 1987, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "@(#)sync.c 8.1 (Berkeley) 5/31/93";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <stdlib.h>
#include <unistd.h>
diff --git a/bin/test/Makefile b/bin/test/Makefile
index 59ea2be99539..4cdebcb5054c 100644
--- a/bin/test/Makefile
+++ b/bin/test/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.1 (Berkeley) 5/31/93
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/bin/test/Makefile.depend b/bin/test/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/bin/test/Makefile.depend
+++ b/bin/test/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/bin/test/test.1 b/bin/test/test.1
index eaa5f2b2cce7..04a39a3c7eaa 100644
--- a/bin/test/test.1
+++ b/bin/test/test.1
@@ -29,9 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)test.1 8.1 (Berkeley) 5/31/93
-.\" $FreeBSD$
-.\"
.Dd October 5, 2016
.Dt TEST 1
.Os
diff --git a/bin/test/test.c b/bin/test/test.c
index 1570238300e9..af2783f0aee9 100644
--- a/bin/test/test.c
+++ b/bin/test/test.c
@@ -14,9 +14,6 @@
* as a builtin for /bin/sh (#define SHELL).
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/stat.h>
diff --git a/bin/test/tests/Makefile b/bin/test/tests/Makefile
index a1a5d4f02fa7..232ae04c0cb5 100644
--- a/bin/test/tests/Makefile
+++ b/bin/test/tests/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <bsd.own.mk>
diff --git a/bin/test/tests/Makefile.depend b/bin/test/tests/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/bin/test/tests/Makefile.depend
+++ b/bin/test/tests/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/bin/test/tests/legacy_test.sh b/bin/test/tests/legacy_test.sh
index 8dae88f0d7af..44594da9d886 100644
--- a/bin/test/tests/legacy_test.sh
+++ b/bin/test/tests/legacy_test.sh
@@ -28,7 +28,6 @@
#
# TEST.sh - check if test(1) or builtin test works
#
-# $FreeBSD$
# force a specified test program, e.g. `env test=/bin/test sh regress.sh'
: ${test=test}
diff --git a/bin/tests/Makefile b/bin/tests/Makefile
index 3b3078f8612a..b8996030aafc 100644
--- a/bin/tests/Makefile
+++ b/bin/tests/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.PATH: ${SRCTOP}/tests
KYUAFILE= yes
diff --git a/bin/tests/Makefile.depend b/bin/tests/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/bin/tests/Makefile.depend
+++ b/bin/tests/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/bin/timeout/Makefile b/bin/timeout/Makefile
new file mode 100644
index 000000000000..fa6741afb1dc
--- /dev/null
+++ b/bin/timeout/Makefile
@@ -0,0 +1,11 @@
+
+.include <src.opts.mk>
+
+PROG= timeout
+
+SYMLINKS= ../..${BINDIR}/timeout /usr/bin/timeout
+
+HAS_TESTS=
+SUBDIR.${MK_TESTS}+= tests
+
+.include <bsd.prog.mk>
diff --git a/bin/timeout/Makefile.depend b/bin/timeout/Makefile.depend
new file mode 100644
index 000000000000..84b8ddd67e34
--- /dev/null
+++ b/bin/timeout/Makefile.depend
@@ -0,0 +1,16 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ gnu/lib/csu \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libcompiler_rt \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/bin/timeout/tests/Makefile b/bin/timeout/tests/Makefile
new file mode 100644
index 000000000000..7a2fd60db436
--- /dev/null
+++ b/bin/timeout/tests/Makefile
@@ -0,0 +1,4 @@
+
+ATF_TESTS_SH= timeout_test
+
+.include <bsd.test.mk>
diff --git a/bin/timeout/tests/Makefile.depend b/bin/timeout/tests/Makefile.depend
new file mode 100644
index 000000000000..11aba52f82cf
--- /dev/null
+++ b/bin/timeout/tests/Makefile.depend
@@ -0,0 +1,10 @@
+# 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/bin/timeout/tests/timeout_test.sh b/bin/timeout/tests/timeout_test.sh
new file mode 100644
index 000000000000..2a8e0112b97c
--- /dev/null
+++ b/bin/timeout/tests/timeout_test.sh
@@ -0,0 +1,214 @@
+
+atf_test_case nominal
+nominal_head()
+{
+ atf_set "descr" "Basic tests on timeout(1) utility"
+}
+
+nominal_body()
+{
+ atf_check \
+ -o empty \
+ -e empty \
+ -s exit:0 \
+ timeout 5 true
+}
+
+atf_test_case time_unit
+time_unit_head()
+{
+ atf_set "descr" "Test parsing the default time unit"
+}
+
+time_unit_body()
+{
+ atf_check \
+ -o empty \
+ -e empty \
+ -s exit:0 \
+ timeout 1d true
+
+ atf_check \
+ -o empty \
+ -e empty \
+ -s exit:0 \
+ timeout 1h true
+
+ atf_check \
+ -o empty \
+ -e empty \
+ -s exit:0 \
+ timeout 1m true
+
+ atf_check \
+ -o empty \
+ -e empty \
+ -s exit:0 \
+ timeout 1s true
+}
+
+atf_test_case no_timeout
+no_timeout_head()
+{
+ atf_set "descr" "Test disabled timeout"
+}
+
+no_timeout_body()
+{
+ atf_check \
+ -o empty \
+ -e empty \
+ -s exit:0 \
+ timeout 0 true
+}
+
+atf_test_case exit_numbers
+exit_numbers_head()
+{
+ atf_set "descr" "Test exit numbers"
+}
+
+exit_numbers_body()
+{
+ atf_check \
+ -o empty \
+ -e empty \
+ -s exit:2 \
+ -x timeout 5 sh -c \'exit 2\'
+
+ atf_check \
+ -o empty \
+ -e empty \
+ -s exit:124 \
+ timeout .1 sleep 1
+
+ # With preserve status exit should be 128 + TERM aka 143
+ atf_check \
+ -o empty \
+ -e empty \
+ -s exit:143 \
+ timeout --preserve-status .1 sleep 10
+
+ atf_check \
+ -o empty \
+ -e empty \
+ -s exit:124 \
+ timeout -s1 -k1 .1 sleep 10
+
+ atf_check \
+ -o empty \
+ -e empty \
+ -s exit:0 \
+ -x sh -c 'trap "" CHLD; exec timeout 10 true'
+}
+
+atf_test_case with_a_child
+with_a_child_head()
+{
+ atf_set "descr" "When starting with a child (coreutils bug#9098)"
+}
+
+with_a_child_body()
+{
+ out=$(sleep .1 & exec timeout .5 sh -c 'sleep 2; echo foo')
+ status=$?
+ test "$out" = "" && test $status = 124 || atf_fail
+
+}
+
+atf_test_case invalid_timeout
+invalid_timeout_head()
+{
+ atf_set "descr" "Invalid timeout"
+}
+
+invalid_timeout_body()
+{
+ atf_check \
+ -o empty \
+ -e inline:"timeout: invalid duration\n" \
+ -s exit:125 \
+ timeout invalid sleep 0
+
+ atf_check \
+ -o empty \
+ -e inline:"timeout: invalid duration\n" \
+ -s exit:125 \
+ timeout --kill-after=invalid 1 sleep 0
+
+ atf_check \
+ -o empty \
+ -e inline:"timeout: invalid duration\n" \
+ -s exit:125 \
+ timeout 42D sleep 0
+
+ atf_check \
+ -o empty \
+ -e inline:"timeout: invalid duration\n" \
+ -s exit:125 \
+ timeout 999999999999999999999999999999999999999999999999999999999999d sleep 0
+
+ atf_check \
+ -o empty \
+ -e inline:"timeout: invalid duration\n" \
+ -s exit:125 \
+ timeout 2.34e+5d sleep 0
+}
+
+atf_test_case invalid_signal
+invalid_signal_head()
+{
+ atf_set "descr" "Invalid signal"
+}
+
+invalid_signal_body()
+{
+ atf_check \
+ -o empty \
+ -e inline:"timeout: invalid signal\n" \
+ -s exit:125 \
+ timeout --signal=invalid 1 sleep 0
+}
+
+atf_test_case invalid_command
+invalid_command_head()
+{
+ atf_set "descr" "Invalid command"
+}
+
+invalid_command_body()
+{
+ atf_check \
+ -o empty \
+ -e inline:"timeout: exec(.): Permission denied\n" \
+ -s exit:126 \
+ timeout 10 .
+}
+
+atf_test_case no_such_command
+no_such_command_head()
+{
+ atf_set "descr" "No such command"
+}
+
+no_such_command_body()
+{
+ atf_check \
+ -o empty \
+ -e inline:"timeout: exec(enoexists): No such file or directory\n" \
+ -s exit:127 \
+ timeout 10 enoexists
+}
+
+atf_init_test_cases()
+{
+ atf_add_test_case nominal
+ atf_add_test_case time_unit
+ atf_add_test_case no_timeout
+ atf_add_test_case exit_numbers
+ atf_add_test_case with_a_child
+ atf_add_test_case invalid_timeout
+ atf_add_test_case invalid_signal
+ atf_add_test_case invalid_command
+ atf_add_test_case no_such_command
+}
diff --git a/bin/timeout/timeout.1 b/bin/timeout/timeout.1
new file mode 100644
index 000000000000..9e624e809376
--- /dev/null
+++ b/bin/timeout/timeout.1
@@ -0,0 +1,206 @@
+.\" SPDX-License-Identifier: BSD-2-Clause
+.\"
+.\" Copyright (c) 2014 Baptiste Daroussin <bapt@FreeBSD.org>
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.Dd June 26, 2023
+.Dt TIMEOUT 1
+.Os
+.Sh NAME
+.Nm timeout
+.Nd run a command with a time limit
+.Sh SYNOPSIS
+.Nm
+.Op Fl -signal Ar sig | Fl s Ar sig
+.Op Fl -preserve-status
+.Op Fl -kill-after Ar time | Fl k Ar time
+.Op Fl -foreground
+.Ar duration
+.Ar command
+.Op Ar args ...
+.Sh DESCRIPTION
+.Nm
+starts the
+.Ar command
+with its
+.Ar args .
+If the
+.Ar command
+is still running after
+.Ar duration ,
+it is killed.
+By default,
+.Dv SIGTERM
+is sent.
+The special
+.Ar duration ,
+zero, signifies no limit.
+Therefore a signal is never sent if
+.Ar duration
+is 0.
+.Pp
+The options are as follows:
+.Bl -tag -width indent
+.It Fl -preserve-status
+Exit with the same status as
+.Ar command ,
+even if it times out and is killed.
+.It Fl -foreground
+Do not propagate timeout to the children of
+.Ar command .
+.It Fl s Ar sig , Fl -signal Ar sig
+Specify the signal to send on timeout.
+By default,
+.Dv SIGTERM
+is sent.
+.It Fl k Ar time , Fl -kill-after Ar time
+Send a
+.Dv SIGKILL
+signal if
+.Ar command
+is still running after
+.Ar time
+after the first signal was sent.
+.El
+.Sh DURATION FORMAT
+.Ar duration
+and
+.Ar time
+are non-negative integer or real (decimal) numbers, with an optional
+unit-specifying suffix.
+Values without an explicit unit are interpreted as seconds.
+.Pp
+Supported unit symbols are:
+.Bl -tag -width indent -compact
+.It Cm s
+seconds
+.It Cm m
+minutes
+.It Cm h
+hours
+.It Cm d
+days
+.El
+.Sh EXIT STATUS
+If the timeout was not reached, the exit status of
+.Ar command
+is returned.
+.Pp
+If the timeout was reached and
+.Fl -preserve-status
+is set, the exit status of
+.Ar command
+is returned.
+If
+.Fl -preserve-status
+is not set, an exit status of 124 is returned.
+.Pp
+If
+.Ar command
+exits after receiving a signal, the exit status returned is the signal number
+plus 128.
+.Pp
+If
+.Ar command
+refers to a non-existing program, the exit status returned is 127.
+.Pp
+If
+.Ar command
+is an otherwise invalid program, the exit status returned is 126.
+.Pp
+If an invalid parameter is passed to
+.Fl s
+or
+.Fl k ,
+the exit status returned is 125.
+.Sh EXAMPLES
+Run
+.Xr sleep 1
+with a time limit of 4 seconds.
+Since the command completes in 2 seconds, the exit status is 0:
+.Bd -literal -offset indent
+$ timeout 4 sleep 2
+$ echo $?
+0
+.Ed
+.Pp
+Run
+.Xr sleep 1
+for 4 seconds and terminate process after 2 seconds.
+124 is returned since no
+.Fl -preserve-status
+is used:
+.Bd -literal -offset indent
+$ timeout 2 sleep 4
+$ echo $?
+124
+.Ed
+.Pp
+Same as above but preserving status.
+Exit status is 128 + signal number (15 for
+.Va SIGTERM ) :
+.Bd -literal -offset indent
+$ timeout --preserve-status 2 sleep 4
+$ echo $?
+143
+.Ed
+.Pp
+Same as above but sending
+.Va SIGALRM
+(signal number 14) instead of
+.Va SIGTERM :
+.Bd -literal -offset indent
+$ timeout --preserve-status -s SIGALRM 2 sleep 4
+$ echo $?
+142
+.Ed
+.Pp
+Try to
+.Xr fetch 1
+the PDF version of the
+.Fx
+Handbook.
+Send a
+.Va SIGTERM
+signal after 1 minute and send a
+.Va SIGKILL
+signal 5 seconds later if the process refuses to stop:
+.Bd -literal -offset indent
+$ timeout -k 5s 1m fetch \\
+> https://download.freebsd.org/ftp/doc/en/books/handbook/book.pdf
+.Ed
+.Sh SEE ALSO
+.Xr kill 1 ,
+.Xr nohup 1 ,
+.Xr signal 3 ,
+.Xr daemon 8
+.Sh HISTORY
+The
+.Nm
+command first appeared in
+.Fx 10.3 .
+.Sh AUTHORS
+.An Baptiste Daroussin Aq Mt bapt@FreeBSD.org
+and
+.An Vsevolod Stakhov Aq Mt vsevolod@FreeBSD.org
diff --git a/bin/timeout/timeout.c b/bin/timeout/timeout.c
new file mode 100644
index 000000000000..b1c3262bf711
--- /dev/null
+++ b/bin/timeout/timeout.c
@@ -0,0 +1,358 @@
+/*-
+ * Copyright (c) 2014 Baptiste Daroussin <bapt@FreeBSD.org>
+ * Copyright (c) 2014 Vsevolod Stakhov <vsevolod@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in this position and unchanged.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#include <sys/procctl.h>
+#include <sys/time.h>
+#include <sys/wait.h>
+
+#include <err.h>
+#include <errno.h>
+#include <getopt.h>
+#include <signal.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#define EXIT_TIMEOUT 124
+
+static sig_atomic_t sig_chld = 0;
+static sig_atomic_t sig_term = 0;
+static sig_atomic_t sig_alrm = 0;
+static sig_atomic_t sig_ign = 0;
+
+static void
+usage(void)
+{
+
+ fprintf(stderr, "Usage: %s [--signal sig | -s sig] [--preserve-status]"
+ " [--kill-after time | -k time] [--foreground] <duration> <command>"
+ " <arg ...>\n", getprogname());
+
+ exit(EXIT_FAILURE);
+}
+
+static double
+parse_duration(const char *duration)
+{
+ double ret;
+ char *end;
+
+ ret = strtod(duration, &end);
+ if (ret == 0 && end == duration)
+ errx(125, "invalid duration");
+
+ if (end == NULL || *end == '\0')
+ return (ret);
+
+ if (end != NULL && *(end + 1) != '\0')
+ errx(125, "invalid duration");
+
+ switch (*end) {
+ case 's':
+ break;
+ case 'm':
+ ret *= 60;
+ break;
+ case 'h':
+ ret *= 60 * 60;
+ break;
+ case 'd':
+ ret *= 60 * 60 * 24;
+ break;
+ default:
+ errx(125, "invalid duration");
+ }
+
+ if (ret < 0 || ret >= 100000000UL)
+ errx(125, "invalid duration");
+
+ return (ret);
+}
+
+static int
+parse_signal(const char *str)
+{
+ int sig, i;
+ const char *errstr;
+
+ sig = strtonum(str, 1, sys_nsig - 1, &errstr);
+
+ if (errstr == NULL)
+ return (sig);
+ if (strncasecmp(str, "SIG", 3) == 0)
+ str += 3;
+
+ for (i = 1; i < sys_nsig; i++) {
+ if (strcasecmp(str, sys_signame[i]) == 0)
+ return (i);
+ }
+
+ errx(125, "invalid signal");
+}
+
+static void
+sig_handler(int signo)
+{
+ if (sig_ign != 0 && signo == sig_ign) {
+ sig_ign = 0;
+ return;
+ }
+
+ switch (signo) {
+ case 0:
+ case SIGINT:
+ case SIGHUP:
+ case SIGQUIT:
+ case SIGTERM:
+ sig_term = signo;
+ break;
+ case SIGCHLD:
+ sig_chld = 1;
+ break;
+ case SIGALRM:
+ sig_alrm = 1;
+ break;
+ }
+}
+
+static void
+set_interval(double iv)
+{
+ struct itimerval tim;
+
+ memset(&tim, 0, sizeof(tim));
+ tim.it_value.tv_sec = (time_t)iv;
+ iv -= (time_t)iv;
+ tim.it_value.tv_usec = (suseconds_t)(iv * 1000000UL);
+
+ if (setitimer(ITIMER_REAL, &tim, NULL) == -1)
+ err(EXIT_FAILURE, "setitimer()");
+}
+
+int
+main(int argc, char **argv)
+{
+ int ch;
+ unsigned long i;
+ int foreground, preserve;
+ int error, pstat, status;
+ int killsig = SIGTERM;
+ pid_t pid, cpid;
+ double first_kill;
+ double second_kill;
+ bool timedout = false;
+ bool do_second_kill = false;
+ bool child_done = false;
+ struct sigaction signals;
+ struct procctl_reaper_status info;
+ struct procctl_reaper_kill killemall;
+ int signums[] = {
+ -1,
+ SIGTERM,
+ SIGINT,
+ SIGHUP,
+ SIGCHLD,
+ SIGALRM,
+ SIGQUIT,
+ };
+
+ foreground = preserve = 0;
+ second_kill = 0;
+
+ const struct option longopts[] = {
+ { "preserve-status", no_argument, &preserve, 1 },
+ { "foreground", no_argument, &foreground, 1 },
+ { "kill-after", required_argument, NULL, 'k'},
+ { "signal", required_argument, NULL, 's'},
+ { "help", no_argument, NULL, 'h'},
+ { NULL, 0, NULL, 0 }
+ };
+
+ while ((ch = getopt_long(argc, argv, "+k:s:h", longopts, NULL)) != -1) {
+ switch (ch) {
+ case 'k':
+ do_second_kill = true;
+ second_kill = parse_duration(optarg);
+ break;
+ case 's':
+ killsig = parse_signal(optarg);
+ break;
+ case 0:
+ break;
+ case 'h':
+ default:
+ usage();
+ }
+ }
+
+ argc -= optind;
+ argv += optind;
+
+ if (argc < 2)
+ usage();
+
+ first_kill = parse_duration(argv[0]);
+ argc--;
+ argv++;
+
+ if (!foreground) {
+ /* Acquire a reaper */
+ if (procctl(P_PID, getpid(), PROC_REAP_ACQUIRE, NULL) == -1)
+ err(EXIT_FAILURE, "Fail to acquire the reaper");
+ }
+
+ memset(&signals, 0, sizeof(signals));
+ sigemptyset(&signals.sa_mask);
+
+ if (killsig != SIGKILL && killsig != SIGSTOP)
+ signums[0] = killsig;
+
+ for (i = 0; i < sizeof(signums) / sizeof(signums[0]); i++)
+ sigaddset(&signals.sa_mask, signums[i]);
+
+ signals.sa_handler = sig_handler;
+ signals.sa_flags = SA_RESTART;
+
+ for (i = 0; i < sizeof(signums) / sizeof(signums[0]); i++)
+ if (signums[i] != -1 && signums[i] != 0 &&
+ sigaction(signums[i], &signals, NULL) == -1)
+ err(EXIT_FAILURE, "sigaction()");
+
+ signal(SIGTTIN, SIG_IGN);
+ signal(SIGTTOU, SIG_IGN);
+
+ pid = fork();
+ if (pid == -1)
+ err(EXIT_FAILURE, "fork()");
+ else if (pid == 0) {
+ /* child process */
+ signal(SIGTTIN, SIG_DFL);
+ signal(SIGTTOU, SIG_DFL);
+
+ error = execvp(argv[0], argv);
+ if (error == -1) {
+ if (errno == ENOENT)
+ err(127, "exec(%s)", argv[0]);
+ else
+ err(126, "exec(%s)", argv[0]);
+ }
+ }
+
+ if (sigprocmask(SIG_BLOCK, &signals.sa_mask, NULL) == -1)
+ err(EXIT_FAILURE, "sigprocmask()");
+
+ /* parent continues here */
+ set_interval(first_kill);
+
+ for (;;) {
+ sigemptyset(&signals.sa_mask);
+ sigsuspend(&signals.sa_mask);
+
+ if (sig_chld) {
+ sig_chld = 0;
+
+ while ((cpid = waitpid(-1, &status, WNOHANG)) != 0) {
+ if (cpid < 0) {
+ if (errno == EINTR)
+ continue;
+ else
+ break;
+ } else if (cpid == pid) {
+ pstat = status;
+ child_done = true;
+ }
+ }
+ if (child_done) {
+ if (foreground) {
+ break;
+ } else {
+ procctl(P_PID, getpid(),
+ PROC_REAP_STATUS, &info);
+ if (info.rs_children == 0)
+ break;
+ }
+ }
+ } else if (sig_alrm) {
+ sig_alrm = 0;
+
+ timedout = true;
+ if (!foreground) {
+ killemall.rk_sig = killsig;
+ killemall.rk_flags = 0;
+ procctl(P_PID, getpid(), PROC_REAP_KILL,
+ &killemall);
+ } else
+ kill(pid, killsig);
+
+ if (do_second_kill) {
+ set_interval(second_kill);
+ second_kill = 0;
+ sig_ign = killsig;
+ killsig = SIGKILL;
+ } else
+ break;
+
+ } else if (sig_term) {
+ if (!foreground) {
+ killemall.rk_sig = sig_term;
+ killemall.rk_flags = 0;
+ procctl(P_PID, getpid(), PROC_REAP_KILL,
+ &killemall);
+ } else
+ kill(pid, sig_term);
+
+ if (do_second_kill) {
+ set_interval(second_kill);
+ second_kill = 0;
+ sig_ign = killsig;
+ killsig = SIGKILL;
+ } else
+ break;
+ }
+ }
+
+ while (!child_done && wait(&pstat) == -1) {
+ if (errno != EINTR)
+ err(EXIT_FAILURE, "waitpid()");
+ }
+
+ if (!foreground)
+ procctl(P_PID, getpid(), PROC_REAP_RELEASE, NULL);
+
+ if (WEXITSTATUS(pstat))
+ pstat = WEXITSTATUS(pstat);
+ else if (WIFSIGNALED(pstat))
+ pstat = 128 + WTERMSIG(pstat);
+
+ if (timedout && !preserve)
+ pstat = EXIT_TIMEOUT;
+
+ return (pstat);
+}
diff --git a/bin/uuidgen/Makefile b/bin/uuidgen/Makefile
index 0b27d20e9805..234ee20300eb 100644
--- a/bin/uuidgen/Makefile
+++ b/bin/uuidgen/Makefile
@@ -1,5 +1,5 @@
-# $FreeBSD$
+PACKAGE= runtime
PROG= uuidgen
.include <bsd.prog.mk>
diff --git a/bin/uuidgen/Makefile.depend b/bin/uuidgen/Makefile.depend
index cae7e645ef6a..38d979787478 100644
--- a/bin/uuidgen/Makefile.depend
+++ b/bin/uuidgen/Makefile.depend
@@ -1,11 +1,12 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
+ include/xlocale \
lib/${CSU_DIR} \
lib/libc \
+ lib/libcapsicum \
+ lib/libcasper/libcasper \
lib/libcompiler_rt \
diff --git a/bin/uuidgen/uuidgen.1 b/bin/uuidgen/uuidgen.1
index f793fb248cdf..51475c900bbc 100644
--- a/bin/uuidgen/uuidgen.1
+++ b/bin/uuidgen/uuidgen.1
@@ -22,9 +22,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.
.\"
-.\" $FreeBSD$
-.\"
-.Dd May 23, 2012
+.Dd March 1, 2023
.Dt UUIDGEN 1
.Os
.Sh NAME
@@ -33,6 +31,8 @@
.Sh SYNOPSIS
.Nm
.Op Fl 1
+.Op Fl r
+.Op Fl c
.Op Fl n Ar count
.Op Fl o Ar filename
.Sh DESCRIPTION
@@ -50,6 +50,10 @@ This option only has effect if multiple identifiers are to be generated and
instructs
.Nm
to not generate them in batch, but one at a time.
+.It Fl r
+This option controls creation of random UUID (version 4).
+.It Fl c
+This option controls creation of compact UUID (without hyphen).
.It Fl n
This option controls the number of identifiers generated.
By default, multiple identifiers are generated in batch.
diff --git a/bin/uuidgen/uuidgen.c b/bin/uuidgen/uuidgen.c
index e135dfc4b6e0..3e2c0324a959 100644
--- a/bin/uuidgen/uuidgen.c
+++ b/bin/uuidgen/uuidgen.c
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2002 Marcel Moolenaar
+ * Copyright (c) 2022 Tobias C. Berner
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,9 +26,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/capsicum.h>
#include <capsicum_helpers.h>
@@ -40,26 +38,92 @@ __FBSDID("$FreeBSD$");
static void
usage(void)
{
- (void)fprintf(stderr, "usage: uuidgen [-1] [-n count] [-o filename]\n");
+ (void)fprintf(stderr,
+ "usage: uuidgen [-1] [-r] [-n count] [-o filename]\n");
exit(1);
}
+static void
+uuid_to_compact_string(const uuid_t *u, char **s, uint32_t *status)
+{
+ uuid_t nil;
+
+ if (status != NULL)
+ *status = uuid_s_ok;
+
+ if (s == NULL)
+ return;
+
+ if (u == NULL) {
+ u = &nil;
+ uuid_create_nil(&nil, NULL);
+ }
+
+ asprintf(s, "%08x%04x%04x%02x%02x%02x%02x%02x%02x%02x%02x",
+ u->time_low, u->time_mid, u->time_hi_and_version,
+ u->clock_seq_hi_and_reserved, u->clock_seq_low, u->node[0],
+ u->node[1], u->node[2], u->node[3], u->node[4], u->node[5]);
+
+ if (*s == NULL && status != NULL)
+ *status = uuid_s_no_memory;
+}
+
+static int
+uuidgen_v4(struct uuid *store, int count)
+{
+ int size;
+ struct uuid *item;
+
+ if (count < 1) {
+ errno = EINVAL;
+ return (-1);
+ }
+ size = sizeof(struct uuid) * count;
+ arc4random_buf(store, size);
+ item = store;
+ for (int i = 0; i < count; ++i) {
+ /*
+ * Set the two most significant bits (bits 6 and 7) of the
+ * clock_seq_hi_and_reserved to zero and one, respectively.
+ */
+ item->clock_seq_hi_and_reserved &= ~(3 << 6);
+ item->clock_seq_hi_and_reserved |= (2 << 6);
+ /*
+ * Set the four most significant bits (bits 12 through 15) of
+ * the time_hi_and_version field to the 4-bit version number
+ * from Section 4.1.3.
+ */
+ item->time_hi_and_version &= ~(15 << 12);
+ item->time_hi_and_version |= (4 << 12);
+ item++;
+ };
+ return (0);
+}
+
int
main(int argc, char *argv[])
{
FILE *fp;
uuid_t *store, *uuid;
char *p;
- int ch, count, i, iterate, status;
+ int ch, count, i, iterate, status, version;
+ void (*tostring)(const uuid_t *, char **, uint32_t *) = uuid_to_string;
- count = -1; /* no count yet */
- fp = stdout; /* default output file */
- iterate = 0; /* not one at a time */
- while ((ch = getopt(argc, argv, "1n:o:")) != -1)
+ count = -1; /* no count yet */
+ fp = stdout; /* default output file */
+ iterate = 0; /* not one at a time */
+ version = 1; /* create uuid v1 by default */
+ while ((ch = getopt(argc, argv, "1crn:o:")) != -1)
switch (ch) {
case '1':
iterate = 1;
break;
+ case 'c':
+ tostring = uuid_to_compact_string;
+ break;
+ case 'r':
+ version = 4;
+ break;
case 'n':
if (count > 0)
usage();
@@ -92,27 +156,41 @@ main(int argc, char *argv[])
if (count == -1)
count = 1;
- store = (uuid_t*)malloc(sizeof(uuid_t) * count);
+ store = (uuid_t *)malloc(sizeof(uuid_t) * count);
if (store == NULL)
err(1, "malloc()");
if (!iterate) {
/* Get them all in a single batch */
- if (uuidgen(store, count) != 0)
- err(1, "uuidgen()");
+ if (version == 1) {
+ if (uuidgen(store, count) != 0)
+ err(1, "uuidgen()");
+ } else if (version == 4) {
+ if (uuidgen_v4(store, count) != 0)
+ err(1, "uuidgen_v4()");
+ } else {
+ err(1, "unsupported version");
+ }
} else {
uuid = store;
for (i = 0; i < count; i++) {
- if (uuidgen(uuid++, 1) != 0)
- err(1, "uuidgen()");
+ if (version == 1) {
+ if (uuidgen(uuid++, 1) != 0)
+ err(1, "uuidgen()");
+ } else if (version == 4) {
+ if (uuidgen_v4(uuid++, 1) != 0)
+ err(1, "uuidgen_v4()");
+ } else {
+ err(1, "unsupported version");
+ }
}
}
uuid = store;
while (count--) {
- uuid_to_string(uuid++, &p, &status);
+ tostring(uuid++, &p, &status);
if (status != uuid_s_ok)
- err(1, "cannot stringify a UUID");
+ err(1, "cannot stringify a UUID");
fprintf(fp, "%s\n", p);
free(p);
}