From b8c60bc9ca365f8261fa97900b6fa939f6ebc303 Mon Sep 17 00:00:00 2001 From: Chet Ramey Date: Thu, 3 Jul 2025 16:15:36 -0400 Subject: [PATCH] Bash-5.3 distribution sources and documentation --- .gitignore~ | 115 - CHANGES | 937 +- COMPAT | 98 +- CWRU/PLATFORMS | 31 - CWRU/changelog | 7340 ++++++++- CWRU/misc/open-files.c | 1 + CWRU/misc/sigs.c | 8 +- CWRU/misc/sigstat.c | 9 +- ChangeLog | 7340 ++++++++- INSTALL | 478 +- MANIFEST | 180 +- Makefile.in | 1032 +- NEWS | 202 + POSIX | 461 +- RBASH | 56 +- README | 35 +- aclocal.m4 | 238 +- alias.c | 88 +- alias.h | 22 +- array.c | 177 +- array.h | 92 +- array2.c | 204 +- arrayfunc.c | 404 +- arrayfunc.h | 124 +- assoc.c | 88 +- assoc.h | 42 +- bashansi.h | 26 +- bashhist.c | 147 +- bashhist.h | 45 +- bashline.c | 1158 +- bashline.h | 49 +- bashtypes.h | 14 +- bracecomp.c | 23 +- braces.c | 320 +- buildconf.h.in | 51 + builtins/Makefile.in | 63 +- builtins/alias.def | 40 +- builtins/bashgetopt.c | 10 +- builtins/bashgetopt.h | 6 +- builtins/bind.def | 73 +- builtins/break.def | 24 +- builtins/builtin.def | 5 +- builtins/caller.def | 14 +- builtins/cd.def | 110 +- builtins/colon.def | 8 +- builtins/command.def | 23 +- builtins/common.c | 294 +- builtins/common.h | 223 +- builtins/complete.def | 156 +- builtins/declare.def | 191 +- builtins/echo.def | 8 +- builtins/enable.def | 126 +- builtins/eval.def | 5 +- builtins/evalfile.c | 99 +- builtins/evalstring.c | 155 +- builtins/exec.def | 53 +- builtins/exit.def | 22 +- builtins/fc.def | 99 +- builtins/fg_bg.def | 18 +- builtins/gen-helpfiles.c | 20 +- builtins/getopt.c | 27 +- builtins/getopt.h | 14 +- builtins/getopts.def | 43 +- builtins/hash.def | 50 +- builtins/help.def | 108 +- builtins/history.def | 65 +- builtins/jobs.def | 35 +- builtins/kill.def | 28 +- builtins/let.def | 6 +- builtins/mapfile.def | 45 +- builtins/mkbuiltins.c | 282 +- builtins/printf.def | 968 +- builtins/psize.c | 9 +- builtins/pushd.def | 99 +- builtins/read.def | 389 +- builtins/reserved.def | 10 + builtins/return.def | 11 +- builtins/set.def | 173 +- builtins/setattr.def | 104 +- builtins/shift.def | 18 +- builtins/shopt.def | 198 +- builtins/source.def | 75 +- builtins/suspend.def | 10 +- builtins/test.def | 5 +- builtins/times.def | 10 +- builtins/trap.def | 120 +- builtins/type.def | 45 +- builtins/ulimit.def | 139 +- builtins/umask.def | 156 +- builtins/wait.def | 137 +- command.h | 20 +- config-bot.h | 11 - config-top.h | 30 +- config.h.in | 153 +- configure | 10912 +++++++------ configure.ac | 170 +- copy_cmd.c | 92 +- cross-build/msys32.cache | 251 + dispose_cmd.c | 41 +- dispose_cmd.h | 23 +- doc/Makefile.in | 64 +- doc/bash.0 | 8111 +++++----- doc/bash.1 | 7569 +++++---- doc/bash.html | 7903 ++++++---- doc/bash.info | 12167 ++++++++------- doc/bash.pdf | Bin 401989 -> 439102 bytes doc/bashbug.ps | 297 - doc/bashref.dvi | Bin 823680 -> 895444 bytes doc/bashref.html | 17821 ++++++++++++---------- doc/bashref.info | 12167 ++++++++------- doc/bashref.pdf | Bin 795771 -> 855783 bytes doc/bashref.texi | 5166 ++++--- doc/builtins.0 | 2793 ++-- doc/builtins.1 | 2 +- doc/builtins.pdf | Bin 0 -> 143906 bytes doc/builtins.ps | 3435 ----- doc/rbash.0 | 67 +- doc/rbash.pdf | Bin 0 -> 19221 bytes doc/rbash.ps | 290 - doc/version.texi | 12 +- error.c | 137 +- error.h | 42 +- eval.c | 58 +- examples/functions/autoload.v3 | 2 +- examples/functions/autoload.v4 | 2 +- examples/functions/setalrm | 66 + examples/loadables/Makefile.in | 41 +- examples/loadables/accept.c | 12 +- examples/loadables/asort.c | 40 +- examples/loadables/basename.c | 5 +- examples/loadables/cat.c | 34 +- examples/loadables/chmod.c | 156 + examples/loadables/csv.c | 25 +- examples/loadables/cut.c | 191 +- examples/loadables/dirname.c | 5 +- examples/loadables/dsv.c | 26 +- examples/loadables/fdflags.c | 37 +- examples/loadables/finfo.c | 144 +- examples/loadables/fltexpr.c | 1762 +++ examples/loadables/getconf.c | 91 +- examples/loadables/getconf.h | 8 - examples/loadables/head.c | 10 +- examples/loadables/hello.c | 11 +- examples/loadables/id.c | 34 +- examples/loadables/kv.c | 244 + examples/loadables/ln.c | 18 +- examples/loadables/logname.c | 5 +- examples/loadables/mkdir.c | 92 +- examples/loadables/mkfifo.c | 7 +- examples/loadables/mktemp.c | 7 +- examples/loadables/mypid.c | 6 +- examples/loadables/necho.c | 8 +- examples/loadables/ocut.c | 616 + examples/loadables/pathchk.c | 26 +- examples/loadables/print.c | 17 +- examples/loadables/printenv.c | 5 +- examples/loadables/push.c | 5 +- examples/loadables/realpath.c | 8 +- examples/loadables/rm.c | 5 +- examples/loadables/rmdir.c | 5 +- examples/loadables/seq.c | 40 +- examples/loadables/setpgid.c | 9 +- examples/loadables/sleep.c | 6 +- examples/loadables/stat.c | 57 +- examples/loadables/strftime.c | 13 +- examples/loadables/strptime.c | 294 + examples/loadables/sync.c | 64 +- examples/loadables/tee.c | 7 +- examples/loadables/template.c | 11 +- examples/loadables/truefalse.c | 8 +- examples/loadables/tty.c | 7 +- examples/loadables/uname.c | 11 +- examples/loadables/unlink.c | 5 +- examples/loadables/whoami.c | 5 +- examples/scripts/bcalc | 2 +- examples/scripts/secure-script | 31 + examples/shellmath/shellmath.sh | 95 +- execute_cmd.c | 1375 +- execute_cmd.h | 106 +- expr.c | 369 +- externs.h | 487 +- findcmd.c | 144 +- findcmd.h | 23 +- flags.c | 22 +- flags.h | 16 +- general.c | 283 +- general.h | 209 +- hashcmd.c | 28 +- hashcmd.h | 12 +- hashlib.c | 81 +- hashlib.h | 40 +- include/ansi_stdlib.h | 8 +- include/gettext.h | 2 +- include/intprops-internal.h | 397 + include/memalloc.h | 14 +- include/ocache.h | 8 +- include/posixselect.h | 4 +- include/posixtime.h | 21 +- include/shmbchar.h | 81 +- include/shmbutil.h | 38 +- include/shtty.h | 42 +- include/stdc.h | 14 +- include/stdckdint.in.h | 35 + include/systimes.h | 4 +- include/unlocked-io.h | 138 + input.c | 179 +- input.h | 99 +- jobs.c | 1206 +- jobs.h | 198 +- lib/glob/Makefile.in | 22 +- lib/glob/collsyms.h | 6 +- lib/glob/glob.c | 172 +- lib/glob/glob.h | 10 +- lib/glob/glob_loop.c | 7 +- lib/glob/gm_loop.c | 15 +- lib/glob/gmisc.c | 10 +- lib/glob/ndir.h | 50 - lib/glob/sm_loop.c | 282 +- lib/glob/smatch.c | 98 +- lib/glob/strmatch.c | 16 +- lib/glob/strmatch.h | 6 +- lib/glob/xmbsrtowcs.c | 32 +- lib/intl/Makefile.in | 477 +- lib/intl/VERSION | 2 +- lib/intl/arg-nonnull.h | 26 + lib/intl/attribute.h | 226 + lib/intl/bindtextdom.c | 301 +- lib/intl/dcgettext.c | 29 +- lib/intl/dcigettext.c | 1294 +- lib/intl/dcngettext.c | 31 +- lib/intl/dgettext.c | 31 +- lib/intl/dngettext.c | 32 +- lib/intl/eval-plural.h | 30 +- lib/intl/explodename.c | 223 +- lib/intl/export.h | 8 + lib/intl/filename.h | 110 + lib/intl/finddomain.c | 146 +- lib/intl/flexmember.h | 57 + lib/intl/gettext.c | 27 +- lib/intl/gettextP.h | 257 +- lib/intl/gmo.h | 42 +- lib/intl/hash-string.c | 50 + lib/intl/hash-string.h | 63 +- lib/intl/intl-compat.c | 71 +- lib/intl/intl-exports.c | 38 + lib/intl/l10nflist.c | 370 +- lib/intl/langprefs.c | 406 + lib/intl/libgnuintl.in.h | 599 + lib/intl/loadinfo.h | 133 +- lib/intl/loadmsgcat.c | 976 +- lib/intl/localcharset.c | 1326 +- lib/intl/localcharset.h | 124 +- lib/intl/localealias.c | 187 +- lib/intl/localename-table.c | 48 + lib/intl/localename-table.in.h | 73 + lib/intl/localename.c | 3471 ++++- lib/intl/lock.c | 749 + lib/intl/lock.h | 791 + lib/intl/log.c | 122 +- lib/intl/ngettext.c | 27 +- lib/intl/os2compat.c | 22 +- lib/intl/os2compat.h | 30 +- lib/intl/osdep.c | 26 +- lib/intl/plural-exp.c | 41 +- lib/intl/plural-exp.h | 120 +- lib/intl/plural.c | 1794 ++- lib/intl/plural.h | 90 + lib/intl/plural.y | 115 +- lib/intl/printf-args.c | 186 + lib/intl/printf-args.h | 157 + lib/intl/printf-parse.c | 639 + lib/intl/printf-parse.h | 84 + lib/intl/printf.c | 458 + lib/intl/ref-add.sin | 10 +- lib/intl/ref-del.sin | 10 +- lib/intl/relocatable.c | 483 +- lib/intl/relocatable.h | 81 +- lib/intl/setlocale-lock.c | 150 + lib/intl/setlocale.c | 1771 +++ lib/intl/setlocale_null.c | 414 + lib/intl/setlocale_null.h | 82 + lib/intl/textdomain.c | 69 +- lib/intl/thread-optim.h | 60 + lib/intl/threadlib.c | 108 + lib/intl/tsearch.c | 682 + lib/intl/tsearch.h | 81 + lib/intl/vasnprintf.c | 5874 +++++++ lib/intl/vasnprintf.h | 76 + lib/intl/vasnwprintf.h | 44 + lib/intl/verify.h | 336 + lib/intl/version.c | 24 + lib/intl/wprintf-parse.h | 84 + lib/intl/xsize.c | 3 + lib/intl/xsize.h | 108 + lib/malloc/Makefile.in | 7 +- lib/malloc/alloca.c | 11 +- lib/malloc/imalloc.h | 20 +- lib/malloc/malloc.c | 203 +- lib/malloc/mstats.h | 10 +- lib/malloc/sbrk.c | 80 + lib/malloc/shmalloc.h | 46 +- lib/malloc/stats.c | 32 +- lib/malloc/table.c | 66 +- lib/malloc/table.h | 22 +- lib/malloc/trace.c | 30 +- lib/malloc/watch.c | 20 +- lib/malloc/watch.h | 6 +- lib/malloc/xmalloc.c | 21 +- lib/readline/Makefile.in | 21 +- lib/readline/ansi_stdlib.h | 8 +- lib/readline/bind.c | 442 +- lib/readline/callback.c | 21 +- lib/readline/chardefs.h | 2 +- lib/readline/colors.c | 4 +- lib/readline/complete.c | 457 +- lib/readline/display.c | 393 +- lib/readline/doc/Makefile | 79 +- lib/readline/doc/history.aux | 63 + lib/readline/doc/history.cp | 5 + lib/readline/doc/history.cps | 8 + lib/readline/doc/history.fn | 33 + lib/readline/doc/history.fns | 44 + lib/readline/doc/history.log | 247 + lib/readline/doc/history.texi | 4 +- lib/readline/doc/history.toc | 0 lib/readline/doc/history.vr | 13 + lib/readline/doc/history.vrs | 13 + lib/readline/doc/hstech.texi | 244 +- lib/readline/doc/hsuser.texi | 378 +- lib/readline/doc/rlman.aux | 156 + lib/readline/doc/rlman.cp | 11 + lib/readline/doc/rlman.cps | 20 + lib/readline/doc/rlman.fn | 267 + lib/readline/doc/rlman.fns | 287 + lib/readline/doc/rlman.log | 326 + lib/readline/doc/rlman.texi | 2 +- lib/readline/doc/rlman.toc | 52 + lib/readline/doc/rlman.vr | 83 + lib/readline/doc/rlman.vrs | 82 + lib/readline/doc/rltech.texi | 1239 +- lib/readline/doc/rluser.texi | 1360 +- lib/readline/doc/rluserman.aux | 69 + lib/readline/doc/rluserman.cp | 9 + lib/readline/doc/rluserman.cps | 16 + lib/readline/doc/rluserman.fn | 89 + lib/readline/doc/rluserman.fns | 109 + lib/readline/doc/rluserman.log | 242 + lib/readline/doc/rluserman.texi | 4 +- lib/readline/doc/rluserman.toc | 23 + lib/readline/doc/rluserman.vr | 46 + lib/readline/doc/rluserman.vrs | 61 + lib/readline/doc/version.texi | 12 +- lib/readline/emacs_keymap.c | 2 +- lib/readline/examples/excallback.c | 31 +- lib/readline/examples/fileman.c | 170 +- lib/readline/examples/histexamp.c | 12 +- lib/readline/examples/manexamp.c | 65 +- lib/readline/examples/rl-callbacktest.c | 11 +- lib/readline/examples/rl.c | 14 +- lib/readline/examples/rlcat.c | 20 +- lib/readline/examples/rltest.c | 6 +- lib/readline/funmap.c | 15 +- lib/readline/histexpand.c | 84 +- lib/readline/histfile.c | 192 +- lib/readline/histlib.h | 15 +- lib/readline/history.c | 168 +- lib/readline/history.h | 14 +- lib/readline/histsearch.c | 158 +- lib/readline/input.c | 120 +- lib/readline/isearch.c | 101 +- lib/readline/kill.c | 41 +- lib/readline/macro.c | 2 +- lib/readline/mbutil.c | 176 +- lib/readline/misc.c | 198 +- lib/readline/nls.c | 3 +- lib/readline/parens.c | 5 +- lib/readline/parse-colors.c | 45 +- lib/readline/posixselect.h | 4 +- lib/readline/posixtime.h | 21 +- lib/readline/readline.c | 67 +- lib/readline/readline.h | 106 +- lib/readline/rlconf.h | 5 + lib/readline/rldefs.h | 16 +- lib/readline/rlmbutil.h | 172 +- lib/readline/rlprivate.h | 81 +- lib/readline/rlstdc.h | 14 +- lib/readline/rltty.c | 55 +- lib/readline/rltypedefs.h | 16 +- lib/readline/rlwinsize.h | 5 +- lib/readline/search.c | 231 +- lib/readline/shell.c | 8 +- lib/readline/signals.c | 32 +- lib/readline/tcap.h | 14 +- lib/readline/terminal.c | 140 +- lib/readline/text.c | 487 +- lib/readline/tilde.c | 21 +- lib/readline/undo.c | 4 +- lib/readline/util.c | 130 +- lib/readline/vi_mode.c | 84 +- lib/readline/xmalloc.c | 2 +- lib/readline/xmalloc.h | 10 +- lib/sh/Makefile.in | 80 +- lib/sh/anonfile.c | 151 + lib/sh/casemod.c | 21 +- lib/sh/clktck.c | 4 +- lib/sh/clock.c | 25 +- lib/sh/compat.c | 53 + lib/sh/dprintf.c | 18 +- lib/sh/eaccess.c | 31 +- lib/sh/fmtulong.c | 26 +- lib/sh/fnxform.c | 32 +- lib/sh/fpurge.c | 4 +- lib/sh/getcwd.c | 18 +- lib/sh/getenv.c | 55 +- lib/sh/gettimeofday.c | 130 +- lib/sh/inet_aton.c | 13 +- lib/sh/input_avail.c | 11 +- lib/sh/itos.c | 19 +- lib/sh/mailstat.c | 6 +- lib/sh/makepath.c | 14 +- lib/sh/mbscasecmp.c | 21 +- lib/sh/mbschr.c | 6 - lib/sh/mbscmp.c | 17 +- lib/sh/mbsncmp.c | 80 + lib/sh/mktime.c | 157 +- lib/sh/netconn.c | 5 +- lib/sh/netopen.c | 49 +- lib/sh/oslib.c | 55 +- lib/sh/pathcanon.c | 14 +- lib/sh/pathphys.c | 43 +- lib/sh/random.c | 52 +- lib/sh/reallocarray.c | 44 + lib/sh/rename.c | 5 +- lib/sh/setlinebuf.c | 3 +- lib/sh/shmatch.c | 38 +- lib/sh/shmbchar.c | 27 +- lib/sh/shquote.c | 54 +- lib/sh/shtty.c | 62 +- lib/sh/snprintf.c | 200 +- lib/sh/spell.c | 25 +- lib/sh/strcasecmp.c | 11 +- lib/sh/strcasestr.c | 6 +- lib/sh/strchrnul.c | 6 +- lib/sh/strdup.c | 5 +- lib/sh/strerror.c | 5 +- lib/sh/strftime.c | 255 +- lib/sh/stringlist.c | 69 +- lib/sh/stringvec.c | 82 +- lib/sh/strlcpy.c | 39 + lib/sh/strnlen.c | 6 +- lib/sh/strpbrk.c | 6 +- lib/sh/strscpy.c | 41 + lib/sh/strstr.c | 2 +- lib/sh/strtod.c | 12 +- lib/sh/strtoimax.c | 11 +- lib/sh/strtol.c | 11 +- lib/sh/strtoumax.c | 11 +- lib/sh/strtrans.c | 55 +- lib/sh/strvis.c | 10 +- lib/sh/timers.c | 6 +- lib/sh/times.c | 7 +- lib/sh/timeval.c | 60 +- lib/sh/tmpfile.c | 118 +- lib/sh/uconvert.c | 13 +- lib/sh/ufuncs.c | 84 +- lib/sh/unicode.c | 45 +- lib/sh/utf8.c | 28 +- lib/sh/vprint.c | 15 +- lib/sh/wcsdup.c | 5 +- lib/sh/wcsnwidth.c | 6 +- lib/sh/wcswidth.c | 6 +- lib/sh/winsize.c | 39 +- lib/sh/zcatfd.c | 10 +- lib/sh/zgetline.c | 27 +- lib/sh/zmapfd.c | 20 +- lib/sh/zread.c | 138 +- lib/sh/zwrite.c | 11 +- lib/termcap/termcap.c | 97 +- lib/termcap/termcap.h | 26 +- lib/termcap/tparam.c | 56 +- lib/tilde/Makefile.in | 23 +- lib/tilde/shell.c | 2 +- lib/tilde/tilde.c | 21 +- list.c | 24 +- locale.c | 109 +- m4/bison.m4 | 92 + m4/c-bool.m4 | 27 + m4/codeset.m4 | 3 +- m4/d-type.m4 | 32 + m4/extern-inline.m4 | 11 +- m4/fcntl-o.m4 | 5 +- m4/flexmember.m4 | 44 + m4/gettext.m4 | 91 +- m4/host-cpu-c-abi.m4 | 52 +- m4/iconv.m4 | 67 +- m4/intdiv0.m4 | 21 +- m4/intl-thread-locale.m4 | 78 +- m4/intl.m4 | 65 +- m4/intlmacosx.m4 | 33 +- m4/inttypes.m4 | 57 +- m4/inttypes_h.m4 | 2 +- m4/lcmessage.m4 | 10 +- m4/lib-ld.m4 | 6 +- m4/lib-link.m4 | 173 +- m4/lib-prefix.m4 | 206 +- m4/locale_h.m4 | 174 + m4/lock.m4 | 2 +- m4/nls.m4 | 10 +- m4/po.m4 | 49 +- m4/printf-posix.m4 | 6 +- m4/progtest.m4 | 16 +- m4/pthread_rwlock_rdlock.m4 | 30 +- m4/size_max.m4 | 8 +- m4/stdint_h.m4 | 2 +- m4/strtoimax.m4 | 24 +- m4/threadlib.m4 | 673 +- m4/unlocked-io.m4 | 31 + m4/wchar_t.m4 | 2 +- m4/wint_t.m4 | 47 +- m4/xsize.m4 | 2 +- mailcheck.c | 88 +- mailcheck.h | 18 +- make_cmd.c | 173 +- make_cmd.h | 66 +- mksyntax.c | 108 +- nojobs.c | 195 +- parse.y | 1714 ++- parser-built | 193 + parser.h | 16 +- patchlevel.h | 4 +- pathexp.c | 443 +- pathexp.h | 42 +- pathnames.h.in | 2 +- pcomplete.c | 381 +- pcomplete.h | 41 +- pcomplib.c | 36 +- po/POTFILES.in | 14 +- po/af.gmo | Bin 1280 -> 1040 bytes po/af.po | 1460 +- po/bash.pot | 1402 +- po/bg.gmo | Bin 248812 -> 258404 bytes po/bg.po | 1621 +- po/ca.gmo | Bin 183474 -> 128568 bytes po/ca.po | 2227 +-- po/cs.gmo | Bin 185301 -> 192115 bytes po/cs.po | 1651 +- po/da.gmo | Bin 70624 -> 60443 bytes po/da.po | 1535 +- po/de.gmo | Bin 119767 -> 182342 bytes po/de.po | 3308 ++-- po/el.gmo | Bin 83800 -> 77549 bytes po/el.po | 1508 +- po/en@boldquot.gmo | Bin 164675 -> 180619 bytes po/en@boldquot.po | 1710 ++- po/en@quot.gmo | Bin 163043 -> 178923 bytes po/en@quot.po | 1697 +- po/eo.gmo | Bin 162418 -> 118409 bytes po/eo.po | 1559 +- po/es.gmo | Bin 183966 -> 190295 bytes po/es.po | 1683 +- po/et.gmo | Bin 12156 -> 27510 bytes po/et.po | 2359 ++- po/fi.gmo | Bin 73116 -> 62932 bytes po/fi.po | 1528 +- po/fr.gmo | Bin 144345 -> 197028 bytes po/fr.po | 3456 ++--- po/ga.gmo | Bin 115689 -> 100049 bytes po/ga.po | 1542 +- po/gl.gmo | Bin 53798 -> 48557 bytes po/gl.po | 1534 +- po/hr.gmo | Bin 136072 -> 184243 bytes po/hr.po | 3093 ++-- po/hu.gmo | Bin 152745 -> 116359 bytes po/hu.po | 1545 +- po/id.gmo | Bin 98266 -> 81233 bytes po/id.po | 1543 +- po/it.gmo | Bin 83883 -> 190431 bytes po/it.po | 3971 +++-- po/ja.gmo | Bin 115343 -> 91569 bytes po/ja.po | 2336 +-- po/ka.gmo | Bin 49809 -> 44183 bytes po/ka.po | 1843 ++- po/ko.gmo | Bin 185651 -> 192128 bytes po/ko.po | 1653 +- po/lt.gmo | Bin 28770 -> 26385 bytes po/lt.po | 1508 +- po/nb.gmo | Bin 172246 -> 120592 bytes po/nb.po | 2399 +-- po/nl.gmo | Bin 181276 -> 187509 bytes po/nl.po | 1704 ++- po/pl.gmo | Bin 184164 -> 190807 bytes po/pl.po | 1606 +- po/pt.gmo | Bin 170400 -> 186579 bytes po/pt.po | 2847 ++-- po/pt_BR.gmo | Bin 183592 -> 190756 bytes po/pt_BR.po | 1866 ++- po/ro.gmo | Bin 190057 -> 197068 bytes po/ro.po | 1724 ++- po/ru.gmo | Bin 128223 -> 105270 bytes po/ru.po | 4316 +++--- po/sk.gmo | Bin 83429 -> 69047 bytes po/sk.po | 1534 +- po/sl.gmo | Bin 80665 -> 66641 bytes po/sl.po | 1539 +- po/sq.gmo | Bin 584 -> 584 bytes po/sq.po | 1731 ++- po/sr.gmo | Bin 232614 -> 241651 bytes po/sr.po | 1702 ++- po/sv.gmo | Bin 176963 -> 183324 bytes po/sv.po | 1600 +- po/tr.gmo | Bin 106418 -> 96241 bytes po/tr.po | 961 +- po/uk.gmo | Bin 237263 -> 246838 bytes po/uk.po | 1636 +- po/vi.gmo | Bin 133752 -> 108706 bytes po/vi.po | 1535 +- po/zh_CN.gmo | Bin 130043 -> 176530 bytes po/zh_CN.po | 1647 +- po/zh_TW.gmo | Bin 168819 -> 118863 bytes po/zh_TW.po | 2023 ++- print_cmd.c | 491 +- quit.h | 16 + redir.c | 278 +- redir.h | 24 +- shell.c | 393 +- shell.h | 36 +- sig.c | 108 +- sig.h | 52 +- siglist.c | 4 +- siglist.h | 4 +- stringlib.c | 107 +- subst.c | 2539 +-- subst.h | 183 +- support/Makefile.in | 3 +- support/bash.pc.in | 5 +- support/bashbug.sh.in | 4 +- support/bashversion.c | 33 +- support/config.guess | 111 +- support/config.rpath | 93 +- support/config.sub | 942 +- support/install-sh | 541 + support/install.sh | 247 - support/man2html.c | 15 +- support/mksignames.c | 13 +- support/mkversion.sh | 6 +- support/printenv.c | 13 +- support/recho.c | 17 +- support/rlvers.sh | 1 + support/shobj-conf | 20 +- support/siglen.c | 28 + support/signames.c | 25 +- support/texi2html | 6 +- support/xcase.c | 15 +- support/xenix-link.sh | 84 - support/zecho.c | 10 +- test.c | 219 +- test.h | 11 +- tests/alias.right | 19 + tests/alias.tests | 12 +- tests/alias4.sub | 7 + tests/alias7.sub | 92 + tests/arith-for.right | 10 + tests/arith-for.tests | 18 + tests/arith.right | 176 +- tests/arith.tests | 25 + tests/arith10.sub | 95 + tests/arith9.sub | 38 + tests/array.right | 127 +- tests/array.tests | 49 +- tests/array16.sub | 9 + tests/array27.sub | 3 + tests/array31.sub | 43 + tests/array32.sub | 98 + tests/array33.sub | 52 + tests/assoc.right | 11 +- tests/assoc.tests | 7 + tests/assoc13.sub | 14 +- tests/assoc19.sub | 50 + tests/attr.right | 4 +- tests/braces.right | 25 + tests/braces.tests | 44 + tests/builtins.right | 233 +- tests/builtins.tests | 64 +- tests/builtins1.sub | 4 + tests/builtins10.sub | 39 + tests/builtins11.sub | 45 + tests/builtins12.sub | 40 + tests/builtins2.sub | 4 + tests/builtins8.sub | 85 + tests/builtins9.sub | 59 + tests/case.right | 3 + tests/case.tests | 9 + tests/casemod.right | 2 + tests/casemod.tests | 7 +- tests/complete.right | 324 + tests/complete.tests | 33 + tests/comsub-eof.right | 4 +- tests/comsub-eof0.sub | 6 + tests/comsub-posix.right | 14 +- tests/comsub.right | 20 +- tests/comsub.tests | 25 + tests/comsub2.right | 192 + tests/comsub2.tests | 153 + tests/comsub21.sub | 65 + tests/comsub22.sub | 26 + tests/comsub23.sub | 79 + tests/comsub24.sub | 77 + tests/comsub25.sub | 138 + tests/comsub26.sub | 36 + tests/comsub7.sub | 64 + tests/cond-error1.sub | 28 + tests/cond-regexp.sub | 42 - tests/cond-regexp2.sub | 32 +- tests/cond-regexp3.sub | 2 +- tests/cond-xtrace1.sub | 19 + tests/cond.right | 51 +- tests/cond.tests | 20 +- tests/dbg-support.right | 135 +- tests/dbg-support.tests | 4 + tests/dollar-at-star | 3 + tests/dollar-star11.sub | 98 + tests/dollar.right | 40 + tests/dynvar.right | 8 + tests/dynvar.tests | 26 +- tests/errors.right | 324 +- tests/errors.tests | 109 +- tests/errors1.sub | 9 +- tests/errors10.sub | 70 + tests/errors11.sub | 42 + tests/errors12.sub | 42 + tests/errors4.sub | 16 + tests/errors7.sub | 3 + tests/errors8.sub | 3 + tests/exec.right | 117 +- tests/exec15.sub | 72 + tests/exec16.sub | 127 + tests/exec17.sub | 69 + tests/exec3.sub | 72 +- tests/exec6.sub | 16 + tests/execscript | 53 +- tests/exp.right | 18 +- tests/exp.tests | 9 + tests/exp1.sub | 20 + tests/exportfunc.right | 4 +- tests/exportfunc.tests | 1 + tests/extglob.right | 7 + tests/extglob.tests | 6 + tests/extglob8.sub | 33 + tests/func.right | 93 + tests/func.tests | 15 + tests/func5.sub | 107 + tests/getopts.right | 2 + tests/getopts10.sub | 6 + tests/glob-bracket.right | 103 + tests/glob-bracket.tests | 309 + tests/glob.right | 20 +- tests/glob.tests | 1 + tests/glob10.sub | 2 +- tests/glob11.sub | 77 + tests/glob2.sub | 10 +- tests/glob8.sub | 2 +- tests/heredoc.right | 43 +- tests/heredoc.tests | 40 +- tests/heredoc10.sub | 55 + tests/heredoc8.sub | 62 + tests/heredoc9.sub | 44 + tests/histexp.right | 7 + tests/histexp.tests | 4 + tests/histexp1.sub | 8 + tests/history.right | 105 +- tests/history.tests | 4 + tests/history1.sub | 5 + tests/history3.sub | 3 + tests/history5.sub | 16 + tests/history7.sub | 74 + tests/history8.sub | 18 + tests/history9.sub | 57 + tests/intl.right | 12 +- tests/intl.tests | 2 + tests/intl4.sub | 35 + tests/invocation.right | 104 + tests/invocation.tests | 78 + tests/invocation1.sub | 40 + tests/invocation2.sub | 50 + tests/invocation3.sub | 25 + tests/jobs.right | 91 +- tests/jobs.tests | 32 +- tests/jobs5.sub | 5 + tests/jobs8.sub | 29 + tests/jobs9.sub | 14 + tests/lastpipe.right | 1 + tests/lastpipe.tests | 3 + tests/more-exp.right | 2 +- tests/nameref.right | 46 +- tests/nameref23.sub | 14 + tests/nameref24.sub | 42 + tests/nameref25.sub | 25 + tests/nameref4.sub | 14 + tests/new-exp.right | 47 +- tests/new-exp.tests | 17 + tests/new-exp10.sub | 49 +- tests/parser.right | 4 + tests/parser.tests | 10 + tests/posix2syntax.sub | 35 + tests/posixpipe.right | 4 + tests/posixpipe.tests | 7 + tests/precedence | 75 - tests/printf.right | 118 +- tests/printf.tests | 70 +- tests/printf1.sub | 10 +- tests/printf3.sub | 2 +- tests/printf5.sub | 36 + tests/printf6.sub | 47 + tests/printf7.sub | 91 + tests/quote.right | 2 + tests/quote.tests | 7 + tests/quotearray.right | 16 +- tests/read.right | 23 + tests/read.tests | 19 + tests/read1.sub | 22 + tests/read10.sub | 17 + tests/read2.sub | 7 +- tests/read3.sub | 4 + tests/read7.sub | 3 +- tests/read9.sub | 41 + tests/redir.right | 31 +- tests/redir.tests | 31 +- tests/redir11.sub | 2 + tests/redir12.sub | 62 +- tests/redir13.in | 5 + tests/redir8.sub | 5 + tests/rsh.right | 15 +- tests/rsh.tests | 1 + tests/run-all | 8 +- tests/run-braces | 2 +- tests/run-comsub2 | 2 + tests/run-cond | 2 + tests/run-extglob | 2 +- tests/run-glob-bracket | 5 + tests/run-invocation | 2 + tests/run-minimal | 18 +- tests/run-set-x | 2 +- tests/set-e.right | 2 + tests/set-e.tests | 13 + tests/set-x.right | 12 + tests/set-x.tests | 5 + tests/set-x1.sub | 3 + tests/set-x2.sub | 15 + tests/shopt.right | 100 +- tests/source8.sub | 68 + tests/test.right | 69 +- tests/test.tests | 54 +- tests/test1.sub | 2 +- tests/tilde.right | 1 + tests/tilde.tests | 1 + tests/trap.right | 23 + tests/trap.tests | 27 +- tests/trap2.sub | 2 + tests/trap6.sub | 19 + tests/trap7.sub | 8 + tests/trap8.sub | 14 + tests/trap9.sub | 84 + tests/type.right | 40 +- tests/type.tests | 31 +- tests/type4.sub | 10 + tests/type5.sub | 59 + tests/unicode1.sub | 68 +- tests/varenv.right | 92 +- tests/varenv.sh | 225 - tests/varenv.tests | 3 + tests/varenv1.sub | 23 + tests/varenv12.sub | 13 + tests/varenv14.sub | 43 + tests/varenv2.sub | 4 + tests/varenv21.sub | 1 + tests/varenv23.sub | 95 + tests/varenv24.sub | 102 + tests/varenv25.sub | 73 + tests/varenv7.sub | 4 +- tests/vredir.right | 28 +- tests/vredir.tests | 4 +- tests/vredir1.sub | 17 + tests/vredir4.sub | 18 + tests/vredir7.sub | 6 + tests/vredir8.sub | 29 +- trap.c | 361 +- trap.h | 122 +- unwind_prot.c | 143 +- unwind_prot.h | 34 +- variables.c | 1421 +- variables.h | 372 +- version.c | 24 +- xmalloc.c | 80 +- xmalloc.h | 25 +- y.tab.c | 3498 +++-- y.tab.h | 10 +- 896 files changed, 174476 insertions(+), 103826 deletions(-) delete mode 100644 .gitignore~ delete mode 100644 CWRU/PLATFORMS create mode 100644 buildconf.h.in create mode 100644 cross-build/msys32.cache delete mode 100644 doc/bashbug.ps create mode 100644 doc/builtins.pdf delete mode 100644 doc/builtins.ps create mode 100644 doc/rbash.pdf delete mode 100644 doc/rbash.ps create mode 100644 examples/functions/setalrm create mode 100644 examples/loadables/chmod.c create mode 100644 examples/loadables/fltexpr.c create mode 100644 examples/loadables/kv.c create mode 100644 examples/loadables/ocut.c create mode 100644 examples/loadables/strptime.c create mode 100644 examples/scripts/secure-script create mode 100644 include/intprops-internal.h create mode 100644 include/stdckdint.in.h create mode 100644 include/unlocked-io.h delete mode 100644 lib/glob/ndir.h create mode 100644 lib/intl/arg-nonnull.h create mode 100644 lib/intl/attribute.h create mode 100644 lib/intl/export.h create mode 100644 lib/intl/filename.h create mode 100644 lib/intl/flexmember.h create mode 100644 lib/intl/hash-string.c create mode 100644 lib/intl/intl-exports.c create mode 100644 lib/intl/langprefs.c create mode 100644 lib/intl/libgnuintl.in.h create mode 100644 lib/intl/localename-table.c create mode 100644 lib/intl/localename-table.in.h create mode 100644 lib/intl/lock.c create mode 100644 lib/intl/lock.h create mode 100644 lib/intl/plural.h create mode 100644 lib/intl/printf-args.c create mode 100644 lib/intl/printf-args.h create mode 100644 lib/intl/printf-parse.c create mode 100644 lib/intl/printf-parse.h create mode 100644 lib/intl/printf.c create mode 100644 lib/intl/setlocale-lock.c create mode 100644 lib/intl/setlocale.c create mode 100644 lib/intl/setlocale_null.c create mode 100644 lib/intl/setlocale_null.h create mode 100644 lib/intl/thread-optim.h create mode 100644 lib/intl/threadlib.c create mode 100644 lib/intl/tsearch.c create mode 100644 lib/intl/tsearch.h create mode 100644 lib/intl/vasnprintf.c create mode 100644 lib/intl/vasnprintf.h create mode 100644 lib/intl/vasnwprintf.h create mode 100644 lib/intl/verify.h create mode 100644 lib/intl/version.c create mode 100644 lib/intl/wprintf-parse.h create mode 100644 lib/intl/xsize.c create mode 100644 lib/intl/xsize.h create mode 100644 lib/malloc/sbrk.c create mode 100644 lib/readline/doc/history.aux create mode 100644 lib/readline/doc/history.cp create mode 100644 lib/readline/doc/history.cps create mode 100644 lib/readline/doc/history.fn create mode 100644 lib/readline/doc/history.fns create mode 100644 lib/readline/doc/history.log create mode 100644 lib/readline/doc/history.toc create mode 100644 lib/readline/doc/history.vr create mode 100644 lib/readline/doc/history.vrs create mode 100644 lib/readline/doc/rlman.aux create mode 100644 lib/readline/doc/rlman.cp create mode 100644 lib/readline/doc/rlman.cps create mode 100644 lib/readline/doc/rlman.fn create mode 100644 lib/readline/doc/rlman.fns create mode 100644 lib/readline/doc/rlman.log create mode 100644 lib/readline/doc/rlman.toc create mode 100644 lib/readline/doc/rlman.vr create mode 100644 lib/readline/doc/rlman.vrs create mode 100644 lib/readline/doc/rluserman.aux create mode 100644 lib/readline/doc/rluserman.cp create mode 100644 lib/readline/doc/rluserman.cps create mode 100644 lib/readline/doc/rluserman.fn create mode 100644 lib/readline/doc/rluserman.fns create mode 100644 lib/readline/doc/rluserman.log create mode 100644 lib/readline/doc/rluserman.toc create mode 100644 lib/readline/doc/rluserman.vr create mode 100644 lib/readline/doc/rluserman.vrs create mode 100644 lib/sh/anonfile.c create mode 100644 lib/sh/compat.c create mode 100644 lib/sh/mbsncmp.c create mode 100644 lib/sh/reallocarray.c create mode 100644 lib/sh/strlcpy.c create mode 100644 lib/sh/strscpy.c create mode 100644 m4/bison.m4 create mode 100644 m4/c-bool.m4 create mode 100644 m4/d-type.m4 create mode 100644 m4/flexmember.m4 create mode 100644 m4/locale_h.m4 create mode 100644 m4/unlocked-io.m4 create mode 100755 support/install-sh delete mode 100755 support/install.sh create mode 100644 support/siglen.c delete mode 100755 support/xenix-link.sh create mode 100644 tests/alias7.sub create mode 100644 tests/arith10.sub create mode 100644 tests/arith9.sub create mode 100644 tests/array31.sub create mode 100644 tests/array32.sub create mode 100644 tests/array33.sub create mode 100644 tests/assoc19.sub create mode 100644 tests/builtins10.sub create mode 100644 tests/builtins11.sub create mode 100644 tests/builtins12.sub create mode 100644 tests/builtins8.sub create mode 100644 tests/builtins9.sub create mode 100644 tests/comsub2.right create mode 100644 tests/comsub2.tests create mode 100644 tests/comsub21.sub create mode 100644 tests/comsub22.sub create mode 100644 tests/comsub23.sub create mode 100644 tests/comsub24.sub create mode 100644 tests/comsub25.sub create mode 100644 tests/comsub26.sub create mode 100644 tests/comsub7.sub create mode 100644 tests/cond-error1.sub delete mode 100644 tests/cond-regexp.sub create mode 100644 tests/cond-xtrace1.sub create mode 100644 tests/dollar-star11.sub create mode 100644 tests/errors10.sub create mode 100644 tests/errors11.sub create mode 100644 tests/errors12.sub create mode 100644 tests/exec15.sub create mode 100644 tests/exec16.sub create mode 100644 tests/exec17.sub create mode 100644 tests/extglob8.sub create mode 100644 tests/func5.sub create mode 100644 tests/glob-bracket.right create mode 100644 tests/glob-bracket.tests create mode 100644 tests/glob11.sub create mode 100644 tests/heredoc10.sub create mode 100644 tests/heredoc8.sub create mode 100644 tests/heredoc9.sub create mode 100644 tests/history7.sub create mode 100644 tests/history8.sub create mode 100644 tests/history9.sub create mode 100644 tests/intl4.sub create mode 100644 tests/invocation.right create mode 100644 tests/invocation.tests create mode 100644 tests/invocation1.sub create mode 100644 tests/invocation2.sub create mode 100644 tests/invocation3.sub create mode 100644 tests/jobs8.sub create mode 100644 tests/jobs9.sub create mode 100644 tests/nameref24.sub create mode 100644 tests/nameref25.sub delete mode 100755 tests/precedence create mode 100644 tests/printf5.sub create mode 100644 tests/printf6.sub create mode 100644 tests/printf7.sub create mode 100644 tests/read10.sub create mode 100644 tests/read9.sub create mode 100644 tests/redir13.in create mode 100644 tests/run-comsub2 create mode 100644 tests/run-glob-bracket create mode 100644 tests/run-invocation create mode 100644 tests/set-x2.sub create mode 100644 tests/source8.sub create mode 100644 tests/trap7.sub create mode 100644 tests/trap8.sub create mode 100644 tests/trap9.sub create mode 100644 tests/type5.sub delete mode 100644 tests/varenv.sh create mode 100644 tests/varenv23.sub create mode 100644 tests/varenv24.sub create mode 100644 tests/varenv25.sub diff --git a/.gitignore~ b/.gitignore~ deleted file mode 100644 index 1512a9ab0..000000000 --- a/.gitignore~ +++ /dev/null @@ -1,115 +0,0 @@ -# don't push out -i --i - -*.save -.DS_Store -.DS_Store? -._* -.Spotlight-V100 -# -# these files are all created by the build process; none are in the repository -# -*.o -*.a -*.dSYM -.build -.made - -config.h -config.status -config.cache -config.log - -autom4te.cache - -bash -bashbug -bashversion - -Makefile -builtins/Makefile -builtins/builtext.h -builtins/builtins.c -builtins/mkbuiltins -builtins/pipesize.h -builtins/psize.aux - -doc/Makefile -examples/loadables/Makefile -examples/loadables/Makefile.inc -examples/loadables/perl/Makefile -lib/glob/Makefile -lib/intl/Makefile -lib/malloc/Makefile -lib/readline/Makefile -lib/sh/Makefile -lib/termcap/Makefile -lib/tilde/Makefile -support/Makefile - -lib/intl/charset.alias -lib/intl/libgnuintl.h -lib/intl/libintl.h -lib/intl/ref-add.sed -lib/intl/ref-del.sed - -po/Makefile -po/Makefile.in -po/POTFILES -po/stamp-po - -support/bash.pc -support/man2html -support/bashbug.sh - -lsignames.h -pathnames.h -signames.h -version.h -syntax.c -stamp-h - -mksignames -mksyntax - -printenv -recho -xcase -zecho -tests/printenv -tests/recho -tests/xcase -tests/zecho - -examples/loadables/accept -examples/loadables/basename -examples/loadables/csv -examples/loadables/cut -examples/loadables/dirname -examples/loadables/fdflags -examples/loadables/finfo -examples/loadables/head -examples/loadables/id -examples/loadables/ln -examples/loadables/logname -examples/loadables/mkdir -examples/loadables/mkfifo -examples/loadables/mktemp -examples/loadables/mypid -examples/loadables/pathchk -examples/loadables/print -examples/loadables/push -examples/loadables/realpath -examples/loadables/rm -examples/loadables/rmdir -examples/loadables/seq -examples/loadables/setpgid -examples/loadables/sleep -examples/loadables/strftime -examples/loadables/sync -examples/loadables/tee -examples/loadables/truefalse -examples/loadables/tty -examples/loadables/uname -examples/loadables/unlink -examples/loadables/whoami diff --git a/CHANGES b/CHANGES index e4e0124f2..62cfa4723 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,938 @@ +This document details the changes between this version, bash-5.3-rc2, and +the previous version, bash-5.3-rc1. + +1. Changes to Bash + +a. Fixed a problem with invoking the correct programmable completion compspec + if the line contains a quoted command separator before point. + +b. Fixed a bug in the `read' builtin that caused it to skip the delimiter if + it appeared in an invalid multibyte character. + +c. Fixed a bug with parsing command substitutions that caused a syntax error + to pop too many input sources. + +d. Fixed an issue with recursive parsing that caused the parser to reset and + pop all the delimiters off the stack; the caller needs to check for that + possibility. + +e. Fixed an issue with interactive input that caused EOF not to exit the + shell if it was read as part of a here-document. + +f. Fixed an issue with a backslash-newline appearing after a right paren in + a nested subshell command. + +g. Fixed an issue with invalid sequence expressions in brace expansions. + +h. Fixed an issue with a nameref variable referencing an unset array element + when the nounset option is enabled. + +2. Changes to Readline + +a. The history library no longer skips blank lines while it is reading a + multiline history entry from a history file. + +3. New Features in Bash + +a. The `install-strip' and `strip' Makefile targets now deal with cross- + compiling. + +4. New Features in Readline + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-5.3-rc1, and +the previous version, bash-5.3-beta. + +1. Changes to Bash + +a. Fixed a bug where backslash did not quote multibyte characters in some + cases. + +b. Requesting the length of an element of an unset array is a fatal error + when `set -u' is enabled and the subscript is not `@' or `*'. + +c. Prompt expansion now quotes the results of \U. + +d. Changes to `set -e' exit behavior in posix mode, since POSIX now says to + exit as if executing the `exit builtin with no arguments'. + +e. Fixes to the `exec' builtin to undo redirections if it is given a command + name to execute and the exection fails, but the shell does not exit. This + is POSIX interp 1896. + +f. Fixed a bug that resulted in `wait' setting $? to 255 in some cases when + waiting for a specific PID. + +g. Fixed a bug involving redirections to the file descriptor bash is using to + read a script. + +h. In POSIX mode, `kill' returns a failure status if any of the PID/job + arguments are not found or if sending the signal fails. + +i. Fixed a bug that caused an invalid brace sequence expression to mess up + expansion of an enclosing brace expansion. + +j. Fixed a bug in command printing that output the wrong default file + descriptor for the <> redirection. + +k. User-specified subshells (`(...)') now update BASH_COMMAND in the subshell. + +l. Fixed a display bug with the `help -m' and loadable builtins. + +m. Fixed a potential file descriptor leak when trying to use a pipe for a + here document. + +n. Fix a bug with multiple assignment statements preceding a simple command + containing nofork comsubs. + +o. Fix a potential bug that could result in a NULL buffered stream even with + a valid input file descriptor. + +2. Changes to Readline + +a. Fixed a bug that allowed a history search to change the current history + list position. + +b. Fixed a bug that allowed ^G to retain a saved command to execute. + +c. Updates to new export-completions command to allow filename suffixes. + +d. Fixed a redisplay bug with prompts containing multiple sequences of + invisible characters that are longer than the screen width. + +3. New Features in Bash + +a. There is a new `fltexpr' loadable builtin to perform floating-point + arithmetic similarly to `let'. + +4. New Features in Readline + +a. Readline can reset its idea of the screen dimensions when executing after + a SIGCONT. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-5.3-beta, and +the previous version, bash-5.3-alpha. + +1. Changes to Bash + +a. Per POSIX, a null pathname argument to `cd' is now an error. + +b. Fixes for command completion when the directory portion of the pathname + contains characters that require quoting. + +c. Fix to prevent redirections from undergoing word expansion twice. + +d. Fix for rare parsing issue with for loops where a newline appears before + `in'. + +e. The bash build process now assumes a C90 compilation environment and a + POSIX.1-1990 execution environment. + +f. Fixed a bug where bash's internal redirection flags could collide with + the system's open/fcntl flags. + +g. Fixed a problem with `jobs' run from a trap or `bind -x' command printing + the status of terminated foreground jobs. + +h. Bash works around a macOS gettext bug with translating the `command not + found' message by caching the translated string. + +i. Bash does not try to set the tty state after a process finishes if it is + running a trap, running a readline key binding (bind -x), or executing a + programmable completion. + +j. Restricted shells are not allowed to run `enable -f', even when it's + shorthand from `enable f'. + +k. Work around an android problem with file descriptors if the read builtin + gets both -u and -e. + +l. Fixed some small memory leaks in bash completion and command parsing and + execution. + +m. Fix for crash when timed commands jump back to the top level after SIGINT. + +n. Minor fixes for command substitution parsing in the foreground. + +o. Fix to reset read builtin buffer after SIGINT. + +p. Fix for inconsistency between arrays and scalar variables when declaring + local variables and using values from previous variable contexts. + +q. Bash doesn't try to give the terminal back to the original process group + after running a trap unless job control is enabled. + +r. Fix to inhibit fork optimizations in functions that set a RETURN trap. + +s. Fixes for parsing commands within process substitutions where they should + behave differently than command substitutions, including prohibiting the + special case for redirections that is only available for command + substitutions. + +t. Restrict the effect of force_fignore to the cases where FIGNORE should + affect completions. + +u. Fix for `read' builtin and invalid multibyte characters that contain the + delimiter character, so the delimiter acts as intended. + +v. Fix for `read -e' so it restores the correct completion function if it's + interrupted. + +w. Fix an off-by-one error when parsing an improperly-formed printf time + specification. + +x. Fix for return status for commands whose return status is being inverted + when set -e is ignored. + +y. Fix for checking `read' builtin timeouts after we check for having read + the delimiter. + +z. Fixes for integer overflows and size_t variables. + +aa. Fixes for the Makefiles to simplify, remove some unused variables, and + clean up what `git' sees after running the various clean targets. + +bb. Fix for the `exec' builtin to avoid duplicate error messages. + +cc. `printf' now warns if there are no valid characters at all in an integer + argument. + +2. Changes to Readline + +a. Make sure the bracketed-paste input buffer is null-terminated when read + returns an error. + +b. Fixed a small memory leak in execute-named-command if the command doesn't + exist or the function doesn't return. + +c. Fix for attempting to change case of invalid multibyte characters. + +d. Fix for possible completions that compare identically when using case- + insensitive completion but have different byte lengths. + +e. Fix to make non-incremental searches use undo lists and set the history + position the same way as incremental searches. + +f. Don't check for signals when handling a received signal. + +g. Fix off-by-one error when tokenizing words like $((expr)) while performing + history expansion. + +h. Fixes for incremental searches and redisplay in the C locale. + +i. Fixes for some use-after-free of the undo list errors when stacking multiple + commands that use rl_maybe_replace_line to save changes to a history entry. + +j. Fixes to ensure that completion-prefix-display-length and + colored-completion-prefix are mutually exclusive. + +3. New Features in Bash + +a. MULTIPLE_COPROCS is now enabled by default. + +b. The `bind' builtin interprets additional non-option arguments after -p or + -P as bindable command names and restricts output to the bindings for + those names. + +c. Bash now uses the login shell for $BASH if the shell is named `su' or `-su'. + +d. Bash now prints job notifications if an interactive shell is running a trap, + even though the shell is not interactive at that moment. + +e. Programmable completion allows a new compspec loaded after a completion + function returns 124 to be used in more cases. + +f. ./source has a new -p PATH option, which makes it use the PATH argument + instead of $PATH to look for the file. + +g. GLOBSORT has a new `numeric' sort specifier, which sorts all-digit strings + as numbers. + +h. Documentation has been significantly updated. + +i. `wait -n' can now return terminated process substitutions, jobs about + which the user has already been notified (like `wait' without options), + +j. `wait -n' removes jobs from the jobs table or list of terminated children + when in posix mode. + +k. Changed the `wait' builtin behavior regarding process substitutions to + match the documentation. + +l. There is a new `bash_source_fullpath' shopt option, which makes bash put + full pathnames into BASH_SOURCE, and a way to set a default value for it + at configure time. + +m. Posix mode now forces job notifications to occur when the new edition of + POSIX specifies (since it now specifies them). + +n. Interactive shells don't print job notifications while sourcing scripts. + +o. The parser prints more information about the command it's trying to parse + when it encounters EOF before completing the command. + +p. Posix mode no longer requires function names to be valid shell identifiers. + +q. If `exit' is run in a trap and not supplied an exit status argument, it + uses the value of $? from before the trap only if it's run at the trap's + `top level' and would cause the trap to end (that is, not in a subshell). + This is from Posix interp 1602. + +4. New Features in Readline + +a. Documentation has been significantly updated. + +b. New `force-meta-prefix' bindable variable, which forces the use of ESC as + the meta prefix when using "\M-" in key bindings instead of overloading + convert-meta. + +c. The default value for `readline-colored-completion-prefix' no longer has a + leading `.'; the original report was based on a misunderstanding. + +d. There is a new bindable command, `export-completions', which writes the + possible completions for a word to the standard output in a defined format. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-5.3-alpha, and +the previous version, bash-5.2-release. + +1. Changes to Bash + +a. Stop checking for new mail if an interactive shell is in the middle of + programmable completion or readline command dispatching. + +b. Changes to multibyte character translation to handle shift states better. + +c. Fixed a bug with subshell command execution that caused it to set LINENO + incorrectly. + +d. Fixed a bug that caused some array subscript references in arithmetic + expansions to seg fault. + +e. Don't report on foreground jobs that we won't notify the user about if + jobs is run from a trap handler or a `bind -x' command. + +f. Fixed a bug where temporarily turning on `extglob' while parsing a command + substitution in compatibility mode could leave it set. + +g. Fixed a bug where nested word expansions confused the state parser and + resulted in quotes being required where they should not have been. + +h. Fixed a bug where nested function definitions resulted in `display -F' + printing incorrect line numbers. + +i. Fixed the message printed when the shell gets ENOENT from execve: specific + message about a bad interpreter before the generic error message. + +j. Fixed a spurious debug message when errexit is set and the shell is + exiting from an eval command in a shell function. + +k. Fixed a bug where a pending signal would cause pattern matching to fail in + an exit trap. + +l. Fixed a crash caused by a null replacement string in pattern replacement. + +m. Fixed a bug in interactive shells where a SIGINT received while parsing a + command substitution would leave the expand_aliases option disabled. + +n. Fixed a bug with command printing when printing multiple shell functions + with here-documents inside a command substitution. + +o. Fixed a bug with expanding aliases while parsing command substitutions + inside another word expansion. + +p. Fixed a bug with alias expansion in posix mode in an eval command inside a + command substitution. + +q. Fixed a bug that caused the parser not to reset correctly if it encountered + a syntax error while trying to read a WORD token. + +r. Fixed a bug that caused `<(' and `>(' to trigger process substitution inside + an arithmetic expression. + +s. Fixed a bug that caused the shell to unlink FIFOs used for process + substitution before a compound command completes. + +t. Fixed a bug that caused the read builtin to not recognize some negative + fractional arguments. + +u. Fixed a bug that caused subshells not to run the EXIT trap if a signal + arrived after the command and before returning to the caller. + +v. Fixed a bug where `wait' without arguments could wait for inherited + process substitutions, which are not children of this shell. + +w. Fixed a bug with expanding $* in a here-document body. + +x. Fixed a bug where `declare -p' in a shell function would show the wrong + command for `local -'. + +y. Change for POSIX interpretation 1602 about the default return status for + `return' in a trap command. + +z. Fixed a bug that caused double evaluation of a dynamic variable like + $RANDOM when using certain parameter expansions. + +aa. Fixed a bug where `read -e -t' would cause an interactive shell to exit. + +bb. Fixed a number of bugs with pathname expansion/pattern matching and + slashes in bracket expressions. + +cc. Fixed several bugs with optimizing out forks. + +dd. Fixed a memory leak when referencing unset associative array elements. + +ee. System-specific changes for: WIN32 + +ff. Perform more cleanup if the shell exceeds maximum function nesting level. + +gg. Fixed a bug that caused `eval' to run the ERR trap in commands where it + should not. + +hh. Fixed nameref expansion where nameref values are valid length expansion + expressions but invalid identifiers. + +ii. Fixed an error that caused syntax errors when expanding nested word + expansions inside a here-document. + +jj. POSIX special builtins now exit the shell in posix mode on more failure + cases. + +kk. Brace expansion is interruptible at more spots, so long expansions can + be interrupted more quickly. + +ll. Fixed a crash caused by running `set -o emacs' in `bash -c command'. + +mm. Fixed a bug that caused bash to reset the terminal process group before + a command exited if it received a SIGINT in a non-interactive shell. + +nn. Significant changes to the source code to make it C23-conformant, including + C23 undefined behavior. + +oo. Treat read(2) errors while reading input as immediately fatal errors + instead of the traditional EOF; POSIX interp 1629 + +pp. Fix to allow asynchronous commands to use `trap' to reset signals that + are ignored during the command; POSIX interp 751. + +qq. Fix a posix-mode bug with alias expansion when checking for reserved + words and the previous alias expansion ends with a space. + +rr. Programmable completion now creates empty elements in COMP_WORDS if the + cursor is on whitespace just preceding a word. + +ss. Fixed a bug that prevented aliases ending with a space from alias + expanding the next word if more than two aliases are expanded from a + single word. + +tt. Fixed a bug that caused the shell to give the terminal to the shell's + process group when reaping a background job. + +uu. Command printing is more consistent when to print `function' before a + shell function name. + +vv. Fixed a bug that caused unset not to remove a function named a[b] if + there was no array variable a. + +ww. Posix mode doesn't perform function lookup for function names containing + a slash. + +xx. <( and >( can now be used in function names. [CHANGE REMOVED] + +yy. Fixed a bug that caused tilde expansion not to be performed on some + array subscripts. + +zz. Fixed key-value pair associative array assignment to be more consistent + with compound array assignment, and indexed array assignment (a=(zero one)) + to be more consistent with explicitly assigning indices one by one. + +aaa. In posix mode, extra arguments to `fc' are now an error. + +bbb. The bash readline commands that perform history and alias expansion try + to place point closer to where it was in the unexpanded line. + +ccc. Fixed multiple invocations of `local -' in the same shell function to + have the same effect as one. + +ddd. Don't export $_ if allexport is set. + +eee. Don't add extra newlines to the history if parsing a delimited construct. + +fff. Dynamically-loaded builtins cannot have slashes in their names, since + they'll never be called. + +ggg. Fixed a bug that could cause reading EOF while parsing a quoted string + to terminate the shell. + +hhh. Fixed a bug that caused local variables with the same name as variables + in `declare's temporary environment to be propagated back to the caller. + +iii. Don't try to perform brace expansion on assignment statements in compound + assignments. + +jjj. Fixed a bug that could cause a crash while evaluating an arithmetic for + command if one of the expressions expands to NULL. + +kkk. In posix mode, cd tries to change to what the user typed if the + canonicalized version of that pathname is longer than PATH_MAX. + +lll. Fixes for some errors revealed by address sanitizer. + +mmm. If fork(2) fails, kill the current pipeline processes with SIGKILL after + SIGTERM, in case they're ignoring SIGTERM. + +nnn. Fix to adding command substitutions to history to avoid adding semicolons + where they shouldn't be. + +ooo. Programmable completion and compgen honor the setting of `dotglob'. + +ppp. Use gettimeofday(2) to get time information instead of using time(3). + +qqq. Save and restore readline variables affecting filename completions in + case someone runs `compgen' in the foreground. + +rrr. Treat the failure to open file in $(&- so it doesn't silently close stdin if var is not a number. + +uuu. Follow namerefs in ${name=word} so the shell can implement the POSIX + semantics of returning "the final value of parameter." + +vvv. Bash performs better nameref loop detection in several lookup cases. + +www. SIGINT will now break out of loops if a process executed in the loop dies + due to SIGINT, not just if the loop body is a list. This is no longer + dependent on the compatibility level. + +xxx. FIGNORE suffixes can now match the entire pathname, like tcsh, instead + of requiring a non-empty prefix. + +yyy. Fix bug that caused FUNCNAME not to be reset after a parse error with + compound assignments to local variables. + +zzz. Fix bug that caused `jobs' not to remove jobs from the list in a SIGCHLD + trap. + +aaaa. Fix bug that caused `ignoreeof' to be ignored if EOF is read at a + secondary prompt or while parsing a command substitution. + +bbbb. Fixes to removing jobs from the jobs table when the user isn't notified; + has effects of fixing issues with `wait -n' not finding jobs. + +cccc. Fixes to loadable builtin processing so that we never pass a null + pathname or try to load a builtin that's not found if the -n option is + supplied. + +dddd. Work around system-specific problems (macOS) where isblank(3) returns + true for characters >= 0x80 in a UTF-8 locale. + +eeee. Fix for crash while parsing alias expansions that include compound + assignments. + +ffff. Fixe for non-interactive shells reading a script file that ends with + backslash preceding EOF. + +gggg. Fix to command printing when here-documents are attached to compound + commands in lists. + +hhhh. Fix bug with sourcing `files' created by process substitutions inside + a `.' script. + +iiii. Fixes to declare builtin to treat arguments to declare -f that look like + assignment statements or array references as function names. + +jjjj. Fixed a variable conversion problem when exporting a variable in the + temporary environment back to the calling scope. + +kkkk. BASH_REMATCH can now be a local variable. + +llll. Subshell commands clear process substitutions so anything created by a + redirection doesn't affect the subshell. + +mmmm. Fixes for several small memory leaks. + +nnnn. The shell simply ignores attempts to assign to `noassign' variables + instead of treating them as an assignment error and possibly causing + the shell to exit. + +oooo. If the cd builtin uses $OLDPWD, allow it to use $CDPATH if the user has + set it to something that's not a full pathname. + +pppp. The test builtin only supports the optional argument to -t if parsing + an expression with more than four arguments and not in posix mode. + +qqqq. Changes to filename quoting and rewriting to deal with NFC and NFD + Unicode forms (primarily for macOS). + +rrrr. Send SIGCONT to a job we've just restarted with fg or bg, even if we + think it's already running. + +ssss. Fixes for setting the line number associated with a simple command. + +tttt. Many changes for integer overflow and out-of-range arguments to printf. + +uuuu. Fixes for the read builtin and unescaped backslashes preceding NULs or + the end of the input. + +vvvv. The -[anrw] options to the history builtin should have no effect if + HISTFILE is unset or null. + +wwww. If programmable completion uses something different than what the user + typed as the command name (full pathname, alias, etc.), display what's + actually used in `compopt' output. + +xxxx. Fix bug with closing /dev/fd process substitutions in shell functions. + +yyyy. Fix bug with `declare -g' trying to convert a global associative array + to an indexed array. + +zzzz. Fix bash history expansion characters so we don't get empty history + events. + +aaaaa. Allow `time' and `!' reserved words to be followed by `&', which POSIX + interp 267 says is required. + +bbbbb. Upgrade intl library to the one from gettext-0.21.1. + +ccccc. Fix line number in the event that a simple command jumps back to the + top level on error. + +ddddd. Make the order of setting BASH_COMMAND, running the DEBUG trap, and + printing PS4 consistent across all command types. + +eeeee. Rely on child processes to set the terminal process group instead of + having the parent do it as well. + +fffff. Fix `printf' to consume entire multibyte characters in the format string, + in case the encoding contains `/' or `%'. + +ggggg. Fix `hash' to return 1 if -d is supplied and the hash table is empty. + +hhhhh. Fix `select' command to be like `for' in that an invalid selection + variable is a fatal error in posix mode. + +iiiii. Fix to parameter length expansion to avoid expanding dynamic variables + (e.g., RANDOM) more than once. + +jjjjj. Fix to `shift', `break', and `continue' to skip over a `--' when + printing an invalid argument error message. + +kkkkk. Fix bug that caused an invalid arithmetic expression in an arithmetic + `for' command to leave the loop level set to the wrong value, preventing + `break' and `continue' from working. + +lllll. Fix problem with removing escapes in the `E' variable transformation. + +mmmmm. Fix bug with word splitting if `read' assigns to IFS. + +nnnnn. Fix posix-mode cases where failure of special builtins did not cause + the shell to exit. + +ooooo. Some fixes to cases where the shell quotes characters that are special + internally. + +ppppp. Fix error with read builtin trying to assign to a readonly variable. + +qqqqq. Fix a slight race condition when bash receives a SIGINT while waiting + for a foreground job. + +rrrrr. Fix integer parsing to accept more whitespace characters after the + digit string -- the same ones we accept before the digits. + +sssss. Fix a crash when attempting to brace-expand a very large list of + strings fails. + +ttttt. Fix dynamic loading of builtins not to look in the current directory + if looking in BASH_LOADABLES_PATH is not successful, like $PATH + searching. + +uuuuu. Fix `bind -x' commands to understand negative argument counts. + +vvvvv. Disable fork optimization if the shell is running startup files because + SSH_SOURCE_BASHRC was enabled; prevents infinite recursion. + +wwwww. Fix `unset' builtin to implement POSIX interp 1009, which says that + unsetting a variable in the temporary environment unsets the variable + in the enclosing scope also, in posix mode. + +xxxxx. Fix parser to read here-document body from the current alias, if that's + where input is being read from. + +yyyyy. Fix an off-by-one error that caused completion to fail for certain + pathnames containing backslash-quoted single-quotes. + +zzzzz. Fix command printing to print a coproc name only if the coproc command + is not a simple command. + +aaaaaa. Fix prompt string decoding to preserve the value of $_. + +bbbbbb. In posix mode, supplying a non-identifier as a function name to `export' + or `readonly' should cause the shell to exit, since these are special + builtins. + +cccccc. Fix a crash that happens due to accessing freed memory if the parser + encounters a syntax error while parsing an alias or a compound + assignment. + +dddddd. Fix a bug that could cause errors while executing a DEBUG trap in a + pipeline. + +eeeeee. Fix a bug where exiting a subshell should not try to restore the + terminal settings if that subshell didn't reinitialize them. + +ffffff. Remove long-lived workaround for old AFS bug that causes problems with + modern implementations. + +gggggg. Fix a bug that caused an assignment error to BASHOPTS or SHELLOPTS to + remove the variable's readonly attribute. + +hhhhhh. Fix for a crash if a pathname argument to `cd' is NULL and the current + directory has been removed. + +iiiiii. Fix a bug with shell-expand-line readline command that caused it to + interpret quoted single quotes incorrectly when inside $'...'. + +jjjjjj. Fix to the declare builtin to catch more invalid option combinations. + +kkkkkk. Fix to avoid unsafe execution of the EXIT trap if a terminating signal + arrives while bash is waiting for a foreground process. + +llllll. Fixed a bug that allowed attribute changes to readonly variables that + changed the effects of attempted assignments. + +mmmmmm. Fix bug that caused quoting errors if $* was expanded in a context + where word splitting was not performed. + +oooooo. Fix bug that caused declare commands with `-' and `+' options and an + assignment statement to be misinterpreted. + +pppppp. Retry opening startup files if the open is interrupted by a signal + and is not automatically restarted. + +qqqqqq. Fix printing a case command where one of the case command lists begins + with the word `esac'. + +rrrrrr. Fix for history and command number expansion when expanding a prompt + string that contains the @P variable transformation. + +ssssss. Fix a bug that could cause the shell to hang if a script used multiple + coprocesses without manually closing file descriptors associated with + existing coprocesses. + +2. Changes to Readline + +a. Fixed a bug in clearing the visible line structure before redisplay. + +b. Fix a bug where setlocale(3) returning NULL caused a crash. + +c. Fixed signal checking in callback mode to handle signals that arrive before + readline restores the application's signal handlers. + +d. Fixed a bug with word completion where the directory name needs to be + dequoted and tilde-expanded. + +e. Fixed a bug that caused compilation to fail on systems with select but not + pselect. + +f. System-specific changes for: WIN32, z/OS, Cygwin, MSYS + +g. Fixed a bug that caused word completion mismatches if the quoted text the + user typed was longer than the unquoted match. + +h. Fixes for freeing undo lists that might appear in history list entries + after non-incremental searches. + +i. Fixes for some errors revealed by address sanitizer. + +j. In vi mode, if an `f' or `F' move command associated with a `c' or `C' + command fails, don't enter insert mode. + +k. Fixed bug with truncating a history file containing timestamps that caused + the timestamp associated with the first history entry not to be written. + +l. Fix vi-mode so that a motion command attached to d/D, y/Y, or t/T must + consume or delete at least one character. + +m. Fix a redisplay error when displaying meta characters as octal sequences + and other C locale issues. + +n. Fix error that caused characters composing an incomplete multibyte + character not to be inserted into the line. + +o. In callback mode, let the application echo the signal characters (e.g., ^C) + when the application's signal handlers are installed. + +p. Added some support for lines that consume more than the physical number of + screen lines. + +q. Make sure dump-variables returns the string values for active-region-start-color + and active-region-end-color if they're set. + +r. Fixes to how characters between 128 and 159 are printed when displaying + macro values (use symbolic notation instead of directly printing the + character). + +s. Don't convert meta characters that contain NULL (\M-\C-@) to actual NULs, + which prematurely terminates the macro value. + +t. Fix typo in the readline color prefix extension that it uses for coloring + filename prefixes when displaying possible completions. + +u. Call the filename rewrite hook on the word being completed before comparing + it against possible completions from the file system to get consistent + strings. + +v. Fix infinite recursion that can happen if someone binds a key that doesn't + have a different upper and lower case representation to do-lowercase-version. + +w. Check for non-ANSI (dumb) terminals a little more thoroughly. + +x. Don't attempt to history-expand the `quick substitution' character at the + beginning of a line if the application has set the quoting state to single + quotes. + +y. Fix small memory leak if non-incremental or incremental search is + interrupted by a signal. + +z. Loading very large history files should be much faster. + +aa. Retry opening startup files if the open is interrupted by a signal + and is not automatically restarted. + +3. New Features in Bash + +a. When checking whether a script file argument is a binary file, check the + first two lines of a script if the first line begins with `#!'. + +b. Bash does a better job of preserving user-supplied quotes around a word + completion, instead of requoting it. + +c. Bash reports the starting line number in an error message about an + unterminated compound command like `if' without a `fi'. + +d. Implement the POSIX requirement that running the `jobs' builtin removes + jobs from the jobs list. + +f. Call bash signal handlers while executing programmable completion commands, + instead of readline's. + +g. Print an error message if a regular expression used with [[ fails to compile. + +h. The `umask' builtin now has additional features for full POSIX conformance. + +i. `type -a -P' reports both hashed pathnames and the result of a $PATH search. + +j. `trap' has a new -P option that prints the trap action associated with each + signal argument. + +k. The `command' builtin preceding a declaration builtin (e.g., `declare') + preserves the special assignment statement parsing for the declation + builtin. This is a new POSIX requirement. + +l. `printf' uses the `alternate form' for %q and %Q to force single quoting. + +m. `printf' now interprets %ls (%S) and %lc (%C) as referring to wide strings + and characters, respectively, when in a multibyte locale. + +n. The shell can be compiled with a different default value for the + patsub_replacement option. + +o. Check for window size changes during trap commands, `bind -x' commands, + and programmable completion. + +p. Treat a NULL value for $PATH as equivalent to ".". + +p. New loadable builtins: kv, strptime + +q. GLOBSORT: new variable to specify how to sort the results of pathname + expansion (name, size, blocks, mtime, atime, ctime, none) in ascending + or descending order. + +r. `compgen' has a new option: -V varname. If supplied, it stores the generated + completions into VARNAME instead of printing them on stdout. + +s. New form of command substitution: ${ command; } or ${|command;} to capture + the output of COMMAND without forking a child process and using pipes. + +t. array_expand_once: new shopt option, replaces assoc_expand_once + +u. complete/compopt new option: fullquote; sets rl_full_quoting_desired so all + possible completions are quoted as if they were filenames. + +v. Command timing now allows precisions up to 6 digits instead of 3 in + $TIMEFORMAT. + +w. BASH_MONOSECONDS: new dynamic variable that returns the value of the + system's monotonic clock, if one is available. + +x. BASH_TRAPSIG: new variable, set to the numeric signal number of the trap + being executed while it's running. + +y. The checkwinsize option can be used in subshell commands started from + interactive shells. + +z. In posix mode, the test command < and > binary primaries compare strings + using the current locale. + +aa. bind -x allows new key binding syntax: separate the key sequence and the + command string with whitespace, but require the command string to be + double-quoted if this is used. This allows different quoting options for + the command string. + +bb. Print commands bound to key sequences using `bind -x' with the new key + binding syntax it allows. + +cc. `read' has a new `-E' option to use readline but with the default bash + completion (including programmable completion). + +dd. New bindable readline command name: `bash-vi-complete'. + +ee. New test builtin behavior when parsing a parenthesized subexpression and + test was given more than 4 arguments: scan forward for a closing paren and + call posixtest() if there are 4 or fewer arguments between the parentheses. + Added for compatibility with coreutils test, dependent on the shell + compatibility level. Such expressions remain ambiguous. + +4. New Features in Readline + +a. Output a newline if there is no prompt and readline reads an empty line. + +b. The history library falls back to stdio when writing the history list if + mmap fails. + +c. New bindable variable `search-ignore-case', causes readline to perform + case-insensitive incremental and non-incremental history searches. + +d. rl_full_quoting_desired: new application-settable variable, causes all + completions to be quoted as if they were filenames. + +e. rl_macro_display_hook: new application-settable function pointer, used if + the application wants to print macro values itself instead of letting + readline do it + +f. rl_reparse_colors: new application-callable function, reparses $LS_COLORS + (presumably after the user changes it) + +g. rl_completion_rewrite_hook: new application-settable function pointer, + called to modify the word being completed before comparing it against + pathnames from the file system. + +h. execute-named-command: a new bindable command that reads the name of a + readline command from the standard input and executes it. Bound to M-x + in emacs mode by default. + +i. Incremental and non-incremental searches now allow ^V/^Q (or, in the former + case, anything bound to quoted-insert) to quote characters in the search + string. + +j. There is a new rl_print_keybinding function that prints the key bindings + for a single bindable function specified by name. +------------------------------------------------------------------------------ This document details the changes between this version, bash-5.2-release, and the previous version, bash-5.2-rc4. @@ -1063,7 +1998,7 @@ n. The `test -N' operator uses nanosecond timestamp granularity if it's available. o. Bash posix mode now treats assignment statements preceding shell function - definitions the same as in its default mode, since POSIX has changed and + calls the same as in its default mode, since POSIX has changed and no longer requires those assignments to persist after the function returns (POSIX interp 654). diff --git a/COMPAT b/COMPAT index 9fda7fb8f..d64cb33b6 100644 --- a/COMPAT +++ b/COMPAT @@ -2,13 +2,13 @@ Compatibility with previous versions ==================================== This document details the incompatibilities between this version of bash, -bash-5.2, and the previous widely-available versions, bash-3.2 (which is +bash-5.3, and the previous widely-available versions, bash-3.2 (which is still the `standard' version for Mac OS X), 4.2/4.3 (which are still -standard on a few Linux distributions), and bash-4.4/bash-5.0/bash-5.1, -the current widely-available versions. These were discovered by users of -bash-2.x through 5.x, so this list is not comprehensive. Some of these -incompatibilities occur between the current version and versions 2.0 and -above. +standard on a few Linux distributions), and bash-4.4 and +bash-5.0/bash-5.1/bash-5.2, the current widely-available versions. +These were discovered by users of bash-2.x through 5.x, so this list is not +comprehensive. Some of these incompatibilities occur between the current +version and versions 2.0 and above. 1. Bash uses a new quoting syntax, $"...", to do locale-specific string translation. Users who have relied on the (undocumented) @@ -315,118 +315,126 @@ above. string if there is not enough input. Previous versions discarded the characters read. -41. Beginning with bash-4.0, when one of the commands in a pipeline is killed - by a SIGINT while executing a command list, the shell acts as if it - received the interrupt. This can be disabled by setting the compat31 or - compat32 shell options. - -42. Bash-4.0 changes the handling of the set -e option so that the shell exits +41. Bash-4.0 changes the handling of the set -e option so that the shell exits if a pipeline fails (and not just if the last command in the failing pipeline is a simple command). This is not as Posix specifies. There is work underway to update this portion of the standard; the bash-4.0 behavior attempts to capture the consensus at the time of release. -43. Bash-4.0 fixes a Posix mode bug that caused the . (source) builtin to +42. Bash-4.0 fixes a Posix mode bug that caused the . (source) builtin to search the current directory for its filename argument, even if "." is not in $PATH. Posix says that the shell shouldn't look in $PWD in this case. -44. Bash-4.1 uses the current locale when comparing strings using the < and +43. Bash-4.1 uses the current locale when comparing strings using the < and > operators to the `[[' command. This can be reverted to the previous behavior (ASCII collating and strcmp(3)) by setting one of the `compatNN' shopt options, where NN is less than 41. -45. Bash-4.1 conforms to the current Posix specification for `set -u': +44. Bash-4.1 conforms to the current Posix specification for `set -u': expansions of $@ and $* when there are no positional parameters do not cause the shell to exit. -46. Bash-4.1 implements the current Posix specification for `set -e' and +45. Bash-4.1 implements the current Posix specification for `set -e' and exits when any command fails, not just a simple command or pipeline. -47. Command substitutions now remove the caller's trap strings when trap is +46. Command substitutions now remove the caller's trap strings when trap is run to set a new trap in the subshell. Previous to bash-4.2, the old trap strings persisted even though the actual signal handlers were reset. -48. When in Posix mode, a single quote is not treated specially in a +47. When in Posix mode, a single quote is not treated specially in a double-quoted ${...} expansion, unless the expansion operator is # or % or the new `//', `^', or `,' expansions. In particular, it does not define a new quoting context. This is from Posix interpretation 221. -49. Posix mode shells no longer exit if a variable assignment error occurs +48. Posix mode shells no longer exit if a variable assignment error occurs with an assignment preceding a command that is not a special builtin. -50. Bash-4.2 attempts to preserve what the user typed when performing word +49. Bash-4.2 attempts to preserve what the user typed when performing word completion, instead of, for instance, expanding shell variable references to their value. -51. When in Posix mode, bash-4.2 exits if the filename supplied as an argument +50. When in Posix mode, bash-4.2 exits if the filename supplied as an argument to `.' is not found and the shell is not interactive. -52. When compiled for strict Posix compatibility, bash-4.3 does not enable +51. When compiled for strict Posix compatibility, bash-4.3 does not enable history expansion by default in interactive shells, since it results in a non-conforming environment. -53. Bash-4.3 runs the replacement string in the pattern substitution word +52. Bash-4.3 runs the replacement string in the pattern substitution word expansion through quote removal. The code already treats quote characters in the replacement string as special; if it treats them as special, then quote removal should remove them. -54. Bash-4.4 no longer considers a reference to ${a[@]} or ${a[*]}, where `a' +53. Bash-4.4 no longer considers a reference to ${a[@]} or ${a[*]}, where `a' is an array without any elements set, to be a reference to an unset variable. This means that such a reference will not cause the shell to exit when the `-u' option is enabled. -55. Bash-4.4 allows double quotes to quote the history expansion character (!) +54. Bash-4.4 allows double quotes to quote the history expansion character (!) when in Posix mode, since Posix specifies the effects of double quotes. -56. Bash-4.4 does not inherit $PS4 from the environment if running as root. +55. Bash-4.4 does not inherit $PS4 from the environment if running as root. -57. Bash-4.4 doesn't allow a `break' or `continue' in a function to affect +56. Bash-4.4 doesn't allow a `break' or `continue' in a function to affect loop execution in the calling context. -58. Bash-4.4 no longer expands tildes in $PATH elements when in Posix mode. +57. Bash-4.4 no longer expands tildes in $PATH elements when in Posix mode. -59. Bash-4.4 does not attempt to perform a compound array assignment if an +58. Bash-4.4 does not attempt to perform a compound array assignment if an argument to `declare' or a similar builtin expands to a word that looks like a compound array assignment (e.g. declare w=$x where x='(foo)'). -60. Bash-5.0 only sets up BASH_ARGV and BASH_ARGC at startup if extended +59. Bash-5.0 only sets up BASH_ARGV and BASH_ARGC at startup if extended debugging mode is active. The old behavior of unconditionally setting BASH_ARGC and BASH_ARGV is available at compatibility levels less than or equal to 44. -61. Bash-5.0 doesn't allow a `break' or `continue' in a subshell to attempt +60. Bash-5.0 doesn't allow a `break' or `continue' in a subshell to attempt to break or continue loop execution inherited from the calling context. -62. Bash-5.0 doesn't allow variable assignments preceding builtins like +61. Bash-5.0 doesn't allow variable assignments preceding builtins like export and readonly to modify variables with the same name in preceding contexts (including the global context) unless the shell is in posix mode, since export and readonly are special builtins. -63. Bash-5.1 changes the way posix-mode shells handle assignment statements +62. Bash-5.1 changes the way posix-mode shells handle assignment statements preceding shell function calls. Previous versions of POSIX specified that such assignments would persist after the function returned; subsequent versions of the standard removed that requirement (interpretation #654). Bash-5.1 posix mode assignment statements preceding shell function calls do not persist after the function returns. -64. Bash-5.1 reverts to the bash-4.4 treatment of pathname expansion of words +63. Bash-5.1 reverts to the bash-4.4 treatment of pathname expansion of words containing backslashes but no other special globbing characters. This comes after a protracted discussion and a POSIX interpretation (#1234). -65. In bash-5.1, disabling posix mode attempts to restore the state of several +64. In bash-5.1, disabling posix mode attempts to restore the state of several options that posix mode modifies to the state they had before enabling posix mode. Previous versions restored these options to default values. -66. Bash-5.2 attempts to prevent double-expansion of array subscripts under +65. Bash-5.2 attempts to prevent double-expansion of array subscripts under certain circumstances, especially arithmetic evaluation, by acting as if the `assoc_expand_once' shell option were set. -67. The `unset' builtin in bash-5.2 treats array subscripts `@' and `*' +66. The `unset' builtin in bash-5.2 treats array subscripts `@' and `*' differently than previous versions, and differently depending on whether the array is indexed or associative. +67. The `test' builtin in bash-5.3 treats parenthesized subexpressions when + given more than four arguments differently. It scans forward for a + closing paren and counts the number of arguments between the parens. If + there are four or fewer, it uses the posix test algorithm on the + subexpression. + +68. The bind builtin's -p and -P options treat any arguments remaining after + option processing as bindable command names for which to print any key + bindings. + +69. Interactive shells will notify the user of completed jobs while sourcing + a script. Newer versions defer notification until script execution + completes. Shell Compatibility Level ========================= @@ -485,10 +493,6 @@ compat31 compat32 - the < and > operators to the [[ command do not consider the current locale when comparing strings; they use ASCII ordering - - interrupting a command list such as "a ; b ; c" causes the execution - of the next command in the list (in bash-4.0 and later versions, - the shell acts as if it received the interrupt, so interrupting - one command in a list aborts the execution of the entire list) compat40 - the < and > operators to the [[ command do not consider the current @@ -516,10 +520,6 @@ compat42 single quotes are not special within double-quoted word expansions compat43 - - the shell does not print a warning message if an attempt is made to - use a quoted compound assignment as an argument to declare - (declare -a foo='(1 2)'). Later versions warn that this usage is - deprecated. - word expansion errors are considered non-fatal errors that cause the current command to fail, even in posix mode (the default behavior is to make them fatal errors that cause the shell to exit) @@ -588,6 +588,14 @@ compat51 (set using BASH_COMPAT) expansion time if extglob hasn't been enabled by the time the command is executed. +compat52 (set using BASH_COMPAT) + - the test builtin uses its historical algorithm for parsing + expressions composed of five or more primaries. + - the -p and -P options to the bind builtin treat remaining arguments + as bindable command names for which to print any key bindings + - interactive shells will notify the user of completed jobs while + sourcing a script. Newer versions defer notification until script + execution completes. ------------------------------------------------------------------------------- Copying and distribution of this file, with or without modification, diff --git a/CWRU/PLATFORMS b/CWRU/PLATFORMS deleted file mode 100644 index f05caff56..000000000 --- a/CWRU/PLATFORMS +++ /dev/null @@ -1,31 +0,0 @@ -The version of bash in this directory has been compiled on the -following systems: - -By chet: - -SunOS 4.1.4 -SunOS 5.5 -BSDI BSD/OS 2.1 -FreeBSD 2.2 -NetBSD 1.2 -AIX 4.2 -AIX 4.1.4 -HP/UX 9.05, 10.01, 10.10, 10.20 -Linux 2.0.29 (libc 5.3.12) -Linux 2.0.4 (libc 5.3.12) - -By other testers: - -SCO ODT 2.0 -SCO 3.2v5.0, 3.2v4.2 -SunOS 5.3 -SunOS 5.5 -BSD/OS 2.1 -FreeBSD 2.2 -SunOS 4.1.3 -Irix 5.3 -Irix 6.2 -Linux 2.0 (unknown distribution) -Digital OSF/1 3.2 -GNU Hurd 0.1 -SVR4.2 diff --git a/CWRU/changelog b/CWRU/changelog index da6d4aa1c..a868dc5c5 100644 --- a/CWRU/changelog +++ b/CWRU/changelog @@ -1,4 +1,3 @@ - 12/6/2020 --------- @@ -3950,3 +3949,7342 @@ lib/readline/history.c 9/23 ---- [bash-5.2 frozen] + + 9/26 + ---- +[bash-5.2 released] + + 9/27 + ---- +mailcheck.c + - time_to_check_mail: don't bother if we're in the middle of readline + completion or command dispatching. + From https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1019462 + +lib/readline/display.c + - rl_forced_update_display: use memset to clear out visible_line + instead of trying to use a loop; line_size is the size. + Report from + +print_cmd.c + - indirection_level_string: use MBRLEN and an initialized mbstate_t + object to avoid altering an internal mbstate_t. + From Koichi Murase + +subst.c + - string_extract_verbatim: use an explicit mbstate_t object and pass + it to MBRLEN and mbrtowc to avoid altering the state that + ADVANCE_CHAR is using. + From Koichi Murase + - setifs: use an explicit mbstate_t object and pass it to MBRLEN so + to avoid altering an internal mbstate_t. + From Koichi Murase + +builtins/printf.def + - asciicode: use an explicit mbstate_t object and pass it to mbrtowc + to avoid using an incorrect internal mbstate_t + From Koichi Murase + +lib/sh/{mbscasecmp,mbscmp}.c + - mbscasecmp,mbscmp: use different mbstate_t objects for the different + strings so they don't affect each others' intermediate mbstate. + From Koichi Murase + + 9/28 + ---- +execute_cmd.c + - execute_command_internal: if executing a (command) subshell, restore + the value of line_number from save_line_number before returning early + due to being a non-terminal pipeline element. + From https://savannah.gnu.org/support/index.php?110714 + + 9/30 + ---- +subst.c + - expand_array_subscript: make sure to pass a non-NULL first argument + to sh_backslash_quote. Report from Emanuele Torre , + patch from Koichi Murase + + 9/30 + ---- +jobs.c + - cleanup_dead_jobs: delete dead foreground jobs we won't notify the + user about (those not killed by a signal or killed by SIGINT/SIGPIPE). + From a report from Koichi Murase + - wait_for_any_job: never return a foreground job, even when requested + by pid, if it's in the jobs list + Report and fix from Koichi Murase + +m4/strtoimax.m4 + - BASH_FUNC_STRTOIMAX: fix logic inversion of result; we should be + replacing the function if the tests show we *don't* have a working + version. Report from Emanuel Haupt + + 10/4 + ---- +lib/readline/nls.c + - _rl_init_locale: cope with setlocale returning NULL, make sure we + set up a default value for LC_CTYPE. Report from + https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1021109 + +lib/readline/{input.c,rlprivate.h} + - fixes for compiling on w64-mingw32 + + 10/5 + ---- +parse.y + - xparse_dolparen: save and restore extended_glob using local_extglob + in the same way that parse_comsub does. Fixes compat issue reported in + https://bugs.gentoo.org/873931 and by Kerin Millar + + 10/6 + ---- +subst.c + - extract_dollar_brace_string: keep a stack of dolbrace_state values + to handle nested expansions. Report from + Antoine + + 10/7 + ---- +builtins/{shopt.def,common.h} + - extglob_flag: new variable to hold the state of the `extglob' option; + initialized to EXTGLOB_DEFAULT like extended_glob + - shopt_set_extglob: new function to set extended_glob to the right + value for the rest of the shell + +parse.y + - reset_parser: set extended_glob to extglob_flag, which is only + changed by shopt, remove global_extglob + - parse_comsub,parse_cond_command,xparse_dolparen: no longer use + global_extglob + +execute_cmd.c + - execute_cond_node: reset extended_glob to the value of extglob_flag, + since we're executing a command here + + 10/8 + ---- +parse.y + - save_dstart: when we set the value of function_dstart, save the old + value in save_dstart (read_token, read_token_word); restore it in + the grammar production after calling make_function_def. This gives + you correct line numbers for one level of function nesting. + Report from Daniel Castro + + 10/10 + ----- +execute_cmd.c + - shell_execve: rearrange code so that we check for a bad interpreter + before printing a generic ENOENT error message. Report from + Kirill Elagin + + 10/12 + ----- +lib/readline/callback.c + - CALLBACK_READ_RETURN: add an inlined call to RL_CHECK_SIGNALS so we + can handle any signals that arrived before we restored the calling + application's signal handlers. From a gdb dicussion with + Simon Marchi + + 10/12 + ----- +variables.c + - pop_var_context: flag an internal error for shell_variables not + pointing to a function context only if we haven't already flushed + all the local contexts and reset variable_context. This can happen + if errexit is enabled and we're going to be exiting the shell, but + we're running unwind-protects on our way out. Report from + Xavier Delaruelle + + 10/13 + ----- +sig.c + - kill_shell: broke the code that resets the signal disposition to the + default and sends a terminating signal to the shell into a separate + function + - termsig_handler: set handling_termsig to terminating_signal and make + it file-scope so other functions know we're handling a terminating + signal and are about to exit, and which signal it is (latter not used + yet) + - termsig_sighandler: if we get a fatal signal while we're handling a + fatal signal, kill ourselves with the second fatal signal immediately. + Fixes issue reported by Andreas Schwab + +execute_cmd.c + - execute_case_command: call CHECK_TERMSIG after the call to strmatch, + since gmatch will return FNM_NOMATCH if there's a pending terminating + signal and we don't want incorrect results + +subst.c + - pat_subst: make sure REP is non-NULL before calling savestring on it. + Report from Justin Wood (Callek) + + 10/14 + ----- +builtins/{shopt.def,common.h} + - expand_aliases: split into a variable that holds the current state + of alias expansion (expand_aliases) and a variable that reflects the + global option value (expalias_flag), make sure expand_aliases is set + appropriately by shopt + +shell.c,execute_cmd.c,general.c + - expand_aliases: make sure expand_aliases and expalias_flag always + agree + +parser.h + - PST_STRING: new parser flag, set when parsing a string to a command + or word list + +parse.y + - reset_parser: if we're parsing a command substitution or a string, + and need to restore expand_aliases, make sure it's set to the value + of expalias_flag. + Fixes SIGINT during interactive command substitution parsing bug + reported by feng xiangjun + - parse_string_to_word_list,parse_string_to_command: make sure to set + PST_STRING in parser_flags since we're resetting expand_aliases + + 10/17 + ----- +print_cmd.c + - print_function_def, named_function_string: if the function doesn't + have any here-documents, unset was_heredoc after printing the + closing brace so we can add a separator if there is another command + following the function definition. Fixes bug with multiple function + definitions and here-documents reported by D630 + - make_command_string_internal: if we're printing a command + substitution, make sure to preserve newlines in the comsub so we + avoid problems with re-parsing function defs or command substitutions + containing multiple compound commands that need to be separated + by newlines, but don't double them up + +parse.y + - P_ARITH: new parse_matched_pair flags value; used to jump to + parse_comsub if we see a $( inside a $(( )), $[ ], or (( )) + - parse_matched_pair,parse_comsub,parse_arith_command,read_token_word: + make sure to call parse_matched_pair with P_ARITH if we're parsing + an arithmetic command or expansion + - parse_matched_pair: if we see $( inside a call with P_ARITH in the + flags argument, jump to parse_dollar_word and call parse_comsub to + parse it. The rest of the steps assume that parse_comsub has + expanded aliases (or not) appropriately. Fixes bug 2 from + https://bugzilla.redhat.com/show_bug.cgi?id=2134307 + + 10/18 + ----- +builtins/evalstring.c + - parse_and_execute: we play tricks in the parser and in command_substitute + to turn expand_aliases on and off depending on the comsub parser + pass and whether or not we're in posix mode. Since this should only + matter for parsing, when we're processing a command substitution, we + set expand_aliases to the global flag value after parsing the + command and before executing it, and restore it if the global flag + value isn't changed during execution. Fixes bug 1 from + https://bugzilla.redhat.com/show_bug.cgi?id=2134307 + +command.h + - PF_BACKQUOTE: new flag value, only used by command_substitute to + differentiate between `` and $() forms. The former does not have + aliases expanded by parse_comsub in posix mode, so needs to expand + them in parse_and_execute like default mode + +subst.c + - command_substitute: don't modify expand_aliases if PF_BACKQUOTE is + included in flags, since aliases haven't been expanded in the + command string (it was run through parse.y:parse_matched_pair()) + - expand_word_internal: pass PF_BACKQUOTE to command_substitute() if + expanding a `` command substitution + + 10/20 + ----- +parse.y + - yylex: return YYUNDEF as current_token if read_token returns < 0. + Fixes parser reset issue reported by Todd Stein + in https://savannah.gnu.org/support/index.php?110745 + +subst.c + - ARITH_EXP_CHARS: chars that are special and trigger expansion in + arithmetic expressions, EXP_CHARS without `<' and `>'. Fixes bug + reported by Glenn Jackman + +execute_cmd.c + - retain_fifos: replace executing_list (which is still present) as the + indicator of whether or not to save and restore the FIFO list around + a call to execute_command_internal/execute_command; it's more + descriptive and can be used elsewhere + - execute_for_command: set retain_fifos so we don't unlink the fifo + list until the for command completes. Fixes issue reported in + https://savannah.gnu.org/support/index.php?110743 + +lib/readline/xmalloc.c + - memory_error_and_abort: add `const' qualifiers to the argument. Fix + from Markus Elfring + + 10/24 + ----- +general.c + - check_binary_file: check the first two lines for NULs if the first + line begins with a `#!'; otherwise check the first. From a discussion + and patch in https://savannah.gnu.org/support/?110744 + (larsh@apache.org) + +parse.y + - parse_matched_pair: set PST_NOERROR if we read to EOF without finding + a closing match and call parser_error; avoids redundant error + message + +lib/sh/uconvert.c + - uconvert: RETURN: if ipart (integer part) is 0, but upart (fractional + part) is non-zero, multiply upart by mult so we don't lose the sign + for values in the range (-1, 0]. From a report by + izabera + +execute_cmd.c + - execute_in_subshell: check for terminating signals before we return + to our caller, which will immediately exit, and before running any + exit trap (since termsig_handler will run any exit trap). Fixes bug + reported by Andrew Neff + + 10/26 + ----- +lib/readline/complete.c + - rl_filename_completion_function: if the application doesn't supply + any directory hook functions, we need to handle the case where we + dequoted users_dirname and also tilde-expanded dirname. We choose + to tilde expand users_dirname rather than call the application + dequoting function again. Report and patch from + Stefan H. Holek + + 10/27 + ----- +execute_cmd.c + - execute_in_subshell: call procsub_clear in addition to clear_fifo_list, + since none of these process substitutions are children of this new + subshell + +jobs.c + - wait_for_background_pids: call procsub_waitpid on the last procsub + created as long as it's the same as $!, then call reap_procsubs to + clean up the procsub list. Don't call procsub_waitall. Report from + Oguz İsmail Uysal + + 10/31 + ----- +expr.c + - expr_streval: explicitly permit `@' and `*' as associative array + subscripts if the shell compatibility level is greater than 51. + Prompted by report from Corey Hickey + +subst.c + - string_list_pos_params, param_expand: make sure that $* is treated + the same as "$*" in here-document bodies that are being expanded. + From https://lists.gnu.org/archive/html/bug-bash/2022-09/msg00002.html + + 11/1 + ---- +lib/readline/readline.c + - readline_internal_char: save and restore the value of _rl_top_level + around our use of setjmp, even though it doesn't matter in most + cases. Report from sparrowhawk996@gmail.com that it causes crashes + in some obscure callback-mode cases + +lib/readline/isearch.c + - _rl_isearch_dispatch: if we end the search and stuff characters back + to be read again, decrement the current key sequence index by 2 so + we don't have duplicate characters in the sequence + +lib/readline/misc.c + - rl_digit_argument: call _rl_del_executing_keyseq after rl_execute_next + + 11/3 + ---- +builtins/setattr.def + - show_localname_attributes: special-case "-" local variable, since + there is no `declare -' equivalent. + Reported by Emanuele Torre . + + 11/4 + ---- +lib/sh/tmpfile.c + - sh_mktmpname,sh_mktmpfd: use get_urandom32() instead of random() if + we're not using mktemp or mkstemp and the system provides the + appropriate support + +trap.c + - trap_variable_context: new variable, set to variable_context every + time a trap string runs (that is, every time running_trap is set to + a value > 0) in _run_trap_internal, run_exit_trap, run_pending_traps + +trap.h + - trap_variable_context: extern declaration + +builtins/common.c + - get_exitstat: if the `return' builtin is running, we are running a + trap (but not the DEBUG trap), and the return would cause the trap + string to complete (variable_context == trap_variable_context, so + we haven't executed another shell function), use the last command + exit value as the return status. POSIX interp 1602, from + https://www.austingroupbugs.net/view.php?id=1602 + + 11/4 + ---- + +lib/readline/display.c + - local_prompt_invis_chars: new array variable, similar to + local_prompt_newlines, that keeps track of the number of invisible + characters on each line of the prompt string. Use in WRAP_OFFSET + macro with eye to using in W_OFFSET as well. Used for the case where + the last line of the prompt is not the last line with invisible + characters. Can use this in more calculations replacing wrap_offset + and prompt_invis_chars_first_line going forward. Inspired by report + from https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1018851 + - update_line: use local_prompt_invis_chars to set _rl_last_c_pos + correctly when on a non-terminal prompt line that contains + invisible characters + + 11/7 + ---- +subst.c + - get_var_and_type: allocate new memory for *valp and return it if the + type is VT_ARRAYMEMBER. The callers -- all of which treat this case + the same as VT_VARIABLE -- will free appropriately. Fixes problems + with using parameter operations like ## on dynamic array variables, + reported by Ivan Kapranov back on 8/31/2022 + +expr.c + - change some error messages to make it clearer these are arithmetic + syntax errors. These will require new translations. + +test.c + - integer_expected_error: change the message to remove `expression', + since this is only called for the `test' builtin, where TEST_ARITHEXP + is not in FLAGS. This will require a new translation. + Reported by Emanuele Torre back on + 6/15/2022 + + 11/10 + ----- +builtins/read.def + - reset_timeout: when a timer expires, make sure to cancel any + readline timeout as well with rl_clear_timeout(). + From https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1023776 + + 11/11 + ----- +builtins/reserved.def + - !: add short help text + +lib/readline/complete.c + - make_quoted_replacement: if readline found quote characters anywhere + in the filename, but is not completing on an unclosed quoted string, + and there is an application filename quoting function, let that + function quote the filename if necessary + +bashline.c + - COMPLETE_DQUOTE2: new completion quoting style define + - bash_expand_filename: new function, runs a filename passed to it + through word expansion, suppressing command and process substitution + and returns the result (in new memory if it's different than the + filename argument) + - bash_quote_filename: if the return value from bash_check_expchar is + `$' or ``', expand the filename and if it contains characters that + should be quoted, set the quoting style to COMPLETE_DQUOTE2 + - bash_quote_filename: if the completion quoting style is COMPLETE_DQUOTE2, + use sh_mkdoublequoted to put double quotes around the entire + unexpanded filename instead of using sh_double_quote, which will + backslash-quote any `$'. This is a start at preserving user-supplied + quotes if the (expanded) completed filename requires them. From + reports by Peng Yu in 5/2020 and + Pedro Gimeno in 6/2021 + + 11/14 + ----- +parse.y + - report_syntax_error: if word_top is set and we reach EOF, report the + starting line number in the error message. From a patch from + L A Walsh and Manuel Reiter + back in 9/2018 + - MAX_CASE_NEST: doubled to 256, renamed to MAX_COMPOUND_NEST + - read_token_word: add `if', `while', and `until' to the set of + compound commands that use WORD_TOP and WORD_LINENO (with + corresponding changes to grammar productions) + - [grammar]: changed check to decrement WORD_TOP to >= 0 since we + start at -1 and we want to decrement back to -1 when all loops are + closed + +builtins/jobs.def + - jobs_builtin: call notify_and_cleanup after displaying the status of + jobs to implement POSIX requirement that `jobs' remove terminated + jobs from the jobs list + https://pubs.opengroup.org/onlinepubs/9699919799/utilities/jobs.html#tag_20_62 + + 11/15 + ----- +lib/sh/input_avail.c + - include signal.h unconditionally, we need it for HAVE_SELECT and + HAVE_PSELECT + - nchars_avail: make sure we declare and use readfds and exceptfds if + we have pselect or select available + +lib/readline/input.c + - rl_gather_tyi,rl_getc: need to declare and use readfds and exceptfds + if HAVE_PSELECT or HAVE_SELECT is set. Report from + Henry Bent , fixes from + Koichi Murase + + 11/16 + ----- +lib/sh/ufuncs.c + - quit.h: include unconditionally for declaration of sigemptyset even + if HAVE_SELECT is not defined + +lib/sh/timers.c + - USEC_PER_SEC: make sure it's defined even if HAVE_SELECT is not + +lib/glob/sm_loop.c + - BRACKMATCH: if an equivalence class does not match, and the next + character following the class is a `]', treat that as the end of + the bracket expression. + Report and fix from Koichi Murase + - GMATCH: if the current character in the string is a `/' and the + current element in the pattern is a bracket expresion, and the FLAGS + include FNM_PATHNAME, return FNM_NOMATCH immediately. A bracket + expression can never match a slash. + Report and fix from Koichi Murase + - BRACKMATCH: if we encounter a in a bracket expression, either + individually or as part of an equivalence class, nullify the bracket + expression and force the `[' to be matched as an ordinary + character + + 11/17 + ----- +lib/glob/sm_loop.c + - BRACKMATCH: if a slash character appears as the first character + after a non-matching character class or equivalence class, treat + the bracket as an ordinary character that must be matched literally + - BRACKMATCH: if a slash character appears as the second character + of a range expression, treat the bracket as an ordinary character + - BRACKMATCH: if a slash character appears in the portion of a + bracket expression that already matched, treat the bracket as an + ordinary character + Updates from Koichi Murase + - BRACKMATCH: if a range expression is incomplete (no end char), + treat the bracket as an ordinary character + + 11/18 + ----- +doc/bashref.texi + - Reporting Bugs: add mention of the Savannah project page. Suggested + by Loïc Yhuel + + 11/20 + ----- +builtins/common.h + - SEVAL_NOOPTIMIZE: new flag for parse_and_execute: means don't try to + optimize forks out of any simple or conditional commands + +builtins/evalstring.c + - parse_and_execute: if FLAGS includes SEVAL_NOOPTIMIZE, don't try to + call can_optimize_connection to optimize away forks from AND_AND or + OR_OR commands + +builtins/eval.def,trap.c,parse.y,jobs.c + - parse_and_execute: include SEVAL_NOOPTIMIZE in any calls to + parse_and_execute. Fixes bug reported by + Frode Nordahl + + 11/21 + ----- +lib/readline/readline.c + - readline_initialize_everything: use xmalloc to initialize + rl_executing_keyseq, since we use xrealloc to reallocate it and + don't check it for NULL anywhere + +subst.c + - parameter_brace_expand_word: make sure to update *ESTATEP and pass + ES back to the caller even if array_value returns NULL. Fixes + memory leak referencing unset associative array elements reported + by Ralf Oehler ; fix from + Koichi Murase + + 11/22 + ----- +lib/glob/sm_loop.c + - BRACKMATCH: if a backslash appears before a slash in a bracket + expression, treat the whole thing as literal and try to match the + open bracket + - BRACKMATCH: if a bracket expression ends in an unquoted backslash, + try to match the left bracket literally and go on. More discussion with + Koichi Murase + +execute_cmd.c + - execute_in_subshell: don't try to optimize away forks in the command + if the subshell command is being timed or its return value is being + inverted. Report from Dabrien 'Dabe' Murphy + + 11/23 + ----- +lib/readline/complete.c + - __WIN32__: remove uses of this preprocessor symbol, use _WIN32 + +lib/readline/rldefs.h + - Don't define NEW_TTY_DRIVER on _WIN32. Fix from + sparrowhawk996@gmail.com + +include/posixselect.h + - include "posixtime.h" instead of so the right guards + are present + +builtins/read.def + - read_builtin_timeout: make sure we don't try to call shtimer_select + if HAVE_SELECT isn't define; it won't be compiled in + +include/stdc.h + - restrict: make sure we have a definition if __STDC__ is not defined + +include/posixtime.h,lib/sh/gettimeofday.c + - gettimeofday: make sure the function signature matches POSIX by + adding `restrict' + + 11/25 + ----- +include/posixselect.h + - don't try to define HAVE_SELECT at all if _WIN32 is defined + +lib/readline/kill.c + - define WIN32_LEAN_AND_MEAN for the windows-specific paste function + +lib/readline/rlprivate.h + - _rl_timeout_select: only include declaration if HAVE_SELECT or + HAVE_PSELECT are defined + + 11/28 + ----- +lib/readline/input.c + - rl_gather_tyi: call rl_input_available_hook after FIONREAD test, + let the application hook into whether or not there are characters + to read + +execute_cmd.c + - execute_function: if the maximum function nesting level is exceeded, + run the unwind-protects before jumping back to top level. Report + from felix + +variables.c + - find_variable_nameref_for_create,find_variable_nameref_for_assignment: + handle find_variable_nameref returning &nameref_maxloop_value, return + NULL and print a warning message in that case + - find_variable_nameref: return &namref_maxloop_value instead of NULL + if the number of resolution cycles exceeds NAMEREF_MAX; change + callers to print a new error message in this case; no other change + in behavior. From a 4/2020 suggestion from Andrej Podzimek + + - find_variable_nameref_context, find_nameref_at_context, + find_variable_last_nameref_context: make sure to return + &nameref_maxloop_value consistently and handle getting it as a + return value from other functions + + 11/29 + ----- +lib/readline/display.c + - _rl_update_final: if there is only one line (_rl_vis_botlin == 0) + and that line is empty (botline_length == 0), assume there is no + prompt and the line has no contents, so output the CR/LF to indicate + that the newline has been read. From a report from + Kevin Pulo + + 11/30 + ----- +builtins/evalstring.c + - parse_and_execute: if we are executing the eval builtin, and the + return status from the command is suppressed (builtin_ignoring_errexit), + set CMD_IGNORE_RETURN in the parsed command's flags. From a report + from Tycho Kirchner + + 12/1 + ---- +lib/glob/sm_loop.c + - PARSE_SUBBRACKET: a reworked PARSE_COLLSYM, generalized to handle + [:, [=, and [. special bracket expressions + - BRACKMATCH: change to use PARSE_SUBBRACKET consistently to parse + [:, [=, and [. special bracket expressions + - PATSCAN: takes new FLAGS arg, changed all callers to just pass the + flags they get through to PATSCAN + - PATSCAN: call PARSE_SUBBRACKET for [:, [=, and [. to treat them + consistently (uses FLAGS argument here) + - PATSCAN: handle FNM_NOESCAPE appearing in FLAGS argument + This set of fixes contributed by Koichi Murase + +lib/glob/{glob,gmisc}.c + - PATSCAN: change all callers to add extra flags arg of 0 + +doc/{bash.1,bashref.texi} + - trap description: replace ARG with ACTION + - clarify the language describing what trap without arguments and + trap -p without arguments display + - clarify that trap in non-interactive shells does not allow signals + that were ignored at shell start to be trapped; interactive shells + allow this + - trap: add missing command types to the description of when the + DEBUG trap is executed + +builtins/trap.def + - LONG_DOC: replace ARG with ACTION + - make it clear that trap and trap -p without arguments display a + information about specified signals, but in a form that may be + reused as shell input + + 12/5 + ---- +pcomplete.c + - compgen_compspec: new flag saying whether or not we're running via + the compgen builtin or via programmable completion: set to 0 + every time gen_progcomp_completions runs, set to 1 in + gen_compspec_completions if this_shell_builtin == compgen_builtin + - gen_shell_function_completions: call rl_clear_signals and + rl_set_signals so the shell's signal handlers are active when + running shell functions to generate completions. We try to do it + only when programmable completion, not the compgen builtin, is active. + Idea from Koichi Murase , fixes bug + reported in 9/22 + +sig.c + - sigint_sighandler, termsig_sighandler: since these can now be called + during programmable completion, we need to set the readline signal + event hook if the readline state includes RL_STATE_DISPATCHING or + RL_STATE_COMPLETING, since we can't rely on RL_STATE_SIGHANDLER + being set and we want to call throw_to_top_level here + - throw_to_top_level: if the shell is interactive, before calling + bashline_reset (which zeroes rl_signal_event_hook), call + rl_cleanup_after_signal if we think readline hasn't called it + already + + 12/9 + ---- +configure.ac + - add "LOCAL_LDFLAGS = -rdynamic" for freebsd/openbsd/netbsd. Reported + by Christian Weisgerber + + 12/12 + ----- +subst.c + - parameter_brace_expand_length: handle namerefs with values that are + valid length expansion expressions but invalid identifiers. From + ed7-aspire4925@hotmail.com via https://savannah.gnu.org/support/?110799 + + 12/13 + ----- +subst.c + - extract_heredoc_dolbrace_string: fix off-by-one error after calling + extract_command_subst and extract_process_subst that caused it to + copy one too many parsed characters. Fix for bug reported by + Norbert Lange + + 12/14 + ----- +execute_cmd.c + - execute_cond_node: if a regular expression fails to compile, print + an error message. Report from Emanuele Torre + back on 6/15/2022 + +trap.c + - trap_variable_context -> trap_return_context, initialize from + funcnest + sourcenest instead of variable_context so we handle + shell function execution and `./source', both of which can use + `return'. Idea from Koichi Murase + +builtins/common.c + - get_exitstat: compare trap_return_context against funcnest+sourcenest, + since that's how it's initialized now + +lib/readline/readline.c + - readline_internal_charloop: if we're not using the callback interface, + don't restore _rl_top_level from olevel, since we will just be going + around the loop again and will potentially need to use it multiple + times. Report from Emanuele Torre + + 12/15 + ----- +shell.h + - EX_UTILERROR: new generic special builtin return status to indicate a + POSIX utility error that should cause a non-interactive shell to abort + +execute_cmd.c + - builtin_status: translate EX_UTILERROR to EXECUTION_FAILURE + +builtins/set.def + - unset_builtin: return EX_UTILERROR if posix_utility_error is set; + set it when trying to unset a non-identifier (variable) or a + non-unsettable or readonly variable + + 12/16 + ----- +subst.c + - de_backslash: now takes a second argument with the current quoting + flags + - de_backslash: if the quoting flags include Q_HERE_DOCUMENT and the + shell is in posix mode, remove backslashes quoting double quotes + +subst.h + - de_backslash: update extern declaration + +lib/readline/histexpand.c + - history_expand_internal,get_history_word_specifier,get_subst_pattern, + hist_error,history_find_word,hist_string_extract_single_quoted: + now take const char * string arguments + +lib/readline/mbutil.c + - _rl_get_char_len,_rl_adjust_point,_rl_find_next_mbchar_internal, + _rl_find_next_mbchar,_rl_find_prev_mbchar,_rl_find_prev_mbchar_internal, + _rl_test_nonzero,_rl_find_prev_utf8char,_rl_is_mbchar_matched, + _rl_compare_chars,_rl_char_value: take const char * string arguments + + 12/17 + ----- +builtins/umask.def + - parse_symbolic_umask: add missing POSIX pieces: + o `action' of ugo, meaning to copy portions of initial mask + o multiple `op' specs as part of the action string (`u=r-w') + (resets perm) + o missing perm characters Xst in action string + o default `who' equivalent to `a' instead of fixing up later + + 12/19 + ----- +builtins/type.def + - if -a and -P are both supplied, look in the command hash table but + continue and perform a $PATH search even if the NAME is hashed. + From a report by Adam Vodopjan + +doc/{bash.1,bashref.texi} + - type: update description to fix it to what the code actually does + +builtins/set.def + - set_edit_mode: don't run with_input_from_stdin or with_input_from_stream + unless command_execution_string is NULL. Report from + Harald van Dijk + + 12/20 + ----- +braces.c + - array_concat: add a check for interrupts and terminating signals + into the inner loop + +jobs.c + - without_job_control: set original_pgrp == NO_PID since we don't + want to be messing with the terminal pgrp if we call end_job_control. + From a report from ks1322 ks1322 + + 12/21 + ----- +include/{posixtime.h,systimes.h,shmbutil.h,shtty.h} + - PARAMS: remove + + 12/22 + ----- +builtins/evalfile.c + - _evalfile: add SEVAL_NOOPTIMIZE to the parse_and_execute flags + (maybe overkill, but safer). From a report by + Dan Church and Oguz + +lib/sh/gettimeofday.c + - gettimeofday: added code for _WIN32 version + + 12/27 + ----- +doc/{bash.1,bashref.texi},builtins/printf.def + - specify the valid format characters as a subset of what printf(3) + specifies, note that the %n format specifier takes a variable name + as an argument. Suggestion from Emanuele Torre + + 12/28 + ----- +{xmalloc,variables,unwind_prot,trap,test,subst,sig,siglist,shell,redir, +pcomplete,pathexp,make_cmd,mailcheck,jobs,input,hashcmd,hashlib,general, +flags,findcmd,externs,execute_cmd,error,dispose_cmd,command,bashline, +bashhist,assoc,arrayfunc,array,alias}.h +{version,version2}.c + - PARAMS: remove for ANSI C-ification + +builtins/{getopt,common,bashgetopt}.h +builtins/{mkbuiltins,gen-helpfiles,psize,psize-posix}.c +builtins/{evalstring,bashgetopt,common,evalfile,getopt}.c +builtins{alias,bind,break,cd,command,complete,declare,enable,exit,fc, +fg_bg,getopts,hash,help,history,jobs,kill,mapfile,printf,pushd,read,set, +shopt,source,suspend,trap,type,ulimit,umask,wait}.def + - PARAMS: remove for ANSI C-ification + +lib/malloc/{watch,table,shmalloc,mstats,imalloc}.h +lib/malloc/{malloc,stats,table,trace}.c + - PARAMS: remove for ANSI C-ification + +lib/glob/{glob,strmatch}.h +lib/glob/{glob,glob_loop,gmisc,sm_loop,smatch,strmatch,xmbsrtowcs}.c + - PARAMS: remove for ANSI C-ification + +lib/intl/{eval-plural,plural-exp,loadinfo,hash-string,gettextP}.h, +lib/intl{plural.y,plural.c}, +lib/intl/{finddomain,bindtextdom,dcigettext,l10nflist,loadmsgcat,localealias,plural-exp}.c + - PARAMS: remove for ANSI C-ification + - STATIC -> static + - internal_function -> inline + +lib/sh/{casemod,clock,eaccess,fnxform,fpurge,makepath,mktime,netopen,pathphys,random,shquote,snprintf,spell,strtod,strtoimax,strtoumax,times,timeval,tmpfile,unicode,winsize,zcatfd,zgetline,zmapfd}.c + - PARAMS: remove for ANSI C-ification + +support/{bashversion.c,mkversion.sh,mksignames.c} + - PARAMS: remove for ANSI C-ification + +lib/sh/{clock,strchrnul,getcwd,times,rename,inet_aton,strdup,strerror,strnlen +strpbrk,strtod,strtoimax,strtol,strtoumax,wcsdup,wcsnwidth,wcswidth,strcasecmp, +strcasestr}.c + - C89-style function declarations + +lib/malloc/{alloca,malloc,stats,table,trace,xmalloc}.c + - C89-style function declarations + + 12/29 + ----- +lib/glob/{glob,glob_loop,gmisc,sm_loop,smatch,strmatch,xmbsrtowcs}.c + - C89-style function declarations + +lib/sh/{zcatfd,zgetline,zmapfd,zread,zwrite,winsize,vprint,uconvert,ufuncs, +unicode,utf8}.c +lib/sh/{stringlist,stringvec,strtrans,strvis,timeval,tmpfile}.c +lib/sh/{setlinebuf,shmatch,shmbchar,shquote,shtty,snprintf,spell}.c +lib/sh/{random,pathcanon,pathphys,oslib,netconn,netopen}.c +lib/sh/{mailstat,makepath,mbscasecmp,mbschr,mbscmp,mktime}.c +lib/sh/{input_avail,itos,getenv,fmtulong,fnxform,eaccess,dprintf,casemod,clktck}.c + - C89-style function declarations + +examples/loadables/{accept,asort,basename,bcat,cat,csv,cut,dirname,dsv}.c +examples/loadables/{fdflags,finfo,head,hello,id,lcut,ln}.c +examples/loadables/{mkdir,mkfifo,mktemp,mypid,necho,pathchk}.c +examples/loadables/{print,printenv,push,realpath,rm,rmdir,seq}.c +examples/loadables/{setpgid,stat,strftime,sync,tee,template,truefalse,tty}.c +examples/loadables/{uname,unlink,whoami}.c + - C89-style function declarations + +xmalloc.c, array2.c, list.c, dispose_cmd.c, copy_cmd.c, bracecomp.c, mksyntax.c + - PARAMS: remove for ANSI C-ification + - C89-style function declarations + + 12/30 + ----- +hashlib.c,assoc.c,input.c,hashcmd.c,alias.c,alias.h,array.c,flags.c,pcomplib.c, +pcomplib.h,locale.c +variables.c,arrayfunc.c,bashhist.c,bashline.c,error.c,pathexp.c,nojobs.c, +stringlib.c,eval.c,findcmd.c,mailcheck.c,make_cmd.c,shell.c,print_cmd.c, +general.c,expr.c + - PARAMS: remove for ANSI C-ification + - C89-style function declarations + - add `const' and `inline' where it makes sense + + 12/31 + ----- +test.c,execute_cmd.c,parse.y,pcomplete.c,trap.c,subst.c,braces.c,jobs.c,sig.c +builtins/{evalstring.c,gen-helpfiles.c,mkbuiltins.c} +builtins/{alias.def,bind.def,break.def,builtin.def,caller.def,cd.def,colon.def} +builtins/{command.def,complete.def,declare.def,echo.def,enable.def,eval.def} +builtins/{exec.def,exit.def,fc.def,fg_bg.def,hash.def,help.def,history.def} +builtins/{jobs.def,kill.def,let.def,mapfile.def,printf.def,pushd.def,read.def} +builtins/{return.def,set.def,setattr.def,shift.def,shopt.def,source.def} +builtins/{suspend.def,test.def,times.def,trap.def,type.def,ulimit.def} +builtins/{umask.def,wait.def} + - PARAMS: remove for ANSI C-ification + - C89-style function declarations + - add `const' and `inline' where it makes sense + + 1/2/2023 + -------- +lib/sh/{stringvec.c,inet_aton.c,strnlen.c,spell.c,netopen.c,stringlist.c} +lib/sh/{strtrans.c,tmpfile.c,uconvert.c,zcatfd.c} +builtins/{common.c,common.h} +mailcheck.c,bashline.c,pathexp.c,stringlib.c,locale.c,pcomplete.c,redir.c +test.c,trap.c,variables.c,bashhist.c,expr.c,arrayfunc.c,assoc.c,variables.c +subst.c,findcmd.c +arrayfunc.h,variables.h,findcmd.h,bashline.h,trap.h,pathexp.h,externs.h, +pcomplete.h,bashhist.h,assoc.h,general.h,subst.h + - more `const' changes, remove `register' + + 1/3 + --- +parse.y + - more `const' changes, remove `register' + +variables.h + - VARLIST: list_len and list_size now size_t + +variables.c + - vlist_alloc: take size_t parameter, changed callers + - vlist_realloc: take size_t parameter, changed callers + +lib/sh/stringvec.c,externs.h + - functions that take int size params now take size_t + - strvec_len: returns size_t + +lib/sh/stringlist.c,externs.h + - STRINGLIST: list_size and list_len now size_t + - functions that take int size params now take size_t + +variables.c,bashline.c,builtins/bind.def + - change strvec_ int parameters to size_t where it makes sense + - change strlist_ int parameters to size_t where it makes sense + +builtins/shopt.def + - reset_shopt_options: set glob_always_skip_dot_and_dotdot to 1, + since that's the current default in lib/glob/glob.c + + 1/4 + --- +execute_cmd.c,parse.y,general.c,make_cmd.c,print_cmd.c,variables.c,expr.c +jobs.c,subst.c,input.c,unwind_prot.c,pathexp.c,pathexp.h,alias.c,bashline.c +bashhist.c,lib/sh/shquote.c,externs.h,stringlib.c,locale.c,findcmd.c +builtins/common.c,builtins/declare.def,builtins/enable.def,builtins/fc.def +lib/sh/zmapfd.c,builtins/help.def,builtins/mapfile.def,builtins/read.def +builtins/shopt.def,lib/glob/glob.c,lib/glob/smatch.c,lib/glob/sm_loop.c +lib/glob/xmbsrtowcs.c,lib/glob/gmisc.c,lib/glob/gm_loop.c +lib/sh/getenv.c,lib/sh/makepath.c,lib/sh/pathphys.c,lib/sh/tmpfile.c +lib/sh/stringlib.c,lib/sh/spell.c,lib/sh/strtrans.c,lib/sh/zgetline.c +lib/sh/mbscasecmp.c,lib/sh/utf8.c +lib/readline/readline.c,lib/readline/rlprivate.h,lib/readline/vi_mode.c +lib/readline/complete.c,lib/readline/bind.c,lib/readline/isearch.c +lib/readline/util.c,lib/readline/kill.c,lib/readline/macro.c +lib/readline/text.c,lib/readline/histexpand.c,lib/readline/histfile.c +lib/readline/mbutil.c,lib/tilde/tilde.c + - size_t changes + - remove some unused variables + - remove `register' + + 1/5 + --- +builtins/getopt.c + - sh_getopt_restore_state: make sure argv[sh_curopt] is non-null before + using it + +parse.y + - CHECK_FOR_RESERVED_WORD: make sure to set word_top appropriately if + the last token was IF, WHILE, or UNTIL, since these tokens can follow + those reserved words + +Makefile.in + - ubsan: new target, to build with gcc/clang UBSan undefined behavior + sanitizer + + 1/6 + --- +execute_cmd.[ch],locale.c,parse.y,expr.c,bracecomp.c,bashline.c,externs.h +stringlib.c,general.[ch] +builtins/{subst.c,array.c,echo.def,printf.def,enable.def,help.def,set.def} +lib/sh/{strtrans.c,stringvec.c,shquote.c} +lib/glob/sm_loop.c +lib/readline/{vi_mode.c,histfile.c,funmap.c,complete.c,display.c,bind.c,isearch.c} +lib/tilde/tilde.c + - final code cleanups for ANSI C and lint/ubsan/asan runs + + 1/7 + --- +lib/readline/complete.c + - rl_complete_internal: when computing nontrivial_lcd and the length + of the text from the line buffer, dequote the text from the line + buffer before comparing it against the common prefix of the matches + (matches[0]), so we don't get spurious mismatches if the quoted text + from the line is longer than the unquoted match. Report from + Martin Castillo + +input.[ch] + - get_buffered_stream(fd): new function, return the BUFFERED_STREAM * + corresponding to file descriptor FD, if it exists + + 1/8 + --- +parse.y + - shell_getc: if yy_getc returns EOF but the buffered stream input + indicates an error state, set shell_input_line_terminator to + READERR. Currently treated the same as EOF. + + 1/10 + ---- +lib/sh/random.c + - intrand32: use % operator instead of (mathematically equivalent) + subtraction and multiplication, which can cause signed 32-bit + overflow. Report from Sam James + +lib/readline/input.c + - rl_getc: if the application hasn't defined a signal event handler, + and readline is in callback mode, make sure SIGINT breaks out of + operations like incremental and non-incremental searches and digit + arguments by calling _rl_abort_internal, since the callback code + expects the various contexts that rl_callback_sigcleanup() resets + to be valid + - rl_getc: if there is a pending signal when we enter the while loop + in callback mode, handle it in the same way we would if a signal + arrived while we were waiting in select/pselect. That forces + callback mode to call _rl_abort_internal in the right place. + From a report from Andrew Burgess + + 1/13 + ---- +trap.c + - SIG_ASYNCSIG: new value for sigmodes; means that the signal is + ignored because an async command is being executed + - set_signal: if the original signal disposition is SIG_IGN only + return if SIG_ASYNCSIG isn't set. This implements POSIX interp 751 + for setting a trap + - ignore_signal: if we're ignoring a signal that already has SIG_IGNORED + set, make sure we set SIG_TRAPPED in case of SIG_ASYNCSIG (POSIX + interp 751) + - reset_signal,restore_signal: if we want to reset or restore a signal + that has SIG_ASYNCSIG set, make sure we reset to SIG_DFL if the + signal is trapped to maintain POSIX semantics + - set_signal_async_ignored: new function to set original_signals to + SIG_IGN and set the SIG_IGNORED and SIG_ASYNCSIG sigmode flags; used + by setup_async_signals + - signal_is_async_ignored: return true if the SIG argument is being + ignored because it's part of an async list + +trap.h + - set_signal_async_ignored,signal_is_async_ignored: extern declarations + +sig.c + - initialize_terminating_signals: if a signal is ignored because it's + part of an async list, don't bother trying to initialize or set the + hard ignored flag + +execute_cmd.c + - execute_simple_command: if we're executing a builtin or function + asynchronously, call reset_terminating_signals like we do in + execute_in_subshell() + - execute_subshell_builtin_or_function: only call set_sigint_handler + if async is 0, so we don't undo the work done by setup_async_signals. + If the old handler is SIG_IGN and the signal has SIG_ASYNCSIG set + and isn't trapped, restore the old handler + - setup_async_signals: call set_signal_async_ignored to set the right + flags + + 1/16 + ---- +parse.y + - read_token_word: if we're in posix mode, and we find a reserved word + before checking a token for aliases, turn off the `check next word + for aliases' flag (PST_ALEXPNEXT). This is for compatibility with + other shells. From a report by + - shell_getc: make sure the shell is reading a buffered stream before + checking the default buffered stream for errors if yy_getc returns 0 + + 1/17 + ---- +subst.c + - split_at_delims: if the cursor is at whitespace just preceding a + word, and we're doing this for completion (e.g., to build COMP_WORDS), + force the creation of an empty word and set the current word to it. + This is a change from previous behavior, but a useful one: it makes + COMP_WORDS[COMP_CWORD] and $2 to a completion function consistent + and the same as the word readline wants to complete. From a report + from Naim Favier back in 6/2022 + +parse.y + - read_token: turn off PST_ALEXPNEXT if we read a shell metacharacter: + we will expand aliases anyway if the token puts the shell in a + command word position and we took pains to turn it off for + redirection tokens; remove special cases that turned it off + - pop_string: don't turn off PST_ALEXPNEXT if it's on; this is what + prevents it from being enabled if an alias expansion of more than + two aliases ends with a space. Fixes issue reported by + + + 1/18 + ---- +jobs.c + - wait_for: if we are reaping a background job, don't bother trying to + give the terminal back to shell_pgrp -- we never set the terminal's + pgrp to that job in the first place. Fixes issue reported by + Steffen Nurpmeso + + 1/19 + ---- +lib/readline/{histexpand.c,history.h} + - history_expand: first argument is now `const char *'. Request from + Simon Marchi + +lib/readline/doc/{history.3,hstech.texi} + - history_expansion: change description to note new const first arg + + 1/21 + ---- +lib/readline/input.c + - rl_gather_tyi: move call to rl_input_available_hook to the top, + giving it first shot. There's still no way for it to set chars_avail. + Conditionalize the rest of the input methods based on whether the + result == -1. + +lib/readline/rl_private.h + - move the decision making about RL_TIMEOUT_USE_SELECT/RL_TIMEOUT_USE_SIGALRM + here from input.c + + 1/23 + ---- +trap.c + - restore_default_signal: if we have a signal that's not trapped, but + is a signal that is set to SIG_ASYNCSIG, POSIX interp 751 requires + the shell to allow it to be reset to the default, even though it + wasn't already trapped + +subst.c + - do_assignment_internal: don't allocate new memory for NAME, just + modify and restore it in place + + 1/25 + ---- +lib/readline/histfile.c + - history_write_slow: a fallback function that uses stdio to write the + history list to a supplied file descriptor + - history_do_write: call history_write_slow if ftruncate/mmap/malloc + fail; hope the simpler approach works + + 1/27 + ---- +general.[ch] + - valid_function_name: new function, returns non-zero if the name + can be used as a function name without the `function' prefix + +print_cmd.c + - named_function_string,print_function_def: use valid_function_name so + the rules about when to use the `function' reserved word are + consistent + +builtins/trap.def + - new option -P, which prints only the action associated with each + signal spec argument + +doc/{bash.1,bashref.texi} + - trap: document new -P option, add note that trap -p or trap -P in a + subshell can print the parent's traps + + 1/28 + ---- +parse.y + - shell_getc: make sure references to shell_input_line_property are + protected by #ifdef HANDLE_MULTIBYTE. From + https://savannah.gnu.org/patch/?10309 + +print_cmd.c + - named_function_string,print_function_def: don't copy the function + COMMAND * before printing it as text; unwind-protect any redirects + attached to the function body + +parse.y + - PST_CMDBLTIN: new parser state, means the previous token word was + `command' in a command position + - read_token_word: in posix mode, "command" followed by a declaration + utility preserves the declaration utility status of the following + word, so we mark that state and then check a word for being an + assignment builtin if in that state on the next call. This makes + compound assignments to builtins that accept them (e.g., `declare') + work as if `command' were not present. This is a POSIX issue 8 + requirement + - read_token: turn off PST_CMDBLTIN state as appropriate + +subst.c + - use locale_mb_cur_max instead of MB_CUR_MAX consistently + + 2/1 + --- +builtins/printf.def + - printf_builtin: %q and %Q use the `alternate form' flag to force + single quoting instead of backslash quoting. $'...' is still + preferred if there are characters that require it + - getwidestr, getwidechar: functions to take a possibly multibyte + character string and convert to a wide character string or a wide + character, respectively + - convwidestr, convwidechar: functions to take a wide character string + or single character, apply any precision, convert back to a multibyte + character string, and return the result for printing + - printf_builtin: consistently print an error message if printstr() + returns < 0, since it will only do that if ferror(stdout) is true; + let the PRETURN macro do that if appropriate, so we don't duplicate + code + + 2/2 + --- +builtins/printf.def + - printwidestr: wide-character version of printstr; understands + fieldwidth and precision as characters instead of bytes + - printf_builtin: interpret %ls and %lc as referring to wide strings + and characters, respectively; use printwidestr to print the wide- + character string obtained from the (presumably multibyte) argument. + Fieldwidth and precision are characters, not bytes + + 2/3 + --- +builtins/set.def + - unset_builtin: since tokenize_array_reference modifies its NAME + argument, we need to restore the original word if there is no + array variable found with that name, so we can go ahead and try to + unset a function with that wonky name. Inspired by a report from + Emanuele Torre + +parse.y + - read_token_word: don't set the W_HASDOLLAR flag in the returned WORD + for <(command) and >(command). That way they can be used in function + names. + +execute_cmd.c + - execute_simple_command: if in posix mode, don't perform function + lookup for command names that contain a slash + +builtins/enable.def + - dyn_load_builtins: don't allow dynamically loaded builtins to have + slashes in their name + + 2/4 + --- +general.c + - valid_function_word: new function, used to check whether a word can + be used as a function name. Replaces call to check_identifier(); + incorporates POSIX interp 383 check for special builtin so we can + move it out of execute_intern_function(). + - valid_function_name: use the FLAGS argument instead of POSIXLY_CORRECT; + only reject reserved words if FLAGS&1 + +execute_cmd.c + - execute_intern_function: call valid_function_word() instead of + check_identifier(); remove check for special builtin that + valid_function_word performs + +print_cmd.c + - print_function_def,named_function_string: pass POSIXLY_CORRECT to + valid_function_name as the FLAGS argument + + 2/6 + --- +subst.c + - expand_subscript_string: don't set W_NOTILDE in td.flags so we + perform `normal' tilde expansion (expansion at the start of the + word) on the array subscript + - expand_oneword,expand_compound_assignment_word: change second arg to + ATYPE, which better reflects its use + +arrayfunc.c + - assign_assoc_from_kvlist,assign_compound_array_list,expand_and_quote_assoc_word: + use expand_assignment_string_to_string instead of expand_subscript_string + for the rhs of the assignment or the second word in the kvpair to + be more consistent with how assignment statements behave (e.g., + tilde expansion). Fixes issue reported by maroloccio@gmail.com + + 2/7 + --- +parse.y + - discard_until: now returns the last character read. If we get an + EOF while processing a comment, return EOF (rarely happens; + shell_getc returns EOF only under certain circumstances) + - read_token: if discard_until returns EOF, return yacc_EOF + +input.h + - bclearerror: new macro, clears the B_ERROR flag in the buffered + stream BP + +input.c + - b_fill_buffer: try making errors `sticky': if the B_ERROR flag is + set for the buffered stream, return EOF immediately. This is similar + to what stdio does + +builtins/fc.def + - fc_builtin: in posix mode, if there are extra arguments supplied to + -s (e.g. pat=rep first last), throw an error + +doc/{bash.1,bashref.texi} + - printf: document new altform for %q/%Q and %ls/%lc + + 2/8 + --- +bashline.c + - set_up_new_line: if the new line doesn't change rl_line_buffer, + just return right away without changing rl_point. Affects + alias-expand-line, history-expand-line, and history-and-alias-expand-line. + Inspired by a report from + Addison Brendtro + +builtins/declare.def + - declare_internal: make multiple calls to `local -' at the same + context have no effect after the first one. That way we don't keep + overwriting the saved option set. Report and fix from + Emanuele Torre + + 2/10 + ---- +execute_cmd.[ch] + - bind_lastarg: now a public function + +parse.y + - execute_variable_command: call bind_lastarg instead of bind_variable + to avoid exporting $_ if allexport is set. Fix from + Emanuele Torre + - history_delimiting_chars: if we're parsing some kind of delimited + construct that's *not* a quoted string, don't bother adding an extra + newline to the history if the current history entry already ends in + a newline. From https://savannah.gnu.org/support/?110838 via + Ganapathi Kamath + + 2/13 + ---- +bashline.c + - set_up_new_line: add some more heuristics to try and usefully + position rl_point + + 2/16 + ---- +lib/readline/complete.c + - complete_fncmp: fix for case mapping `-' and `_' if the bytes do not + form a valid multibyte character + +lib/readline/util.c + - new functions: _rl_strcaseeqn, like strcasencmp but with a flag to + handle character mapping (-_) like completion-map-case wants, and + _rl_charcasecmp, to do the same thing for two characters. + Inspired by a patch from Brennan Vincent + +lib/readline/mbutil.c + - new functions: _rl_mb_strcaseeqn and _rl_mb_charcasecmp, multibyte + versions of the above + Inspired by a patch from Brennan Vincent + +lib/readline/{rlprivate.h,rlmbutil.h} + - extern declarations for the above functions + +lib/readline/complete.c + - complete_fncmp: use _rl_mb_strcaseeqn and _rl_strcaseeqn as + appropriate, remove duplicated inline code + Inspired by a patch from Brennan Vincent + +lib/readline/{isearch.c,rlprivate.h} + - _rl_search_case_fold: new variable, will be used to indicate case- + insensitive incremental and non-incremental searches + +lib/readline/bind.c + - search-ignore-case: new bindable variable, tied to _rl_search_case_fold + Inspired by a patch from Brennan Vincent + +lib/sh/mbsncmp.c + - mbsncmp(3) replacement + +lib/readline/isearch.c + - _rl_isearch_dispatch: honor `search-ignore-case' variable and perform + case-insensitive incremental searches if it's set + Inspired by a patch from Brennan Vincent + +lib/readline/histlib.h + - CASEFOLD_SEARCH: new flag for history searching, means to search + strings case-insensitively + +lib/readline/histsearch.c + - history_search_internal: anchored searches honor CASEFOLD_SEARCH + +lib/readline/histsearch.c + - history_search_internal: searches now honor CASEFOLD_SEARCH + - _hs_history_search: new function, just external interface to + history_search_internal, allows the rest of the library to specify + search flags + +lib/readline/histlib.h + - _hs_history_search: extern declaration + +lib/readline/search.c + - noninc_search_from_pos: use _hs_history_search, add CASEFOLD_SEARCH + to flags if _rl_search_case_fold is non-zero + +doc/bash.1,lib/readline/doc/{readline.3,rluser.texi} + - search-ignore-case: document new bindable variable + + 2/17 + ---- +config-top.h + - PATSUB_REPLACE_DEFAULT: macro set to 1 or 0 to set the default value + of `patsub_replacement'. Can be overridden by -DPATSUB_REPLACE_DEFAULT=0 + in the `make' command + +builtins/shopt.def + - reset_shopt_options: reset patsub_replacement to PATSUB_REPLACE_DEFAULT + +subst.c + - patsub_replacement: initialize to PATSUB_REPLACE_DEFAULT + +parse.y + - shell_getc: only call clearerr(stdin) when yy_stream_get returns EOF + if the shell is currently interactive (interactive != 0) + - shell_getc: if the shell is not interactive (interactive_shell == 0) + and using stdio to read the script (bash_input.type == st_stream), + set shell_input_line_terminator to READERR if ferror(stdin) is true + after yy_stream_get returns EOF + + 2/20 + ---- +doc/{bash.1,bashref.texi} + - update aliases description based on a bug-bash discussion + - update description of word splitting behavior when IFS is unset + +builtins/evalfile.c + - _evalfile: if reading the entire file doesn't return the same + number of bytes as requested (the file size), treat this as a read + error + + 2/21 + ---- +parse.y + - yylex: if read_token returns < 0, return YYEOF if EOF_Reached = 1. + Don't return yacc_EOF because that allows commands to be executed. + - grammar: add a production to handle YYEOF, treating it the same as + yacc_EOF. Based on a report from + Eduardo A. Bustamante López + +jobs.c + - wait_for: if we're checking for window size changes, allow checks + during trap commands while readline is active or `bind -x' command + execution. Fix from Koichi Murase + + 2/22 + ---- +jobs.c + - wait_for: check for window size changes during programmable completion + + 2/23 + ---- +execute_cmd.c,input.c,jobs.c,nojobs.c,parse.y,redir.c,shell.c +builtins/{exec.def,read.def} +input.h + - BUFFERED_INPUT: preprocessor #define is gone, this code is now + unconditional + + 2/24 + ---- +builtins/declare.def + - declare_internal: set the att_propagate flag on a variable that is + marked as att_tempvar only if it's *not* marked att_local. The + effect is that local variables with the same name as variables in + the temporary environment are not propagated to the previous scope. + From a report by Voldemar Lazarev + that prompted a bug-bash discussion + +builtins/setattr.def + - set_var_attribute: don't set local variables for which we are setting + export or readonly to propagate back to the previous context, but + make sure we preserve posix semantics + +parse.y + - read_token_word: if we're parsing the words of a compound assignment + (parser_state & PST_COMPASSIGN), and we have a valid assignment + statement as a word ([sub]=value), set W_NOBRACE in the word so we + don't try and perform brace expansion on it. This makes ( [sub]=word ) + closer to name[sub]=word. + From a report by Ilkka Virta back in July, 2020: + https://lists.gnu.org/archive/html/bug-bash/2020-07/msg00133.html + + 2/27 + ---- +lib/readline/display.c + - rl_redisplay: if HANDLE_MULTIBYTE is defined, do the special META_CHAR + handling if wc_bytes == wc_width == 1 + +execute_cmd.c + - eval_arith_for_expr: make sure we don't call make_word with a NULL + string if expand_arith_string returns NULL. Report from + F G + +arrayfunc.c + - assign_assoc_from_kvlist: added code, currently disabled, to perform + all expansions, including word splitting, on the kv-pair word list + + 2/28 + ---- +lib/readline/search.c + - rl_history_search_reinit: change check against history_string_size + to account for history_string_size now being a size_t. Report and + fix from Grisha Levit + + 3/2 + --- +lib/readline/history.c + - _hs_search_history_data: search the history list for an entry with + `data' matching the argument; return the index + - _hs_replace_history_data: search backwards through the history list + from the end + +lib/readline/histlib.h + - _hs_search_history_data: extern declaration + +lib/readline/search.c + - make_history_line_current: make sure rl_undo_list doesn't appear in + any history entries (it should be a private search string undo list) + before freeing it + +lib/readline/misc.c + - _rl_free_saved_history_line: make sure the undo list in + _rl_saved_line_for_history isn't rl_undo_list and doesn't appear in + any history list entries as `data' before freeing it. Fixes core + dump after SIGINT reported by Grisha Levit + +parse.y,print_cmd.c + - changes for size_t when computing new amount for xrealloc + + 3/3 + --- +parse.y + - set_word_top: new inline function to check and set word_top; called + from the appropriate places + - parse_dparen: call set_word_top before parsing an arith command or + nested subshell. Fixes underflow issue reported by + Grisha Levit + +examples/loadables/kv.c + - kv: new loadable builtin, reads key-value pairs from stdin and assigns + them to an associative array + + 3/7 + --- +builtins/trap.def + - trap_builtin: if trying to restore SIGQUIT to its default disposition, + and the shell is in posix mode, set to SIG_DFL if the shell is + running as an async command and signal_is_async_ignored (SIGQUIT) is + true. Posix conformance issue 751 + + 3/8 + --- +builtins/alias.def + - print_alias: now returns int. Check for write errors using sh_chkwrite + and return EXECUTION_FAILURE if it fails + - alias_builtin: if print_alias returns EXECUTION_FAILURE, return + EXECUTION_FAILURE immediately (write error). POSIX test conformance + + 3/9 + --- +builtins/cd.def + - change_to_directory: if we're not in physical mode and are in posix + mode, add step 9 of the posix cd algorithm, which essentially tries + the pathname the user supplied if it's shorter than PATH_MAX and the + length of the canonicalized pathname is longer than PATH_MAX. This + is basically what default bash mode does without the length checks. + POSIX test conformance. + +subst.c + - strip_trailing_ifs_whitespace: use ifs_whitespace(*s) instead of + spctabnl(*s) like word splitting and get_word_from_string. POSIX + test conformance + +jobs.c + - wait_for: tweak change from 1/18 to make sure a J_ASYNC job isn't in + the foreground (J_FOREGROUND) as it would be if it had been continued + in the foreground with `fg'; if it is, we want to give the terminal + back to shell_pgrp + + 3/10 + ---- +input.c + - fd_berror: returns true if the file descriptor passed as an arg + corresponds to a buffered stream with an error condition + +parse.y + - shell_getc: use fd_berror instead of inline code + - shell_getc: if yy_getc returns EOF, immediately set line[0] to NULL + and set shell_input_line_terminator to READERR. Then exit immediately + with status 128 if index == 0, line[index] == NULL, and READERR. + Posix interp 1629 + +config-top.h + - FATAL_READERROR: now defined to 1 by default + +lib/readline/display.c + - rl_expand_prompt: allocate an empty string for local_prompt if prompt + is the NULL or empty string. Fixes seg fault with rl_message and + empty prompt reported by Grisha Levit + +lib/readline/histexpand.c + - history_expand: if hist_extract_single_quoted returns an index at or + past the end of the string, correct the index and break the loop, + which will cause a return. Report and fix from + Grisha Levit + + 3/13 + ---- +lib/readline/vi_mode.c + - rl_domove_motion_callback: set the MOVE_FAILED flag in the context M + if rl_dispatch returns non-zero and other movement-command-specific + conditions are met. Right now, an unsuccessful `f' or `F' command + is failure. + - _rl_vi_domove_motion_cleanup: if the command is `c' or `C', we don't + enter insert mode if the MOVE_FAILED flag is set in the context M. + This is how standalone vi works. + +lib/readline/kill.c + - rl_unix_filename_rubout: add some checks for rl_point > 0 before + looking at rl_line_buffer[rl_point - 1]. Report and fix from + Grisha Levit + +lib/readline/isearch.c + - _rl_isearch_dispatch: reset cxt->sline_index to 0 if it's past the + end of the history string (sline_len). Fixes asan bug reported by + Grisha Levit + +lib/readline/histexpand.c + - history_tokenize_word: don't increment the string index past the + NULL if the line ends in a backslash.Fixes asan bug reported by + Grisha Levit + +lib/readline/vi_mode.c + - rl_vi_yank_to,rl_vi_change_to,rl_vi_delete_to: if these are called + with an existing valid vimvcxt, save it and allocate a new one for + the current function call to use, then restore it before returning. + This prevents referencing vimvcxt after freeing it in the case that + these functions call each other recursively (e.g., y1y1, c1d1, etc.). + Fixes asan bug reported by Grisha Levit + + 3/14 + ---- +bashhist.c + - bash_add_history: make sure curlen is large enough before checking + curlen - 1 and curlen - 2, otherwise you can get buffer underflow. + Fixes asan bug reported by Grisha Levit + +bashline.c + - bash_spell_correct_shellword: don't bother trying to correct empty + words. Fixes asan bug reported by Grisha Levit + +lib/sh/shquote.c + - sh_mkdoublequoted: make sure to allocate enough memory for the + pathological case: where every character in the string needs to be + backslash-escaped because it's special within double quotes. + Fixes asan bug reported by Grisha Levit + +doc/{bash.1,bashref.texi} + - here documents: make sure the summary specifies the here-document is + terminated by `delimiter'; specify what the delimiter is if the word + is not quoted. Prompted by a help-bash post from + goncholden + + 3/15 + ---- +doc/bash.1,lib/readline/doc/rluser.texi + - shell-expand-line: enumerate the specific expansions performed. + From a request by Alex Bochannek + +findcmd.c + - path_value: new function, returns normalized version of $PATH. Takes + a single argument saying whether or not to look in the temporary + environment first. Normalizes null $PATH (PATH=) into ".". From a + bug-bash discussion started by Moshe Looks + - _find_user_command_in_path: use path_value() + - user_command_matches: use path_value() + - search_for_command: if PATH[0] == 0, set PATH = "." like path_value(). + This has the side effect of calling command_not_found_handle when + PATH is the empty string and the command isn't in the current + directory + - search_for_command: if path == 0, but we found an executable in the + current directory, make sure to set dot_found_in_search before adding + it to the command hash table + +findcmd.h + - path_value: extern declaration + +bashline.c + - command_word_completion_function: use path_value() + +builtins/enable.def + - dyn_load_builtin: use path_value for BASH_LOADABLES_PATH; it's cleaner + though it doesn't change the behavior + + 3/17 + ---- +bashline.c + - bashline_reset: reset rl_filename_quoting_function, since there is a + SIGINT code path where it could remain reset by glob completion. + Reported by Grisha Levit + - command_word_completion_function,command_subst_completion_function, + glob_complete_word: set some static variables to NULL + after freeing them so they don't potentially get freed twice after + a SIGINT during completion + Reported by Grisha Levit + +parse.y + - read_token_word: when deciding how to quote translated strings, don't + free ttok before comparing it to ttrans + Reported by Grisha Levit + - parse_matched_pair: same thing for freeing nestret + - read_token: if we return a newline, make sure we call set_word_top() + if necessary. + Fixes underflow reported by Grisha Levit + +lib/glob/sm_loop.c + - EXTMATCH: don't bother with FNM_PATHNAME checks; this function isn't + called with a pathname. + Fixes underflow reported by Grisha Levit + +lib/readline/misc.c + - rl_maybe_replace_line: if we replace a history entry's data with + rl_undo_list, we need to set rl_undo_list to 0, since we should not + have rl_undo_list pointing to something from a history entry + Fixes asan error reported by Grisha Levit + + 3/20 + ---- +lib/readline/histexpand.c + - postproc_subst_rhs: fix off-by-one error when reallocating new string + for case where we're *not* substituting for `&' + Fixes asan error reported by Grisha Levit + +jobs.c + - terminate_current_pipeline: add a SIGKILL call in there in case the + SIGTERM doesn't work + - terminate_current_pipeline: add a version that works when job control + isn't enabled (pipeline_pgrp == shell_pgrp) + +subst.c + - skip_to_delim: pass completeflag (SX_COMPLETE) to extract_dollar_brace_string + in case it includes a command substitution, since we want to inhibit + error messages in this case + +parse.y + - no_semi_successors: add DOLPAREN to list since something like $(\n + shouldn't have a semicolon added there. + From a report by Grisha Levit + + 3/21 + ---- +pcomplete.c + - gen_globpat_matches: set noglob_dot_filenames here since we're not + calling shell_glob_filename to do it + From a report by Grisha Levit + + 3/22 + ---- +lib/readline/misc.c + - rl_maybe_replace_line: if we're replacing a history entry with the + current line buffer and undo list, then zero out any undo list in + _rl_saved_line_for_history, since we're not going to use it any more + Fixes asan error reported by Grisha Levit + +lib/readline/undo.c + - rl_free_undo_list: if we're freeing rl_undo_list, it can't be a + valid value for data in _rl_saved_line_for_history + Fixes asan error reported by Grisha Levit + +lib/readline/complete.c + - display_matches: don't call rl_display_match_list if we received a + signal during get_y_or_n and didn't jump out for some reason + From a report by Grisha Levit + - rl_display_match_list: return if we received a signal during + _rl_internal_pager (via get_y_or_n) and didn't jump out + From a report by Grisha Levit + + 3/23 + ---- +lib/readline/history.c + - history_truncate_file: don't bother trying to read the existing + history file if we're just truncating it to 0 lines + + 3/24 + ---- +lib/readline/histfile.c + - history_truncate_file: fix off-by-one error that resulted in the + timestamp associated with the first history entry not being written + to the truncated history file + From a report by Grisha Levit + +parse.y + - decode_prompt_string: do something rational if localtime() returns + NULL (extraordinarily rare) + From a report by Paul Eggert + +examples/loadables/stat.c + - stattime: ditto + +examples/loadables/strftime.c + - strftime_builtin: ditto + +lib/readline/examples/histexamp.c + - main: ditto + +include/posixtime.h + - getnow(): new inline function, calls gettimeofday and returns tv_sec; + replacement for time(0). From Paul Eggert + +general.h + - NOW: use a call to getnow() to standardize on gettimeofday for time + information + +lib/readline/history.c + - include #posixtime.h for getnow() + - hist_inittime: use getnow() instead of calling time(0) + +parse.y + - posixtime.h: include instead of + - decode_prompt_string: use getnow() instead of calling time(0) + + 3/27 + ---- +parse.y + - count_all_jobs: add extern definition if JOB_CONTROL is not defined. + From Emanuele Torre + +bashhist.c + - bash_add_history: make sure the current history line is not empty + before checking what ended it. + From a report by Grisha Levit + +lib/readline/histexpand.c + - history_tokenize_word: break out of loop for incomplete command and + process substitution or extended globbing patterns + From a report by Grisha Levit + +bashline.c + - hostnames_matching: fix size_t issue when checking whether to realloc + From a report by Grisha Levit + +lib/sh/random.c + - genseed: use uintptr_t instead of u_bits32_t to silence compiler + warnings. From Paul Eggert + +aclocal.m4 +array2.c +builtins/mkbuiltins.c,builtins/psize-posix.c,version.c +builtins/getopts.def +lib/readline/text.c,lib/readline/bind.c +support/recho.c,support/mksignames.c,support/zecho.c,support/xcase.c +support/printenv.c,support/signames.c,support/bashversion.c +support/memtest.c,support/endian.c +lib/glob/gm_loop.c + - some cleanups for function prototypes and other stdc requirements + From Paul Eggert + +lib/readline/doc/{rltech.texi,hstech.texi} + - add prototypes and stdc requirements to the examples + +builtins/complete.def + - compgen_builtin: save and restore readline variables affecting how + filename completions are treated in case someone uses compgen in + the foreground. + From a report by Grisha Levit + + 3/28 + ---- +aclocal.m4 +builtins/enable.def,builtins/gen-helpfiles.c,builtins/help.def,builtins/printf.def +general.h,hashlib.h +include/ansi_stdlib.h,include/ocache.h +lib/glob/collsyms.h,lib/glob/glob.c +lib/readline/history.h,lib/readline/xmalloc.h +xmalloc.c,xmalloc.h +lib/sh/strtrans.c +lib/tilde/tilde.c +mksyntax.c +support/endian.c + - don't bother with __STDC__ if we are just using C89 features like + const, function prototypes, etc. + From Paul Eggert + +externs.h + - prototype the list functions that take GENERIC_LIST * + From Paul Eggert + +builtins/common.c,examples/loadables/getconf.c +execute_cmd.c,pcomplete.c,subst.c +lib/sh/stringlist.c,lib/sh/stringvec.c + - changes and casts now that the generic list functions are prototyped + From Paul Eggert + + 3/29 + ---- +aclocal.m4,configure.ac +builtins/common.c,builtins/mkbuiltins.c,builtins/printf.def +include/memalloc.h,include/stdc.h +general.h,jobs.h +pcomplete.c,print_cmd.c +m4/iconv.m4 +lib/readline/bind.c,lib/readline/complete.c,lib/readline/display.c +lib/readline/funmap.c,lib/readline/util.c,lib/readline/parens.c +lib/readline/histlib.h +lib/readline/readline.h,lib/readline/rldefs.h,lib/readline/rlstdc.h,lib/readline/rlprivate.h +lib/sh/dprintf.c,lib/sh/snprintf.c,lib/sh/vprintf.c +lib/malloc/shmalloc.h,lib/malloc/imalloc.h,lib/malloc/xmalloc.c +lib/termcap/termcap.h + - stdarg: since we now assume C89 for prototypes at least, always + prefer stdarg to old-style varargs + - SH_VA_START: now use plain old va_start + - don't bother with extern declarations for standard C89 functions + From Paul Eggert + +config-bot.h + - PREFER_STDARG: remove + +builtins/mkbuiltins.c +execute_cmd.c,unwind_prot.c +unwind_prot.h + - start on ANSI/ISO C changes for the unwind-protect framework + - introduce new unwind-protect function pointer type to replace + Function + From Paul Eggert + + 3/30 + ---- +builtins/command.def,builtins/fc.def,builtins/read.def,builtins/source.def +builtins/evalfile.c,builtins/evalstring.c +dispose_cmd.c,execute_cmd.c,pcomplete.c,print_cmd.c,subst.c,jobs.c,variables.c +dispose_cmd.h,general.h,trap.h +unwind_prot.c,unwind_prot.h + - rest of work to convert unwind-protect framework to ANSI/ISO C. + Convert unwind-protects to use new shim functions that obey the new + unwind-protect function type + From Paul Eggert + +general.h + - STREQ, STREQN: now static inline functions to take advantage of arg + type conversion + +pcomplete.c,subst.c +lib/readline/histexpand.c,lib/readline/mbutil.c + - fix size_t subtractions in comparisons to avoid unsigned underflow + +externs.h +execute_cmd.c +builtins/times.h + - add prototypes for functions taking clock_t and timeval, make their + declaration in externs.h conditional on NEED_CLOCK_FUNCS_DECL and + NEED_TIMEVAL_FUNCS_DECL, respectively + + 3/31 + ---- +subst.c + - expand_string_dollar_quote: check for zero-length return from + string_extract_{single,double}_quoted and avoid size_t underflow + Fixes asan error reported by Grisha Levit + + 4/3 + --- +builtins/evalstring.c + - open_redir_file: treat the case of failing to open the file as a + non-fatal expansion error instead of a (fatal) redirection error. + Report from Zev Weiss + + 4/4 + --- +lib/readline/vi_mode.c + - _rl_domove_motion_cleanup: d/D require the same special case as c/C + so that a motion command that doesn't move the cursor consumes/deletes + at least one character. + From Emanuele Torre + - _rl_domove_motion_cleanup: ditto for y/Y + - rl_domove_motion_callback: if t/T/;/, fail (return non-zero without + moving point), flag the motion command as having failed (MOVE_FAILED) + + 4/6 + --- +subst.c + - command_substitute: save the return status of the child process in + last_command_subst_status; don't assign to last_command_exit_value + in posix mode (posix interp 1150) + +execute_cmd.c + - execute_null_command: a simple command without a command word but + with command substitutions now returns last_command_subst_status. + It may or may not have already modified $? depending on posix mode + +redir.c + - redir_varvalue: legal_number validity check should be == 0, not < 0 + From a report by Grisha Levit + + 4/10 + ---- +subst.c + - parameter_brace_expand_rhs: check for namerefs in the variable name + part of the ${name=word} expansion so we can go back and implement + the POSIX semantics of returning "the final value of parameter." + From a report by Grisha Levit + +sig.c,sig.h + - sigpipe_handler: clean up, set $?, and throw to top level on receipt + of a SIGPIPE + - termsig_handler: if the variable builtin_catch_sigpipe is set (it's + not set anywhere yet), call sigpipe_handler instead of terminating + the shell. Still need to make sure a sighandler is installed for + SIGPIPE even if initialize_terminating_signals isn't called + + 4/14 + ---- +lib/sh/tmpfile.c + - sh_mktmpfd: add support for MT_UNLINK flag, unlinks created filename + before returning fd, fails if the unlink fails for some reason + + 4/15 + ---- +pathexp.c,pathexp.h + - globsort: support for various glob sorting criteria as defined by + the GLOBSORT variable: name, size, blocks, mtime, atime, ctime. + Default is ascending sort by name, as is traditional. Based on an + idea from Evan Gates + - setup_globsort: parse the value of the GLOBSORT variable, find + sorting type and whether or not it's ascending or descending + - noquote_glob_filename: glob_filename for programmable completion, + doesn't call quote_string_for_globbing and honors GLOBSORT, dotglob, + and globstar + +pcomplete.c + - gen_globpat_matches: call noquote_glob_filename, let that handle + all the variables and GLOB_FAILED + +variables.c + - GLOBSORT: support for special variable, call setup_globsort on + set or unset + +doc/bash.1,doc/bashref.texi + - GLOBSORT: document variable and its effects on pathname expansion + + 4/17 + ---- +builtins/complete.def + - build_actions: take an additional char ** arg VNAMEP; if it is non- + null, accept a -V VARNAME option that names an indexed array + variable in which to store the completions. + - compgen_builtin: if the -V option is supplied, store the possible + completions into VARNAME instead of printing them on stdout. From a + patch from Grisha Levit , idea originally + from konsolebox back in 2/2022 + +doc/bash.1,lib/readline/doc/rluser.texi + - compgen: document new -V option + + 4/18 + ---- +lib/readline/vi_mode.c + - rl_domove_read_callback: call _rl_arg_init before reading digit + argument so prompt gets saved, both callback and non-callback modes + From a report by Grisha Levit + - rl_vi_arg_dispatch: if we return 0 to end the digit argument and + turn off NUMERICARG, call rl_restore_prompt + +lib/readline/histexpand.c + - history_expand_internal: make sure subst_lhs is not null before we + call postproc_subst_rhs. + From a report by Grisha Levit + +lib/readline/display.c + - rl_redisplay: remove redundant code that ends up incrementing lpos + too much for meta characters displayed as octal escape sequences. + From a report by Grisha Levit + + 4/19 + ---- +bashline.c + - attempt_shell_completion: handle case where s > e after calls to + find_cmd_start and find_cmd_end, respectively. + From a report by Grisha Levit + +lib/readline/display.c + - update_line: fix setting of `wsatend' when computing ols and nls in + the multibyte case; this caused redisplay to print more characters + than it needed + - update_line: fix calculation of visible_wrap_offset when moving up + to line 0, trying to figure whether or not the visible prompt has + any invisible characters. Fixes C locale issue reported by + Grisha Levit + + 4/20 + ---- +lib/readline/text.c + - _rl_rubout_char: update erase-at-end-of-line hack to deal with the + unlikely event that a character in a non-multibyte locale is + displayed using an octal representation. + From a report by Grisha Levit + +execute_cmd.c,execute_cmd.h,builtins/evalstring.c + - interrupt_execution: replaces `executing_list' + - interrupt_execution: set while executing while, for, until, select, + and arithmetic for loops + +jobs.c + - wait_for: if a process dies due to a SIGINT while the shell is + executing a loop or a list, act as if the shell got SIGINT. This + is no longer dependent on the compatibility level + From a report by Grisha Levit + +bashline.c + - name_is_acceptable: allow FIGNORE suffixes to match the entire + pathname like tcsh does instead of requiring a non-empty prefix. + From Emanuele Torre + + 4/23 + ---- +lib/readline/misc.c + - _rl_unsave_line: new function, takes a HIST_ENTRY * as an argument, + generalized rl_maybe_unsave_line + - _rl_alloc_saved_line: allocate a new HIST_ENTRY *, populate it like + rl_saved_line_for_history + - _rl_free_saved_line: free a saved HIST_ENTRY * + - _rl_free_saved_history_line: call _rl_free_saved_line + - _rl_previous_history_internal: new function, internals of + rl_get_previous_history; change rl_get_previous_history to call it + +lib/readline/history.h + - HIST_ENTRY_DEFINED: define sentinel if HIST_ENTRY struct defined + +lib/readline/rlprivate.h + - _rl_alloc_saved_line,_rl_free_saved_line,_rl_unsave_line: new extern + function definitions + - _rl_free_saved_search_line: new extern definition + +lib/readline/search.c + - _rl_saved_line_for_search: use private storage to save current line, + avoid clashes with rl_saved_line_for_history + - _rl_free_saved_search_line,_rl_unsave_saved_search_line: new functions + to manage _rl_saved_line_for_search + - noninc_dosearch,_rl_nsearch_abort: clean up _rl_saved_line_for_search + instead of rl_saved_line_for_history + - rl_history_search_internal: allocate private _rl_saved_line_for_search; + unsave or free it as appropriate + - _rl_history_search_reinit: free up any _rl_saved_line_for_search just + in case + +lib/readline/vi_mode.c + - rl_vi_search: free _rl_saved_line_for_search, since that's what the + non-incremental search functions use now + - rl_domove_read_callback: if we read a numeric argument, then a motion + character, make sure the motion character is valid before returning + it and going on + From a report by minipython <599192367@qq.com> + + 4/27 + ---- +lib/readline/display.c + - _rl_move_cursor_relative: when checking to see whether data is within + the invisible line, make sure to stay within the invisible line + line break boundaries + From a report by minipython <599192367@qq.com> + +lib/readline/search.c + - dispose_saved_search_line: new function, either unsave the saved + search line (if we're not at the end of the history) or free it + (if we are). Needs to be immediately followed by call to + make_history_line_current, which resets rl_undo_list + - make_history_line_current: change strategy: rely on callers to + manage _rl_saved_line_for_search and rl_undo_list; just copy the + data from the passed history entry into the line buffer and reset + rl_undo_list + - noninc_dosearch,rl_history_search_internal: call dispose_saved_search_line + before calling make_history_line_current + +lib/readline/misc.c + - _rl_start_using_history: free the undo list associated with + _rl_saved_line_for_history, if one exists. Have to watch out for + this causing pointer aliasing problems, maybe add a call to + _hs_search_history_data() + + 4/28 + ---- +pathexp.c + - sh_globsort: a sort specifier of `nosort' disables sorting completely + +doc/bash.1,doc/bashref.texi + - GLOBSORT: document `nosort' sort specifier + +bashline.c + - attempt_shell_completion: attempt completion with the empty command + for a null command word on a line with only whitespace following any + optional assignment statements + - attempt_shell_completion: make sure that the start of the command + word is not after rl_point before calling the programmable completion + for the initial word. + From a report by Grisha Levit + +lib/readline/histexpand.c + - history_expand: don't read past the end of the string if it ends with + an incomplete multibyte character + From a report by Grisha Levit + + 5/1 + --- +lib/readline/text.c + - _rl_insert_char: make sure to return 1 in all cases where there are + pending bytes accumulating for a multibyte character + - _rl_insert_char: if the COUNT argument is 0, insert any pending + bytes read so far. The idea is that these bytes were accumulating + to compose a possible multibyte character, and the count of 0 + indicates that the current character doesn't contribute to that + because it's bound to an editing command. + - rl_insert, rl_quoted_insert: make sure to call _rl_insert_char + with a 0 count as appropriate to insert any accumulating bytes + From a patch by Grisha Levit + +sig.c + - top_level_cleanup,throw_to_top_level: set variable_context to 0, just + to make sure + +execute_cmd.c + - function_misc_cleanup: new function, runs make_funcname_visible and + unlink_fifo_list at the end of execute_function, replaces inline + code + - uw_function_misc_cleanup: unwind-protect function, just calls + function_misc_cleanup. Installed by execute_function. + Partial fix for FUNCNAME bug reported by Grisha Levit + - execute_builtin: run unwind-protects if evalnest exeeds max + - execute_builtin: run unwind-protects if sourcenest exeeds max + +parse.y + - parse_string_to_word_list: set current_token = '\n' on error + - parse_string_to_word_list: if we're executing and not running in + parse_and_execute, call top_level_cleanup before we jump to the + top level. Rest of fix for FUNCNAME bug + - parse_compound_assignment: set last_read_token and current_token to + '\n' on parse error. Fix for alias expansion bug reported by + Grisha Levit + - parse_compound_assignment: if we're executing and not running in + parse_and_execute, call top_level_cleanup before we jump to the + top level + + 5/2 + --- +jobs.c + - run_sigchld_trap: don't freeze and unfreeze the jobs list; move it + to the callers who are running this on SIGCHLD receipt and cannot + deal with jobs disappearing from the list while they're running + - waitchld: if we are running the wait builtin, continue to run the + SIGCHLD trap immediately upon signal receipt, but freeze and + unfreeze the jobs list around the call to run_sigchld_trap(). + Fixes issue with `jobs' in a SIGCHLD trap not removing jobs from + the jobs list reported by Guldrelokk + + 5/4 + --- +input.c + - fd_to_buffered_stream: make sure buffers[fd2] is non-null before + turning on SHAREDBUF. + From Emanuele Torre + +eval.c + - reader_loop: save and restore EOF_Reached around expanding $PS0, + setting it to 0 for the expansion so it doesn't affect things like + command substitution. + From a report by Grisha Levit + +parse.y + - parse_comsub: handle ${Ccommand; }, where C == space, tab, newline, + or '|' + - read_token_word: understand ${Ccommand; } and call parse_comsub to + parse the contents + - parse_matched_pair: understand ${Ccommand; } inside another paired + construct + - new `funsub' production, like comsub but for ${Ccommand;} nofork + command substitution + +execute_cmd.c + - execute_simple_command: if we fork because of pipes in or out, clear + the fifo list, since subshell aren't supposed to inherit fifos + + 5/8 + --- +parser.h + - PST_FUNSUBST: new parser state, parsing the command in ${Ccommand;}. + Primarily used to have read_token_word return `}' as a separate + token even if it's not delimited like a reserved word + +subst.h + - SX_FUNSUB: new flag, tell xparse_dolparen we are parsing the command + in a ${Ccommand;} nofork command substitution + +parse.y + - xparse_dolparen: handle parsing ${Ccommand;} nofork command + substitution like parse_comsub + - read_token: if we're parsing a foreground command substitution, + treat a word that begins with an unquoted `}' as a `}' token to + terminate the ${Ccommand;} construct without requiring that the + close brace be delimited like a reserved word + - no_semi_successors: add DOLBRACE + - reserved_word_acceptable: add DOLBRACE + +subst.c + - extract_function_subst: like extract_command_subst, but for nofork + command substitutions; calls xparse_dolparen with the SX_FUNSUB + flag to differentiate + - string_extract_double_quoted,extract_delimited_string, + extract_heredoc_dolbrace_string,extract_dollar_brace_string, + param_expand: call extract_function_subst as appropriate + - function_substitute: like command_substitute, but for nofork command + substitutions. Just a stub for now + + 5/11 + ---- +jobs.[ch] + - pipeline_saver: already_making_children now saved and restored as + part of the struct; no longer need a separate variable + - save_pipeline,restore_pipeline: save already_making_children to struct + +parse.y + - parse_comsub,xparse_dolparen: handle `(' as the first char of a + funsub (ksh93 supports that) + +subst.c + - function_substitute: complete implementation; handle both funsubs + and valsubs (need different terminology); dummy up a fake shell + function so local variables and `return' work; do the right thing + with process groups + - executing_funsub: flag for the rest of the shell to know we're + expanding a funsub; used by parse_and_execute + +builtins/evalstring.c + - parse_and_execute: check executing_funsub to do the right thing with + alias expansion and posix mode + + 5/12 + ---- +doc/bash.1,doc/bashref.texi + - function substitution (or lambda substitution, or nofork command + substitution): document + + 5/15 + ---- +subst.c + - function_substitute: make sure to decrement variable_context in the + unwind-protects since we don't unwind_protect it individually. + Report from Oguz + + 5/17 + ---- +configure.ac + - i370 machines cannot use the bash malloc + Patch from Igor Todorovski + +support/signames.c + - initialize_signames: add support for z/OS signals. + Patch from Igor Todorovski + +lib/glob/smatch.c + - collseqcmp: new name for collequiv[_wc], that function apparently + exists in libc on z/OS + Patch from Igor Todorovski + +jobs.c + - mark_all_jobs_as_dead: make sure to reset js.j_ndead to the right + number of jobs in the array + +execute_cmd.c + - execute_while_or_until: move call to REAP() after the action + executes, like other loop functions + +shell.c,parse.y,lib/intl/gettextP.h + - add some __MVS__ checks for z/OS systems + + 5/18 + ---- +jobs.c + - wait_for_any_job: catch jobs that can terminate and be reaped + when we call UNBLOCK_CHILD between the loop where we check the + jobs list for dead jobs and the loop where we check for running + jobs and poll for them with wait_for(). + Fixes bug reported by Aleksey Covacevice + + 5/20 + ---- +subst.c + - read_comsub: quote CTLNUL if it's in $IFS and we're parsing the + RHS of an assignment statement + - comsub_quote_string: ditto + - comsub_shouldquote: break code that decides whether to CTLESC escape + a character read from a command substitution or $REPLY into its own + inline function; change read_comsub/comsub_quote_string callers + + 5/21 + ---- +subst.c + - quote_escapes_internal: use ifs_cmap instead of iterating through + ifs_value to set skip_ctlesc and skip_ctlnul + + 5/23 + ---- +parser.h + - remove `(' from FUNSUB_CHARS + +parse.y + - parse_comsub: don't bother with `(' as one of the FUNSUB_CHARS + +doc/bash.1,doc/bashref.texi + - command substitution: remove mention of `(' as a valid character + following the open brace in nofork command substitution + + 5/24 + ---- +parse.y + - parse_comsub: avoid adding `;' to an empty ${ command substitution + - parse_comsub: if open == '{', push back a newline we read into + peekc to get PS2 prompting right. + From a report by Grisha Levit + +subst.c + - skip_double_quoted: pass the SX_COMPLETE flag down to + extract_dollar_brace_string in case it contains an unclosed command + substitution. + From a report by Grisha Levit + + 5/25 + ---- +shell.c + - make sure shell_initialized is set to 1 before running -c command + +make_cmd.c + - make_function_def: initialize source_file to something other than + `main' or `environment' if the shell is not interactive. + From a report from Emanuele Torre + +parse.y + - save_token_state,restore_token_state: save and restore token_to_read + - read_token_word: if we read EOF in an interactive shell, set + token_to_read to yacc_EOF and EOF_Reached to 1 so the token will + be delimited but the next call to read_token returns yacc_EOF + - handle_ignoreeof: broke the code that checks eof_encountered and + possibly exceeds the ignoreeof limit out into a separate public + function, called from handle_eof_input_unit + +eval.c + - reader_loop: if EOF_Reached is set in an interactive shell after + parse_command and execute_command, and ignoreeof has been enabled, + check for ignoreeof with handle_ignoreeof and reset EOF_Reached + back to 0 if we should not exit. This can occur when EOF delimits + a simple command (simple_command_terminator) + From a report by Grisha Levit + + 5/27 + ---- +lib/readline/mbutil.c + - _rl_get_char_len: if SRC is "", make sure to return 0 + +lib/readline/isearch.c + - _rl_isearch_callback: if _rl_search_getchar returns EOF, return 1 + to abort search; if it returns with RL_STATE_ISEARCH unset, return + 1 (handling a signal can turn it off via _rl_isearch_cleanup) + + 5/29 + ---- +lib/readline/text.c + - _rl_insert_char, rl_quoted_insert: minor fixes from Grisha Levit + +builtins/printf.def + - bexpand: use the same calculation for the size of the return buffer + as ansicstr(). + From a report by Grisha Levit + +locale.c + - locale_setblanks: work around problem with macOS where isblank(x) + incorrectly returns true for characters 0x80-0xff in a UTF-8 locale + From a report by Grisha Levit + - set_default_locale_vars,set_locale_vars,reset_locale_vars: make sure + we call locale_setblanks after setting/resetting locale_utf8locale, + since we use that in locale_setblanks + +lib/sh/smatch.c + - charseqcmp,is_cclass,FOLD: make sure we don't treat chars >= 0x80 + as valid in a UTF-8 locale, since they are multibyte characters. + From a report by Grisha Levit with a full + explanation in http://www.openradar.me/FB9973780 + + 5/30 + ---- +builtins/enable.def + - enable_builtin: don't call dlopen with a null pathname, it will + succeed. Report from Wiley Young + +lib/readline/readline.c + - _rl_dispatch_subseq: if a user binds do-lowercase-version to something + that isn't an uppercase character, flag an error rather than recurse. + From a report by Grisha Levit + + 5/31 + ---- +builtins/enable.def + - enable_builtin: don't try to load a builtin that's not found if + the -n flag is supplied. + From a report from Emanuele Torre + +parse.y + - parse_comsub: use was_word code again to make sure we add a closing + `;' if the last token parsed before the closing ';' or '\n' was a + word, no matter what character ends it. + From a report by Grisha Levit + +aclocal.m4,configure.ac,findcmd.c + - IBM z/OS changes from Igor Todorovski + + 6/1 + --- +parse.y + - shell_getc: if the shell is not interactive and reading from a + buffered stream or stdin, and not expanding an alias, add a + backslash to a line ending with like we do when + reading from a string. This prevents a backslash-newline from + being discarded when we are removing backslash-newlines from the + input, since we will add a newline to shell_input_line in this case. + From a report by Rob Landley + +parse.y + - parse_compound_assignment: check and compensate for an alias being + popped out from underneath this function by read_token() (e.g., + alias L='m=("x")'. Since we don't push a new input source, we should + never restore pushed_string_list from the saved parser state, but + we check and only do this if we were expanding an alias when this + function was called. + From a report by Wiley Young + + 6/2 + --- +print_cmd.c + - print_if_command: make sure to print any pending here-documents after + printing the test. + From https://bugzilla.redhat.com/show_bug.cgi?id=2211214 + +builtins/enable.def + - if -n is supplied with -f, attempt to load the builtin but mark it + as disabled after loading. + Suggested by Robert Elz + +builtins/evalfile.c + - _evalfile: increment retain_fifos, so we don't delete any FIFOs or + pipes we inherited before sourcing this file; restore original value + before we return. + From https://savannah.gnu.org/support/index.php?110883 + + 6/3 + --- +subst.c + - expand_string_dollar_quote: if singlequote_translations is set, there + is a chance for a use-after-free of `t'. + From a report by Grisha Levit + + 6/7 + --- +jobs.c,nojobs.c,jobs.h + - job_control_active_p: new function, returns 1 if job control is + currently enabled and we have given away the terminal + +builtins/evalstring.c + - should_suppress_fork: don't optimize away the fork if job control is + active because we need to call end_job_control and give the terminal + back to the original process group when this command finishes. Call + job_control_active_p() to check this. + Report from Andrew Hamon + + 6/8 + --- +shell.c + - ssh_run_startup_files: new variable, set by run_startup_files if + the shell decides it's being run by ssh and runs bashrc (only if + SSH_SOURCE_BASHRC is defined). Non-zero while the startup files + are being run. Not used by any other part of the shell yet. + + 6/12 + ---- +arrayfunc.h + - new inline functions to convert between assignment flags (ASS_*), + array value flags (AV_*), and valid array flags (VA_*) + +shell.h + - include arrayfunc.h after subst.h and variables.h so all the values + for the new inline functions are available + +variables.c + - bind_int_variable: use convert_assign_flags_to_validarray_flags and + convert_assign_flags_to_arrayval flags instead of inline assignments + +builtins/common.c + - builtin_bind_variable: use convert_assign_flags_to_validarray_flags + instead of inline assignments + +arrayfunc.c + - assign_array_element: use convert_assign_flags_to_arrayval_flags + instead of inline code + - assign_array_element_internal: use convert_assign_flags_to_arrayval_flags + to pass the right values to array_expand_index + - assign_array_var_from_string: since expand_compound_array_assignment + performs one round of expansion on the subscripts, make sure to add + ASS_NOEXPAND (if assoc_expand_once is set) and ASS_ALLOWALLSUB to the + flags we pass to assign_compound_array_list + - unbind_array_index: use convert_validarray_flags_to_array_value_flags + to pass the right values to array_expand_index + - array_expand_index: uncomment code tagged for bash-5.3 that checks + AV_NOEXPAND and suppresses call to expand_arith_string if it's set. + This set of changes extends assoc_expand_once to indexed arrays + +arrayfunc.[ch],execute_cmd.c,expr.c,test.c,builtins/common.c,builtins/mkbuiltins.c +builtins/declare.def,builtins/set.def,builtins/shopt.def + - array_expand_once: new name for internal assoc_expand_once variable + + 6/13 + ---- +builtins/shopt.def + - array_expand_once: new option, replaces assoc_expand_once + +doc/bash.1,doc/bashref.texi + - array_expand_once: document new shopt option + + 6/15 + ---- +lib/readline/complete.c + - rl_full_quoting_desired: new application-settable variable, if set + to non-zero by an application completion function, all completions + will be quoted as if they were filenames, subject to the value of + rl_filename_quote_characters. Initialized to 0 and reset to 0 + by set_completion_defaults. + From a contribution by Grisha Levit + - QUOTING_DESIRED: new macro to check whether we should quote completions + +lib/readline/readline.h + - rl_full_quoting_desired: extern declaration + +lib/readline/doc/rltech.texi + - rl_full_quoting_desired: document + +configure.ac + - bumped version to 5.3-devel + +pcomplete.h + - COPT_FULLQUOTE: new compspec option, for rl_full_quoting_desired + +pcomplete.c + - pcomp_set_readline_variables: set rl_full_quoting_desired according + to COPT_FULLQUOTE + +builtins/complete.def + - fullquote: add new complete/compopt option value + +doc/bash.1,lib/readline/doc/rluser.texi + - fullquote: document new complete/compopt option + +lib/sh/timeval.c + - timeval_to_secs: sfp argument is now a long *; there is a new + maxval argument (always 10^6 for now) that determines how to + round; returns tv_usec in *sfp if maxval == 10^6; otherwise + return value is basically tv_usec/maxval with rounding + - print_timeval: change argument type in call to timeval_to_secs + +lib/sh/clock.c + - clock_t_to_secs: sfp argument is now a long * + - print_clock_t: change argument type in call to clock_t_to_secs + +externs.h + - timeval_to_seconds, clock_t_to_seconds: change prototypes + +execute_cmd.c + - mkfmt,print_formatted_time: fractional seconds arguments are now + longs + - mkfmt: accept precisions up to 6; since sec_fraction is in usecs, + perform any necessary rounding for precisions < 6 + - print_formatted_time: allow precision specifiers up to 6; default + is still 3 + - time_command: fractional seconds variables are now long; add new + argument to timeval_to_secs (always 1000000) + - time_command: if we call clock_t_to_secs, multiply the return + fractional seconds value by 1000 to convert it from msec to usec + +doc/bash.1,doc/bashref.texi + - TIMEFORMAT: document that the max precision is now 6 + From https://savannah.gnu.org/support/?110343 + + 6/16 + ---- +variables.c + - get_monoseconds: use clock_gettime to return the value of the + system's monotonic clock, if available + - BASH_MONOSECONDS: a new dynamic variable that returns the value of + get_monoseconds + From a suggestion by William Kennington + +doc/bash.1,doc/bashref.texi + - BASH_MONOSECONDS: document + +trap.c + - save_bash_trapsig,set_bash_trapsig,restore_bash_trapsig: functions + to manage value of BASH_TRAPSIG + - run_pending_traps: save and restore the value of BASH_TRAPSIG; set + it to the numeric signal number of the trap being run while it's + executing + From a feature request by Eric Marceau + - _run_trap_internal,run_exit_trap: save and restore BASH_TRAPSIG; + make sure it's set appropriately + +doc/bash.1,doc/bashref.texi + - BASH_TRAPSIG: document + +builtins/declare.def + - declare_internal: if declare is supplied -f and an argument that + looks like an assignment statement, fail only if there is not a + function with that name already defined. + From a report from Emanuele Torre + back in 12/22 + +jobs.c + - wait_for: make checkwinsize work in subshell commands started from + interactive shells + New feature request by Kerin Millar + +print_cmd.c + - semicolon: don't return immediately unless a preceding `&' is + itself preceded by a space, as the rest of the printing code prints + asynchronous commands. + Report and patch by Grisha Levit + + 6/17 + ---- +arrayfunc.c + - arrayvar_copyval: copy an array or hash table from shell variable + V1 to V2 + +arrayfunc.h + - arrayvar_copyval: extern declaration + +subst.h + - ASS_NOTEMPENV: new flag for bind_variable and assignments + +variables.c + - bind_variable: if ASS_NOTEMPENV is in FLAGS, don't bother calling + bind_tempenv_variable + +builtins/declare.def + - declare_internal: if we find the variable in the temporary + environment, call bind_variable with the ASS_NOTEMPENV flag since + we are already dealing with a variable from the temporary environment + - declare_internal: if we bind a new global variable because we're + modifying a variable from the temporary environment, make sure to + call arrayvar_copyval to copy array variables from the temporary + environment to the global scope + +variables.c + - push_temp_var: if we are pushing an array variable, make sure to + call arrayvar_copyval on the new variable + Final fix for bug reported by Wiley Young + - push_posix_tempvar_internal: call arrayar_copyval instead of using + inline code + + 6/19 + ---- +lib/sh/shmatch.c + - sh_regmatch: use builtin_find_indexed_array to allow a local copy + of BASH_REMATCH. + From https://lists.gnu.org/archive/html/bug-bash/2022-05/msg00052.html + +execute_cmd.c + - execute_in_subshell: tentative change to clear procsub list after + performing redirections, so nothing in a redirection can affect + what's in the subshell. + From https://lists.gnu.org/archive/html/bug-bash/2022-10/msg00114.html + +test.c + - binary_operator: in posix mode, the < and > operators compare strings + using the current locale (strcoll). + From https://www.austingroupbugs.net/view.php?id=375 + +bashline.c + - bash_default_completion: make sure that command completion adds the + trailing `/' suffix for directories even if the directory name is + the same as the common prefix of matches. + From https://lists.gnu.org/archive/html/bug-bash/2022-11/msg00034.html + +lib/readline/kill.c + - rl_vi_yank_pop: make repeated invocations of vi-yank-pop cycle + through the kill ring just like in emacs mode, even when point + is at the end of the line. + From https://lists.gnu.org/archive/html/bug-bash/2022-08/msg00105.html + +parse.y + - parse_comsub: set variables if the last token (last_read_token) is + `;', `\n', or `&', in addition to was_word + - parse_comsub: if the last read token was a newline (was_newline), + terminate the comsub with a newline instead of a semicolon; keeps + the line numbers more consistent. + From a report by Grisha Levit + +lib/sh/anonfile.c + - anonopen: use memfd_create if it is available, fall through to + traditional Unix/POSIX implementation if it fails + + 6/20 + ---- +parse.y + - yy_string_unget: don't push EOF back to a string, like the other + unget functions + + 6/21 + ---- +parse.y + - read_a_line: don't push an EOF back into the string or line if the + line ends in a backslash. + From a report by Rob Landley + + 6/22 + ---- +lib/readline/input.c + - rl_gather_tyi: make sure result is initialized + +lib/readline/kill.c + - _rl_read_bracketed_paste_prefix: make sure key is initialized + +builtins/read.def + - read_builtin: make sure pass_next and saw_escape are initialized + before a possible goto + - read_builtin: make sure to initialize prevset for very short + timeouts + +subst.c + - function_substitute: make sure tflag is initialized even when we + don't call read_comsub, since we return it in ret->flags + All from a report by Grisha Levit + +builtins/complete.def + - compgen_builtin: use array_from_argv to assign elements of the + stringlist to the array variable. + Update from Grisha Levit + +builtins/cd.def + - bindpwd: fix seg fault from an unlikely set of circumstances + From a report by Grisha Levit + +arrayfunc.h + - convert_validarray_flags_to_arrayval_flags: initialize avflags + From a report by Grisha Levit + +lib/sh/anonfile.c + - anonopen: set *fn if memfd_create is used + From a report by Grisha Levit + + 6/23 + ---- +arrayfunc.c + - bind_assoc_var_internal: free key to fix small leak if assign_func + used + - quote_compound_array_word: free value to fix small leak + +builtins/evalstring.c + - parse_and_execute: free parsed command on failed function definition + import + - open_redir_file: free FN if we're not passing it back to the caller + +subst.c + - param_expand: free TEMP1 in code paths that don't do it now + +bashline.c + - bash_command_name_stat_hook: if we modify *NAME, free the old value + +examples/loadables/{kv,stat}.c + - bind_assoc_variable is caller-free VALUE, so free when needed and + don't allocate a new copy if not + All from a report by Grisha Levit + + 6/24 + ---- +lib/readline/complete.c + - rl_menu_complete: use _rl_free_match_list instead of just freeing + MATCHES if we have too many possible completions to display. + From a report by Grisha Levit + + 6/25 + ---- +eval.c + - reader_loop: make sure to allow exit builtin (code == EXITBLTIN) to + exit the shell when ignoreeof is set + From a report by Grisha Levit + + 6/26 + ---- +lib/readline/complete.c + - complete_sigcleanarg_t: new struct to hold match list and saved line + buffer for cleanup on receipt of SIGINT + - _rl_complete_sigcleanup: use new sigcleanarg_t struct and free both + members + - rl_complete_internal: whenever we display the match list, set up to + clean the matches and saved line buffer in the event of a SIGINT + From a report by Grisha Levit + +lib/readline/signals.c + - _rl_handle_signal: if readline is compiled to include callbacks, only + call rl_echo_signal_char if we're not in callback mode or the + application has set rl_persistent_signal_handlers, leaving any + application signal handler to call it (or not) otherwise. + From a discussion with Andrew Burgess + +lib/glob/glob.c + - glob_filename: if ARRAY == TEMP_RESULTS, make sure to free TEMP_RESULTS + after copying the filenames out of ARRAY, since we either assigned it + directly or glob_dir_to_array returned it because the dirname was + the empty string. + From a report by Grisha Levit + +lib/readline/rltypedefs.h + - Function: only compile in these obsolete typedefs if + WANT_OBSOLETE_TYPEDEFS is defined + +print_cmd.c + - xtrace_print_assignment,xtrace_print_word_list: prioritize checking + for characters that need $'...' printing over shell metacharacters + so that strings containing both get the $'...' treatment + From a report by Grisha Levit + + 6/27 + ---- +subst.c + - skip_double_quoted: make sure to call extract_function_subst with + the SX_NOALLOC flag + From a report by Grisha Levit + +trap.c + - _run_trap_internal: if we're running a trap but shell_eof_token is + set, this means we're somehow running a trap while parsing a + command substitution (weird set of circumstances). Call + reset_parser and unset shell_eof_token if shell_eof_token is set + From a report by Wiley Young + +builtins/setattr.def + - set_var_attribute: don't set the att_propagate attribute unless the + variable whose attribute is being modified is in the temporary + environment for this builtin, not any previous temporary environments + (like the temp env for a function call, or a special builtin like + `.') + +variables.c + - push_posix_temp_var: if we have an array variable we're trying to + push up here, use arrayvar_copyval to copy the value correctly + +arrayfunc.c + - arrayvar_copyval: make sure that V2 ends up being the same type of + array as V1 (att_array or att_assoc), since we're copying the value. + Fixes issue reported by Grisha Levit , but + with the previous fix to set_var_attribute, it's not needed + - assign_compound_array_list: check for integer overflow if the max + index of the array is already INT_MAX. + From a report from Emanuele Torre + - assign_array_var_from_word_list: ditto + + 6/28 + ---- +pcomplete.c,bashline.c + - uw_restore_parser_state,uw_rl_set_signals: move to bashline.c so the + general readline support can use them + +bashline.h + - uw_restore_parser_state,uw_rl_set_signals: extern declarations + +bashline.c + - unset_readline_variables,uw_unset_readline_variables: function to + unset READLINE_{LINE,POINT,MARK,ARGUMENT} and its unwind-protect + counterpart + - bash_execute_unix_command: add unwind-protect to free up allocated + memory + Report and patch by Grisha Levit + +doc/bash.1,doc/bashref.texi + - BASH_ARGC,BASH_ARGV,BASH_SOURCE,BASH_LINENO: note that these variables + may not be assigned to or unset + + 6/29 + ---- +builtins/declare.def + - declare_internal: attempting to assign to a noassign variable is no + longer an assignment error; the attempt is just ignored + +arrayfunc.c + - find_or_make_array_variable: take a new flag value, 4: means to + return noassign variables as themselves instead of NULL without + performing the assignment so the caller can handle them differently. + - assign_array_from_string: pass flags & 4 to find_or_make_array_variable + so we can simply ignore attempted assignments to noassign array + variables instead of treating them as assignment errors + From a report by Kerin Millar + +expr.c + - exppower: only report negative exponent error if noeval == 0. + Fixes issue reported by Steffen Nurpmeso + + 6/30 + ---- +lib/sh/anonfile.c + - anonopen: add support for using shm_open or shm_mkstemp to create + an anonymous file using POSIX shared memory + +configure.ac + - if --enable-static-link is supplied, add -static to LDFLAGS on + Linux if opt_profiling isn't enabled + From a report from Emanuele Torre + +print_cmd.c + - make_command_string_internal: if we're recursively printing a list + (connection) with more than two elements, don't print any deferred + here-documents after the make_command_string_internal on the right + side of the connection unless we're at the end of the list + (printing_connection == 1). This way the caller gets to add the + appropriate connector before printing the deferred here-documents. + From a report by Grisha Levit + - make_command_string_internal,print_group_command: after we call + PRINT_DEFERRED_HEREDOCS and follow it with a closing `)' (subshell) + or `}' (group command), we can set was_heredoc to 0 because we are + no longer printing a here-document + From a report by Grisha Levit + + 7/3 + --- +lib/readline/complete.c + - rl_username_completion_function: simplify things by just skipping the + function body if HAVE_GETPWENT is not defined. + From a report by Grisha Levit + +lib/sh/ufuncs.c + - fsleep: broke into three functions: nsleep, which uses nanosleep, + ssleep, which uses select/pselect, and ancientsleep, which uses + sleep. Prefer nanosleep, use the others depending on what's + defined. + From a report and patch by Grisha Levit + +arrayfunc.c + - assign_compound_array_list: now behaves more like a series of + assignment statements (a=(one two) is more like a[0]=one a[1]=two) + in terms of error handling -- break after the first invalid + assignment -- and return value -- now return int, 0 on failure and + 1 on success so the callers can throw assignment errors + - assign_compound_array_list: if we have an explicit [subscript]=value + assignment, use the negative-indices-count-back-from-the-end strategy; + otherwise use last_ind and throw an error on overflow. This is like + standalone assignment statements + - assign_array_var_from_string: catch new return value from + assign_compound_array_list; return NULL if assign_compound_array_list + returns failure + +subst.c + - do_compound_assignment: if assign_compound_array_list or + assign_array_var_from_string return error (0 or NULL, respectively), + treat as an assignment error similar to assigning to a readonly + variable + Inspired by a report from Emanuele Torre + +arrayfunc.h + - assign_compound_array_list: new return type + + 7/5 + --- +builtins/enable.def + - enable_builtin: make sure dynamic builtin loading and unloading + updates the `enabled' and `disabled' programmable completion lists. + From a report and patch by Grisha Levit + +doc/bash.1,doc/bashref.texi + - hash: add note that assigment to PATH clears the hash table. + Report by Sebastian Carlos + +lib/readline/complete.c + - rl_filename_completion_function: make sure the results of + *rl_filename_rewrite_hook are freed consistently if the function + returns newly-allocated memory + From a report and patch by Grisha Levit + back in May + + 7/6 + --- +builtins/cd.def + - cd_builtin: if $OLDPWD is set by the user or script to something + that's not a full pathname, allow it to use $CDPATH. + From a report by Dustin Boyd + + 7/7 + --- +shell.h + - user_info: add members for saved uid and saved gid + +shell.c + - uidget: if we have setresuid/setresgid, get the saved uid and saved + gid so we can set them if we disable privileged mode + - disable_priv_mode: only call setuid/setresuid and setgid/setresgid + if the euid (egid) != uid (gid). If we have setresuid/setresgid, + add a check whether the saved uid (gid) isn't the same as the real + uid (gid). Potentially saves a couple of system calls. + Fixes Android issue, patch by Grisha Levit + +test.c + - unary_operator: only support historical handling of -t and its + optional argument when not in posix mode + - unary_test: print an error if the argument to -t is not a number + - unary_operator: only make the argument to -t optional if the + next argument is -a or -o and we are using the historical algorithm + (argc >= 5), otherwise force it to be a number and print an error + message if it's not + From a report by Stephane Chazelas + +doc/bash.1,doc/bashref.texi + - added note about test/[ sorting using the current locale with the + `<' and `>' operators when in posix mode + - added note about the integer argument to test -t being required + when in posix mode + - added note recommending against the use of test with 5 or more + arguments in favor of combining multiple instances of test with + && or || + From a report by Stephane Chazelas + + 7/10 + ---- +jobs.c + - start_job: turn off (on) the J_ASYNC flag depending on whether the + job is being started in the foreground (background). It matters now + that we use IS_ASYNC to determine whether to give the terminal + back to the shell's process group. + From a report by Grisha Levit + +bashline.c + - command_word_completion_function: if we have a glob pattern that + expands to multiple words, dispose of the list before returning NULL. + From a report by Grisha Levit + +variables.c + - makunbound: if we're unsetting a local variable, preserve the export + attribute even if the variable's not in the temporary environment + Tentative fix, compatible with other POSIX shells (except the BSD + variants of ash) + + 7/12 + ---- +lib/sh/unicode.c + - include if HAVE_LANGINFO_CODESET is defined, use + nl_langinfo (CODESET) if HAVE_LANGINFO_CODESET is define, since + we no longer check for nl_langinfo. This is what locale.c does. + + 7/15 + ---- +lib/readline/display.c + - rl_redisplay: rudimentary code to handle some cases where the line + buffer consumes more than the physical number of screen lines. It's + not a screen editor, but it handles some of the common cases. + From https://bugs.launchpad.net/ubuntu/+source/bash/+bug/2024628 + + 7/17 + ---- +builtins/printf.def + - getwidestr: make sure to force mbsrtowcs to convert the closing NULL + so the wide-character string is NULL-terminated. + From a report by Grisha Levit + +lib/sh/shmatch.c + - strregerror: new function to return regerror(3) error message text + in allocated memory + - sh_regmatch: add an additional argument to hold the error message + from regerror(3), in newly-allocated memory; generated by call to + strregerror() on regcomp(3) failure + From a patch by Grisha Levit + +externs.h + - sh_regmatch: update extern declaration + +execute_cmd.c + - execute_cond_node: pass pointer to buffer to return any error + message; if sh_regmatch returns 2, use a non-NULL error buffer in + the error message. + +lib/readline/bind.c + - _rl_get_string_variable_value: return the values for + active-region-start-color (_rl_active_region_start_color) and + active-region-end-color (_rl_active_region_end_color) if they + are set. + Fixes bind -v issue reported by Sebastian Carlos + - _rl_get_string_variable_value: if the history is stifled, make + sure we report the history size as < 0 so the output of bind -v + can be reused as input. + Fixes bind -v issue reported by Sebastian Carlos + + 7/20 + ---- +pathexp.c + - quote_string_for_globbing: don't bother backslash-quoting multibyte + characters. It matters for macOS and doesn't make a difference for + other systems, and those aren't going to be special globbing chars. + From a report by Grisha Levit + +lib/glob/glob.c + - glob_vector: normalize the pattern with fnx_fromfs so we make sure + it's also in NFC on macOS (other systems don't care). This is a + POSIX violation, but part of correcting the longtime HFS+ (and Finder) + misfeature + +lib/readline/complete.c + - rl_filename_completion_function: if the application sets a filename + rewrite hook, use it to rewrite the filename we're matching as well + as filenames read with readdir(). + [SUPERSEDED BY CHANGE OF 10/4/2023] + From a report by Grisha Levit + + 7/21 + ---- +pathexp.c + - quote_string_for_globbing: see if we can get away without backslash- + quoting single-byte characters that aren't CTLESC or characters + that are special to EREs or BREs, even if they're quoted + +bashline.c + - bashline_set_filename_hooks: convenience function to set the + directory hook and the filename rewrite and stat hooks; call from + other places in the file so these are set consistently + +bashline.h + - bashline_set_filename_hooks: extern declaration + +builtins/complete.def + - compgen_builtin: make sure to set the directory and filename hooks + so compgen called from a script works more like compgen called + from a word completion context. + Inspired by a report by Grisha Levit + +doc/Makefile.in + - bash.pdf: use groff -T pdf to create, instead of creating postscript + and then using ghostscript + + 7/24 + ---- +jobs.c + - start_job: unconditionally send SIGCONT to the job we just started, + even if we think it was already running, to reduce the window for a + potential race condition, and only change the state to RUNNING if + the SIGCONT succeeds or if the process has terminated so we can + clean it up later. + Report from Earl Chew + +make_cmd.c + - make_simple_command,make_bare_simple_command: now take line number as + an argument; used instead of line_number to set the line associated + with the simple command + +make_cmd.h + - make_simple_command,make_bare_simple_command: change prototype + +parse.y,builtins/command.def,builtins.jobs.def + - make_simple_command,make_bare_simple_command: change callers + + 7/25 + ---- +parse.y + - read_token_word: try to keep track of whether we are parsing the + first word of a simple command and set simplecmd_lineno if we + are. We start a simple command when we return ASSIGNMENT_WORD + or WORD in a command token position. This gives better values for + $LINENO in multi-line simple commands + - redirection: set simplecmd_lineno if it's -1, meaning this is a + simple command with a leading redirection or a null command with + only a redirection + - pass simplecmd_lineno to make_simple_command if we are starting a + simple command (the first ELEMENT) + - parse_comsub,xparse_dolparen: save and restore simplecmd_lineno + - simple_command,function_def production: reset simplecmd_lineno to -1 + after parsing a simple command or a function declared as WORD() + + 7/26 + ---- +doc/bash.1,doc/bashref.texi + - xpg_echo: add description of how this can be used to suppress echo + option interpretation + Inspired by report from Zachary Santer + + 7/27 + ---- +builtins/printf.def + - printf_erange: make out-of-range errors conversion errors even if + the conversion function fully consumes the argument. + From a report by thomas@habets.se + + 7/31 + ---- +lib/readline/rltypedefs.h + - rl_macro_print_func_t: typedef for a function to print macro key + bindings + +lib/readline/bind.c + - rl_macro_display_hook: hook function to call if the application + wants to display a key sequence bound to a macro + - rl_macro_dumper: if rl_macro_display_hook is non-NULL, call it to + display the macro value (after `untranslating' it to add back any + required backslashes) + +lib/readline/doc/rltech.texi + - rl_macro_display_hook: add description + +pathexp.c + - glob_char_p: add the characters that are special within BRE bracket + expressions. + Inspired by a report by Grisha Levit + +bashline.c + - bind_keyseq_to_unix_command: allow whitespace to separate the keyseq + and the command string, but require the command string to be + surrounded by double quotes if it is. If we get a whitespace + separator, call rl_macro_bind so we get the string `translated' + according to how readline does it (backslash-escape sequences + processed, etc.) + - print_unix_command: function to print a key sequence and a unix + command bound to it from cmd_xmap, using a space separator + - print_unix_command_map: make sure to set rl_macro_display_hook to + print_unix_command before calling rl_macro_dumper to print the + bound command strings + + 8/1 + --- +builtins/read.def + - read_builtin: saw_escape is now a count of CTLESCs we added to the + input + - read_builtin: since we increment saw_escape when we add a CTLESC, + decrement it when we remove one from the input (\\\n, \\\0) + - read_builtin: remove the CTLESC we added if we have a backslash- + escaped NULL character ('\0') + - read_builtin: if the input ends with an unescaped newline, remove + the CTLESC we added + From a report by Grisha Levit + + 8/2 + --- +builtins/history.def + - history_builtin: if history -[anrw] is used without a filename + argument, and HISTFILE is unset or null, return success immediately + From a report by Grisha Levit + +doc/{bash.1,bashref.texi},lib/readline/doc/hsuser.texi + - history: document that if filename is not supplied, and HISTFILE is + unset or null, the [-anrw] options have no effect + + 8/3 + --- +pcomplete.c + - gen_progcomp_completions: if the actual compspec that's run is + something different from what's typed (full pathname, alias, etc.), + set pcomp_curcmd to the word corresponding to the actual compspec, + instead of what was typed. This is what eventually gets used by + the compopt builtin's output. + From a report by Grisha Levit + +execute_cmd.c + - execute_coproc: in parent, close /dev/fd FIFOs only if we're not + executing a shell function, like other calls to unlink_fifo_list(). + Report from Hal Blackburn in + https://savannah.gnu.org/support/index.php?110910 + +subst.c + - do_compound_assignment: don't attempt to convert a global associative + array to an indexed array with declare -g. + From a report and patch by Grisha Levit + + 8/7 + --- +lib/readline/bind.c + - rl_print_keybinding: new function, prints a the key bindings for a + single function specified by name + - rl_function_dumper: call rl_print_keybinding for every function name + +lib/readline/readline.h + - rl_print_keybinding: extern declaration + +lib/readline/bind.c + - _rl_untranslate_macro_value: make sure characters betweeen 128 and + 159 (metafied control characters) are printed using the \M-\C- + notation instead of directly writing the control character. + From a report and patch by Grisha Levit + - rl_get_keyname: if a key binding shadows a function or macro, print + the ANYOTHERKEY binding as a null string + From a report and patch by Grisha Levit + - rl_untranslate_keyseq: make changes analogous to + _rl_untranslate_macro_value so that we don't print control characters + directly + - rl_invoking_keyseqs_in_map: if the key corresponds to a keymap, use + _rl_get_keyname to get its text representation, so this function + returns consistent results + - rl_translate_keyseq: if convert-meta is on, don't convert meta chars + that are, e.g., \M-\C-@ (128) into \e followed by a NUL, resulting + in truncated key sequences. Just don't honor convert-meta in this + case + + 8/8 + --- +bashhist.c + - bash_history_no_expand_chars: add the rest of the shell + metacharacters so we don't get empty history events; tcsh does more + or less the same thing + Inspired by a report from Emanuele Torre + + 8/9 + --- +parse.y + - grammar: change bare `time' and `!' productions to use nullcmd_terminator, + which is a list_terminator or a `&' to allow things like `time &' + and `! &' which the original version of POSIX interp 267 (the one + I implemented) says we should support + + 8/11 + ---- +m4/bison.m4,m4/flexmember.m4,m4/locale_h.m4 + - new m4 files from gettext-0.21.1 + +m4/gettext.m4,m4/intl.m4 +m4/{codeset,extern-inline,fcntl-o,glibc2,glibc21,host-cpu-c-abi,iconv,intdiv0}.$ +m4/{intl-thread-locale,intlmacosx,intmax,inttypes-pri,inttypes,inttypes_h}.m4 +m4/{lcmessage,lib-ld,lib-link,lib-prefix,locale_h,lock,nls,po,printf-posix}.m4 +m4/{progtest,pthread_rwlock_rdlock,size_max,stdint_h,strtoimax,threadlib}.m4 +m4/{uintmax_t,ulonglong,visibility,wchar_t,wint_t,xsize}.m4 + - updated m4 files from gettext-0.21.1 + +configure.ac,config.h.in + - updated autoconf files with changes for gettext-0.21.1 + +MANIFEST + - updated distribution manifest with new files from gettext-0.21.1 + +lib/sh/unicode.c + - u32cconv: prefer nl_langinfo to locale_charset like locale.c: + locale_isutf8() + +execute_cmd.c + - uw_restore_lineno: an unwind-protect fuction to restore a saved + line_number + - execute_command: add an unwind-protect to restore line_number in + case execute_simple_command longjmps back to top_level or a + return context. + Side effect of https://savannah.gnu.org/support/index.php?110919 + - execute_for_command, execute_select_command, execute_case_command: + add unwind-protect to restore line_number (could also do it for + if, while, until but those don't modify line_number) + - execute_command_internal: add_unwind_protect to restore line number + for arith, cond, function def commands + + 8/14 + ---- +execute_cmd.c + - execute_simple_command: don't call savestring on the_printed_command_except_trap + if it's NULL. + From a report by Grisha Levit + + 8/15 + ---- +lib/readline/rltty.c + - prepare_terminal_settings: replace USE_XON_XOFF macro with private + variable _rl_use_tty_xon_xoff (initially set to 1); if it's set to + 0 disable the tty start and stop characters. Prep for making it a + bindable variable setting + +builtins/read.def + - edit_line: now takes a third argument saying whether or not to + set rl_attempted_completion_function to NULL to use readline's + default filename completion (the default) + - read_builtin: new option -E to use readline and use the bash + default completion (that is, leave rl_attempted_completion_function + unchanged) + From a suggestion by konsolebox back in 5/2021 + + +doc/bash.1,doc/bashref.texi + - read: document new -E option + + 8/17 + ---- +aclocal.m4 + - BASH_CHECK_LIB_TERMCAP: add a check for bash_cv_termcap_lib == + "libcurses"; set TERMCAP_LIB=-lcurses in this case + + 8/18 + ---- +subst.c + - bash_variable_assignment_error: new function, implements default mode + behavior for variable assignment errors + - posix_variable_assignment_error: new function, implements posix mode + behavior for variable assignment errors + - parameter_brace_expand_rhs,expand_declaration_argument, + do_assignment_statements: call posix_variable_assignment_error or + bash_variable_assignment_error as appropriate + + 8/21 + ---- +lib/readline/misc.c + - _rl_arg_dispatch: add the digits or other characters to + rl_executing_keyseq if we're not calling _rl_dispatch. + From a report by Grisha Levit + +print_cmd.c + - print_simple_command: make sure that the_printed_command[0] == '\0' + if we're printing a null simple command with no words + Patch by Grisha Levit + + 8/22 + ---- +builtins/read.def + - read_builtin: make `delim' variable local, pass to edit_line to + set the last character of the returned line; change edit_line + prototype. + From a suggestion by Grisha Levit + + 8/23 + ---- +parse.y + - comsub and funsub productions: don't reset eof_encountered to 0 in + the action + +subst.c + - function_substitute: unwind-protect eof_encountered so ignoreeof + doesn't keep getting reset to 0 if PS1 includes a ${ ...;} command. + From a report by Grisha Levit + + 8/25 + ---- +doc/{bash.1,bashref.texi} + - clarify the cases where arrayname[@] doesn't refer to all the + elements of an associative array (the unset builtin and test/[/[[ -v + for now) + Inspired by https://savannah.gnu.org/support/index.php?110924 + + 8/28 + ---- +execute_cmd.c + - execute_for_command,execute_select_command,execute_arith_command, + execute_case_command: fix up order in which BASH_COMMAND is set, + the DEBUG trap is run, and PS4 is printed. + From a report by Grisha Levit + +lib/readline/colors.c + - RL_COLOR_PREFIX_EXTENSION: make sure the custom suffix has a leading + `.' + Report and fix from Stefan Klinger + +lib/readline/parse-colors.c + - free_color_ext_list: new function, called on parse error, frees the + list of extensions + - rl_reparse_colors: new public function, frees old extension list and + reparses (presumably new) value of LS_COLORS; some minimal checking + to make sure the value has really changed + + 9/1 + --- +parse.y + - time_command_acceptable: make sure `time' is recognized as a + reserved word after DOLPAREN and DOLBRACE. + Report from Dima Korobskiy + +builtins/printf.def + - printf_builtin: make 'C' equivalent to 'lc'; 'S' equivalent to 'ls' + as POSIX specifies + + 9/6 + --- +eval.c + - parse_command: don't run pending traps if we're parsing a command + substitution + From a report from Emanuele Torre + + 9/8 + --- +jobs.c + - stop_pipeline: don't have the parent set the terminal pgrp; rely on + child processes to do it to avoid potential race conditions. + From a discussion beginning at + https://lists.gnu.org/archive/html/bug-bash/2023-08/msg00087.html + +builtins/printf.def + - bexpand: when parsing the string to be expanded, consume entire + multibyte characters at a time, in case their encoding includes a + '\\' + - printf_builtin: when parsing the format string, consume entire + multibyte characters at a time unless they begin with '\\' or '%', + to avoid characters whose encoding contains those characters + + 9/11 + ---- +builtins/hash.def + - hash_builtin: if the -p option is supplied without a name to hash, + it's an error + +hashcmd.c + - phash_remove: if the hash table is empty, return 1 like unalias does + when the alias isn't in the hash table. + Report from from Mike Jonkmans + + 9/13 + ---- +test.c + - binary_test,unary_test: now static + - cond_test: new function, calls binary_test or unary_test as appropriate + and handles longjmps from test_syntax_error + +test.h + - cond_test: extern declaration + +execute_cmd.c + - execute_cond_node: call cond_test instead of binary_test or unary_test. + From a report and patch from Grisha Levit + +doc/bash.1,doc/bashref.texi + - hash: add some text about the mutual exclusivity of the -t, -p, and + -d options + + 9/14 + ---- +subst.c,subst.h,externs.h + - string_extract,string_extract_verbatim,string_extract_double_quoted, + string_extract_single_quoted,skip_single_quoted,skip_double_quoted, + extract_delimited_string,extract_heredoc_dolbrace_string, + extract_dollar_brace_string,parameter_brace_expand,param_expand, + extract_command_subst,extract_function_subst,extract_arithmetic_subst, + extract_process_subst,extract_array_assignment_list, + expand_array_subscript + change function signatures to take size_t * instead of int * for + arguments that are string indices or lengths, change callers + - unquoted_substring,unquoted_member,string_extract, + string_extract_double_quoted,skip_double_quoted, + string_extract_single_quoted,skip_single_quoted, + string_extract_verbatim,extract_delimited_string, + extract_heredoc_dolbrace_string,extract_dollar_brace_string, + parameter_brace_expand,param_expand,skip_matched_pair,skip_to_delim, + skip_to_histexp,list_string,expand_string_dollar_quote, + parameter_brace_expand_rhs,expand_array_subscript,shouldexp_replacement, + expand_array_subscript,string_quote_removal: change variables used + for string indexes to size_t + [merge from size_t branch] + +arrayfunc.c + - expand_compound_array_assignment: use size_t for string indices + +braces.c + - brace_gobbler: use size_t for string indices + +parse.y + - xparse_dolparen: change function signature to use size_t * + instead of int * for string index, use size_t for string indices + +general.c, general.h + - bash_tilde_find_word: change function signature to use size_t * + instead of int * for string index + +lib/readline/readline.h + - rl_reparse_colors: extern declaration + +lib/readline/doc/rltech.texi + - rl_reparse_colors: document as public function + + 9/21 + ---- +pcomplete.c + - it_init_aliases: move the free (alias_list) inside #ifdef ALIAS. + Report and fix from Mike Jonkmans + +redir.c + - redirection_error: set W_NOPROCSUB in the word redirection_error + creates to call redirection_expand + +builtins/bind.def + - bind_builtin: use CASE_HELPOPT so the long doc gets printed when + --help is supplied + +builtins/getopts.def + - getopts_builtin: change to use no_options() + + 9/22 + ---- +execute_cmd.c + - execute_select_command: in posix mode, an invalid selection variable + name is a fatal error, just like with `for'. This is compatible with + ksh93 and mksh + + 9/25 + ---- +subst.c + - parameter_brace_expand_length: rearrange the code slightly to reduce + the number of find_variable calls. This matters if the variable is + dynamic and produces a new value each time (e.g., RANDOM). + + 9/26 + ---- +builtins/shift.def + - shift_builtin: if get_numeric_arg returns a number out of range and + we're going to print an error message, make sure to skip over an + argument of `--' so we can print the right argument + +builtins/break.def + - break_builtin,continue_builtin: ditto with get_numeric_arg and `--' + + 9/28 + ---- +builtins/history.def + - history_builtin: changed error message if the numeric argument to -d + is invalid + + 9/29 + ---- +subst.c + - array_length_reference: include the open bracket in the error message + passed to err_badarraysub; it looks cleaner + + 10/2 + ---- +jobs.c + - delete_all_jobs: if we are clearing the jobs list, reset the stats + about running and dead jobs and child processes + Report from Koichi Murase + + 10/4 + ---- +lib/readline/complete.c + - rl_completion_rewrite_hook: rewrite hook applied to the completion + word before comparing against the possible completions from the + file system (modified by rl_filename_rewrite_hook) + - rl_filename_completion_function: call rl_completion_rewrite_hook, + if set by the calling application, on the filename portion of the + word to be completed + +lib/readline/readline.h + - rl_completion_rewrite_hook: extern declaration + +bashline.c + - bash_set_filename_hooks: set rl_completion_rewrite_hook to + bash_filename_rewrite_hook now that we've separated them + From a report and patch from Grisha Levit ; + original report from Stefan H. Holek + +lib/readline/doc/rltech.texi + - rl_completion_rewrite_hook: document + + 10/5 + ---- +lib/readline/complete.c + - rl_complete_internal: use `%' as an op character to indicate that + we should just display the completions, like '?' in previous versions + (nothing uses this yet) + - rl_possible_completions: set last_completion_failed to 0 before we + pass '?' to rl_complete_internal so we don't worry about trying to + insert a single completion + + 10/6 + ---- +subst.c + - string_transform: use ansicstr directly for the `E' transformation + so we don't accidentally remove too many escapes. + From a report and patch from Grisha Levit + +execute_cmd.c + - execute_arith_for_command: make sure a failed init expression resets + loop_level so break and continue work correctly + From a report and patch from Grisha Levit + - execute_for_command: set line_number for invalid identifier error + messages; restore before returning error + From a report and patch from Grisha Levit + +lib/readline/misc.c + - _rl_set_insert_mode: manage RL_STATE_OVERWRITE when modifiying + insert mode + +doc/bash.1,doc/bashref.texi + - some style and formatting changes from Bjarni Ingi Gislason + + +subst.c + - getifs: now returns allocated memory to insulate it from changes to + $IFS + +builtins/read.def + - read_builtin: since getifs now returns allocated memory, note when + we need to free ifs_chars and free it before returning. + Reported by Robert Elz in + https://www.austingroupbugs.net/view.php?id=1778#c6513 + + 10/7 + ---- +pathexp.c + - glob_char_p: add more of the extglob pattern characters; it doesn't + hurt to quote them + Report and patch from Grisha Levit + - unquoted_glob_pattern_p: don't treat a `(' immediately following a + `/' as a potential globbing character + - unquoted_glob_pattern_p: only treat the extended glob characters + followed by a `(' as a glob pattern if extended_glob is enabled + - unquoted_glob_pattern_p: an unquoted backslash isn't treated + specially any more, but if it's followed by a CTLESC, you still + don't treat the next character as an unquoted globbing char + Report and patch from Grisha Levit + + 10/9 + ---- +builtins/common.c + - get_numeric_arg: if fatal > 0, set the exit status to EX_USAGE + and call jump_to_top_level with EXITPROG or DISCARD. We don't + need to do everything that throw_to_top_level() does here (it's + really meant for signals and other exceptional failure conditions). + +builtins/cd.def + - cd_builtin: exit with EX_USAGE on too many arguments + +builtins/shift.def + - shift_builtin: return EX_USAGE if get_numeric_arg returns 0, + indicating that the argument wasn't a valid number + +builtins/history.def + - shift_builtin: return EX_USAGE if get_numeric_arg returns 0 + +builtins/exit.def + - exit_or_logout: if get_exitstat (which calls get_numeric_arg) returns + a value > EX_SHERRBASE, indicating an error, just return that to + the caller and let the caller deal with it. This means that + `exit xyz' is no longer a fatal error, but can potentially cause a + non-interactive posix-mode shell to exit because exit is a special + builtin + +builtins/return.def + - return_builtin: if a non-interactive shell in posix mode gets an + invalid numeric arg from get_exitstat, return immediately and let + the caller deal with exiting + All prompted by a report by Martin Schulte + + 10/13 + ----- +pathexp.c + - unquoted_glob_pattern_p: restore some of the special treatment of + backslash followed by CTLESC removed on 10/7 + Report and patch from Grisha Levit + +parse.y + - parse_matched_pair: don't add an extra CTLESC after reading \CTLESC, + like in other parts of the parser + +subst.c + - dequote_string: don't drop trailing CTLESC in a string with more + than a single character + Report and patch from Grisha Levit + +lib/sh/strtrans.c + - ansicstr: handle $'\c^A' and $'\c^?' correctly when being expanded + by the parser (flags&2). The parser passes these as \c^A^A and + \c^A^?, respectively, so we should strip the quoting CTLESC. + Report from Grisha Levit + +subst.[ch] + - extract_dollar_brace_string: now global so brace expansion can use it + +braces.c + - brace_gobbler: use extract_dollar_brace_string if we see ${ with + the appropriate value of QUOTING, so we don't have to teach brace + expansion more shell syntax. + Report from Emanuele Torre + - brace_gobbler: call the word extraction functions with SX_NOALLOC + so we don't have to allocate memory we're just going to free + + 10/16 + ----- +builtins/read.def + - read_builtin: return EX_MISCERROR (2) if there is an error trying + to assign to one of the variables. This is what the newest POSIX + draft specifies. + +variables.c + - dispose_variable_value: do the right thing for att_nofree vars + - makunbound: call dispose_variable_value instead of using inline code + +braces.c + - brace_gobbler: make sure to set no_longjmp_on_fatal_error around + calls to extract_dollar_brace_string + + 10/17 + ----- +braces.c + - brace_gobbler: set SX_NOLONGJMP|SX_NOERROR in the flags passed + to extract_command_subst; make sure no_longjmp_on_fatal_error + is set before that call + - brace_gobbler: revert 10/13 change to use extract_dollar_brace_string + + 10/20 + ----- +parse.y + + - xparse_dolparen,parse_string_to_command: if SX_NOERROR is set in + FLAGS, add PST_NOERROR to parser_state. Not much effect yet. + - parse_matched_pair: if PST_NOERROR is set in parser_state, don't + print an error message if we hit EOF, just return an error. A start + at using PST_NOERROR to suppress error messages, not just duplicate + ones. We'll see how this goes before adding more + +builtins/printf.def + - decodeprec: decode the precision into an intmax_t; clamp the return + value at INT_MAX + - printf_builtin: update to posix interp 1647 (even though it's about + fprintf(3)) and output a NUL byte if %lc is supplied a null argument. + - printf_builtin: fix case where %Q is supplied with a precision in + the format string + - printf_builtin: fix case where %Q is supplied with a precision + greater than INT_MAX + - getwidestr,getwidechar: handle case where there is no argument + supplied; return NULL or NUL + - convwidestr: allow a precedence of 0 for %ls + - getint: don't call getintmax any more, just use the same code style + inline; getintmax will consume an extra argument on an error + Report and patches from Grisha Levit + - printf_builtin: handle field width and precision overflow from + getint() by ignoring the argument (fieldwidth = 0, precision = -1) + + 10/26 + ----- +jobs.c + - wait_for: rearrange code that sets the SIGINT handler to + wait_sigint_handler and saves the old handler to old_sigint_handler + to avoid delay before assigning the handler + Report from Wenlin Kang + - wait_sigint_handler: if cur_sigint_handler (what restore_sigint_handler) + just restored or ignored) is INVALID_SIGNAL_HANDLER, set the + appropriate SIGINT handler with set_sigint_handler before sending + ourselves SIGINT + + 10/30 + ----- +general.c + - legal_number: use the same test (isspace(3)) to skip trailing + whitespace that strtoimax uses to skip leading whitespace. + Report and patch from Paul Eggert + +general.c,general.h + - legal_number: renamed to valid_number, changed all callers + - legal_identifier: renamed to valid_identifier, changed all callers + - legal_alias_name: renamed to valid_alias_name, changed all callers + +lib/sh/compat.c + - legal_number: definition of legal_number here for backwards compat + with old loadable builtins + - legal_identifier: definition of legal_identifier here for backwards + compat with old loadable builtins + - legal_alias_name: same + +subst.c + - brace_expand_word_list: if brace_expand returns NULL, dummy up a + single-element vector with a copy of the original word so we can + add it to the result list unchanged. + Inspired by https://savannah.gnu.org/support/?110948 + + 11/3 + ---- +lib/readline/text.c + - readstr: set of functions to read a string from the keyboard, using + rl_line_buffer for temporary storage, with minimal editing and an + optional caller-supplied completion function. Doesn't use the + callback framework yet since none of the functions are public + - rl_execute_named_command: new bindable function to read a bindable + command name (from the funmap_names array) and execute it, with + command name completion on SPACE and TAB + +lib/readline/readline.h + - rl_execute_named_command: new extern declaration + +lib/readline/rlprivate.h + - new extern declarations for the readstr function framework + +lib/readline/funmap.c + - execute-named-command: new bindable function name + +lib/readline/emacs_keymap.c + - rl_execute_named_function: bound to M-x by default + +lib/readline/doc/rluser.texi + - execute-named-command: document as bindable function name with its + default binding to M-x in emacs mode + + 11/6 + ---- +lib/readline/search.c + - _rl_nsearch_dispatch: use ^V/^Q for rl_quoted_insert into the + search string + +lib/readline/isearch.c + - _rl_isearch_dispatch: use ^V or anything bound to rl_quoted_insert + for rl_quoted_insert into the search string + +lib/readline/terminal.c + - add support for new BE/BD and PS/PE bracketed-paste capabilities. + Nothing uses them yet. + + 11/10 + ----- +builtins/enable.def + - dyn_load_builtin: if we don't find a pathname argument without a + slash in BASH_LOADABLES_PATH, convert it to a pathname with a slash + before calling dlopen, to force the loader to look in the current + directory (Linux, for example, will not). + + 11/14 + ----- +examples/loadables/fdflags.c + - fdflags_builtin: only parse the setspec once, since parsing uses + strtok. + Report and patch from Emanuele Torre + + 11/15 + ----- +builtins/enable.def + - dyn_load_builtin: if BASH_LOADABLES_PATH is set, use only it: don't + fall back to looking in the current directory. This changes the + historical behavior and brings the path behavior more in line with + PATH, but not CDPATH. + + 11/20 + ----- +lib/readline/complete.c + - rl_complete_internal: add `|' as a character for rl_complete_internal + that also just displays the completions, since `%' is overloaded by + rl_menu_complete + + 11/23 + ----- +examples/loadables/strptime.c + - strptime: new loadable builtin, interface to strptime(3). Takes a + date-time string as its arguments and tries to parse it according + to a number of built-in formats. If successful, it outputs the + result as a number of seconds since the epoch. Understands some + handy shorthands like "now" and "tomorrow". + + 11/24 + ----- +tests/unicode1.sub + - update the driver function using namerefs and ${!x[@]} + - zh_TW.BIG5: fixed some problems with the test encodings. + Report and patches from Grisha Levit + + 11/25 + ----- +tests/glob2.sub + - zh_HK.big5hkscs -> zh_TW.big5 to work around macOS 14 issues with + BSD-based locale definition + +bashline.c + - bash_execute_unix_command: check count != 1 instead of count > 1 to + handle negative arguments + +lib/readline/bind.c + - rl_trim_arg_from_keyseq: change the parsing_digits logic to handle + multiple instances of `-' the same way rl_digit_loop does (collapse + to 1) + - rl_trim_arg_from_keyseq: fix typo to correctly recognize a `-' + after a key sequence bound to universal-argument + - rl_trim_arg_from_keyseq: trim negative argument for a key sequence + that is shadowed by a longer key sequence (ANYOTHERKEY) + Report and patches from Grisha Levit + + 11/27 + ----- +support/shobj-conf + - solaris2: change PIC option for non-gcc Solaris 2 builds + +lib/malloc/malloc.c + - binsize: make sure indexing into binsizes casts to size_t (unsigned) + +examples/loadables/getconf.c + - protect more of the _SC defines with #ifdefs for different systems + +examples/loadables/fdflags.c + - ALLFLAGS: add some more flag values from Solaris/AIX/HP-UX + + 11/28 + ----- +subst.c + - function_substitute: unwind return_catch_flag unconditionally + Report and patch from Grisha Levit + - function_substitute: save getopts state and restore it if the + funsub declares a local copy of OPTIND + Report and patch from Grisha Levit + +lib/readline/display.c + - rl_redisplay: make sure lpos is initialized to 0 if local_prompt is + NULL + +shell.c + - run_startup_files: make sure ssh_reading_startup_files is set to 0 + in more places; still dependent on SSH_SOURCE_BASHRC + +builtins/evalstring.c + - should_suppress_fork: make sure ssh_reading_startup_files is 0 in + order to suppress a fork. It will never be non-zero unless someone + enables SSH_SOURCE_BASHRC. + Fixes https://issues.redhat.com/browse/RHEL-5653 + +variables.c + - posix_unbind_tempvar: new function to implement POSIX interp 1009, + which says that `x=4 unset x' not only unsets the variable in the + temporary environment but the most recent scope as well. + +variables.h + - posix_unbind_tempvar: extern declaration + +builtins/set.def + - unset_builtin: if we are unsetting a variable that is in some + temporary environment, and the shell is in posix mode, call + posix_unbind_tempvar to implement the right posix behavior + +doc/bashref.texi + - update posix mode section with change to unset for interp 1009 + + 12/1 + ---- +lib/readline/readline.c + - _rl_subseq_result: add check before _rl_do_lowercase_version that + _rl_to_lower actually results in a different key sequence + Report and patch from Grisha Levit + +lib/readline/isearch.c + - _rl_isearch_dispatch: if the function bound to a key and the function + bound to the result of _rl_to_lower for that key are both + rl_do_lowercase_version, just insert the key into the search string + + 12/5 + ---- +parse.y,parser.h + - heredoc_string: new variable to indicate whether or not we're reading + a here-document from an alias (a pushed string). Set in + gather_here_documents individually for each call to + make_here_document. + +parse.y + - read_a_line: if heredoc_string is non-zero, use shell_getc instead + of yy_getc to get the right alias processing + - shell_getc: if heredoc_string is non-zero, don't add a space to the + end of the alias -- it can mess up the here-document delimiter if + the next character is a newline + Report and sample patch from gldrk + +parse.y,make_cmd.c + - read_a_line,make_here_document: if we're using shell_getc to read + the body of a here-document, let it manage line_number + + 12/8 + ---- +bashline.c + - bash_dequote_filename: fix an off-by-one error that didn't remove a + closing single quote in a filename if it was backslash-escaped. + Report by Ole Tange , fix from Grisha Levit + +lib/readline/terminal.c + - _rl_check_ansi_terminal: check whether or not rl_terminal_name + appears to be an ANSI/ECMA-48 terminal. Check some common terminal + types and then check whether some common terminal capabilities + (ce, nd, ho, up) begin with CSI (ESC-[) and then have a correct + subsequent character + - _rl_term_isansi: new variable, holds readline's idea about whether + the value of rl_terminal_name is an ANSI/ECMA-48 terminal. Initialized + to RL_ANSI_TERM_DEFAULT; set to the result of _rl_check_ansi_terminal + if initialized to 0 and on a `non-dumb' terminal + From an idea by John Tsiombikas in 11/2023 + +lib/readline/rlconf.h + - RL_ANSI_TERM_DEFAULT: define to 1 (yes) or 0 (no) to tell readline + whether or not to assume it's running on an ANSI/ECMA-48 terminal. + The default is 1 (yes) + + 12/11 + ----- +print_cmd.c + - make_command_string_internal: when printing a coproc, print the + coproc name only if the coproc command is not a simple command. + Report from Albert Akchurin + + 12/14 + ----- +doc/bash.1,doc/bashref.texi + - bind: clarify meaning of `re-read' as being individual arguments + to `bind'. + Report from Dan Jacobson + - history expansion: add that the quick substitution character is + only active when it's the first character on the line. + Suggested by Dale R. Worley + +lib/readline/histexpand.c + - history_expand: if history_quoting_state is "'", don't try to + interpret the quick substitution syntax at the start of the string. + Report from Sundeep Agarwal + +execute_cmd.c,execute_cmd.h + - save_lastarg: new function, returns saved value of $_ in allocated + memory + +parse.y + - execute_variable_command: instead of inline code, call save_lastarg + +mailcheck.c + - check_mail: instead of inline code, call save_lastarg + - check_mail: instead of calling bind_variable, use bind_lastarg + +parse.y + - decode_prompt_string: use save_lastarg() and bind_lastarg() to preserve + the value of $_ across prompt string decoding. + Patch from Grisha Levit + + 12/21 + ----- +lib/readline/doc/readline.3 + - updates to some vi-mode bindings + Patch from Josh Brobst + +builtins/setattr.def + - set_or_show_attributes: in posix mode, supplying an argument that is + not an identifier when not acting on functions is a utility error. + This will cause a non-interactive shell to exit + + 12/27 + ----- +print_cmd.c + - command_print_word_list,print_select_command_head,print_case_command_head, + print_function_def: if we're in pretty-print mode, dequote words + before printing them + Report from Seth Sabar + +shell.c + - execute_profile_file,execute_bashrc_file: separate the (duplicated) + code that sources the various profile and bashrc files out into + separate functions + - find_bashrc_file: new function, returns the name of the interactive + shell startup file that should be executed if --rcfile (--init-file) + is not supplied; currently returns DEFAULT_BASHRC + - bashrc_file: default to NULL, making it just the filename supplied as + an argument to --rcfile/--init-file + - execute_bashrc_file: execute whatever find_bashrc_file() returns + if bashrc_file is NULL + From a patch from Allison Karlitskaya + + 1/3/2024 + -------- +print_cmd.c + - print_case_clauses: if we're printing a comsub for subsequent parsing, + don't add a newline before the first case clause, since it adds a + token after the `in' that will allow reserved words to be parsed. + Report from Oguz + + 1/5 + --- +lib/readline/doc/rltech.texi,lib/readline/doc/readline.3 + - Note that since quoted characters are possible, the line readline() + returns may contain embedded newlines. + From a report by Martin Buck + + 1/8 + --- +parse.y + - parse_compound_assignment,parse_string_to_word_list: if we call + reset_parser, directly or indirectly via yyerror, make sure to set + the pushed_strings member of the saved parser state to NULL, since + reset_parser already freed it and we don't want to try and restore + it in restore_parser_state. + From a report by Nathan Mills + + 1/10 + ---- +builtins/hash.def, builtins/ulimit.def + - add some calls to sh_chkwrite where there is builtin output + +lib/sh/eaccess.c + - sh_stat: use strcpy/strcpy when constructing pbuf instead of + strcpy/strcat + +lib/sh/tmpfile.c + - sh_mktmpname,sh_mktmpfd,sh_mktmpdir: use snprintf (filename, PATH_MAX, ...) + instead of sprintf (filename, ...) + + 1/11 + ---- +configure.ac + - unconditionally AC_DEFINE(PGRP_PIPE), to prevent the problem with a + pipeline and a DEBUG trap containing an external command described + in https://lists.gnu.org/archive/html/bug-bash/2024-01/msg00037.html + + 1/12 + ---- +jobs.c + - wait_for_any_job: if we're executing a funsub/varsub, do the wait + even if the jobs list is frozen, but don't remove the job from the + table or change its notification status + Report from Oguz + +subst.c + - uw_unbind_variable: unset the first instance of the named variable, + don't follow namerefs. This is for REPLY in a varsub if it's made + a nameref. + Report from Oguz + +shell.c + - main: call compat_init() so the linker drags in the old compatibility + functions from lib/sh/compat.c. Primarily for use by existing loadable + builtins + +parse.y + - parse_compound_assignment: handle error case (wl == &parse_string_error) + before restoring the parser state from ps + Report from Grisha Levit + + 1/13 + ---- +lib/readline/complete.c + - compute_lcd_of_matches: move a strlen out of a call to MBRTOWC by + computing the length of the entire string once and then using an + offset from it while going through the loop + + 1/15 + ---- +parse.y + - parse_compound_assignment: treat parsing a string following (( (read + by parse_dparen but not an arithmetic command) the same as + expanding an alias when fixing up the pushed string list + Report from Grisha Levit + + 1/18 + ---- +doc/bash.1 + - typos and style fixes to satisfy groff warnings; remove uses of the + `CW' constant-width font; use .EX/.EE for examples; use consistent + style for double-quoted strings; fix inconsistent inter-paragraph + spacing + Fixes from G. Branden Robinson + + 1/19 + ---- +test.c + - binary_test: make sure all calls in posix mode use TEST_LOCALE for + locale-specific string comparisons + +shell.c + - find_bashrc_file: remove + + 1/20 + ---- +shell.c + - exit_shell: don't try to call rl_deprep_terminal, regardless of the + readline state we inherited, if bash_readline_initialized is 0 + Fixes bug reported by Oguz + - shell_reinitialize: reset startup_state and reading_shell_script to 0; + reset debugging_mode to 0 + + 1/22 + ---- +builtins/shopt.def + - reset_shopt_options: reset debugging_mode to 0 + +builtins/set.def + - reset_shell_options: reset interactive_comments to 1 + +braces.c + - brace_expand: if the first call to brace_gobbler consumes the entire + string, don't try to call it again + - brace_expand: check that i < tlen before checking to see if + expand_seqterm left more of the string unconsumed + - brace_gobbler: if extract_command_subst hits the end of the string + without closing the command substitution, make sure we return 0 as + well as set *i = tlen + From a fuzzing report by Nathan Mills + + 1/23 + ---- +subst.c + - function_substitute: unwind-protect current_builtin and this_shell_builtin + like we do this_shell_function + From a fuzzing report by Nathan Mills + + 1/24 + ---- +braces.c + - brace_gobbler: handle nofork command substitutions; skip over any + enclosed command and any braces it contains + +bashline.c + - check_redir: return 0 if we're in a nofork comsub, so we will attempt + command word completion if appropriate + + 1/26 + ---- +lib/readline/readline.h + - RL_STATE_READSTR: new state flag saying we are reading an arbitrary + string from the keyboard using rl_readstr + +lib/readline/rlprivate.h + - READSTR_FREEPMT: new context state flag for rl_readstr; indicates + that we have allocated a new prompt with _rl_make_prompt_for_search + and we should free it with rl_restore_prompt because rl_clear_message + will not do it + +lib/readline/text.c + - _rl_readstr_init,_rl_readstr_cleanup: set and unset RL_STATE_READSTR + - _rl_unsave_saved_readstr_line: free any rl_undo_list, which we may + have accumulated while reading the string, before restoring the line + Fixes leaks reported by sparrowhawk996@gmail.com. + - _rl_readstr_init: set the READSTR_FREEPMT context flag after we + call _rl_make_prompt_for_search, which calls rl_save_prompt + - _rl_readstr_sigcleanup: new function to call from signal cleanup; + restores prompt and calls _rl_readstr_cleanup to free the readstr + context + - _rl_readstr_restore: if the RL_READSTR_FREEPMT flag is set in the + context, call rl_restore_prompt to deallocate the prompt we created + +lib/readline/callback.c + - rl_callback_sigcleanup: call _rl_readstr_sigcleanup to deallocate + readstr state on a signal + +lib/readline/text.c + - rl_execute_named_command: free COMMAND before returning + + 1/27 + ---- +lib/readline/rlprivate.h + - SF_FREEPMT: new flag for non-incremental search contexts: means we + saved the prompt data with _rl_make_prompt_for_search and need to + restore it with rl_restore_prompt, since rl_clear_message will not + +lib/readline/search.c + - _rl_nsearch_sigcleanup: new function that if calls rl_restore_prompt + to clean up the saved prompt data if necessary before calling the + context cleanup function, avoids memory leak + - _rl_nsearch_init: set the SF_FREEPMPT flag after calling + _rl_make_prompt_from_search so we can clean it up properly on errors + - _rl_nsearch_abort,_rl_nsearch_dosearch: call rl_restore_prompt only + if cxt->sflags includes SF_FREEPMT, manage SF_FREEPMT state + +lib/readline/signals.c + - _rl_state_sigcleanup: call _rl_nsearch_sigcleanup + +lib/readline/callback.c + - _rl_callback_sigcleanup: call _rl_nsearch_sigcleanup + + 1/29 + ---- +builtins/cd.def + - change_to_directory: don't try to canonicalize a NULL path that's + NULL after make_absolute. + From a report by Kerin Millar + +jobs.c + - retrieve_proc_status,delete_proc_status: external interfaces to + bgp_search and bgp_delete, respectively; these take an argument + that says whether or not to block SIGCHLD + +jobs.h + - retrieve_proc_status,delete_proc_status: extern declarations + +builtins/wait.def + - check_bgpids: new function to check whether a requested PID is in + the bgpids table (retrieve_proc_status) and optionally delete it + if it is (posixly_correct delete_proc_status) while returning its + status. If the PID isn't in the bgpids table, return -1 + - wait_builtin: if -n is supplied with pid/job arguments, use + check_bgpids to check the bgpids table for any of the requested + pids. Tagged for bash-5.3, might need another option + From a report by Steven Pelley + + 1/30 + ---- +redir.c + - redir_open: assume the AFS bug with O_CREAT and existing files in + protected directories has been fixed over the years, so take out + the workaround. + From a report by Etienne Champetier + +jobs.c + - wait_for_any_job: if the jobs list is frozen and we're running a + funsub, mark the job as notified so it gets cleaned up later + - wait_for_any_job: if we're in posix mode, we should remove the job + from the job list and not add it to the bgpids list, as posix + requires + +builtins/set.def + - set_shellopts: use ASS_FORCE in the call to bind_variable so we + don't have to mess with temporarily turning off readonly + +builtins/shopt.def + - set_bashopts: same + Report by Emanuele Torre + + 2/1 + --- +builtins/printf.def + - vblen: make it a size_t to avoid going negative on underflow + - clearerr, ferror, fflush: don't test these if vflag is set and we're + writing to a string (multiple places) + - vbprintf: pass through failure returns (< 0) from vsnprintf to the + caller(s) so we can return on errors + - printf_builtin: remove redundant test for empty or missing format + string + - PF: call builtin_error if vflag is set, sh_wrerror otherwise + (via PRETURN) + - PF: use PRETURN so we can get partial output to the variable on + error (if vflag is set) + - PRETURN: free conv_buf before attempting the write (it would get + cleaned up on the next call, but why not) + - PRETURN: clean up vbuf only if vflag is set, and clean it up on + error (it would get cleaned up on the next call, but...) + Fixes from Grisha Levit + + 2/2 + --- +doc/bash.1,doc/bashref.texi + - word expansions: make it clearer that quote removal is one of the + shell word expansions + +execute_cmd.c,execute_cmd.h + - currently_executing_command: no longer static, so other parts of + the shell can save and restore it if necessary + +subst.c + - function_substitute: unwind-protect currently_executing_command, + since parse_and_execute can overwrite it in the current shell + execution context. + Report from Grisha Levit + +lib/readline/readline.c + - readline_common_teardown: new function from the guts of + readline_internal_teardown, manages and deallocates rl_undo_list. + +lib/readline/callback.c + - rl_callback_handler_remove: if we're removing the line handler + while we still have an undo list, we didn't call + readline_internal_teardown. Call readline_common_teardown to manage + the undo list in case we are calling this from a signal handler + but not exiting the program. + Fixes leaks reported by sparrowhawk996@gmail.com. + +variables.c + - initialize_shell_variables: use ASS_FORCE when binding SHELLOPTS or + BASHOPTS if we get them from the environment, in case they've + already been created as shell variables and set to readonly (like + changes from 1/30) + - set_ppid: use ASS_FORCE in the call to bind_variable instead of + temporarily turning off att_readonly + +subst.c + - extract_delimited_string: pass FLAGS down to skip_single_quoted and + skip_double_quoted so we propagate SX_COMMAND and SX_COMPLETE + properly. + Fixes bug reported by A4-Tacks + + 2/3 + --- +bashline.c + - initialize_readline: add `bash-vi-complete' as a bindable command + name so users can bind other key sequences to it + - vi_advance_point: function to advance point by one character even + in the presence of multibyte characters + - bash_vi_complete: call vi_advance_point instead of just incrementing + rl_point + + 2/5 + --- +doc/bash.1,lib/readline/doc/readline.3 + - minor updates to handle old versions of troff and groff warnings + Fixes from G. Branden Robinson + + 2/7 + --- +jobs.c + - notify_of_job_status: in non-interactive shells, if we're not going + to print information about a terminated background job + (SIGINT/SIGTERM/SIGPIPE), don't mark it as notified, in the same + way that we don't mark background jobs that exit cleanly as notified + Inspired by a discussion with Robert Elz and + https://lists.gnu.org/archive/html/bug-bash/2024-01/msg00189.html + + 2/9 + --- +lib/readline/history.c + - DEFAULT_HISTORY_GROW_SIZE: bump up to 256 + - real_history, real_history_size: the true history array and its + allocated size. the_history begins a user-visible window into this + list, extending for history_size entries + - history_list_grow_size: compute how much to extend the history list; + increase by roughly sqrt(history_size), don't extend by less than + (new) DEFAULT_HISTORY_GROW_SIZE + - history_list_resize: possibly resize/realloc real_history and reset + the_history to real_history and history_size to real_history_size + - advance_history: make the `window' that the_history provides into + real_history advance to simulate dropping an initial entry; don't + need to memmove all the entries any more + - add_history: call advance_history as necessary to move the_history + window + - add_history: call history_list_resize as necessary + Report and initial patch from Casey Johnson + + 2/12 + ---- +bashline.c,lib/readline/bind.c,lib/readline/display.c + - replace some sprintf calls with snprintf to appease clang + +execute_cmd.c + - execute_simple_command: unwind-protect this_command_name, since we + assign it to something we will free if unwind-protects are run + - execute_function: unwind-protect currently_executing_command, since + execute_command_internal will change it to something will will free + if unwind-protects are run + Report from Grisha Levit + - execute_function: if we didn't compile with debugger support, restore + currently_executing_command after run_debug_trap, like in other + cases + + 2/13 + ---- +builtins/declare.def + - declare_invalid_opts: move the code that checks for invalid option + combinations to its own function; it returns 0 for no errors and + a return code for declare_internal to return otherwise + Inspired by report from Grisha Levit + - declare_invalid_opts: make -A -a and -A +A/-a +a option combinations + invalid + Report from Grisha Levit + + 2/14 + ---- +bashline.c,general.c,subst.c,lib/sh/pathphys.c,builtins/read.def, +support/bashversion.c + - changes for cygwin and msys (no new features) + +bashline.c,builtins/fc.def,general.c,parse.y,stringlib.c,subst.c,variables.c + - MSYS-specific changes to support \r\n line endings and DOS-style + paths + +configure.ac,cross-build/msys32.cache,support/config.rpath,support/shobj-conf + - MSYS-specific build options + +configure.ac,config.h.in,m4/unlocked-io.m4,general.h,include/unlocked-io.h +MANIFEST + - adapt Gnulib's unlocked-io module for faster stdio functions. + From Grisha Levit + +lib/malloc/malloc.c,lib/malloc/table.h,lib/sh/strlcpy.c + - fixes for ISO C 23 + Patch from Collin Funk + + 2/16 + ---- +jobs.c + - waitchld: note whether or not we are executing in a signal handler + context and break out of the loop if we receive a terminating + signal instead of calling termsig_handler, which can execute unsafe + functions + From https://issues.redhat.com/browse/RHEL-22295 + +variables.h + - valid_readonly_attrs,invalid_readonly_attrs: new defines for declare + to use to validate attempts to modify attributes of readonly + variables + +builtins/declare.def + - declare_internal: reject attempts to modify (set or unset) attributes + in invalid_readonly_attrs for readonly variables. + From a discussion with Grisha Levit + + 2/17 + ---- +variables.h + - add att_readonly to valid_readonly_attrs; it's valid to use + declare -r var ; declare -r var + +Makefile.in,builtins/Makefile.in + - add unlocked-io.h to dependencies and variable contents where + appropriate + - add additional include files to INSTALLED_INCFILES + +builtins/pushd.def,examples/loadables/necho.c + - fix order of includes to get unlocked-io.h + From Grisha Levit + +subst.c,subst.h + - rename quote_rhs -> quote_nosplit + + 2/19 + ---- + +subst.c + - quote_var_value: break the code that quotes a variable value ($x, + ${x}, ${x[n]}, etc.) into a separate inline function and call it + from param_expand and parameter_brace_expand_word so they do it + consistently + - param_expand: quote $* appropriately using quote_nosplit if we are + in a place where word splitting will not occur (PF_NOSPLIT2), + expand_no_split_dollar_star == 1 but quoted is 0 + - quote_var_value: use quote_nosplit if we are in a place where word + splitting will not occur (PF_NOSPLIT2) but quoted == 0. + Fixes bug with IFS=$'\1' reported by alex xmb sw ratchev + +arrayfunc.c + - array_value: make sure to quote ${A[*]} appropriately if not quoted + (quoted == 0) and in a place where word splitting does not occur + (flags & AV_ASSIGNRHS); the caller expects array_value to quote in + this case + +subst.c + - parameter_brace_expand_word: make sure to call array_value with + AV_ASSIGNRHS if we are expanding unquoted ${A[*]} in a place where + word splitting does not occur with a non-null $IFS; array_value will + quote appropriately here + - parameter_brace_expand_word,param_expand: use quote_var_value when + expanding $N and ${N} + +doc/bash.1,doc/bashref.texi + - HISTIGNORE: clarify the description a little to emphasize that lines + matching one of the patterns are not saved in the history list + From https://savannah.gnu.org/support/index.php?111020 + + 2/20 + ---- +builtins/evalfile.c + - FEVAL_RETRY: if set in FLAGS, _evalfile will retry an interrupted + open + - _evalfile: if open() returns -1, FEVAL_RETRY is set in FLAGS, and + errno == EINTR, retry the open after checking for interrupts or + terminating signals + - maybe_execute_file,force_execute_file: pass FEVAL_RETRY in flags + +bashhist.c + - load_history: retry read_history if it returns EINTR after checking + for interrupts or terminating signals + +lib/readline/bind.c + - _rl_read_init_file: retry the open once if it's interrupted due to a + signal. If we are at a point where readline has installed its + signal handlers, check for signals readline handles + From a patch from Grisha Levit + + 2/21 + ---- +subst.c + - make_internal_declare: now takes two strings of option arguments: + those to turn on (`-') and those to turn off (`+') + - expand_declaration_argument: simplify the code; handle `-' and `+' + optionsns; always call make_internal_declare + From a patch from Grisha Levit + + 2/22 + ---- +aclocal.m4 + - add additional character to test for broken wcwidth (0x200b) + +lib/readline/display.c + - update_line: use IS_COMBINING_CHAR instead of UNICODE_COMBINING_CHAR + plus WCWIDTH; it doesn't make sense on systems where wcwidth isn't + broken + + 2/27 + ---- +print_cmd.c + - print_case_clauses: if one of the case command pattern lists begins + with the word `esac' (unquoted), precede the pattern list with `(', + since it had to be there originally to get through the parser. + Report by Emanuele Torre + + 2/29 + ---- +general.c,general.h + - string_to_rlimtype: takes a second ENDP argument, like strtol, so + the caller doesn't have to check that the string is all digits, + but can optionally check for and disallow a 0x prefix + + 3/2 + --- +subst.c + - dequote_list: unset the W_QUOTED flag in the word after dequoting it + - parameter_brace_expand_rhs: if the word in the list returned by + expand_string_for_rhs has W_QUOTED set, but the string being + expanded was not quoted, turn on the W_QUOTED in the returned word + so we can potentially avoid word splitting + - expand_word_internal: if CTLNUL is a IFS character, don't add quoted + null strings to istring if we're going to be word splitting, since + they will be treated as word delimiters + + 3/6 + --- +examples/loadables/getconf.c + - getconf_builtin,getconf_all: changes for POSIX interp 1808 proposal + to allow an optional pathname argument with -a that forces its use + for pathconf variables + https://www.austingroupbugs.net/view.php?id=1808 + + 3/11 + ---- +builtins/printf.def + - printf_builtin: %lc/%ls (%C/%S) should only work on wide characters + when in a locale where MB_CUR_MAX > 1. + Report by Emanuele Torre + + 3/12 + ---- +jobs.c + - notify_of_job_status: don't mark terminated background jobs or stopped + jobs as notified in shells started to run -c command + From a report by Greg Wooledge + - notify_of_job_status: make the final marking the dead job as notified + a true catch-all so we can put a debugging message in there to see + if there are other missing cases + - notify_of_job_status: don't mark terminated jobs that died due to + a signal the shell trapped (on the assumption that the shell + received the signal, too) as notified, since we don't report on it + in the JDEAD case if the signal is trapped + + 3/13 + ---- +builtins/printf.def + - PF: print an error message if printf returns an error or leaves + ferror(stdout) true + From a report by Paul Eggert + + 3/14 + ---- +builtins/printf.def + - getint: now takes an int argument and returns it if the conversion + overflows an int; changed callers in printf_builtin + - getint: consolidate checks for overflow. This changes the behavior + if the argument overflows an intmax_t: it returns a field width of + 0 (the overflow result) instead of -1, which changes how printf + behaves. This is consistent with the behavior when the argument + overflows an int + - printf_builtin: change check for overflow of [LONG_MIN..LONG_MAX] + for %d/%i to be explicit instead of relying on integer overflow of p + - printstr,printwidestr: print message if field width or precision + overflow, since we don't call printf + - printstr,printwidestr: set field width and precision on integer + overflow the way we do in printf_builtin + From a report and patch by Paul Eggert + +bashtypes.h + - PRIdMAX: move redefinition here after including inttypes.h + +builtins/printf.def,examples/loadables/seq.c,examples/loadables/getconf.h + - remove PRIdMAX redefinitions, since it's now fixed in bashtypes.h + From a report and patch by Paul Eggert + + 3/15 + ---- +include/stdckdint.in.h,include/intprops-internal.h + - new files, from gnulib + +configure.ac + - stdckdint.h: create in the build directory if the system doesn't + provide one by copying ${srcdir}/include/stdckdint.in.h; make + sure we don't create a new one every time, changing the timestamp + +Makefile.in + - CREATED_HEADERS: add stdckdint.h + +stringlib.c,externs.h + - substring: now takes size_t arguments for START and END + +lib/sh/stringvec.c + - strvec_create,strvec_mcreate,strvec_resize,strvec_mresize: use + ckd_mul to avoid size_t overflow + - strvec_len,strvec_flush: use size_t variable as array index + From a report by Paul Eggert + +bashansi.h + - stdbool.h: include if we have it, typedef bool as unsigned char if + we don't and HAVE_C_BOOL isn't defined + + +m4/c-bool.m4 + - autoconf check for `bool' from gnulib + +configure.ac + - include m4/c-bool.m4, call gl_C_BOOL; don't explicitly check for + stdbool.h using AC_CHECK_HEADERS any more + +config.h.in + - HAVE_C_BOOL: define + + 3/16 + ---- + +builtins/printf.def + - decodeprec: now decodeint, takes new arguments: a char ** that is + the string to parse and update, an argument saying whether or not + to print an error message on overflow, and an argument that should + be the return value on overflow; use ckd_* macros to check overflow + - printstr, printwidestr: use a different mechanism to check overflow; + call decodeint to get precision and field width + +braces.c + - include stdckdint.h for the ckd_* overflow checking macros + - mkseq: the width argument is now size_t + - mkseq: perform overflow detection using the ckd_* macros + - mkseq: perform zero-padding directly instead of using asprintf; the + sprintf family has trouble when width > INT_MAX + - expand_seqterm: use size_t instead of int for length and width + variables + From a report and patch by Paul Eggert + + 3/18 + ---- +builtins/printf.def + - printstr,bexpand: changed size/length arguments to be size_t; changed + callers + +subst.c + - string_var_assignment: if the variable is a local variable at the + current scope, output a declare command even if there are no + attributes or value. Still tagged as tentative + + 3/23 + ---- +test.c + - posixtest: takes an argument, the number of test arguments to parse + - two_arguments,three_arguments: use advance() instead of accessing + and manipulating pos directly + - posixtest,three_arguments,two_arguments: don't set pos = argc + directly, rely on functions to advance pos appropriately + Picked up from coreutils test + - term: if we see a left paren, scan forward for a closing right paren + and use posixtest() if there are 1-4 arguments between the parens to + avoid ambiguous behavior for expressions like true -a \( ! -a \), + which, though it's horribly ambiguous, a user would expect to + return false instead of an error message + Picked up from coreutils-9.2 test + + 3/25 + ---- +bashansi.c + - HAVE_C_BOOL: prefer if defined, fall back to stdbool.h if bool isn't + a compiler builtin + +braces.c + - mkseq: simplify break condition + +builtins/printf.def + - decodeint: let the caller decide what to do with an overflow return, + don't return -1 after calling report_erange(). This will honor a + precision even if the field width overflows + - printf_builtin: check for overflow when adjusting precision for + string length with %Q + - printstr,printwidestr: now that the code uses decodeint, we don't + need to check the precision against INT_MAX + +bashansi.h + - include stddef.h if we have it, otherwise define replacements for + NULL and offsetof() + +builtins/help.def,lib/sh/fmtulong.c,lib/sh/getcwd.c,lib/sh/makepath.c, +lib/sh/snprintf.c,lib/sh/strtod.c,lib/sh/strtol.c,unwind_prot.c, +lib/readline/shell.c + - include bashansi.h instead of stddef.h, or remove a stddef.h include + if bashansi.h is already included + - remove extra definitions that appear in stddef.h or bashansi.h + +lib/sh/reallocarray.c,externs.h + - implementation of reallocarray(), originally from OpenBSD, from + Paul Eggert + +configure.ac + - use AC_REPLACE_FUNCS for reallocarray + +xmalloc.c,xmalloc.h + - xreallocarray: implementation of reallocarray that uses xrealloc + - sh_xreallocarray: implementation of reallocarray that uses + sh_xrealloc and has file and line information for error messages + +lib/sh/stringvec.c + - strvec_create, strvec_resize: rewrite in terms of xreallocarray + - strvec_mcreate, strvec_mresize: rewrite in terms of reallocarray + - strvec_remove, strvec_search, strvec_copy, strvec_from_word_list, + strvec_to_word_list: use size_t instead of int where appropriate + +lib/sh/stringvec.c,externs.h + - strvec_search: return a value of type ptrdiff_t, since size_t is + unsigned and we want to return -1 if not found + + All from a report and patch by Paul Eggert + +test.c + - term: change paren scan algorithm to count open and close parens so + we handle nested subexpressions. Still not compatible in the case + of something like test true -a \( ! -a \) \) + + 3/27 + ---- +parse.y + - flush_parser_state: new function, deallocates the members of a + parser state struct that are dynamically allocated + - parse_comsub: call flush_parser_state in places where we will + return an error or jump to the top level + Fixes memory leaks on error reported by bug_reports00@protonmail.com + +Makefile.in + - CREATED_MACOS: list of dSYM directories created by building and + testing + - distclean,maintainer-clean: remove $(CREATED_HEADERS) and + $(CREATED_MACOS) + - maintainer-clean: remove ctags/etags files + + 3/28 + ---- +bashline.c,bashline.h + - uw_restore_parser_state: moved to parse.y and declaration to shell.h + +shell.c,shell.h + - parsing_command: new flag, set to 1 when calling yyparse; saved and + restored by save_parser_state/restore_parser_state + +parse.y,shell.h + - parsing_command: new element of sh_parser_state_t + +sig.c + - throw_to_top_level: reset executing and parsing_command to 0 + +parse.y + - parse_comsub: set parsing_command to 1 before calling yyparse() + +eval.c + - parse_command: set parsing_command to 1 before calling yyparse(), + restore old value when yyparse returns + +subst.c + - function_substitute: if we are parsing a command, save the parser + state with save_parser_state and add an unwind-protect to restore it + From a report from Grisha Levit + - function_substitute: only save and restore the pipestatus array if + we are not parsing a command, since save_parser_state saves it + +parse.y,externs.h + - decode_prompt_string: now takes an additional argument to determine + whether this is expanding PS[0124] or the @P transformation + - decode_prompt_string: keep track of the (last) real prompt string + being decoded so a @P expansion embedded in the prompt returns the + same result as the prompt string itself for the \! and \# expansions + From a patch from Grisha Levit + +parse.y,print_cmd.c,eval.c,subst.c + - decode_prompt_string: changed all callers + + + 3/29 + ---- + +doc/bash.1,lib/readline/doc/readline.3,lib/readline/doc/history.3 + - fix some font-setting directives + - fix some word breaks for font-changing macros + +lib/readline/doc/history.3 + - fix the macros for function signatures for AT&T troff limitations + - fix some paragraph spacing and other layout/spacing/hyphenation + issues + Fixes from G. Branden Robinson + + 4/1 + --- +execute_cmd.c + - shell_execve: minor changes to code that checks the #! interpreter + name + +execute_cmd.c + - execute_coproc: if MULTIPLE_COPROCS is not defined, close any old + file descriptors corresponding to sh_coproc. The user can still + copy them from the coproc array if desired; this prevents the shell + from hanging if a second coproc inherits file descriptors from a + previous one + From a report by Carl Edquist + +jobs.c,nojobs.c,jobs.h + - process_exit_status: no longer static, public function with an + extern declaration + + 4/2 + --- +execute_cmd.c,execute_cmd.h + - coproc_pidchk: now takes a full WAIT status word as a second + argument instead of just the exit status; arranged the prototype + to only be included if the source file includes posixwait.h for WAIT + +jobs.c + - waitchld: call coproc_pidchk with a WAIT second argument (like + nojobs.c does) + +command.h + - COPROC_STOPPED,COPROC_FOREGROUND: new flags values for coproc + +execute_cmd.c + - coproc_setstatus: now takes a full WAIT status word as the second + argument, passed from coproc_pidchk + - coproc_setstatus: use process_exit_status to translate a WAIT into + an int status, doing proper termsig+128 handling + - coproc_getstate: take a WAIT and return the appropriate COPROC_ + status flag (DEAD, STOPPED, etc.) + - coproc_setstatus: use coproc_getstate to set cp->c_flags + + 4/4 + --- +configure.ac + - changed release status to bash-5.3-alpha + - AC_PROG_GCC_TRADITIONAL: removed, since it no longer is supported + in autoconf-2.72 (which MacPorts upgraded me to) + +test.c + - term: made change of 3/25 dependent on the compatibility level + +support/config.guess,support/config.sub,support/config.rpath + - new versions, imported from gnulib + + 4/5 + --- +doc/bashref.texi + - update compatibility, posix mode, and bourne shell sections for + bash-5.3-alpha release + +version.c + - update copyright date to 2024 + +[bash-5.3-alpha frozen] + + 4/6 + --- +builtins/cd.def + - cd_builtin: a null pathname argument is now an error; POSIX interp + 1047 + +variables.c + - makunbound: revert change from 7/10/2023 about preserving the export + attribute when unsetting a local variable in light of POSIX interp + 1806 + + 4/8 + --- +bashline.c + - command_word_completion_function: we don't need to perform an extra + comparison against what rl_filename_completion_function returns if + we are searching $PATH for executable completions + - command_word_completion_function: if a directory name from $PATH + contains characters that need to be quoted, quote them and set + rl_completion_found_quote to force rl_filename_completion_function + to dequote the entire pathname + - command_word_completion_function: since the directory name from $PATH + is not quoted, use the dequoted hint to construct the full pathname + to pass to rl_filename_completion_function (possibly after quoting it) + From https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=306043 + + 4/10 + ---- +redir.h + - RX_EXPANDED: flag set when translating redirects to their final form; + indicates the redirection should not be expanded again + +redir.c + - do_redirection_internal: when translating a redirect into + r_err_and_out, set the RX_EXPANDED flag so the filename doesn't + get expanded again. + Fixes bug reported by squeaky + + 4/12 + ---- +parse.y + - expecting_in_command: new variable, set to FOR or CASE depending on + which command is expecting the IN token to follow it + - {save,restore}_parser_state: save and restore expecting_in_command + in `incmd' member + - special_case_tokens: for POSIX rule 6, check expecting_in_token + instead of last_read_token/token_before_that for case/for command + and whether we should return IN and maybe set PST_CASEPAT + - special_case_tokens: reset expecting_in_command before returning DO + - read_token_word: set expecting_in_command if last_read_token was + CASE or FOR and we are returning a WORD + - reset_parser: reset expecting_in_command + - parse_comsub,parse_compound_assignment: reset expecting_in_command + Fixes bug reported by nbowler@draconx.ca + +parser.h + - incmd: new member of parser_state, saves and restores the value of + expecting_in_command + - PST_FORCMD: new parser state, used to say if we're parsing a `for' + command and waiting for an IN token (not used yet) + + 4/22 + ---- +config-top.h + - MULTIPLE_COPROCS: now enabled by default + + 4/23 + ---- +doc/bash.1,doc/bashref.texi + - add text clarifying the difference between PIPESTATUS and $? + +expr.c,redir.c,jobs.c,parse.y,arrayfunc.c,test.c,subst.c +builtins/declare.def,builtins/wait.def,builtins/printf.def + - went through and removed or modified TAGs for bash-5.3 + +lib/readline/bind.c + - rl_print_keybinding: handle case where there are no key sequences + bound to the command name; don't just print out every unbound key + +builtins/bind.def + - bind_builtin: if the shell compatibility level is > 52, interpret + additional non-option arguments supplied with -P and -p as bindable + command names and print out any bindings for those names + + 4/24 + ---- +Makefile.in,doc/Makefile.in,builtins/Makefile.in +lib/sh/Makefile.in,lib/glob/Makefile.in,lib/tilde/Makefile.in +lib/readline/Makefile.in + - MFLAGS -> BASH_MAKEFLAGS, rely on make passing MAKEFLAGS in the + environment + From a report by Cedric Blancher + +buildconf.h + - new build include file, construct from buildconf.h.in; contains a + subset of config.h for use by the build tools + +mksyntax.c + - now assumes a C90 compilation environment; includes buildconf.h for + any build-time configuration variables + +Makefile.in + - buildconf.h: add to CREATED_CONFIGURE + - mksyntax: now depends on buildconf.h instead of config.h + + 4/25 + ---- +support/bashversion.c,version.c + - now assumes a C90 compilation environment; includes buildconf.h for + any build-time configuration variables + +support/printenv.c,support/recho.c,support/xcase.c,support/zecho.c + - now assumes a C90 compilation environment and POSIX.1-1990 execution + environment + + 4/26 + ---- +redir.h + - RX_INTERNAL, RX_USER (unused), RX_SAVCLEXEC, RX_SAVEFD, RX_EXPANDED: + new values starting at 0x80, now intended for rflags member of a + struct redirect; don't want them colliding with O_XX flags for open + and fcntl + +redir.c + - rflags: save redirect->rflags and pass it to make_redirection if + we're translating a redirection into a new one + - new_redirect: pass rflags to all calls to make_redirection now that + it holds more than REDIR_VARASSIGN + - RX_INTERNAL, RX_USER (unused), RX_SAVCLEXEC, RX_SAVEFD, RX_EXPANDED: + check and assign these in the rflags member; they're only used here + - do_redirection_internal: assign new_redirect->rflags back to + redirect->rflags since it can possibly be modified with RX_EXPANDED + - do_redirection_internal: take care not to leave REDIR_VARASSIGN in + new_redirect->rflags, since it will cause redirector to be freed, + leading to accessing freed memory + From a report by Clark Wang and a hint from + and Grisha Levit + + 4/28 + ---- +lib/sh/anonfile.c + - anonopen: call memfd_create with MFD_NOEXEC_SEAL + From a report by Kerin Millar + + 4/29 + ---- +shell.c,shell.h + - su_shell: now global + +variables.c + - get_bash_name: use the user's login shell for $BASH if the shell is + a login shell and the name is "-su". + From https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1069978 + +subst.c + - uw_unbind_localvar: unwind-protect to unbind a local variable at + the current function context + - function_substitute: make sure we unbind the local REPLY we created + at the current (fake) context + From a report by Koichi Murase + + 4/30 + ---- + +subst.c + - expand_arrayref: fix crash from freeing memory that's only allocated + and initialized if ARRAY_VARS is defined + Report and patch from Henrik Lindström + +jobs.h,jobs.c + - JLIST_POSIX: new format argument for pretty_print_job; implements + POSIX requirement that jobs display the status of all background + jobs and all jobs the user hasn't been notified about (unused yet) + - JLIST_BGONLY: new format argument for pretty_print_job; restricts + output to background jobs only (unused yet) + +jobs.c,jobs.h,execute_cmd.c,subst.c + - freeze_jobs_list: now takes an int argument with the new value of + jobs_list_frozen; prep for having different values with different + meanings; changed callers + +jobs.c + - wait_for_any_job: return right away if jobs_list_frozen > 0; allow + job status changes (e.g., J_NOTIFIED) if jobs_list_frozen < 0; use + this instead of testing executing_funsub directly + - notify_and_cleanup: allow notification and status change if + jobs_list_frozen < 0; don't delete any dead jobs + - should_notify: takes a job index and returns 1 if the shell would + notify the user about it, given the current job state + - pretty_print_job: if the jobs list is frozen, only print status + about jobs for which the shell would notify users (by calling + should_notify()) + +subst.c + - function_substitute: freeze the jobs list with value -1 so jobs + can change status and possibly inhibit printing by `jobs' + + 5/2 + --- +jobs.c + - notify_and_cleanup: allow job notifications if an interactive shell + is running a trap (interactive == 0 && interactive_shell && running_trap) + Fixes report by Koichi Murase on 11/14/2022 + - print_pipeline: don't print an extra space before the pipeline; push + that into pretty_print_job; print the space after the pid if we + print one + +jobs.h + - LONGEST_SIGNAL_DESC: update to 27 (macos SIGPROF). This changes the + test output + + 5/3 + --- +builtins/common.h + - SEVAL_NOTIFY: new flag for parse_and_execute; means we want job + notifications even though we're not interactive at this time and + would not satisfy the conditions + +builtins/evalstring.c + - parse_prologue: if SEVAL_NOTIFY is supplied, unwind-protect + want_job_notifications and set it to 1 + +jobs.c,jobs.h.nojobs.c + - want_job_notifications: new global variable, initialized to 0 + +jobs.c + - notify_and_cleanup: notify about dead jobs if want_job_notifications + is non-zero + +parse.y + - execute_variable_command: call parse_and_execute with the SEVAL_NOTIFY + flag + +eval.c + - reader_loop: call notify_and_cleanup before executing $PROMPT_COMMAND + if the shell is interactive and prompting + +trap.c + - run_pending_traps,_run_trap_internal,run_exit_trap: add SEVAL_NOTIFY + to the flags for parse_and_execute if the shell is interactive + +bashline.c + - bash_execute_unix_command: add SEVAL_NOTIFY to the flags for + parse_and_execute if the shell is interactive + Rest of fix for report by Koichi Murase + on 11/14/2022 + + 5/6 + --- + +execute_cmd.c,shell.c,builtins/evalfile.c,unwind_prot.c + - change some translated error messages to make the text more uniform + and reduce the number of gettext() calls + +redir.c,parse.y,bashhist.c.locale.c +builtins/common.c,builtins/bind.def,builtins/exec.def,builtins/fc.def +builtins/help.def,builtins/mapfile.def,builtins/printf.def,builtins/read.def +builtins/ulimit.def + - change some error messages to avoid having the format be the return + value from gettext() to avoid clang complaints; simplified + translatable strings and made them more uniform by removing printf + formatting directives + +execute_cmd.c + - notfound_str: cache the translated version of "command not found" + so we can call gettext early on and work around a macOS misfeature + From a MacPorts ticket https://trac.macports.org/ticket/68638 + forwarded by Tom + - execute_disk_command: use notfound_str instead of calling gettext + every time a command isn't found + +execute_cmd.c,execute_cmd.h + - init_notfound_str: call gettext to initialize and translate + notfound_str + - execute_disk_command: call init_notfound_str before forking if it + hasn't been initialized + +locale.c + - set_default_locale_vars: after we set the appropriate values for the + locale shell variables, call init_notfound_str to force a call to + gettext() + +jobs.c + - wait_for: don't try to set the tty state if we're running a trap, + even if a process terminates due to a signal + + 5/7 + --- +builtins/enable.def + - enable_builtin: don't try to turn enable f into enable -f f if the + shell is restricted + + 5/11 + ---- + +doc/bash.1,lib/readline/doc/readline.3,lib/readline/doc/rltech.texi + - document some of the bindable commands bound to Home, End, Insert, + Page Up, and Page Down, if those keys exist + From a report by Xose Vazquez Perez in 3/2024 + +configure + - make sure to note in CHANGES that configure now supports + --enable-year2038 for large time_t + + 5/14 + ---- +pathexp.c + - glob_quote_char: new function, identify characters that should have + backslashes preserved when quoting a glob pattern. Currently has + all the glob_char_p characters plus `%' and `#' for pattern + substitution and removal. + Fixes issue reported by Andreas Schwab + + 5/16 + ---- +pcomplete.c + - programmable_completions: change to allow a newly-loaded compspec + (after a completion function returns 124) to be used in more cases + From a patch from Grisha Levit + +mksyntax.c,version.c,support/bashversion.c + - include config.h if CROSS_COMPILING is not defined, assuming that + the build host and target host are the same + +buildconf.h.in + - if cross-compiling, define _POSIX_C_SOURCE and _XOPEN_SOURCE to + get the C90/1003.1-1992 compilation environment we assume + From a report from Grisha Levit + + 5/17 + ---- +pathexp.c + - globsort_sizecmp,globsort_blockscmp: replace subtraction with a + generic transitive comparison function to avoid problems with + integer underflow + From a report from Grisha Levit + + 5/20 + ---- +lib/readline/kill.c + - _rl_bracketed_text: make sure buf is null-terminated even if + rl_read_key() returns an error + From a report from Grisha Levit + +builtins/read.def + - read_builtin: if -u and -e are both supplied, dup the file descriptor + supplied as an argument to -u and use it in the new FILE * to pass + to readline as rl_instream. Works around an android problem with + stdio and application-managed file descriptors + Report and patch from Grisha Levit + + 5/21 + ---- +lib/sh/spell.c + - mindist: don't check best unless we set it + Report and patch from Grisha Levit + +jobs.c + - make_child: if FORK_NOJOB is in the flags argument, don't call + setpgid to set the child's process group in either the parent or + child + - alloc_process,dispose_process: allocate and deallocate a PROCESS; + changed callers + +subst.c + - command_substitute: call cleanup_the_pipeline after waiting for + the command substitution process, since we allocated it + + 5/22 + ---- +lib/readline/text.c + - rl_execute_named_command: fix a leak if the command name is null or + the bound function doesn't return (rl_abort) + Report and patch from Grisha Levit + +bashline.c + - command_word_completion_function: free directory_part if it's left + over from a previous completion + - command_subst_completion_function: free contents of match list left + over from previous completion + - bash_spell_correct_shellword: free text if it's "" before returning + - build_history_completion_array: only call qsort if there's actually + something in the array to sort + Report and patches from Grisha Levit + - bash_spell_correct_shellword: fix bug where we would correct the + previous word if we start on the first character of a word + - bash_spell_correct_shellword: make negative argument counts work + backwards, correcting words before point + Report from Grisha Levit + + 5/23 + ---- +lib/readline/text.c + - rl_change_case: if mbrtowc returns -1 or -2, jump to changing case + for a single character, since _rl_find_next_mbchar_internal() will + treat an invalid multibyte character as a sequence of bytes + Report from Grisha Levit + + 5/25 + ---- +execute_cmd.c + - shell_execve: fix typo in code that chops \r off the end of the #! + interpreter + Report and fix from Collin Funk + + 5/28 + ---- +execute_cmd.c + - time_command: only restore command->flags if we haven't longjmped + Report from Michael Maurer and + Grisha Levit + +subst.c + - skip_to_delim: if we're not skipping over command substitutions + lexically, call extract_command_subst instead of using the old + extract_delimited_string + Fixes bug reported by Oguz + +execute_cmd.c + - execute_arith_for_command: handle the extremely unlikely case that + the step or test expressions execute `break' or `continue' in a + nofork command substitution + Report from Oguz + + 5/29 + ---- +lib/readline/complete.c + - compute_lcd_of_matches: if we have multiple matches that compare + equally when using case-insensitive completion, but are different + lengths due to the presence of multibyte characters, use the + shorter match as the common prefix to avoid overflow + Report from Grisha Levit + + 5/30 + ---- +lib/readline/text.c + - _rl_readstr_init: don't call rl_maybe_replace_line since we're not + actually moving off this history line + Report from Grisha Levit + +builtins/read.def + - read_builtin: free ifs_chars in more return code paths + Report and patch from Grisha Levit + + 5/31 + ---- +quit.h + - ZRESET: new macro, calls zreset() if interrupt_state is non-zero + +lib/sh/zread.c + - zread: if read returns -1/EINTR, and we're executing a builtin, + call zreset just in case + +builtins/read.def + - read_builtin: if read returns > 0 (partial read) but interrupt_state + is non-zero, we're going to call throw_to_top_level, so call + ZRESET before that happens + Report from Oguz + - read_builtin: if zread/zreadc/zreadintr/zreadcintr return -1/EINTR, + make sure we call ZRESET in case zread did not + +variables.h + - ASSIGN_DISALLOWED: macro that encapsulates when an assignment to + SHELL_VAR *v with flags f will be disallowed and fail + +arrayfunc.c,execute_cmd.c,expr.c,redir.c,subst.c,variables.c +builtins/delare.def,builtins/getopts.def,builtins/printf.def,builtins/read.def + - use ASSIGN_DISALLOWED where appropriate + +arrayfunc.c + - assign_array_element_internal: if the assignment failed, as tested by + ASSIGN_DISALLOWED, free the assoc array key we allocated + Report from Grisha Levit + + 6/3 + --- +variables.c + - bind_function_def: don't copy the command tree if we're overwriting + a function definition; after function binding, the function_def + struct never uses the saved command anyway + From a report and patch by Koichi Murase + +parse.y + - make sure to free WORD in coproc WORD COMMAND after creating the + coproc struct + Report and patch from Grisha Levit + +builtins/exec.def + - exec_builtin: we don't need to set args to NULL; if shell_execve + reallocates args to add more items at the front, it has committed + to longjmp back to the top level + Report and patch from Grisha Levit + +subst.c + - expand_word_internal: dispose of the list used for $@ if we're not + splitting and save the space-separated list back to tword->word + Report and patch from Grisha Levit + +parse.y + - read_token: if we try to parse a conditional command and get a syntax + error, make sure to dispose of the partial command we created + Report and patch from Grisha Levit + - read_token: if we try to parse a conditional command and get a syntax + error because we read an unexpected WORD, dispose of the WORD_DESC + before returning -1 + Report and patch from Grisha Levit + - cond_term: if we read a WORD where we expect something else, dispose + of the WORD_DESC before returning COND_ERROR + Report and patch from Grisha Levit + + 6/10 + ---- +parse.y + - cond_term: if we read a WORD when expecting a close paren, dispose + of the WORD_DESC before returning COND_ERROR + - error_token_from_token: use the TOK argument instead of + current_token if we can't find the token as a reserved word or + symbol + + 6/12 + ---- +builtins/source.def + - source_builtin: add -p PATH option, searches PATH argument instead + of $PATH; overrides sourcepath; does not search $PWD if path search + fails + +doc/bash.1,doc/bashref.texi + - source: document -p + +pathexp.c + - if the size, blocks, or any of the time values compare equal, use + the name for a secondary sort key + +lib/sh/winsize.c + - tcgetwinsize: provide definition for missing newly-standard function + - get_new_window_size: use tcgetwinsize + +subst.c + - do_compound_assignment: if ASS_CHKLOCAL is in the flags, check for + variables at previous local scopes instead of just the current local + scope and the global scope + Part of fix for inconsistency between arrays and scalar variables + reported by Will Allan + +builtins/declare.def + - declare_find_variable: if `declare -G' is used, check for + variables at previous local scopes instead of just the current local + scope and the global scope + Rest of fix for inconsistency between arrays and scalar variables + reported by Will Allan + +pathexp.h + - SORT_NUMERIC: new "numeric" sort specifier + +pathexp.c + - globsort_numericcmp: new sort function for the "numeric" sort + specifier: all-digit names are sorted as numbers; names containing + any non-digits sort after all-digit names and are sorted + lexicographically. + Inspired by a discussion with Robert Elz + + 6/21 + ---- +lib/readline/text.c + - rl_change_case: make mlen size_t to assign the return value from + wcrtomb; change the tests of < 0 to use MB_INVALIDCH. + Report from Siteshwar Vashisht + + 6/26 + ---- +trap.c + - run_debug_trap: give the terminal back to pipeline_pgrp only if + job_control is enabled; that's the only way the trap command would + have given it to a different process group + Fixes bug reported by Mark March + + 6/27 + ---- +configure.ac + - remove support for cached files for cross-compiling; it's too hard + to keep them up-to-date without access to the platforms + + 6/28 + ---- +lib/readline/util.c + - _rl_audit_tty: make sure to close fd before returning on error + +lib/sh/casemod.c + - sh_modcase: use size_t variable as return value for wcrtomb; check + for invalid wide char and copy all characters in the multibyte + character as-is if it is + +lib/sh/zwrite.c + - zwrite: use size_t and ssize_t variables + +builtins/evalfile.c + - _evalfile: use size_t variable for return value from strlen() + +lib/readline/funmap.c + - rl_funmap_names: don't bother calling qsort if result doesn't have + any entries + + All from a report by Siteshwar Vashisht + + 6/29 + ---- +lib/readline/examples/histexamp.c,lib/readline/examples/manexamp.c, +lib/readline/examples/rl-callbacktest.c,lib/readline/examples/rl-callbacktest2.c, +lib/readline/examples/excallback.c,lib/readline/examples/rlptytest.c + - small changes to fix warnings + From a report by Hiroo Hayashi + + 7/1 + --- +execute_cmd.c: + - ADJUST_LINE_NUMBER: encapsulate code that adjusts line_number in + shell functions executed in interactive shells into a macro + + 7/2 + --- +doc/bash.1,doc/bashref.texi + - changes to the --rcfile description to avoid the use of `force' and + stay away from the word `replace' + +lib/readline/misc.c + - _rl_maybe_replace_line: old rl_maybe_replace_line, now takes an + argument saying whether or not to clear rl_undo_list + - rl_maybe_replace_line: now calls _rl_maybe_replace_line with a 0 + argument for backwards compatibility + +lib/readline/rlprivate.h + - _rl_maybe_replace_line: extern declaration + +lib/readline/search.c + - _rl_nsearch_init,rl_history_search_internal: call _rl_maybe_replace_line + with a 1 argument so these searches can manage rl_undo_list and + restore it appropriately + - rl_history_search_internal: don't set the history offset back to + oldpos if the history search is successful; we want the history offset + to be set to the position of the last matching line, like isearch + + 7/5 + --- +jobs.c + - procsub_reap: new function, blocks and unblocks SIGCHLD around + call to procsub_prune + - cleanup_dead_jobs: call procsub_reap even if there are no jobs in + the jobs list or the jobs list is frozen + Inspired by report from Zachary Santer + + 7/6 + --- +subst.c,subst.h,execute_cmd.c,jobs.c + - reap_procsubs: rename to delete_procsubs + + 7/7 + --- +aclocal.m4 + - BASH_CHECK_LIB_TERMCAP: check for ncursesw before ncurses, add + -lncursesw if found, to avoid pkgconfig issues for readline (since + this is a shared file) + Report and fix from Rosen Penev + + 7/8 + --- +builtins/evalstring.c + - should_optimize_fork: don't optimize the fork if we're executing in + a shell function and a return trap is set + - optimize_shell_function: mark a simple command at the end of a shell + function as a candidate for optimization, rather than setting + CMD_NO_FORK before the function executes -- it could set a return + trap + Report from Jens Schmidt + - parse_and_execute: don't let process substitutions or other calls + to parse_and_execute do + - parse_string: if flags & SEVAL_ONECMD, stop after parsing a single + command, even if it doesn't consume the entire string + +parse.y + - parse_string_to_command: call parse_string with SEVAL_ONECMD, since + we only want to parse a single command and make sure it consumes + the entire string, not consume the string and return the last command + parsed + + 7/9 + --- +bashline.c + - _ignore_completion_names: restrict force_fignore to act only on + completions that should be affected by FIGNORE; in other cases + act as if it were set to 1 + From a report and patch by Koichi Murase + + 7/15 + ---- +builtins/ulimit.def + - add help text saying that some of the units change in posix mode + + + 7/17 + ---- +subst.c + - remove some unused functions + +jobs.c,jobs.h + - procsub_search,procsub_delete: now take an extra parameter saying + whether or not to block SIGCHLD while they run; avoids overhead + when called when SIGCHLD is already blocked; changed callers and + extern declaration + - struct process now has a new FLAGS member; possible values defined + in jobs.h; initialized in alloc_process + - procsub_setflag,procsub_setflag: set one of the PROC_XXX flags on + one or all of the processes in the procsub list + - new value for the flags argument to make_child: FORK_PROCSUB + - add_process: now returns the PROCESS * it creates so the caller can + set flags or otherwise modify it + - get_job_by_pid: return NO_JOB for negative pids immediately + +subst.c + - process_substitute,command_substitute: call make_child with the + appropriate FORK_ flag + +jobs.c + - make_child: set PROC_ flags in the PROCESS * we create based on the + FORK_ flags the caller passes + - wait_for: only call set_procsub_status if the process has terminated + - wait_for_any_job: check for any terminated procsubs as well as any + terminated background jobs + +builtins/wait.def + - check_bgpids: rename to check_nonjobs + - wait_builtin: if the -n option is supplied and pid arguments are + supplied, check the bgpids list and procsubs for terminated processes + - check_nonjobs: if one of the pids in LIST corresponds to a terminated + procsub, return its status and move the procsub to the bgpids list + - set_waitlist: if we have a non-existent or invalid job, and a pid + argument that's >= 0, look for a procsub with that pid and set + PROC_WAITING if we have one + - unset_waitlist: unset PROC_WAITING in all procsubs + + 7/18 + ---- +jobs.c + - procsub_prune: set last_procsub_child to NULL if we are cleaning up + that process because it's terminated, since that will invalidate the + pointer + + 7/22 + ---- +lib/malloc/malloc.c + - RIGHT_BUCKET: don't check binsizes[nu-1] unless nu >= 1; clamp at 0 + otherwise + - internal_realloc: don't check bucket at nunits-1 unless nunits >= 1 + Report and fix from Collin Funk + + 7/25 + ---- +variables.c + - push_source: new function, pushes a filename to BASH_SOURCE; changed + callers (shell.c, execute_cmd.c, builtins/evalfile.c) + - bash_source_fullpath: new variable, if non-zero, push_source runs + the filename through sh_realpath before pushing it to BASH_SOURCE + Feature requested by several, including konsolebox + +builtins/shopt.def + - bash_source_fullpath: new option, controls bash_source_fullpath and + whether or not BASH_SOURCE contains full pathnames + +doc/bash.1,doc/bashref.texi + - bash_source_fullpath: document new shell option + + 7/26 + ---- +jobs.c,jobs.h,subst.c + - last_procsub_pid: new variable, set to the pid of last_procsub_child, + so it will survive the PROCESS * being deleted if we need it. Not + used yet + + 7/29 + ---- +doc/bash.1,doc/bashref.texi + - wait: update description to clarify wait -n and unify language + Inspired by report from Zachary Santer + - set: note that the -e behavior for pipelines is affected by the + state of the pipefail option + From a report by Martin D Kealey + +variables.c,hashcmd.c,builtins/hash.def,builtins/history.def,builtins/source.def + - use ABSPATH/RELPATH/absolute_program instead of testing for slash + explicitly + + 7/30 + ---- +lib/readline/histfile.c + - history_do_write: return 0 immediately if nelements < 0 + Report from ZeroIntensity Dev + + 8/3 + --- +lib/sh/zread.c,externs.h + - zungetc: new function, pushes a character back into a single char of + storage so it can be used with the zread* functions that call read(2) + directly and don't use lbuf. If we try to push back more than one + char, we use lbuf, assuming that the caller will accommodate it + +builtins/read.def + - read_mbchar: if we read a partial multibyte character (-2) and then + a delimiter that makes it an invalid multibyte character (-1), use + zungetc to push the delimiter back, adjust mbchar, and return what + we read so far to be added as single bytes + From a report by Kerin Millar + + 8/7 + --- +builtins/evalstring.c + - can_optimize_connection: only check bash_input.location.string if + bash_input.type == st_string, in case we want to use this in other + contexts. If we do, the caller *must* make sure it's the last + command in the calling context + +execute_cmd.c + - execute_subshell_builtin_or_function: if this is an async function + call, try to optimize away the fork before the last simple command + in the function body by calling optimize_shell_function + - execute_command_internal: if we have a simple command for which + CMD_TRY_OPTIMIZING is set in a SUBSHELL_ASYNC subshell environment, + try to set CMD_NO_FORK by checking via should_optimize_fork + + 8/9 + --- +parse.y + - yy_readline_get: before calling readline, call rl_clear_signals to + reset the signal handling disposition to a known state. Most of the + time it's a no-op + +lib/readline/signals.c + - _rl_handle_signal: make the call to sigprocmask(SIG_UNBLOCK,... + more symmetric with the corresponding call to SIG_BLOCK + +trap.c + - run_pending_traps: before calling run_interrupt_trap, restore + running_trap and trap_return_context, since _run_trap_internal + will save and restore them, too + +builtins/read.def + - read_builtin: if -e is supplied, make sure to install unwind-protects + to reset the attempted completion function and the event hook even + if the timeout is not supplied. + Report from Oguz + + 8/12 + ---- +lib/readline/histsearch.c,lib/readline/histlib.h + - history_search_internal: takes a new argument, LINEDIR, saying which + direction to perform the substring/pattern search in the line, + decoupling it from the direction through the history list; changed + all callers (history_search, history_search_prefix, _hs_history_search, + _hs_history_patsearch) + - _hs_history_search,_hs_history_patsearch: takes the same new LINEDIR + argument, just passes it to history_search_internal; changed all + callers (noninc_search_from_pos) + +lib/readline/search.c + - noninc_search_from_pos: changed calls to _hs_history_search and + _hs_history_patsearch + +lib/readline/histexpand.c + - get_history_event: instead of using function pointers to a history + search function, set the right flags and just call _hs_history_search + with those flags using -1 for list direction and line direction + + 8/13 + ---- +builtins/printf.def + - printf_builtin: fix params to call to mklong for long double formats + if STRTOLD_BROKEN is defined + +lib/sh/winsize.c + - rearrange includes to make sure is included if + HAVE_TCGETWINSIZE is defined + Report from Grisha Levit + + 8/14 + ---- +lib/readline/rlmbutil.h + - _rl_is_basic: adapted from gnulib is_basic; tells whether a character + is a single byte because it's guaranteed by ISO C and POSIX + +lib/readline/mbutil.c + - _rl_mbstrlen: counts the number of possibly multibyte characters in a + string depending on the current locale; uses _rl_utf8_mbstrlen or + _rl_gen_mbstrlen as appropriate (or strlen for a single-byte locale) + +lib/readline/readline.c + - _rl_internal_char_cleanup: if we are using multibyte characters, call + _rl_mbstrlen to determine whether or not we've read as many characters + than rl_num_chars_to_read says we should + Report from Grisha Levit + +builtins/read.def + - delim,delim_char: once again an int so we can more easily + distinguish -1 and other unsigned char values >= 0x7f; make + sure delim gets an unsigned char if passed with -d + - edit_line: now takes an int parameter for the delim char; only add + the delim to the end of the string if it's non-negative + - set_eol_delim,unset_eol_delim: now explicitly check whether or not + the delimiter character is non-negativesince it's no longer unsigned + - read_mbchar: make sure to cast the char read to unsigned before + comparing it against the delim + Report and patch from Grisha Levit + + 8/15 + ---- +include/shmbchar.h,lib/sh/shmbchar.c + - is_basic: update test for IS_BASIC_ASCII to include $, @, and `, + which ISO C guarantees to be single-byte + - is_basic_table: update bitmap to include new characters + + 8/21 + ---- +shell.c + - main: make sure to set read_but_dont_execute (-n) to 0 in an + interactive shell in case it was set at invocation, but not in + cases where it was forced with -i + Report from Milana <94888u@riseup.net> + + 8/22 + ---- +lib/readline/bind.c + - force-meta-prefix: new bindable variable, used to determine whether + to convert a meta character (>= 0x80) to an escape-prefixed key + sequence (using ESC as the meta prefix). If set, do the conversion + unconditionally; if unset, use the value of convert-meta as in + previous bash/readline versions + Suggestion from Reuben Thomas + - _rl_function_of_keyseq_internal: if we encounter a character/byte + with the eighth bit set, use force-meta-prefix to decide whether + to translate it to an escape-prefixed key sequence + - rl_bind_key: if we have a meta character, assume it was generated by + Meta- and honor the setting of force-meta-prefix + - rl_translate_keyseq: if we have \M-, use force-meta-prefix to decide + whether or not to translate it to an escape-prefixed key sequence + +lib/readline/doc/rluser.texi,lib/readline/doc/readline.3,doc/bash.1 + - force-meta-prefix: document new bindable variable and defaults + - convert-meta, enable-meta-key, input-meta, output-meta: update + description with better explanation of Meta key and meta characters, + and locale character encoding + - Key Bindings: expand description of \M- and Meta- modifiers + - Readline Introduction: expand description of the Meta key and the + various things it can do, reference force-meta-prefix and + enable-meta-key + + 8/26 + ---- +doc/bashref.texi + - case: add process substitution to the list of expansions for the + word. + Reported by shynur + +execute_cmd.c + - execute_null_command: if an empty simple command (no words, just + redirections) requires a fork, reset top_level and exit if we + longjmp there. This can happen with an expansion error while we + evaluate the redirection. + Report from youheng.lue@gmail.com + - execute_connection: in default mode, bash performs jobs notifications + in an interactive shell between commands separated by ';' or '\n'. + It shouldn't do this in posix mode, since posix now specifies when + notifications can take place + +examples/loadables/{realpath,csv,dsv,cut,stat,kv} + - changes to make them build when arrays are not available + Report from Dennis Clarke + +jobs.c + - notify_and_cleanup: make interactive shells notifying during sourced + scripts dependent on the shell compatibility level and inactive in + versions beyond bash-5.2 + Inspired by report from Zachary Santer + +doc/bashref.texi + - Bash posix mode: note the change with job notifications in command + lists + - Shell compatibility mode: note job notification changes for compat + level > 52 + +parse.y + - CHECK_FOR_RESERVED_WORD: call set_word_top here on the reserved word + token about to be returned; don't worry about trying to set it after + the fact + Report from Collin Funk + + 8/28 + ---- +parse.y + - CHECK_FOR_RESERVED_WORD: change word_top to keep track of the line + number where a compound command begins; call set_word_top on the + current token about to be returned + - read_token_word: call set_word_top if special_case_tokens returns + something; currently used for `{' + - set_word_top: add `{' to the list of compound commands we track + - grammar: every time we parse a group command or equivalent for the + `for' and `select' compound commands, decrement word_top after we + see the `}' + - parse_dparen: set arith_lineno from word_lineno[word_top] since we + now set it for FOR when we read it + + 8/29 + ---- +parse.y + - read_token: don't turn on PST_SUBSHELL after reading a left paren + if the last token was a WORD, since that's a function definition, + not a subshell + - read_token,parse_dparen: don't turn on PST_SUBSHELL if we run into + a left paren while parsing a conditional command (PST_CONDCMD is + set in parser_state) + - set_word_top: add `(' to the tokens saved in word_lineno + - grammar: decrement word_top in the subshell_command production + - read_token,parse_dparen: call set_word_top where we add PST_SUBSHELL + to parser_state + + 8/30 + ---- +parse.y + - set_word_top: add COND_START to the list of tokens that set + word_lineno[word_top] + - grammar: decrement word_top after COND_END + - rename: word_lineno -> compoundcmd_lineno, word_top -> compoundcmd_top, + set_word_top -> set_compoundcmd_top + +lib/readline/signals.c + - _rl_release_sigint: don't check for signals if we're already + handling a received signal + Report from Tycho Kirchner and + Eduardo A. Bustamante López + + 8/31 + ---- +builtins/printf.def + - printf_builtin: when parsing a time specification format, don't + increment the format pointer to check for 'T' unless it points + to a closing right paren, rejecting the format if it's not a `)' + when the loop breaks + Report from Andrey Kovalev + + 9/6 + --- +jobs.c,jobs.h + - notify_and_cleanup: now takes an argument saying which job to notify + about; if arg is -1 it notifies about all jobs as previously + - maybe_print_job_notifications: convenience function to encapsulate + policy about when to call notify_of_job_status in one place; called + by notify_and_cleanup + - notify_of_job_status,maybe_print_job_notifications: now take an int + argument with the same semantics as notify_and_cleanup + - wait_for_any_job: now call notify_of_job_status only on the job we + just retrieved and will return + - wait_for: don't call notify_and_cleanup if posixly_correct unless + the shell is not currently interactive, since posix says we can + notify in a non-interactive shell when a foreground job changes + state + +jobs.c,parse.y,eval.c,execute_cmd.c,builtins/jobs.def,trap.c + - notify_and_cleanup: changed all callers appropriately + +builtins/evalfile.c + - _evalfile: renamed to evalfile_internal + - evalfile_internal: increment and decrement (or unwind-protect) the + value of want_job_notifications; increment it to a non-zero value + if the shell is interactive and the compatibility level is <= 52 + (see change to notify_and_cleanup of 8/26) + +jobs.c + - maybe_print_job_notifications: remove clause testing sourcelevel; + use want_job_notifications for this + + 9/11 + ---- + +[prayers for the victims of 9/11] + + 9/12 + ---- +support/mkdep + - new version from Martin Kealey; modified for inclusion + +Makefile.in + - MKDEP_ variables to be able to control various aspects of `make + depend' + + 9/13 + ---- +configure.ac + - relstatus: update to `beta' + + + 9/16 + ---- +builtins/jobs.def + - jobs_builtin: when listing individial jobs, don't call notify_and_cleanup + (which notifies about outstanding terminated jobs) if the shell is + interactive and in posix mode + + 9/20 + ---- +jobs.c + - wait_for_single_pid: if wait finds a status for the pid argument in + the bgp list, remove it from the bgp list if the shell is in posix + mode + + 9/23 + ---- +execute_cmd.c + - execute_command_internal: if the COMMAND * passed in to execute has + the CMD_INVERT_RETURN flag set, make sure we propagate that to + simple commands, for commands, arith for commands, select commands, + case commands, while/until commands, if commands, group commands, + shell functions, pipelines, subshells, and connections so if set -e + is enabled in the body (or test for if/while/until) its effect is + ignored + - execute_in_subshell: if the subshell's return status is being inverted, + make sure to ignore set -e in the commands the subshell executes + - execute_pipeline: if the pipeline's return status is being inverted, + make sure to ignore the effects of set -e in all pipeline elements + - execute_connection: if the list's return status is being inverted + (tough to do because of precedence), make sure the list commands + ignore the effect of set -e + + 9/24 + ---- +jobs.c + - start_job: don't fetch the tty settings if we're being called from + a readline key binding (bind -x) or programmable completion + From a report by David Moberg + + 9/25 + ---- +jobs.c + - wait_for_any_job: if the jobs table is empty and there are no + eligible procsubs, and the shell is in posix mode, take a random + pid from the bgpids table, delete it, and return its status + (since we would be deleting that pid from bgpids anyway) + + 9/26 + ---- +lib/readline/histexpand.c + - history_tokenize_word: fix off-by-one error (incrementing i one too + many positions after the increment in the loop) preventing words + like `$((expr))' from being tokenized correctly + Report from Milana <94888u@riseup.net> + +config.h.in,configure.ac + - new option: bash-source-fullpath-default: set it to make the + bash_source_fullpath option enabled by default; sets + BASH_SOURCE_FULLPATH_DEFAULT + Based on a patch from konsolebox + +variables.c + - bash_source_fullpath: initialize to BASH_SOURCE_FULLPATH_DEFAULT, + set by configure + +doc/bashref.texi + - --enable-bash-source-default: document + + 9/27 + ---- +doc/bash.1,doc/bashref.texi + - update builtins documenation: make language and paragraph breaks + more consistent between the document formats; update active + language + + 10/1 + ---- +doc/bash.1,doc/bashref.texi,lib/readline/doc/rluser.texi,lib/readline/doc/hsuser.texi + - update more documentation sections to make language consistent + between formats, reduce passive voice + + 10/7 + ---- +lib/readline/doc/history.3 + - update history expansion section to be consistent with hsuser.texi + and bash.1 + +doc/bash.1,doc/bashref.texi,lib/readline/doc/rluser.texi,lib/readline/doc/readline.3 +lib/readline/doc/hsuser.texi,lib/readline/doc/history.3 + - next set of updates for consistency between formats, update language, + fix formatting conventions + + 10/11 + ----- +lib/readline/doc/rltech.texi,lib/readline/doc/hstech.texi + - next set of updates for consistency between formats, update language, + fix formatting conventions + + 10/12 + ----- +Makefile.in,builtins/Makefile.in + - update dependencies on readline, history include files + +builtins/shopt.def + - update bash_source_fullpath reset to use new default + +configure.ac + - update to use the right option name for bash-source-fullpath-default + Report and patch from Grisha Levit + +braces.c + - mkseq: fix loop condition to avoid integer overflow + Report and patch from Grisha Levit + +builtins/help.def + - show_desc: don't assume that long_doc[0] ends with a newline, + just add one manually when we hit a newline or NULL + Report and patch from Grisha Levit + +builtins/read.def + - read_builtin: don't check the timeout after breaking out of the + character read loop unless we didn't read anything (i == 0) and + the last read return EOF or error + - read_builtin: move check_read_timeout call to the end of the read + loop, after we check for the delimiter and whether or not we've + read the right number of characters, so we always return any + valid data + Report from Thomas Oettli + + 10/14 + ----- +jobs.c + - wait_for_any_job: in posix mode, take any terminated pid from bgpids + before waiting for a running job to terminate + Inspired by report from Zachary Santer + + 10/14 + ----- +doc/bash.1,doc/bashref.texi + - next set of updates for consistency between formats, update language, + fix formatting conventions (job control section) + +doc/bash.1,doc/bashref.texi,lib/readline/doc/readline.3,lib/readline/doc/rluser.texi + - minor wording updates and typo fixes from + G. Branden Robinson + + 10/15 + ----- +doc/bash.1,doc/bashref.texi,lib/readline/doc/readline.3,lib/readline/doc/rluser.texi + - wording/formatting updates and typo fixes from + G. Branden Robinson + +doc/bash.1 + - update .FN macro, use it consistently for filenames, like @file{} + +doc/bashref.texi + - make sure to use @dots and @file consistently + +doc/bash.1,lib/readline/doc/readline.3 + - make sure `readline' is typeset consistently + + 10/18 + ----- +sig.c + - fix minix typo + +lib/readline/history.c + - history_do_write: for portability, make sure that the offset argument + to mmap is page-aligned, since some systems (linux, macos) require it. + Report and patch from Grisha Levit + +lib/readline/util.c + - rl_tilde_expand: rearrange code to do bounds checking before data + validation when finding the end of the tilde-word to avoid + touching uninitialized data + Report and patch from Grisha Levit + + 10/20 + ----- +doc/bash.1,doc/bashref.texi + - update word splitting section to add what IFS whitespace means and + how word splitting uses it. Based on a bug-bash discussion + + 10/21 + ----- +lib/readline/colors.c +doc/bash.1,lib/readline/doc/readline.3,lib/readline/doc/rluser.texi + - RL_COLOR_PREFIX_EXTENSION: remove the leading `.' again; this was + the result of a misunderstanding about how `dircolors' works + Report from Daniël Gerbrand Haasbroek + +lib/readline/isearch.c + - _rl_isearch_dispatch: when adding the character to the search + string, insert it as a single byte in the C locale (or if we're + not doing multibyte characters) + Report and patch from Grisha Levit + + 10/23 + ----- +doc/bash.1,doc/bashref.texi + - SIGNALS: update section to make it clear how job control affects + SIGINT receipt and the behavior of the shell when it's waiting + for a command that receives one. + From a suggestion by Simone Robinson + +builtins/common.c + - get_job_spec: warn about deprecated notation if the job spec doesn't + have a leading `%'; code to return BAD_JOBSPEC tagged for bash-5.4 + - sh_invalidjob: new convenience function to print error for invalid + job specifications + +builtins/jobs.def, builtins/ kill.def, builtins/ wait.def, builtins/fg_bg.def + - handle BAD_JOBSPEC return from get_job_spec; call sh_invalidjob. + Nothing returns that yet. + +builtins/kill.def + - kill_builtin: change to use common error message via sh_badpid() if + we get an argument where the first character is not a digit or `%' + +builtins/jobs.def + - jobs_builtin: check for INVALID_JOB return from get_job_spec to + avoid call to get_job_by_jid + + 10/24 + ----- +error.c, error.h + - err_invalidid: common error function for invalid identifiers; + changed callers in execute_cmd.c, general.c + +general.c + - valid_function_word: separated posix check against special builtin + names (flags&4) and posix check for valid identifiers (flags&1); + callers need to differentiate. This means that posix mode does not + require function names to be valid identifiers + +execute_cmd.c + - execute_intern_function: don't call valid_function_word with + (flags&1) in posix mode unless POSIX_RESTRICT_FUNCNAME is defined; + call with flags&4 to keep the check against special builtin names + +print_cmd.c + - print_function_def,named_function_string: don't print functions + with names that are invalid identifiers with a leading `function' + +config-top.h + - POSIX_RESTRICT_FUNCNAME: placeholder, not defined by default + +doc/bashref.texi + - Posix mode: remove item about function names being valid shell + identifiers + + 10/25 + ----- +aclocal.m4 + - simplify the checks for the various members of struct dirent + Report and patch from Grisha Levit + +m4/strtoimax.m4 + - simplify and remove redundant caching and cache check + Report and patch from Grisha Levit + +builtins/common.c + - get_exitstat: make the behavior of exit with no arguments + running in a trap action the same as return: check for any trap + (running_trap > 0) in the current execution_context. This is + POSIX interp 1602, in POSIX.1-2024 + +stringlib.c + - find_token_in_alist: if FLAGS is non-zero, do *not* allocate new + memory for the token. The existing behavior is to allocate memory + and return a copy of the token, and all callers pass 0 + +parse.y + - compoundcmd_lineno: now an array of `struct tokeninfo', which + has line number and current compound command information + - change compoundcmd_lineno[compoundcmd_top] to + compoundcmd_lineno[compoundcmd_top].lineno in all calls + - set_compoundcmd_top: in addition to assigning line number info, + assign T to compoundcmd_lineno[compoundcmd_top].token + - report_syntax_error: if we get a syntax error while looking for + shell_eof_token (comsubs), include the token we were looking for + in the error message + - report_syntax_error: if we are reporting an unexpected EOF error, + and compoundcmd_top >= 0, look up the token for the compound + command we're parsing, including `(', and change the error message + to include it + + 10/26 + ----- +Makefile.in + - PURIFY,GLOBC,GLOBO,ALLOC_FILES,LIBRARY_SOURCE: remove + - ADDON_CFLAGS,ADDON_LDDFLAGS: initialize to empty + - GRAM_H: remove from HSOURCES + - profiling-tests: use Program instead of PROGRAM + +builtins/Makefile.in + - DEBUG: initialize from configure + - SYSTEM_FLAGS: remove, since it's not passed from topdir Makefile + - ADDON_CFLAGS: initialize to empty + +lib/glob/Makefile.in + - ADDON_CFLAGS: initialize to empty + +lib/readline/Makefile.in + - ADDON_CFLAGS: initialize to empty + - APP_CFLAGS: remove + +lib/sh/Makefile.in + - DEBUG: initialize from configure + - ADDON_CFLAGS: initialize to empty + - LIBOBJDIR: initialize to empty; configure uses it in LIBOBJS + +lib/tilde/Makefile.in + - ADDON_CFLAGS: initialize to empty + - CCFLAGS: add ADDON_CFLAGS, replacing ASAN_CFLAGS + +support/Makefile.in + - SYSTEM_FLAGS: remove, since it's not passed from topdir Makefile + + Makefiles report and patch from Grisha Levit + +version.c,shell.h + - default_compatibility_level: int variable, initialized to + DEFAULT_COMPAT_LEVEL like shell_compatibility_level + +variables.c + - sv_shcompat: use default_compatibility_level instead of + DEFAULT_COMPAT_LEVEL so variables.o doesn't have to depend on + version.h + +builtins/shopt.def + - set_compatibility_level: use default_compatibility_level instead + of DEFAULT_COMPAT_LEVEL so shopt.o doesn't have to depend on + version.h + - don't include version.h any more + +configure.ac,Makefile.in,support/Makefile.in,doc/Makefile.in + - remove some unused variables: BASE_CFLAGS_FOR_BUILD, DEBUGGER_DIR, + INTLOBJS, TEXINDEX, TEX, MALLOC, SIGNAMES_SUPPORT + From a report by Martin D Kealey + + 10/28 + ----- +builtins/exec.def + - exec_builtin: don't try to print an error message in the cases + where shell_execve prints one, in case we have execfail set + Report from Emanuele Torre + +Makefile.in + - LIBRARY_SOURCE: add back in to tags targets, add definition + Suggestion from Mike Jonkmans + + 10/31 + ----- +lib/readline/search.c + - make_history_line_current: change to use the same strategy to move + to a history line as incremental search: one or more calls to + rl_get_{next,previous}_history + - dispose_saved_search_line: remove + - noninc_dosearch: no longer need to call _rl_unsave_saved_search_line + or dispose_saved_search_line; use new calling convention for + make_history_line_current + - _rl_nsearch_init: don't need to call _rl_maybe_replace_line, wait + until we move to the history line + - _rl_nsearch_dosearch: free the undo list unconditionally, since we + are committed to using the contents of rl_line_buffer as the search + string + - _rl_nsearch_dosearch: if we abort because of no search string, call + _rl_unsave_saved_search_line and let the caller clean up + - _rl_nsearch_dosearch: if the search fails, reset rl_point to the + saved point, since we will be restoring the old line + - rl_history_search_internal: don't bother to save and restore the + search line, since we don't use rl_line_buffer for anything + - rl_history_search_internal: use new calling convention for + make_history_line_current + - all these changes unify the incremental and non-incremental search + implementations + +lib/readline/readline.c + - rl_initialize: reset rl_eof_found to 0 at the same time we reset + the EOF state + Report and fix from Andrew Burgess (GDB) + + 11/6 + ---- +lib/readline/display.c + - rl_redisplay: if we changed screen lines during the redisplay and + we need to return to the line with the cursor, make sure to account + for differing numbers of invisible characters in the two lines + - rl_redisplay: if we need to redisplay the prompt because we moved + into a portion of it containing invisible characters while moving + to the line containing the cursor, make sure to account for the + cursor being on a line other than 0 and the prompt wrapping lines. + If it wraps, we only want to redisplay the portion after the line + wrap before the line the cursor is on + Fix for C locale issues reported by Grisha Levit + + 11/7 + ---- +lib/termcap/termcap.c + - tgetent: fix small memory leak on file open error + +Makefile.in + - y.tab.h: move from CREATED_HEADERS to INSTALLED_HEADERS so we don't + clean it + - maybe-clean: slightly change the syntax of the recipe + +doc/Makefile.in + - PSFILES: split into CREATED_PS and ps files from the distro + so we just remove CREATED_PS in maintainer-clean target + - PDFFILES: split into CREATED_PDF and ps files from the distro + so we just remove CREATED_PDF in maintainer-clean targets + - clean,mostlyclean: swap + - mostlyclean: don't remove Makefile + - maybe-clean: use realpath equivalent like in top-level Makefile.in + Report from Mike Jonkmans + + 11/11 + ----- +Makefile.in,doc/Makefile.in,lib/glob/Makefile.in,lib/readline/Makefile.in +lib/malloc/Makefile.in.,lib/tilde/Makefile.in + - mostlyclean: swap with clean where appropriate + - add .PHONY target for clean targets where appropriate + +Makefile.in,configure.ac + - STDCKDINT_H: variable for possibly-created file stdckdint.h, for + dependencies; add dependencies where appropriate + +Makefile.in,doc/Makefile.in + - add various gnu-standard install targets that do nothing + + 11/14 + ----- +CHANGES,NEWS + - updated for bash-5.3-beta + + 11/15 + ----- +lib/sh/snprintf.c + - wchars: fix small memory leak by freeing lbuf if wcrtomb fails + Report from SerGoGubarev + +lib/readline/complete.c + - vector_len: an inline convenience function to return the length + of an array of strings; callers are remove_duplicate_matches, + rl_old_menu_complete, rl_menu_complete + - rl_complete_internal: add `$' as a value for what_to_do that + exports a (possibly null) list of possible completions to an + application or another process by writing them, using a specific + protocol, to rl_outstream + - rl_export_completions: bindable command to perform word completion + and write the results, with other information, to rl_outstream + - _rl_export_completions: workhorse function to export the completions + Based on a patch from Matthew Tromp , + original request from Spencer Baugh back in 11/23 + +lib/readline/readline.h + - rl_export_completions: extern declaration + +lib/readline/funmap.c + - export-completions: new bindable command name + +doc/bash.1,lib/readline/doc/readline.3,lib/readline/doc/rluser.texi + - export-completions: document, including output format + + 11/19 + ----- +Makefile.in + - HYBRID_HEADERS: new variable containing header files that may appear + in the build directory or the source directory + - maybe-install-headers: rule to install header files that may appear + in the build directory or a subdirectory of it; install-headers + depends on it + - uninstall-headers: remove $(HYBRID_HEADERS); fix typo in recipe + + 11/21 + ----- +builtins/printf.def + - chk_converror: inline function to use for single place to check + for numeric overflow, change callers to use it + + 11/25 + ----- +doc/bash.1,doc/bashref.texi + - minor updates to the section on bracket expressions in pattern + matching + +builtins/command.def + - update -v help string to indicate that the output is a single word + Report from Andrew Davis + + 11/26 + ----- +builtins/printf.def + - chk_converr: add check for no characters being converted at all, + print same warning message as if *ep != 0. This covers the case of + an empty string argument. + Report by Paul Eggert + +Makefile.in,doc/Makefile.in + - uninstall: make sure the bash-specific directories created by + `make install' are emptied and removed + + 11/27 + ----- +doc/bash.1,doc/bashref.texi +lib/readline/doc/readline.3,lib/readline/doc/history.3 +lib/readline/doc/rluser.texi,lib/readline/doc/rltech.texi + - another set of updates for formatting consistency, language + consistency between man pages and info files + + 12/1 + ---- +lib/readline/misc.c + - rl_get_previous_history: call _rl_maybe_replace_line with arg of 1 + so it clears rl_undo_list, since this may not immediately replace + rl_undo_list with something from history + Report from Grisha Levit + + 12/5 + ---- +doc/bash.1,doc/bashref.texi +lib/readline/doc/rluser.texi + - updates for active voice, future tense, formatting and fonts, edits + to Programmable Completion + Suggestions from G. Branden Robinson + + 12/10 + ----- +lib/readline/complete.c + - fnprint: make sure _rl_completion_prefix_display_length and + _rl_colored_completion_prefix are mutually exclusive, since the + callers assume they are. + +bashline.c + - bash_default_completion: if we're trying to complete a glob pattern, + and rl_completion_type is '?', tell readline not to append a slash + if the pattern ends in one. + +doc/bash.1,lib/readline/doc/readline.3,lib/readline/doc/rluser.texi + - completion-prefix-display-length: note that readline uses `___' + instead of an ellipsis if the filename begins with a period + All reported by Frederick Abell + +doc/bash.1,doc/bashref.texi + - PIPESTATUS: enumerate the commands that set PIPESTATUS + From a report by Ulrich Müller + +lib/readline/isearch.c + - _rl_isearch_init: change to call _rl_maybe_replace_line with arg + of 1 so rl_undo_list gets cleared (see change from 12/1) + Report from Grisha Levit + + 12/13 + ----- +CHANGES,NEWS + - updated for bash-5.3-beta + + 12/15 + ----- +lib/readline/histexpand.c + - get_history_event: make sure we don't change history_offset whether + the search succeeds or fails, don't set it to history_length. + Callers don't expect to have the history offset changed out from + under them. + Fixes bug reported by Grisha Levit + + 12/16 + ----- +lib/readline/util.c + - _rl_abort_internal: make sure to clear _rl_command_to_execute + Report and patch from Grisha Levit + +tests/printf7.sub,tests/cond-regexp2.sub + - accommodate different error messages across different systems + + 1/2/2025 + -------- +tests/run-all, tests/run-minimal + - BASHOPTS: unset or unexport as appropriate, same as SHELLOPTS + From a report by Martin D Kealey + + 1/9 + --- +subst.c + - string_extract_verbatim: take into account the fact that CTLESC can + quote multibyte characters; use ADVANCE_CHAR instead of increment + Fixes bug reported by jktseug@gmail.com + + 1/10 + ---- +expr.c + - expr_bind_variable,expr_streval: suppress additional expansion if + called by the `let' builtin, whether or not array_expand_once is set + - expr_skipsubscript: suppress expansion while parsing subscripts + whether array_expand_once is set or not + Still have to change tests if this goes final + These are all conditional on shell_compatibility_level > 51 + From a bug-bash post by Greg Wooledge + + 1/14 + ---- +lib/readline/complete.c + - _rl_export_completions: use print_filename instead of fprintf to + display the possible completions so slashes and file types can + be included + From a patch from Matthew Tromp + + 1/15 + ---- +examples/loadables/fltexpr.c + - fltexpr: new loadable builtin to do floating-point arithmetic + expression evaluation and optionally print the result + + 1/16 + ---- +builtins/printf.def + - getarg(), advancearg(): cosmetic changes to make it easier to + implement %N$ format specifiers in the future + + 1/18 + ---- +subst.c + - array_length_reference: requesting the length of an element of an + unset variable using array syntax is a fatal error when `set -u' + is enabled and the subscript is not `@' or `*'. + Inspired by a report from Ian Kelling + + 1/20 + ---- +parse.y + - decode_prompt_string: since Debian has made the spectaculary bad call + to allow arbitrary characters in usernames, protect the results of + the \u expansion in the same way as \[Ww] and \[Hh] (externally- + controlled data) + From https://savannah.gnu.org/patch/?10496 + + 1/21 + ---- +eval.c + - reader_loop: if we longjmp with ERREXIT, don't reset any local + function contexts in posix mode, since POSIX says to exit as if + executing the `exit builtin with no arguments'. Revision of change + from 7/2022. + From a report by Ivan Shapovalov in 11/2024 + +lib/readline/display.c + - rl_redisplay: after calling update_line, when putting the cursor + where it needs to be and reprinting part of the line with the + prompt that contains invisible characters, make sure we start to + output characters at the portion in the prompt buffer that begins + on the current line and only offset by the number of invisible + characters on the current line, and set _rl_last_c_pos accordingly + in both multibyte and singlebyte locales. + Fixes bug reported by Andreas Schwab + + 1/22 + ---- +execute_cmd.c + - execute_builtin_or_function: if we're executing the exec builtin, + and there are redirections, let exec_builtin handle disposing of + redirection_undo_list if there is no program name to execute, so + it's still there if exec returns and doesn't exit the shell. + Then we can manage disposing of exec_redirection_undo_list and + letting the redirections be undone as normal. + This is POSIX interp 1896, with modifications from + https://www.austingroupbugs.net/view.php?id=1896#c7037 + +builtins/exec.def + - exec_builtin: dispose of redirection_undo_list and set it to NULL + if there is no program name operand; let execute_builtin_or_function + clean it up + + 1/23 + ---- +lib/readline/terminal.c + - _rl_tcgetwinsize,_rl_tcsetwinsize: function wrappers for tcgetwinsize/ + tcsetwinsize with fallbacks to ioctl if those functions aren't + available + - _rl_get_screensize: use _rl_tcgetwinsize + +lib/readline/rlwinsize.h + - _rl_tcgetwinsize,_rl_tcsetwinsize: extern function declarations + +lib/readine/rltty.c + - set_winsize: use _rl_tcgetwinsize/_rl_tcsetwinsize + - set_winsize: if _rl_tcgetwinsize succeeds, use the values to set + readline's idea of the screen size via _rl_set_screen_size + Inspired by a discussion with Olav Mørkrid + + 1/24 + ---- +lib/readline/signals.c + - _rl_handling_signal: new private variable, set to the signal we're + currently handling in _rl_signal_handler (SIGWINCH) or + _rl_handle_signal (all others). Only valid if RL_STATE_SIGHANDLER + is set + +lib/readline/rlprivate.h + - _rl_handling_signal: new extern declaration + +lib/readline/rltty.c + - set_winsize: only set readline's idea of the screen size if we're + executing in a signal handler context and handling SIGTSTP and the + application has indicated that it doesn't want the environment + variables LINES and COLUMNS to have priority (rl_prefer_env_winsize) + + 1/30 + ---- +jobs.c + - wait_for_single_pid: if wait_for returns -1/ECHILD, make sure to + return 257 just as if the child was not found, optionally printing + an error message if JWAIT_PERROR is supplied + From a discussion with Ian + + 2/8 + --- +redir.c + - do_redirection_internal: keep track of whether the redirector fd + was active with a new variable. Not used yet, should be optimized + out. + - add_undo_fd_redirect: new undo function using r_move_input so we + don't need a dup redir and a separate close redir to undo. Not + used yet + - do_redirection_internal: only call check_bash_input if we're + creating an undo list and not running one + +command.h + - OUTPUT_REDIRECT: add r_output_force + +input.c + - check_bash_input: if we dup the bash input fd to another in + save_bash_input, return that fd. Continue to return -1 on error + and 0 if we don't do anything but sync + +execute_cmd.c + - execute_null_command: force a subshell if any of the redirections + involve the bash input buffered fd. + From a report by Martin D Kealey + + 2/10 + ---- + +examples/loadables/chmod.c + - chmod: new loadable builtin, inspired by zhixu.liu@gmail.com in + https://savannah.gnu.org/patch/?10499 + + 2/11 + ---- +builtins/kill.def + - kill_builtin: in posix mode, return a failure status if any of the + pid/job arguments are not found or sending the signal fails. This + is consistent with + https://pubs.opengroup.org/onlinepubs/9799919799/utilities/kill.html#tag_20_64_14 + + 2/12 + ---- +braces.c + - brace_gobbler: take a new argument in which to return the type of + brace expansion (comma or sequence) we think we've found; change + all callers + - brace_expand: even if we find a BRACE_ARG_SEPARATOR, don't try to + perform expansion if brace_gobbler doesn't think we have a + BRACE_COMMA expansion + - valid_seqterm: new function, performs minimal validation on a + sequence expansion, used to skip over invalid sequence expressions + in brace_expand + - brace_expand: call valid_seqterm if brace_gobbler finds a BRACE_SEQ + expansion + Inspired by report from Robert Elz + + 2/13 + ---- +doc/bash.1,doc/bashref.texi + - clarified the handling of double quotes in EXPRESSION in + (( EXPRESSION )) and $(( EXPRESSION )) to say that only unescaped + double quotes are removed + +expr.c + - expr_bind_variable,expr_streval: revert change from 1/10 that + suppresses additional expansion when called by the `let' builtin, + tag for possible inclusion in a future release when I can look + at parallel changes to ((...)) and $((...)) (and probably + declare 'a[" "]=12' or similar) + + 2/14 + ---- + +lib/sh/zmapfd.c,externs.h + - zmapfd: now returns ssize_t in case of large files when size_t is + larger than int + +builtins/evalfile.c,builtins/help.def + - zmapfd: changed callers + +print_cmd.c + - print_redirection: the default file descriptor for <> is 0 + Report and fix from Emanuele Torre + + 2/18 + ---- +configure.ac + - check for d_type member of struct dirent for future use + + 2/24 + ---- +doc/bash.1,doc/bashref.texi + - document the word expansions performed on indexed array subscripts + and assoc array keys + - document the possibility and effect of empty strings on arithmetic + evaluation for substring expansion, arithmetic expansion, operands + to the the [[ command's arithmetic operators, the expression in + the (( compound command, and indexed array subscripts + + 2/24 + ---- +execute_cmd.c + - execute_command_internal: if executing a (...) subshell, make sure + to update BASH_COMMAND before exiting on an error return from the + subshell with -e set + Report from Max Bowsher + + 3/3 + --- +redir.c + - here_document_to_fd: if we are trying to use a pipe for a here + document, but the F_GETPIPE_SZ fcntl returns a value shorter than + the here document length, make sure to close the pipe file descriptors + +builtins/ulimit.def + - pipesize: use pathconf and _PC_PIPE_BUF if available + + 3/8 + --- +braces.c + - brace_expand: make sure to call valid_seqterm with the right length + so that text[tlen] == '}' + + 3/10 + ---- +builtins/help.def + - show_manpage: if the first line of long_doc doesn't contain a + newline, e.g., if it's a loadable builtin, add one so there's the + usual space between NAME and SYNOPSIS + +m4/codeset.m4 + - define HAVE_NL_LANGINFO + +lib/sh/strftime.c + - updates for locale-awareness + + 3/14 + ---- +lib/termcap/termcap.c,lib/termcap/tparam.c + - updates for ISO C + + 3/17 + ---- +configure.ac + - update release to rc1, update CHANGES and NEWS + + 3/19 + ---- +lib/readline/rlmbutil.h + - _rl_wcwidth: make sure wchar_t constants have an `L' prefix + + 3/24 + ---- +subst.c + - function_substitute: set temporary_env to NULL (we've already + set up an unwind-protect for it) before pushing the context, so + pop_context doesn't free it out from underneath the caller. + Report from Emanuele Torre + + 3/27 + ---- +shell.c + - set_bash_input: if the call to with_input_from_buffered_stream does + not result in a valid buffer corresponding to the file descriptor, + print an error message and set last_command_exit_value + From a report in https://savannah.gnu.org/patch/?10512 + + 4/3 + --- +lib/sh/gettimeofday.c + - updated from version in gnulib + +[bash-5.3-rc1 frozen] + + 4/4 + --- +examples/loadables/fltexpr.c + - add support for function calls; support almost all math function + calls in math.h + - add support for pi, gamma, e mathematical constants + + 4/7 + --- +doc/bash.1,doc/bashref.texi + - HISTFILESIZE: note that the history file will contain complete + history entries whose lines may total slightly more than + $HISTFILESIZE if the entries contain multiple lines + From a report from Jens Schmidt + - export: note that you can use -f with -p to display exported functions + From a report from Duncan Roe + +builtins/history.def + - add history -d start-end to the long doc + From a report from Duncan Roe + + 4/9 + --- +lib/readline/histfile.c + - read_history_range: changes to not skip blank lines if we are + reading a history file with multiline history entries. + From a report by Jens Schmidt + + 4/11 + ---- +bashline.c + - attempt_shell_completion: move the check for char_is_quoted from + check_redir to the caller, set in_command_position to 0 if the + command separator is quoted + From https://savannah.gnu.org/support/?111224 david@mandelberg.org + - check_extglob: break check for extended glob out into separate + function, call from attempted_shell_completion, set in_command_position + to -1 if it returns 1, as with the old call to check_redir + + 4/21 + ---- +builtins/read.def + - read_mbchar: if we read a delimiter character that makes an + incomplete multibyte character into an invalid multibyte character, + only push the delimiter back if we read that character ourselves + (i > 1). + Report from Greg Wooledge + + 4/23 + ---- +parse.y + - pop_delimiter: only decrement delimiter_depth if it's > 0, since + reset_parser() may have set it to 0 after the matching call to + push_delimiter + Report from Grisha Levit based on a report + from Александр Ушаков + + 4/25 + ---- +parse.y + - read_a_line: if the shell is interactive, and not reading from a + string, check whether a previous call to shell_getc has set + EOF_Reached and return EOF in this case, after resetting the + current token to '\n'. This makes EOFs that are not the first + character on the line `sticky' instead of just token delimiters. + From https://savannah.gnu.org/bugs/?67045 + - history_delimiting_chars: if it looks like we just finished a + subshell, and the line we're adding begins with an operator that + can't follow a semicolon, return a newline + From https://savannah.gnu.org/patch/?10517 + + 4/28 + ---- +parse.y + - parse_arith_command: if the character after the first right paren + isn't a right paren, making the construct a nested subshell, push + that character back and return the subshell command as the current + token string, which we push onto the pushed string list. Reading + one character more can cause synchronization problems with backslash + newline, among other things. + From https://savannah.gnu.org/patch/?10517 + + 4/29 + ---- +builtins/evalstring.c + - parse_string: only run the top-level unwind-protects if we're + actually going to be calling jump_to_top_level(); otherwise let + xparse_dolparen take care of it + From a report by Александр Ушаков + + 5/1 + --- +lib/sh/zread.c + - zungetc: rework to use a local 16-byte buffer so we can push back + multiple characters whether we use read or zread + - zread/zreadretry/zreadintr/zreadc/zreadcintr/zreadn: changed to use + zpopbuf to check whether we have pushed back bytes + - zreset,zsyncfd: reset the pushback buffer indices + +builtins/read.def + - read_mbchar: handle the delimiter being part of an invalid multibyte + character, not just the byte that makes the multibyte character + invalid: keep track of where the delimiter char is in the buffer and + use zungetc to push back that character and everything we read + after it so subsequent buffered (zread) or unbuffered (read) reads + will return them + + 5/2 + --- +lib/readline/display.c,lib/readline/histexpand.c,lib/readline/history.c, +lib/readline/input.c,lib/readline/search.c,lib/readline/shell.c, +lib/readline/util.c,lib/readline/readline.c,lib/readline/histfile.c + - fixes for issues (unused variables, etc.) uncovered by static + analysis + All from a report by Siteshwar Vashisht + + 5/16 + ---- +lib/readline/terminal.c + - NEED_EXTERN_PC: add __gnu_hurd__ to the systems that require this + if not using ncurses; rework the structure of the defines + Report from Collin Funk + +braces.c + - brace_gobbler: don't mark an expression as BRACE_SEQ if we've + already seen a comma and marked it as BRACE_COMMA, so we treat + it as a comma brace expansion. + From a report by Sam James + +support/install-sh + - new version from coreutils-git (2024-12-03.03); renamed from install.sh + +aclocal.m4 + - AM_PROG_INSTALL_SH, AM_PROG_INSTALL_STRIP: added from automake + +configure.ac + - call AM_PROG_INSTALL_SH, AM_PROG_INSTALL_STRIP + +Makefile.in + - STRIP: let configure substitute it from AC_CHECK_TOOL result + - INSTALL_STRIP_PROGRAM: let configure substitute it from + AM_PROG_INSTALL_STRIP + - install-strip: change to set INSTALL_PROGRAM=${INSTALL_STRIP_PROGRAM} + to avoid hard-coding `-s' in the recipe + All from a report by NR + + 5/18 + ---- +subst.c + - param_expand: if we expand a nameref that references an unset array + variable reference, make sure we enforce `nounset', with the usual + exceptions for `@' and `*' subscripts + From a report from Emanuele Torre + + 5/22 + ---- +buildconf.h.in + - add additional defines for conservative ISO C/POSIX environment + - add HAVE_C_BOOL define in case someone cross-compiles with a C23 + compiler + From a report by Bruce Dubbs + +builtins/mkbuiltins.c + - include buildconf.h instead of having separate defines when + cross-compiling + + 6/11 + ---- +lib/readline/terminal.c + - rework change from 5/16 to add __gnu_hurd__ to the list of systems + that don't need extern PC/UP/BC + Reported by Joel Ebel as a static link failure + due to multiply-defined symbols + + 6/12 + ---- +general.c + - valid_function_word: back out change from 2/4/2023 that allowed + quoted characters in function names. + Inspired by discussion with Robert Elz and + Koichi Murase + +parse.y + - read_token_word: set dollar_present if we see <( or >), backing + out change from 2/4/2023 diff --git a/CWRU/misc/open-files.c b/CWRU/misc/open-files.c index 6a5557769..67440de4d 100644 --- a/CWRU/misc/open-files.c +++ b/CWRU/misc/open-files.c @@ -27,6 +27,7 @@ #include +int main() { register int i; diff --git a/CWRU/misc/sigs.c b/CWRU/misc/sigs.c index bae93f8ad..c575de90f 100644 --- a/CWRU/misc/sigs.c +++ b/CWRU/misc/sigs.c @@ -20,16 +20,16 @@ #include #include +#include extern const char * const sys_siglist[]; typedef void sighandler(); -main(argc, argv) -int argc; -char **argv; +int +main(int argc, char **argv) { - register int i; + int i; sighandler *h; for (i = 1; i < NSIG; i++) { diff --git a/CWRU/misc/sigstat.c b/CWRU/misc/sigstat.c index 9135baa4a..41ed361e1 100644 --- a/CWRU/misc/sigstat.c +++ b/CWRU/misc/sigstat.c @@ -26,14 +26,18 @@ #include #include #include +#include +#include +#include -extern char *strrchr(); static char *signames[NSIG]; char *progname; -void sigstat(); +void sigstat(int); +void init_signames(void); +int main(argc, argv) int argc; char **argv; @@ -83,6 +87,7 @@ int sig; printf("%s: signal is trapped (?)\n", signame); } +void init_signames() { register int i; diff --git a/ChangeLog b/ChangeLog index da6d4aa1c..a868dc5c5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,3 @@ - 12/6/2020 --------- @@ -3950,3 +3949,7342 @@ lib/readline/history.c 9/23 ---- [bash-5.2 frozen] + + 9/26 + ---- +[bash-5.2 released] + + 9/27 + ---- +mailcheck.c + - time_to_check_mail: don't bother if we're in the middle of readline + completion or command dispatching. + From https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1019462 + +lib/readline/display.c + - rl_forced_update_display: use memset to clear out visible_line + instead of trying to use a loop; line_size is the size. + Report from + +print_cmd.c + - indirection_level_string: use MBRLEN and an initialized mbstate_t + object to avoid altering an internal mbstate_t. + From Koichi Murase + +subst.c + - string_extract_verbatim: use an explicit mbstate_t object and pass + it to MBRLEN and mbrtowc to avoid altering the state that + ADVANCE_CHAR is using. + From Koichi Murase + - setifs: use an explicit mbstate_t object and pass it to MBRLEN so + to avoid altering an internal mbstate_t. + From Koichi Murase + +builtins/printf.def + - asciicode: use an explicit mbstate_t object and pass it to mbrtowc + to avoid using an incorrect internal mbstate_t + From Koichi Murase + +lib/sh/{mbscasecmp,mbscmp}.c + - mbscasecmp,mbscmp: use different mbstate_t objects for the different + strings so they don't affect each others' intermediate mbstate. + From Koichi Murase + + 9/28 + ---- +execute_cmd.c + - execute_command_internal: if executing a (command) subshell, restore + the value of line_number from save_line_number before returning early + due to being a non-terminal pipeline element. + From https://savannah.gnu.org/support/index.php?110714 + + 9/30 + ---- +subst.c + - expand_array_subscript: make sure to pass a non-NULL first argument + to sh_backslash_quote. Report from Emanuele Torre , + patch from Koichi Murase + + 9/30 + ---- +jobs.c + - cleanup_dead_jobs: delete dead foreground jobs we won't notify the + user about (those not killed by a signal or killed by SIGINT/SIGPIPE). + From a report from Koichi Murase + - wait_for_any_job: never return a foreground job, even when requested + by pid, if it's in the jobs list + Report and fix from Koichi Murase + +m4/strtoimax.m4 + - BASH_FUNC_STRTOIMAX: fix logic inversion of result; we should be + replacing the function if the tests show we *don't* have a working + version. Report from Emanuel Haupt + + 10/4 + ---- +lib/readline/nls.c + - _rl_init_locale: cope with setlocale returning NULL, make sure we + set up a default value for LC_CTYPE. Report from + https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1021109 + +lib/readline/{input.c,rlprivate.h} + - fixes for compiling on w64-mingw32 + + 10/5 + ---- +parse.y + - xparse_dolparen: save and restore extended_glob using local_extglob + in the same way that parse_comsub does. Fixes compat issue reported in + https://bugs.gentoo.org/873931 and by Kerin Millar + + 10/6 + ---- +subst.c + - extract_dollar_brace_string: keep a stack of dolbrace_state values + to handle nested expansions. Report from + Antoine + + 10/7 + ---- +builtins/{shopt.def,common.h} + - extglob_flag: new variable to hold the state of the `extglob' option; + initialized to EXTGLOB_DEFAULT like extended_glob + - shopt_set_extglob: new function to set extended_glob to the right + value for the rest of the shell + +parse.y + - reset_parser: set extended_glob to extglob_flag, which is only + changed by shopt, remove global_extglob + - parse_comsub,parse_cond_command,xparse_dolparen: no longer use + global_extglob + +execute_cmd.c + - execute_cond_node: reset extended_glob to the value of extglob_flag, + since we're executing a command here + + 10/8 + ---- +parse.y + - save_dstart: when we set the value of function_dstart, save the old + value in save_dstart (read_token, read_token_word); restore it in + the grammar production after calling make_function_def. This gives + you correct line numbers for one level of function nesting. + Report from Daniel Castro + + 10/10 + ----- +execute_cmd.c + - shell_execve: rearrange code so that we check for a bad interpreter + before printing a generic ENOENT error message. Report from + Kirill Elagin + + 10/12 + ----- +lib/readline/callback.c + - CALLBACK_READ_RETURN: add an inlined call to RL_CHECK_SIGNALS so we + can handle any signals that arrived before we restored the calling + application's signal handlers. From a gdb dicussion with + Simon Marchi + + 10/12 + ----- +variables.c + - pop_var_context: flag an internal error for shell_variables not + pointing to a function context only if we haven't already flushed + all the local contexts and reset variable_context. This can happen + if errexit is enabled and we're going to be exiting the shell, but + we're running unwind-protects on our way out. Report from + Xavier Delaruelle + + 10/13 + ----- +sig.c + - kill_shell: broke the code that resets the signal disposition to the + default and sends a terminating signal to the shell into a separate + function + - termsig_handler: set handling_termsig to terminating_signal and make + it file-scope so other functions know we're handling a terminating + signal and are about to exit, and which signal it is (latter not used + yet) + - termsig_sighandler: if we get a fatal signal while we're handling a + fatal signal, kill ourselves with the second fatal signal immediately. + Fixes issue reported by Andreas Schwab + +execute_cmd.c + - execute_case_command: call CHECK_TERMSIG after the call to strmatch, + since gmatch will return FNM_NOMATCH if there's a pending terminating + signal and we don't want incorrect results + +subst.c + - pat_subst: make sure REP is non-NULL before calling savestring on it. + Report from Justin Wood (Callek) + + 10/14 + ----- +builtins/{shopt.def,common.h} + - expand_aliases: split into a variable that holds the current state + of alias expansion (expand_aliases) and a variable that reflects the + global option value (expalias_flag), make sure expand_aliases is set + appropriately by shopt + +shell.c,execute_cmd.c,general.c + - expand_aliases: make sure expand_aliases and expalias_flag always + agree + +parser.h + - PST_STRING: new parser flag, set when parsing a string to a command + or word list + +parse.y + - reset_parser: if we're parsing a command substitution or a string, + and need to restore expand_aliases, make sure it's set to the value + of expalias_flag. + Fixes SIGINT during interactive command substitution parsing bug + reported by feng xiangjun + - parse_string_to_word_list,parse_string_to_command: make sure to set + PST_STRING in parser_flags since we're resetting expand_aliases + + 10/17 + ----- +print_cmd.c + - print_function_def, named_function_string: if the function doesn't + have any here-documents, unset was_heredoc after printing the + closing brace so we can add a separator if there is another command + following the function definition. Fixes bug with multiple function + definitions and here-documents reported by D630 + - make_command_string_internal: if we're printing a command + substitution, make sure to preserve newlines in the comsub so we + avoid problems with re-parsing function defs or command substitutions + containing multiple compound commands that need to be separated + by newlines, but don't double them up + +parse.y + - P_ARITH: new parse_matched_pair flags value; used to jump to + parse_comsub if we see a $( inside a $(( )), $[ ], or (( )) + - parse_matched_pair,parse_comsub,parse_arith_command,read_token_word: + make sure to call parse_matched_pair with P_ARITH if we're parsing + an arithmetic command or expansion + - parse_matched_pair: if we see $( inside a call with P_ARITH in the + flags argument, jump to parse_dollar_word and call parse_comsub to + parse it. The rest of the steps assume that parse_comsub has + expanded aliases (or not) appropriately. Fixes bug 2 from + https://bugzilla.redhat.com/show_bug.cgi?id=2134307 + + 10/18 + ----- +builtins/evalstring.c + - parse_and_execute: we play tricks in the parser and in command_substitute + to turn expand_aliases on and off depending on the comsub parser + pass and whether or not we're in posix mode. Since this should only + matter for parsing, when we're processing a command substitution, we + set expand_aliases to the global flag value after parsing the + command and before executing it, and restore it if the global flag + value isn't changed during execution. Fixes bug 1 from + https://bugzilla.redhat.com/show_bug.cgi?id=2134307 + +command.h + - PF_BACKQUOTE: new flag value, only used by command_substitute to + differentiate between `` and $() forms. The former does not have + aliases expanded by parse_comsub in posix mode, so needs to expand + them in parse_and_execute like default mode + +subst.c + - command_substitute: don't modify expand_aliases if PF_BACKQUOTE is + included in flags, since aliases haven't been expanded in the + command string (it was run through parse.y:parse_matched_pair()) + - expand_word_internal: pass PF_BACKQUOTE to command_substitute() if + expanding a `` command substitution + + 10/20 + ----- +parse.y + - yylex: return YYUNDEF as current_token if read_token returns < 0. + Fixes parser reset issue reported by Todd Stein + in https://savannah.gnu.org/support/index.php?110745 + +subst.c + - ARITH_EXP_CHARS: chars that are special and trigger expansion in + arithmetic expressions, EXP_CHARS without `<' and `>'. Fixes bug + reported by Glenn Jackman + +execute_cmd.c + - retain_fifos: replace executing_list (which is still present) as the + indicator of whether or not to save and restore the FIFO list around + a call to execute_command_internal/execute_command; it's more + descriptive and can be used elsewhere + - execute_for_command: set retain_fifos so we don't unlink the fifo + list until the for command completes. Fixes issue reported in + https://savannah.gnu.org/support/index.php?110743 + +lib/readline/xmalloc.c + - memory_error_and_abort: add `const' qualifiers to the argument. Fix + from Markus Elfring + + 10/24 + ----- +general.c + - check_binary_file: check the first two lines for NULs if the first + line begins with a `#!'; otherwise check the first. From a discussion + and patch in https://savannah.gnu.org/support/?110744 + (larsh@apache.org) + +parse.y + - parse_matched_pair: set PST_NOERROR if we read to EOF without finding + a closing match and call parser_error; avoids redundant error + message + +lib/sh/uconvert.c + - uconvert: RETURN: if ipart (integer part) is 0, but upart (fractional + part) is non-zero, multiply upart by mult so we don't lose the sign + for values in the range (-1, 0]. From a report by + izabera + +execute_cmd.c + - execute_in_subshell: check for terminating signals before we return + to our caller, which will immediately exit, and before running any + exit trap (since termsig_handler will run any exit trap). Fixes bug + reported by Andrew Neff + + 10/26 + ----- +lib/readline/complete.c + - rl_filename_completion_function: if the application doesn't supply + any directory hook functions, we need to handle the case where we + dequoted users_dirname and also tilde-expanded dirname. We choose + to tilde expand users_dirname rather than call the application + dequoting function again. Report and patch from + Stefan H. Holek + + 10/27 + ----- +execute_cmd.c + - execute_in_subshell: call procsub_clear in addition to clear_fifo_list, + since none of these process substitutions are children of this new + subshell + +jobs.c + - wait_for_background_pids: call procsub_waitpid on the last procsub + created as long as it's the same as $!, then call reap_procsubs to + clean up the procsub list. Don't call procsub_waitall. Report from + Oguz İsmail Uysal + + 10/31 + ----- +expr.c + - expr_streval: explicitly permit `@' and `*' as associative array + subscripts if the shell compatibility level is greater than 51. + Prompted by report from Corey Hickey + +subst.c + - string_list_pos_params, param_expand: make sure that $* is treated + the same as "$*" in here-document bodies that are being expanded. + From https://lists.gnu.org/archive/html/bug-bash/2022-09/msg00002.html + + 11/1 + ---- +lib/readline/readline.c + - readline_internal_char: save and restore the value of _rl_top_level + around our use of setjmp, even though it doesn't matter in most + cases. Report from sparrowhawk996@gmail.com that it causes crashes + in some obscure callback-mode cases + +lib/readline/isearch.c + - _rl_isearch_dispatch: if we end the search and stuff characters back + to be read again, decrement the current key sequence index by 2 so + we don't have duplicate characters in the sequence + +lib/readline/misc.c + - rl_digit_argument: call _rl_del_executing_keyseq after rl_execute_next + + 11/3 + ---- +builtins/setattr.def + - show_localname_attributes: special-case "-" local variable, since + there is no `declare -' equivalent. + Reported by Emanuele Torre . + + 11/4 + ---- +lib/sh/tmpfile.c + - sh_mktmpname,sh_mktmpfd: use get_urandom32() instead of random() if + we're not using mktemp or mkstemp and the system provides the + appropriate support + +trap.c + - trap_variable_context: new variable, set to variable_context every + time a trap string runs (that is, every time running_trap is set to + a value > 0) in _run_trap_internal, run_exit_trap, run_pending_traps + +trap.h + - trap_variable_context: extern declaration + +builtins/common.c + - get_exitstat: if the `return' builtin is running, we are running a + trap (but not the DEBUG trap), and the return would cause the trap + string to complete (variable_context == trap_variable_context, so + we haven't executed another shell function), use the last command + exit value as the return status. POSIX interp 1602, from + https://www.austingroupbugs.net/view.php?id=1602 + + 11/4 + ---- + +lib/readline/display.c + - local_prompt_invis_chars: new array variable, similar to + local_prompt_newlines, that keeps track of the number of invisible + characters on each line of the prompt string. Use in WRAP_OFFSET + macro with eye to using in W_OFFSET as well. Used for the case where + the last line of the prompt is not the last line with invisible + characters. Can use this in more calculations replacing wrap_offset + and prompt_invis_chars_first_line going forward. Inspired by report + from https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1018851 + - update_line: use local_prompt_invis_chars to set _rl_last_c_pos + correctly when on a non-terminal prompt line that contains + invisible characters + + 11/7 + ---- +subst.c + - get_var_and_type: allocate new memory for *valp and return it if the + type is VT_ARRAYMEMBER. The callers -- all of which treat this case + the same as VT_VARIABLE -- will free appropriately. Fixes problems + with using parameter operations like ## on dynamic array variables, + reported by Ivan Kapranov back on 8/31/2022 + +expr.c + - change some error messages to make it clearer these are arithmetic + syntax errors. These will require new translations. + +test.c + - integer_expected_error: change the message to remove `expression', + since this is only called for the `test' builtin, where TEST_ARITHEXP + is not in FLAGS. This will require a new translation. + Reported by Emanuele Torre back on + 6/15/2022 + + 11/10 + ----- +builtins/read.def + - reset_timeout: when a timer expires, make sure to cancel any + readline timeout as well with rl_clear_timeout(). + From https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1023776 + + 11/11 + ----- +builtins/reserved.def + - !: add short help text + +lib/readline/complete.c + - make_quoted_replacement: if readline found quote characters anywhere + in the filename, but is not completing on an unclosed quoted string, + and there is an application filename quoting function, let that + function quote the filename if necessary + +bashline.c + - COMPLETE_DQUOTE2: new completion quoting style define + - bash_expand_filename: new function, runs a filename passed to it + through word expansion, suppressing command and process substitution + and returns the result (in new memory if it's different than the + filename argument) + - bash_quote_filename: if the return value from bash_check_expchar is + `$' or ``', expand the filename and if it contains characters that + should be quoted, set the quoting style to COMPLETE_DQUOTE2 + - bash_quote_filename: if the completion quoting style is COMPLETE_DQUOTE2, + use sh_mkdoublequoted to put double quotes around the entire + unexpanded filename instead of using sh_double_quote, which will + backslash-quote any `$'. This is a start at preserving user-supplied + quotes if the (expanded) completed filename requires them. From + reports by Peng Yu in 5/2020 and + Pedro Gimeno in 6/2021 + + 11/14 + ----- +parse.y + - report_syntax_error: if word_top is set and we reach EOF, report the + starting line number in the error message. From a patch from + L A Walsh and Manuel Reiter + back in 9/2018 + - MAX_CASE_NEST: doubled to 256, renamed to MAX_COMPOUND_NEST + - read_token_word: add `if', `while', and `until' to the set of + compound commands that use WORD_TOP and WORD_LINENO (with + corresponding changes to grammar productions) + - [grammar]: changed check to decrement WORD_TOP to >= 0 since we + start at -1 and we want to decrement back to -1 when all loops are + closed + +builtins/jobs.def + - jobs_builtin: call notify_and_cleanup after displaying the status of + jobs to implement POSIX requirement that `jobs' remove terminated + jobs from the jobs list + https://pubs.opengroup.org/onlinepubs/9699919799/utilities/jobs.html#tag_20_62 + + 11/15 + ----- +lib/sh/input_avail.c + - include signal.h unconditionally, we need it for HAVE_SELECT and + HAVE_PSELECT + - nchars_avail: make sure we declare and use readfds and exceptfds if + we have pselect or select available + +lib/readline/input.c + - rl_gather_tyi,rl_getc: need to declare and use readfds and exceptfds + if HAVE_PSELECT or HAVE_SELECT is set. Report from + Henry Bent , fixes from + Koichi Murase + + 11/16 + ----- +lib/sh/ufuncs.c + - quit.h: include unconditionally for declaration of sigemptyset even + if HAVE_SELECT is not defined + +lib/sh/timers.c + - USEC_PER_SEC: make sure it's defined even if HAVE_SELECT is not + +lib/glob/sm_loop.c + - BRACKMATCH: if an equivalence class does not match, and the next + character following the class is a `]', treat that as the end of + the bracket expression. + Report and fix from Koichi Murase + - GMATCH: if the current character in the string is a `/' and the + current element in the pattern is a bracket expresion, and the FLAGS + include FNM_PATHNAME, return FNM_NOMATCH immediately. A bracket + expression can never match a slash. + Report and fix from Koichi Murase + - BRACKMATCH: if we encounter a in a bracket expression, either + individually or as part of an equivalence class, nullify the bracket + expression and force the `[' to be matched as an ordinary + character + + 11/17 + ----- +lib/glob/sm_loop.c + - BRACKMATCH: if a slash character appears as the first character + after a non-matching character class or equivalence class, treat + the bracket as an ordinary character that must be matched literally + - BRACKMATCH: if a slash character appears as the second character + of a range expression, treat the bracket as an ordinary character + - BRACKMATCH: if a slash character appears in the portion of a + bracket expression that already matched, treat the bracket as an + ordinary character + Updates from Koichi Murase + - BRACKMATCH: if a range expression is incomplete (no end char), + treat the bracket as an ordinary character + + 11/18 + ----- +doc/bashref.texi + - Reporting Bugs: add mention of the Savannah project page. Suggested + by Loïc Yhuel + + 11/20 + ----- +builtins/common.h + - SEVAL_NOOPTIMIZE: new flag for parse_and_execute: means don't try to + optimize forks out of any simple or conditional commands + +builtins/evalstring.c + - parse_and_execute: if FLAGS includes SEVAL_NOOPTIMIZE, don't try to + call can_optimize_connection to optimize away forks from AND_AND or + OR_OR commands + +builtins/eval.def,trap.c,parse.y,jobs.c + - parse_and_execute: include SEVAL_NOOPTIMIZE in any calls to + parse_and_execute. Fixes bug reported by + Frode Nordahl + + 11/21 + ----- +lib/readline/readline.c + - readline_initialize_everything: use xmalloc to initialize + rl_executing_keyseq, since we use xrealloc to reallocate it and + don't check it for NULL anywhere + +subst.c + - parameter_brace_expand_word: make sure to update *ESTATEP and pass + ES back to the caller even if array_value returns NULL. Fixes + memory leak referencing unset associative array elements reported + by Ralf Oehler ; fix from + Koichi Murase + + 11/22 + ----- +lib/glob/sm_loop.c + - BRACKMATCH: if a backslash appears before a slash in a bracket + expression, treat the whole thing as literal and try to match the + open bracket + - BRACKMATCH: if a bracket expression ends in an unquoted backslash, + try to match the left bracket literally and go on. More discussion with + Koichi Murase + +execute_cmd.c + - execute_in_subshell: don't try to optimize away forks in the command + if the subshell command is being timed or its return value is being + inverted. Report from Dabrien 'Dabe' Murphy + + 11/23 + ----- +lib/readline/complete.c + - __WIN32__: remove uses of this preprocessor symbol, use _WIN32 + +lib/readline/rldefs.h + - Don't define NEW_TTY_DRIVER on _WIN32. Fix from + sparrowhawk996@gmail.com + +include/posixselect.h + - include "posixtime.h" instead of so the right guards + are present + +builtins/read.def + - read_builtin_timeout: make sure we don't try to call shtimer_select + if HAVE_SELECT isn't define; it won't be compiled in + +include/stdc.h + - restrict: make sure we have a definition if __STDC__ is not defined + +include/posixtime.h,lib/sh/gettimeofday.c + - gettimeofday: make sure the function signature matches POSIX by + adding `restrict' + + 11/25 + ----- +include/posixselect.h + - don't try to define HAVE_SELECT at all if _WIN32 is defined + +lib/readline/kill.c + - define WIN32_LEAN_AND_MEAN for the windows-specific paste function + +lib/readline/rlprivate.h + - _rl_timeout_select: only include declaration if HAVE_SELECT or + HAVE_PSELECT are defined + + 11/28 + ----- +lib/readline/input.c + - rl_gather_tyi: call rl_input_available_hook after FIONREAD test, + let the application hook into whether or not there are characters + to read + +execute_cmd.c + - execute_function: if the maximum function nesting level is exceeded, + run the unwind-protects before jumping back to top level. Report + from felix + +variables.c + - find_variable_nameref_for_create,find_variable_nameref_for_assignment: + handle find_variable_nameref returning &nameref_maxloop_value, return + NULL and print a warning message in that case + - find_variable_nameref: return &namref_maxloop_value instead of NULL + if the number of resolution cycles exceeds NAMEREF_MAX; change + callers to print a new error message in this case; no other change + in behavior. From a 4/2020 suggestion from Andrej Podzimek + + - find_variable_nameref_context, find_nameref_at_context, + find_variable_last_nameref_context: make sure to return + &nameref_maxloop_value consistently and handle getting it as a + return value from other functions + + 11/29 + ----- +lib/readline/display.c + - _rl_update_final: if there is only one line (_rl_vis_botlin == 0) + and that line is empty (botline_length == 0), assume there is no + prompt and the line has no contents, so output the CR/LF to indicate + that the newline has been read. From a report from + Kevin Pulo + + 11/30 + ----- +builtins/evalstring.c + - parse_and_execute: if we are executing the eval builtin, and the + return status from the command is suppressed (builtin_ignoring_errexit), + set CMD_IGNORE_RETURN in the parsed command's flags. From a report + from Tycho Kirchner + + 12/1 + ---- +lib/glob/sm_loop.c + - PARSE_SUBBRACKET: a reworked PARSE_COLLSYM, generalized to handle + [:, [=, and [. special bracket expressions + - BRACKMATCH: change to use PARSE_SUBBRACKET consistently to parse + [:, [=, and [. special bracket expressions + - PATSCAN: takes new FLAGS arg, changed all callers to just pass the + flags they get through to PATSCAN + - PATSCAN: call PARSE_SUBBRACKET for [:, [=, and [. to treat them + consistently (uses FLAGS argument here) + - PATSCAN: handle FNM_NOESCAPE appearing in FLAGS argument + This set of fixes contributed by Koichi Murase + +lib/glob/{glob,gmisc}.c + - PATSCAN: change all callers to add extra flags arg of 0 + +doc/{bash.1,bashref.texi} + - trap description: replace ARG with ACTION + - clarify the language describing what trap without arguments and + trap -p without arguments display + - clarify that trap in non-interactive shells does not allow signals + that were ignored at shell start to be trapped; interactive shells + allow this + - trap: add missing command types to the description of when the + DEBUG trap is executed + +builtins/trap.def + - LONG_DOC: replace ARG with ACTION + - make it clear that trap and trap -p without arguments display a + information about specified signals, but in a form that may be + reused as shell input + + 12/5 + ---- +pcomplete.c + - compgen_compspec: new flag saying whether or not we're running via + the compgen builtin or via programmable completion: set to 0 + every time gen_progcomp_completions runs, set to 1 in + gen_compspec_completions if this_shell_builtin == compgen_builtin + - gen_shell_function_completions: call rl_clear_signals and + rl_set_signals so the shell's signal handlers are active when + running shell functions to generate completions. We try to do it + only when programmable completion, not the compgen builtin, is active. + Idea from Koichi Murase , fixes bug + reported in 9/22 + +sig.c + - sigint_sighandler, termsig_sighandler: since these can now be called + during programmable completion, we need to set the readline signal + event hook if the readline state includes RL_STATE_DISPATCHING or + RL_STATE_COMPLETING, since we can't rely on RL_STATE_SIGHANDLER + being set and we want to call throw_to_top_level here + - throw_to_top_level: if the shell is interactive, before calling + bashline_reset (which zeroes rl_signal_event_hook), call + rl_cleanup_after_signal if we think readline hasn't called it + already + + 12/9 + ---- +configure.ac + - add "LOCAL_LDFLAGS = -rdynamic" for freebsd/openbsd/netbsd. Reported + by Christian Weisgerber + + 12/12 + ----- +subst.c + - parameter_brace_expand_length: handle namerefs with values that are + valid length expansion expressions but invalid identifiers. From + ed7-aspire4925@hotmail.com via https://savannah.gnu.org/support/?110799 + + 12/13 + ----- +subst.c + - extract_heredoc_dolbrace_string: fix off-by-one error after calling + extract_command_subst and extract_process_subst that caused it to + copy one too many parsed characters. Fix for bug reported by + Norbert Lange + + 12/14 + ----- +execute_cmd.c + - execute_cond_node: if a regular expression fails to compile, print + an error message. Report from Emanuele Torre + back on 6/15/2022 + +trap.c + - trap_variable_context -> trap_return_context, initialize from + funcnest + sourcenest instead of variable_context so we handle + shell function execution and `./source', both of which can use + `return'. Idea from Koichi Murase + +builtins/common.c + - get_exitstat: compare trap_return_context against funcnest+sourcenest, + since that's how it's initialized now + +lib/readline/readline.c + - readline_internal_charloop: if we're not using the callback interface, + don't restore _rl_top_level from olevel, since we will just be going + around the loop again and will potentially need to use it multiple + times. Report from Emanuele Torre + + 12/15 + ----- +shell.h + - EX_UTILERROR: new generic special builtin return status to indicate a + POSIX utility error that should cause a non-interactive shell to abort + +execute_cmd.c + - builtin_status: translate EX_UTILERROR to EXECUTION_FAILURE + +builtins/set.def + - unset_builtin: return EX_UTILERROR if posix_utility_error is set; + set it when trying to unset a non-identifier (variable) or a + non-unsettable or readonly variable + + 12/16 + ----- +subst.c + - de_backslash: now takes a second argument with the current quoting + flags + - de_backslash: if the quoting flags include Q_HERE_DOCUMENT and the + shell is in posix mode, remove backslashes quoting double quotes + +subst.h + - de_backslash: update extern declaration + +lib/readline/histexpand.c + - history_expand_internal,get_history_word_specifier,get_subst_pattern, + hist_error,history_find_word,hist_string_extract_single_quoted: + now take const char * string arguments + +lib/readline/mbutil.c + - _rl_get_char_len,_rl_adjust_point,_rl_find_next_mbchar_internal, + _rl_find_next_mbchar,_rl_find_prev_mbchar,_rl_find_prev_mbchar_internal, + _rl_test_nonzero,_rl_find_prev_utf8char,_rl_is_mbchar_matched, + _rl_compare_chars,_rl_char_value: take const char * string arguments + + 12/17 + ----- +builtins/umask.def + - parse_symbolic_umask: add missing POSIX pieces: + o `action' of ugo, meaning to copy portions of initial mask + o multiple `op' specs as part of the action string (`u=r-w') + (resets perm) + o missing perm characters Xst in action string + o default `who' equivalent to `a' instead of fixing up later + + 12/19 + ----- +builtins/type.def + - if -a and -P are both supplied, look in the command hash table but + continue and perform a $PATH search even if the NAME is hashed. + From a report by Adam Vodopjan + +doc/{bash.1,bashref.texi} + - type: update description to fix it to what the code actually does + +builtins/set.def + - set_edit_mode: don't run with_input_from_stdin or with_input_from_stream + unless command_execution_string is NULL. Report from + Harald van Dijk + + 12/20 + ----- +braces.c + - array_concat: add a check for interrupts and terminating signals + into the inner loop + +jobs.c + - without_job_control: set original_pgrp == NO_PID since we don't + want to be messing with the terminal pgrp if we call end_job_control. + From a report from ks1322 ks1322 + + 12/21 + ----- +include/{posixtime.h,systimes.h,shmbutil.h,shtty.h} + - PARAMS: remove + + 12/22 + ----- +builtins/evalfile.c + - _evalfile: add SEVAL_NOOPTIMIZE to the parse_and_execute flags + (maybe overkill, but safer). From a report by + Dan Church and Oguz + +lib/sh/gettimeofday.c + - gettimeofday: added code for _WIN32 version + + 12/27 + ----- +doc/{bash.1,bashref.texi},builtins/printf.def + - specify the valid format characters as a subset of what printf(3) + specifies, note that the %n format specifier takes a variable name + as an argument. Suggestion from Emanuele Torre + + 12/28 + ----- +{xmalloc,variables,unwind_prot,trap,test,subst,sig,siglist,shell,redir, +pcomplete,pathexp,make_cmd,mailcheck,jobs,input,hashcmd,hashlib,general, +flags,findcmd,externs,execute_cmd,error,dispose_cmd,command,bashline, +bashhist,assoc,arrayfunc,array,alias}.h +{version,version2}.c + - PARAMS: remove for ANSI C-ification + +builtins/{getopt,common,bashgetopt}.h +builtins/{mkbuiltins,gen-helpfiles,psize,psize-posix}.c +builtins/{evalstring,bashgetopt,common,evalfile,getopt}.c +builtins{alias,bind,break,cd,command,complete,declare,enable,exit,fc, +fg_bg,getopts,hash,help,history,jobs,kill,mapfile,printf,pushd,read,set, +shopt,source,suspend,trap,type,ulimit,umask,wait}.def + - PARAMS: remove for ANSI C-ification + +lib/malloc/{watch,table,shmalloc,mstats,imalloc}.h +lib/malloc/{malloc,stats,table,trace}.c + - PARAMS: remove for ANSI C-ification + +lib/glob/{glob,strmatch}.h +lib/glob/{glob,glob_loop,gmisc,sm_loop,smatch,strmatch,xmbsrtowcs}.c + - PARAMS: remove for ANSI C-ification + +lib/intl/{eval-plural,plural-exp,loadinfo,hash-string,gettextP}.h, +lib/intl{plural.y,plural.c}, +lib/intl/{finddomain,bindtextdom,dcigettext,l10nflist,loadmsgcat,localealias,plural-exp}.c + - PARAMS: remove for ANSI C-ification + - STATIC -> static + - internal_function -> inline + +lib/sh/{casemod,clock,eaccess,fnxform,fpurge,makepath,mktime,netopen,pathphys,random,shquote,snprintf,spell,strtod,strtoimax,strtoumax,times,timeval,tmpfile,unicode,winsize,zcatfd,zgetline,zmapfd}.c + - PARAMS: remove for ANSI C-ification + +support/{bashversion.c,mkversion.sh,mksignames.c} + - PARAMS: remove for ANSI C-ification + +lib/sh/{clock,strchrnul,getcwd,times,rename,inet_aton,strdup,strerror,strnlen +strpbrk,strtod,strtoimax,strtol,strtoumax,wcsdup,wcsnwidth,wcswidth,strcasecmp, +strcasestr}.c + - C89-style function declarations + +lib/malloc/{alloca,malloc,stats,table,trace,xmalloc}.c + - C89-style function declarations + + 12/29 + ----- +lib/glob/{glob,glob_loop,gmisc,sm_loop,smatch,strmatch,xmbsrtowcs}.c + - C89-style function declarations + +lib/sh/{zcatfd,zgetline,zmapfd,zread,zwrite,winsize,vprint,uconvert,ufuncs, +unicode,utf8}.c +lib/sh/{stringlist,stringvec,strtrans,strvis,timeval,tmpfile}.c +lib/sh/{setlinebuf,shmatch,shmbchar,shquote,shtty,snprintf,spell}.c +lib/sh/{random,pathcanon,pathphys,oslib,netconn,netopen}.c +lib/sh/{mailstat,makepath,mbscasecmp,mbschr,mbscmp,mktime}.c +lib/sh/{input_avail,itos,getenv,fmtulong,fnxform,eaccess,dprintf,casemod,clktck}.c + - C89-style function declarations + +examples/loadables/{accept,asort,basename,bcat,cat,csv,cut,dirname,dsv}.c +examples/loadables/{fdflags,finfo,head,hello,id,lcut,ln}.c +examples/loadables/{mkdir,mkfifo,mktemp,mypid,necho,pathchk}.c +examples/loadables/{print,printenv,push,realpath,rm,rmdir,seq}.c +examples/loadables/{setpgid,stat,strftime,sync,tee,template,truefalse,tty}.c +examples/loadables/{uname,unlink,whoami}.c + - C89-style function declarations + +xmalloc.c, array2.c, list.c, dispose_cmd.c, copy_cmd.c, bracecomp.c, mksyntax.c + - PARAMS: remove for ANSI C-ification + - C89-style function declarations + + 12/30 + ----- +hashlib.c,assoc.c,input.c,hashcmd.c,alias.c,alias.h,array.c,flags.c,pcomplib.c, +pcomplib.h,locale.c +variables.c,arrayfunc.c,bashhist.c,bashline.c,error.c,pathexp.c,nojobs.c, +stringlib.c,eval.c,findcmd.c,mailcheck.c,make_cmd.c,shell.c,print_cmd.c, +general.c,expr.c + - PARAMS: remove for ANSI C-ification + - C89-style function declarations + - add `const' and `inline' where it makes sense + + 12/31 + ----- +test.c,execute_cmd.c,parse.y,pcomplete.c,trap.c,subst.c,braces.c,jobs.c,sig.c +builtins/{evalstring.c,gen-helpfiles.c,mkbuiltins.c} +builtins/{alias.def,bind.def,break.def,builtin.def,caller.def,cd.def,colon.def} +builtins/{command.def,complete.def,declare.def,echo.def,enable.def,eval.def} +builtins/{exec.def,exit.def,fc.def,fg_bg.def,hash.def,help.def,history.def} +builtins/{jobs.def,kill.def,let.def,mapfile.def,printf.def,pushd.def,read.def} +builtins/{return.def,set.def,setattr.def,shift.def,shopt.def,source.def} +builtins/{suspend.def,test.def,times.def,trap.def,type.def,ulimit.def} +builtins/{umask.def,wait.def} + - PARAMS: remove for ANSI C-ification + - C89-style function declarations + - add `const' and `inline' where it makes sense + + 1/2/2023 + -------- +lib/sh/{stringvec.c,inet_aton.c,strnlen.c,spell.c,netopen.c,stringlist.c} +lib/sh/{strtrans.c,tmpfile.c,uconvert.c,zcatfd.c} +builtins/{common.c,common.h} +mailcheck.c,bashline.c,pathexp.c,stringlib.c,locale.c,pcomplete.c,redir.c +test.c,trap.c,variables.c,bashhist.c,expr.c,arrayfunc.c,assoc.c,variables.c +subst.c,findcmd.c +arrayfunc.h,variables.h,findcmd.h,bashline.h,trap.h,pathexp.h,externs.h, +pcomplete.h,bashhist.h,assoc.h,general.h,subst.h + - more `const' changes, remove `register' + + 1/3 + --- +parse.y + - more `const' changes, remove `register' + +variables.h + - VARLIST: list_len and list_size now size_t + +variables.c + - vlist_alloc: take size_t parameter, changed callers + - vlist_realloc: take size_t parameter, changed callers + +lib/sh/stringvec.c,externs.h + - functions that take int size params now take size_t + - strvec_len: returns size_t + +lib/sh/stringlist.c,externs.h + - STRINGLIST: list_size and list_len now size_t + - functions that take int size params now take size_t + +variables.c,bashline.c,builtins/bind.def + - change strvec_ int parameters to size_t where it makes sense + - change strlist_ int parameters to size_t where it makes sense + +builtins/shopt.def + - reset_shopt_options: set glob_always_skip_dot_and_dotdot to 1, + since that's the current default in lib/glob/glob.c + + 1/4 + --- +execute_cmd.c,parse.y,general.c,make_cmd.c,print_cmd.c,variables.c,expr.c +jobs.c,subst.c,input.c,unwind_prot.c,pathexp.c,pathexp.h,alias.c,bashline.c +bashhist.c,lib/sh/shquote.c,externs.h,stringlib.c,locale.c,findcmd.c +builtins/common.c,builtins/declare.def,builtins/enable.def,builtins/fc.def +lib/sh/zmapfd.c,builtins/help.def,builtins/mapfile.def,builtins/read.def +builtins/shopt.def,lib/glob/glob.c,lib/glob/smatch.c,lib/glob/sm_loop.c +lib/glob/xmbsrtowcs.c,lib/glob/gmisc.c,lib/glob/gm_loop.c +lib/sh/getenv.c,lib/sh/makepath.c,lib/sh/pathphys.c,lib/sh/tmpfile.c +lib/sh/stringlib.c,lib/sh/spell.c,lib/sh/strtrans.c,lib/sh/zgetline.c +lib/sh/mbscasecmp.c,lib/sh/utf8.c +lib/readline/readline.c,lib/readline/rlprivate.h,lib/readline/vi_mode.c +lib/readline/complete.c,lib/readline/bind.c,lib/readline/isearch.c +lib/readline/util.c,lib/readline/kill.c,lib/readline/macro.c +lib/readline/text.c,lib/readline/histexpand.c,lib/readline/histfile.c +lib/readline/mbutil.c,lib/tilde/tilde.c + - size_t changes + - remove some unused variables + - remove `register' + + 1/5 + --- +builtins/getopt.c + - sh_getopt_restore_state: make sure argv[sh_curopt] is non-null before + using it + +parse.y + - CHECK_FOR_RESERVED_WORD: make sure to set word_top appropriately if + the last token was IF, WHILE, or UNTIL, since these tokens can follow + those reserved words + +Makefile.in + - ubsan: new target, to build with gcc/clang UBSan undefined behavior + sanitizer + + 1/6 + --- +execute_cmd.[ch],locale.c,parse.y,expr.c,bracecomp.c,bashline.c,externs.h +stringlib.c,general.[ch] +builtins/{subst.c,array.c,echo.def,printf.def,enable.def,help.def,set.def} +lib/sh/{strtrans.c,stringvec.c,shquote.c} +lib/glob/sm_loop.c +lib/readline/{vi_mode.c,histfile.c,funmap.c,complete.c,display.c,bind.c,isearch.c} +lib/tilde/tilde.c + - final code cleanups for ANSI C and lint/ubsan/asan runs + + 1/7 + --- +lib/readline/complete.c + - rl_complete_internal: when computing nontrivial_lcd and the length + of the text from the line buffer, dequote the text from the line + buffer before comparing it against the common prefix of the matches + (matches[0]), so we don't get spurious mismatches if the quoted text + from the line is longer than the unquoted match. Report from + Martin Castillo + +input.[ch] + - get_buffered_stream(fd): new function, return the BUFFERED_STREAM * + corresponding to file descriptor FD, if it exists + + 1/8 + --- +parse.y + - shell_getc: if yy_getc returns EOF but the buffered stream input + indicates an error state, set shell_input_line_terminator to + READERR. Currently treated the same as EOF. + + 1/10 + ---- +lib/sh/random.c + - intrand32: use % operator instead of (mathematically equivalent) + subtraction and multiplication, which can cause signed 32-bit + overflow. Report from Sam James + +lib/readline/input.c + - rl_getc: if the application hasn't defined a signal event handler, + and readline is in callback mode, make sure SIGINT breaks out of + operations like incremental and non-incremental searches and digit + arguments by calling _rl_abort_internal, since the callback code + expects the various contexts that rl_callback_sigcleanup() resets + to be valid + - rl_getc: if there is a pending signal when we enter the while loop + in callback mode, handle it in the same way we would if a signal + arrived while we were waiting in select/pselect. That forces + callback mode to call _rl_abort_internal in the right place. + From a report from Andrew Burgess + + 1/13 + ---- +trap.c + - SIG_ASYNCSIG: new value for sigmodes; means that the signal is + ignored because an async command is being executed + - set_signal: if the original signal disposition is SIG_IGN only + return if SIG_ASYNCSIG isn't set. This implements POSIX interp 751 + for setting a trap + - ignore_signal: if we're ignoring a signal that already has SIG_IGNORED + set, make sure we set SIG_TRAPPED in case of SIG_ASYNCSIG (POSIX + interp 751) + - reset_signal,restore_signal: if we want to reset or restore a signal + that has SIG_ASYNCSIG set, make sure we reset to SIG_DFL if the + signal is trapped to maintain POSIX semantics + - set_signal_async_ignored: new function to set original_signals to + SIG_IGN and set the SIG_IGNORED and SIG_ASYNCSIG sigmode flags; used + by setup_async_signals + - signal_is_async_ignored: return true if the SIG argument is being + ignored because it's part of an async list + +trap.h + - set_signal_async_ignored,signal_is_async_ignored: extern declarations + +sig.c + - initialize_terminating_signals: if a signal is ignored because it's + part of an async list, don't bother trying to initialize or set the + hard ignored flag + +execute_cmd.c + - execute_simple_command: if we're executing a builtin or function + asynchronously, call reset_terminating_signals like we do in + execute_in_subshell() + - execute_subshell_builtin_or_function: only call set_sigint_handler + if async is 0, so we don't undo the work done by setup_async_signals. + If the old handler is SIG_IGN and the signal has SIG_ASYNCSIG set + and isn't trapped, restore the old handler + - setup_async_signals: call set_signal_async_ignored to set the right + flags + + 1/16 + ---- +parse.y + - read_token_word: if we're in posix mode, and we find a reserved word + before checking a token for aliases, turn off the `check next word + for aliases' flag (PST_ALEXPNEXT). This is for compatibility with + other shells. From a report by + - shell_getc: make sure the shell is reading a buffered stream before + checking the default buffered stream for errors if yy_getc returns 0 + + 1/17 + ---- +subst.c + - split_at_delims: if the cursor is at whitespace just preceding a + word, and we're doing this for completion (e.g., to build COMP_WORDS), + force the creation of an empty word and set the current word to it. + This is a change from previous behavior, but a useful one: it makes + COMP_WORDS[COMP_CWORD] and $2 to a completion function consistent + and the same as the word readline wants to complete. From a report + from Naim Favier back in 6/2022 + +parse.y + - read_token: turn off PST_ALEXPNEXT if we read a shell metacharacter: + we will expand aliases anyway if the token puts the shell in a + command word position and we took pains to turn it off for + redirection tokens; remove special cases that turned it off + - pop_string: don't turn off PST_ALEXPNEXT if it's on; this is what + prevents it from being enabled if an alias expansion of more than + two aliases ends with a space. Fixes issue reported by + + + 1/18 + ---- +jobs.c + - wait_for: if we are reaping a background job, don't bother trying to + give the terminal back to shell_pgrp -- we never set the terminal's + pgrp to that job in the first place. Fixes issue reported by + Steffen Nurpmeso + + 1/19 + ---- +lib/readline/{histexpand.c,history.h} + - history_expand: first argument is now `const char *'. Request from + Simon Marchi + +lib/readline/doc/{history.3,hstech.texi} + - history_expansion: change description to note new const first arg + + 1/21 + ---- +lib/readline/input.c + - rl_gather_tyi: move call to rl_input_available_hook to the top, + giving it first shot. There's still no way for it to set chars_avail. + Conditionalize the rest of the input methods based on whether the + result == -1. + +lib/readline/rl_private.h + - move the decision making about RL_TIMEOUT_USE_SELECT/RL_TIMEOUT_USE_SIGALRM + here from input.c + + 1/23 + ---- +trap.c + - restore_default_signal: if we have a signal that's not trapped, but + is a signal that is set to SIG_ASYNCSIG, POSIX interp 751 requires + the shell to allow it to be reset to the default, even though it + wasn't already trapped + +subst.c + - do_assignment_internal: don't allocate new memory for NAME, just + modify and restore it in place + + 1/25 + ---- +lib/readline/histfile.c + - history_write_slow: a fallback function that uses stdio to write the + history list to a supplied file descriptor + - history_do_write: call history_write_slow if ftruncate/mmap/malloc + fail; hope the simpler approach works + + 1/27 + ---- +general.[ch] + - valid_function_name: new function, returns non-zero if the name + can be used as a function name without the `function' prefix + +print_cmd.c + - named_function_string,print_function_def: use valid_function_name so + the rules about when to use the `function' reserved word are + consistent + +builtins/trap.def + - new option -P, which prints only the action associated with each + signal spec argument + +doc/{bash.1,bashref.texi} + - trap: document new -P option, add note that trap -p or trap -P in a + subshell can print the parent's traps + + 1/28 + ---- +parse.y + - shell_getc: make sure references to shell_input_line_property are + protected by #ifdef HANDLE_MULTIBYTE. From + https://savannah.gnu.org/patch/?10309 + +print_cmd.c + - named_function_string,print_function_def: don't copy the function + COMMAND * before printing it as text; unwind-protect any redirects + attached to the function body + +parse.y + - PST_CMDBLTIN: new parser state, means the previous token word was + `command' in a command position + - read_token_word: in posix mode, "command" followed by a declaration + utility preserves the declaration utility status of the following + word, so we mark that state and then check a word for being an + assignment builtin if in that state on the next call. This makes + compound assignments to builtins that accept them (e.g., `declare') + work as if `command' were not present. This is a POSIX issue 8 + requirement + - read_token: turn off PST_CMDBLTIN state as appropriate + +subst.c + - use locale_mb_cur_max instead of MB_CUR_MAX consistently + + 2/1 + --- +builtins/printf.def + - printf_builtin: %q and %Q use the `alternate form' flag to force + single quoting instead of backslash quoting. $'...' is still + preferred if there are characters that require it + - getwidestr, getwidechar: functions to take a possibly multibyte + character string and convert to a wide character string or a wide + character, respectively + - convwidestr, convwidechar: functions to take a wide character string + or single character, apply any precision, convert back to a multibyte + character string, and return the result for printing + - printf_builtin: consistently print an error message if printstr() + returns < 0, since it will only do that if ferror(stdout) is true; + let the PRETURN macro do that if appropriate, so we don't duplicate + code + + 2/2 + --- +builtins/printf.def + - printwidestr: wide-character version of printstr; understands + fieldwidth and precision as characters instead of bytes + - printf_builtin: interpret %ls and %lc as referring to wide strings + and characters, respectively; use printwidestr to print the wide- + character string obtained from the (presumably multibyte) argument. + Fieldwidth and precision are characters, not bytes + + 2/3 + --- +builtins/set.def + - unset_builtin: since tokenize_array_reference modifies its NAME + argument, we need to restore the original word if there is no + array variable found with that name, so we can go ahead and try to + unset a function with that wonky name. Inspired by a report from + Emanuele Torre + +parse.y + - read_token_word: don't set the W_HASDOLLAR flag in the returned WORD + for <(command) and >(command). That way they can be used in function + names. + +execute_cmd.c + - execute_simple_command: if in posix mode, don't perform function + lookup for command names that contain a slash + +builtins/enable.def + - dyn_load_builtins: don't allow dynamically loaded builtins to have + slashes in their name + + 2/4 + --- +general.c + - valid_function_word: new function, used to check whether a word can + be used as a function name. Replaces call to check_identifier(); + incorporates POSIX interp 383 check for special builtin so we can + move it out of execute_intern_function(). + - valid_function_name: use the FLAGS argument instead of POSIXLY_CORRECT; + only reject reserved words if FLAGS&1 + +execute_cmd.c + - execute_intern_function: call valid_function_word() instead of + check_identifier(); remove check for special builtin that + valid_function_word performs + +print_cmd.c + - print_function_def,named_function_string: pass POSIXLY_CORRECT to + valid_function_name as the FLAGS argument + + 2/6 + --- +subst.c + - expand_subscript_string: don't set W_NOTILDE in td.flags so we + perform `normal' tilde expansion (expansion at the start of the + word) on the array subscript + - expand_oneword,expand_compound_assignment_word: change second arg to + ATYPE, which better reflects its use + +arrayfunc.c + - assign_assoc_from_kvlist,assign_compound_array_list,expand_and_quote_assoc_word: + use expand_assignment_string_to_string instead of expand_subscript_string + for the rhs of the assignment or the second word in the kvpair to + be more consistent with how assignment statements behave (e.g., + tilde expansion). Fixes issue reported by maroloccio@gmail.com + + 2/7 + --- +parse.y + - discard_until: now returns the last character read. If we get an + EOF while processing a comment, return EOF (rarely happens; + shell_getc returns EOF only under certain circumstances) + - read_token: if discard_until returns EOF, return yacc_EOF + +input.h + - bclearerror: new macro, clears the B_ERROR flag in the buffered + stream BP + +input.c + - b_fill_buffer: try making errors `sticky': if the B_ERROR flag is + set for the buffered stream, return EOF immediately. This is similar + to what stdio does + +builtins/fc.def + - fc_builtin: in posix mode, if there are extra arguments supplied to + -s (e.g. pat=rep first last), throw an error + +doc/{bash.1,bashref.texi} + - printf: document new altform for %q/%Q and %ls/%lc + + 2/8 + --- +bashline.c + - set_up_new_line: if the new line doesn't change rl_line_buffer, + just return right away without changing rl_point. Affects + alias-expand-line, history-expand-line, and history-and-alias-expand-line. + Inspired by a report from + Addison Brendtro + +builtins/declare.def + - declare_internal: make multiple calls to `local -' at the same + context have no effect after the first one. That way we don't keep + overwriting the saved option set. Report and fix from + Emanuele Torre + + 2/10 + ---- +execute_cmd.[ch] + - bind_lastarg: now a public function + +parse.y + - execute_variable_command: call bind_lastarg instead of bind_variable + to avoid exporting $_ if allexport is set. Fix from + Emanuele Torre + - history_delimiting_chars: if we're parsing some kind of delimited + construct that's *not* a quoted string, don't bother adding an extra + newline to the history if the current history entry already ends in + a newline. From https://savannah.gnu.org/support/?110838 via + Ganapathi Kamath + + 2/13 + ---- +bashline.c + - set_up_new_line: add some more heuristics to try and usefully + position rl_point + + 2/16 + ---- +lib/readline/complete.c + - complete_fncmp: fix for case mapping `-' and `_' if the bytes do not + form a valid multibyte character + +lib/readline/util.c + - new functions: _rl_strcaseeqn, like strcasencmp but with a flag to + handle character mapping (-_) like completion-map-case wants, and + _rl_charcasecmp, to do the same thing for two characters. + Inspired by a patch from Brennan Vincent + +lib/readline/mbutil.c + - new functions: _rl_mb_strcaseeqn and _rl_mb_charcasecmp, multibyte + versions of the above + Inspired by a patch from Brennan Vincent + +lib/readline/{rlprivate.h,rlmbutil.h} + - extern declarations for the above functions + +lib/readline/complete.c + - complete_fncmp: use _rl_mb_strcaseeqn and _rl_strcaseeqn as + appropriate, remove duplicated inline code + Inspired by a patch from Brennan Vincent + +lib/readline/{isearch.c,rlprivate.h} + - _rl_search_case_fold: new variable, will be used to indicate case- + insensitive incremental and non-incremental searches + +lib/readline/bind.c + - search-ignore-case: new bindable variable, tied to _rl_search_case_fold + Inspired by a patch from Brennan Vincent + +lib/sh/mbsncmp.c + - mbsncmp(3) replacement + +lib/readline/isearch.c + - _rl_isearch_dispatch: honor `search-ignore-case' variable and perform + case-insensitive incremental searches if it's set + Inspired by a patch from Brennan Vincent + +lib/readline/histlib.h + - CASEFOLD_SEARCH: new flag for history searching, means to search + strings case-insensitively + +lib/readline/histsearch.c + - history_search_internal: anchored searches honor CASEFOLD_SEARCH + +lib/readline/histsearch.c + - history_search_internal: searches now honor CASEFOLD_SEARCH + - _hs_history_search: new function, just external interface to + history_search_internal, allows the rest of the library to specify + search flags + +lib/readline/histlib.h + - _hs_history_search: extern declaration + +lib/readline/search.c + - noninc_search_from_pos: use _hs_history_search, add CASEFOLD_SEARCH + to flags if _rl_search_case_fold is non-zero + +doc/bash.1,lib/readline/doc/{readline.3,rluser.texi} + - search-ignore-case: document new bindable variable + + 2/17 + ---- +config-top.h + - PATSUB_REPLACE_DEFAULT: macro set to 1 or 0 to set the default value + of `patsub_replacement'. Can be overridden by -DPATSUB_REPLACE_DEFAULT=0 + in the `make' command + +builtins/shopt.def + - reset_shopt_options: reset patsub_replacement to PATSUB_REPLACE_DEFAULT + +subst.c + - patsub_replacement: initialize to PATSUB_REPLACE_DEFAULT + +parse.y + - shell_getc: only call clearerr(stdin) when yy_stream_get returns EOF + if the shell is currently interactive (interactive != 0) + - shell_getc: if the shell is not interactive (interactive_shell == 0) + and using stdio to read the script (bash_input.type == st_stream), + set shell_input_line_terminator to READERR if ferror(stdin) is true + after yy_stream_get returns EOF + + 2/20 + ---- +doc/{bash.1,bashref.texi} + - update aliases description based on a bug-bash discussion + - update description of word splitting behavior when IFS is unset + +builtins/evalfile.c + - _evalfile: if reading the entire file doesn't return the same + number of bytes as requested (the file size), treat this as a read + error + + 2/21 + ---- +parse.y + - yylex: if read_token returns < 0, return YYEOF if EOF_Reached = 1. + Don't return yacc_EOF because that allows commands to be executed. + - grammar: add a production to handle YYEOF, treating it the same as + yacc_EOF. Based on a report from + Eduardo A. Bustamante López + +jobs.c + - wait_for: if we're checking for window size changes, allow checks + during trap commands while readline is active or `bind -x' command + execution. Fix from Koichi Murase + + 2/22 + ---- +jobs.c + - wait_for: check for window size changes during programmable completion + + 2/23 + ---- +execute_cmd.c,input.c,jobs.c,nojobs.c,parse.y,redir.c,shell.c +builtins/{exec.def,read.def} +input.h + - BUFFERED_INPUT: preprocessor #define is gone, this code is now + unconditional + + 2/24 + ---- +builtins/declare.def + - declare_internal: set the att_propagate flag on a variable that is + marked as att_tempvar only if it's *not* marked att_local. The + effect is that local variables with the same name as variables in + the temporary environment are not propagated to the previous scope. + From a report by Voldemar Lazarev + that prompted a bug-bash discussion + +builtins/setattr.def + - set_var_attribute: don't set local variables for which we are setting + export or readonly to propagate back to the previous context, but + make sure we preserve posix semantics + +parse.y + - read_token_word: if we're parsing the words of a compound assignment + (parser_state & PST_COMPASSIGN), and we have a valid assignment + statement as a word ([sub]=value), set W_NOBRACE in the word so we + don't try and perform brace expansion on it. This makes ( [sub]=word ) + closer to name[sub]=word. + From a report by Ilkka Virta back in July, 2020: + https://lists.gnu.org/archive/html/bug-bash/2020-07/msg00133.html + + 2/27 + ---- +lib/readline/display.c + - rl_redisplay: if HANDLE_MULTIBYTE is defined, do the special META_CHAR + handling if wc_bytes == wc_width == 1 + +execute_cmd.c + - eval_arith_for_expr: make sure we don't call make_word with a NULL + string if expand_arith_string returns NULL. Report from + F G + +arrayfunc.c + - assign_assoc_from_kvlist: added code, currently disabled, to perform + all expansions, including word splitting, on the kv-pair word list + + 2/28 + ---- +lib/readline/search.c + - rl_history_search_reinit: change check against history_string_size + to account for history_string_size now being a size_t. Report and + fix from Grisha Levit + + 3/2 + --- +lib/readline/history.c + - _hs_search_history_data: search the history list for an entry with + `data' matching the argument; return the index + - _hs_replace_history_data: search backwards through the history list + from the end + +lib/readline/histlib.h + - _hs_search_history_data: extern declaration + +lib/readline/search.c + - make_history_line_current: make sure rl_undo_list doesn't appear in + any history entries (it should be a private search string undo list) + before freeing it + +lib/readline/misc.c + - _rl_free_saved_history_line: make sure the undo list in + _rl_saved_line_for_history isn't rl_undo_list and doesn't appear in + any history list entries as `data' before freeing it. Fixes core + dump after SIGINT reported by Grisha Levit + +parse.y,print_cmd.c + - changes for size_t when computing new amount for xrealloc + + 3/3 + --- +parse.y + - set_word_top: new inline function to check and set word_top; called + from the appropriate places + - parse_dparen: call set_word_top before parsing an arith command or + nested subshell. Fixes underflow issue reported by + Grisha Levit + +examples/loadables/kv.c + - kv: new loadable builtin, reads key-value pairs from stdin and assigns + them to an associative array + + 3/7 + --- +builtins/trap.def + - trap_builtin: if trying to restore SIGQUIT to its default disposition, + and the shell is in posix mode, set to SIG_DFL if the shell is + running as an async command and signal_is_async_ignored (SIGQUIT) is + true. Posix conformance issue 751 + + 3/8 + --- +builtins/alias.def + - print_alias: now returns int. Check for write errors using sh_chkwrite + and return EXECUTION_FAILURE if it fails + - alias_builtin: if print_alias returns EXECUTION_FAILURE, return + EXECUTION_FAILURE immediately (write error). POSIX test conformance + + 3/9 + --- +builtins/cd.def + - change_to_directory: if we're not in physical mode and are in posix + mode, add step 9 of the posix cd algorithm, which essentially tries + the pathname the user supplied if it's shorter than PATH_MAX and the + length of the canonicalized pathname is longer than PATH_MAX. This + is basically what default bash mode does without the length checks. + POSIX test conformance. + +subst.c + - strip_trailing_ifs_whitespace: use ifs_whitespace(*s) instead of + spctabnl(*s) like word splitting and get_word_from_string. POSIX + test conformance + +jobs.c + - wait_for: tweak change from 1/18 to make sure a J_ASYNC job isn't in + the foreground (J_FOREGROUND) as it would be if it had been continued + in the foreground with `fg'; if it is, we want to give the terminal + back to shell_pgrp + + 3/10 + ---- +input.c + - fd_berror: returns true if the file descriptor passed as an arg + corresponds to a buffered stream with an error condition + +parse.y + - shell_getc: use fd_berror instead of inline code + - shell_getc: if yy_getc returns EOF, immediately set line[0] to NULL + and set shell_input_line_terminator to READERR. Then exit immediately + with status 128 if index == 0, line[index] == NULL, and READERR. + Posix interp 1629 + +config-top.h + - FATAL_READERROR: now defined to 1 by default + +lib/readline/display.c + - rl_expand_prompt: allocate an empty string for local_prompt if prompt + is the NULL or empty string. Fixes seg fault with rl_message and + empty prompt reported by Grisha Levit + +lib/readline/histexpand.c + - history_expand: if hist_extract_single_quoted returns an index at or + past the end of the string, correct the index and break the loop, + which will cause a return. Report and fix from + Grisha Levit + + 3/13 + ---- +lib/readline/vi_mode.c + - rl_domove_motion_callback: set the MOVE_FAILED flag in the context M + if rl_dispatch returns non-zero and other movement-command-specific + conditions are met. Right now, an unsuccessful `f' or `F' command + is failure. + - _rl_vi_domove_motion_cleanup: if the command is `c' or `C', we don't + enter insert mode if the MOVE_FAILED flag is set in the context M. + This is how standalone vi works. + +lib/readline/kill.c + - rl_unix_filename_rubout: add some checks for rl_point > 0 before + looking at rl_line_buffer[rl_point - 1]. Report and fix from + Grisha Levit + +lib/readline/isearch.c + - _rl_isearch_dispatch: reset cxt->sline_index to 0 if it's past the + end of the history string (sline_len). Fixes asan bug reported by + Grisha Levit + +lib/readline/histexpand.c + - history_tokenize_word: don't increment the string index past the + NULL if the line ends in a backslash.Fixes asan bug reported by + Grisha Levit + +lib/readline/vi_mode.c + - rl_vi_yank_to,rl_vi_change_to,rl_vi_delete_to: if these are called + with an existing valid vimvcxt, save it and allocate a new one for + the current function call to use, then restore it before returning. + This prevents referencing vimvcxt after freeing it in the case that + these functions call each other recursively (e.g., y1y1, c1d1, etc.). + Fixes asan bug reported by Grisha Levit + + 3/14 + ---- +bashhist.c + - bash_add_history: make sure curlen is large enough before checking + curlen - 1 and curlen - 2, otherwise you can get buffer underflow. + Fixes asan bug reported by Grisha Levit + +bashline.c + - bash_spell_correct_shellword: don't bother trying to correct empty + words. Fixes asan bug reported by Grisha Levit + +lib/sh/shquote.c + - sh_mkdoublequoted: make sure to allocate enough memory for the + pathological case: where every character in the string needs to be + backslash-escaped because it's special within double quotes. + Fixes asan bug reported by Grisha Levit + +doc/{bash.1,bashref.texi} + - here documents: make sure the summary specifies the here-document is + terminated by `delimiter'; specify what the delimiter is if the word + is not quoted. Prompted by a help-bash post from + goncholden + + 3/15 + ---- +doc/bash.1,lib/readline/doc/rluser.texi + - shell-expand-line: enumerate the specific expansions performed. + From a request by Alex Bochannek + +findcmd.c + - path_value: new function, returns normalized version of $PATH. Takes + a single argument saying whether or not to look in the temporary + environment first. Normalizes null $PATH (PATH=) into ".". From a + bug-bash discussion started by Moshe Looks + - _find_user_command_in_path: use path_value() + - user_command_matches: use path_value() + - search_for_command: if PATH[0] == 0, set PATH = "." like path_value(). + This has the side effect of calling command_not_found_handle when + PATH is the empty string and the command isn't in the current + directory + - search_for_command: if path == 0, but we found an executable in the + current directory, make sure to set dot_found_in_search before adding + it to the command hash table + +findcmd.h + - path_value: extern declaration + +bashline.c + - command_word_completion_function: use path_value() + +builtins/enable.def + - dyn_load_builtin: use path_value for BASH_LOADABLES_PATH; it's cleaner + though it doesn't change the behavior + + 3/17 + ---- +bashline.c + - bashline_reset: reset rl_filename_quoting_function, since there is a + SIGINT code path where it could remain reset by glob completion. + Reported by Grisha Levit + - command_word_completion_function,command_subst_completion_function, + glob_complete_word: set some static variables to NULL + after freeing them so they don't potentially get freed twice after + a SIGINT during completion + Reported by Grisha Levit + +parse.y + - read_token_word: when deciding how to quote translated strings, don't + free ttok before comparing it to ttrans + Reported by Grisha Levit + - parse_matched_pair: same thing for freeing nestret + - read_token: if we return a newline, make sure we call set_word_top() + if necessary. + Fixes underflow reported by Grisha Levit + +lib/glob/sm_loop.c + - EXTMATCH: don't bother with FNM_PATHNAME checks; this function isn't + called with a pathname. + Fixes underflow reported by Grisha Levit + +lib/readline/misc.c + - rl_maybe_replace_line: if we replace a history entry's data with + rl_undo_list, we need to set rl_undo_list to 0, since we should not + have rl_undo_list pointing to something from a history entry + Fixes asan error reported by Grisha Levit + + 3/20 + ---- +lib/readline/histexpand.c + - postproc_subst_rhs: fix off-by-one error when reallocating new string + for case where we're *not* substituting for `&' + Fixes asan error reported by Grisha Levit + +jobs.c + - terminate_current_pipeline: add a SIGKILL call in there in case the + SIGTERM doesn't work + - terminate_current_pipeline: add a version that works when job control + isn't enabled (pipeline_pgrp == shell_pgrp) + +subst.c + - skip_to_delim: pass completeflag (SX_COMPLETE) to extract_dollar_brace_string + in case it includes a command substitution, since we want to inhibit + error messages in this case + +parse.y + - no_semi_successors: add DOLPAREN to list since something like $(\n + shouldn't have a semicolon added there. + From a report by Grisha Levit + + 3/21 + ---- +pcomplete.c + - gen_globpat_matches: set noglob_dot_filenames here since we're not + calling shell_glob_filename to do it + From a report by Grisha Levit + + 3/22 + ---- +lib/readline/misc.c + - rl_maybe_replace_line: if we're replacing a history entry with the + current line buffer and undo list, then zero out any undo list in + _rl_saved_line_for_history, since we're not going to use it any more + Fixes asan error reported by Grisha Levit + +lib/readline/undo.c + - rl_free_undo_list: if we're freeing rl_undo_list, it can't be a + valid value for data in _rl_saved_line_for_history + Fixes asan error reported by Grisha Levit + +lib/readline/complete.c + - display_matches: don't call rl_display_match_list if we received a + signal during get_y_or_n and didn't jump out for some reason + From a report by Grisha Levit + - rl_display_match_list: return if we received a signal during + _rl_internal_pager (via get_y_or_n) and didn't jump out + From a report by Grisha Levit + + 3/23 + ---- +lib/readline/history.c + - history_truncate_file: don't bother trying to read the existing + history file if we're just truncating it to 0 lines + + 3/24 + ---- +lib/readline/histfile.c + - history_truncate_file: fix off-by-one error that resulted in the + timestamp associated with the first history entry not being written + to the truncated history file + From a report by Grisha Levit + +parse.y + - decode_prompt_string: do something rational if localtime() returns + NULL (extraordinarily rare) + From a report by Paul Eggert + +examples/loadables/stat.c + - stattime: ditto + +examples/loadables/strftime.c + - strftime_builtin: ditto + +lib/readline/examples/histexamp.c + - main: ditto + +include/posixtime.h + - getnow(): new inline function, calls gettimeofday and returns tv_sec; + replacement for time(0). From Paul Eggert + +general.h + - NOW: use a call to getnow() to standardize on gettimeofday for time + information + +lib/readline/history.c + - include #posixtime.h for getnow() + - hist_inittime: use getnow() instead of calling time(0) + +parse.y + - posixtime.h: include instead of + - decode_prompt_string: use getnow() instead of calling time(0) + + 3/27 + ---- +parse.y + - count_all_jobs: add extern definition if JOB_CONTROL is not defined. + From Emanuele Torre + +bashhist.c + - bash_add_history: make sure the current history line is not empty + before checking what ended it. + From a report by Grisha Levit + +lib/readline/histexpand.c + - history_tokenize_word: break out of loop for incomplete command and + process substitution or extended globbing patterns + From a report by Grisha Levit + +bashline.c + - hostnames_matching: fix size_t issue when checking whether to realloc + From a report by Grisha Levit + +lib/sh/random.c + - genseed: use uintptr_t instead of u_bits32_t to silence compiler + warnings. From Paul Eggert + +aclocal.m4 +array2.c +builtins/mkbuiltins.c,builtins/psize-posix.c,version.c +builtins/getopts.def +lib/readline/text.c,lib/readline/bind.c +support/recho.c,support/mksignames.c,support/zecho.c,support/xcase.c +support/printenv.c,support/signames.c,support/bashversion.c +support/memtest.c,support/endian.c +lib/glob/gm_loop.c + - some cleanups for function prototypes and other stdc requirements + From Paul Eggert + +lib/readline/doc/{rltech.texi,hstech.texi} + - add prototypes and stdc requirements to the examples + +builtins/complete.def + - compgen_builtin: save and restore readline variables affecting how + filename completions are treated in case someone uses compgen in + the foreground. + From a report by Grisha Levit + + 3/28 + ---- +aclocal.m4 +builtins/enable.def,builtins/gen-helpfiles.c,builtins/help.def,builtins/printf.def +general.h,hashlib.h +include/ansi_stdlib.h,include/ocache.h +lib/glob/collsyms.h,lib/glob/glob.c +lib/readline/history.h,lib/readline/xmalloc.h +xmalloc.c,xmalloc.h +lib/sh/strtrans.c +lib/tilde/tilde.c +mksyntax.c +support/endian.c + - don't bother with __STDC__ if we are just using C89 features like + const, function prototypes, etc. + From Paul Eggert + +externs.h + - prototype the list functions that take GENERIC_LIST * + From Paul Eggert + +builtins/common.c,examples/loadables/getconf.c +execute_cmd.c,pcomplete.c,subst.c +lib/sh/stringlist.c,lib/sh/stringvec.c + - changes and casts now that the generic list functions are prototyped + From Paul Eggert + + 3/29 + ---- +aclocal.m4,configure.ac +builtins/common.c,builtins/mkbuiltins.c,builtins/printf.def +include/memalloc.h,include/stdc.h +general.h,jobs.h +pcomplete.c,print_cmd.c +m4/iconv.m4 +lib/readline/bind.c,lib/readline/complete.c,lib/readline/display.c +lib/readline/funmap.c,lib/readline/util.c,lib/readline/parens.c +lib/readline/histlib.h +lib/readline/readline.h,lib/readline/rldefs.h,lib/readline/rlstdc.h,lib/readline/rlprivate.h +lib/sh/dprintf.c,lib/sh/snprintf.c,lib/sh/vprintf.c +lib/malloc/shmalloc.h,lib/malloc/imalloc.h,lib/malloc/xmalloc.c +lib/termcap/termcap.h + - stdarg: since we now assume C89 for prototypes at least, always + prefer stdarg to old-style varargs + - SH_VA_START: now use plain old va_start + - don't bother with extern declarations for standard C89 functions + From Paul Eggert + +config-bot.h + - PREFER_STDARG: remove + +builtins/mkbuiltins.c +execute_cmd.c,unwind_prot.c +unwind_prot.h + - start on ANSI/ISO C changes for the unwind-protect framework + - introduce new unwind-protect function pointer type to replace + Function + From Paul Eggert + + 3/30 + ---- +builtins/command.def,builtins/fc.def,builtins/read.def,builtins/source.def +builtins/evalfile.c,builtins/evalstring.c +dispose_cmd.c,execute_cmd.c,pcomplete.c,print_cmd.c,subst.c,jobs.c,variables.c +dispose_cmd.h,general.h,trap.h +unwind_prot.c,unwind_prot.h + - rest of work to convert unwind-protect framework to ANSI/ISO C. + Convert unwind-protects to use new shim functions that obey the new + unwind-protect function type + From Paul Eggert + +general.h + - STREQ, STREQN: now static inline functions to take advantage of arg + type conversion + +pcomplete.c,subst.c +lib/readline/histexpand.c,lib/readline/mbutil.c + - fix size_t subtractions in comparisons to avoid unsigned underflow + +externs.h +execute_cmd.c +builtins/times.h + - add prototypes for functions taking clock_t and timeval, make their + declaration in externs.h conditional on NEED_CLOCK_FUNCS_DECL and + NEED_TIMEVAL_FUNCS_DECL, respectively + + 3/31 + ---- +subst.c + - expand_string_dollar_quote: check for zero-length return from + string_extract_{single,double}_quoted and avoid size_t underflow + Fixes asan error reported by Grisha Levit + + 4/3 + --- +builtins/evalstring.c + - open_redir_file: treat the case of failing to open the file as a + non-fatal expansion error instead of a (fatal) redirection error. + Report from Zev Weiss + + 4/4 + --- +lib/readline/vi_mode.c + - _rl_domove_motion_cleanup: d/D require the same special case as c/C + so that a motion command that doesn't move the cursor consumes/deletes + at least one character. + From Emanuele Torre + - _rl_domove_motion_cleanup: ditto for y/Y + - rl_domove_motion_callback: if t/T/;/, fail (return non-zero without + moving point), flag the motion command as having failed (MOVE_FAILED) + + 4/6 + --- +subst.c + - command_substitute: save the return status of the child process in + last_command_subst_status; don't assign to last_command_exit_value + in posix mode (posix interp 1150) + +execute_cmd.c + - execute_null_command: a simple command without a command word but + with command substitutions now returns last_command_subst_status. + It may or may not have already modified $? depending on posix mode + +redir.c + - redir_varvalue: legal_number validity check should be == 0, not < 0 + From a report by Grisha Levit + + 4/10 + ---- +subst.c + - parameter_brace_expand_rhs: check for namerefs in the variable name + part of the ${name=word} expansion so we can go back and implement + the POSIX semantics of returning "the final value of parameter." + From a report by Grisha Levit + +sig.c,sig.h + - sigpipe_handler: clean up, set $?, and throw to top level on receipt + of a SIGPIPE + - termsig_handler: if the variable builtin_catch_sigpipe is set (it's + not set anywhere yet), call sigpipe_handler instead of terminating + the shell. Still need to make sure a sighandler is installed for + SIGPIPE even if initialize_terminating_signals isn't called + + 4/14 + ---- +lib/sh/tmpfile.c + - sh_mktmpfd: add support for MT_UNLINK flag, unlinks created filename + before returning fd, fails if the unlink fails for some reason + + 4/15 + ---- +pathexp.c,pathexp.h + - globsort: support for various glob sorting criteria as defined by + the GLOBSORT variable: name, size, blocks, mtime, atime, ctime. + Default is ascending sort by name, as is traditional. Based on an + idea from Evan Gates + - setup_globsort: parse the value of the GLOBSORT variable, find + sorting type and whether or not it's ascending or descending + - noquote_glob_filename: glob_filename for programmable completion, + doesn't call quote_string_for_globbing and honors GLOBSORT, dotglob, + and globstar + +pcomplete.c + - gen_globpat_matches: call noquote_glob_filename, let that handle + all the variables and GLOB_FAILED + +variables.c + - GLOBSORT: support for special variable, call setup_globsort on + set or unset + +doc/bash.1,doc/bashref.texi + - GLOBSORT: document variable and its effects on pathname expansion + + 4/17 + ---- +builtins/complete.def + - build_actions: take an additional char ** arg VNAMEP; if it is non- + null, accept a -V VARNAME option that names an indexed array + variable in which to store the completions. + - compgen_builtin: if the -V option is supplied, store the possible + completions into VARNAME instead of printing them on stdout. From a + patch from Grisha Levit , idea originally + from konsolebox back in 2/2022 + +doc/bash.1,lib/readline/doc/rluser.texi + - compgen: document new -V option + + 4/18 + ---- +lib/readline/vi_mode.c + - rl_domove_read_callback: call _rl_arg_init before reading digit + argument so prompt gets saved, both callback and non-callback modes + From a report by Grisha Levit + - rl_vi_arg_dispatch: if we return 0 to end the digit argument and + turn off NUMERICARG, call rl_restore_prompt + +lib/readline/histexpand.c + - history_expand_internal: make sure subst_lhs is not null before we + call postproc_subst_rhs. + From a report by Grisha Levit + +lib/readline/display.c + - rl_redisplay: remove redundant code that ends up incrementing lpos + too much for meta characters displayed as octal escape sequences. + From a report by Grisha Levit + + 4/19 + ---- +bashline.c + - attempt_shell_completion: handle case where s > e after calls to + find_cmd_start and find_cmd_end, respectively. + From a report by Grisha Levit + +lib/readline/display.c + - update_line: fix setting of `wsatend' when computing ols and nls in + the multibyte case; this caused redisplay to print more characters + than it needed + - update_line: fix calculation of visible_wrap_offset when moving up + to line 0, trying to figure whether or not the visible prompt has + any invisible characters. Fixes C locale issue reported by + Grisha Levit + + 4/20 + ---- +lib/readline/text.c + - _rl_rubout_char: update erase-at-end-of-line hack to deal with the + unlikely event that a character in a non-multibyte locale is + displayed using an octal representation. + From a report by Grisha Levit + +execute_cmd.c,execute_cmd.h,builtins/evalstring.c + - interrupt_execution: replaces `executing_list' + - interrupt_execution: set while executing while, for, until, select, + and arithmetic for loops + +jobs.c + - wait_for: if a process dies due to a SIGINT while the shell is + executing a loop or a list, act as if the shell got SIGINT. This + is no longer dependent on the compatibility level + From a report by Grisha Levit + +bashline.c + - name_is_acceptable: allow FIGNORE suffixes to match the entire + pathname like tcsh does instead of requiring a non-empty prefix. + From Emanuele Torre + + 4/23 + ---- +lib/readline/misc.c + - _rl_unsave_line: new function, takes a HIST_ENTRY * as an argument, + generalized rl_maybe_unsave_line + - _rl_alloc_saved_line: allocate a new HIST_ENTRY *, populate it like + rl_saved_line_for_history + - _rl_free_saved_line: free a saved HIST_ENTRY * + - _rl_free_saved_history_line: call _rl_free_saved_line + - _rl_previous_history_internal: new function, internals of + rl_get_previous_history; change rl_get_previous_history to call it + +lib/readline/history.h + - HIST_ENTRY_DEFINED: define sentinel if HIST_ENTRY struct defined + +lib/readline/rlprivate.h + - _rl_alloc_saved_line,_rl_free_saved_line,_rl_unsave_line: new extern + function definitions + - _rl_free_saved_search_line: new extern definition + +lib/readline/search.c + - _rl_saved_line_for_search: use private storage to save current line, + avoid clashes with rl_saved_line_for_history + - _rl_free_saved_search_line,_rl_unsave_saved_search_line: new functions + to manage _rl_saved_line_for_search + - noninc_dosearch,_rl_nsearch_abort: clean up _rl_saved_line_for_search + instead of rl_saved_line_for_history + - rl_history_search_internal: allocate private _rl_saved_line_for_search; + unsave or free it as appropriate + - _rl_history_search_reinit: free up any _rl_saved_line_for_search just + in case + +lib/readline/vi_mode.c + - rl_vi_search: free _rl_saved_line_for_search, since that's what the + non-incremental search functions use now + - rl_domove_read_callback: if we read a numeric argument, then a motion + character, make sure the motion character is valid before returning + it and going on + From a report by minipython <599192367@qq.com> + + 4/27 + ---- +lib/readline/display.c + - _rl_move_cursor_relative: when checking to see whether data is within + the invisible line, make sure to stay within the invisible line + line break boundaries + From a report by minipython <599192367@qq.com> + +lib/readline/search.c + - dispose_saved_search_line: new function, either unsave the saved + search line (if we're not at the end of the history) or free it + (if we are). Needs to be immediately followed by call to + make_history_line_current, which resets rl_undo_list + - make_history_line_current: change strategy: rely on callers to + manage _rl_saved_line_for_search and rl_undo_list; just copy the + data from the passed history entry into the line buffer and reset + rl_undo_list + - noninc_dosearch,rl_history_search_internal: call dispose_saved_search_line + before calling make_history_line_current + +lib/readline/misc.c + - _rl_start_using_history: free the undo list associated with + _rl_saved_line_for_history, if one exists. Have to watch out for + this causing pointer aliasing problems, maybe add a call to + _hs_search_history_data() + + 4/28 + ---- +pathexp.c + - sh_globsort: a sort specifier of `nosort' disables sorting completely + +doc/bash.1,doc/bashref.texi + - GLOBSORT: document `nosort' sort specifier + +bashline.c + - attempt_shell_completion: attempt completion with the empty command + for a null command word on a line with only whitespace following any + optional assignment statements + - attempt_shell_completion: make sure that the start of the command + word is not after rl_point before calling the programmable completion + for the initial word. + From a report by Grisha Levit + +lib/readline/histexpand.c + - history_expand: don't read past the end of the string if it ends with + an incomplete multibyte character + From a report by Grisha Levit + + 5/1 + --- +lib/readline/text.c + - _rl_insert_char: make sure to return 1 in all cases where there are + pending bytes accumulating for a multibyte character + - _rl_insert_char: if the COUNT argument is 0, insert any pending + bytes read so far. The idea is that these bytes were accumulating + to compose a possible multibyte character, and the count of 0 + indicates that the current character doesn't contribute to that + because it's bound to an editing command. + - rl_insert, rl_quoted_insert: make sure to call _rl_insert_char + with a 0 count as appropriate to insert any accumulating bytes + From a patch by Grisha Levit + +sig.c + - top_level_cleanup,throw_to_top_level: set variable_context to 0, just + to make sure + +execute_cmd.c + - function_misc_cleanup: new function, runs make_funcname_visible and + unlink_fifo_list at the end of execute_function, replaces inline + code + - uw_function_misc_cleanup: unwind-protect function, just calls + function_misc_cleanup. Installed by execute_function. + Partial fix for FUNCNAME bug reported by Grisha Levit + - execute_builtin: run unwind-protects if evalnest exeeds max + - execute_builtin: run unwind-protects if sourcenest exeeds max + +parse.y + - parse_string_to_word_list: set current_token = '\n' on error + - parse_string_to_word_list: if we're executing and not running in + parse_and_execute, call top_level_cleanup before we jump to the + top level. Rest of fix for FUNCNAME bug + - parse_compound_assignment: set last_read_token and current_token to + '\n' on parse error. Fix for alias expansion bug reported by + Grisha Levit + - parse_compound_assignment: if we're executing and not running in + parse_and_execute, call top_level_cleanup before we jump to the + top level + + 5/2 + --- +jobs.c + - run_sigchld_trap: don't freeze and unfreeze the jobs list; move it + to the callers who are running this on SIGCHLD receipt and cannot + deal with jobs disappearing from the list while they're running + - waitchld: if we are running the wait builtin, continue to run the + SIGCHLD trap immediately upon signal receipt, but freeze and + unfreeze the jobs list around the call to run_sigchld_trap(). + Fixes issue with `jobs' in a SIGCHLD trap not removing jobs from + the jobs list reported by Guldrelokk + + 5/4 + --- +input.c + - fd_to_buffered_stream: make sure buffers[fd2] is non-null before + turning on SHAREDBUF. + From Emanuele Torre + +eval.c + - reader_loop: save and restore EOF_Reached around expanding $PS0, + setting it to 0 for the expansion so it doesn't affect things like + command substitution. + From a report by Grisha Levit + +parse.y + - parse_comsub: handle ${Ccommand; }, where C == space, tab, newline, + or '|' + - read_token_word: understand ${Ccommand; } and call parse_comsub to + parse the contents + - parse_matched_pair: understand ${Ccommand; } inside another paired + construct + - new `funsub' production, like comsub but for ${Ccommand;} nofork + command substitution + +execute_cmd.c + - execute_simple_command: if we fork because of pipes in or out, clear + the fifo list, since subshell aren't supposed to inherit fifos + + 5/8 + --- +parser.h + - PST_FUNSUBST: new parser state, parsing the command in ${Ccommand;}. + Primarily used to have read_token_word return `}' as a separate + token even if it's not delimited like a reserved word + +subst.h + - SX_FUNSUB: new flag, tell xparse_dolparen we are parsing the command + in a ${Ccommand;} nofork command substitution + +parse.y + - xparse_dolparen: handle parsing ${Ccommand;} nofork command + substitution like parse_comsub + - read_token: if we're parsing a foreground command substitution, + treat a word that begins with an unquoted `}' as a `}' token to + terminate the ${Ccommand;} construct without requiring that the + close brace be delimited like a reserved word + - no_semi_successors: add DOLBRACE + - reserved_word_acceptable: add DOLBRACE + +subst.c + - extract_function_subst: like extract_command_subst, but for nofork + command substitutions; calls xparse_dolparen with the SX_FUNSUB + flag to differentiate + - string_extract_double_quoted,extract_delimited_string, + extract_heredoc_dolbrace_string,extract_dollar_brace_string, + param_expand: call extract_function_subst as appropriate + - function_substitute: like command_substitute, but for nofork command + substitutions. Just a stub for now + + 5/11 + ---- +jobs.[ch] + - pipeline_saver: already_making_children now saved and restored as + part of the struct; no longer need a separate variable + - save_pipeline,restore_pipeline: save already_making_children to struct + +parse.y + - parse_comsub,xparse_dolparen: handle `(' as the first char of a + funsub (ksh93 supports that) + +subst.c + - function_substitute: complete implementation; handle both funsubs + and valsubs (need different terminology); dummy up a fake shell + function so local variables and `return' work; do the right thing + with process groups + - executing_funsub: flag for the rest of the shell to know we're + expanding a funsub; used by parse_and_execute + +builtins/evalstring.c + - parse_and_execute: check executing_funsub to do the right thing with + alias expansion and posix mode + + 5/12 + ---- +doc/bash.1,doc/bashref.texi + - function substitution (or lambda substitution, or nofork command + substitution): document + + 5/15 + ---- +subst.c + - function_substitute: make sure to decrement variable_context in the + unwind-protects since we don't unwind_protect it individually. + Report from Oguz + + 5/17 + ---- +configure.ac + - i370 machines cannot use the bash malloc + Patch from Igor Todorovski + +support/signames.c + - initialize_signames: add support for z/OS signals. + Patch from Igor Todorovski + +lib/glob/smatch.c + - collseqcmp: new name for collequiv[_wc], that function apparently + exists in libc on z/OS + Patch from Igor Todorovski + +jobs.c + - mark_all_jobs_as_dead: make sure to reset js.j_ndead to the right + number of jobs in the array + +execute_cmd.c + - execute_while_or_until: move call to REAP() after the action + executes, like other loop functions + +shell.c,parse.y,lib/intl/gettextP.h + - add some __MVS__ checks for z/OS systems + + 5/18 + ---- +jobs.c + - wait_for_any_job: catch jobs that can terminate and be reaped + when we call UNBLOCK_CHILD between the loop where we check the + jobs list for dead jobs and the loop where we check for running + jobs and poll for them with wait_for(). + Fixes bug reported by Aleksey Covacevice + + 5/20 + ---- +subst.c + - read_comsub: quote CTLNUL if it's in $IFS and we're parsing the + RHS of an assignment statement + - comsub_quote_string: ditto + - comsub_shouldquote: break code that decides whether to CTLESC escape + a character read from a command substitution or $REPLY into its own + inline function; change read_comsub/comsub_quote_string callers + + 5/21 + ---- +subst.c + - quote_escapes_internal: use ifs_cmap instead of iterating through + ifs_value to set skip_ctlesc and skip_ctlnul + + 5/23 + ---- +parser.h + - remove `(' from FUNSUB_CHARS + +parse.y + - parse_comsub: don't bother with `(' as one of the FUNSUB_CHARS + +doc/bash.1,doc/bashref.texi + - command substitution: remove mention of `(' as a valid character + following the open brace in nofork command substitution + + 5/24 + ---- +parse.y + - parse_comsub: avoid adding `;' to an empty ${ command substitution + - parse_comsub: if open == '{', push back a newline we read into + peekc to get PS2 prompting right. + From a report by Grisha Levit + +subst.c + - skip_double_quoted: pass the SX_COMPLETE flag down to + extract_dollar_brace_string in case it contains an unclosed command + substitution. + From a report by Grisha Levit + + 5/25 + ---- +shell.c + - make sure shell_initialized is set to 1 before running -c command + +make_cmd.c + - make_function_def: initialize source_file to something other than + `main' or `environment' if the shell is not interactive. + From a report from Emanuele Torre + +parse.y + - save_token_state,restore_token_state: save and restore token_to_read + - read_token_word: if we read EOF in an interactive shell, set + token_to_read to yacc_EOF and EOF_Reached to 1 so the token will + be delimited but the next call to read_token returns yacc_EOF + - handle_ignoreeof: broke the code that checks eof_encountered and + possibly exceeds the ignoreeof limit out into a separate public + function, called from handle_eof_input_unit + +eval.c + - reader_loop: if EOF_Reached is set in an interactive shell after + parse_command and execute_command, and ignoreeof has been enabled, + check for ignoreeof with handle_ignoreeof and reset EOF_Reached + back to 0 if we should not exit. This can occur when EOF delimits + a simple command (simple_command_terminator) + From a report by Grisha Levit + + 5/27 + ---- +lib/readline/mbutil.c + - _rl_get_char_len: if SRC is "", make sure to return 0 + +lib/readline/isearch.c + - _rl_isearch_callback: if _rl_search_getchar returns EOF, return 1 + to abort search; if it returns with RL_STATE_ISEARCH unset, return + 1 (handling a signal can turn it off via _rl_isearch_cleanup) + + 5/29 + ---- +lib/readline/text.c + - _rl_insert_char, rl_quoted_insert: minor fixes from Grisha Levit + +builtins/printf.def + - bexpand: use the same calculation for the size of the return buffer + as ansicstr(). + From a report by Grisha Levit + +locale.c + - locale_setblanks: work around problem with macOS where isblank(x) + incorrectly returns true for characters 0x80-0xff in a UTF-8 locale + From a report by Grisha Levit + - set_default_locale_vars,set_locale_vars,reset_locale_vars: make sure + we call locale_setblanks after setting/resetting locale_utf8locale, + since we use that in locale_setblanks + +lib/sh/smatch.c + - charseqcmp,is_cclass,FOLD: make sure we don't treat chars >= 0x80 + as valid in a UTF-8 locale, since they are multibyte characters. + From a report by Grisha Levit with a full + explanation in http://www.openradar.me/FB9973780 + + 5/30 + ---- +builtins/enable.def + - enable_builtin: don't call dlopen with a null pathname, it will + succeed. Report from Wiley Young + +lib/readline/readline.c + - _rl_dispatch_subseq: if a user binds do-lowercase-version to something + that isn't an uppercase character, flag an error rather than recurse. + From a report by Grisha Levit + + 5/31 + ---- +builtins/enable.def + - enable_builtin: don't try to load a builtin that's not found if + the -n flag is supplied. + From a report from Emanuele Torre + +parse.y + - parse_comsub: use was_word code again to make sure we add a closing + `;' if the last token parsed before the closing ';' or '\n' was a + word, no matter what character ends it. + From a report by Grisha Levit + +aclocal.m4,configure.ac,findcmd.c + - IBM z/OS changes from Igor Todorovski + + 6/1 + --- +parse.y + - shell_getc: if the shell is not interactive and reading from a + buffered stream or stdin, and not expanding an alias, add a + backslash to a line ending with like we do when + reading from a string. This prevents a backslash-newline from + being discarded when we are removing backslash-newlines from the + input, since we will add a newline to shell_input_line in this case. + From a report by Rob Landley + +parse.y + - parse_compound_assignment: check and compensate for an alias being + popped out from underneath this function by read_token() (e.g., + alias L='m=("x")'. Since we don't push a new input source, we should + never restore pushed_string_list from the saved parser state, but + we check and only do this if we were expanding an alias when this + function was called. + From a report by Wiley Young + + 6/2 + --- +print_cmd.c + - print_if_command: make sure to print any pending here-documents after + printing the test. + From https://bugzilla.redhat.com/show_bug.cgi?id=2211214 + +builtins/enable.def + - if -n is supplied with -f, attempt to load the builtin but mark it + as disabled after loading. + Suggested by Robert Elz + +builtins/evalfile.c + - _evalfile: increment retain_fifos, so we don't delete any FIFOs or + pipes we inherited before sourcing this file; restore original value + before we return. + From https://savannah.gnu.org/support/index.php?110883 + + 6/3 + --- +subst.c + - expand_string_dollar_quote: if singlequote_translations is set, there + is a chance for a use-after-free of `t'. + From a report by Grisha Levit + + 6/7 + --- +jobs.c,nojobs.c,jobs.h + - job_control_active_p: new function, returns 1 if job control is + currently enabled and we have given away the terminal + +builtins/evalstring.c + - should_suppress_fork: don't optimize away the fork if job control is + active because we need to call end_job_control and give the terminal + back to the original process group when this command finishes. Call + job_control_active_p() to check this. + Report from Andrew Hamon + + 6/8 + --- +shell.c + - ssh_run_startup_files: new variable, set by run_startup_files if + the shell decides it's being run by ssh and runs bashrc (only if + SSH_SOURCE_BASHRC is defined). Non-zero while the startup files + are being run. Not used by any other part of the shell yet. + + 6/12 + ---- +arrayfunc.h + - new inline functions to convert between assignment flags (ASS_*), + array value flags (AV_*), and valid array flags (VA_*) + +shell.h + - include arrayfunc.h after subst.h and variables.h so all the values + for the new inline functions are available + +variables.c + - bind_int_variable: use convert_assign_flags_to_validarray_flags and + convert_assign_flags_to_arrayval flags instead of inline assignments + +builtins/common.c + - builtin_bind_variable: use convert_assign_flags_to_validarray_flags + instead of inline assignments + +arrayfunc.c + - assign_array_element: use convert_assign_flags_to_arrayval_flags + instead of inline code + - assign_array_element_internal: use convert_assign_flags_to_arrayval_flags + to pass the right values to array_expand_index + - assign_array_var_from_string: since expand_compound_array_assignment + performs one round of expansion on the subscripts, make sure to add + ASS_NOEXPAND (if assoc_expand_once is set) and ASS_ALLOWALLSUB to the + flags we pass to assign_compound_array_list + - unbind_array_index: use convert_validarray_flags_to_array_value_flags + to pass the right values to array_expand_index + - array_expand_index: uncomment code tagged for bash-5.3 that checks + AV_NOEXPAND and suppresses call to expand_arith_string if it's set. + This set of changes extends assoc_expand_once to indexed arrays + +arrayfunc.[ch],execute_cmd.c,expr.c,test.c,builtins/common.c,builtins/mkbuiltins.c +builtins/declare.def,builtins/set.def,builtins/shopt.def + - array_expand_once: new name for internal assoc_expand_once variable + + 6/13 + ---- +builtins/shopt.def + - array_expand_once: new option, replaces assoc_expand_once + +doc/bash.1,doc/bashref.texi + - array_expand_once: document new shopt option + + 6/15 + ---- +lib/readline/complete.c + - rl_full_quoting_desired: new application-settable variable, if set + to non-zero by an application completion function, all completions + will be quoted as if they were filenames, subject to the value of + rl_filename_quote_characters. Initialized to 0 and reset to 0 + by set_completion_defaults. + From a contribution by Grisha Levit + - QUOTING_DESIRED: new macro to check whether we should quote completions + +lib/readline/readline.h + - rl_full_quoting_desired: extern declaration + +lib/readline/doc/rltech.texi + - rl_full_quoting_desired: document + +configure.ac + - bumped version to 5.3-devel + +pcomplete.h + - COPT_FULLQUOTE: new compspec option, for rl_full_quoting_desired + +pcomplete.c + - pcomp_set_readline_variables: set rl_full_quoting_desired according + to COPT_FULLQUOTE + +builtins/complete.def + - fullquote: add new complete/compopt option value + +doc/bash.1,lib/readline/doc/rluser.texi + - fullquote: document new complete/compopt option + +lib/sh/timeval.c + - timeval_to_secs: sfp argument is now a long *; there is a new + maxval argument (always 10^6 for now) that determines how to + round; returns tv_usec in *sfp if maxval == 10^6; otherwise + return value is basically tv_usec/maxval with rounding + - print_timeval: change argument type in call to timeval_to_secs + +lib/sh/clock.c + - clock_t_to_secs: sfp argument is now a long * + - print_clock_t: change argument type in call to clock_t_to_secs + +externs.h + - timeval_to_seconds, clock_t_to_seconds: change prototypes + +execute_cmd.c + - mkfmt,print_formatted_time: fractional seconds arguments are now + longs + - mkfmt: accept precisions up to 6; since sec_fraction is in usecs, + perform any necessary rounding for precisions < 6 + - print_formatted_time: allow precision specifiers up to 6; default + is still 3 + - time_command: fractional seconds variables are now long; add new + argument to timeval_to_secs (always 1000000) + - time_command: if we call clock_t_to_secs, multiply the return + fractional seconds value by 1000 to convert it from msec to usec + +doc/bash.1,doc/bashref.texi + - TIMEFORMAT: document that the max precision is now 6 + From https://savannah.gnu.org/support/?110343 + + 6/16 + ---- +variables.c + - get_monoseconds: use clock_gettime to return the value of the + system's monotonic clock, if available + - BASH_MONOSECONDS: a new dynamic variable that returns the value of + get_monoseconds + From a suggestion by William Kennington + +doc/bash.1,doc/bashref.texi + - BASH_MONOSECONDS: document + +trap.c + - save_bash_trapsig,set_bash_trapsig,restore_bash_trapsig: functions + to manage value of BASH_TRAPSIG + - run_pending_traps: save and restore the value of BASH_TRAPSIG; set + it to the numeric signal number of the trap being run while it's + executing + From a feature request by Eric Marceau + - _run_trap_internal,run_exit_trap: save and restore BASH_TRAPSIG; + make sure it's set appropriately + +doc/bash.1,doc/bashref.texi + - BASH_TRAPSIG: document + +builtins/declare.def + - declare_internal: if declare is supplied -f and an argument that + looks like an assignment statement, fail only if there is not a + function with that name already defined. + From a report from Emanuele Torre + back in 12/22 + +jobs.c + - wait_for: make checkwinsize work in subshell commands started from + interactive shells + New feature request by Kerin Millar + +print_cmd.c + - semicolon: don't return immediately unless a preceding `&' is + itself preceded by a space, as the rest of the printing code prints + asynchronous commands. + Report and patch by Grisha Levit + + 6/17 + ---- +arrayfunc.c + - arrayvar_copyval: copy an array or hash table from shell variable + V1 to V2 + +arrayfunc.h + - arrayvar_copyval: extern declaration + +subst.h + - ASS_NOTEMPENV: new flag for bind_variable and assignments + +variables.c + - bind_variable: if ASS_NOTEMPENV is in FLAGS, don't bother calling + bind_tempenv_variable + +builtins/declare.def + - declare_internal: if we find the variable in the temporary + environment, call bind_variable with the ASS_NOTEMPENV flag since + we are already dealing with a variable from the temporary environment + - declare_internal: if we bind a new global variable because we're + modifying a variable from the temporary environment, make sure to + call arrayvar_copyval to copy array variables from the temporary + environment to the global scope + +variables.c + - push_temp_var: if we are pushing an array variable, make sure to + call arrayvar_copyval on the new variable + Final fix for bug reported by Wiley Young + - push_posix_tempvar_internal: call arrayar_copyval instead of using + inline code + + 6/19 + ---- +lib/sh/shmatch.c + - sh_regmatch: use builtin_find_indexed_array to allow a local copy + of BASH_REMATCH. + From https://lists.gnu.org/archive/html/bug-bash/2022-05/msg00052.html + +execute_cmd.c + - execute_in_subshell: tentative change to clear procsub list after + performing redirections, so nothing in a redirection can affect + what's in the subshell. + From https://lists.gnu.org/archive/html/bug-bash/2022-10/msg00114.html + +test.c + - binary_operator: in posix mode, the < and > operators compare strings + using the current locale (strcoll). + From https://www.austingroupbugs.net/view.php?id=375 + +bashline.c + - bash_default_completion: make sure that command completion adds the + trailing `/' suffix for directories even if the directory name is + the same as the common prefix of matches. + From https://lists.gnu.org/archive/html/bug-bash/2022-11/msg00034.html + +lib/readline/kill.c + - rl_vi_yank_pop: make repeated invocations of vi-yank-pop cycle + through the kill ring just like in emacs mode, even when point + is at the end of the line. + From https://lists.gnu.org/archive/html/bug-bash/2022-08/msg00105.html + +parse.y + - parse_comsub: set variables if the last token (last_read_token) is + `;', `\n', or `&', in addition to was_word + - parse_comsub: if the last read token was a newline (was_newline), + terminate the comsub with a newline instead of a semicolon; keeps + the line numbers more consistent. + From a report by Grisha Levit + +lib/sh/anonfile.c + - anonopen: use memfd_create if it is available, fall through to + traditional Unix/POSIX implementation if it fails + + 6/20 + ---- +parse.y + - yy_string_unget: don't push EOF back to a string, like the other + unget functions + + 6/21 + ---- +parse.y + - read_a_line: don't push an EOF back into the string or line if the + line ends in a backslash. + From a report by Rob Landley + + 6/22 + ---- +lib/readline/input.c + - rl_gather_tyi: make sure result is initialized + +lib/readline/kill.c + - _rl_read_bracketed_paste_prefix: make sure key is initialized + +builtins/read.def + - read_builtin: make sure pass_next and saw_escape are initialized + before a possible goto + - read_builtin: make sure to initialize prevset for very short + timeouts + +subst.c + - function_substitute: make sure tflag is initialized even when we + don't call read_comsub, since we return it in ret->flags + All from a report by Grisha Levit + +builtins/complete.def + - compgen_builtin: use array_from_argv to assign elements of the + stringlist to the array variable. + Update from Grisha Levit + +builtins/cd.def + - bindpwd: fix seg fault from an unlikely set of circumstances + From a report by Grisha Levit + +arrayfunc.h + - convert_validarray_flags_to_arrayval_flags: initialize avflags + From a report by Grisha Levit + +lib/sh/anonfile.c + - anonopen: set *fn if memfd_create is used + From a report by Grisha Levit + + 6/23 + ---- +arrayfunc.c + - bind_assoc_var_internal: free key to fix small leak if assign_func + used + - quote_compound_array_word: free value to fix small leak + +builtins/evalstring.c + - parse_and_execute: free parsed command on failed function definition + import + - open_redir_file: free FN if we're not passing it back to the caller + +subst.c + - param_expand: free TEMP1 in code paths that don't do it now + +bashline.c + - bash_command_name_stat_hook: if we modify *NAME, free the old value + +examples/loadables/{kv,stat}.c + - bind_assoc_variable is caller-free VALUE, so free when needed and + don't allocate a new copy if not + All from a report by Grisha Levit + + 6/24 + ---- +lib/readline/complete.c + - rl_menu_complete: use _rl_free_match_list instead of just freeing + MATCHES if we have too many possible completions to display. + From a report by Grisha Levit + + 6/25 + ---- +eval.c + - reader_loop: make sure to allow exit builtin (code == EXITBLTIN) to + exit the shell when ignoreeof is set + From a report by Grisha Levit + + 6/26 + ---- +lib/readline/complete.c + - complete_sigcleanarg_t: new struct to hold match list and saved line + buffer for cleanup on receipt of SIGINT + - _rl_complete_sigcleanup: use new sigcleanarg_t struct and free both + members + - rl_complete_internal: whenever we display the match list, set up to + clean the matches and saved line buffer in the event of a SIGINT + From a report by Grisha Levit + +lib/readline/signals.c + - _rl_handle_signal: if readline is compiled to include callbacks, only + call rl_echo_signal_char if we're not in callback mode or the + application has set rl_persistent_signal_handlers, leaving any + application signal handler to call it (or not) otherwise. + From a discussion with Andrew Burgess + +lib/glob/glob.c + - glob_filename: if ARRAY == TEMP_RESULTS, make sure to free TEMP_RESULTS + after copying the filenames out of ARRAY, since we either assigned it + directly or glob_dir_to_array returned it because the dirname was + the empty string. + From a report by Grisha Levit + +lib/readline/rltypedefs.h + - Function: only compile in these obsolete typedefs if + WANT_OBSOLETE_TYPEDEFS is defined + +print_cmd.c + - xtrace_print_assignment,xtrace_print_word_list: prioritize checking + for characters that need $'...' printing over shell metacharacters + so that strings containing both get the $'...' treatment + From a report by Grisha Levit + + 6/27 + ---- +subst.c + - skip_double_quoted: make sure to call extract_function_subst with + the SX_NOALLOC flag + From a report by Grisha Levit + +trap.c + - _run_trap_internal: if we're running a trap but shell_eof_token is + set, this means we're somehow running a trap while parsing a + command substitution (weird set of circumstances). Call + reset_parser and unset shell_eof_token if shell_eof_token is set + From a report by Wiley Young + +builtins/setattr.def + - set_var_attribute: don't set the att_propagate attribute unless the + variable whose attribute is being modified is in the temporary + environment for this builtin, not any previous temporary environments + (like the temp env for a function call, or a special builtin like + `.') + +variables.c + - push_posix_temp_var: if we have an array variable we're trying to + push up here, use arrayvar_copyval to copy the value correctly + +arrayfunc.c + - arrayvar_copyval: make sure that V2 ends up being the same type of + array as V1 (att_array or att_assoc), since we're copying the value. + Fixes issue reported by Grisha Levit , but + with the previous fix to set_var_attribute, it's not needed + - assign_compound_array_list: check for integer overflow if the max + index of the array is already INT_MAX. + From a report from Emanuele Torre + - assign_array_var_from_word_list: ditto + + 6/28 + ---- +pcomplete.c,bashline.c + - uw_restore_parser_state,uw_rl_set_signals: move to bashline.c so the + general readline support can use them + +bashline.h + - uw_restore_parser_state,uw_rl_set_signals: extern declarations + +bashline.c + - unset_readline_variables,uw_unset_readline_variables: function to + unset READLINE_{LINE,POINT,MARK,ARGUMENT} and its unwind-protect + counterpart + - bash_execute_unix_command: add unwind-protect to free up allocated + memory + Report and patch by Grisha Levit + +doc/bash.1,doc/bashref.texi + - BASH_ARGC,BASH_ARGV,BASH_SOURCE,BASH_LINENO: note that these variables + may not be assigned to or unset + + 6/29 + ---- +builtins/declare.def + - declare_internal: attempting to assign to a noassign variable is no + longer an assignment error; the attempt is just ignored + +arrayfunc.c + - find_or_make_array_variable: take a new flag value, 4: means to + return noassign variables as themselves instead of NULL without + performing the assignment so the caller can handle them differently. + - assign_array_from_string: pass flags & 4 to find_or_make_array_variable + so we can simply ignore attempted assignments to noassign array + variables instead of treating them as assignment errors + From a report by Kerin Millar + +expr.c + - exppower: only report negative exponent error if noeval == 0. + Fixes issue reported by Steffen Nurpmeso + + 6/30 + ---- +lib/sh/anonfile.c + - anonopen: add support for using shm_open or shm_mkstemp to create + an anonymous file using POSIX shared memory + +configure.ac + - if --enable-static-link is supplied, add -static to LDFLAGS on + Linux if opt_profiling isn't enabled + From a report from Emanuele Torre + +print_cmd.c + - make_command_string_internal: if we're recursively printing a list + (connection) with more than two elements, don't print any deferred + here-documents after the make_command_string_internal on the right + side of the connection unless we're at the end of the list + (printing_connection == 1). This way the caller gets to add the + appropriate connector before printing the deferred here-documents. + From a report by Grisha Levit + - make_command_string_internal,print_group_command: after we call + PRINT_DEFERRED_HEREDOCS and follow it with a closing `)' (subshell) + or `}' (group command), we can set was_heredoc to 0 because we are + no longer printing a here-document + From a report by Grisha Levit + + 7/3 + --- +lib/readline/complete.c + - rl_username_completion_function: simplify things by just skipping the + function body if HAVE_GETPWENT is not defined. + From a report by Grisha Levit + +lib/sh/ufuncs.c + - fsleep: broke into three functions: nsleep, which uses nanosleep, + ssleep, which uses select/pselect, and ancientsleep, which uses + sleep. Prefer nanosleep, use the others depending on what's + defined. + From a report and patch by Grisha Levit + +arrayfunc.c + - assign_compound_array_list: now behaves more like a series of + assignment statements (a=(one two) is more like a[0]=one a[1]=two) + in terms of error handling -- break after the first invalid + assignment -- and return value -- now return int, 0 on failure and + 1 on success so the callers can throw assignment errors + - assign_compound_array_list: if we have an explicit [subscript]=value + assignment, use the negative-indices-count-back-from-the-end strategy; + otherwise use last_ind and throw an error on overflow. This is like + standalone assignment statements + - assign_array_var_from_string: catch new return value from + assign_compound_array_list; return NULL if assign_compound_array_list + returns failure + +subst.c + - do_compound_assignment: if assign_compound_array_list or + assign_array_var_from_string return error (0 or NULL, respectively), + treat as an assignment error similar to assigning to a readonly + variable + Inspired by a report from Emanuele Torre + +arrayfunc.h + - assign_compound_array_list: new return type + + 7/5 + --- +builtins/enable.def + - enable_builtin: make sure dynamic builtin loading and unloading + updates the `enabled' and `disabled' programmable completion lists. + From a report and patch by Grisha Levit + +doc/bash.1,doc/bashref.texi + - hash: add note that assigment to PATH clears the hash table. + Report by Sebastian Carlos + +lib/readline/complete.c + - rl_filename_completion_function: make sure the results of + *rl_filename_rewrite_hook are freed consistently if the function + returns newly-allocated memory + From a report and patch by Grisha Levit + back in May + + 7/6 + --- +builtins/cd.def + - cd_builtin: if $OLDPWD is set by the user or script to something + that's not a full pathname, allow it to use $CDPATH. + From a report by Dustin Boyd + + 7/7 + --- +shell.h + - user_info: add members for saved uid and saved gid + +shell.c + - uidget: if we have setresuid/setresgid, get the saved uid and saved + gid so we can set them if we disable privileged mode + - disable_priv_mode: only call setuid/setresuid and setgid/setresgid + if the euid (egid) != uid (gid). If we have setresuid/setresgid, + add a check whether the saved uid (gid) isn't the same as the real + uid (gid). Potentially saves a couple of system calls. + Fixes Android issue, patch by Grisha Levit + +test.c + - unary_operator: only support historical handling of -t and its + optional argument when not in posix mode + - unary_test: print an error if the argument to -t is not a number + - unary_operator: only make the argument to -t optional if the + next argument is -a or -o and we are using the historical algorithm + (argc >= 5), otherwise force it to be a number and print an error + message if it's not + From a report by Stephane Chazelas + +doc/bash.1,doc/bashref.texi + - added note about test/[ sorting using the current locale with the + `<' and `>' operators when in posix mode + - added note about the integer argument to test -t being required + when in posix mode + - added note recommending against the use of test with 5 or more + arguments in favor of combining multiple instances of test with + && or || + From a report by Stephane Chazelas + + 7/10 + ---- +jobs.c + - start_job: turn off (on) the J_ASYNC flag depending on whether the + job is being started in the foreground (background). It matters now + that we use IS_ASYNC to determine whether to give the terminal + back to the shell's process group. + From a report by Grisha Levit + +bashline.c + - command_word_completion_function: if we have a glob pattern that + expands to multiple words, dispose of the list before returning NULL. + From a report by Grisha Levit + +variables.c + - makunbound: if we're unsetting a local variable, preserve the export + attribute even if the variable's not in the temporary environment + Tentative fix, compatible with other POSIX shells (except the BSD + variants of ash) + + 7/12 + ---- +lib/sh/unicode.c + - include if HAVE_LANGINFO_CODESET is defined, use + nl_langinfo (CODESET) if HAVE_LANGINFO_CODESET is define, since + we no longer check for nl_langinfo. This is what locale.c does. + + 7/15 + ---- +lib/readline/display.c + - rl_redisplay: rudimentary code to handle some cases where the line + buffer consumes more than the physical number of screen lines. It's + not a screen editor, but it handles some of the common cases. + From https://bugs.launchpad.net/ubuntu/+source/bash/+bug/2024628 + + 7/17 + ---- +builtins/printf.def + - getwidestr: make sure to force mbsrtowcs to convert the closing NULL + so the wide-character string is NULL-terminated. + From a report by Grisha Levit + +lib/sh/shmatch.c + - strregerror: new function to return regerror(3) error message text + in allocated memory + - sh_regmatch: add an additional argument to hold the error message + from regerror(3), in newly-allocated memory; generated by call to + strregerror() on regcomp(3) failure + From a patch by Grisha Levit + +externs.h + - sh_regmatch: update extern declaration + +execute_cmd.c + - execute_cond_node: pass pointer to buffer to return any error + message; if sh_regmatch returns 2, use a non-NULL error buffer in + the error message. + +lib/readline/bind.c + - _rl_get_string_variable_value: return the values for + active-region-start-color (_rl_active_region_start_color) and + active-region-end-color (_rl_active_region_end_color) if they + are set. + Fixes bind -v issue reported by Sebastian Carlos + - _rl_get_string_variable_value: if the history is stifled, make + sure we report the history size as < 0 so the output of bind -v + can be reused as input. + Fixes bind -v issue reported by Sebastian Carlos + + 7/20 + ---- +pathexp.c + - quote_string_for_globbing: don't bother backslash-quoting multibyte + characters. It matters for macOS and doesn't make a difference for + other systems, and those aren't going to be special globbing chars. + From a report by Grisha Levit + +lib/glob/glob.c + - glob_vector: normalize the pattern with fnx_fromfs so we make sure + it's also in NFC on macOS (other systems don't care). This is a + POSIX violation, but part of correcting the longtime HFS+ (and Finder) + misfeature + +lib/readline/complete.c + - rl_filename_completion_function: if the application sets a filename + rewrite hook, use it to rewrite the filename we're matching as well + as filenames read with readdir(). + [SUPERSEDED BY CHANGE OF 10/4/2023] + From a report by Grisha Levit + + 7/21 + ---- +pathexp.c + - quote_string_for_globbing: see if we can get away without backslash- + quoting single-byte characters that aren't CTLESC or characters + that are special to EREs or BREs, even if they're quoted + +bashline.c + - bashline_set_filename_hooks: convenience function to set the + directory hook and the filename rewrite and stat hooks; call from + other places in the file so these are set consistently + +bashline.h + - bashline_set_filename_hooks: extern declaration + +builtins/complete.def + - compgen_builtin: make sure to set the directory and filename hooks + so compgen called from a script works more like compgen called + from a word completion context. + Inspired by a report by Grisha Levit + +doc/Makefile.in + - bash.pdf: use groff -T pdf to create, instead of creating postscript + and then using ghostscript + + 7/24 + ---- +jobs.c + - start_job: unconditionally send SIGCONT to the job we just started, + even if we think it was already running, to reduce the window for a + potential race condition, and only change the state to RUNNING if + the SIGCONT succeeds or if the process has terminated so we can + clean it up later. + Report from Earl Chew + +make_cmd.c + - make_simple_command,make_bare_simple_command: now take line number as + an argument; used instead of line_number to set the line associated + with the simple command + +make_cmd.h + - make_simple_command,make_bare_simple_command: change prototype + +parse.y,builtins/command.def,builtins.jobs.def + - make_simple_command,make_bare_simple_command: change callers + + 7/25 + ---- +parse.y + - read_token_word: try to keep track of whether we are parsing the + first word of a simple command and set simplecmd_lineno if we + are. We start a simple command when we return ASSIGNMENT_WORD + or WORD in a command token position. This gives better values for + $LINENO in multi-line simple commands + - redirection: set simplecmd_lineno if it's -1, meaning this is a + simple command with a leading redirection or a null command with + only a redirection + - pass simplecmd_lineno to make_simple_command if we are starting a + simple command (the first ELEMENT) + - parse_comsub,xparse_dolparen: save and restore simplecmd_lineno + - simple_command,function_def production: reset simplecmd_lineno to -1 + after parsing a simple command or a function declared as WORD() + + 7/26 + ---- +doc/bash.1,doc/bashref.texi + - xpg_echo: add description of how this can be used to suppress echo + option interpretation + Inspired by report from Zachary Santer + + 7/27 + ---- +builtins/printf.def + - printf_erange: make out-of-range errors conversion errors even if + the conversion function fully consumes the argument. + From a report by thomas@habets.se + + 7/31 + ---- +lib/readline/rltypedefs.h + - rl_macro_print_func_t: typedef for a function to print macro key + bindings + +lib/readline/bind.c + - rl_macro_display_hook: hook function to call if the application + wants to display a key sequence bound to a macro + - rl_macro_dumper: if rl_macro_display_hook is non-NULL, call it to + display the macro value (after `untranslating' it to add back any + required backslashes) + +lib/readline/doc/rltech.texi + - rl_macro_display_hook: add description + +pathexp.c + - glob_char_p: add the characters that are special within BRE bracket + expressions. + Inspired by a report by Grisha Levit + +bashline.c + - bind_keyseq_to_unix_command: allow whitespace to separate the keyseq + and the command string, but require the command string to be + surrounded by double quotes if it is. If we get a whitespace + separator, call rl_macro_bind so we get the string `translated' + according to how readline does it (backslash-escape sequences + processed, etc.) + - print_unix_command: function to print a key sequence and a unix + command bound to it from cmd_xmap, using a space separator + - print_unix_command_map: make sure to set rl_macro_display_hook to + print_unix_command before calling rl_macro_dumper to print the + bound command strings + + 8/1 + --- +builtins/read.def + - read_builtin: saw_escape is now a count of CTLESCs we added to the + input + - read_builtin: since we increment saw_escape when we add a CTLESC, + decrement it when we remove one from the input (\\\n, \\\0) + - read_builtin: remove the CTLESC we added if we have a backslash- + escaped NULL character ('\0') + - read_builtin: if the input ends with an unescaped newline, remove + the CTLESC we added + From a report by Grisha Levit + + 8/2 + --- +builtins/history.def + - history_builtin: if history -[anrw] is used without a filename + argument, and HISTFILE is unset or null, return success immediately + From a report by Grisha Levit + +doc/{bash.1,bashref.texi},lib/readline/doc/hsuser.texi + - history: document that if filename is not supplied, and HISTFILE is + unset or null, the [-anrw] options have no effect + + 8/3 + --- +pcomplete.c + - gen_progcomp_completions: if the actual compspec that's run is + something different from what's typed (full pathname, alias, etc.), + set pcomp_curcmd to the word corresponding to the actual compspec, + instead of what was typed. This is what eventually gets used by + the compopt builtin's output. + From a report by Grisha Levit + +execute_cmd.c + - execute_coproc: in parent, close /dev/fd FIFOs only if we're not + executing a shell function, like other calls to unlink_fifo_list(). + Report from Hal Blackburn in + https://savannah.gnu.org/support/index.php?110910 + +subst.c + - do_compound_assignment: don't attempt to convert a global associative + array to an indexed array with declare -g. + From a report and patch by Grisha Levit + + 8/7 + --- +lib/readline/bind.c + - rl_print_keybinding: new function, prints a the key bindings for a + single function specified by name + - rl_function_dumper: call rl_print_keybinding for every function name + +lib/readline/readline.h + - rl_print_keybinding: extern declaration + +lib/readline/bind.c + - _rl_untranslate_macro_value: make sure characters betweeen 128 and + 159 (metafied control characters) are printed using the \M-\C- + notation instead of directly writing the control character. + From a report and patch by Grisha Levit + - rl_get_keyname: if a key binding shadows a function or macro, print + the ANYOTHERKEY binding as a null string + From a report and patch by Grisha Levit + - rl_untranslate_keyseq: make changes analogous to + _rl_untranslate_macro_value so that we don't print control characters + directly + - rl_invoking_keyseqs_in_map: if the key corresponds to a keymap, use + _rl_get_keyname to get its text representation, so this function + returns consistent results + - rl_translate_keyseq: if convert-meta is on, don't convert meta chars + that are, e.g., \M-\C-@ (128) into \e followed by a NUL, resulting + in truncated key sequences. Just don't honor convert-meta in this + case + + 8/8 + --- +bashhist.c + - bash_history_no_expand_chars: add the rest of the shell + metacharacters so we don't get empty history events; tcsh does more + or less the same thing + Inspired by a report from Emanuele Torre + + 8/9 + --- +parse.y + - grammar: change bare `time' and `!' productions to use nullcmd_terminator, + which is a list_terminator or a `&' to allow things like `time &' + and `! &' which the original version of POSIX interp 267 (the one + I implemented) says we should support + + 8/11 + ---- +m4/bison.m4,m4/flexmember.m4,m4/locale_h.m4 + - new m4 files from gettext-0.21.1 + +m4/gettext.m4,m4/intl.m4 +m4/{codeset,extern-inline,fcntl-o,glibc2,glibc21,host-cpu-c-abi,iconv,intdiv0}.$ +m4/{intl-thread-locale,intlmacosx,intmax,inttypes-pri,inttypes,inttypes_h}.m4 +m4/{lcmessage,lib-ld,lib-link,lib-prefix,locale_h,lock,nls,po,printf-posix}.m4 +m4/{progtest,pthread_rwlock_rdlock,size_max,stdint_h,strtoimax,threadlib}.m4 +m4/{uintmax_t,ulonglong,visibility,wchar_t,wint_t,xsize}.m4 + - updated m4 files from gettext-0.21.1 + +configure.ac,config.h.in + - updated autoconf files with changes for gettext-0.21.1 + +MANIFEST + - updated distribution manifest with new files from gettext-0.21.1 + +lib/sh/unicode.c + - u32cconv: prefer nl_langinfo to locale_charset like locale.c: + locale_isutf8() + +execute_cmd.c + - uw_restore_lineno: an unwind-protect fuction to restore a saved + line_number + - execute_command: add an unwind-protect to restore line_number in + case execute_simple_command longjmps back to top_level or a + return context. + Side effect of https://savannah.gnu.org/support/index.php?110919 + - execute_for_command, execute_select_command, execute_case_command: + add unwind-protect to restore line_number (could also do it for + if, while, until but those don't modify line_number) + - execute_command_internal: add_unwind_protect to restore line number + for arith, cond, function def commands + + 8/14 + ---- +execute_cmd.c + - execute_simple_command: don't call savestring on the_printed_command_except_trap + if it's NULL. + From a report by Grisha Levit + + 8/15 + ---- +lib/readline/rltty.c + - prepare_terminal_settings: replace USE_XON_XOFF macro with private + variable _rl_use_tty_xon_xoff (initially set to 1); if it's set to + 0 disable the tty start and stop characters. Prep for making it a + bindable variable setting + +builtins/read.def + - edit_line: now takes a third argument saying whether or not to + set rl_attempted_completion_function to NULL to use readline's + default filename completion (the default) + - read_builtin: new option -E to use readline and use the bash + default completion (that is, leave rl_attempted_completion_function + unchanged) + From a suggestion by konsolebox back in 5/2021 + + +doc/bash.1,doc/bashref.texi + - read: document new -E option + + 8/17 + ---- +aclocal.m4 + - BASH_CHECK_LIB_TERMCAP: add a check for bash_cv_termcap_lib == + "libcurses"; set TERMCAP_LIB=-lcurses in this case + + 8/18 + ---- +subst.c + - bash_variable_assignment_error: new function, implements default mode + behavior for variable assignment errors + - posix_variable_assignment_error: new function, implements posix mode + behavior for variable assignment errors + - parameter_brace_expand_rhs,expand_declaration_argument, + do_assignment_statements: call posix_variable_assignment_error or + bash_variable_assignment_error as appropriate + + 8/21 + ---- +lib/readline/misc.c + - _rl_arg_dispatch: add the digits or other characters to + rl_executing_keyseq if we're not calling _rl_dispatch. + From a report by Grisha Levit + +print_cmd.c + - print_simple_command: make sure that the_printed_command[0] == '\0' + if we're printing a null simple command with no words + Patch by Grisha Levit + + 8/22 + ---- +builtins/read.def + - read_builtin: make `delim' variable local, pass to edit_line to + set the last character of the returned line; change edit_line + prototype. + From a suggestion by Grisha Levit + + 8/23 + ---- +parse.y + - comsub and funsub productions: don't reset eof_encountered to 0 in + the action + +subst.c + - function_substitute: unwind-protect eof_encountered so ignoreeof + doesn't keep getting reset to 0 if PS1 includes a ${ ...;} command. + From a report by Grisha Levit + + 8/25 + ---- +doc/{bash.1,bashref.texi} + - clarify the cases where arrayname[@] doesn't refer to all the + elements of an associative array (the unset builtin and test/[/[[ -v + for now) + Inspired by https://savannah.gnu.org/support/index.php?110924 + + 8/28 + ---- +execute_cmd.c + - execute_for_command,execute_select_command,execute_arith_command, + execute_case_command: fix up order in which BASH_COMMAND is set, + the DEBUG trap is run, and PS4 is printed. + From a report by Grisha Levit + +lib/readline/colors.c + - RL_COLOR_PREFIX_EXTENSION: make sure the custom suffix has a leading + `.' + Report and fix from Stefan Klinger + +lib/readline/parse-colors.c + - free_color_ext_list: new function, called on parse error, frees the + list of extensions + - rl_reparse_colors: new public function, frees old extension list and + reparses (presumably new) value of LS_COLORS; some minimal checking + to make sure the value has really changed + + 9/1 + --- +parse.y + - time_command_acceptable: make sure `time' is recognized as a + reserved word after DOLPAREN and DOLBRACE. + Report from Dima Korobskiy + +builtins/printf.def + - printf_builtin: make 'C' equivalent to 'lc'; 'S' equivalent to 'ls' + as POSIX specifies + + 9/6 + --- +eval.c + - parse_command: don't run pending traps if we're parsing a command + substitution + From a report from Emanuele Torre + + 9/8 + --- +jobs.c + - stop_pipeline: don't have the parent set the terminal pgrp; rely on + child processes to do it to avoid potential race conditions. + From a discussion beginning at + https://lists.gnu.org/archive/html/bug-bash/2023-08/msg00087.html + +builtins/printf.def + - bexpand: when parsing the string to be expanded, consume entire + multibyte characters at a time, in case their encoding includes a + '\\' + - printf_builtin: when parsing the format string, consume entire + multibyte characters at a time unless they begin with '\\' or '%', + to avoid characters whose encoding contains those characters + + 9/11 + ---- +builtins/hash.def + - hash_builtin: if the -p option is supplied without a name to hash, + it's an error + +hashcmd.c + - phash_remove: if the hash table is empty, return 1 like unalias does + when the alias isn't in the hash table. + Report from from Mike Jonkmans + + 9/13 + ---- +test.c + - binary_test,unary_test: now static + - cond_test: new function, calls binary_test or unary_test as appropriate + and handles longjmps from test_syntax_error + +test.h + - cond_test: extern declaration + +execute_cmd.c + - execute_cond_node: call cond_test instead of binary_test or unary_test. + From a report and patch from Grisha Levit + +doc/bash.1,doc/bashref.texi + - hash: add some text about the mutual exclusivity of the -t, -p, and + -d options + + 9/14 + ---- +subst.c,subst.h,externs.h + - string_extract,string_extract_verbatim,string_extract_double_quoted, + string_extract_single_quoted,skip_single_quoted,skip_double_quoted, + extract_delimited_string,extract_heredoc_dolbrace_string, + extract_dollar_brace_string,parameter_brace_expand,param_expand, + extract_command_subst,extract_function_subst,extract_arithmetic_subst, + extract_process_subst,extract_array_assignment_list, + expand_array_subscript + change function signatures to take size_t * instead of int * for + arguments that are string indices or lengths, change callers + - unquoted_substring,unquoted_member,string_extract, + string_extract_double_quoted,skip_double_quoted, + string_extract_single_quoted,skip_single_quoted, + string_extract_verbatim,extract_delimited_string, + extract_heredoc_dolbrace_string,extract_dollar_brace_string, + parameter_brace_expand,param_expand,skip_matched_pair,skip_to_delim, + skip_to_histexp,list_string,expand_string_dollar_quote, + parameter_brace_expand_rhs,expand_array_subscript,shouldexp_replacement, + expand_array_subscript,string_quote_removal: change variables used + for string indexes to size_t + [merge from size_t branch] + +arrayfunc.c + - expand_compound_array_assignment: use size_t for string indices + +braces.c + - brace_gobbler: use size_t for string indices + +parse.y + - xparse_dolparen: change function signature to use size_t * + instead of int * for string index, use size_t for string indices + +general.c, general.h + - bash_tilde_find_word: change function signature to use size_t * + instead of int * for string index + +lib/readline/readline.h + - rl_reparse_colors: extern declaration + +lib/readline/doc/rltech.texi + - rl_reparse_colors: document as public function + + 9/21 + ---- +pcomplete.c + - it_init_aliases: move the free (alias_list) inside #ifdef ALIAS. + Report and fix from Mike Jonkmans + +redir.c + - redirection_error: set W_NOPROCSUB in the word redirection_error + creates to call redirection_expand + +builtins/bind.def + - bind_builtin: use CASE_HELPOPT so the long doc gets printed when + --help is supplied + +builtins/getopts.def + - getopts_builtin: change to use no_options() + + 9/22 + ---- +execute_cmd.c + - execute_select_command: in posix mode, an invalid selection variable + name is a fatal error, just like with `for'. This is compatible with + ksh93 and mksh + + 9/25 + ---- +subst.c + - parameter_brace_expand_length: rearrange the code slightly to reduce + the number of find_variable calls. This matters if the variable is + dynamic and produces a new value each time (e.g., RANDOM). + + 9/26 + ---- +builtins/shift.def + - shift_builtin: if get_numeric_arg returns a number out of range and + we're going to print an error message, make sure to skip over an + argument of `--' so we can print the right argument + +builtins/break.def + - break_builtin,continue_builtin: ditto with get_numeric_arg and `--' + + 9/28 + ---- +builtins/history.def + - history_builtin: changed error message if the numeric argument to -d + is invalid + + 9/29 + ---- +subst.c + - array_length_reference: include the open bracket in the error message + passed to err_badarraysub; it looks cleaner + + 10/2 + ---- +jobs.c + - delete_all_jobs: if we are clearing the jobs list, reset the stats + about running and dead jobs and child processes + Report from Koichi Murase + + 10/4 + ---- +lib/readline/complete.c + - rl_completion_rewrite_hook: rewrite hook applied to the completion + word before comparing against the possible completions from the + file system (modified by rl_filename_rewrite_hook) + - rl_filename_completion_function: call rl_completion_rewrite_hook, + if set by the calling application, on the filename portion of the + word to be completed + +lib/readline/readline.h + - rl_completion_rewrite_hook: extern declaration + +bashline.c + - bash_set_filename_hooks: set rl_completion_rewrite_hook to + bash_filename_rewrite_hook now that we've separated them + From a report and patch from Grisha Levit ; + original report from Stefan H. Holek + +lib/readline/doc/rltech.texi + - rl_completion_rewrite_hook: document + + 10/5 + ---- +lib/readline/complete.c + - rl_complete_internal: use `%' as an op character to indicate that + we should just display the completions, like '?' in previous versions + (nothing uses this yet) + - rl_possible_completions: set last_completion_failed to 0 before we + pass '?' to rl_complete_internal so we don't worry about trying to + insert a single completion + + 10/6 + ---- +subst.c + - string_transform: use ansicstr directly for the `E' transformation + so we don't accidentally remove too many escapes. + From a report and patch from Grisha Levit + +execute_cmd.c + - execute_arith_for_command: make sure a failed init expression resets + loop_level so break and continue work correctly + From a report and patch from Grisha Levit + - execute_for_command: set line_number for invalid identifier error + messages; restore before returning error + From a report and patch from Grisha Levit + +lib/readline/misc.c + - _rl_set_insert_mode: manage RL_STATE_OVERWRITE when modifiying + insert mode + +doc/bash.1,doc/bashref.texi + - some style and formatting changes from Bjarni Ingi Gislason + + +subst.c + - getifs: now returns allocated memory to insulate it from changes to + $IFS + +builtins/read.def + - read_builtin: since getifs now returns allocated memory, note when + we need to free ifs_chars and free it before returning. + Reported by Robert Elz in + https://www.austingroupbugs.net/view.php?id=1778#c6513 + + 10/7 + ---- +pathexp.c + - glob_char_p: add more of the extglob pattern characters; it doesn't + hurt to quote them + Report and patch from Grisha Levit + - unquoted_glob_pattern_p: don't treat a `(' immediately following a + `/' as a potential globbing character + - unquoted_glob_pattern_p: only treat the extended glob characters + followed by a `(' as a glob pattern if extended_glob is enabled + - unquoted_glob_pattern_p: an unquoted backslash isn't treated + specially any more, but if it's followed by a CTLESC, you still + don't treat the next character as an unquoted globbing char + Report and patch from Grisha Levit + + 10/9 + ---- +builtins/common.c + - get_numeric_arg: if fatal > 0, set the exit status to EX_USAGE + and call jump_to_top_level with EXITPROG or DISCARD. We don't + need to do everything that throw_to_top_level() does here (it's + really meant for signals and other exceptional failure conditions). + +builtins/cd.def + - cd_builtin: exit with EX_USAGE on too many arguments + +builtins/shift.def + - shift_builtin: return EX_USAGE if get_numeric_arg returns 0, + indicating that the argument wasn't a valid number + +builtins/history.def + - shift_builtin: return EX_USAGE if get_numeric_arg returns 0 + +builtins/exit.def + - exit_or_logout: if get_exitstat (which calls get_numeric_arg) returns + a value > EX_SHERRBASE, indicating an error, just return that to + the caller and let the caller deal with it. This means that + `exit xyz' is no longer a fatal error, but can potentially cause a + non-interactive posix-mode shell to exit because exit is a special + builtin + +builtins/return.def + - return_builtin: if a non-interactive shell in posix mode gets an + invalid numeric arg from get_exitstat, return immediately and let + the caller deal with exiting + All prompted by a report by Martin Schulte + + 10/13 + ----- +pathexp.c + - unquoted_glob_pattern_p: restore some of the special treatment of + backslash followed by CTLESC removed on 10/7 + Report and patch from Grisha Levit + +parse.y + - parse_matched_pair: don't add an extra CTLESC after reading \CTLESC, + like in other parts of the parser + +subst.c + - dequote_string: don't drop trailing CTLESC in a string with more + than a single character + Report and patch from Grisha Levit + +lib/sh/strtrans.c + - ansicstr: handle $'\c^A' and $'\c^?' correctly when being expanded + by the parser (flags&2). The parser passes these as \c^A^A and + \c^A^?, respectively, so we should strip the quoting CTLESC. + Report from Grisha Levit + +subst.[ch] + - extract_dollar_brace_string: now global so brace expansion can use it + +braces.c + - brace_gobbler: use extract_dollar_brace_string if we see ${ with + the appropriate value of QUOTING, so we don't have to teach brace + expansion more shell syntax. + Report from Emanuele Torre + - brace_gobbler: call the word extraction functions with SX_NOALLOC + so we don't have to allocate memory we're just going to free + + 10/16 + ----- +builtins/read.def + - read_builtin: return EX_MISCERROR (2) if there is an error trying + to assign to one of the variables. This is what the newest POSIX + draft specifies. + +variables.c + - dispose_variable_value: do the right thing for att_nofree vars + - makunbound: call dispose_variable_value instead of using inline code + +braces.c + - brace_gobbler: make sure to set no_longjmp_on_fatal_error around + calls to extract_dollar_brace_string + + 10/17 + ----- +braces.c + - brace_gobbler: set SX_NOLONGJMP|SX_NOERROR in the flags passed + to extract_command_subst; make sure no_longjmp_on_fatal_error + is set before that call + - brace_gobbler: revert 10/13 change to use extract_dollar_brace_string + + 10/20 + ----- +parse.y + + - xparse_dolparen,parse_string_to_command: if SX_NOERROR is set in + FLAGS, add PST_NOERROR to parser_state. Not much effect yet. + - parse_matched_pair: if PST_NOERROR is set in parser_state, don't + print an error message if we hit EOF, just return an error. A start + at using PST_NOERROR to suppress error messages, not just duplicate + ones. We'll see how this goes before adding more + +builtins/printf.def + - decodeprec: decode the precision into an intmax_t; clamp the return + value at INT_MAX + - printf_builtin: update to posix interp 1647 (even though it's about + fprintf(3)) and output a NUL byte if %lc is supplied a null argument. + - printf_builtin: fix case where %Q is supplied with a precision in + the format string + - printf_builtin: fix case where %Q is supplied with a precision + greater than INT_MAX + - getwidestr,getwidechar: handle case where there is no argument + supplied; return NULL or NUL + - convwidestr: allow a precedence of 0 for %ls + - getint: don't call getintmax any more, just use the same code style + inline; getintmax will consume an extra argument on an error + Report and patches from Grisha Levit + - printf_builtin: handle field width and precision overflow from + getint() by ignoring the argument (fieldwidth = 0, precision = -1) + + 10/26 + ----- +jobs.c + - wait_for: rearrange code that sets the SIGINT handler to + wait_sigint_handler and saves the old handler to old_sigint_handler + to avoid delay before assigning the handler + Report from Wenlin Kang + - wait_sigint_handler: if cur_sigint_handler (what restore_sigint_handler) + just restored or ignored) is INVALID_SIGNAL_HANDLER, set the + appropriate SIGINT handler with set_sigint_handler before sending + ourselves SIGINT + + 10/30 + ----- +general.c + - legal_number: use the same test (isspace(3)) to skip trailing + whitespace that strtoimax uses to skip leading whitespace. + Report and patch from Paul Eggert + +general.c,general.h + - legal_number: renamed to valid_number, changed all callers + - legal_identifier: renamed to valid_identifier, changed all callers + - legal_alias_name: renamed to valid_alias_name, changed all callers + +lib/sh/compat.c + - legal_number: definition of legal_number here for backwards compat + with old loadable builtins + - legal_identifier: definition of legal_identifier here for backwards + compat with old loadable builtins + - legal_alias_name: same + +subst.c + - brace_expand_word_list: if brace_expand returns NULL, dummy up a + single-element vector with a copy of the original word so we can + add it to the result list unchanged. + Inspired by https://savannah.gnu.org/support/?110948 + + 11/3 + ---- +lib/readline/text.c + - readstr: set of functions to read a string from the keyboard, using + rl_line_buffer for temporary storage, with minimal editing and an + optional caller-supplied completion function. Doesn't use the + callback framework yet since none of the functions are public + - rl_execute_named_command: new bindable function to read a bindable + command name (from the funmap_names array) and execute it, with + command name completion on SPACE and TAB + +lib/readline/readline.h + - rl_execute_named_command: new extern declaration + +lib/readline/rlprivate.h + - new extern declarations for the readstr function framework + +lib/readline/funmap.c + - execute-named-command: new bindable function name + +lib/readline/emacs_keymap.c + - rl_execute_named_function: bound to M-x by default + +lib/readline/doc/rluser.texi + - execute-named-command: document as bindable function name with its + default binding to M-x in emacs mode + + 11/6 + ---- +lib/readline/search.c + - _rl_nsearch_dispatch: use ^V/^Q for rl_quoted_insert into the + search string + +lib/readline/isearch.c + - _rl_isearch_dispatch: use ^V or anything bound to rl_quoted_insert + for rl_quoted_insert into the search string + +lib/readline/terminal.c + - add support for new BE/BD and PS/PE bracketed-paste capabilities. + Nothing uses them yet. + + 11/10 + ----- +builtins/enable.def + - dyn_load_builtin: if we don't find a pathname argument without a + slash in BASH_LOADABLES_PATH, convert it to a pathname with a slash + before calling dlopen, to force the loader to look in the current + directory (Linux, for example, will not). + + 11/14 + ----- +examples/loadables/fdflags.c + - fdflags_builtin: only parse the setspec once, since parsing uses + strtok. + Report and patch from Emanuele Torre + + 11/15 + ----- +builtins/enable.def + - dyn_load_builtin: if BASH_LOADABLES_PATH is set, use only it: don't + fall back to looking in the current directory. This changes the + historical behavior and brings the path behavior more in line with + PATH, but not CDPATH. + + 11/20 + ----- +lib/readline/complete.c + - rl_complete_internal: add `|' as a character for rl_complete_internal + that also just displays the completions, since `%' is overloaded by + rl_menu_complete + + 11/23 + ----- +examples/loadables/strptime.c + - strptime: new loadable builtin, interface to strptime(3). Takes a + date-time string as its arguments and tries to parse it according + to a number of built-in formats. If successful, it outputs the + result as a number of seconds since the epoch. Understands some + handy shorthands like "now" and "tomorrow". + + 11/24 + ----- +tests/unicode1.sub + - update the driver function using namerefs and ${!x[@]} + - zh_TW.BIG5: fixed some problems with the test encodings. + Report and patches from Grisha Levit + + 11/25 + ----- +tests/glob2.sub + - zh_HK.big5hkscs -> zh_TW.big5 to work around macOS 14 issues with + BSD-based locale definition + +bashline.c + - bash_execute_unix_command: check count != 1 instead of count > 1 to + handle negative arguments + +lib/readline/bind.c + - rl_trim_arg_from_keyseq: change the parsing_digits logic to handle + multiple instances of `-' the same way rl_digit_loop does (collapse + to 1) + - rl_trim_arg_from_keyseq: fix typo to correctly recognize a `-' + after a key sequence bound to universal-argument + - rl_trim_arg_from_keyseq: trim negative argument for a key sequence + that is shadowed by a longer key sequence (ANYOTHERKEY) + Report and patches from Grisha Levit + + 11/27 + ----- +support/shobj-conf + - solaris2: change PIC option for non-gcc Solaris 2 builds + +lib/malloc/malloc.c + - binsize: make sure indexing into binsizes casts to size_t (unsigned) + +examples/loadables/getconf.c + - protect more of the _SC defines with #ifdefs for different systems + +examples/loadables/fdflags.c + - ALLFLAGS: add some more flag values from Solaris/AIX/HP-UX + + 11/28 + ----- +subst.c + - function_substitute: unwind return_catch_flag unconditionally + Report and patch from Grisha Levit + - function_substitute: save getopts state and restore it if the + funsub declares a local copy of OPTIND + Report and patch from Grisha Levit + +lib/readline/display.c + - rl_redisplay: make sure lpos is initialized to 0 if local_prompt is + NULL + +shell.c + - run_startup_files: make sure ssh_reading_startup_files is set to 0 + in more places; still dependent on SSH_SOURCE_BASHRC + +builtins/evalstring.c + - should_suppress_fork: make sure ssh_reading_startup_files is 0 in + order to suppress a fork. It will never be non-zero unless someone + enables SSH_SOURCE_BASHRC. + Fixes https://issues.redhat.com/browse/RHEL-5653 + +variables.c + - posix_unbind_tempvar: new function to implement POSIX interp 1009, + which says that `x=4 unset x' not only unsets the variable in the + temporary environment but the most recent scope as well. + +variables.h + - posix_unbind_tempvar: extern declaration + +builtins/set.def + - unset_builtin: if we are unsetting a variable that is in some + temporary environment, and the shell is in posix mode, call + posix_unbind_tempvar to implement the right posix behavior + +doc/bashref.texi + - update posix mode section with change to unset for interp 1009 + + 12/1 + ---- +lib/readline/readline.c + - _rl_subseq_result: add check before _rl_do_lowercase_version that + _rl_to_lower actually results in a different key sequence + Report and patch from Grisha Levit + +lib/readline/isearch.c + - _rl_isearch_dispatch: if the function bound to a key and the function + bound to the result of _rl_to_lower for that key are both + rl_do_lowercase_version, just insert the key into the search string + + 12/5 + ---- +parse.y,parser.h + - heredoc_string: new variable to indicate whether or not we're reading + a here-document from an alias (a pushed string). Set in + gather_here_documents individually for each call to + make_here_document. + +parse.y + - read_a_line: if heredoc_string is non-zero, use shell_getc instead + of yy_getc to get the right alias processing + - shell_getc: if heredoc_string is non-zero, don't add a space to the + end of the alias -- it can mess up the here-document delimiter if + the next character is a newline + Report and sample patch from gldrk + +parse.y,make_cmd.c + - read_a_line,make_here_document: if we're using shell_getc to read + the body of a here-document, let it manage line_number + + 12/8 + ---- +bashline.c + - bash_dequote_filename: fix an off-by-one error that didn't remove a + closing single quote in a filename if it was backslash-escaped. + Report by Ole Tange , fix from Grisha Levit + +lib/readline/terminal.c + - _rl_check_ansi_terminal: check whether or not rl_terminal_name + appears to be an ANSI/ECMA-48 terminal. Check some common terminal + types and then check whether some common terminal capabilities + (ce, nd, ho, up) begin with CSI (ESC-[) and then have a correct + subsequent character + - _rl_term_isansi: new variable, holds readline's idea about whether + the value of rl_terminal_name is an ANSI/ECMA-48 terminal. Initialized + to RL_ANSI_TERM_DEFAULT; set to the result of _rl_check_ansi_terminal + if initialized to 0 and on a `non-dumb' terminal + From an idea by John Tsiombikas in 11/2023 + +lib/readline/rlconf.h + - RL_ANSI_TERM_DEFAULT: define to 1 (yes) or 0 (no) to tell readline + whether or not to assume it's running on an ANSI/ECMA-48 terminal. + The default is 1 (yes) + + 12/11 + ----- +print_cmd.c + - make_command_string_internal: when printing a coproc, print the + coproc name only if the coproc command is not a simple command. + Report from Albert Akchurin + + 12/14 + ----- +doc/bash.1,doc/bashref.texi + - bind: clarify meaning of `re-read' as being individual arguments + to `bind'. + Report from Dan Jacobson + - history expansion: add that the quick substitution character is + only active when it's the first character on the line. + Suggested by Dale R. Worley + +lib/readline/histexpand.c + - history_expand: if history_quoting_state is "'", don't try to + interpret the quick substitution syntax at the start of the string. + Report from Sundeep Agarwal + +execute_cmd.c,execute_cmd.h + - save_lastarg: new function, returns saved value of $_ in allocated + memory + +parse.y + - execute_variable_command: instead of inline code, call save_lastarg + +mailcheck.c + - check_mail: instead of inline code, call save_lastarg + - check_mail: instead of calling bind_variable, use bind_lastarg + +parse.y + - decode_prompt_string: use save_lastarg() and bind_lastarg() to preserve + the value of $_ across prompt string decoding. + Patch from Grisha Levit + + 12/21 + ----- +lib/readline/doc/readline.3 + - updates to some vi-mode bindings + Patch from Josh Brobst + +builtins/setattr.def + - set_or_show_attributes: in posix mode, supplying an argument that is + not an identifier when not acting on functions is a utility error. + This will cause a non-interactive shell to exit + + 12/27 + ----- +print_cmd.c + - command_print_word_list,print_select_command_head,print_case_command_head, + print_function_def: if we're in pretty-print mode, dequote words + before printing them + Report from Seth Sabar + +shell.c + - execute_profile_file,execute_bashrc_file: separate the (duplicated) + code that sources the various profile and bashrc files out into + separate functions + - find_bashrc_file: new function, returns the name of the interactive + shell startup file that should be executed if --rcfile (--init-file) + is not supplied; currently returns DEFAULT_BASHRC + - bashrc_file: default to NULL, making it just the filename supplied as + an argument to --rcfile/--init-file + - execute_bashrc_file: execute whatever find_bashrc_file() returns + if bashrc_file is NULL + From a patch from Allison Karlitskaya + + 1/3/2024 + -------- +print_cmd.c + - print_case_clauses: if we're printing a comsub for subsequent parsing, + don't add a newline before the first case clause, since it adds a + token after the `in' that will allow reserved words to be parsed. + Report from Oguz + + 1/5 + --- +lib/readline/doc/rltech.texi,lib/readline/doc/readline.3 + - Note that since quoted characters are possible, the line readline() + returns may contain embedded newlines. + From a report by Martin Buck + + 1/8 + --- +parse.y + - parse_compound_assignment,parse_string_to_word_list: if we call + reset_parser, directly or indirectly via yyerror, make sure to set + the pushed_strings member of the saved parser state to NULL, since + reset_parser already freed it and we don't want to try and restore + it in restore_parser_state. + From a report by Nathan Mills + + 1/10 + ---- +builtins/hash.def, builtins/ulimit.def + - add some calls to sh_chkwrite where there is builtin output + +lib/sh/eaccess.c + - sh_stat: use strcpy/strcpy when constructing pbuf instead of + strcpy/strcat + +lib/sh/tmpfile.c + - sh_mktmpname,sh_mktmpfd,sh_mktmpdir: use snprintf (filename, PATH_MAX, ...) + instead of sprintf (filename, ...) + + 1/11 + ---- +configure.ac + - unconditionally AC_DEFINE(PGRP_PIPE), to prevent the problem with a + pipeline and a DEBUG trap containing an external command described + in https://lists.gnu.org/archive/html/bug-bash/2024-01/msg00037.html + + 1/12 + ---- +jobs.c + - wait_for_any_job: if we're executing a funsub/varsub, do the wait + even if the jobs list is frozen, but don't remove the job from the + table or change its notification status + Report from Oguz + +subst.c + - uw_unbind_variable: unset the first instance of the named variable, + don't follow namerefs. This is for REPLY in a varsub if it's made + a nameref. + Report from Oguz + +shell.c + - main: call compat_init() so the linker drags in the old compatibility + functions from lib/sh/compat.c. Primarily for use by existing loadable + builtins + +parse.y + - parse_compound_assignment: handle error case (wl == &parse_string_error) + before restoring the parser state from ps + Report from Grisha Levit + + 1/13 + ---- +lib/readline/complete.c + - compute_lcd_of_matches: move a strlen out of a call to MBRTOWC by + computing the length of the entire string once and then using an + offset from it while going through the loop + + 1/15 + ---- +parse.y + - parse_compound_assignment: treat parsing a string following (( (read + by parse_dparen but not an arithmetic command) the same as + expanding an alias when fixing up the pushed string list + Report from Grisha Levit + + 1/18 + ---- +doc/bash.1 + - typos and style fixes to satisfy groff warnings; remove uses of the + `CW' constant-width font; use .EX/.EE for examples; use consistent + style for double-quoted strings; fix inconsistent inter-paragraph + spacing + Fixes from G. Branden Robinson + + 1/19 + ---- +test.c + - binary_test: make sure all calls in posix mode use TEST_LOCALE for + locale-specific string comparisons + +shell.c + - find_bashrc_file: remove + + 1/20 + ---- +shell.c + - exit_shell: don't try to call rl_deprep_terminal, regardless of the + readline state we inherited, if bash_readline_initialized is 0 + Fixes bug reported by Oguz + - shell_reinitialize: reset startup_state and reading_shell_script to 0; + reset debugging_mode to 0 + + 1/22 + ---- +builtins/shopt.def + - reset_shopt_options: reset debugging_mode to 0 + +builtins/set.def + - reset_shell_options: reset interactive_comments to 1 + +braces.c + - brace_expand: if the first call to brace_gobbler consumes the entire + string, don't try to call it again + - brace_expand: check that i < tlen before checking to see if + expand_seqterm left more of the string unconsumed + - brace_gobbler: if extract_command_subst hits the end of the string + without closing the command substitution, make sure we return 0 as + well as set *i = tlen + From a fuzzing report by Nathan Mills + + 1/23 + ---- +subst.c + - function_substitute: unwind-protect current_builtin and this_shell_builtin + like we do this_shell_function + From a fuzzing report by Nathan Mills + + 1/24 + ---- +braces.c + - brace_gobbler: handle nofork command substitutions; skip over any + enclosed command and any braces it contains + +bashline.c + - check_redir: return 0 if we're in a nofork comsub, so we will attempt + command word completion if appropriate + + 1/26 + ---- +lib/readline/readline.h + - RL_STATE_READSTR: new state flag saying we are reading an arbitrary + string from the keyboard using rl_readstr + +lib/readline/rlprivate.h + - READSTR_FREEPMT: new context state flag for rl_readstr; indicates + that we have allocated a new prompt with _rl_make_prompt_for_search + and we should free it with rl_restore_prompt because rl_clear_message + will not do it + +lib/readline/text.c + - _rl_readstr_init,_rl_readstr_cleanup: set and unset RL_STATE_READSTR + - _rl_unsave_saved_readstr_line: free any rl_undo_list, which we may + have accumulated while reading the string, before restoring the line + Fixes leaks reported by sparrowhawk996@gmail.com. + - _rl_readstr_init: set the READSTR_FREEPMT context flag after we + call _rl_make_prompt_for_search, which calls rl_save_prompt + - _rl_readstr_sigcleanup: new function to call from signal cleanup; + restores prompt and calls _rl_readstr_cleanup to free the readstr + context + - _rl_readstr_restore: if the RL_READSTR_FREEPMT flag is set in the + context, call rl_restore_prompt to deallocate the prompt we created + +lib/readline/callback.c + - rl_callback_sigcleanup: call _rl_readstr_sigcleanup to deallocate + readstr state on a signal + +lib/readline/text.c + - rl_execute_named_command: free COMMAND before returning + + 1/27 + ---- +lib/readline/rlprivate.h + - SF_FREEPMT: new flag for non-incremental search contexts: means we + saved the prompt data with _rl_make_prompt_for_search and need to + restore it with rl_restore_prompt, since rl_clear_message will not + +lib/readline/search.c + - _rl_nsearch_sigcleanup: new function that if calls rl_restore_prompt + to clean up the saved prompt data if necessary before calling the + context cleanup function, avoids memory leak + - _rl_nsearch_init: set the SF_FREEPMPT flag after calling + _rl_make_prompt_from_search so we can clean it up properly on errors + - _rl_nsearch_abort,_rl_nsearch_dosearch: call rl_restore_prompt only + if cxt->sflags includes SF_FREEPMT, manage SF_FREEPMT state + +lib/readline/signals.c + - _rl_state_sigcleanup: call _rl_nsearch_sigcleanup + +lib/readline/callback.c + - _rl_callback_sigcleanup: call _rl_nsearch_sigcleanup + + 1/29 + ---- +builtins/cd.def + - change_to_directory: don't try to canonicalize a NULL path that's + NULL after make_absolute. + From a report by Kerin Millar + +jobs.c + - retrieve_proc_status,delete_proc_status: external interfaces to + bgp_search and bgp_delete, respectively; these take an argument + that says whether or not to block SIGCHLD + +jobs.h + - retrieve_proc_status,delete_proc_status: extern declarations + +builtins/wait.def + - check_bgpids: new function to check whether a requested PID is in + the bgpids table (retrieve_proc_status) and optionally delete it + if it is (posixly_correct delete_proc_status) while returning its + status. If the PID isn't in the bgpids table, return -1 + - wait_builtin: if -n is supplied with pid/job arguments, use + check_bgpids to check the bgpids table for any of the requested + pids. Tagged for bash-5.3, might need another option + From a report by Steven Pelley + + 1/30 + ---- +redir.c + - redir_open: assume the AFS bug with O_CREAT and existing files in + protected directories has been fixed over the years, so take out + the workaround. + From a report by Etienne Champetier + +jobs.c + - wait_for_any_job: if the jobs list is frozen and we're running a + funsub, mark the job as notified so it gets cleaned up later + - wait_for_any_job: if we're in posix mode, we should remove the job + from the job list and not add it to the bgpids list, as posix + requires + +builtins/set.def + - set_shellopts: use ASS_FORCE in the call to bind_variable so we + don't have to mess with temporarily turning off readonly + +builtins/shopt.def + - set_bashopts: same + Report by Emanuele Torre + + 2/1 + --- +builtins/printf.def + - vblen: make it a size_t to avoid going negative on underflow + - clearerr, ferror, fflush: don't test these if vflag is set and we're + writing to a string (multiple places) + - vbprintf: pass through failure returns (< 0) from vsnprintf to the + caller(s) so we can return on errors + - printf_builtin: remove redundant test for empty or missing format + string + - PF: call builtin_error if vflag is set, sh_wrerror otherwise + (via PRETURN) + - PF: use PRETURN so we can get partial output to the variable on + error (if vflag is set) + - PRETURN: free conv_buf before attempting the write (it would get + cleaned up on the next call, but why not) + - PRETURN: clean up vbuf only if vflag is set, and clean it up on + error (it would get cleaned up on the next call, but...) + Fixes from Grisha Levit + + 2/2 + --- +doc/bash.1,doc/bashref.texi + - word expansions: make it clearer that quote removal is one of the + shell word expansions + +execute_cmd.c,execute_cmd.h + - currently_executing_command: no longer static, so other parts of + the shell can save and restore it if necessary + +subst.c + - function_substitute: unwind-protect currently_executing_command, + since parse_and_execute can overwrite it in the current shell + execution context. + Report from Grisha Levit + +lib/readline/readline.c + - readline_common_teardown: new function from the guts of + readline_internal_teardown, manages and deallocates rl_undo_list. + +lib/readline/callback.c + - rl_callback_handler_remove: if we're removing the line handler + while we still have an undo list, we didn't call + readline_internal_teardown. Call readline_common_teardown to manage + the undo list in case we are calling this from a signal handler + but not exiting the program. + Fixes leaks reported by sparrowhawk996@gmail.com. + +variables.c + - initialize_shell_variables: use ASS_FORCE when binding SHELLOPTS or + BASHOPTS if we get them from the environment, in case they've + already been created as shell variables and set to readonly (like + changes from 1/30) + - set_ppid: use ASS_FORCE in the call to bind_variable instead of + temporarily turning off att_readonly + +subst.c + - extract_delimited_string: pass FLAGS down to skip_single_quoted and + skip_double_quoted so we propagate SX_COMMAND and SX_COMPLETE + properly. + Fixes bug reported by A4-Tacks + + 2/3 + --- +bashline.c + - initialize_readline: add `bash-vi-complete' as a bindable command + name so users can bind other key sequences to it + - vi_advance_point: function to advance point by one character even + in the presence of multibyte characters + - bash_vi_complete: call vi_advance_point instead of just incrementing + rl_point + + 2/5 + --- +doc/bash.1,lib/readline/doc/readline.3 + - minor updates to handle old versions of troff and groff warnings + Fixes from G. Branden Robinson + + 2/7 + --- +jobs.c + - notify_of_job_status: in non-interactive shells, if we're not going + to print information about a terminated background job + (SIGINT/SIGTERM/SIGPIPE), don't mark it as notified, in the same + way that we don't mark background jobs that exit cleanly as notified + Inspired by a discussion with Robert Elz and + https://lists.gnu.org/archive/html/bug-bash/2024-01/msg00189.html + + 2/9 + --- +lib/readline/history.c + - DEFAULT_HISTORY_GROW_SIZE: bump up to 256 + - real_history, real_history_size: the true history array and its + allocated size. the_history begins a user-visible window into this + list, extending for history_size entries + - history_list_grow_size: compute how much to extend the history list; + increase by roughly sqrt(history_size), don't extend by less than + (new) DEFAULT_HISTORY_GROW_SIZE + - history_list_resize: possibly resize/realloc real_history and reset + the_history to real_history and history_size to real_history_size + - advance_history: make the `window' that the_history provides into + real_history advance to simulate dropping an initial entry; don't + need to memmove all the entries any more + - add_history: call advance_history as necessary to move the_history + window + - add_history: call history_list_resize as necessary + Report and initial patch from Casey Johnson + + 2/12 + ---- +bashline.c,lib/readline/bind.c,lib/readline/display.c + - replace some sprintf calls with snprintf to appease clang + +execute_cmd.c + - execute_simple_command: unwind-protect this_command_name, since we + assign it to something we will free if unwind-protects are run + - execute_function: unwind-protect currently_executing_command, since + execute_command_internal will change it to something will will free + if unwind-protects are run + Report from Grisha Levit + - execute_function: if we didn't compile with debugger support, restore + currently_executing_command after run_debug_trap, like in other + cases + + 2/13 + ---- +builtins/declare.def + - declare_invalid_opts: move the code that checks for invalid option + combinations to its own function; it returns 0 for no errors and + a return code for declare_internal to return otherwise + Inspired by report from Grisha Levit + - declare_invalid_opts: make -A -a and -A +A/-a +a option combinations + invalid + Report from Grisha Levit + + 2/14 + ---- +bashline.c,general.c,subst.c,lib/sh/pathphys.c,builtins/read.def, +support/bashversion.c + - changes for cygwin and msys (no new features) + +bashline.c,builtins/fc.def,general.c,parse.y,stringlib.c,subst.c,variables.c + - MSYS-specific changes to support \r\n line endings and DOS-style + paths + +configure.ac,cross-build/msys32.cache,support/config.rpath,support/shobj-conf + - MSYS-specific build options + +configure.ac,config.h.in,m4/unlocked-io.m4,general.h,include/unlocked-io.h +MANIFEST + - adapt Gnulib's unlocked-io module for faster stdio functions. + From Grisha Levit + +lib/malloc/malloc.c,lib/malloc/table.h,lib/sh/strlcpy.c + - fixes for ISO C 23 + Patch from Collin Funk + + 2/16 + ---- +jobs.c + - waitchld: note whether or not we are executing in a signal handler + context and break out of the loop if we receive a terminating + signal instead of calling termsig_handler, which can execute unsafe + functions + From https://issues.redhat.com/browse/RHEL-22295 + +variables.h + - valid_readonly_attrs,invalid_readonly_attrs: new defines for declare + to use to validate attempts to modify attributes of readonly + variables + +builtins/declare.def + - declare_internal: reject attempts to modify (set or unset) attributes + in invalid_readonly_attrs for readonly variables. + From a discussion with Grisha Levit + + 2/17 + ---- +variables.h + - add att_readonly to valid_readonly_attrs; it's valid to use + declare -r var ; declare -r var + +Makefile.in,builtins/Makefile.in + - add unlocked-io.h to dependencies and variable contents where + appropriate + - add additional include files to INSTALLED_INCFILES + +builtins/pushd.def,examples/loadables/necho.c + - fix order of includes to get unlocked-io.h + From Grisha Levit + +subst.c,subst.h + - rename quote_rhs -> quote_nosplit + + 2/19 + ---- + +subst.c + - quote_var_value: break the code that quotes a variable value ($x, + ${x}, ${x[n]}, etc.) into a separate inline function and call it + from param_expand and parameter_brace_expand_word so they do it + consistently + - param_expand: quote $* appropriately using quote_nosplit if we are + in a place where word splitting will not occur (PF_NOSPLIT2), + expand_no_split_dollar_star == 1 but quoted is 0 + - quote_var_value: use quote_nosplit if we are in a place where word + splitting will not occur (PF_NOSPLIT2) but quoted == 0. + Fixes bug with IFS=$'\1' reported by alex xmb sw ratchev + +arrayfunc.c + - array_value: make sure to quote ${A[*]} appropriately if not quoted + (quoted == 0) and in a place where word splitting does not occur + (flags & AV_ASSIGNRHS); the caller expects array_value to quote in + this case + +subst.c + - parameter_brace_expand_word: make sure to call array_value with + AV_ASSIGNRHS if we are expanding unquoted ${A[*]} in a place where + word splitting does not occur with a non-null $IFS; array_value will + quote appropriately here + - parameter_brace_expand_word,param_expand: use quote_var_value when + expanding $N and ${N} + +doc/bash.1,doc/bashref.texi + - HISTIGNORE: clarify the description a little to emphasize that lines + matching one of the patterns are not saved in the history list + From https://savannah.gnu.org/support/index.php?111020 + + 2/20 + ---- +builtins/evalfile.c + - FEVAL_RETRY: if set in FLAGS, _evalfile will retry an interrupted + open + - _evalfile: if open() returns -1, FEVAL_RETRY is set in FLAGS, and + errno == EINTR, retry the open after checking for interrupts or + terminating signals + - maybe_execute_file,force_execute_file: pass FEVAL_RETRY in flags + +bashhist.c + - load_history: retry read_history if it returns EINTR after checking + for interrupts or terminating signals + +lib/readline/bind.c + - _rl_read_init_file: retry the open once if it's interrupted due to a + signal. If we are at a point where readline has installed its + signal handlers, check for signals readline handles + From a patch from Grisha Levit + + 2/21 + ---- +subst.c + - make_internal_declare: now takes two strings of option arguments: + those to turn on (`-') and those to turn off (`+') + - expand_declaration_argument: simplify the code; handle `-' and `+' + optionsns; always call make_internal_declare + From a patch from Grisha Levit + + 2/22 + ---- +aclocal.m4 + - add additional character to test for broken wcwidth (0x200b) + +lib/readline/display.c + - update_line: use IS_COMBINING_CHAR instead of UNICODE_COMBINING_CHAR + plus WCWIDTH; it doesn't make sense on systems where wcwidth isn't + broken + + 2/27 + ---- +print_cmd.c + - print_case_clauses: if one of the case command pattern lists begins + with the word `esac' (unquoted), precede the pattern list with `(', + since it had to be there originally to get through the parser. + Report by Emanuele Torre + + 2/29 + ---- +general.c,general.h + - string_to_rlimtype: takes a second ENDP argument, like strtol, so + the caller doesn't have to check that the string is all digits, + but can optionally check for and disallow a 0x prefix + + 3/2 + --- +subst.c + - dequote_list: unset the W_QUOTED flag in the word after dequoting it + - parameter_brace_expand_rhs: if the word in the list returned by + expand_string_for_rhs has W_QUOTED set, but the string being + expanded was not quoted, turn on the W_QUOTED in the returned word + so we can potentially avoid word splitting + - expand_word_internal: if CTLNUL is a IFS character, don't add quoted + null strings to istring if we're going to be word splitting, since + they will be treated as word delimiters + + 3/6 + --- +examples/loadables/getconf.c + - getconf_builtin,getconf_all: changes for POSIX interp 1808 proposal + to allow an optional pathname argument with -a that forces its use + for pathconf variables + https://www.austingroupbugs.net/view.php?id=1808 + + 3/11 + ---- +builtins/printf.def + - printf_builtin: %lc/%ls (%C/%S) should only work on wide characters + when in a locale where MB_CUR_MAX > 1. + Report by Emanuele Torre + + 3/12 + ---- +jobs.c + - notify_of_job_status: don't mark terminated background jobs or stopped + jobs as notified in shells started to run -c command + From a report by Greg Wooledge + - notify_of_job_status: make the final marking the dead job as notified + a true catch-all so we can put a debugging message in there to see + if there are other missing cases + - notify_of_job_status: don't mark terminated jobs that died due to + a signal the shell trapped (on the assumption that the shell + received the signal, too) as notified, since we don't report on it + in the JDEAD case if the signal is trapped + + 3/13 + ---- +builtins/printf.def + - PF: print an error message if printf returns an error or leaves + ferror(stdout) true + From a report by Paul Eggert + + 3/14 + ---- +builtins/printf.def + - getint: now takes an int argument and returns it if the conversion + overflows an int; changed callers in printf_builtin + - getint: consolidate checks for overflow. This changes the behavior + if the argument overflows an intmax_t: it returns a field width of + 0 (the overflow result) instead of -1, which changes how printf + behaves. This is consistent with the behavior when the argument + overflows an int + - printf_builtin: change check for overflow of [LONG_MIN..LONG_MAX] + for %d/%i to be explicit instead of relying on integer overflow of p + - printstr,printwidestr: print message if field width or precision + overflow, since we don't call printf + - printstr,printwidestr: set field width and precision on integer + overflow the way we do in printf_builtin + From a report and patch by Paul Eggert + +bashtypes.h + - PRIdMAX: move redefinition here after including inttypes.h + +builtins/printf.def,examples/loadables/seq.c,examples/loadables/getconf.h + - remove PRIdMAX redefinitions, since it's now fixed in bashtypes.h + From a report and patch by Paul Eggert + + 3/15 + ---- +include/stdckdint.in.h,include/intprops-internal.h + - new files, from gnulib + +configure.ac + - stdckdint.h: create in the build directory if the system doesn't + provide one by copying ${srcdir}/include/stdckdint.in.h; make + sure we don't create a new one every time, changing the timestamp + +Makefile.in + - CREATED_HEADERS: add stdckdint.h + +stringlib.c,externs.h + - substring: now takes size_t arguments for START and END + +lib/sh/stringvec.c + - strvec_create,strvec_mcreate,strvec_resize,strvec_mresize: use + ckd_mul to avoid size_t overflow + - strvec_len,strvec_flush: use size_t variable as array index + From a report by Paul Eggert + +bashansi.h + - stdbool.h: include if we have it, typedef bool as unsigned char if + we don't and HAVE_C_BOOL isn't defined + + +m4/c-bool.m4 + - autoconf check for `bool' from gnulib + +configure.ac + - include m4/c-bool.m4, call gl_C_BOOL; don't explicitly check for + stdbool.h using AC_CHECK_HEADERS any more + +config.h.in + - HAVE_C_BOOL: define + + 3/16 + ---- + +builtins/printf.def + - decodeprec: now decodeint, takes new arguments: a char ** that is + the string to parse and update, an argument saying whether or not + to print an error message on overflow, and an argument that should + be the return value on overflow; use ckd_* macros to check overflow + - printstr, printwidestr: use a different mechanism to check overflow; + call decodeint to get precision and field width + +braces.c + - include stdckdint.h for the ckd_* overflow checking macros + - mkseq: the width argument is now size_t + - mkseq: perform overflow detection using the ckd_* macros + - mkseq: perform zero-padding directly instead of using asprintf; the + sprintf family has trouble when width > INT_MAX + - expand_seqterm: use size_t instead of int for length and width + variables + From a report and patch by Paul Eggert + + 3/18 + ---- +builtins/printf.def + - printstr,bexpand: changed size/length arguments to be size_t; changed + callers + +subst.c + - string_var_assignment: if the variable is a local variable at the + current scope, output a declare command even if there are no + attributes or value. Still tagged as tentative + + 3/23 + ---- +test.c + - posixtest: takes an argument, the number of test arguments to parse + - two_arguments,three_arguments: use advance() instead of accessing + and manipulating pos directly + - posixtest,three_arguments,two_arguments: don't set pos = argc + directly, rely on functions to advance pos appropriately + Picked up from coreutils test + - term: if we see a left paren, scan forward for a closing right paren + and use posixtest() if there are 1-4 arguments between the parens to + avoid ambiguous behavior for expressions like true -a \( ! -a \), + which, though it's horribly ambiguous, a user would expect to + return false instead of an error message + Picked up from coreutils-9.2 test + + 3/25 + ---- +bashansi.c + - HAVE_C_BOOL: prefer if defined, fall back to stdbool.h if bool isn't + a compiler builtin + +braces.c + - mkseq: simplify break condition + +builtins/printf.def + - decodeint: let the caller decide what to do with an overflow return, + don't return -1 after calling report_erange(). This will honor a + precision even if the field width overflows + - printf_builtin: check for overflow when adjusting precision for + string length with %Q + - printstr,printwidestr: now that the code uses decodeint, we don't + need to check the precision against INT_MAX + +bashansi.h + - include stddef.h if we have it, otherwise define replacements for + NULL and offsetof() + +builtins/help.def,lib/sh/fmtulong.c,lib/sh/getcwd.c,lib/sh/makepath.c, +lib/sh/snprintf.c,lib/sh/strtod.c,lib/sh/strtol.c,unwind_prot.c, +lib/readline/shell.c + - include bashansi.h instead of stddef.h, or remove a stddef.h include + if bashansi.h is already included + - remove extra definitions that appear in stddef.h or bashansi.h + +lib/sh/reallocarray.c,externs.h + - implementation of reallocarray(), originally from OpenBSD, from + Paul Eggert + +configure.ac + - use AC_REPLACE_FUNCS for reallocarray + +xmalloc.c,xmalloc.h + - xreallocarray: implementation of reallocarray that uses xrealloc + - sh_xreallocarray: implementation of reallocarray that uses + sh_xrealloc and has file and line information for error messages + +lib/sh/stringvec.c + - strvec_create, strvec_resize: rewrite in terms of xreallocarray + - strvec_mcreate, strvec_mresize: rewrite in terms of reallocarray + - strvec_remove, strvec_search, strvec_copy, strvec_from_word_list, + strvec_to_word_list: use size_t instead of int where appropriate + +lib/sh/stringvec.c,externs.h + - strvec_search: return a value of type ptrdiff_t, since size_t is + unsigned and we want to return -1 if not found + + All from a report and patch by Paul Eggert + +test.c + - term: change paren scan algorithm to count open and close parens so + we handle nested subexpressions. Still not compatible in the case + of something like test true -a \( ! -a \) \) + + 3/27 + ---- +parse.y + - flush_parser_state: new function, deallocates the members of a + parser state struct that are dynamically allocated + - parse_comsub: call flush_parser_state in places where we will + return an error or jump to the top level + Fixes memory leaks on error reported by bug_reports00@protonmail.com + +Makefile.in + - CREATED_MACOS: list of dSYM directories created by building and + testing + - distclean,maintainer-clean: remove $(CREATED_HEADERS) and + $(CREATED_MACOS) + - maintainer-clean: remove ctags/etags files + + 3/28 + ---- +bashline.c,bashline.h + - uw_restore_parser_state: moved to parse.y and declaration to shell.h + +shell.c,shell.h + - parsing_command: new flag, set to 1 when calling yyparse; saved and + restored by save_parser_state/restore_parser_state + +parse.y,shell.h + - parsing_command: new element of sh_parser_state_t + +sig.c + - throw_to_top_level: reset executing and parsing_command to 0 + +parse.y + - parse_comsub: set parsing_command to 1 before calling yyparse() + +eval.c + - parse_command: set parsing_command to 1 before calling yyparse(), + restore old value when yyparse returns + +subst.c + - function_substitute: if we are parsing a command, save the parser + state with save_parser_state and add an unwind-protect to restore it + From a report from Grisha Levit + - function_substitute: only save and restore the pipestatus array if + we are not parsing a command, since save_parser_state saves it + +parse.y,externs.h + - decode_prompt_string: now takes an additional argument to determine + whether this is expanding PS[0124] or the @P transformation + - decode_prompt_string: keep track of the (last) real prompt string + being decoded so a @P expansion embedded in the prompt returns the + same result as the prompt string itself for the \! and \# expansions + From a patch from Grisha Levit + +parse.y,print_cmd.c,eval.c,subst.c + - decode_prompt_string: changed all callers + + + 3/29 + ---- + +doc/bash.1,lib/readline/doc/readline.3,lib/readline/doc/history.3 + - fix some font-setting directives + - fix some word breaks for font-changing macros + +lib/readline/doc/history.3 + - fix the macros for function signatures for AT&T troff limitations + - fix some paragraph spacing and other layout/spacing/hyphenation + issues + Fixes from G. Branden Robinson + + 4/1 + --- +execute_cmd.c + - shell_execve: minor changes to code that checks the #! interpreter + name + +execute_cmd.c + - execute_coproc: if MULTIPLE_COPROCS is not defined, close any old + file descriptors corresponding to sh_coproc. The user can still + copy them from the coproc array if desired; this prevents the shell + from hanging if a second coproc inherits file descriptors from a + previous one + From a report by Carl Edquist + +jobs.c,nojobs.c,jobs.h + - process_exit_status: no longer static, public function with an + extern declaration + + 4/2 + --- +execute_cmd.c,execute_cmd.h + - coproc_pidchk: now takes a full WAIT status word as a second + argument instead of just the exit status; arranged the prototype + to only be included if the source file includes posixwait.h for WAIT + +jobs.c + - waitchld: call coproc_pidchk with a WAIT second argument (like + nojobs.c does) + +command.h + - COPROC_STOPPED,COPROC_FOREGROUND: new flags values for coproc + +execute_cmd.c + - coproc_setstatus: now takes a full WAIT status word as the second + argument, passed from coproc_pidchk + - coproc_setstatus: use process_exit_status to translate a WAIT into + an int status, doing proper termsig+128 handling + - coproc_getstate: take a WAIT and return the appropriate COPROC_ + status flag (DEAD, STOPPED, etc.) + - coproc_setstatus: use coproc_getstate to set cp->c_flags + + 4/4 + --- +configure.ac + - changed release status to bash-5.3-alpha + - AC_PROG_GCC_TRADITIONAL: removed, since it no longer is supported + in autoconf-2.72 (which MacPorts upgraded me to) + +test.c + - term: made change of 3/25 dependent on the compatibility level + +support/config.guess,support/config.sub,support/config.rpath + - new versions, imported from gnulib + + 4/5 + --- +doc/bashref.texi + - update compatibility, posix mode, and bourne shell sections for + bash-5.3-alpha release + +version.c + - update copyright date to 2024 + +[bash-5.3-alpha frozen] + + 4/6 + --- +builtins/cd.def + - cd_builtin: a null pathname argument is now an error; POSIX interp + 1047 + +variables.c + - makunbound: revert change from 7/10/2023 about preserving the export + attribute when unsetting a local variable in light of POSIX interp + 1806 + + 4/8 + --- +bashline.c + - command_word_completion_function: we don't need to perform an extra + comparison against what rl_filename_completion_function returns if + we are searching $PATH for executable completions + - command_word_completion_function: if a directory name from $PATH + contains characters that need to be quoted, quote them and set + rl_completion_found_quote to force rl_filename_completion_function + to dequote the entire pathname + - command_word_completion_function: since the directory name from $PATH + is not quoted, use the dequoted hint to construct the full pathname + to pass to rl_filename_completion_function (possibly after quoting it) + From https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=306043 + + 4/10 + ---- +redir.h + - RX_EXPANDED: flag set when translating redirects to their final form; + indicates the redirection should not be expanded again + +redir.c + - do_redirection_internal: when translating a redirect into + r_err_and_out, set the RX_EXPANDED flag so the filename doesn't + get expanded again. + Fixes bug reported by squeaky + + 4/12 + ---- +parse.y + - expecting_in_command: new variable, set to FOR or CASE depending on + which command is expecting the IN token to follow it + - {save,restore}_parser_state: save and restore expecting_in_command + in `incmd' member + - special_case_tokens: for POSIX rule 6, check expecting_in_token + instead of last_read_token/token_before_that for case/for command + and whether we should return IN and maybe set PST_CASEPAT + - special_case_tokens: reset expecting_in_command before returning DO + - read_token_word: set expecting_in_command if last_read_token was + CASE or FOR and we are returning a WORD + - reset_parser: reset expecting_in_command + - parse_comsub,parse_compound_assignment: reset expecting_in_command + Fixes bug reported by nbowler@draconx.ca + +parser.h + - incmd: new member of parser_state, saves and restores the value of + expecting_in_command + - PST_FORCMD: new parser state, used to say if we're parsing a `for' + command and waiting for an IN token (not used yet) + + 4/22 + ---- +config-top.h + - MULTIPLE_COPROCS: now enabled by default + + 4/23 + ---- +doc/bash.1,doc/bashref.texi + - add text clarifying the difference between PIPESTATUS and $? + +expr.c,redir.c,jobs.c,parse.y,arrayfunc.c,test.c,subst.c +builtins/declare.def,builtins/wait.def,builtins/printf.def + - went through and removed or modified TAGs for bash-5.3 + +lib/readline/bind.c + - rl_print_keybinding: handle case where there are no key sequences + bound to the command name; don't just print out every unbound key + +builtins/bind.def + - bind_builtin: if the shell compatibility level is > 52, interpret + additional non-option arguments supplied with -P and -p as bindable + command names and print out any bindings for those names + + 4/24 + ---- +Makefile.in,doc/Makefile.in,builtins/Makefile.in +lib/sh/Makefile.in,lib/glob/Makefile.in,lib/tilde/Makefile.in +lib/readline/Makefile.in + - MFLAGS -> BASH_MAKEFLAGS, rely on make passing MAKEFLAGS in the + environment + From a report by Cedric Blancher + +buildconf.h + - new build include file, construct from buildconf.h.in; contains a + subset of config.h for use by the build tools + +mksyntax.c + - now assumes a C90 compilation environment; includes buildconf.h for + any build-time configuration variables + +Makefile.in + - buildconf.h: add to CREATED_CONFIGURE + - mksyntax: now depends on buildconf.h instead of config.h + + 4/25 + ---- +support/bashversion.c,version.c + - now assumes a C90 compilation environment; includes buildconf.h for + any build-time configuration variables + +support/printenv.c,support/recho.c,support/xcase.c,support/zecho.c + - now assumes a C90 compilation environment and POSIX.1-1990 execution + environment + + 4/26 + ---- +redir.h + - RX_INTERNAL, RX_USER (unused), RX_SAVCLEXEC, RX_SAVEFD, RX_EXPANDED: + new values starting at 0x80, now intended for rflags member of a + struct redirect; don't want them colliding with O_XX flags for open + and fcntl + +redir.c + - rflags: save redirect->rflags and pass it to make_redirection if + we're translating a redirection into a new one + - new_redirect: pass rflags to all calls to make_redirection now that + it holds more than REDIR_VARASSIGN + - RX_INTERNAL, RX_USER (unused), RX_SAVCLEXEC, RX_SAVEFD, RX_EXPANDED: + check and assign these in the rflags member; they're only used here + - do_redirection_internal: assign new_redirect->rflags back to + redirect->rflags since it can possibly be modified with RX_EXPANDED + - do_redirection_internal: take care not to leave REDIR_VARASSIGN in + new_redirect->rflags, since it will cause redirector to be freed, + leading to accessing freed memory + From a report by Clark Wang and a hint from + and Grisha Levit + + 4/28 + ---- +lib/sh/anonfile.c + - anonopen: call memfd_create with MFD_NOEXEC_SEAL + From a report by Kerin Millar + + 4/29 + ---- +shell.c,shell.h + - su_shell: now global + +variables.c + - get_bash_name: use the user's login shell for $BASH if the shell is + a login shell and the name is "-su". + From https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1069978 + +subst.c + - uw_unbind_localvar: unwind-protect to unbind a local variable at + the current function context + - function_substitute: make sure we unbind the local REPLY we created + at the current (fake) context + From a report by Koichi Murase + + 4/30 + ---- + +subst.c + - expand_arrayref: fix crash from freeing memory that's only allocated + and initialized if ARRAY_VARS is defined + Report and patch from Henrik Lindström + +jobs.h,jobs.c + - JLIST_POSIX: new format argument for pretty_print_job; implements + POSIX requirement that jobs display the status of all background + jobs and all jobs the user hasn't been notified about (unused yet) + - JLIST_BGONLY: new format argument for pretty_print_job; restricts + output to background jobs only (unused yet) + +jobs.c,jobs.h,execute_cmd.c,subst.c + - freeze_jobs_list: now takes an int argument with the new value of + jobs_list_frozen; prep for having different values with different + meanings; changed callers + +jobs.c + - wait_for_any_job: return right away if jobs_list_frozen > 0; allow + job status changes (e.g., J_NOTIFIED) if jobs_list_frozen < 0; use + this instead of testing executing_funsub directly + - notify_and_cleanup: allow notification and status change if + jobs_list_frozen < 0; don't delete any dead jobs + - should_notify: takes a job index and returns 1 if the shell would + notify the user about it, given the current job state + - pretty_print_job: if the jobs list is frozen, only print status + about jobs for which the shell would notify users (by calling + should_notify()) + +subst.c + - function_substitute: freeze the jobs list with value -1 so jobs + can change status and possibly inhibit printing by `jobs' + + 5/2 + --- +jobs.c + - notify_and_cleanup: allow job notifications if an interactive shell + is running a trap (interactive == 0 && interactive_shell && running_trap) + Fixes report by Koichi Murase on 11/14/2022 + - print_pipeline: don't print an extra space before the pipeline; push + that into pretty_print_job; print the space after the pid if we + print one + +jobs.h + - LONGEST_SIGNAL_DESC: update to 27 (macos SIGPROF). This changes the + test output + + 5/3 + --- +builtins/common.h + - SEVAL_NOTIFY: new flag for parse_and_execute; means we want job + notifications even though we're not interactive at this time and + would not satisfy the conditions + +builtins/evalstring.c + - parse_prologue: if SEVAL_NOTIFY is supplied, unwind-protect + want_job_notifications and set it to 1 + +jobs.c,jobs.h.nojobs.c + - want_job_notifications: new global variable, initialized to 0 + +jobs.c + - notify_and_cleanup: notify about dead jobs if want_job_notifications + is non-zero + +parse.y + - execute_variable_command: call parse_and_execute with the SEVAL_NOTIFY + flag + +eval.c + - reader_loop: call notify_and_cleanup before executing $PROMPT_COMMAND + if the shell is interactive and prompting + +trap.c + - run_pending_traps,_run_trap_internal,run_exit_trap: add SEVAL_NOTIFY + to the flags for parse_and_execute if the shell is interactive + +bashline.c + - bash_execute_unix_command: add SEVAL_NOTIFY to the flags for + parse_and_execute if the shell is interactive + Rest of fix for report by Koichi Murase + on 11/14/2022 + + 5/6 + --- + +execute_cmd.c,shell.c,builtins/evalfile.c,unwind_prot.c + - change some translated error messages to make the text more uniform + and reduce the number of gettext() calls + +redir.c,parse.y,bashhist.c.locale.c +builtins/common.c,builtins/bind.def,builtins/exec.def,builtins/fc.def +builtins/help.def,builtins/mapfile.def,builtins/printf.def,builtins/read.def +builtins/ulimit.def + - change some error messages to avoid having the format be the return + value from gettext() to avoid clang complaints; simplified + translatable strings and made them more uniform by removing printf + formatting directives + +execute_cmd.c + - notfound_str: cache the translated version of "command not found" + so we can call gettext early on and work around a macOS misfeature + From a MacPorts ticket https://trac.macports.org/ticket/68638 + forwarded by Tom + - execute_disk_command: use notfound_str instead of calling gettext + every time a command isn't found + +execute_cmd.c,execute_cmd.h + - init_notfound_str: call gettext to initialize and translate + notfound_str + - execute_disk_command: call init_notfound_str before forking if it + hasn't been initialized + +locale.c + - set_default_locale_vars: after we set the appropriate values for the + locale shell variables, call init_notfound_str to force a call to + gettext() + +jobs.c + - wait_for: don't try to set the tty state if we're running a trap, + even if a process terminates due to a signal + + 5/7 + --- +builtins/enable.def + - enable_builtin: don't try to turn enable f into enable -f f if the + shell is restricted + + 5/11 + ---- + +doc/bash.1,lib/readline/doc/readline.3,lib/readline/doc/rltech.texi + - document some of the bindable commands bound to Home, End, Insert, + Page Up, and Page Down, if those keys exist + From a report by Xose Vazquez Perez in 3/2024 + +configure + - make sure to note in CHANGES that configure now supports + --enable-year2038 for large time_t + + 5/14 + ---- +pathexp.c + - glob_quote_char: new function, identify characters that should have + backslashes preserved when quoting a glob pattern. Currently has + all the glob_char_p characters plus `%' and `#' for pattern + substitution and removal. + Fixes issue reported by Andreas Schwab + + 5/16 + ---- +pcomplete.c + - programmable_completions: change to allow a newly-loaded compspec + (after a completion function returns 124) to be used in more cases + From a patch from Grisha Levit + +mksyntax.c,version.c,support/bashversion.c + - include config.h if CROSS_COMPILING is not defined, assuming that + the build host and target host are the same + +buildconf.h.in + - if cross-compiling, define _POSIX_C_SOURCE and _XOPEN_SOURCE to + get the C90/1003.1-1992 compilation environment we assume + From a report from Grisha Levit + + 5/17 + ---- +pathexp.c + - globsort_sizecmp,globsort_blockscmp: replace subtraction with a + generic transitive comparison function to avoid problems with + integer underflow + From a report from Grisha Levit + + 5/20 + ---- +lib/readline/kill.c + - _rl_bracketed_text: make sure buf is null-terminated even if + rl_read_key() returns an error + From a report from Grisha Levit + +builtins/read.def + - read_builtin: if -u and -e are both supplied, dup the file descriptor + supplied as an argument to -u and use it in the new FILE * to pass + to readline as rl_instream. Works around an android problem with + stdio and application-managed file descriptors + Report and patch from Grisha Levit + + 5/21 + ---- +lib/sh/spell.c + - mindist: don't check best unless we set it + Report and patch from Grisha Levit + +jobs.c + - make_child: if FORK_NOJOB is in the flags argument, don't call + setpgid to set the child's process group in either the parent or + child + - alloc_process,dispose_process: allocate and deallocate a PROCESS; + changed callers + +subst.c + - command_substitute: call cleanup_the_pipeline after waiting for + the command substitution process, since we allocated it + + 5/22 + ---- +lib/readline/text.c + - rl_execute_named_command: fix a leak if the command name is null or + the bound function doesn't return (rl_abort) + Report and patch from Grisha Levit + +bashline.c + - command_word_completion_function: free directory_part if it's left + over from a previous completion + - command_subst_completion_function: free contents of match list left + over from previous completion + - bash_spell_correct_shellword: free text if it's "" before returning + - build_history_completion_array: only call qsort if there's actually + something in the array to sort + Report and patches from Grisha Levit + - bash_spell_correct_shellword: fix bug where we would correct the + previous word if we start on the first character of a word + - bash_spell_correct_shellword: make negative argument counts work + backwards, correcting words before point + Report from Grisha Levit + + 5/23 + ---- +lib/readline/text.c + - rl_change_case: if mbrtowc returns -1 or -2, jump to changing case + for a single character, since _rl_find_next_mbchar_internal() will + treat an invalid multibyte character as a sequence of bytes + Report from Grisha Levit + + 5/25 + ---- +execute_cmd.c + - shell_execve: fix typo in code that chops \r off the end of the #! + interpreter + Report and fix from Collin Funk + + 5/28 + ---- +execute_cmd.c + - time_command: only restore command->flags if we haven't longjmped + Report from Michael Maurer and + Grisha Levit + +subst.c + - skip_to_delim: if we're not skipping over command substitutions + lexically, call extract_command_subst instead of using the old + extract_delimited_string + Fixes bug reported by Oguz + +execute_cmd.c + - execute_arith_for_command: handle the extremely unlikely case that + the step or test expressions execute `break' or `continue' in a + nofork command substitution + Report from Oguz + + 5/29 + ---- +lib/readline/complete.c + - compute_lcd_of_matches: if we have multiple matches that compare + equally when using case-insensitive completion, but are different + lengths due to the presence of multibyte characters, use the + shorter match as the common prefix to avoid overflow + Report from Grisha Levit + + 5/30 + ---- +lib/readline/text.c + - _rl_readstr_init: don't call rl_maybe_replace_line since we're not + actually moving off this history line + Report from Grisha Levit + +builtins/read.def + - read_builtin: free ifs_chars in more return code paths + Report and patch from Grisha Levit + + 5/31 + ---- +quit.h + - ZRESET: new macro, calls zreset() if interrupt_state is non-zero + +lib/sh/zread.c + - zread: if read returns -1/EINTR, and we're executing a builtin, + call zreset just in case + +builtins/read.def + - read_builtin: if read returns > 0 (partial read) but interrupt_state + is non-zero, we're going to call throw_to_top_level, so call + ZRESET before that happens + Report from Oguz + - read_builtin: if zread/zreadc/zreadintr/zreadcintr return -1/EINTR, + make sure we call ZRESET in case zread did not + +variables.h + - ASSIGN_DISALLOWED: macro that encapsulates when an assignment to + SHELL_VAR *v with flags f will be disallowed and fail + +arrayfunc.c,execute_cmd.c,expr.c,redir.c,subst.c,variables.c +builtins/delare.def,builtins/getopts.def,builtins/printf.def,builtins/read.def + - use ASSIGN_DISALLOWED where appropriate + +arrayfunc.c + - assign_array_element_internal: if the assignment failed, as tested by + ASSIGN_DISALLOWED, free the assoc array key we allocated + Report from Grisha Levit + + 6/3 + --- +variables.c + - bind_function_def: don't copy the command tree if we're overwriting + a function definition; after function binding, the function_def + struct never uses the saved command anyway + From a report and patch by Koichi Murase + +parse.y + - make sure to free WORD in coproc WORD COMMAND after creating the + coproc struct + Report and patch from Grisha Levit + +builtins/exec.def + - exec_builtin: we don't need to set args to NULL; if shell_execve + reallocates args to add more items at the front, it has committed + to longjmp back to the top level + Report and patch from Grisha Levit + +subst.c + - expand_word_internal: dispose of the list used for $@ if we're not + splitting and save the space-separated list back to tword->word + Report and patch from Grisha Levit + +parse.y + - read_token: if we try to parse a conditional command and get a syntax + error, make sure to dispose of the partial command we created + Report and patch from Grisha Levit + - read_token: if we try to parse a conditional command and get a syntax + error because we read an unexpected WORD, dispose of the WORD_DESC + before returning -1 + Report and patch from Grisha Levit + - cond_term: if we read a WORD where we expect something else, dispose + of the WORD_DESC before returning COND_ERROR + Report and patch from Grisha Levit + + 6/10 + ---- +parse.y + - cond_term: if we read a WORD when expecting a close paren, dispose + of the WORD_DESC before returning COND_ERROR + - error_token_from_token: use the TOK argument instead of + current_token if we can't find the token as a reserved word or + symbol + + 6/12 + ---- +builtins/source.def + - source_builtin: add -p PATH option, searches PATH argument instead + of $PATH; overrides sourcepath; does not search $PWD if path search + fails + +doc/bash.1,doc/bashref.texi + - source: document -p + +pathexp.c + - if the size, blocks, or any of the time values compare equal, use + the name for a secondary sort key + +lib/sh/winsize.c + - tcgetwinsize: provide definition for missing newly-standard function + - get_new_window_size: use tcgetwinsize + +subst.c + - do_compound_assignment: if ASS_CHKLOCAL is in the flags, check for + variables at previous local scopes instead of just the current local + scope and the global scope + Part of fix for inconsistency between arrays and scalar variables + reported by Will Allan + +builtins/declare.def + - declare_find_variable: if `declare -G' is used, check for + variables at previous local scopes instead of just the current local + scope and the global scope + Rest of fix for inconsistency between arrays and scalar variables + reported by Will Allan + +pathexp.h + - SORT_NUMERIC: new "numeric" sort specifier + +pathexp.c + - globsort_numericcmp: new sort function for the "numeric" sort + specifier: all-digit names are sorted as numbers; names containing + any non-digits sort after all-digit names and are sorted + lexicographically. + Inspired by a discussion with Robert Elz + + 6/21 + ---- +lib/readline/text.c + - rl_change_case: make mlen size_t to assign the return value from + wcrtomb; change the tests of < 0 to use MB_INVALIDCH. + Report from Siteshwar Vashisht + + 6/26 + ---- +trap.c + - run_debug_trap: give the terminal back to pipeline_pgrp only if + job_control is enabled; that's the only way the trap command would + have given it to a different process group + Fixes bug reported by Mark March + + 6/27 + ---- +configure.ac + - remove support for cached files for cross-compiling; it's too hard + to keep them up-to-date without access to the platforms + + 6/28 + ---- +lib/readline/util.c + - _rl_audit_tty: make sure to close fd before returning on error + +lib/sh/casemod.c + - sh_modcase: use size_t variable as return value for wcrtomb; check + for invalid wide char and copy all characters in the multibyte + character as-is if it is + +lib/sh/zwrite.c + - zwrite: use size_t and ssize_t variables + +builtins/evalfile.c + - _evalfile: use size_t variable for return value from strlen() + +lib/readline/funmap.c + - rl_funmap_names: don't bother calling qsort if result doesn't have + any entries + + All from a report by Siteshwar Vashisht + + 6/29 + ---- +lib/readline/examples/histexamp.c,lib/readline/examples/manexamp.c, +lib/readline/examples/rl-callbacktest.c,lib/readline/examples/rl-callbacktest2.c, +lib/readline/examples/excallback.c,lib/readline/examples/rlptytest.c + - small changes to fix warnings + From a report by Hiroo Hayashi + + 7/1 + --- +execute_cmd.c: + - ADJUST_LINE_NUMBER: encapsulate code that adjusts line_number in + shell functions executed in interactive shells into a macro + + 7/2 + --- +doc/bash.1,doc/bashref.texi + - changes to the --rcfile description to avoid the use of `force' and + stay away from the word `replace' + +lib/readline/misc.c + - _rl_maybe_replace_line: old rl_maybe_replace_line, now takes an + argument saying whether or not to clear rl_undo_list + - rl_maybe_replace_line: now calls _rl_maybe_replace_line with a 0 + argument for backwards compatibility + +lib/readline/rlprivate.h + - _rl_maybe_replace_line: extern declaration + +lib/readline/search.c + - _rl_nsearch_init,rl_history_search_internal: call _rl_maybe_replace_line + with a 1 argument so these searches can manage rl_undo_list and + restore it appropriately + - rl_history_search_internal: don't set the history offset back to + oldpos if the history search is successful; we want the history offset + to be set to the position of the last matching line, like isearch + + 7/5 + --- +jobs.c + - procsub_reap: new function, blocks and unblocks SIGCHLD around + call to procsub_prune + - cleanup_dead_jobs: call procsub_reap even if there are no jobs in + the jobs list or the jobs list is frozen + Inspired by report from Zachary Santer + + 7/6 + --- +subst.c,subst.h,execute_cmd.c,jobs.c + - reap_procsubs: rename to delete_procsubs + + 7/7 + --- +aclocal.m4 + - BASH_CHECK_LIB_TERMCAP: check for ncursesw before ncurses, add + -lncursesw if found, to avoid pkgconfig issues for readline (since + this is a shared file) + Report and fix from Rosen Penev + + 7/8 + --- +builtins/evalstring.c + - should_optimize_fork: don't optimize the fork if we're executing in + a shell function and a return trap is set + - optimize_shell_function: mark a simple command at the end of a shell + function as a candidate for optimization, rather than setting + CMD_NO_FORK before the function executes -- it could set a return + trap + Report from Jens Schmidt + - parse_and_execute: don't let process substitutions or other calls + to parse_and_execute do + - parse_string: if flags & SEVAL_ONECMD, stop after parsing a single + command, even if it doesn't consume the entire string + +parse.y + - parse_string_to_command: call parse_string with SEVAL_ONECMD, since + we only want to parse a single command and make sure it consumes + the entire string, not consume the string and return the last command + parsed + + 7/9 + --- +bashline.c + - _ignore_completion_names: restrict force_fignore to act only on + completions that should be affected by FIGNORE; in other cases + act as if it were set to 1 + From a report and patch by Koichi Murase + + 7/15 + ---- +builtins/ulimit.def + - add help text saying that some of the units change in posix mode + + + 7/17 + ---- +subst.c + - remove some unused functions + +jobs.c,jobs.h + - procsub_search,procsub_delete: now take an extra parameter saying + whether or not to block SIGCHLD while they run; avoids overhead + when called when SIGCHLD is already blocked; changed callers and + extern declaration + - struct process now has a new FLAGS member; possible values defined + in jobs.h; initialized in alloc_process + - procsub_setflag,procsub_setflag: set one of the PROC_XXX flags on + one or all of the processes in the procsub list + - new value for the flags argument to make_child: FORK_PROCSUB + - add_process: now returns the PROCESS * it creates so the caller can + set flags or otherwise modify it + - get_job_by_pid: return NO_JOB for negative pids immediately + +subst.c + - process_substitute,command_substitute: call make_child with the + appropriate FORK_ flag + +jobs.c + - make_child: set PROC_ flags in the PROCESS * we create based on the + FORK_ flags the caller passes + - wait_for: only call set_procsub_status if the process has terminated + - wait_for_any_job: check for any terminated procsubs as well as any + terminated background jobs + +builtins/wait.def + - check_bgpids: rename to check_nonjobs + - wait_builtin: if the -n option is supplied and pid arguments are + supplied, check the bgpids list and procsubs for terminated processes + - check_nonjobs: if one of the pids in LIST corresponds to a terminated + procsub, return its status and move the procsub to the bgpids list + - set_waitlist: if we have a non-existent or invalid job, and a pid + argument that's >= 0, look for a procsub with that pid and set + PROC_WAITING if we have one + - unset_waitlist: unset PROC_WAITING in all procsubs + + 7/18 + ---- +jobs.c + - procsub_prune: set last_procsub_child to NULL if we are cleaning up + that process because it's terminated, since that will invalidate the + pointer + + 7/22 + ---- +lib/malloc/malloc.c + - RIGHT_BUCKET: don't check binsizes[nu-1] unless nu >= 1; clamp at 0 + otherwise + - internal_realloc: don't check bucket at nunits-1 unless nunits >= 1 + Report and fix from Collin Funk + + 7/25 + ---- +variables.c + - push_source: new function, pushes a filename to BASH_SOURCE; changed + callers (shell.c, execute_cmd.c, builtins/evalfile.c) + - bash_source_fullpath: new variable, if non-zero, push_source runs + the filename through sh_realpath before pushing it to BASH_SOURCE + Feature requested by several, including konsolebox + +builtins/shopt.def + - bash_source_fullpath: new option, controls bash_source_fullpath and + whether or not BASH_SOURCE contains full pathnames + +doc/bash.1,doc/bashref.texi + - bash_source_fullpath: document new shell option + + 7/26 + ---- +jobs.c,jobs.h,subst.c + - last_procsub_pid: new variable, set to the pid of last_procsub_child, + so it will survive the PROCESS * being deleted if we need it. Not + used yet + + 7/29 + ---- +doc/bash.1,doc/bashref.texi + - wait: update description to clarify wait -n and unify language + Inspired by report from Zachary Santer + - set: note that the -e behavior for pipelines is affected by the + state of the pipefail option + From a report by Martin D Kealey + +variables.c,hashcmd.c,builtins/hash.def,builtins/history.def,builtins/source.def + - use ABSPATH/RELPATH/absolute_program instead of testing for slash + explicitly + + 7/30 + ---- +lib/readline/histfile.c + - history_do_write: return 0 immediately if nelements < 0 + Report from ZeroIntensity Dev + + 8/3 + --- +lib/sh/zread.c,externs.h + - zungetc: new function, pushes a character back into a single char of + storage so it can be used with the zread* functions that call read(2) + directly and don't use lbuf. If we try to push back more than one + char, we use lbuf, assuming that the caller will accommodate it + +builtins/read.def + - read_mbchar: if we read a partial multibyte character (-2) and then + a delimiter that makes it an invalid multibyte character (-1), use + zungetc to push the delimiter back, adjust mbchar, and return what + we read so far to be added as single bytes + From a report by Kerin Millar + + 8/7 + --- +builtins/evalstring.c + - can_optimize_connection: only check bash_input.location.string if + bash_input.type == st_string, in case we want to use this in other + contexts. If we do, the caller *must* make sure it's the last + command in the calling context + +execute_cmd.c + - execute_subshell_builtin_or_function: if this is an async function + call, try to optimize away the fork before the last simple command + in the function body by calling optimize_shell_function + - execute_command_internal: if we have a simple command for which + CMD_TRY_OPTIMIZING is set in a SUBSHELL_ASYNC subshell environment, + try to set CMD_NO_FORK by checking via should_optimize_fork + + 8/9 + --- +parse.y + - yy_readline_get: before calling readline, call rl_clear_signals to + reset the signal handling disposition to a known state. Most of the + time it's a no-op + +lib/readline/signals.c + - _rl_handle_signal: make the call to sigprocmask(SIG_UNBLOCK,... + more symmetric with the corresponding call to SIG_BLOCK + +trap.c + - run_pending_traps: before calling run_interrupt_trap, restore + running_trap and trap_return_context, since _run_trap_internal + will save and restore them, too + +builtins/read.def + - read_builtin: if -e is supplied, make sure to install unwind-protects + to reset the attempted completion function and the event hook even + if the timeout is not supplied. + Report from Oguz + + 8/12 + ---- +lib/readline/histsearch.c,lib/readline/histlib.h + - history_search_internal: takes a new argument, LINEDIR, saying which + direction to perform the substring/pattern search in the line, + decoupling it from the direction through the history list; changed + all callers (history_search, history_search_prefix, _hs_history_search, + _hs_history_patsearch) + - _hs_history_search,_hs_history_patsearch: takes the same new LINEDIR + argument, just passes it to history_search_internal; changed all + callers (noninc_search_from_pos) + +lib/readline/search.c + - noninc_search_from_pos: changed calls to _hs_history_search and + _hs_history_patsearch + +lib/readline/histexpand.c + - get_history_event: instead of using function pointers to a history + search function, set the right flags and just call _hs_history_search + with those flags using -1 for list direction and line direction + + 8/13 + ---- +builtins/printf.def + - printf_builtin: fix params to call to mklong for long double formats + if STRTOLD_BROKEN is defined + +lib/sh/winsize.c + - rearrange includes to make sure is included if + HAVE_TCGETWINSIZE is defined + Report from Grisha Levit + + 8/14 + ---- +lib/readline/rlmbutil.h + - _rl_is_basic: adapted from gnulib is_basic; tells whether a character + is a single byte because it's guaranteed by ISO C and POSIX + +lib/readline/mbutil.c + - _rl_mbstrlen: counts the number of possibly multibyte characters in a + string depending on the current locale; uses _rl_utf8_mbstrlen or + _rl_gen_mbstrlen as appropriate (or strlen for a single-byte locale) + +lib/readline/readline.c + - _rl_internal_char_cleanup: if we are using multibyte characters, call + _rl_mbstrlen to determine whether or not we've read as many characters + than rl_num_chars_to_read says we should + Report from Grisha Levit + +builtins/read.def + - delim,delim_char: once again an int so we can more easily + distinguish -1 and other unsigned char values >= 0x7f; make + sure delim gets an unsigned char if passed with -d + - edit_line: now takes an int parameter for the delim char; only add + the delim to the end of the string if it's non-negative + - set_eol_delim,unset_eol_delim: now explicitly check whether or not + the delimiter character is non-negativesince it's no longer unsigned + - read_mbchar: make sure to cast the char read to unsigned before + comparing it against the delim + Report and patch from Grisha Levit + + 8/15 + ---- +include/shmbchar.h,lib/sh/shmbchar.c + - is_basic: update test for IS_BASIC_ASCII to include $, @, and `, + which ISO C guarantees to be single-byte + - is_basic_table: update bitmap to include new characters + + 8/21 + ---- +shell.c + - main: make sure to set read_but_dont_execute (-n) to 0 in an + interactive shell in case it was set at invocation, but not in + cases where it was forced with -i + Report from Milana <94888u@riseup.net> + + 8/22 + ---- +lib/readline/bind.c + - force-meta-prefix: new bindable variable, used to determine whether + to convert a meta character (>= 0x80) to an escape-prefixed key + sequence (using ESC as the meta prefix). If set, do the conversion + unconditionally; if unset, use the value of convert-meta as in + previous bash/readline versions + Suggestion from Reuben Thomas + - _rl_function_of_keyseq_internal: if we encounter a character/byte + with the eighth bit set, use force-meta-prefix to decide whether + to translate it to an escape-prefixed key sequence + - rl_bind_key: if we have a meta character, assume it was generated by + Meta- and honor the setting of force-meta-prefix + - rl_translate_keyseq: if we have \M-, use force-meta-prefix to decide + whether or not to translate it to an escape-prefixed key sequence + +lib/readline/doc/rluser.texi,lib/readline/doc/readline.3,doc/bash.1 + - force-meta-prefix: document new bindable variable and defaults + - convert-meta, enable-meta-key, input-meta, output-meta: update + description with better explanation of Meta key and meta characters, + and locale character encoding + - Key Bindings: expand description of \M- and Meta- modifiers + - Readline Introduction: expand description of the Meta key and the + various things it can do, reference force-meta-prefix and + enable-meta-key + + 8/26 + ---- +doc/bashref.texi + - case: add process substitution to the list of expansions for the + word. + Reported by shynur + +execute_cmd.c + - execute_null_command: if an empty simple command (no words, just + redirections) requires a fork, reset top_level and exit if we + longjmp there. This can happen with an expansion error while we + evaluate the redirection. + Report from youheng.lue@gmail.com + - execute_connection: in default mode, bash performs jobs notifications + in an interactive shell between commands separated by ';' or '\n'. + It shouldn't do this in posix mode, since posix now specifies when + notifications can take place + +examples/loadables/{realpath,csv,dsv,cut,stat,kv} + - changes to make them build when arrays are not available + Report from Dennis Clarke + +jobs.c + - notify_and_cleanup: make interactive shells notifying during sourced + scripts dependent on the shell compatibility level and inactive in + versions beyond bash-5.2 + Inspired by report from Zachary Santer + +doc/bashref.texi + - Bash posix mode: note the change with job notifications in command + lists + - Shell compatibility mode: note job notification changes for compat + level > 52 + +parse.y + - CHECK_FOR_RESERVED_WORD: call set_word_top here on the reserved word + token about to be returned; don't worry about trying to set it after + the fact + Report from Collin Funk + + 8/28 + ---- +parse.y + - CHECK_FOR_RESERVED_WORD: change word_top to keep track of the line + number where a compound command begins; call set_word_top on the + current token about to be returned + - read_token_word: call set_word_top if special_case_tokens returns + something; currently used for `{' + - set_word_top: add `{' to the list of compound commands we track + - grammar: every time we parse a group command or equivalent for the + `for' and `select' compound commands, decrement word_top after we + see the `}' + - parse_dparen: set arith_lineno from word_lineno[word_top] since we + now set it for FOR when we read it + + 8/29 + ---- +parse.y + - read_token: don't turn on PST_SUBSHELL after reading a left paren + if the last token was a WORD, since that's a function definition, + not a subshell + - read_token,parse_dparen: don't turn on PST_SUBSHELL if we run into + a left paren while parsing a conditional command (PST_CONDCMD is + set in parser_state) + - set_word_top: add `(' to the tokens saved in word_lineno + - grammar: decrement word_top in the subshell_command production + - read_token,parse_dparen: call set_word_top where we add PST_SUBSHELL + to parser_state + + 8/30 + ---- +parse.y + - set_word_top: add COND_START to the list of tokens that set + word_lineno[word_top] + - grammar: decrement word_top after COND_END + - rename: word_lineno -> compoundcmd_lineno, word_top -> compoundcmd_top, + set_word_top -> set_compoundcmd_top + +lib/readline/signals.c + - _rl_release_sigint: don't check for signals if we're already + handling a received signal + Report from Tycho Kirchner and + Eduardo A. Bustamante López + + 8/31 + ---- +builtins/printf.def + - printf_builtin: when parsing a time specification format, don't + increment the format pointer to check for 'T' unless it points + to a closing right paren, rejecting the format if it's not a `)' + when the loop breaks + Report from Andrey Kovalev + + 9/6 + --- +jobs.c,jobs.h + - notify_and_cleanup: now takes an argument saying which job to notify + about; if arg is -1 it notifies about all jobs as previously + - maybe_print_job_notifications: convenience function to encapsulate + policy about when to call notify_of_job_status in one place; called + by notify_and_cleanup + - notify_of_job_status,maybe_print_job_notifications: now take an int + argument with the same semantics as notify_and_cleanup + - wait_for_any_job: now call notify_of_job_status only on the job we + just retrieved and will return + - wait_for: don't call notify_and_cleanup if posixly_correct unless + the shell is not currently interactive, since posix says we can + notify in a non-interactive shell when a foreground job changes + state + +jobs.c,parse.y,eval.c,execute_cmd.c,builtins/jobs.def,trap.c + - notify_and_cleanup: changed all callers appropriately + +builtins/evalfile.c + - _evalfile: renamed to evalfile_internal + - evalfile_internal: increment and decrement (or unwind-protect) the + value of want_job_notifications; increment it to a non-zero value + if the shell is interactive and the compatibility level is <= 52 + (see change to notify_and_cleanup of 8/26) + +jobs.c + - maybe_print_job_notifications: remove clause testing sourcelevel; + use want_job_notifications for this + + 9/11 + ---- + +[prayers for the victims of 9/11] + + 9/12 + ---- +support/mkdep + - new version from Martin Kealey; modified for inclusion + +Makefile.in + - MKDEP_ variables to be able to control various aspects of `make + depend' + + 9/13 + ---- +configure.ac + - relstatus: update to `beta' + + + 9/16 + ---- +builtins/jobs.def + - jobs_builtin: when listing individial jobs, don't call notify_and_cleanup + (which notifies about outstanding terminated jobs) if the shell is + interactive and in posix mode + + 9/20 + ---- +jobs.c + - wait_for_single_pid: if wait finds a status for the pid argument in + the bgp list, remove it from the bgp list if the shell is in posix + mode + + 9/23 + ---- +execute_cmd.c + - execute_command_internal: if the COMMAND * passed in to execute has + the CMD_INVERT_RETURN flag set, make sure we propagate that to + simple commands, for commands, arith for commands, select commands, + case commands, while/until commands, if commands, group commands, + shell functions, pipelines, subshells, and connections so if set -e + is enabled in the body (or test for if/while/until) its effect is + ignored + - execute_in_subshell: if the subshell's return status is being inverted, + make sure to ignore set -e in the commands the subshell executes + - execute_pipeline: if the pipeline's return status is being inverted, + make sure to ignore the effects of set -e in all pipeline elements + - execute_connection: if the list's return status is being inverted + (tough to do because of precedence), make sure the list commands + ignore the effect of set -e + + 9/24 + ---- +jobs.c + - start_job: don't fetch the tty settings if we're being called from + a readline key binding (bind -x) or programmable completion + From a report by David Moberg + + 9/25 + ---- +jobs.c + - wait_for_any_job: if the jobs table is empty and there are no + eligible procsubs, and the shell is in posix mode, take a random + pid from the bgpids table, delete it, and return its status + (since we would be deleting that pid from bgpids anyway) + + 9/26 + ---- +lib/readline/histexpand.c + - history_tokenize_word: fix off-by-one error (incrementing i one too + many positions after the increment in the loop) preventing words + like `$((expr))' from being tokenized correctly + Report from Milana <94888u@riseup.net> + +config.h.in,configure.ac + - new option: bash-source-fullpath-default: set it to make the + bash_source_fullpath option enabled by default; sets + BASH_SOURCE_FULLPATH_DEFAULT + Based on a patch from konsolebox + +variables.c + - bash_source_fullpath: initialize to BASH_SOURCE_FULLPATH_DEFAULT, + set by configure + +doc/bashref.texi + - --enable-bash-source-default: document + + 9/27 + ---- +doc/bash.1,doc/bashref.texi + - update builtins documenation: make language and paragraph breaks + more consistent between the document formats; update active + language + + 10/1 + ---- +doc/bash.1,doc/bashref.texi,lib/readline/doc/rluser.texi,lib/readline/doc/hsuser.texi + - update more documentation sections to make language consistent + between formats, reduce passive voice + + 10/7 + ---- +lib/readline/doc/history.3 + - update history expansion section to be consistent with hsuser.texi + and bash.1 + +doc/bash.1,doc/bashref.texi,lib/readline/doc/rluser.texi,lib/readline/doc/readline.3 +lib/readline/doc/hsuser.texi,lib/readline/doc/history.3 + - next set of updates for consistency between formats, update language, + fix formatting conventions + + 10/11 + ----- +lib/readline/doc/rltech.texi,lib/readline/doc/hstech.texi + - next set of updates for consistency between formats, update language, + fix formatting conventions + + 10/12 + ----- +Makefile.in,builtins/Makefile.in + - update dependencies on readline, history include files + +builtins/shopt.def + - update bash_source_fullpath reset to use new default + +configure.ac + - update to use the right option name for bash-source-fullpath-default + Report and patch from Grisha Levit + +braces.c + - mkseq: fix loop condition to avoid integer overflow + Report and patch from Grisha Levit + +builtins/help.def + - show_desc: don't assume that long_doc[0] ends with a newline, + just add one manually when we hit a newline or NULL + Report and patch from Grisha Levit + +builtins/read.def + - read_builtin: don't check the timeout after breaking out of the + character read loop unless we didn't read anything (i == 0) and + the last read return EOF or error + - read_builtin: move check_read_timeout call to the end of the read + loop, after we check for the delimiter and whether or not we've + read the right number of characters, so we always return any + valid data + Report from Thomas Oettli + + 10/14 + ----- +jobs.c + - wait_for_any_job: in posix mode, take any terminated pid from bgpids + before waiting for a running job to terminate + Inspired by report from Zachary Santer + + 10/14 + ----- +doc/bash.1,doc/bashref.texi + - next set of updates for consistency between formats, update language, + fix formatting conventions (job control section) + +doc/bash.1,doc/bashref.texi,lib/readline/doc/readline.3,lib/readline/doc/rluser.texi + - minor wording updates and typo fixes from + G. Branden Robinson + + 10/15 + ----- +doc/bash.1,doc/bashref.texi,lib/readline/doc/readline.3,lib/readline/doc/rluser.texi + - wording/formatting updates and typo fixes from + G. Branden Robinson + +doc/bash.1 + - update .FN macro, use it consistently for filenames, like @file{} + +doc/bashref.texi + - make sure to use @dots and @file consistently + +doc/bash.1,lib/readline/doc/readline.3 + - make sure `readline' is typeset consistently + + 10/18 + ----- +sig.c + - fix minix typo + +lib/readline/history.c + - history_do_write: for portability, make sure that the offset argument + to mmap is page-aligned, since some systems (linux, macos) require it. + Report and patch from Grisha Levit + +lib/readline/util.c + - rl_tilde_expand: rearrange code to do bounds checking before data + validation when finding the end of the tilde-word to avoid + touching uninitialized data + Report and patch from Grisha Levit + + 10/20 + ----- +doc/bash.1,doc/bashref.texi + - update word splitting section to add what IFS whitespace means and + how word splitting uses it. Based on a bug-bash discussion + + 10/21 + ----- +lib/readline/colors.c +doc/bash.1,lib/readline/doc/readline.3,lib/readline/doc/rluser.texi + - RL_COLOR_PREFIX_EXTENSION: remove the leading `.' again; this was + the result of a misunderstanding about how `dircolors' works + Report from Daniël Gerbrand Haasbroek + +lib/readline/isearch.c + - _rl_isearch_dispatch: when adding the character to the search + string, insert it as a single byte in the C locale (or if we're + not doing multibyte characters) + Report and patch from Grisha Levit + + 10/23 + ----- +doc/bash.1,doc/bashref.texi + - SIGNALS: update section to make it clear how job control affects + SIGINT receipt and the behavior of the shell when it's waiting + for a command that receives one. + From a suggestion by Simone Robinson + +builtins/common.c + - get_job_spec: warn about deprecated notation if the job spec doesn't + have a leading `%'; code to return BAD_JOBSPEC tagged for bash-5.4 + - sh_invalidjob: new convenience function to print error for invalid + job specifications + +builtins/jobs.def, builtins/ kill.def, builtins/ wait.def, builtins/fg_bg.def + - handle BAD_JOBSPEC return from get_job_spec; call sh_invalidjob. + Nothing returns that yet. + +builtins/kill.def + - kill_builtin: change to use common error message via sh_badpid() if + we get an argument where the first character is not a digit or `%' + +builtins/jobs.def + - jobs_builtin: check for INVALID_JOB return from get_job_spec to + avoid call to get_job_by_jid + + 10/24 + ----- +error.c, error.h + - err_invalidid: common error function for invalid identifiers; + changed callers in execute_cmd.c, general.c + +general.c + - valid_function_word: separated posix check against special builtin + names (flags&4) and posix check for valid identifiers (flags&1); + callers need to differentiate. This means that posix mode does not + require function names to be valid identifiers + +execute_cmd.c + - execute_intern_function: don't call valid_function_word with + (flags&1) in posix mode unless POSIX_RESTRICT_FUNCNAME is defined; + call with flags&4 to keep the check against special builtin names + +print_cmd.c + - print_function_def,named_function_string: don't print functions + with names that are invalid identifiers with a leading `function' + +config-top.h + - POSIX_RESTRICT_FUNCNAME: placeholder, not defined by default + +doc/bashref.texi + - Posix mode: remove item about function names being valid shell + identifiers + + 10/25 + ----- +aclocal.m4 + - simplify the checks for the various members of struct dirent + Report and patch from Grisha Levit + +m4/strtoimax.m4 + - simplify and remove redundant caching and cache check + Report and patch from Grisha Levit + +builtins/common.c + - get_exitstat: make the behavior of exit with no arguments + running in a trap action the same as return: check for any trap + (running_trap > 0) in the current execution_context. This is + POSIX interp 1602, in POSIX.1-2024 + +stringlib.c + - find_token_in_alist: if FLAGS is non-zero, do *not* allocate new + memory for the token. The existing behavior is to allocate memory + and return a copy of the token, and all callers pass 0 + +parse.y + - compoundcmd_lineno: now an array of `struct tokeninfo', which + has line number and current compound command information + - change compoundcmd_lineno[compoundcmd_top] to + compoundcmd_lineno[compoundcmd_top].lineno in all calls + - set_compoundcmd_top: in addition to assigning line number info, + assign T to compoundcmd_lineno[compoundcmd_top].token + - report_syntax_error: if we get a syntax error while looking for + shell_eof_token (comsubs), include the token we were looking for + in the error message + - report_syntax_error: if we are reporting an unexpected EOF error, + and compoundcmd_top >= 0, look up the token for the compound + command we're parsing, including `(', and change the error message + to include it + + 10/26 + ----- +Makefile.in + - PURIFY,GLOBC,GLOBO,ALLOC_FILES,LIBRARY_SOURCE: remove + - ADDON_CFLAGS,ADDON_LDDFLAGS: initialize to empty + - GRAM_H: remove from HSOURCES + - profiling-tests: use Program instead of PROGRAM + +builtins/Makefile.in + - DEBUG: initialize from configure + - SYSTEM_FLAGS: remove, since it's not passed from topdir Makefile + - ADDON_CFLAGS: initialize to empty + +lib/glob/Makefile.in + - ADDON_CFLAGS: initialize to empty + +lib/readline/Makefile.in + - ADDON_CFLAGS: initialize to empty + - APP_CFLAGS: remove + +lib/sh/Makefile.in + - DEBUG: initialize from configure + - ADDON_CFLAGS: initialize to empty + - LIBOBJDIR: initialize to empty; configure uses it in LIBOBJS + +lib/tilde/Makefile.in + - ADDON_CFLAGS: initialize to empty + - CCFLAGS: add ADDON_CFLAGS, replacing ASAN_CFLAGS + +support/Makefile.in + - SYSTEM_FLAGS: remove, since it's not passed from topdir Makefile + + Makefiles report and patch from Grisha Levit + +version.c,shell.h + - default_compatibility_level: int variable, initialized to + DEFAULT_COMPAT_LEVEL like shell_compatibility_level + +variables.c + - sv_shcompat: use default_compatibility_level instead of + DEFAULT_COMPAT_LEVEL so variables.o doesn't have to depend on + version.h + +builtins/shopt.def + - set_compatibility_level: use default_compatibility_level instead + of DEFAULT_COMPAT_LEVEL so shopt.o doesn't have to depend on + version.h + - don't include version.h any more + +configure.ac,Makefile.in,support/Makefile.in,doc/Makefile.in + - remove some unused variables: BASE_CFLAGS_FOR_BUILD, DEBUGGER_DIR, + INTLOBJS, TEXINDEX, TEX, MALLOC, SIGNAMES_SUPPORT + From a report by Martin D Kealey + + 10/28 + ----- +builtins/exec.def + - exec_builtin: don't try to print an error message in the cases + where shell_execve prints one, in case we have execfail set + Report from Emanuele Torre + +Makefile.in + - LIBRARY_SOURCE: add back in to tags targets, add definition + Suggestion from Mike Jonkmans + + 10/31 + ----- +lib/readline/search.c + - make_history_line_current: change to use the same strategy to move + to a history line as incremental search: one or more calls to + rl_get_{next,previous}_history + - dispose_saved_search_line: remove + - noninc_dosearch: no longer need to call _rl_unsave_saved_search_line + or dispose_saved_search_line; use new calling convention for + make_history_line_current + - _rl_nsearch_init: don't need to call _rl_maybe_replace_line, wait + until we move to the history line + - _rl_nsearch_dosearch: free the undo list unconditionally, since we + are committed to using the contents of rl_line_buffer as the search + string + - _rl_nsearch_dosearch: if we abort because of no search string, call + _rl_unsave_saved_search_line and let the caller clean up + - _rl_nsearch_dosearch: if the search fails, reset rl_point to the + saved point, since we will be restoring the old line + - rl_history_search_internal: don't bother to save and restore the + search line, since we don't use rl_line_buffer for anything + - rl_history_search_internal: use new calling convention for + make_history_line_current + - all these changes unify the incremental and non-incremental search + implementations + +lib/readline/readline.c + - rl_initialize: reset rl_eof_found to 0 at the same time we reset + the EOF state + Report and fix from Andrew Burgess (GDB) + + 11/6 + ---- +lib/readline/display.c + - rl_redisplay: if we changed screen lines during the redisplay and + we need to return to the line with the cursor, make sure to account + for differing numbers of invisible characters in the two lines + - rl_redisplay: if we need to redisplay the prompt because we moved + into a portion of it containing invisible characters while moving + to the line containing the cursor, make sure to account for the + cursor being on a line other than 0 and the prompt wrapping lines. + If it wraps, we only want to redisplay the portion after the line + wrap before the line the cursor is on + Fix for C locale issues reported by Grisha Levit + + 11/7 + ---- +lib/termcap/termcap.c + - tgetent: fix small memory leak on file open error + +Makefile.in + - y.tab.h: move from CREATED_HEADERS to INSTALLED_HEADERS so we don't + clean it + - maybe-clean: slightly change the syntax of the recipe + +doc/Makefile.in + - PSFILES: split into CREATED_PS and ps files from the distro + so we just remove CREATED_PS in maintainer-clean target + - PDFFILES: split into CREATED_PDF and ps files from the distro + so we just remove CREATED_PDF in maintainer-clean targets + - clean,mostlyclean: swap + - mostlyclean: don't remove Makefile + - maybe-clean: use realpath equivalent like in top-level Makefile.in + Report from Mike Jonkmans + + 11/11 + ----- +Makefile.in,doc/Makefile.in,lib/glob/Makefile.in,lib/readline/Makefile.in +lib/malloc/Makefile.in.,lib/tilde/Makefile.in + - mostlyclean: swap with clean where appropriate + - add .PHONY target for clean targets where appropriate + +Makefile.in,configure.ac + - STDCKDINT_H: variable for possibly-created file stdckdint.h, for + dependencies; add dependencies where appropriate + +Makefile.in,doc/Makefile.in + - add various gnu-standard install targets that do nothing + + 11/14 + ----- +CHANGES,NEWS + - updated for bash-5.3-beta + + 11/15 + ----- +lib/sh/snprintf.c + - wchars: fix small memory leak by freeing lbuf if wcrtomb fails + Report from SerGoGubarev + +lib/readline/complete.c + - vector_len: an inline convenience function to return the length + of an array of strings; callers are remove_duplicate_matches, + rl_old_menu_complete, rl_menu_complete + - rl_complete_internal: add `$' as a value for what_to_do that + exports a (possibly null) list of possible completions to an + application or another process by writing them, using a specific + protocol, to rl_outstream + - rl_export_completions: bindable command to perform word completion + and write the results, with other information, to rl_outstream + - _rl_export_completions: workhorse function to export the completions + Based on a patch from Matthew Tromp , + original request from Spencer Baugh back in 11/23 + +lib/readline/readline.h + - rl_export_completions: extern declaration + +lib/readline/funmap.c + - export-completions: new bindable command name + +doc/bash.1,lib/readline/doc/readline.3,lib/readline/doc/rluser.texi + - export-completions: document, including output format + + 11/19 + ----- +Makefile.in + - HYBRID_HEADERS: new variable containing header files that may appear + in the build directory or the source directory + - maybe-install-headers: rule to install header files that may appear + in the build directory or a subdirectory of it; install-headers + depends on it + - uninstall-headers: remove $(HYBRID_HEADERS); fix typo in recipe + + 11/21 + ----- +builtins/printf.def + - chk_converror: inline function to use for single place to check + for numeric overflow, change callers to use it + + 11/25 + ----- +doc/bash.1,doc/bashref.texi + - minor updates to the section on bracket expressions in pattern + matching + +builtins/command.def + - update -v help string to indicate that the output is a single word + Report from Andrew Davis + + 11/26 + ----- +builtins/printf.def + - chk_converr: add check for no characters being converted at all, + print same warning message as if *ep != 0. This covers the case of + an empty string argument. + Report by Paul Eggert + +Makefile.in,doc/Makefile.in + - uninstall: make sure the bash-specific directories created by + `make install' are emptied and removed + + 11/27 + ----- +doc/bash.1,doc/bashref.texi +lib/readline/doc/readline.3,lib/readline/doc/history.3 +lib/readline/doc/rluser.texi,lib/readline/doc/rltech.texi + - another set of updates for formatting consistency, language + consistency between man pages and info files + + 12/1 + ---- +lib/readline/misc.c + - rl_get_previous_history: call _rl_maybe_replace_line with arg of 1 + so it clears rl_undo_list, since this may not immediately replace + rl_undo_list with something from history + Report from Grisha Levit + + 12/5 + ---- +doc/bash.1,doc/bashref.texi +lib/readline/doc/rluser.texi + - updates for active voice, future tense, formatting and fonts, edits + to Programmable Completion + Suggestions from G. Branden Robinson + + 12/10 + ----- +lib/readline/complete.c + - fnprint: make sure _rl_completion_prefix_display_length and + _rl_colored_completion_prefix are mutually exclusive, since the + callers assume they are. + +bashline.c + - bash_default_completion: if we're trying to complete a glob pattern, + and rl_completion_type is '?', tell readline not to append a slash + if the pattern ends in one. + +doc/bash.1,lib/readline/doc/readline.3,lib/readline/doc/rluser.texi + - completion-prefix-display-length: note that readline uses `___' + instead of an ellipsis if the filename begins with a period + All reported by Frederick Abell + +doc/bash.1,doc/bashref.texi + - PIPESTATUS: enumerate the commands that set PIPESTATUS + From a report by Ulrich Müller + +lib/readline/isearch.c + - _rl_isearch_init: change to call _rl_maybe_replace_line with arg + of 1 so rl_undo_list gets cleared (see change from 12/1) + Report from Grisha Levit + + 12/13 + ----- +CHANGES,NEWS + - updated for bash-5.3-beta + + 12/15 + ----- +lib/readline/histexpand.c + - get_history_event: make sure we don't change history_offset whether + the search succeeds or fails, don't set it to history_length. + Callers don't expect to have the history offset changed out from + under them. + Fixes bug reported by Grisha Levit + + 12/16 + ----- +lib/readline/util.c + - _rl_abort_internal: make sure to clear _rl_command_to_execute + Report and patch from Grisha Levit + +tests/printf7.sub,tests/cond-regexp2.sub + - accommodate different error messages across different systems + + 1/2/2025 + -------- +tests/run-all, tests/run-minimal + - BASHOPTS: unset or unexport as appropriate, same as SHELLOPTS + From a report by Martin D Kealey + + 1/9 + --- +subst.c + - string_extract_verbatim: take into account the fact that CTLESC can + quote multibyte characters; use ADVANCE_CHAR instead of increment + Fixes bug reported by jktseug@gmail.com + + 1/10 + ---- +expr.c + - expr_bind_variable,expr_streval: suppress additional expansion if + called by the `let' builtin, whether or not array_expand_once is set + - expr_skipsubscript: suppress expansion while parsing subscripts + whether array_expand_once is set or not + Still have to change tests if this goes final + These are all conditional on shell_compatibility_level > 51 + From a bug-bash post by Greg Wooledge + + 1/14 + ---- +lib/readline/complete.c + - _rl_export_completions: use print_filename instead of fprintf to + display the possible completions so slashes and file types can + be included + From a patch from Matthew Tromp + + 1/15 + ---- +examples/loadables/fltexpr.c + - fltexpr: new loadable builtin to do floating-point arithmetic + expression evaluation and optionally print the result + + 1/16 + ---- +builtins/printf.def + - getarg(), advancearg(): cosmetic changes to make it easier to + implement %N$ format specifiers in the future + + 1/18 + ---- +subst.c + - array_length_reference: requesting the length of an element of an + unset variable using array syntax is a fatal error when `set -u' + is enabled and the subscript is not `@' or `*'. + Inspired by a report from Ian Kelling + + 1/20 + ---- +parse.y + - decode_prompt_string: since Debian has made the spectaculary bad call + to allow arbitrary characters in usernames, protect the results of + the \u expansion in the same way as \[Ww] and \[Hh] (externally- + controlled data) + From https://savannah.gnu.org/patch/?10496 + + 1/21 + ---- +eval.c + - reader_loop: if we longjmp with ERREXIT, don't reset any local + function contexts in posix mode, since POSIX says to exit as if + executing the `exit builtin with no arguments'. Revision of change + from 7/2022. + From a report by Ivan Shapovalov in 11/2024 + +lib/readline/display.c + - rl_redisplay: after calling update_line, when putting the cursor + where it needs to be and reprinting part of the line with the + prompt that contains invisible characters, make sure we start to + output characters at the portion in the prompt buffer that begins + on the current line and only offset by the number of invisible + characters on the current line, and set _rl_last_c_pos accordingly + in both multibyte and singlebyte locales. + Fixes bug reported by Andreas Schwab + + 1/22 + ---- +execute_cmd.c + - execute_builtin_or_function: if we're executing the exec builtin, + and there are redirections, let exec_builtin handle disposing of + redirection_undo_list if there is no program name to execute, so + it's still there if exec returns and doesn't exit the shell. + Then we can manage disposing of exec_redirection_undo_list and + letting the redirections be undone as normal. + This is POSIX interp 1896, with modifications from + https://www.austingroupbugs.net/view.php?id=1896#c7037 + +builtins/exec.def + - exec_builtin: dispose of redirection_undo_list and set it to NULL + if there is no program name operand; let execute_builtin_or_function + clean it up + + 1/23 + ---- +lib/readline/terminal.c + - _rl_tcgetwinsize,_rl_tcsetwinsize: function wrappers for tcgetwinsize/ + tcsetwinsize with fallbacks to ioctl if those functions aren't + available + - _rl_get_screensize: use _rl_tcgetwinsize + +lib/readline/rlwinsize.h + - _rl_tcgetwinsize,_rl_tcsetwinsize: extern function declarations + +lib/readine/rltty.c + - set_winsize: use _rl_tcgetwinsize/_rl_tcsetwinsize + - set_winsize: if _rl_tcgetwinsize succeeds, use the values to set + readline's idea of the screen size via _rl_set_screen_size + Inspired by a discussion with Olav Mørkrid + + 1/24 + ---- +lib/readline/signals.c + - _rl_handling_signal: new private variable, set to the signal we're + currently handling in _rl_signal_handler (SIGWINCH) or + _rl_handle_signal (all others). Only valid if RL_STATE_SIGHANDLER + is set + +lib/readline/rlprivate.h + - _rl_handling_signal: new extern declaration + +lib/readline/rltty.c + - set_winsize: only set readline's idea of the screen size if we're + executing in a signal handler context and handling SIGTSTP and the + application has indicated that it doesn't want the environment + variables LINES and COLUMNS to have priority (rl_prefer_env_winsize) + + 1/30 + ---- +jobs.c + - wait_for_single_pid: if wait_for returns -1/ECHILD, make sure to + return 257 just as if the child was not found, optionally printing + an error message if JWAIT_PERROR is supplied + From a discussion with Ian + + 2/8 + --- +redir.c + - do_redirection_internal: keep track of whether the redirector fd + was active with a new variable. Not used yet, should be optimized + out. + - add_undo_fd_redirect: new undo function using r_move_input so we + don't need a dup redir and a separate close redir to undo. Not + used yet + - do_redirection_internal: only call check_bash_input if we're + creating an undo list and not running one + +command.h + - OUTPUT_REDIRECT: add r_output_force + +input.c + - check_bash_input: if we dup the bash input fd to another in + save_bash_input, return that fd. Continue to return -1 on error + and 0 if we don't do anything but sync + +execute_cmd.c + - execute_null_command: force a subshell if any of the redirections + involve the bash input buffered fd. + From a report by Martin D Kealey + + 2/10 + ---- + +examples/loadables/chmod.c + - chmod: new loadable builtin, inspired by zhixu.liu@gmail.com in + https://savannah.gnu.org/patch/?10499 + + 2/11 + ---- +builtins/kill.def + - kill_builtin: in posix mode, return a failure status if any of the + pid/job arguments are not found or sending the signal fails. This + is consistent with + https://pubs.opengroup.org/onlinepubs/9799919799/utilities/kill.html#tag_20_64_14 + + 2/12 + ---- +braces.c + - brace_gobbler: take a new argument in which to return the type of + brace expansion (comma or sequence) we think we've found; change + all callers + - brace_expand: even if we find a BRACE_ARG_SEPARATOR, don't try to + perform expansion if brace_gobbler doesn't think we have a + BRACE_COMMA expansion + - valid_seqterm: new function, performs minimal validation on a + sequence expansion, used to skip over invalid sequence expressions + in brace_expand + - brace_expand: call valid_seqterm if brace_gobbler finds a BRACE_SEQ + expansion + Inspired by report from Robert Elz + + 2/13 + ---- +doc/bash.1,doc/bashref.texi + - clarified the handling of double quotes in EXPRESSION in + (( EXPRESSION )) and $(( EXPRESSION )) to say that only unescaped + double quotes are removed + +expr.c + - expr_bind_variable,expr_streval: revert change from 1/10 that + suppresses additional expansion when called by the `let' builtin, + tag for possible inclusion in a future release when I can look + at parallel changes to ((...)) and $((...)) (and probably + declare 'a[" "]=12' or similar) + + 2/14 + ---- + +lib/sh/zmapfd.c,externs.h + - zmapfd: now returns ssize_t in case of large files when size_t is + larger than int + +builtins/evalfile.c,builtins/help.def + - zmapfd: changed callers + +print_cmd.c + - print_redirection: the default file descriptor for <> is 0 + Report and fix from Emanuele Torre + + 2/18 + ---- +configure.ac + - check for d_type member of struct dirent for future use + + 2/24 + ---- +doc/bash.1,doc/bashref.texi + - document the word expansions performed on indexed array subscripts + and assoc array keys + - document the possibility and effect of empty strings on arithmetic + evaluation for substring expansion, arithmetic expansion, operands + to the the [[ command's arithmetic operators, the expression in + the (( compound command, and indexed array subscripts + + 2/24 + ---- +execute_cmd.c + - execute_command_internal: if executing a (...) subshell, make sure + to update BASH_COMMAND before exiting on an error return from the + subshell with -e set + Report from Max Bowsher + + 3/3 + --- +redir.c + - here_document_to_fd: if we are trying to use a pipe for a here + document, but the F_GETPIPE_SZ fcntl returns a value shorter than + the here document length, make sure to close the pipe file descriptors + +builtins/ulimit.def + - pipesize: use pathconf and _PC_PIPE_BUF if available + + 3/8 + --- +braces.c + - brace_expand: make sure to call valid_seqterm with the right length + so that text[tlen] == '}' + + 3/10 + ---- +builtins/help.def + - show_manpage: if the first line of long_doc doesn't contain a + newline, e.g., if it's a loadable builtin, add one so there's the + usual space between NAME and SYNOPSIS + +m4/codeset.m4 + - define HAVE_NL_LANGINFO + +lib/sh/strftime.c + - updates for locale-awareness + + 3/14 + ---- +lib/termcap/termcap.c,lib/termcap/tparam.c + - updates for ISO C + + 3/17 + ---- +configure.ac + - update release to rc1, update CHANGES and NEWS + + 3/19 + ---- +lib/readline/rlmbutil.h + - _rl_wcwidth: make sure wchar_t constants have an `L' prefix + + 3/24 + ---- +subst.c + - function_substitute: set temporary_env to NULL (we've already + set up an unwind-protect for it) before pushing the context, so + pop_context doesn't free it out from underneath the caller. + Report from Emanuele Torre + + 3/27 + ---- +shell.c + - set_bash_input: if the call to with_input_from_buffered_stream does + not result in a valid buffer corresponding to the file descriptor, + print an error message and set last_command_exit_value + From a report in https://savannah.gnu.org/patch/?10512 + + 4/3 + --- +lib/sh/gettimeofday.c + - updated from version in gnulib + +[bash-5.3-rc1 frozen] + + 4/4 + --- +examples/loadables/fltexpr.c + - add support for function calls; support almost all math function + calls in math.h + - add support for pi, gamma, e mathematical constants + + 4/7 + --- +doc/bash.1,doc/bashref.texi + - HISTFILESIZE: note that the history file will contain complete + history entries whose lines may total slightly more than + $HISTFILESIZE if the entries contain multiple lines + From a report from Jens Schmidt + - export: note that you can use -f with -p to display exported functions + From a report from Duncan Roe + +builtins/history.def + - add history -d start-end to the long doc + From a report from Duncan Roe + + 4/9 + --- +lib/readline/histfile.c + - read_history_range: changes to not skip blank lines if we are + reading a history file with multiline history entries. + From a report by Jens Schmidt + + 4/11 + ---- +bashline.c + - attempt_shell_completion: move the check for char_is_quoted from + check_redir to the caller, set in_command_position to 0 if the + command separator is quoted + From https://savannah.gnu.org/support/?111224 david@mandelberg.org + - check_extglob: break check for extended glob out into separate + function, call from attempted_shell_completion, set in_command_position + to -1 if it returns 1, as with the old call to check_redir + + 4/21 + ---- +builtins/read.def + - read_mbchar: if we read a delimiter character that makes an + incomplete multibyte character into an invalid multibyte character, + only push the delimiter back if we read that character ourselves + (i > 1). + Report from Greg Wooledge + + 4/23 + ---- +parse.y + - pop_delimiter: only decrement delimiter_depth if it's > 0, since + reset_parser() may have set it to 0 after the matching call to + push_delimiter + Report from Grisha Levit based on a report + from Александр Ушаков + + 4/25 + ---- +parse.y + - read_a_line: if the shell is interactive, and not reading from a + string, check whether a previous call to shell_getc has set + EOF_Reached and return EOF in this case, after resetting the + current token to '\n'. This makes EOFs that are not the first + character on the line `sticky' instead of just token delimiters. + From https://savannah.gnu.org/bugs/?67045 + - history_delimiting_chars: if it looks like we just finished a + subshell, and the line we're adding begins with an operator that + can't follow a semicolon, return a newline + From https://savannah.gnu.org/patch/?10517 + + 4/28 + ---- +parse.y + - parse_arith_command: if the character after the first right paren + isn't a right paren, making the construct a nested subshell, push + that character back and return the subshell command as the current + token string, which we push onto the pushed string list. Reading + one character more can cause synchronization problems with backslash + newline, among other things. + From https://savannah.gnu.org/patch/?10517 + + 4/29 + ---- +builtins/evalstring.c + - parse_string: only run the top-level unwind-protects if we're + actually going to be calling jump_to_top_level(); otherwise let + xparse_dolparen take care of it + From a report by Александр Ушаков + + 5/1 + --- +lib/sh/zread.c + - zungetc: rework to use a local 16-byte buffer so we can push back + multiple characters whether we use read or zread + - zread/zreadretry/zreadintr/zreadc/zreadcintr/zreadn: changed to use + zpopbuf to check whether we have pushed back bytes + - zreset,zsyncfd: reset the pushback buffer indices + +builtins/read.def + - read_mbchar: handle the delimiter being part of an invalid multibyte + character, not just the byte that makes the multibyte character + invalid: keep track of where the delimiter char is in the buffer and + use zungetc to push back that character and everything we read + after it so subsequent buffered (zread) or unbuffered (read) reads + will return them + + 5/2 + --- +lib/readline/display.c,lib/readline/histexpand.c,lib/readline/history.c, +lib/readline/input.c,lib/readline/search.c,lib/readline/shell.c, +lib/readline/util.c,lib/readline/readline.c,lib/readline/histfile.c + - fixes for issues (unused variables, etc.) uncovered by static + analysis + All from a report by Siteshwar Vashisht + + 5/16 + ---- +lib/readline/terminal.c + - NEED_EXTERN_PC: add __gnu_hurd__ to the systems that require this + if not using ncurses; rework the structure of the defines + Report from Collin Funk + +braces.c + - brace_gobbler: don't mark an expression as BRACE_SEQ if we've + already seen a comma and marked it as BRACE_COMMA, so we treat + it as a comma brace expansion. + From a report by Sam James + +support/install-sh + - new version from coreutils-git (2024-12-03.03); renamed from install.sh + +aclocal.m4 + - AM_PROG_INSTALL_SH, AM_PROG_INSTALL_STRIP: added from automake + +configure.ac + - call AM_PROG_INSTALL_SH, AM_PROG_INSTALL_STRIP + +Makefile.in + - STRIP: let configure substitute it from AC_CHECK_TOOL result + - INSTALL_STRIP_PROGRAM: let configure substitute it from + AM_PROG_INSTALL_STRIP + - install-strip: change to set INSTALL_PROGRAM=${INSTALL_STRIP_PROGRAM} + to avoid hard-coding `-s' in the recipe + All from a report by NR + + 5/18 + ---- +subst.c + - param_expand: if we expand a nameref that references an unset array + variable reference, make sure we enforce `nounset', with the usual + exceptions for `@' and `*' subscripts + From a report from Emanuele Torre + + 5/22 + ---- +buildconf.h.in + - add additional defines for conservative ISO C/POSIX environment + - add HAVE_C_BOOL define in case someone cross-compiles with a C23 + compiler + From a report by Bruce Dubbs + +builtins/mkbuiltins.c + - include buildconf.h instead of having separate defines when + cross-compiling + + 6/11 + ---- +lib/readline/terminal.c + - rework change from 5/16 to add __gnu_hurd__ to the list of systems + that don't need extern PC/UP/BC + Reported by Joel Ebel as a static link failure + due to multiply-defined symbols + + 6/12 + ---- +general.c + - valid_function_word: back out change from 2/4/2023 that allowed + quoted characters in function names. + Inspired by discussion with Robert Elz and + Koichi Murase + +parse.y + - read_token_word: set dollar_present if we see <( or >), backing + out change from 2/4/2023 diff --git a/INSTALL b/INSTALL index 2033143a1..ecc5fd9c0 100644 --- a/INSTALL +++ b/INSTALL @@ -5,45 +5,45 @@ These are installation instructions for Bash. The simplest way to compile Bash is: - 1. 'cd' to the directory containing the source code and type - './configure' to configure Bash for your system. If you're using - 'csh' on an old version of System V, you might need to type 'sh - ./configure' instead to prevent 'csh' from trying to execute - 'configure' itself. + 1. ‘cd’ to the directory containing the source code and type + ‘./configure’ to configure Bash for your system. If you're using + ‘csh’ on an old version of System V, you might need to type ‘sh + ./configure’ instead to prevent ‘csh’ from trying to execute + ‘configure’ itself. - Running 'configure' takes some time. While running, it prints + Running ‘configure’ takes some time. While running, it prints messages telling which features it is checking for. - 2. Type 'make' to compile Bash and build the 'bashbug' bug reporting + 2. Type ‘make’ to compile Bash and build the ‘bashbug’ bug reporting script. - 3. Optionally, type 'make tests' to run the Bash test suite. + 3. Optionally, type ‘make tests’ to run the Bash test suite. - 4. Type 'make install' to install 'bash' and 'bashbug'. This will + 4. Type ‘make install’ to install ‘bash’ and ‘bashbug’. This will also install the manual pages and Info file, message translation files, some supplemental documentation, a number of example loadable builtin commands, and a set of header files for developing loadable builtins. You may need additional privileges to install - 'bash' to your desired destination, so 'sudo make install' might be - required. More information about controlling the locations where - 'bash' and other files are installed is below (*note Installation + ‘bash’ to your desired destination, which may require ‘sudo make + install’. More information about controlling the locations where + ‘bash’ and other files are installed is below (*note Installation Names::). -The 'configure' shell script attempts to guess correct values for +The ‘configure’ shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses -those values to create a 'Makefile' in each directory of the package -(the top directory, the 'builtins', 'doc', 'po', and 'support' -directories, each directory under 'lib', and several others). It also -creates a 'config.h' file containing system-dependent definitions. -Finally, it creates a shell script named 'config.status' that you can +those values to create a ‘Makefile’ in each directory of the package +(the top directory, the ‘builtins’, ‘doc’, ‘po’, and ‘support’ +directories, each directory under ‘lib’, and several others). It also +creates a ‘config.h’ file containing system-dependent definitions. +Finally, it creates a shell script named ‘config.status’ that you can run in the future to recreate the current configuration, a file -'config.cache' that saves the results of its tests to speed up -reconfiguring, and a file 'config.log' containing compiler output -(useful mainly for debugging 'configure'). If at some point -'config.cache' contains results you don't want to keep, you may remove +‘config.cache’ that saves the results of its tests to speed up +reconfiguring, and a file ‘config.log’ containing compiler output +(useful mainly for debugging ‘configure’). If at some point +‘config.cache’ contains results you don't want to keep, you may remove or edit it. -To find out more about the options and arguments that the 'configure' +To find out more about the options and arguments that the ‘configure’ script understands, type bash-4.2$ ./configure --help @@ -53,8 +53,8 @@ at the Bash prompt in your Bash source directory. If you want to build Bash in a directory separate from the source directory - to build for multiple architectures, for example - just use the full path to the configure script. The following commands will -build bash in a directory under '/usr/local/build' from the source code -in '/usr/local/src/bash-4.4': +build Bash in a directory under ‘/usr/local/build’ from the source code +in ‘/usr/local/src/bash-4.4’: mkdir /usr/local/build/bash-4.4 cd /usr/local/build/bash-4.4 @@ -65,32 +65,32 @@ See *note Compiling For Multiple Architectures:: for more information about building in a directory separate from the source. If you need to do unusual things to compile Bash, please try to figure -out how 'configure' could check whether or not to do them, and mail +out how ‘configure’ could check whether or not to do them, and mail diffs or instructions to so they can be considered for the next release. -The file 'configure.ac' is used to create 'configure' by a program -called Autoconf. You only need 'configure.ac' if you want to change it -or regenerate 'configure' using a newer version of Autoconf. If you do +The file ‘configure.ac’ is used to create ‘configure’ by a program +called Autoconf. You only need ‘configure.ac’ if you want to change it +or regenerate ‘configure’ using a newer version of Autoconf. If you do this, make sure you are using Autoconf version 2.69 or newer. You can remove the program binaries and object files from the source -code directory by typing 'make clean'. To also remove the files that -'configure' created (so you can compile Bash for a different kind of -computer), type 'make distclean'. +code directory by typing ‘make clean’. To also remove the files that +‘configure’ created (so you can compile Bash for a different kind of +computer), type ‘make distclean’. Compilers and Options ===================== Some systems require unusual options for compilation or linking that the -'configure' script does not know about. You can give 'configure' +‘configure’ script does not know about. You can give ‘configure’ initial values for variables by setting them in the environment. Using a Bourne-compatible shell, you can do that on the command line like this: CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure -On systems that have the 'env' program, you can do it like this: +On systems that have the ‘env’ program, you can do it like this: env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure @@ -101,69 +101,69 @@ Compiling For Multiple Architectures You can compile Bash for more than one kind of computer at the same time, by placing the object files for each architecture in their own -directory. To do this, you must use a version of 'make' that supports -the 'VPATH' variable, such as GNU 'make'. 'cd' to the directory where -you want the object files and executables to go and run the 'configure' +directory. To do this, you must use a version of ‘make’ that supports +the ‘VPATH’ variable, such as GNU ‘make’. ‘cd’ to the directory where +you want the object files and executables to go and run the ‘configure’ script from the source directory (*note Basic Installation::). You may -need to supply the '--srcdir=PATH' argument to tell 'configure' where -the source files are. 'configure' automatically checks for the source -code in the directory that 'configure' is in and in '..'. +need to supply the ‘--srcdir=PATH’ argument to tell ‘configure’ where +the source files are. ‘configure’ automatically checks for the source +code in the directory that ‘configure’ is in and in ‘..’. -If you have to use a 'make' that does not support the 'VPATH' variable, +If you have to use a ‘make’ that does not support the ‘VPATH’ variable, you can compile Bash for one architecture at a time in the source code directory. After you have installed Bash for one architecture, use -'make distclean' before reconfiguring for another architecture. +‘make distclean’ before reconfiguring for another architecture. Alternatively, if your system supports symbolic links, you can use the -'support/mkclone' script to create a build tree which has symbolic links +‘support/mkclone’ script to create a build tree which has symbolic links back to each file in the source directory. Here's an example that creates a build directory in the current directory from a source -directory '/usr/gnu/src/bash-2.0': +directory ‘/usr/gnu/src/bash-2.0’: bash /usr/gnu/src/bash-2.0/support/mkclone -s /usr/gnu/src/bash-2.0 . -The 'mkclone' script requires Bash, so you must have already built Bash +The ‘mkclone’ script requires Bash, so you must have already built Bash for at least one architecture before you can create build directories for other architectures. Installation Names ================== -By default, 'make install' will install into '/usr/local/bin', -'/usr/local/man', etc.; that is, the "installation prefix" defaults to -'/usr/local'. You can specify an installation prefix other than -'/usr/local' by giving 'configure' the option '--prefix=PATH', or by -specifying a value for the 'prefix' 'make' variable when running 'make -install' (e.g., 'make install prefix=PATH'). The 'prefix' variable -provides a default for 'exec_prefix' and other variables used when -installing bash. +By default, ‘make install’ will install into ‘/usr/local/bin’, +‘/usr/local/man’, etc.; that is, the “installation prefix” defaults to +‘/usr/local’. You can specify an installation prefix other than +‘/usr/local’ by giving ‘configure’ the option ‘--prefix=PATH’, or by +specifying a value for the ‘prefix’ ‘make’ variable when running ‘make +install’ (e.g., ‘make install prefix=PATH’). The ‘prefix’ variable +provides a default for ‘exec_prefix’ and other variables used when +installing Bash. You can specify separate installation prefixes for architecture-specific -files and architecture-independent files. If you give 'configure' the -option '--exec-prefix=PATH', 'make install' will use PATH as the prefix +files and architecture-independent files. If you give ‘configure’ the +option ‘--exec-prefix=PATH’, ‘make install’ will use PATH as the prefix for installing programs and libraries. Documentation and other data files will still use the regular prefix. If you would like to change the installation locations for a single run, -you can specify these variables as arguments to 'make': 'make install -exec_prefix=/' will install 'bash' and 'bashbug' into '/bin' instead of -the default '/usr/local/bin'. +you can specify these variables as arguments to ‘make’: ‘make install +exec_prefix=/’ will install ‘bash’ and ‘bashbug’ into ‘/bin’ instead of +the default ‘/usr/local/bin’. -If you want to see the files bash will install and where it will install +If you want to see the files Bash will install and where it will install them without changing anything on your system, specify the variable -'DESTDIR' as an argument to 'make'. Its value should be the absolute +‘DESTDIR’ as an argument to ‘make’. Its value should be the absolute directory path you'd like to use as the root of your sample installation tree. For example, mkdir /fs1/bash-install make install DESTDIR=/fs1/bash-install -will install 'bash' into '/fs1/bash-install/usr/local/bin/bash', the +will install ‘bash’ into ‘/fs1/bash-install/usr/local/bin/bash’, the documentation into directories within -'/fs1/bash-install/usr/local/share', the example loadable builtins into -'/fs1/bash-install/usr/local/lib/bash', and so on. You can use the -usual 'exec_prefix' and 'prefix' variables to alter the directory paths -beneath the value of 'DESTDIR'. +‘/fs1/bash-install/usr/local/share’, the example loadable builtins into +‘/fs1/bash-install/usr/local/lib/bash’, and so on. You can use the +usual ‘exec_prefix’ and ‘prefix’ variables to alter the directory paths +beneath the value of ‘DESTDIR’. The GNU Makefile standards provide a more complete description of these variables and their effects. @@ -171,325 +171,335 @@ variables and their effects. Specifying the System Type ========================== -There may be some features 'configure' can not figure out automatically, +There may be some features ‘configure’ can not figure out automatically, but needs to determine by the type of host Bash will run on. Usually -'configure' can figure that out, but if it prints a message saying it -can not guess the host type, give it the '--host=TYPE' option. 'TYPE' -can either be a short name for the system type, such as 'sun4', or a -canonical name with three fields: 'CPU-COMPANY-SYSTEM' (e.g., -'i386-unknown-freebsd4.2'). +‘configure’ can figure that out, but if it prints a message saying it +can not guess the host type, give it the ‘--host=TYPE’ option. ‘TYPE’ +can either be a short name for the system type, such as ‘sun4’, or a +canonical name with three fields: ‘CPU-COMPANY-SYSTEM’ (e.g., +‘i386-unknown-freebsd4.2’). -See the file 'support/config.sub' for the possible values of each field. +See the file ‘support/config.sub’ for the possible values of each field. Sharing Defaults ================ -If you want to set default values for 'configure' scripts to share, you -can create a site shell script called 'config.site' that gives default -values for variables like 'CC', 'cache_file', and 'prefix'. 'configure' -looks for 'PREFIX/share/config.site' if it exists, then -'PREFIX/etc/config.site' if it exists. Or, you can set the -'CONFIG_SITE' environment variable to the location of the site script. -A warning: the Bash 'configure' looks for a site script, but not all -'configure' scripts do. +If you want to set default values for ‘configure’ scripts to share, you +can create a site shell script called ‘config.site’ that gives default +values for variables like ‘CC’, ‘cache_file’, and ‘prefix’. ‘configure’ +looks for ‘PREFIX/share/config.site’ if it exists, then +‘PREFIX/etc/config.site’ if it exists. Or, you can set the +‘CONFIG_SITE’ environment variable to the location of the site script. +A warning: the Bash ‘configure’ looks for a site script, but not all +‘configure’ scripts do. Operation Controls ================== -'configure' recognizes the following options to control how it operates. +‘configure’ recognizes the following options to control how it operates. -'--cache-file=FILE' +‘--cache-file=FILE’ Use and save the results of the tests in FILE instead of - './config.cache'. Set FILE to '/dev/null' to disable caching, for - debugging 'configure'. + ‘./config.cache’. Set FILE to ‘/dev/null’ to disable caching, for + debugging ‘configure’. -'--help' - Print a summary of the options to 'configure', and exit. +‘--help’ + Print a summary of the options to ‘configure’, and exit. -'--quiet' -'--silent' -'-q' +‘--quiet’ +‘--silent’ +‘-q’ Do not print messages saying which checks are being made. -'--srcdir=DIR' +‘--srcdir=DIR’ Look for the Bash source code in directory DIR. Usually - 'configure' can determine that directory automatically. + ‘configure’ can determine that directory automatically. -'--version' - Print the version of Autoconf used to generate the 'configure' +‘--version’ + Print the version of Autoconf used to generate the ‘configure’ script, and exit. -'configure' also accepts some other, not widely used, boilerplate -options. 'configure --help' prints the complete list. +‘configure’ also accepts some other, not widely used, boilerplate +options. ‘configure --help’ prints the complete list. Optional Features ================= -The Bash 'configure' has a number of '--enable-FEATURE' options, where +The Bash ‘configure’ has a number of ‘--enable-FEATURE’ options, where FEATURE indicates an optional part of Bash. There are also several -'--with-PACKAGE' options, where PACKAGE is something like 'bash-malloc' -or 'purify'. To turn off the default use of a package, use -'--without-PACKAGE'. To configure Bash without a feature that is -enabled by default, use '--disable-FEATURE'. +‘--with-PACKAGE’ options, where PACKAGE is something like ‘bash-malloc’ +or ‘afs’. To turn off the default use of a package, use +‘--without-PACKAGE’. To configure Bash without a feature that is +enabled by default, use ‘--disable-FEATURE’. -Here is a complete list of the '--enable-' and '--with-' options that -the Bash 'configure' recognizes. +Here is a complete list of the ‘--enable-’ and ‘--with-’ options that +the Bash ‘configure’ recognizes. -'--with-afs' +‘--with-afs’ Define if you are using the Andrew File System from Transarc. -'--with-bash-malloc' - Use the Bash version of 'malloc' in the directory 'lib/malloc'. - This is not the same 'malloc' that appears in GNU libc, but an - older version originally derived from the 4.2 BSD 'malloc'. This - 'malloc' is very fast, but wastes some space on each allocation. - This option is enabled by default. The 'NOTES' file contains a - list of systems for which this should be turned off, and - 'configure' disables this option automatically for a number of - systems. - -'--with-curses' - Use the curses library instead of the termcap library. This should - be supplied if your system has an inadequate or incomplete termcap - database. - -'--with-gnu-malloc' - A synonym for '--with-bash-malloc'. - -'--with-installed-readline[=PREFIX]' +‘--with-bash-malloc’ + Use the Bash version of ‘malloc’ in the directory ‘lib/malloc’. + This is not the same ‘malloc’ that appears in GNU libc, but a + custom version originally derived from the 4.2 BSD ‘malloc’. This + ‘malloc’ is very fast, but wastes some space on each allocation, + though it uses several techniques to minimize the waste. This + option is enabled by default. The ‘NOTES’ file contains a list of + systems for which this should be turned off, and ‘configure’ + disables this option automatically for a number of systems. + +‘--with-curses’ + Use the curses library instead of the termcap library. ‘configure’ + usually chooses this automatically, since most systems include the + termcap functions in the curses library. + +‘--with-gnu-malloc’ + A synonym for ‘--with-bash-malloc’. + +‘--with-installed-readline[=PREFIX]’ Define this to make Bash link with a locally-installed version of - Readline rather than the version in 'lib/readline'. This works - only with Readline 5.0 and later versions. If PREFIX is 'yes' or - not supplied, 'configure' uses the values of the make variables - 'includedir' and 'libdir', which are subdirectories of 'prefix' by + Readline rather than the version in ‘lib/readline’. This works + only with Readline 5.0 and later versions. If PREFIX is ‘yes’ or + not supplied, ‘configure’ uses the values of the make variables + ‘includedir’ and ‘libdir’, which are subdirectories of ‘prefix’ by default, to find the installed version of Readline if it is not in the standard system include and library directories. If PREFIX is - 'no', Bash links with the version in 'lib/readline'. If PREFIX is - set to any other value, 'configure' treats it as a directory + ‘no’, Bash links with the version in ‘lib/readline’. If PREFIX is + set to any other value, ‘configure’ treats it as a directory pathname and looks for the installed version of Readline in - subdirectories of that directory (include files in PREFIX/'include' - and the library in PREFIX/'lib'). + subdirectories of that directory (include files in PREFIX/‘include’ + and the library in PREFIX/‘lib’). The Bash default is to link with + a static library built in the ‘lib/readline’ subdirectory of the + build directory. -'--with-libintl-prefix[=PREFIX]' +‘--with-libintl-prefix[=PREFIX]’ Define this to make Bash link with a locally-installed version of - the libintl library instead of the version in 'lib/intl'. + the libintl library instead of the version in ‘lib/intl’. -'--with-libiconv-prefix[=PREFIX]' +‘--with-libiconv-prefix[=PREFIX]’ Define this to make Bash look for libiconv in PREFIX instead of the - standard system locations. There is no version included with Bash. + standard system locations. The Bash distribution does not include + this library. -'--enable-minimal-config' - This produces a shell with minimal features, close to the +‘--enable-minimal-config’ + This produces a shell with minimal features, closer to the historical Bourne shell. -There are several '--enable-' options that alter how Bash is compiled, +There are several ‘--enable-’ options that alter how Bash is compiled, linked, and installed, rather than changing run-time features. -'--enable-largefile' +‘--enable-largefile’ Enable support for large files (http://www.unix.org/version2/whatsnew/lfs20mar.html) if the operating system requires special compiler options to build programs which can access large files. This is enabled by default, if the operating system provides large file support. -'--enable-profiling' +‘--enable-profiling’ This builds a Bash binary that produces profiling information to be - processed by 'gprof' each time it is executed. + processed by ‘gprof’ each time it is executed. -'--enable-separate-helpfiles' - Use external files for the documentation displayed by the 'help' +‘--enable-separate-helpfiles’ + Use external files for the documentation displayed by the ‘help’ builtin instead of storing the text internally. -'--enable-static-link' - This causes Bash to be linked statically, if 'gcc' is being used. +‘--enable-static-link’ + This causes Bash to be linked statically, if ‘gcc’ is being used. This could be used to build a version to use as root's shell. -The 'minimal-config' option can be used to disable all of the following +The ‘minimal-config’ option can be used to disable all of the following options, but it is processed first, so individual options may be enabled -using 'enable-FEATURE'. +using ‘enable-FEATURE’. -All of the following options except for 'alt-array-implementation', -'disabled-builtins', 'direxpand-default', 'strict-posix-default', and -'xpg-echo-default' are enabled by default, unless the operating system +All of the following options except for ‘alt-array-implementation’, +‘disabled-builtins’, ‘direxpand-default’, ‘strict-posix-default’, and +‘xpg-echo-default’ are enabled by default, unless the operating system does not provide the necessary support. -'--enable-alias' - Allow alias expansion and include the 'alias' and 'unalias' +‘--enable-alias’ + Allow alias expansion and include the ‘alias’ and ‘unalias’ builtins (*note Aliases::). -'--enable-alt-array-implementation' - This builds bash using an alternate implementation of arrays (*note +‘--enable-alt-array-implementation’ + This builds Bash using an alternate implementation of arrays (*note Arrays::) that provides faster access at the expense of using more memory (sometimes many times more, depending on how sparse an array is). -'--enable-arith-for-command' - Include support for the alternate form of the 'for' command that - behaves like the C language 'for' statement (*note Looping +‘--enable-arith-for-command’ + Include support for the alternate form of the ‘for’ command that + behaves like the C language ‘for’ statement (*note Looping Constructs::). -'--enable-array-variables' +‘--enable-array-variables’ Include support for one-dimensional array shell variables (*note Arrays::). -'--enable-bang-history' - Include support for 'csh'-like history substitution (*note History +‘--enable-bang-history’ + Include support for ‘csh’-like history substitution (*note History Interaction::). -'--enable-brace-expansion' - Include 'csh'-like brace expansion ( 'b{a,b}c' ==> 'bac bbc' ). - See *note Brace Expansion::, for a complete description. +‘--enable-bash-source-fullpath-default’ + Set the default value of the ‘bash_source_fullpath’ shell option + described above under *note The Shopt Builtin:: to be enabled. + This controls how filenames are assigned to the ‘BASH_SOURCE’ array + variable. + +‘--enable-brace-expansion’ + Include ‘csh’-like brace expansion ( ‘b{a,b}c’ ↦ ‘bac bbc’ ). See + *note Brace Expansion::, for a complete description. -'--enable-casemod-attributes' - Include support for case-modifying attributes in the 'declare' - builtin and assignment statements. Variables with the 'uppercase' +‘--enable-casemod-attributes’ + Include support for case-modifying attributes in the ‘declare’ + builtin and assignment statements. Variables with the ‘uppercase’ attribute, for example, will have their values converted to uppercase upon assignment. -'--enable-casemod-expansion' +‘--enable-casemod-expansion’ Include support for case-modifying word expansions. -'--enable-command-timing' - Include support for recognizing 'time' as a reserved word and for - displaying timing statistics for the pipeline following 'time' - (*note Pipelines::). This allows pipelines as well as shell - builtins and functions to be timed. +‘--enable-command-timing’ + Include support for recognizing ‘time’ as a reserved word and for + displaying timing statistics for the pipeline following ‘time’ + (*note Pipelines::). This allows timing pipelines, shell compound + commands, shell builtins, and shell functions, which an external + command cannot do easily. -'--enable-cond-command' - Include support for the '[[' conditional command. (*note +‘--enable-cond-command’ + Include support for the ‘[[’ conditional command. (*note Conditional Constructs::). -'--enable-cond-regexp' +‘--enable-cond-regexp’ Include support for matching POSIX regular expressions using the - '=~' binary operator in the '[[' conditional command. (*note + ‘=~’ binary operator in the ‘[[’ conditional command. (*note Conditional Constructs::). -'--enable-coprocesses' - Include support for coprocesses and the 'coproc' reserved word +‘--enable-coprocesses’ + Include support for coprocesses and the ‘coproc’ reserved word (*note Pipelines::). -'--enable-debugger' - Include support for the bash debugger (distributed separately). +‘--enable-debugger’ + Include support for the Bash debugger (distributed separately). -'--enable-dev-fd-stat-broken' - If calling 'stat' on /dev/fd/N returns different results than - calling 'fstat' on file descriptor N, supply this option to enable +‘--enable-dev-fd-stat-broken’ + If calling ‘stat’ on /dev/fd/N returns different results than + calling ‘fstat’ on file descriptor N, supply this option to enable a workaround. This has implications for conditional commands that test file attributes. -'--enable-direxpand-default' - Cause the 'direxpand' shell option (*note The Shopt Builtin::) to +‘--enable-direxpand-default’ + Cause the ‘direxpand’ shell option (*note The Shopt Builtin::) to be enabled by default when the shell starts. It is normally disabled by default. -'--enable-directory-stack' - Include support for a 'csh'-like directory stack and the 'pushd', - 'popd', and 'dirs' builtins (*note The Directory Stack::). +‘--enable-directory-stack’ + Include support for a ‘csh’-like directory stack and the ‘pushd’, + ‘popd’, and ‘dirs’ builtins (*note The Directory Stack::). -'--enable-disabled-builtins' - Allow builtin commands to be invoked via 'builtin xxx' even after - 'xxx' has been disabled using 'enable -n xxx'. See *note Bash - Builtins::, for details of the 'builtin' and 'enable' builtin +‘--enable-disabled-builtins’ + Allow builtin commands to be invoked via ‘builtin xxx’ even after + ‘xxx’ has been disabled using ‘enable -n xxx’. See *note Bash + Builtins::, for details of the ‘builtin’ and ‘enable’ builtin commands. -'--enable-dparen-arithmetic' - Include support for the '((...))' command (*note Conditional +‘--enable-dparen-arithmetic’ + Include support for the ‘((...))’ command (*note Conditional Constructs::). -'--enable-extended-glob' +‘--enable-extended-glob’ Include support for the extended pattern matching features described above under *note Pattern Matching::. -'--enable-extended-glob-default' - Set the default value of the 'extglob' shell option described above +‘--enable-extended-glob-default’ + Set the default value of the ‘extglob’ shell option described above under *note The Shopt Builtin:: to be enabled. -'--enable-function-import' +‘--enable-function-import’ Include support for importing function definitions exported by another instance of the shell from the environment. This option is enabled by default. -'--enable-glob-asciirange-default' - Set the default value of the 'globasciiranges' shell option +‘--enable-glob-asciiranges-default’ + Set the default value of the ‘globasciiranges’ shell option described above under *note The Shopt Builtin:: to be enabled. This controls the behavior of character ranges when used in pattern matching bracket expressions. -'--enable-help-builtin' - Include the 'help' builtin, which displays help on shell builtins +‘--enable-help-builtin’ + Include the ‘help’ builtin, which displays help on shell builtins and variables (*note Bash Builtins::). -'--enable-history' - Include command history and the 'fc' and 'history' builtin commands +‘--enable-history’ + Include command history and the ‘fc’ and ‘history’ builtin commands (*note Bash History Facilities::). -'--enable-job-control' +‘--enable-job-control’ This enables the job control features (*note Job Control::), if the operating system supports them. -'--enable-multibyte' +‘--enable-multibyte’ This enables support for multibyte characters if the operating system provides the necessary support. -'--enable-net-redirections' +‘--enable-net-redirections’ This enables the special handling of filenames of the form - '/dev/tcp/HOST/PORT' and '/dev/udp/HOST/PORT' when used in + ‘/dev/tcp/HOST/PORT’ and ‘/dev/udp/HOST/PORT’ when used in redirections (*note Redirections::). -'--enable-process-substitution' +‘--enable-process-substitution’ This enables process substitution (*note Process Substitution::) if the operating system provides the necessary support. -'--enable-progcomp' +‘--enable-progcomp’ Enable the programmable completion facilities (*note Programmable Completion::). If Readline is not enabled, this option has no effect. -'--enable-prompt-string-decoding' +‘--enable-prompt-string-decoding’ Turn on the interpretation of a number of backslash-escaped - characters in the '$PS0', '$PS1', '$PS2', and '$PS4' prompt + characters in the ‘$PS0’, ‘$PS1’, ‘$PS2’, and ‘$PS4’ prompt strings. See *note Controlling the Prompt::, for a complete list of prompt string escape sequences. -'--enable-readline' +‘--enable-readline’ Include support for command-line editing and history with the Bash version of the Readline library (*note Command Line Editing::). -'--enable-restricted' - Include support for a "restricted shell". If this is enabled, - Bash, when called as 'rbash', enters a restricted mode. See *note - The Restricted Shell::, for a description of restricted mode. +‘--enable-restricted’ + Include support for a “restricted shell”. If this is enabled, Bash + enters a restricted mode when called as ‘rbash’. See *note The + Restricted Shell::, for a description of restricted mode. -'--enable-select' - Include the 'select' compound command, which allows the generation - of simple menus (*note Conditional Constructs::). +‘--enable-select’ + Include the ‘select’ compound command, which allows generation of + simple menus (*note Conditional Constructs::). -'--enable-single-help-strings' - Store the text displayed by the 'help' builtin as a single string +‘--enable-single-help-strings’ + Store the text displayed by the ‘help’ builtin as a single string for each help topic. This aids in translating the text to different languages. You may need to disable this if your compiler cannot handle very long string literals. -'--enable-strict-posix-default' +‘--enable-strict-posix-default’ Make Bash POSIX-conformant by default (*note Bash POSIX Mode::). -'--enable-translatable-strings' - Enable support for '$"STRING"' translatable strings (*note Locale +‘--enable-translatable-strings’ + Enable support for ‘$"STRING"’ translatable strings (*note Locale Translation::). -'--enable-usg-echo-default' - A synonym for '--enable-xpg-echo-default'. +‘--enable-usg-echo-default’ + A synonym for ‘--enable-xpg-echo-default’. -'--enable-xpg-echo-default' - Make the 'echo' builtin expand backslash-escaped characters by - default, without requiring the '-e' option. This sets the default - value of the 'xpg_echo' shell option to 'on', which makes the Bash - 'echo' behave more like the version specified in the Single Unix +‘--enable-xpg-echo-default’ + Make the ‘echo’ builtin expand backslash-escaped characters by + default, without requiring the ‘-e’ option. This sets the default + value of the ‘xpg_echo’ shell option to ‘on’, which makes the Bash + ‘echo’ behave more like the version specified in the Single Unix Specification, version 3. *Note Bash Builtins::, for a description - of the escape sequences that 'echo' recognizes. + of the escape sequences that ‘echo’ recognizes. -The file 'config-top.h' contains C Preprocessor '#define' statements for -options which are not settable from 'configure'. Some of these are not +The file ‘config-top.h’ contains C Preprocessor ‘#define’ statements for +options which are not settable from ‘configure’. Some of these are not meant to be changed; beware of the consequences if you do. Read the comments associated with each definition for more information about its effect. diff --git a/MANIFEST b/MANIFEST index a45b3cfc2..985d1793b 100644 --- a/MANIFEST +++ b/MANIFEST @@ -149,6 +149,7 @@ bashtypes.h f mailcheck.h f xmalloc.h f pathnames.h.in f +buildconf.h.in f # order is important here y.tab.c F y.tab.h F @@ -211,6 +212,7 @@ builtins/bashgetopt.c f builtins/common.h f builtins/bashgetopt.h f #cross-build/cygwin32.cache f +cross-build/msys32.cache f cross-build/x86-beos.cache f cross-build/opennt.cache f cross-build/qnx.cache f @@ -218,6 +220,7 @@ include/ansi_stdlib.h f include/chartypes.h f include/filecntl.h f include/gettext.h f +include/intprops-internal.h f include/maxpath.h f include/memalloc.h f include/ocache.h f @@ -232,10 +235,12 @@ include/shmbutil.h f include/shtty.h f include/stat-time.h f include/stdc.h f +include/stdckdint.in.h f include/systimes.h f include/timer.h f include/typemax.h f include/unionwait.h f +include/unlocked-io.h f lib/glob/Makefile.in f lib/glob/sm_loop.c f lib/glob/smatch.c f @@ -250,48 +255,78 @@ lib/glob/xmbsrtowcs.c f lib/glob/collsyms.h f lib/glob/doc/Makefile f lib/glob/doc/glob.texi f -lib/glob/ndir.h f -lib/intl/ChangeLog f lib/intl/Makefile.in f lib/intl/VERSION f +lib/intl/ref-add.sin f +lib/intl/ref-del.sin f lib/intl/bindtextdom.c f -lib/intl/config.charset f lib/intl/dcgettext.c f lib/intl/dcigettext.c f lib/intl/dcngettext.c f lib/intl/dgettext.c f lib/intl/dngettext.c f -lib/intl/eval-plural.h f lib/intl/explodename.c f lib/intl/finddomain.c f lib/intl/gettext.c f -lib/intl/gettextP.h f -lib/intl/gmo.h f -lib/intl/hash-string.h f +lib/intl/hash-string.c f lib/intl/intl-compat.c f +lib/intl/intl-exports.c f lib/intl/l10nflist.c f -lib/intl/libgnuintl.h.in f -lib/intl/loadinfo.h f +lib/intl/langprefs.c f lib/intl/loadmsgcat.c f lib/intl/localcharset.c f -lib/intl/localcharset.h f -lib/intl/locale.alias f lib/intl/localealias.c f +lib/intl/localename-table.c f lib/intl/localename.c f +lib/intl/lock.c f lib/intl/log.c f lib/intl/ngettext.c f lib/intl/os2compat.c f -lib/intl/os2compat.h f lib/intl/osdep.c f lib/intl/plural-exp.c f -lib/intl/plural-exp.h f lib/intl/plural.c f lib/intl/plural.y f -lib/intl/ref-add.sin f -lib/intl/ref-del.sin f +lib/intl/printf-args.c f +lib/intl/printf-parse.c f +lib/intl/printf.c f lib/intl/relocatable.c f -lib/intl/relocatable.h f +lib/intl/setlocale-lock.c f +lib/intl/setlocale.c f +lib/intl/setlocale_null.c f lib/intl/textdomain.c f +lib/intl/threadlib.c f +lib/intl/tsearch.c f +lib/intl/vasnprintf.c f +lib/intl/version.c f +lib/intl/xsize.c f +lib/intl/arg-nonnull.h f +lib/intl/attribute.h f +lib/intl/eval-plural.h f +lib/intl/export.h f +lib/intl/filename.h f +lib/intl/flexmember.h f +lib/intl/gettextP.h f +lib/intl/gmo.h f +lib/intl/hash-string.h f +lib/intl/libgnuintl.in.h f +lib/intl/loadinfo.h f +lib/intl/localcharset.h f +lib/intl/localename-table.in.h f +lib/intl/lock.h f +lib/intl/os2compat.h f +lib/intl/plural-exp.h f +lib/intl/plural.h f +lib/intl/printf-args.h f +lib/intl/printf-parse.h f +lib/intl/relocatable.h f +lib/intl/setlocale_null.h f +lib/intl/thread-optim.h f +lib/intl/tsearch.h f +lib/intl/vasnprintf.h f +lib/intl/vasnwprintf.h f +lib/intl/verify.h f +lib/intl/wprintf-parse.h f +lib/intl/xsize.h f lib/malloc/Makefile.in f lib/malloc/getpagesize.h f lib/malloc/imalloc.h f @@ -307,6 +342,7 @@ lib/malloc/trace.c f lib/malloc/watch.c f lib/malloc/xmalloc.c f lib/malloc/xleaktrace f 755 +lib/malloc/sbrk.c f lib/malloc/stub.c f lib/malloc/i386-alloca.s f lib/malloc/x386-alloca.s f @@ -398,9 +434,11 @@ lib/readline/examples/rl.c f lib/readline/examples/rlcat.c f lib/readline/examples/Inputrc f lib/sh/Makefile.in f +lib/sh/anonfile.c f lib/sh/casemod.c f lib/sh/clktck.c f lib/sh/clock.c f +lib/sh/compat.c f lib/sh/dprintf.c f lib/sh/eaccess.c f lib/sh/fmtullong.c f @@ -419,6 +457,7 @@ lib/sh/makepath.c f lib/sh/mbscasecmp.c f lib/sh/mbschr.c f lib/sh/mbscmp.c f +lib/sh/mbsncmp.c f lib/sh/memset.c f lib/sh/mktime.c f lib/sh/netconn.c f @@ -427,6 +466,7 @@ lib/sh/oslib.c f lib/sh/pathcanon.c f lib/sh/pathphys.c f lib/sh/random.c f +lib/sh/reallocarray.c f lib/sh/rename.c f lib/sh/setlinebuf.c f lib/sh/shmatch.c f @@ -443,8 +483,10 @@ lib/sh/strerror.c f lib/sh/strftime.c f lib/sh/stringlist.c f lib/sh/stringvec.c f +lib/sh/strlcpy.c f lib/sh/strnlen.c f lib/sh/strpbrk.c f +lib/sh/strscpy.c f lib/sh/strstr.c f lib/sh/strtod.c f lib/sh/strtoimax.c f @@ -484,12 +526,17 @@ lib/tilde/Makefile.in f lib/tilde/tilde.c f lib/tilde/tilde.h f lib/tilde/shell.c f +m4/unlocked-io.m4 f m4/strtoimax.m4 f m4/stat-time.m4 f m4/timespec.m4 f +m4/bison.m4 f +m4/c-bool.m4 f m4/codeset.m4 f +m4/d-type.m4 f m4/extern-inline.m4 f m4/fcntl-o.m4 f +m4/flexmember.m4 f m4/gettext.m4 f m4/glibc2.m4 f m4/glibc21.m4 f @@ -507,6 +554,7 @@ m4/lcmessage.m4 f m4/lib-ld.m4 f m4/lib-link.m4 f m4/lib-prefix.m4 f +m4/locale_h.m4 f m4/lock.m4 f m4/nls.m4 f m4/po.m4 f @@ -575,6 +623,8 @@ po/it.gmo f po/it.po f po/ja.gmo f po/ja.po f +po/ka.gmo f +po/ka.po f po/ko.gmo f po/ko.po f po/lt.gmo f @@ -596,6 +646,8 @@ po/ru.po f po/sk.gmo f po/sk.po f po/sl.gmo f +po/sq.po f +po/sq.gmo f po/sr.po f po/sr.gmo f po/sl.po f @@ -620,7 +672,6 @@ CWRU/misc/sigstat.c f CWRU/misc/bison f CWRU/misc/errlist.c f CWRU/misc/hpux10-dlfcn.h f -CWRU/PLATFORMS f CWRU/README f CWRU/changelog f CWRU/sh-redir-hack f @@ -644,11 +695,8 @@ doc/fdl.txt f # doc/article.ps f doc/rose94.ps f -doc/bash.ps f -doc/bashbug.ps f -doc/builtins.ps f -doc/rbash.ps f -doc/bashref.ps f +#doc/bash.ps f +#doc/bashref.ps f doc/bashref.dvi f doc/bash.0 f doc/bashbug.0 f @@ -660,6 +708,8 @@ doc/bashref.html f doc/article.pdf f doc/bash.pdf f doc/bashref.pdf f +doc/builtins.pdf f +doc/rbash.pdf f doc/rose94.pdf f doc/aosa-bash.pdf f doc/aosa-bash-full.pdf f @@ -667,7 +717,7 @@ doc/aosa-bash-full.pdf f support/Makefile.in f support/bash.pc.in f support/bashversion.c f -support/checkbashisms f 755 +#support/checkbashisms f 755 support/config.guess f support/config.rpath f 755 support/config.sub f @@ -682,7 +732,8 @@ support/mkinstalldirs f 755 support/mkversion.sh f 755 support/mksignames.c f support/signames.c f -support/bashbug.sh f +support/siglen.c f +#support/bashbug.sh f support/bashbug.sh.in f support/man2html.c f support/recho.c f @@ -690,10 +741,10 @@ support/zecho.c f support/xcase.c f support/SYMLINKS f support/fixlinks f 755 -support/install.sh f 755 +support/install-sh f 755 support/texi2dvi f 755 support/texi2html f 755 -support/xenix-link.sh f 755 +#support/xenix-link.sh f 755 support/shobj-conf f 755 support/rlvers.sh f 755 examples/INDEX.txt f @@ -728,15 +779,20 @@ examples/loadables/seq.c f examples/loadables/setpgid.c f examples/loadables/sleep.c f examples/loadables/strftime.c f +examples/loadables/strptime.c f examples/loadables/truefalse.c f examples/loadables/getconf.h f examples/loadables/getconf.c f examples/loadables/fdflags.c f examples/loadables/finfo.c f +examples/loadables/fltexpr.c f examples/loadables/cat.c f +examples/loadables/chmod.c f examples/loadables/csv.c f examples/loadables/dsv.c f +examples/loadables/kv.c f examples/loadables/cut.c f +examples/loadables/ocut.c f examples/loadables/logname.c f examples/loadables/basename.c f examples/loadables/dirname.c f @@ -813,6 +869,7 @@ examples/functions/notify.bash f #examples/functions/repeat3 f examples/functions/seq f examples/functions/seq2 f +examples/functions/setalrm f examples/functions/shcat f examples/functions/shcat2 f examples/functions/sort-pos-params f @@ -844,6 +901,7 @@ examples/scripts/inpath f #examples/scripts/scrollbar2 f #examples/scripts/self-repro f #examples/scripts/showperm.bash f +examples/scripts/secure-script f examples/scripts/shprompt f examples/scripts/spin.bash f #examples/scripts/timeout f @@ -892,6 +950,7 @@ tests/alias3.sub f tests/alias4.sub f tests/alias5.sub f tests/alias6.sub f +tests/alias7.sub f tests/alias.right f tests/appendop.tests f tests/appendop1.sub f @@ -909,6 +968,8 @@ tests/arith5.sub f tests/arith6.sub f tests/arith7.sub f tests/arith8.sub f +tests/arith9.sub f +tests/arith10.sub f tests/array.tests f tests/array.right f tests/array1.sub f @@ -941,6 +1002,9 @@ tests/array27.sub f tests/array28.sub f tests/array29.sub f tests/array30.sub f +tests/array31.sub f +tests/array32.sub f +tests/array33.sub f tests/array-at-star f tests/array2.right f tests/assoc.tests f @@ -963,6 +1027,7 @@ tests/assoc15.sub f tests/assoc16.sub f tests/assoc17.sub f tests/assoc18.sub f +tests/assoc19.sub f tests/attr.tests f tests/attr.right f tests/attr1.sub f @@ -978,6 +1043,11 @@ tests/builtins4.sub f tests/builtins5.sub f tests/builtins6.sub f tests/builtins7.sub f +tests/builtins8.sub f +tests/builtins9.sub f +tests/builtins10.sub f +tests/builtins11.sub f +tests/builtins12.sub f tests/source1.sub f tests/source2.sub f tests/source3.sub f @@ -985,6 +1055,7 @@ tests/source4.sub f tests/source5.sub f tests/source6.sub f tests/source7.sub f +tests/source8.sub f tests/case.tests f tests/case.right f tests/case1.sub f @@ -1003,6 +1074,15 @@ tests/comsub3.sub f tests/comsub4.sub f tests/comsub5.sub f tests/comsub6.sub f +tests/comsub7.sub f +tests/comsub2.tests f +tests/comsub2.right f +tests/comsub21.sub f +tests/comsub22.sub f +tests/comsub23.sub f +tests/comsub24.sub f +tests/comsub25.sub f +tests/comsub26.sub f tests/comsub-eof.tests f tests/comsub-eof0.sub f tests/comsub-eof1.sub f @@ -1021,9 +1101,11 @@ tests/comsub-posix5.sub f tests/comsub-posix6.sub f tests/cond.tests f tests/cond.right f +tests/cond-error1.sub f tests/cond-regexp1.sub f tests/cond-regexp2.sub f tests/cond-regexp3.sub f +tests/cond-xtrace1.sub f tests/coproc.tests f tests/coproc.right f tests/cprint.tests f @@ -1063,6 +1145,7 @@ tests/dollar-star7.sub f tests/dollar-star8.sub f tests/dollar-star9.sub f tests/dollar-star10.sub f +tests/dollar-star11.sub f tests/dollar.right f tests/dstack.tests f tests/dstack.right f @@ -1081,6 +1164,9 @@ tests/errors6.sub f tests/errors7.sub f tests/errors8.sub f tests/errors9.sub f +tests/errors10.sub f +tests/errors11.sub f +tests/errors12.sub f tests/execscript f tests/exec.right f tests/exec1.sub f 755 @@ -1097,6 +1183,9 @@ tests/exec11.sub f tests/exec12.sub f tests/exec13.sub f tests/exec14.sub f +tests/exec15.sub f +tests/exec16.sub f +tests/exec17.sub f tests/exp.tests f tests/exp.right f tests/exp1.sub f @@ -1131,12 +1220,14 @@ tests/extglob4.sub f tests/extglob5.sub f tests/extglob6.sub f tests/extglob7.sub f +tests/extglob8.sub f tests/func.tests f tests/func.right f tests/func1.sub f tests/func2.sub f tests/func3.sub f tests/func4.sub f +tests/func5.sub f tests/getopts.tests f tests/getopts.right f tests/getopts1.sub f @@ -1160,12 +1251,15 @@ tests/glob7.sub f tests/glob8.sub f tests/glob9.sub f tests/glob10.sub f +tests/glob11.sub f tests/glob.right f tests/globstar.tests f tests/globstar.right f tests/globstar1.sub f tests/globstar2.sub f tests/globstar3.sub f +tests/glob-bracket.tests f +tests/glob-bracket.right f tests/heredoc.tests f tests/heredoc.right f tests/heredoc1.sub f @@ -1175,6 +1269,9 @@ tests/heredoc4.sub f tests/heredoc5.sub f tests/heredoc6.sub f tests/heredoc7.sub f +tests/heredoc8.sub f +tests/heredoc9.sub f +tests/heredoc10.sub f tests/herestr.tests f tests/herestr.right f tests/herestr1.sub f @@ -1196,6 +1293,9 @@ tests/history3.sub f tests/history4.sub f tests/history5.sub f tests/history6.sub f +tests/history7.sub f +tests/history8.sub f +tests/history9.sub f tests/ifs.tests f tests/ifs.right f tests/ifs1.sub f @@ -1208,7 +1308,13 @@ tests/intl.tests f tests/intl1.sub f tests/intl2.sub f tests/intl3.sub f +tests/intl4.sub f tests/intl.right f +tests/invocation.tests f +tests/invocation.right f +tests/invocation1.sub f +tests/invocation2.sub f +tests/invocation3.sub f tests/iquote.tests f tests/iquote.right f tests/iquote1.sub f @@ -1222,6 +1328,8 @@ tests/jobs4.sub f tests/jobs5.sub f tests/jobs6.sub f tests/jobs7.sub f +tests/jobs8.sub f +tests/jobs9.sub f tests/jobs.right f tests/lastpipe.right f tests/lastpipe.tests f @@ -1259,6 +1367,8 @@ tests/nameref20.sub f tests/nameref21.sub f tests/nameref22.sub f tests/nameref23.sub f +tests/nameref24.sub f +tests/nameref25.sub f tests/nameref.right f tests/new-exp.tests f tests/new-exp1.sub f @@ -1325,6 +1435,9 @@ tests/printf1.sub f tests/printf2.sub f tests/printf3.sub f tests/printf4.sub f +tests/printf5.sub f +tests/printf6.sub f +tests/printf7.sub f tests/procsub.tests f tests/procsub.right f tests/procsub1.sub f @@ -1352,6 +1465,8 @@ tests/read5.sub f tests/read6.sub f tests/read7.sub f tests/read8.sub f +tests/read9.sub f +tests/read10.sub f tests/redir.tests f tests/redir.right f tests/redir1.sub f @@ -1368,6 +1483,8 @@ tests/redir8.sub f tests/redir9.sub f tests/redir10.sub f tests/redir11.sub f +tests/redir12.sub f +tests/redir13.in f tests/rhs-exp.tests f tests/rhs-exp.right f tests/rhs-exp1.sub f @@ -1391,6 +1508,7 @@ tests/run-case f tests/run-casemod f tests/run-complete f tests/run-comsub f +tests/run-comsub2 f tests/run-comsub-eof f tests/run-comsub-posix f tests/run-cond f @@ -1411,6 +1529,7 @@ tests/run-extglob3 f tests/run-func f tests/run-getopts f tests/run-glob-test f +tests/run-glob-bracket f tests/run-globstar f tests/run-heredoc f tests/run-herestr f @@ -1420,6 +1539,7 @@ tests/run-ifs f tests/run-ifs-posix f tests/run-input-test f tests/run-intl f +tests/run-invocation f tests/run-iquote f tests/run-invert f tests/run-jobs f @@ -1468,6 +1588,7 @@ tests/set-e3a.sub f tests/set-e.right f tests/set-x.tests f tests/set-x1.sub f +tests/set-x2.sub f tests/set-x.right f tests/shopt.tests f tests/shopt1.sub f @@ -1491,12 +1612,16 @@ tests/trap3.sub f tests/trap4.sub f tests/trap5.sub f tests/trap6.sub f +tests/trap7.sub f +tests/trap8.sub f +tests/trap9.sub f tests/type.tests f tests/type.right f tests/type1.sub f tests/type2.sub f tests/type3.sub f tests/type4.sub f +tests/type5.sub f tests/unicode1.sub f tests/unicode2.sub f tests/unicode3.sub f @@ -1525,6 +1650,9 @@ tests/varenv19.sub f tests/varenv20.sub f tests/varenv21.sub f tests/varenv22.sub f +tests/varenv23.sub f +tests/varenv24.sub f +tests/varenv25.sub f tests/version f tests/version.mini f tests/vredir.tests f diff --git a/Makefile.in b/Makefile.in index 0b4df73a7..c4a882f78 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,6 +1,6 @@ -# Makefile for bash-5.2, version 5.1 +# Makefile for bash-5.3, version 5.10 # -# Copyright (C) 1996-2021 Free Software Foundation, Inc. +# Copyright (C) 1996-2025 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -74,19 +74,23 @@ YACC = @YACC@ SHELL = @MAKE_SHELL@ CP = cp RM = rm -f +RMDIR = rmdir AR = @AR@ ARFLAGS = @ARFLAGS@ RANLIB = @RANLIB@ SIZE = @SIZE@ -STRIP = strip +STRIP = @STRIP@ INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_DATA = @INSTALL_DATA@ INSTALLMODE= -m 0755 INSTALLMODE2 = -m 0555 +install_sh = @install_sh@ + CTAGS = ctags CTAGSFLAGS = -x ETAGS = etags @@ -96,9 +100,6 @@ TESTSCRIPT = @TESTSCRIPT@ DEBUGGER_START_FILE = @DEBUGGER_START_FILE@ -#If you have purify, and want to use it, run the make as `make PURIFY=purify' -#PURIFY = @PURIFY@ - # Here is a rule for making .o files from .c files that does not # force the type of the machine (like -M_MACHINE) into the flags. .c.o: @@ -152,6 +153,12 @@ LOCAL_LDFLAGS = @LOCAL_LDFLAGS@ SYSTEM_FLAGS = -DPROGRAM='"$(Program)"' -DCONF_HOSTTYPE='"$(Machine)"' -DCONF_OSTYPE='"$(OS)"' -DCONF_MACHTYPE='"$(MACHTYPE)"' -DCONF_VENDOR='"$(VENDOR)"' $(LOCALE_DEFS) +BASH_MAKEFLAGS = + +# set by lint/sanitize targets +ADDON_CFLAGS = +ADDON_LDFLAGS = + BASE_CCFLAGS = $(SYSTEM_FLAGS) $(LOCAL_DEFS) \ $(DEFS) $(LOCAL_CFLAGS) $(INCLUDES) $(STYLE_CFLAGS) @@ -166,18 +173,32 @@ LDFLAGS_FOR_BUILD = @LDFLAGS_FOR_BUILD@ $(LOCAL_LDFLAGS) $(CFLAGS_FOR_BUILD) ASAN_XCFLAGS = -fsanitize=address -fno-omit-frame-pointer ASAN_XLDFLAGS = -fsanitize=address +UBSAN_XCFLAGS = -fsanitize=undefined -fsanitize-recover -fstack-protector +UBSAN_XLDFLAGS = -fsanitize=undefined + GCOV_XCFLAGS = -fprofile-arcs -ftest-coverage GCOV_XLDFLAGS = -fprofile-arcs -ftest-coverage +# these need CC=clang +LSAN_CC = clang +LSAN_XCFLAGS = -fsanitize=leak -fno-common -fno-omit-frame-pointer -fno-optimize-sibling-calls +LSAN_XLDFLAGS = -fsanitize=leak + +MKDEP = $(SUPPORT_SRC)mkdep +MKDEP_CC = ${CC} +MKDEP_OPTS = -c ${MKDEP_CC} +MKDEP_CCFLAGS = ${CCFLAGS} + INCLUDES = -I. @RL_INCLUDE@ -I$(srcdir) -I$(BASHINCDIR) -I$(LIBSRC) $(INTL_INC) # Maybe add: -Wextra GCC_LINT_FLAGS = -O -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wno-parentheses \ -Wcast-align -Wstrict-prototypes -Wconversion -Wformat \ - -Wformat-nonliteral -Wmissing-braces -Wuninitialized \ + -Wmissing-braces -Wuninitialized \ -Wmissing-declarations -Winline \ - -Wmissing-prototypes -Wtraditional -Wredundant-decls \ - -Wformat-security -pedantic + -Wmissing-prototypes -Wredundant-decls \ + -Wformat-security -pedantic \ + -Werror=incompatible-pointer-types GCC_LINT_CFLAGS = $(BASE_CCFLAGS) $(CPPFLAGS) $(GCC_LINT_FLAGS) @@ -233,6 +254,7 @@ SHLIB_SOURCE = ${SH_LIBSRC}/clktck.c ${SH_LIBSRC}/getcwd.c \ ${SH_LIBSRC}/eaccess.c ${SH_LIBSRC}/wcsdup.c \ ${SH_LIBSRC}/zmapfd.c ${SH_LIBSRC}/fpurge.c \ ${SH_LIBSRC}/zgetline.c ${SH_LIBSRC}/mbscmp.c \ + ${SH_LIBSRC}/mbsncmp.c ${SH_LIBSRC}/anonfile.c \ ${SH_LIBSRC}/casemod.c ${SH_LIBSRC}/uconvert.c \ ${SH_LIBSRC}/ufuncs.c ${SH_LIBSRC}/dprintf.c \ ${SH_LIBSRC}/input_avail.c ${SH_LIBSRC}/mbscasecmp.c \ @@ -240,7 +262,9 @@ SHLIB_SOURCE = ${SH_LIBSRC}/clktck.c ${SH_LIBSRC}/getcwd.c \ ${SH_LIBSRC}/wcswidth.c ${SH_LIBSRC}/wcsnwidth.c \ ${SH_LIBSRC}/shmbchar.c ${SH_LIBSRC}/utf8.c \ ${SH_LIBSRC}/random.c ${SH_LIBSRC}/gettimeofday.c \ - ${SH_LIBSRC}/timers.c ${SH_LIBSRC}/strvis.c + ${SH_LIBSRC}/timers.c ${SH_LIBSRC}/strvis.c \ + ${SH_LIBSRC}/strlcpy.c ${SH_LIBSRC}/strscpy.c \ + ${SH_LIBSRC}/compat.c SHLIB_LIB = -lsh SHLIB_LIBNAME = libsh.a @@ -313,6 +337,8 @@ HISTORY_LIBRARY = $(HIST_LIBDIR)/libhistory.a HISTORY_LDFLAGS = -L$(HIST_LIBDIR) HISTORY_DEP = @HISTORY_DEP@ +HIST_INCLUDEDIR = @HIST_INCLUDEDIR@ + # The source, object and documentation of the history library. HISTORY_SOURCE = $(HIST_LIBSRC)/history.c $(HIST_LIBSRC)/histexpand.c \ $(HIST_LIBSRC)/histsearch.c $(HIST_LIBSRC)/histfile.c \ @@ -386,7 +412,6 @@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LTLIBINTL = @LTLIBINTL@ INTLLIBS = @INTLLIBS@ -INTLOBJS = @INTLOBJS@ # Our malloc. MALLOC_TARGET = @MALLOC_TARGET@ @@ -415,9 +440,11 @@ ALLOC_HEADERS = $(ALLOC_LIBSRC)/getpagesize.h $(ALLOC_LIBSRC)/shmalloc.h \ $(MALLOC_LIBRARY): ${MALLOC_SOURCE} ${ALLOC_HEADERS} config.h @(cd $(ALLOC_LIBDIR) && \ - $(MAKE) $(MFLAGS) \ + $(MAKE) $(BASH_MAKEFLAGS) \ MALLOC_CFLAGS="$(MALLOC_CFLAGS)" ${MALLOC_TARGET} ) || exit 1 +STDCKDINT_H = @STDCKDINT_H@ + BASHINCDIR = ${srcdir}/include BASHINCFILES = $(BASHINCDIR)/posixstat.h $(BASHINCDIR)/ansi_stdlib.h \ $(BASHINCDIR)/filecntl.h $(BASHINCDIR)/posixdir.h \ @@ -426,7 +453,11 @@ BASHINCFILES = $(BASHINCDIR)/posixstat.h $(BASHINCDIR)/ansi_stdlib.h \ $(BASHINCDIR)/posixtime.h $(BASHINCDIR)/systimes.h \ $(BASHINCDIR)/unionwait.h $(BASHINCDIR)/maxpath.h \ $(BASHINCDIR)/shtty.h $(BASHINCDIR)/typemax.h \ - $(BASHINCDIR)/ocache.h + $(BASHINCDIR)/ocache.h $(BASHINCDIR)/unlocked-io.h \ + $(BASHINCDIR)/chartypes.h \ + $(BASHINCDIR)/gettext.h $(BASHINCDIR)/posixselect.h \ + $(BASHINCDIR)/shmbchar.h $(BASHINCDIR)/shmbutil.h \ + $(BASHINCDIR)/stat-time.h $(BASHINCDIR)/timer.h LIBRARIES = $(GLOB_LIB) $(SHLIB_LIB) $(READLINE_LIB) $(HISTORY_LIB) \ $(TERMCAP_LIB) $(TILDE_LIB) $(MALLOC_LIB) $(INTL_LIB) $(LIBICONV) \ @@ -438,15 +469,18 @@ LIBDEP = $(GLOB_DEP) $(SHLIB_DEP) $(INTL_DEP) $(READLINE_DEP) $(HISTORY_DEP) \ LIBRARY_LDFLAGS = $(READLINE_LDFLAGS) $(HISTORY_LDFLAGS) $(GLOB_LDFLAGS) \ $(TILDE_LDFLAGS) $(MALLOC_LDFLAGS) $(SHLIB_LDFLAGS) +LIBRARY_SOURCE = $(SHLIB_SOURCE) $(GLOB_SOURCE) \ + $(READLINE_SOURCE) $(MALLOC_SOURCE) + # # The shell itself # # The main source code for the Bourne Again SHell. CSOURCES = shell.c eval.c parse.y general.c make_cmd.c print_cmd.c y.tab.c \ - dispose_cmd.c execute_cmd.c variables.c $(GLOBC) version.c \ + dispose_cmd.c execute_cmd.c variables.c version.c \ expr.c copy_cmd.c flags.c subst.c hashcmd.c hashlib.c mailcheck.c \ - test.c trap.c alias.c jobs.c nojobs.c $(ALLOC_FILES) braces.c \ + test.c trap.c alias.c jobs.c nojobs.c braces.c \ input.c bashhist.c array.c arrayfunc.c assoc.c sig.c pathexp.c \ unwind_prot.c siglist.c bashline.c bracecomp.c error.c \ list.c stringlib.c locale.c findcmd.c redir.c \ @@ -454,7 +488,7 @@ CSOURCES = shell.c eval.c parse.y general.c make_cmd.c print_cmd.c y.tab.c \ HSOURCES = shell.h flags.h trap.h hashcmd.h hashlib.h jobs.h builtins.h \ general.h variables.h config.h $(ALLOC_HEADERS) alias.h \ - quit.h unwind_prot.h syntax.h ${GRAM_H} \ + quit.h unwind_prot.h syntax.h \ command.h input.h error.h bashansi.h dispose_cmd.h make_cmd.h \ subst.h externs.h siglist.h bashhist.h bashline.h bashtypes.h \ array.h arrayfunc.h sig.h mailcheck.h bashintl.h bashjmp.h \ @@ -471,11 +505,15 @@ INSTALLED_HEADERS = shell.h bashjmp.h command.h syntax.h general.h error.h \ bashintl.h bashansi.h bashjmp.h alias.h hashlib.h \ conftypes.h unwind_prot.h jobs.h siglist.h \ execute_cmd.h +# these can appear in either the source directory or the build directory and +# are installed by install-headers +HYBRID_HEADERS = y.tab.h INSTALLED_BUILTINS_HEADERS = bashgetopt.h common.h getopt.h -INSTALLED_INCFILES = posixstat.h ansi_stdlib.h filecntl.h posixdir.h \ +INSTALLED_INCLUDE_HEADERS = posixstat.h ansi_stdlib.h filecntl.h posixdir.h \ memalloc.h stdc.h posixjmp.h posixwait.h posixtime.h systimes.h \ unionwait.h maxpath.h shtty.h typemax.h ocache.h chartypes.h gettext.h \ - posixstat.h shmbchar.h shmbutil.h stat-time.h + posixstat.h shmbchar.h shmbutil.h stat-time.h posixselect.h \ + timer.h unlocked-io.h # header files chosen based on running of configure SIGNAMES_H = @SIGNAMES_H@ @@ -488,7 +526,7 @@ SIGNAMES_O = @SIGNAMES_O@ ARRAY_O = @ARRAY_O@ # Matching object files. -OBJECTS = shell.o eval.o y.tab.o general.o make_cmd.o print_cmd.o $(GLOBO) \ +OBJECTS = shell.o eval.o y.tab.o general.o make_cmd.o print_cmd.o \ dispose_cmd.o execute_cmd.o variables.o copy_cmd.o error.o \ expr.o flags.o $(JOBS_O) subst.o hashcmd.o hashlib.o mailcheck.o \ trap.o input.o unwind_prot.o pathexp.o sig.o test.o version.o \ @@ -501,7 +539,6 @@ BUILTIN_SRCDIR=$(srcdir)/builtins DEFSRC=$(BUILTIN_SRCDIR) BUILTIN_ABSSRC=${topdir}/builtins DEFDIR = $(dot)/builtins -DEBUGGER_DIR = $(dot)/debugger BUILTIN_DEFS = $(DEFSRC)/alias.def $(DEFSRC)/bind.def $(DEFSRC)/break.def \ $(DEFSRC)/builtin.def $(DEFSRC)/cd.def $(DEFSRC)/colon.def \ @@ -554,10 +591,9 @@ DOCDIR = $(dot)/doc PO_SRC = $(srcdir)/po/ PO_DIR = $(dot)/po/ -SIGNAMES_SUPPORT = $(SUPPORT_SRC)mksignames.c - +# Auxiliary support files SUPPORT_SRC = $(srcdir)/support/ -SDIR = $(dot)/support +SUPPORT_DIR = $(dot)/support TESTS_SUPPORT = recho$(EXEEXT) zecho$(EXEEXT) printenv$(EXEEXT) xcase$(EXEEXT) CREATED_SUPPORT = signames.h recho$(EXEEXT) zecho$(EXEEXT) printenv$(EXEEXT) \ @@ -566,8 +602,11 @@ CREATED_SUPPORT = signames.h recho$(EXEEXT) zecho$(EXEEXT) printenv$(EXEEXT) \ mksignames$(EXEEXT) lsignames.h \ mksyntax${EXEEXT} syntax.c $(VERSPROG) $(VERSOBJ) \ buildversion.o mksignames.o signames.o buildsignames.o +CREATED_MACOS = recho.dSYM zecho.dSYM printenv.dSYM xcase.dSYM \ + bashversion.dSYM mksyntax.dSYM ${DEFDIR}/psize.aux.dSYM CREATED_CONFIGURE = config.h config.cache config.status config.log \ - stamp-h po/POTFILES config.status.lineno + stamp-h po/POTFILES config.status.lineno \ + stdckdint.h buildconf.h CREATED_MAKEFILES = Makefile builtins/Makefile doc/Makefile \ lib/readline/Makefile lib/glob/Makefile \ lib/sh/Makefile lib/tilde/Makefile lib/malloc/Makefile \ @@ -575,8 +614,9 @@ CREATED_MAKEFILES = Makefile builtins/Makefile doc/Makefile \ examples/loadables/Makefile.inc examples/loadables/Makefile.sample \ examples/loadables/perl/Makefile support/Makefile \ lib/intl/Makefile po/Makefile po/Makefile.in -CREATED_HEADERS = signames.h config.h pathnames.h version.h y.tab.h \ +CREATED_HEADERS = signames.h config.h pathnames.h version.h \ ${DEFDIR}/builtext.h +CREATED_SUBDIR_HEADERS = ${LIBINTL_H} OTHER_DOCS = $(srcdir)/CHANGES $(srcdir)/COMPAT $(srcdir)/NEWS $(srcdir)/POSIX \ $(srcdir)/RBASH $(srcdir)/README @@ -587,12 +627,12 @@ LOADABLES_DIR = ${top_builddir}/examples/loadables # Keep GNU Make from exporting the entire environment for small machines. .NOEXPORT: -.made: $(Program) bashbug $(SDIR)/man2html$(EXEEXT) +.made: $(Program) bashbug $(SUPPORT_DIR)/man2html$(EXEEXT) @echo "$(Program) last made for a $(Machine) running $(OS)" >.made $(Program): $(OBJECTS) $(BUILTINS_DEP) $(LIBDEP) .build $(RM) $@ - $(PURIFY) $(CC) $(BUILTINS_LDFLAGS) $(LIBRARY_LDFLAGS) $(LDFLAGS) -o $(Program) $(OBJECTS) $(LIBS) + $(CC) $(BUILTINS_LDFLAGS) $(LIBRARY_LDFLAGS) $(LDFLAGS) -o $(Program) $(OBJECTS) $(LIBS) ls -l $(Program) -$(SIZE) $(Program) @@ -605,9 +645,9 @@ $(Program): $(OBJECTS) $(BUILTINS_DEP) $(LIBDEP) .build @echo " ***********************************************************" @echo -bashbug: $(SDIR)/bashbug.sh $(VERSPROG) +bashbug: $(SUPPORT_DIR)/bashbug.sh $(VERSPROG) @sed -e "s%!PATCHLEVEL!%$(PatchLevel)%" \ - $(SDIR)/bashbug.sh > $@ + $(SUPPORT_DIR)/bashbug.sh > $@ @chmod a+rx bashbug strip: $(Program) .made @@ -616,17 +656,23 @@ strip: $(Program) .made -$(SIZE) $(Program) lint: - ${MAKE} ${MFLAGS} ADDON_CFLAGS='${GCC_LINT_FLAGS}' .made + ${MAKE} $(BASH_MAKEFLAGS) ADDON_CFLAGS='${GCC_LINT_FLAGS}' .made asan: - ${MAKE} ${MFLAGS} ADDON_CFLAGS='${ASAN_XCFLAGS}' ADDON_LDFLAGS='${ASAN_XLDFLAGS}' .made + ${MAKE} $(BASH_MAKEFLAGS) ADDON_CFLAGS='${ASAN_XCFLAGS}' ADDON_LDFLAGS='${ASAN_XLDFLAGS}' .made + +ubsan: + ${MAKE} $(BASH_MAKEFLAGS) ADDON_CFLAGS='${UBSAN_XCFLAGS}' ADDON_LDFLAGS='${UBSAN_XLDFLAGS}' .made valgrind: - ${MAKE} ${MFLAGS} ADDON_CFLAGS='-DDISABLE_MALLOC_WRAPPERS' ADDON_LDFLAGS= .made + ${MAKE} $(BASH_MAKEFLAGS) ADDON_CFLAGS='-DDISABLE_MALLOC_WRAPPERS' ADDON_LDFLAGS= .made + +lsan: + ${MAKE} $(BASH_MAKEFLAGS) CC=${LSAN_CC} ADDON_CFLAGS='${LSAN_XCFLAGS}' ADDON_LDFLAGS='${LSAN_XLDFLAGS}' .made # cheating gcov: - ${MAKE} ${MFLAGS} CFLAGS=-g ADDON_CFLAGS='${GCOV_XCFLAGS}' ADDON_LDFLAGS='${GCOV_XLDFLAGS}' .made + ${MAKE} $(BASH_MAKEFLAGS) CFLAGS=-g ADDON_CFLAGS='${GCOV_XCFLAGS}' ADDON_LDFLAGS='${GCOV_XLDFLAGS}' .made # have to make this separate because making tests depend on $(PROGRAM) asan-tests: asan $(TESTS_SUPPORT) @@ -635,9 +681,16 @@ asan-tests: asan $(TESTS_SUPPORT) @( cd $(srcdir)/tests && \ BUILD_DIR=$(BUILD_DIR) PATH=$(BUILD_DIR)/tests:$$PATH THIS_SH=$(THIS_SH) $(SHELL) ${TESTSCRIPT} ) -profiling-tests: ${PROGRAM} +# have to make this separate because making tests depend on $(PROGRAM) +lsan-tests: lsan $(TESTS_SUPPORT) + @-test -d tests || mkdir tests + @cp $(TESTS_SUPPORT) tests + @( cd $(srcdir)/tests && \ + BUILD_DIR=$(BUILD_DIR) PATH=$(BUILD_DIR)/tests:$$PATH THIS_SH=$(THIS_SH) $(SHELL) ${TESTSCRIPT} ) + +profiling-tests: ${Program} @test "X$$PROFILE_FLAGS" == "X" && { echo "profiling-tests: must be built with profiling enabled" >&2; exit 1; } - @${MAKE} ${MFLAGS} tests TESTSCRIPT=run-gprof + @${MAKE} $(BASH_MAKEFLAGS) tests TESTSCRIPT=run-gprof version.h: $(SOURCES) config.h Makefile patchlevel.h $(SHELL) $(SUPPORT_SRC)mkversion.sh -b -S ${topdir} -s $(RELSTATUS) -d $(Version) -o newversion.h \ @@ -646,11 +699,14 @@ version.h: $(SOURCES) config.h Makefile patchlevel.h bashversion$(EXEEXT): buildversion.o $(SUPPORT_SRC)bashversion.c $(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) ${LDFLAGS_FOR_BUILD} -o $@ $(SUPPORT_SRC)bashversion.c buildversion.o ${LIBS_FOR_BUILD} +bashversion$(EXEEXT): buildconf.h + buildversion.o: $(srcdir)/version.c $(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) -DBUILDTOOL -c -o $@ $(srcdir)/version.c buildversion.o: bashintl.h $(BASHINCDIR)/gettext.h buildversion.o: version.h patchlevel.h conftypes.h +buildversion.o: buildconf.h # old rules GRAM_H = parser-built @@ -680,40 +736,42 @@ $(LIBDEP): .build $(READLINE_LIBRARY): config.h $(READLINE_SOURCE) @echo making $@ in ${RL_LIBDIR} @( { test "${RL_LIBDIR}" = "${libdir}" && exit 0; } || \ - cd ${RL_LIBDIR} && $(MAKE) $(MFLAGS) DEBUG=${DEBUG} libreadline.a) || exit 1 + cd ${RL_LIBDIR} && $(MAKE) $(BASH_MAKEFLAGS) DEBUG=${DEBUG} libreadline.a) || exit 1 $(HISTORY_LIBRARY): config.h $(HISTORY_SOURCE) $(READLINE_DEP) @echo making $@ in ${HIST_LIBDIR} @( { test "${HIST_LIBDIR}" = "${libdir}" && exit 0; } || \ - cd ${HIST_LIBDIR} && $(MAKE) $(MFLAGS) DEBUG=${DEBUG} libhistory.a) || exit 1 + cd ${HIST_LIBDIR} && $(MAKE) $(BASH_MAKEFLAGS) DEBUG=${DEBUG} libhistory.a) || exit 1 $(GLOB_LIBRARY): config.h $(GLOB_SOURCE) @echo making $@ in ${GLOB_LIBDIR} @(cd ${GLOB_LIBDIR} && \ - $(MAKE) $(MFLAGS) DEBUG=${DEBUG} libglob.a) || exit 1 + $(MAKE) $(BASH_MAKEFLAGS) DEBUG=${DEBUG} libglob.a) || exit 1 $(TILDE_LIBRARY): config.h $(TILDE_SOURCE) @echo making $@ in ${TILDE_LIBDIR} @(cd ${TILDE_LIBDIR} && \ - $(MAKE) $(MFLAGS) libtilde.a) || exit 1 + $(MAKE) $(BASH_MAKEFLAGS) libtilde.a) || exit 1 $(TERMCAP_LIBRARY): config.h ${TERMCAP_SOURCE} @echo making $@ in ${TERM_LIBDIR} @(cd ${TERM_LIBDIR} && \ - $(MAKE) $(MFLAGS) libtermcap.a) || exit 1 + $(MAKE) $(BASH_MAKEFLAGS) libtermcap.a) || exit 1 $(SHLIB_LIBRARY): config.h ${SHLIB_SOURCE} @echo making $@ in ${SH_LIBDIR} @(cd ${SH_LIBDIR} && \ - $(MAKE) $(MFLAGS) DEBUG=${DEBUG} ${SHLIB_LIBNAME}) || exit 1 + $(MAKE) $(BASH_MAKEFLAGS) DEBUG=${DEBUG} ${SHLIB_LIBNAME}) || exit 1 ${INTL_LIBRARY}: config.h ${INTL_LIBDIR}/Makefile @echo making $@ in ${INTL_LIBDIR} @(cd ${INTL_LIBDIR} && \ - $(MAKE) $(MFLAGS) XCFLAGS="${LOCAL_CFLAGS}" all) || exit 1 + $(MAKE) $(BASH_MAKEFLAGS) XCFLAGS="${LOCAL_CFLAGS}" all) || exit 1 ${LIBINTL_H}: ${INTL_DEP} +# If we are cross-compiling, we link in this file and initialize the array +# of signal names at runtime signames.o: $(SUPPORT_SRC)signames.c $(RM) $@ $(CC) $(CCFLAGS) -c $(SUPPORT_SRC)signames.c @@ -726,11 +784,13 @@ mksignames.o: $(SUPPORT_SRC)mksignames.c $(RM) $@ $(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) -DBUILDTOOL -c $(SUPPORT_SRC)mksignames.c +# If we are not cross-compiling, we write out a header file (lsignames.h) with +# the signal name definitions at build time mksignames$(EXEEXT): mksignames.o buildsignames.o $(RM) $@ $(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) ${LDFLAGS_FOR_BUILD} -o $@ mksignames.o buildsignames.o ${LIBS_FOR_BUILD} -mksyntax$(EXEEXT): ${srcdir}/mksyntax.c config.h syntax.h ${BASHINCDIR}/chartypes.h bashansi.h +mksyntax$(EXEEXT): ${srcdir}/mksyntax.c buildconf.h syntax.h ${BASHINCDIR}/chartypes.h $(RM) $@ ${CC_FOR_BUILD} ${CCFLAGS_FOR_BUILD} ${LDFLAGS_FOR_BUILD} -o $@ ${srcdir}/mksyntax.c ${LIBS_FOR_BUILD} @@ -748,24 +808,24 @@ syntax.c: mksyntax${EXEEXT} $(srcdir)/syntax.h $(RM) $@ ./mksyntax$(EXEEXT) -o $@ -$(BUILTINS_LIBRARY): $(DEFDIR)/builtext.h $(BUILTIN_DEFS) $(BUILTIN_C_SRC) config.h ${BASHINCDIR}/memalloc.h version.h - @(cd $(DEFDIR) && $(MAKE) $(MFLAGS) DEBUG=${DEBUG} targets ) || exit 1 +$(BUILTINS_LIBRARY): $(DEFDIR)/builtext.h $(BUILTIN_DEFS) $(BUILTIN_C_SRC) config.h ${BASHINCDIR}/memalloc.h pathnames.h + @(cd $(DEFDIR) && $(MAKE) $(BASH_MAKEFLAGS) DEBUG=${DEBUG} targets ) || exit 1 # these require special rules to circumvent make builtin rules ${DEFDIR}/common.o: $(BUILTIN_SRCDIR)/common.c - @(cd $(DEFDIR) && $(MAKE) $(MFLAGS) DEBUG=${DEBUG} common.o) || exit 1 + @(cd $(DEFDIR) && $(MAKE) $(BASH_MAKEFLAGS) DEBUG=${DEBUG} common.o) || exit 1 ${DEFDIR}/bashgetopt.o: $(BUILTIN_SRCDIR)/bashgetopt.c - @(cd $(DEFDIR) && $(MAKE) $(MFLAGS) DEBUG=${DEBUG} bashgetopt.o) || exit 1 + @(cd $(DEFDIR) && $(MAKE) $(BASH_MAKEFLAGS) DEBUG=${DEBUG} bashgetopt.o) || exit 1 ${DEFDIR}/builtext.h: $(BUILTIN_DEFS) - @(cd $(DEFDIR) && $(MAKE) $(MFLAGS) builtext.h ) || exit 1 + @(cd $(DEFDIR) && $(MAKE) $(BASH_MAKEFLAGS) builtext.h ) || exit 1 ${DEFDIR}/pipesize.h: ${BUILTINS_LIBRARY} - @(cd $(DEFDIR) && $(MAKE) $(MFLAGS) pipesize.h ) || exit 1 + @(cd $(DEFDIR) && $(MAKE) $(BASH_MAKEFLAGS) pipesize.h ) || exit 1 -$(SDIR)/man2html$(EXEEXT): ${SUPPORT_SRC}/man2html.c - @(cd $(SDIR) && $(MAKE) $(MFLAGS) all ) || exit 1 +$(SUPPORT_DIR)/man2html$(EXEEXT): $(SUPPORT_SRC)man2html.c + @(cd $(SUPPORT_DIR) && $(MAKE) $(BASH_MAKEFLAGS) all ) || exit 1 # For the justification of the following Makefile rules, see node # `Automatic Remaking' in GNU Autoconf documentation. @@ -795,6 +855,12 @@ pathnames.h: Makefile $(srcdir)/pathnames.h.in fi @${RM} pathnames.tmp +buildconf.h: $(srcdir)/buildconf.h.in + CONFIG_FILES= CONFIG_HEADERS=buildconf.h $(SHELL) ./config.status + +$(SUPPORT_DIR)/bashbug.sh: $(SUPPORT_DIR)/bashbug.sh.in + CONFIG_FILES=$(SUPPORT_DIR)/bashbug.sh CONFIG_HEADERS= $(SHELL) ./config.status + # comment out for distribution $(srcdir)/configure: $(srcdir)/configure.ac $(srcdir)/aclocal.m4 $(srcdir)/config.h.in cd $(srcdir) && autoconf @@ -803,20 +869,21 @@ $(srcdir)/configure: $(srcdir)/configure.ac $(srcdir)/aclocal.m4 $(srcdir)/confi reconfig: force sh $(srcdir)/configure -C -loadables: - cd $(LOADABLES_DIR) && $(MAKE) $(MFLAGS) all +# force loadables to wait until the shell is built +loadables: .made + cd $(LOADABLES_DIR) && $(MAKE) $(BASH_MAKEFLAGS) all #newversion: mkversion # $(RM) .build # ./mkversion -dir $(srcdir) -dist # mv -f newversion.h version.h -# $(MAKE) -f $(srcdir)/Makefile $(MFLAGS) srcdir=$(srcdir) +# $(MAKE) -f $(srcdir)/Makefile $(BASH_MAKEFLAGS) srcdir=$(srcdir) doc documentation: force - @(cd $(DOCDIR) ; $(MAKE) $(MFLAGS) ) + @(cd $(DOCDIR) ; $(MAKE) $(BASH_MAKEFLAGS) ) -info dvi ps: force - @(cd $(DOCDIR) ; $(MAKE) $(MFLAGS) CFLAGS='$(CCFLAGS)' $@ ) +info dvi ps pdf html: force + @(cd $(DOCDIR) ; $(MAKE) $(BASH_MAKEFLAGS) CFLAGS='$(CCFLAGS)' $@ ) force: @@ -825,31 +892,41 @@ TAGS: $(SOURCES) $(BUILTIN_C_SRC) $(LIBRARY_SOURCE) ( cd $(topdir) && $(ETAGS) $(ETAGSFLAGS) $(SOURCES) $(BUILTIN_C_SRC) $(LIBRARY_SOURCE) ) tags: $(SOURCES) $(BUILTIN_C_SRC) $(LIBRARY_SOURCE) - ( cd $(topdir) && $(CTAGS) $(CTAGSFLAGS) $(SOURCES) $(BUILTIN_C_SRC) $(LIBRARY_SOURCE) > $@ ) + ( cd $(topdir) && $(CTAGS) $(CTAGSFLAGS) $(SOURCES) $(BUILTIN_C_SRC) $(LIBRARY_SOURCE) ) # Targets that actually do things not part of the build +install-html: + @(cd $(DOCDIR) ; $(MAKE) $(BASH_MAKEFLAGS) CFLAGS='$(CCFLAGS)' $@ ) + + +install-info: +install-dvi: +install-pdf: +install-ps: +installcheck: + installdirs: @${SHELL} $(SUPPORT_SRC)mkinstalldirs $(DESTDIR)$(bindir) @${SHELL} $(SUPPORT_SRC)mkinstalldirs $(DESTDIR)$(man1dir) @${SHELL} $(SUPPORT_SRC)mkinstalldirs $(DESTDIR)$(infodir) @${SHELL} $(SUPPORT_SRC)mkinstalldirs $(DESTDIR)$(docdir) - -( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ ) + -( cd $(PO_DIR) ; $(MAKE) $(BASH_MAKEFLAGS) DESTDIR=$(DESTDIR) $@ ) install: .made installdirs $(INSTALL_PROGRAM) $(INSTALLMODE) $(Program) $(DESTDIR)$(bindir)/$(Program) $(INSTALL_SCRIPT) $(INSTALLMODE2) bashbug $(DESTDIR)$(bindir)/bashbug $(INSTALL_DATA) $(OTHER_DOCS) $(DESTDIR)$(docdir) - -( cd $(DOCDIR) ; $(MAKE) $(MFLAGS) \ + -( cd $(DOCDIR) ; $(MAKE) $(BASH_MAKEFLAGS) \ man1dir=$(man1dir) man1ext=$(man1ext) \ man3dir=$(man3dir) man3ext=$(man3ext) \ infodir=$(infodir) htmldir=$(htmldir) DESTDIR=$(DESTDIR) $@ ) - -( cd $(DEFDIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ ) - -( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ ) - -( cd $(LOADABLES_DIR) && $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ ) + -( cd $(DEFDIR) ; $(MAKE) $(BASH_MAKEFLAGS) DESTDIR=$(DESTDIR) $@ ) + -( cd $(PO_DIR) ; $(MAKE) $(BASH_MAKEFLAGS) DESTDIR=$(DESTDIR) $@ ) + -( cd $(LOADABLES_DIR) && $(MAKE) $(BASH_MAKEFLAGS) DESTDIR=$(DESTDIR) $@ ) install-strip: - $(MAKE) $(MFLAGS) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' \ + $(MAKE) $(BASH_MAKEFLAGS) INSTALL_PROGRAM='$(INSTALL_STRIP_PROGRAM)' \ prefix=${prefix} exec_prefix=${exec_prefix} \ DESTDIR=$(DESTDIR) install @@ -859,11 +936,24 @@ install-headers-dirs: @${SHELL} $(SUPPORT_SRC)mkinstalldirs $(DESTDIR)$(headersdir)/include @${SHELL} $(SUPPORT_SRC)mkinstalldirs $(DESTDIR)$(pkgconfigdir) -install-headers: install-headers-dirs +maybe-install-headers: install-headers-dirs + @for hf in $(HYBRID_HEADERS) ; do \ + if test -f $(BUILD_DIR)/"$$hf" ; then \ + ${INSTALL_DATA} $(BUILD_DIR)/"$$hf" $(DESTDIR)$(headersdir)/$$hf || exit 1; \ + else \ + ${INSTALL_DATA} $(srcdir)/"$$hf" $(DESTDIR)$(headersdir)/$$hf || exit 1; \ + fi ; \ + done + @SDH=${CREATED_SUBDIR_HEADERS} ; \ + for hf in $${SDH} ; do \ + $(INSTALL_DATA) "$$hf" $(DESTDIR)$(headersdir)/ ; \ + done + +install-headers: maybe-install-headers @for hf in $(INSTALLED_HEADERS) ; do \ ${INSTALL_DATA} $(srcdir)/"$$hf" $(DESTDIR)$(headersdir)/$$hf || exit 1; \ done - @for hf in $(INSTALLED_INCFILES) ; do \ + @for hf in $(INSTALLED_INCLUDE_HEADERS) ; do \ ${INSTALL_DATA} $(BASHINCDIR)/"$$hf" $(DESTDIR)$(headersdir)/include/$$hf || exit 1; \ done @for hf in $(INSTALLED_BUILTINS_HEADERS) ; do \ @@ -876,26 +966,38 @@ install-headers: install-headers-dirs ${INSTALL_DATA} $(srcdir)/"$$hf" $(DESTDIR)$(headersdir)/$$hf || exit 1; \ fi ; \ done - -$(INSTALL_DATA) $(SDIR)/bash.pc $(DESTDIR)$(pkgconfigdir)/bash.pc + -$(INSTALL_DATA) $(SUPPORT_DIR)/bash.pc $(DESTDIR)$(pkgconfigdir)/bash.pc + +uninstall-headers-dirs: + -$(RMDIR) $(DESTDIR)$(headersdir)/builtins $(DESTDIR)$(headersdir)/include + -$(RMDIR) $(DESTDIR)$(headersdir) uninstall-headers: -( cd $(DESTDIR)$(headersdir) && $(RM) $(INSTALLED_HEADERS) ) - -( cd $(DESTDIR)$(headersdir)/include && $(RM) $(INSTALLED_INCFILES) ) + -( cd $(DESTDIR)$(headersdir)/include && $(RM) $(INSTALLED_INCLUDE_HEADERS) ) -( cd $(DESTDIR)$(headersdir)/builtins && $(RM) $(INSTALLED_BUILTINS_HEADERS) ) - -( cd $(DESTDIR)$(headersdir) && $(RM) $(CREATED_HEADERS) ) + -( cd $(DESTDIR)$(headersdir) && $(RM) $(CREATED_HEADERS) $(HYBRID_HEADERS) ) + -SDH=${CREATED_SUBDIR_HEADERS} ; \ + for hf in $${SDH} ; do \ + ( cd $(DESTDIR)$(headersdir) && $(RM) $$(basename "$$hf") ) \ + done -( $(RM) $(DESTDIR)$(pkgconfigdir)/bash.pc ) + # uninstall-headers-dirs + -$(RMDIR) $(DESTDIR)$(headersdir)/builtins $(DESTDIR)$(headersdir)/include + -$(RMDIR) $(DESTDIR)$(headersdir) uninstall: .made $(RM) $(DESTDIR)$(bindir)/$(Program) $(DESTDIR)$(bindir)/bashbug -( cd $(DESTDIR)$(docdir) && ${RM} ${OTHER_INSTALLED_DOCS} ) - -( cd $(DOCDIR) ; $(MAKE) $(MFLAGS) \ + -( cd $(DOCDIR) ; $(MAKE) $(BASH_MAKEFLAGS) \ man1dir=$(man1dir) man1ext=$(man1ext) \ man3dir=$(man3dir) man3ext=$(man3ext) \ infodir=$(infodir) htmldir=$(htmldir) DESTDIR=$(DESTDIR) $@ ) - -( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ ) - -( cd $(LOADABLES_DIR) && $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ ) + -( cd $(PO_DIR) ; $(MAKE) $(BASH_MAKEFLAGS) DESTDIR=$(DESTDIR) $@ ) + -( cd $(LOADABLES_DIR) && $(MAKE) $(BASH_MAKEFLAGS) DESTDIR=$(DESTDIR) $@ ) + -$(RMDIR) $(DESTDIR)$(loadablesdir) $(DESTDIR)$(docdir) -.PHONY: basic-clean clean realclean maintainer-clean distclean mostlyclean maybe-clean +.PHONY: basic-clean clean maintainer-clean distclean mostlyclean maybe-clean LIB_SUBDIRS = ${RL_LIBDIR} ${HIST_LIBDIR} ${TERM_LIBDIR} ${GLOB_LIBDIR} \ ${INTL_LIBDIR} ${TILDE_LIBDIR} ${ALLOC_LIBDIR} ${SH_LIBDIR} @@ -905,55 +1007,60 @@ basic-clean: $(RM) .build .made version.h clean: basic-clean - ( cd $(DOCDIR) && $(MAKE) $(MFLAGS) $@ ) - ( cd builtins && $(MAKE) $(MFLAGS) $@ ) - -( cd $(SDIR) && $(MAKE) $(MFLAGS) $@ ) + ( cd $(DOCDIR) && $(MAKE) $(BASH_MAKEFLAGS) $@ ) + ( cd builtins && $(MAKE) $(BASH_MAKEFLAGS) $@ ) + -( cd $(SUPPORT_DIR) && $(MAKE) $(BASH_MAKEFLAGS) $@ ) -for libdir in ${LIB_SUBDIRS}; do \ - (cd $$libdir && test -f Makefile && $(MAKE) $(MFLAGS) $@) ;\ + (cd $$libdir && test -f Makefile && $(MAKE) $(BASH_MAKEFLAGS) $@) ;\ done - -( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ ) - -( cd $(LOADABLES_DIR) && $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ ) + -( cd $(PO_DIR) ; $(MAKE) $(BASH_MAKEFLAGS) DESTDIR=$(DESTDIR) $@ ) + -( cd $(LOADABLES_DIR) && $(MAKE) $(BASH_MAKEFLAGS) DESTDIR=$(DESTDIR) $@ ) $(RM) $(CREATED_SUPPORT) + $(RM) -rf $(CREATED_MACOS) mostlyclean: basic-clean - ( cd $(DOCDIR) && $(MAKE) $(MFLAGS) $@ ) - ( cd builtins && $(MAKE) $(MFLAGS) $@ ) - -( cd $(SDIR) && $(MAKE) $(MFLAGS) $@ ) + ( cd $(DOCDIR) && $(MAKE) $(BASH_MAKEFLAGS) $@ ) + ( cd builtins && $(MAKE) $(BASH_MAKEFLAGS) $@ ) + -( cd $(SUPPORT_DIR) && $(MAKE) $(BASH_MAKEFLAGS) $@ ) -for libdir in ${LIB_SUBDIRS}; do \ - (cd $$libdir && test -f Makefile && $(MAKE) $(MFLAGS) $@) ;\ + (cd $$libdir && test -f Makefile && $(MAKE) $(BASH_MAKEFLAGS) $@) ;\ done - -( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ ) - -( cd $(LOADABLES_DIR) && $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ ) + -( cd $(PO_DIR) ; $(MAKE) $(BASH_MAKEFLAGS) DESTDIR=$(DESTDIR) $@ ) + -( cd $(LOADABLES_DIR) && $(MAKE) $(BASH_MAKEFLAGS) DESTDIR=$(DESTDIR) $@ ) distclean: basic-clean maybe-clean - ( cd $(DOCDIR) && $(MAKE) $(MFLAGS) $@ ) - ( cd builtins && $(MAKE) $(MFLAGS) $@ ) - -( cd $(SDIR) && $(MAKE) $(MFLAGS) $@ ) + ( cd $(DOCDIR) && $(MAKE) $(BASH_MAKEFLAGS) $@ ) + ( cd builtins && $(MAKE) $(BASH_MAKEFLAGS) $@ ) + -( cd $(SUPPORT_DIR) && $(MAKE) $(BASH_MAKEFLAGS) $@ ) -for libdir in ${LIB_SUBDIRS}; do \ - (cd $$libdir && test -f Makefile && $(MAKE) $(MFLAGS) $@) ;\ + (cd $$libdir && test -f Makefile && $(MAKE) $(BASH_MAKEFLAGS) $@) ;\ done - -( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ ) - -( cd $(LOADABLES_DIR) && $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ ) + -( cd $(PO_DIR) ; $(MAKE) $(BASH_MAKEFLAGS) DESTDIR=$(DESTDIR) $@ ) + -( cd $(LOADABLES_DIR) && $(MAKE) $(BASH_MAKEFLAGS) DESTDIR=$(DESTDIR) $@ ) $(RM) $(CREATED_CONFIGURE) tags TAGS - $(RM) $(CREATED_SUPPORT) Makefile $(CREATED_MAKEFILES) pathnames.h + $(RM) $(CREATED_SUPPORT) Makefile $(CREATED_MAKEFILES) $(CREATED_HEADERS) + $(RM) -rf $(CREATED_MACOS) maintainer-clean: basic-clean @echo This command is intended for maintainers to use. @echo It deletes files that may require special tools to rebuild. $(RM) y.tab.c y.tab.h parser-built tags TAGS - ( cd $(DOCDIR) && $(MAKE) $(MFLAGS) $@ ) - ( cd builtins && $(MAKE) $(MFLAGS) $@ ) - ( cd $(SDIR) && $(MAKE) $(MFLAGS) $@ ) + ( cd $(DOCDIR) && $(MAKE) $(BASH_MAKEFLAGS) $@ ) + ( cd builtins && $(MAKE) $(BASH_MAKEFLAGS) $@ ) + ( cd $(SUPPORT_DIR) && $(MAKE) $(BASH_MAKEFLAGS) $@ ) -for libdir in ${LIB_SUBDIRS}; do \ - (cd $$libdir && test -f Makefile && $(MAKE) $(MFLAGS) $@) ;\ + (cd $$libdir && test -f Makefile && $(MAKE) $(BASH_MAKEFLAGS) $@) ;\ done - -( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ ) - -( cd $(LOADABLES_DIR) && $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ ) - $(RM) $(CREATED_CONFIGURE) $(CREATED_MAKEFILES) - $(RM) $(CREATED_SUPPORT) Makefile pathnames.h + -( cd $(PO_DIR) ; $(MAKE) $(BASH_MAKEFLAGS) DESTDIR=$(DESTDIR) $@ ) + -( cd $(LOADABLES_DIR) && $(MAKE) $(BASH_MAKEFLAGS) DESTDIR=$(DESTDIR) $@ ) + $(RM) $(CREATED_CONFIGURE) Makefile $(CREATED_MAKEFILES) + $(RM) $(CREATED_SUPPORT) $(CREATED_HEADERS) + $(RM) -rf $(CREATED_MACOS) maybe-clean: - -if test X"`cd $(topdir) && pwd -P`" != X"`cd $(BUILD_DIR) && pwd -P`" ; then \ + -TD=$$(cd $(topdir) && pwd -P); \ + BD=$$(cd $(BUILD_DIR) && pwd -P); \ + if test X"$$TD" != X"$$BD" ; then \ $(RM) parser-built y.tab.c y.tab.h ; \ fi @@ -984,13 +1091,13 @@ dist: force @echo $(Program) $(srcdir)/support/mkdist -m $(srcdir)/MANIFEST -s $(srcdir) -r ${PACKAGE} -t $(PACKAGE_VERSION) xdist: force - ( cd $(DOCDIR) && $(MAKE) $(MFLAGS) $@ ) - ( cd po && $(MAKE) $(MFLAGS) $@ ) + ( cd $(DOCDIR) && $(MAKE) $(BASH_MAKEFLAGS) $@ ) + ( cd po && $(MAKE) $(BASH_MAKEFLAGS) $@ ) depend: depends depends: force - $(Program) $(SUPPORT_SRC)mkdep -c ${CC} -- ${CCFLAGS} ${CSOURCES} + $(Program) $(MKDEP) ${MKDEP_OPTS} -- ${MKDEP_CCFLAGS} ${CSOURCES} #### PRIVATE TARGETS #### hashtest: hashlib.c @@ -1032,6 +1139,7 @@ copy_cmd.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h copy_cmd.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h copy_cmd.o: make_cmd.h subst.h sig.h pathnames.h externs.h copy_cmd.o: bashansi.h assoc.h $(BASHINCDIR)/ocache.h $(BASHINCDIR)/chartypes.h +copy_cmd.o: $(BASHINCDIR)/unlocked-io.h dispose_cmd.o: bashansi.h ${BASHINCDIR}/ansi_stdlib.h dispose_cmd.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h dispose_cmd.o: error.h general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h @@ -1039,6 +1147,7 @@ dispose_cmd.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h dispose_cmd.o: make_cmd.h subst.h sig.h pathnames.h externs.h dispose_cmd.o: ${BASHINCDIR}/ocache.h dispose_cmd.o: assoc.h ${BASHINCDIR}/chartypes.h +dispose_cmd.o: $(BASHINCDIR)/unlocked-io.h error.o: config.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h flags.h ${BASHINCDIR}/stdc.h error.h error.o: command.h general.h xmalloc.h externs.h input.h bashhist.h error.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h @@ -1047,12 +1156,14 @@ error.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h error.o: make_cmd.h subst.h sig.h pathnames.h externs.h execute_cmd.h error.o: input.h execute_cmd.h error.o: $(BASHINCDIR)/ocache.h $(BASHINCDIR)/chartypes.h assoc.h +error.o: $(BASHINCDIR)/unlocked-io.h eval.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h trap.h flags.h ${DEFSRC}/common.h eval.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h eval.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h eval.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h eval.o: make_cmd.h subst.h sig.h pathnames.h externs.h parser.h -eval.o: input.h execute_cmd.h +eval.o: input.h execute_cmd.h jobs.h +eval.o: $(BASHINCDIR)/unlocked-io.h eval.o: bashhist.h assoc.h ${BASHINCDIR}/ocache.h ${BASHINCDIR}/chartypes.h execute_cmd.o: config.h bashtypes.h ${BASHINCDIR}/filecntl.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h execute_cmd.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h @@ -1066,6 +1177,7 @@ execute_cmd.o: ${BASHINCDIR}/posixtime.h ${BASHINCDIR}/chartypes.h execute_cmd.o: $(DEFSRC)/getopt.h execute_cmd.o: bashhist.h input.h ${GRAM_H} assoc.h hashcmd.h alias.h execute_cmd.o: ${BASHINCDIR}/ocache.h ${BASHINCDIR}/posixwait.h +execute_cmd.o: $(BASHINCDIR)/unlocked-io.h expr.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h expr.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h expr.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h @@ -1073,6 +1185,7 @@ expr.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h expr.o: make_cmd.h subst.h sig.h pathnames.h externs.h flags.h execute_cmd.h expr.o: ${BASHINCDIR}/chartypes.h expr.o: assoc.h ${BASHINCDIR}/ocache.h ${BASHINCDIR}/typemax.h +expr.o: $(DEFSRC)/common.h $(DEFDIR)/builtext.h findcmd.o: config.h bashtypes.h ${BASHINCDIR}/filecntl.h ${BASHINCDIR}/posixstat.h bashansi.h findcmd.o: ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/memalloc.h shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h findcmd.o: ${BASHINCDIR}/stdc.h error.h general.h xmalloc.h variables.h arrayfunc.h conftypes.h quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h @@ -1129,6 +1242,7 @@ mailcheck.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h mailcheck.o: make_cmd.h subst.h sig.h pathnames.h externs.h mailcheck.o: execute_cmd.h mailcheck.h mailcheck.o: ${BASHINCDIR}/ocache.h ${BASHINCDIR}/chartypes.h assoc.h +mailcheck.o: $(BASHINCDIR)/unlocked-io.h make_cmd.o: config.h bashtypes.h ${BASHINCDIR}/filecntl.h bashansi.h make_cmd.o: command.h ${BASHINCDIR}/stdc.h general.h xmalloc.h error.h flags.h make_cmd.h make_cmd.o: variables.h arrayfunc.h conftypes.h array.h hashlib.h subst.h input.h externs.h @@ -1146,6 +1260,7 @@ y.tab.o: trap.h flags.h parser.h input.h mailcheck.h $(DEFSRC)/common.h y.tab.o: $(DEFDIR)/builtext.h bashline.h bashhist.h jobs.h siglist.h alias.h y.tab.o: ${BASHINCDIR}/typemax.h assoc.h ${BASHINCDIR}/ocache.h y.tab.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h ${BASHINCDIR}/posixwait.h +y.tab.o: $(BASHINCDIR)/unlocked-io.h pathexp.o: config.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h pathexp.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h pathexp.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h @@ -1164,6 +1279,7 @@ print_cmd.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h print_cmd.o: ${GRAM_H} $(DEFSRC)/common.h print_cmd.o: flags.h input.h assoc.h print_cmd.o: $(BASHINCDIR)/ocache.h $(BASHINCDIR)/chartypes.h +print_cmd.o: $(BASHINCDIR)/unlocked-io.h redir.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/filecntl.h redir.o: ${BASHINCDIR}/memalloc.h shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h redir.o: general.h xmalloc.h variables.h arrayfunc.h conftypes.h array.h hashlib.h quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h @@ -1171,15 +1287,17 @@ redir.o: dispose_cmd.h make_cmd.h subst.h sig.h pathnames.h externs.h redir.o: flags.h execute_cmd.h redir.h input.h redir.o: ${DEFDIR}/pipesize.h redir.o: trap.h assoc.h $(BASHINCDIR)/ocache.h $(BASHINCDIR)/chartypes.h +redir.o: $(BASHINCDIR)/unlocked-io.h shell.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/filecntl.h shell.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h shell.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h shell.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h shell.o: make_cmd.h subst.h sig.h pathnames.h externs.h parser.h shell.o: flags.h trap.h mailcheck.h builtins.h $(DEFSRC)/common.h -shell.o: jobs.h siglist.h input.h execute_cmd.h findcmd.h bashhist.h bashline.h +shell.o: jobs.h siglist.h input.h execute_cmd.h findcmd.h bashhist.h bashline.h shell.o: ${GLOB_LIBSRC}/strmatch.h ${BASHINCDIR}/posixtime.h ${BASHINCDIR}/posixwait.h shell.o: ${BASHINCDIR}/ocache.h ${BASHINCDIR}/chartypes.h assoc.h alias.h +shell.o: $(BASHINCDIR)/unlocked-io.h sig.o: config.h bashtypes.h sig.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h sig.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h @@ -1187,6 +1305,7 @@ sig.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h sig.o: make_cmd.h subst.h sig.h pathnames.h externs.h execute_cmd.h sig.o: jobs.h siglist.h trap.h $(DEFSRC)/common.h bashline.h bashhist.h sig.o: ${DEFDIR}/builtext.h +sig.o: $(BASHINCDIR)/unlocked-io.h siglist.o: config.h bashtypes.h siglist.h trap.h stringlib.o: bashtypes.h ${BASHINCDIR}/chartypes.h stringlib.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h @@ -1202,10 +1321,11 @@ subst.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h subst.o: make_cmd.h subst.h sig.h pathnames.h externs.h parser.h subst.o: flags.h jobs.h siglist.h execute_cmd.h ${BASHINCDIR}/filecntl.h trap.h pathexp.h subst.o: mailcheck.h input.h $(DEFSRC)/getopt.h $(DEFSRC)/common.h -subst.o: bashline.h bashhist.h ${GLOB_LIBSRC}/strmatch.h +subst.o: bashline.h bashhist.h ${GLOB_LIBSRC}/strmatch.h redir.h subst.o: ${BASHINCDIR}/chartypes.h subst.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h subst.o: ${DEFDIR}/builtext.h +subst.o: $(BASHINCDIR)/unlocked-io.h test.o: bashtypes.h ${BASHINCDIR}/posixstat.h ${BASHINCDIR}/filecntl.h test.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h test.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h @@ -1233,8 +1353,9 @@ variables.o: flags.h execute_cmd.h mailcheck.h input.h $(DEFSRC)/common.h variables.o: findcmd.h bashhist.h hashcmd.h pathexp.h variables.o: pcomplete.h ${BASHINCDIR}/chartypes.h variables.o: ${BASHINCDIR}/posixtime.h assoc.h ${DEFSRC}/getopt.h -variables.o: version.h $(DEFDIR)/builtext.h +variables.o: $(DEFDIR)/builtext.h version.o: conftypes.h patchlevel.h version.h +version.o: buildconf.h xmalloc.o: config.h bashtypes.h ${BASHINCDIR}/ansi_stdlib.h error.h xmalloc.o: ${BASHINCDIR}/stdc.h $(ALLOC_LIBSRC)/shmalloc.h @@ -1250,11 +1371,14 @@ jobs.o: jobs.h flags.h $(DEFSRC)/common.h $(DEFDIR)/builtext.h jobs.o: ${BASHINCDIR}/posixwait.h ${BASHINCDIR}/unionwait.h jobs.o: ${BASHINCDIR}/posixtime.h jobs.o: $(BASHINCDIR)/ocache.h $(BASHINCDIR)/chartypes.h $(BASHINCDIR)/typemax.h +jobs.o: $(BASHINCDIR)/unlocked-io.h nojobs.o: config.h bashtypes.h ${BASHINCDIR}/filecntl.h bashjmp.h ${BASHINCDIR}/posixjmp.h nojobs.o: command.h ${BASHINCDIR}/stdc.h general.h xmalloc.h jobs.h quit.h siglist.h externs.h nojobs.o: sig.h error.h ${BASHINCDIR}/shtty.h input.h parser.h nojobs.o: $(DEFDIR)/builtext.h nojobs.o: $(BASHINCDIR)/ocache.h $(BASHINCDIR)/chartypes.h $(BASHINCDIR)/typemax.h +nojobs.o: $(BASHINCDIR)/unlocked-io.h +nojobs.o: shell.h pathnames.h # shell features that may be compiled in @@ -1296,7 +1420,8 @@ braces.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h ar braces.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h braces.o: make_cmd.h subst.h sig.h pathnames.h externs.h braces.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h -braces.o: ${BASHINCDIR}/typemax.h ${BASHINCDIR}/ocache.h ${BASHINCDIR}/chartypes.h +braces.o: ${BASHINCDIR}/typemax.h ${BASHINCDIR}/ocache.h ${BASHINCDIR}/chartypes.h +braces.o: ${STDCKDINT_H} ${BASHINCDIR}/intprops-internal.h alias.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h command.h ${BASHINCDIR}/stdc.h alias.o: general.h xmalloc.h bashtypes.h externs.h alias.h alias.o: pcomplete.h hashlib.h @@ -1322,6 +1447,7 @@ pcomplete.o: externs.h ${BASHINCDIR}/maxpath.h execute_cmd.h pcomplete.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h pcomplete.o: builtins.h ${DEFDIR}/builtext.h ${DEFSRC}/common.h pcomplete.o: ${GLOB_LIBSRC}/glob.h ${GLOB_LIBSRC}/strmatch.h +pcomplete.o: $(BASHINCDIR)/unlocked-io.h # library support files @@ -1345,6 +1471,7 @@ bashline.o: $(DEFSRC)/common.h $(GLOB_LIBSRC)/glob.h alias.h bashline.o: pcomplete.h ${BASHINCDIR}/chartypes.h input.h bashline.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h bashline.o: ${DEFDIR}/builtext.h +bashline.o: $(BASHINCDIR)/unlocked-io.h bracecomp.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h bracecomp.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h bracecomp.o: command.h ${BASHINCDIR}/stdc.h error.h @@ -1384,13 +1511,18 @@ pcomplete.o: $(RL_LIBSRC)/keymaps.h $(RL_LIBSRC)/rlstdc.h pcomplete.o: $(RL_LIBSRC)/chardefs.h $(RL_LIBSRC)/readline.h pcomplete.o: $(RL_LIBSRC)/rltypedefs.h ${RL_LIBSRC}/rlmbutil.h -shell.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h +bashhist.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h +bashline.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h +bracecomp.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h +error.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h +eval.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h +execute_cmd.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h +flags.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h variables.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h subst.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h -bashline.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h -bashhist.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h y.tab.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h pcomplete.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h +shell.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h bashline.o: $(TILDE_LIBSRC)/tilde.h bracecomp.o: $(TILDE_LIBSRC)/tilde.h @@ -1432,9 +1564,11 @@ siglist.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h subst.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h test.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h trap.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +unwind_prot.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h variables.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h version.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h xmalloc.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +xmalloc.o: ${STDCKDINT_H} ${BASHINCDIR}/intprops-internal.h # XXX $(MALLOC_SOURCE): bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h @@ -1444,338 +1578,354 @@ signames.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h # XXX - dependencies checked through here # builtin c sources -builtins/bashgetopt.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h -builtins/bashgetopt.o: shell.h syntax.h config.h bashjmp.h command.h general.h xmalloc.h error.h -builtins/bashgetopt.o: variables.h arrayfunc.h conftypes.h quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h -builtins/bashgetopt.o: make_cmd.h subst.h sig.h pathnames.h externs.h -builtins/bashgetopt.o: $(DEFSRC)/common.h -builtins/bashgetopt.o: ${BASHINCDIR}/chartypes.h -builtins/common.o: bashtypes.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h -builtins/common.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h command.h -builtins/common.o: ${BASHINCDIR}/memalloc.h variables.h arrayfunc.h conftypes.h input.h siglist.h -builtins/common.o: quit.h unwind_prot.h ${BASHINCDIR}/maxpath.h jobs.h builtins.h -builtins/common.o: dispose_cmd.h make_cmd.h subst.h externs.h bashhist.h -builtins/common.o: execute_cmd.h ${BASHINCDIR}/stdc.h general.h xmalloc.h error.h pathnames.h -builtins/common.o: ${DEFDIR}/builtext.h parser.h -builtins/common.o: ${BASHINCDIR}/chartypes.h -builtins/evalfile.o: bashtypes.h ${BASHINCDIR}/posixstat.h ${BASHINCDIR}/filecntl.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h -builtins/evalfile.o: shell.h syntax.h config.h bashjmp.h command.h general.h xmalloc.h error.h -builtins/evalfile.o: variables.h arrayfunc.h conftypes.h quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h -builtins/evalfile.o: make_cmd.h subst.h sig.h pathnames.h externs.h parser.h -builtins/evalfile.o: jobs.h builtins.h flags.h input.h execute_cmd.h -builtins/evalfile.o: bashhist.h $(DEFSRC)/common.h -builtins/evalstring.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h -builtins/evalstring.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h command.h siglist.h -builtins/evalstring.o: ${BASHINCDIR}/memalloc.h variables.h arrayfunc.h conftypes.h input.h -builtins/evalstring.o: quit.h unwind_prot.h ${BASHINCDIR}/maxpath.h jobs.h builtins.h -builtins/evalstring.o: dispose_cmd.h make_cmd.h subst.h externs.h -builtins/evalstring.o: jobs.h builtins.h flags.h input.h execute_cmd.h -builtins/evalstring.o: bashhist.h $(DEFSRC)/common.h pathnames.h redir.h -builtins/evalstring.o: ${DEFDIR}/builtext.h -builtins/getopt.o: config.h ${BASHINCDIR}/memalloc.h -builtins/getopt.o: shell.h syntax.h bashjmp.h command.h general.h xmalloc.h error.h -builtins/getopt.o: variables.h arrayfunc.h conftypes.h quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h -builtins/getopt.o: make_cmd.h subst.h sig.h pathnames.h externs.h -builtins/getopt.o: $(DEFSRC)/getopt.h -builtins/mkbuiltins.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h ${BASHINCDIR}/filecntl.h -builtins/mkbuiltins.o: bashansi.h ${BASHINCDIR}/ansi_stdlib.h -builtins/mkbuiltins.o: $(BASHINCDIR)/stdc.h +$(DEFDIR)/bashgetopt.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h +$(DEFDIR)/bashgetopt.o: shell.h syntax.h config.h bashjmp.h command.h general.h xmalloc.h error.h +$(DEFDIR)/bashgetopt.o: variables.h arrayfunc.h conftypes.h quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h +$(DEFDIR)/bashgetopt.o: make_cmd.h subst.h sig.h pathnames.h externs.h +$(DEFDIR)/bashgetopt.o: $(DEFSRC)/common.h +$(DEFDIR)/bashgetopt.o: ${BASHINCDIR}/chartypes.h +$(DEFDIR)/common.o: bashtypes.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h +$(DEFDIR)/common.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h command.h +$(DEFDIR)/common.o: ${BASHINCDIR}/memalloc.h variables.h arrayfunc.h conftypes.h input.h siglist.h +$(DEFDIR)/common.o: quit.h unwind_prot.h ${BASHINCDIR}/maxpath.h jobs.h builtins.h +$(DEFDIR)/common.o: dispose_cmd.h make_cmd.h subst.h externs.h bashhist.h +$(DEFDIR)/common.o: execute_cmd.h ${BASHINCDIR}/stdc.h general.h xmalloc.h error.h pathnames.h +$(DEFDIR)/common.o: ${DEFDIR}/builtext.h parser.h +$(DEFDIR)/common.o: ${BASHINCDIR}/chartypes.h +$(DEFDIR)/common.o: $(BASHINCDIR)/unlocked-io.h +$(DEFDIR)/evalfile.o: bashtypes.h ${BASHINCDIR}/posixstat.h ${BASHINCDIR}/filecntl.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h +$(DEFDIR)/evalfile.o: shell.h syntax.h config.h bashjmp.h command.h general.h xmalloc.h error.h +$(DEFDIR)/evalfile.o: variables.h arrayfunc.h conftypes.h quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h +$(DEFDIR)/evalfile.o: make_cmd.h subst.h sig.h pathnames.h externs.h parser.h +$(DEFDIR)/evalfile.o: jobs.h builtins.h flags.h input.h execute_cmd.h +$(DEFDIR)/evalfile.o: bashhist.h $(DEFSRC)/common.h +$(DEFDIR)/evalstring.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h +$(DEFDIR)/evalstring.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h command.h siglist.h +$(DEFDIR)/evalstring.o: ${BASHINCDIR}/memalloc.h variables.h arrayfunc.h conftypes.h input.h +$(DEFDIR)/evalstring.o: quit.h unwind_prot.h ${BASHINCDIR}/maxpath.h jobs.h builtins.h +$(DEFDIR)/evalstring.o: dispose_cmd.h make_cmd.h subst.h externs.h +$(DEFDIR)/evalstring.o: jobs.h builtins.h flags.h input.h execute_cmd.h +$(DEFDIR)/evalstring.o: bashhist.h $(DEFSRC)/common.h pathnames.h redir.h +$(DEFDIR)/evalstring.o: ${DEFDIR}/builtext.h +$(DEFDIR)/getopt.o: config.h ${BASHINCDIR}/memalloc.h +$(DEFDIR)/getopt.o: shell.h syntax.h bashjmp.h command.h general.h xmalloc.h error.h +$(DEFDIR)/getopt.o: variables.h arrayfunc.h conftypes.h quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h +$(DEFDIR)/getopt.o: make_cmd.h subst.h sig.h pathnames.h externs.h +$(DEFDIR)/getopt.o: $(DEFSRC)/getopt.h +$(DEFDIR)/mkbuiltins.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h ${BASHINCDIR}/filecntl.h +$(DEFDIR)/mkbuiltins.o: bashansi.h ${BASHINCDIR}/ansi_stdlib.h +$(DEFDIR)/mkbuiltins.o: $(BASHINCDIR)/stdc.h # builtin def files -builtins/alias.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h -builtins/alias.o: quit.h $(DEFSRC)/common.h pathnames.h -builtins/alias.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h command.h ${BASHINCDIR}/stdc.h unwind_prot.h -builtins/alias.o: dispose_cmd.h make_cmd.h subst.h externs.h variables.h arrayfunc.h conftypes.h -builtins/bind.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h -builtins/bind.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h -builtins/bind.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h -builtins/bind.o: $(DEFSRC)/bashgetopt.h pathnames.h -builtins/break.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h -builtins/break.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h -builtins/break.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h -builtins/break.o: pathnames.h execute_cmd.h -builtins/builtin.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h -builtins/builtin.o: quit.h $(DEFSRC)/common.h $(DEFSRC)/bashgetopt.h -builtins/builtin.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h -builtins/builtin.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h -builtins/builtin.o: pathnames.h execute_cmd.h -builtins/caller.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h -builtins/caller.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h -builtins/caller.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h -builtins/caller.o: $(DEFSRC)/common.h quit.h -builtins/caller.o: ${BASHINCDIR}/chartypes.h bashtypes.h -builtins/caller.o: ${DEFDIR}/builtext.h pathnames.h -builtins/cd.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h -builtins/cd.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h -builtins/cd.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h -builtins/cd.o: $(DEFSRC)/common.h quit.h pathnames.h -builtins/colon.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h -builtins/colon.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h -builtins/colon.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h -builtins/colon.o: pathnames.h -builtins/command.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h -builtins/command.o: quit.h $(DEFSRC)/bashgetopt.h -builtins/command.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h -builtins/command.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h pathnames.h -builtins/declare.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h -builtins/declare.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h -builtins/declare.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h -builtins/declare.o: $(DEFSRC)/bashgetopt.h pathnames.h flags.h -builtins/declare.o: ${DEFDIR}/builtext.h -builtins/echo.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h -builtins/echo.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h -builtins/echo.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h -builtins/echo.o: pathnames.h -builtins/echo.o: $(DEFSRC)/common.h -builtins/enable.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h -builtins/enable.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h -builtins/enable.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h -builtins/enable.o: pcomplete.h pathnames.h -builtins/eval.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h -builtins/eval.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h -builtins/eval.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h -builtins/eval.o: pathnames.h -builtins/exec.o: bashtypes.h pathnames.h -builtins/exec.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h -builtins/exec.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h -builtins/exec.o: dispose_cmd.h make_cmd.h subst.h externs.h execute_cmd.h -builtins/exec.o: findcmd.h flags.h quit.h $(DEFSRC)/common.h ${BASHINCDIR}/stdc.h -builtins/exec.o: pathnames.h -builtins/exit.o: bashtypes.h -builtins/exit.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h -builtins/exit.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h -builtins/exit.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h -builtins/exit.o: pathnames.h execute_cmd.h -builtins/exit.o: ${DEFDIR}/builtext.h -builtins/fc.o: bashtypes.h ${BASHINCDIR}/posixstat.h -builtins/fc.o: bashansi.h ${BASHINCDIR}/ansi_stdlib.h builtins.h command.h ${BASHINCDIR}/stdc.h -builtins/fc.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h -builtins/fc.o: flags.h unwind_prot.h variables.h arrayfunc.h conftypes.h shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h -builtins/fc.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h quit.h -builtins/fc.o: $(DEFSRC)/bashgetopt.h bashhist.h pathnames.h parser.h -builtins/fc.o: ${BASHINCDIR}/chartypes.h -builtins/fg_bg.o: bashtypes.h $(DEFSRC)/bashgetopt.h -builtins/fg_bg.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h -builtins/fg_bg.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h -builtins/fg_bg.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h -builtins/fg_bg.o: pathnames.h execute_cmd.h -builtins/getopts.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h -builtins/getopts.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h -builtins/getopts.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h -builtins/getopts.o: pathnames.h execute_cmd.h -builtins/hash.o: bashtypes.h execute_cmd.h -builtins/hash.o: builtins.h command.h findcmd.h ${BASHINCDIR}/stdc.h $(DEFSRC)/common.h -builtins/hash.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h -builtins/hash.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h -builtins/hash.o: pathnames.h -builtins/help.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h -builtins/help.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h -builtins/help.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h -builtins/help.o: conftypes.h quit.h execute_cmd.h -builtins/help.o: $(GLOB_LIBSRC)/glob.h pathnames.h -builtins/history.o: bashtypes.h pathnames.h parser.h -builtins/history.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h -builtins/history.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h -builtins/history.o: ${BASHINCDIR}/filecntl.h shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h -builtins/history.o: bashhist.h variables.h arrayfunc.h conftypes.h -builtins/inlib.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h -builtins/inlib.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h -builtins/inlib.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h -builtins/inlib.o: pathnames.h -builtins/jobs.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h -builtins/jobs.o: quit.h $(DEFSRC)/bashgetopt.h -builtins/jobs.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h -builtins/jobs.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h -builtins/jobs.o: pathnames.h -builtins/kill.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h -builtins/kill.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h -builtins/kill.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h trap.h unwind_prot.h variables.h arrayfunc.h conftypes.h -builtins/kill.o: pathnames.h -builtins/let.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h -builtins/let.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h -builtins/let.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h -builtins/let.o: pathnames.h -builtins/printf.o: config.h ${BASHINCDIR}/memalloc.h bashjmp.h command.h error.h -builtins/printf.o: general.h xmalloc.h quit.h dispose_cmd.h make_cmd.h subst.h -builtins/printf.o: externs.h sig.h pathnames.h shell.h syntax.h unwind_prot.h -builtins/printf.o: variables.h arrayfunc.h conftypes.h ${BASHINCDIR}/stdc.h $(DEFSRC)/bashgetopt.h -builtins/printf.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h -builtins/printf.o: ${BASHINCDIR}/chartypes.h -builtins/pushd.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h -builtins/pushd.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h -builtins/pushd.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h -builtins/pushd.o: $(DEFSRC)/common.h pathnames.h -builtins/pushd.o: ${DEFDIR}/builtext.h -builtins/read.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h -builtins/read.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h -builtins/read.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h -builtins/read.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h -builtins/read.o: pathnames.h -builtins/return.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h -builtins/return.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h -builtins/return.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h -builtins/return.o: pathnames.h execute_cmd.h -builtins/set.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h -builtins/set.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h -builtins/set.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h flags.h -builtins/set.o: pathnames.h parser.h -builtins/setattr.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h -builtins/setattr.o: quit.h $(DEFSRC)/common.h $(DEFSRC)/bashgetopt.h -builtins/setattr.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h -builtins/setattr.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h -builtins/setattr.o: pathnames.h flags.h execute_cmd.h -builtins/shift.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h -builtins/shift.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h -builtins/shift.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h -builtins/shift.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h -builtins/shift.o: pathnames.h -builtins/shopt.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h -builtins/shopt.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h -builtins/shopt.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h unwind_prot.h variables.h arrayfunc.h conftypes.h ${BASHINCDIR}/maxpath.h -builtins/shopt.o: $(DEFSRC)/common.h $(DEFSRC)/bashgetopt.h pathnames.h -builtins/shopt.o: bashhist.h bashline.h -builtins/source.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h -builtins/source.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h -builtins/source.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h -builtins/source.o: findcmd.h $(DEFSRC)/bashgetopt.h flags.h trap.h -builtins/source.o: pathnames.h execute_cmd.h -builtins/suspend.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h -builtins/suspend.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h -builtins/suspend.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h -builtins/suspend.o: pathnames.h -builtins/test.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h -builtins/test.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h -builtins/test.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h -builtins/test.o: execute_cmd.h test.h pathnames.h -builtins/times.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h -builtins/times.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h -builtins/times.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h -builtins/times.o: pathnames.h -builtins/trap.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h -builtins/trap.o: quit.h $(DEFSRC)/common.h -builtins/trap.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h -builtins/trap.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h -builtins/trap.o: pathnames.h -builtins/type.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h -builtins/type.o: quit.h $(DEFSRC)/common.h findcmd.h -builtins/type.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h -builtins/type.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h -builtins/type.o: pathnames.h execute_cmd.h parser.h -builtins/ulimit.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h -builtins/ulimit.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h -builtins/ulimit.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h -builtins/ulimit.o: pathnames.h -builtins/umask.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h -builtins/umask.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h -builtins/umask.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h -builtins/umask.o: ${BASHINCDIR}/chartypes.h pathnames.h -builtins/wait.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h -builtins/wait.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h -builtins/wait.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h -builtins/wait.o: execute_cmd.h -builtins/wait.o: ${BASHINCDIR}/chartypes.h pathnames.h - -builtins/complete.o: config.h shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h -builtins/complete.o: unwind_prot.h variables.h arrayfunc.h conftypes.h -builtins/complete.o: bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h -builtins/complete.o: builtins.h pathnames.h general.h -builtins/complete.o: bashtypes.h ${BASHINCDIR}/chartypes.h xmalloc.h -builtins/complete.o: pcomplete.h -builtins/complete.o: ${DEFSRC}/common.h ${DEFSRC}/bashgetopt.h -builtins/mapfile.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h -builtins/mapfile.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h -builtins/mapfile.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h -builtins/mapfile.o: pathnames.h +$(DEFDIR)/alias.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h +$(DEFDIR)/alias.o: quit.h $(DEFSRC)/common.h pathnames.h +$(DEFDIR)/alias.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h command.h ${BASHINCDIR}/stdc.h unwind_prot.h +$(DEFDIR)/alias.o: dispose_cmd.h make_cmd.h subst.h externs.h variables.h arrayfunc.h conftypes.h +$(DEFDIR)/bind.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h +$(DEFDIR)/bind.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h +$(DEFDIR)/bind.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h +$(DEFDIR)/bind.o: $(DEFSRC)/bashgetopt.h pathnames.h +$(DEFDIR)/break.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h +$(DEFDIR)/break.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h +$(DEFDIR)/break.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h +$(DEFDIR)/break.o: pathnames.h execute_cmd.h +$(DEFDIR)/builtin.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h +$(DEFDIR)/builtin.o: quit.h $(DEFSRC)/common.h $(DEFSRC)/bashgetopt.h +$(DEFDIR)/builtin.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h +$(DEFDIR)/builtin.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h +$(DEFDIR)/builtin.o: pathnames.h execute_cmd.h +$(DEFDIR)/caller.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h +$(DEFDIR)/caller.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h +$(DEFDIR)/caller.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h +$(DEFDIR)/caller.o: $(DEFSRC)/common.h quit.h +$(DEFDIR)/caller.o: ${BASHINCDIR}/chartypes.h bashtypes.h +$(DEFDIR)/caller.o: ${DEFDIR}/builtext.h pathnames.h +$(DEFDIR)/cd.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h +$(DEFDIR)/cd.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h +$(DEFDIR)/cd.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h +$(DEFDIR)/cd.o: $(DEFSRC)/common.h quit.h pathnames.h +$(DEFDIR)/colon.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h +$(DEFDIR)/colon.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h +$(DEFDIR)/colon.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h +$(DEFDIR)/colon.o: pathnames.h +$(DEFDIR)/command.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h +$(DEFDIR)/command.o: quit.h $(DEFSRC)/bashgetopt.h +$(DEFDIR)/command.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h +$(DEFDIR)/command.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h pathnames.h +$(DEFDIR)/declare.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h +$(DEFDIR)/declare.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h +$(DEFDIR)/declare.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h +$(DEFDIR)/declare.o: $(DEFSRC)/bashgetopt.h pathnames.h flags.h +$(DEFDIR)/declare.o: ${DEFDIR}/builtext.h +$(DEFDIR)/echo.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h +$(DEFDIR)/echo.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h +$(DEFDIR)/echo.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h +$(DEFDIR)/echo.o: pathnames.h +$(DEFDIR)/echo.o: $(DEFSRC)/common.h +$(DEFDIR)/echo.o: $(BASHINCDIR)/unlocked-io.h +$(DEFDIR)/enable.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h +$(DEFDIR)/enable.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h +$(DEFDIR)/enable.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h +$(DEFDIR)/enable.o: pcomplete.h pathnames.h +$(DEFDIR)/eval.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h +$(DEFDIR)/eval.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h +$(DEFDIR)/eval.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h +$(DEFDIR)/eval.o: pathnames.h +$(DEFDIR)/exec.o: bashtypes.h pathnames.h +$(DEFDIR)/exec.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h +$(DEFDIR)/exec.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h +$(DEFDIR)/exec.o: dispose_cmd.h make_cmd.h subst.h externs.h execute_cmd.h +$(DEFDIR)/exec.o: findcmd.h flags.h quit.h $(DEFSRC)/common.h ${BASHINCDIR}/stdc.h +$(DEFDIR)/exit.o: bashtypes.h +$(DEFDIR)/exit.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h +$(DEFDIR)/exit.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h +$(DEFDIR)/exit.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h +$(DEFDIR)/exit.o: pathnames.h execute_cmd.h +$(DEFDIR)/exit.o: ${DEFDIR}/builtext.h +$(DEFDIR)/exit.o: $(BASHINCDIR)/unlocked-io.h +$(DEFDIR)/fc.o: bashtypes.h ${BASHINCDIR}/posixstat.h +$(DEFDIR)/fc.o: bashansi.h ${BASHINCDIR}/ansi_stdlib.h builtins.h command.h ${BASHINCDIR}/stdc.h +$(DEFDIR)/fc.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h +$(DEFDIR)/fc.o: flags.h unwind_prot.h variables.h arrayfunc.h conftypes.h shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h +$(DEFDIR)/fc.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h quit.h +$(DEFDIR)/fc.o: $(DEFSRC)/bashgetopt.h bashhist.h pathnames.h parser.h +$(DEFDIR)/fc.o: ${BASHINCDIR}/chartypes.h +$(DEFDIR)/fc.o: $(BASHINCDIR)/unlocked-io.h +$(DEFDIR)/fg_bg.o: bashtypes.h $(DEFSRC)/bashgetopt.h +$(DEFDIR)/fg_bg.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h +$(DEFDIR)/fg_bg.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h +$(DEFDIR)/fg_bg.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h +$(DEFDIR)/fg_bg.o: pathnames.h execute_cmd.h +$(DEFDIR)/getopts.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h +$(DEFDIR)/getopts.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h +$(DEFDIR)/getopts.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h +$(DEFDIR)/getopts.o: pathnames.h execute_cmd.h +$(DEFDIR)/hash.o: bashtypes.h execute_cmd.h +$(DEFDIR)/hash.o: builtins.h command.h findcmd.h ${BASHINCDIR}/stdc.h $(DEFSRC)/common.h +$(DEFDIR)/hash.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h +$(DEFDIR)/hash.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h +$(DEFDIR)/hash.o: pathnames.h +$(DEFDIR)/hash.o: $(BASHINCDIR)/unlocked-io.h +$(DEFDIR)/help.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h +$(DEFDIR)/help.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h +$(DEFDIR)/help.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h +$(DEFDIR)/help.o: conftypes.h quit.h execute_cmd.h +$(DEFDIR)/help.o: $(GLOB_LIBSRC)/glob.h pathnames.h +$(DEFDIR)/help.o: $(BASHINCDIR)/unlocked-io.h +$(DEFDIR)/history.o: bashtypes.h pathnames.h parser.h +$(DEFDIR)/history.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h +$(DEFDIR)/history.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h +$(DEFDIR)/history.o: ${BASHINCDIR}/filecntl.h shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h +$(DEFDIR)/history.o: bashhist.h variables.h arrayfunc.h conftypes.h +$(DEFDIR)/history.o: $(BASHINCDIR)/unlocked-io.h +$(DEFDIR)/inlib.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h +$(DEFDIR)/inlib.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h +$(DEFDIR)/inlib.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h +$(DEFDIR)/inlib.o: pathnames.h +$(DEFDIR)/jobs.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h +$(DEFDIR)/jobs.o: quit.h $(DEFSRC)/bashgetopt.h +$(DEFDIR)/jobs.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h +$(DEFDIR)/jobs.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h +$(DEFDIR)/jobs.o: pathnames.h +$(DEFDIR)/kill.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h +$(DEFDIR)/kill.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h +$(DEFDIR)/kill.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h trap.h unwind_prot.h variables.h arrayfunc.h conftypes.h +$(DEFDIR)/kill.o: pathnames.h +$(DEFDIR)/let.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h +$(DEFDIR)/let.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h +$(DEFDIR)/let.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h +$(DEFDIR)/let.o: pathnames.h +$(DEFDIR)/let.o: $(BASHINCDIR)/unlocked-io.h +$(DEFDIR)/printf.o: config.h ${BASHINCDIR}/memalloc.h bashjmp.h command.h error.h +$(DEFDIR)/printf.o: general.h xmalloc.h quit.h dispose_cmd.h make_cmd.h subst.h +$(DEFDIR)/printf.o: externs.h sig.h pathnames.h shell.h syntax.h unwind_prot.h +$(DEFDIR)/printf.o: variables.h arrayfunc.h conftypes.h ${BASHINCDIR}/stdc.h $(DEFSRC)/bashgetopt.h +$(DEFDIR)/printf.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h +$(DEFDIR)/printf.o: ${BASHINCDIR}/chartypes.h +$(DEFDIR)/printf.o: $(BASHINCDIR)/unlocked-io.h +$(DEFDIR)/printf.o: ${STDCKDINT_H} ${BASHINCDIR}/intprops-internal.h +$(DEFDIR)/pushd.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h +$(DEFDIR)/pushd.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h +$(DEFDIR)/pushd.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h +$(DEFDIR)/pushd.o: $(DEFSRC)/common.h pathnames.h +$(DEFDIR)/pushd.o: ${DEFDIR}/builtext.h +$(DEFDIR)/pushd.o: $(BASHINCDIR)/unlocked-io.h +$(DEFDIR)/read.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h +$(DEFDIR)/read.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h +$(DEFDIR)/read.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h +$(DEFDIR)/read.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h +$(DEFDIR)/read.o: pathnames.h +$(DEFDIR)/read.o: $(BASHINCDIR)/unlocked-io.h +$(DEFDIR)/return.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h +$(DEFDIR)/return.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h +$(DEFDIR)/return.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h +$(DEFDIR)/return.o: pathnames.h execute_cmd.h +$(DEFDIR)/set.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h +$(DEFDIR)/set.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h +$(DEFDIR)/set.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h flags.h +$(DEFDIR)/set.o: pathnames.h parser.h +$(DEFDIR)/setattr.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h +$(DEFDIR)/setattr.o: quit.h $(DEFSRC)/common.h $(DEFSRC)/bashgetopt.h +$(DEFDIR)/setattr.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h +$(DEFDIR)/setattr.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h +$(DEFDIR)/setattr.o: pathnames.h flags.h execute_cmd.h +$(DEFDIR)/shift.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h +$(DEFDIR)/shift.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h +$(DEFDIR)/shift.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h +$(DEFDIR)/shift.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h +$(DEFDIR)/shift.o: pathnames.h +$(DEFDIR)/shopt.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h +$(DEFDIR)/shopt.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h +$(DEFDIR)/shopt.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h unwind_prot.h variables.h arrayfunc.h conftypes.h ${BASHINCDIR}/maxpath.h +$(DEFDIR)/shopt.o: $(DEFSRC)/common.h $(DEFSRC)/bashgetopt.h pathnames.h +$(DEFDIR)/shopt.o: bashhist.h bashline.h +$(DEFDIR)/source.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h +$(DEFDIR)/source.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h +$(DEFDIR)/source.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h +$(DEFDIR)/source.o: findcmd.h $(DEFSRC)/bashgetopt.h flags.h trap.h +$(DEFDIR)/source.o: pathnames.h execute_cmd.h +$(DEFDIR)/suspend.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h +$(DEFDIR)/suspend.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h +$(DEFDIR)/suspend.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h +$(DEFDIR)/suspend.o: pathnames.h +$(DEFDIR)/test.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h +$(DEFDIR)/test.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h +$(DEFDIR)/test.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h +$(DEFDIR)/test.o: execute_cmd.h test.h pathnames.h +$(DEFDIR)/times.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h +$(DEFDIR)/times.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h +$(DEFDIR)/times.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h +$(DEFDIR)/times.o: pathnames.h +$(DEFDIR)/times.o: $(BASHINCDIR)/unlocked-io.h +$(DEFDIR)/trap.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h +$(DEFDIR)/trap.o: quit.h $(DEFSRC)/common.h +$(DEFDIR)/trap.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h +$(DEFDIR)/trap.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h +$(DEFDIR)/trap.o: pathnames.h +$(DEFDIR)/type.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h +$(DEFDIR)/type.o: quit.h $(DEFSRC)/common.h findcmd.h +$(DEFDIR)/type.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h +$(DEFDIR)/type.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h +$(DEFDIR)/type.o: pathnames.h execute_cmd.h parser.h +$(DEFDIR)/ulimit.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h +$(DEFDIR)/ulimit.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h +$(DEFDIR)/ulimit.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h +$(DEFDIR)/ulimit.o: pathnames.h +$(DEFDIR)/umask.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h +$(DEFDIR)/umask.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h +$(DEFDIR)/umask.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h +$(DEFDIR)/umask.o: ${BASHINCDIR}/chartypes.h pathnames.h +$(DEFDIR)/wait.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h +$(DEFDIR)/wait.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h +$(DEFDIR)/wait.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h +$(DEFDIR)/wait.o: execute_cmd.h +$(DEFDIR)/wait.o: ${BASHINCDIR}/chartypes.h pathnames.h + +$(DEFDIR)/complete.o: config.h shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h +$(DEFDIR)/complete.o: unwind_prot.h variables.h arrayfunc.h conftypes.h +$(DEFDIR)/complete.o: bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h +$(DEFDIR)/complete.o: builtins.h pathnames.h general.h +$(DEFDIR)/complete.o: bashtypes.h ${BASHINCDIR}/chartypes.h xmalloc.h +$(DEFDIR)/complete.o: pcomplete.h +$(DEFDIR)/complete.o: ${DEFSRC}/common.h ${DEFSRC}/bashgetopt.h +$(DEFDIR)/mapfile.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h +$(DEFDIR)/mapfile.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h +$(DEFDIR)/mapfile.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h +$(DEFDIR)/mapfile.o: pathnames.h # libintl dependencies -builtins/bind.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h -builtins/break.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h -builtins/caller.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h -builtins/cd.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h -builtins/common.c: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h -builtins/complete.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h -builtins/declare.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h -builtins/enable.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h -builtins/evalfile.c: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h -builtins/exec.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h -builtins/exit.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h -builtins/fc.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h -builtins/fg_bg.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h -builtins/getopt.c: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h -builtins/hash.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h -builtins/help.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h -builtins/history.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h -builtins/inlib.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h -builtins/jobs.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h -builtins/kill.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h -builtins/let.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h -builtins/mapfile.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h -builtins/mkbuiltins.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h -builtins/printf.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h -builtins/pushd.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h -builtins/read.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h -builtins/return.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h -builtins/set.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h -builtins/setattr.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h -builtins/shift.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h -builtins/shopt.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h -builtins/source.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h -builtins/suspend.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h -builtins/type.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h -builtins/ulimit.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h -builtins/umask.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +$(DEFDIR)/bind.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +$(DEFDIR)/break.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +$(DEFDIR)/caller.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +$(DEFDIR)/cd.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +$(DEFDIR)/common.c: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +$(DEFDIR)/complete.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +$(DEFDIR)/declare.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +$(DEFDIR)/enable.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +$(DEFDIR)/evalfile.c: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +$(DEFDIR)/exec.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +$(DEFDIR)/exit.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +$(DEFDIR)/fc.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +$(DEFDIR)/fg_bg.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +$(DEFDIR)/getopt.c: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +$(DEFDIR)/hash.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +$(DEFDIR)/help.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +$(DEFDIR)/history.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +$(DEFDIR)/inlib.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +$(DEFDIR)/jobs.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +$(DEFDIR)/kill.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +$(DEFDIR)/let.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +$(DEFDIR)/mapfile.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +$(DEFDIR)/mkbuiltins.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +$(DEFDIR)/printf.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +$(DEFDIR)/pushd.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +$(DEFDIR)/read.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +$(DEFDIR)/return.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +$(DEFDIR)/set.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +$(DEFDIR)/setattr.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +$(DEFDIR)/shift.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +$(DEFDIR)/shopt.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +$(DEFDIR)/source.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +$(DEFDIR)/suspend.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +$(DEFDIR)/type.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +$(DEFDIR)/ulimit.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +$(DEFDIR)/umask.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h # builtin library dependencies -builtins/bind.o: $(RL_LIBSRC)/chardefs.h $(RL_LIBSRC)/readline.h -builtins/bind.o: $(RL_LIBSRC)/keymaps.h $(RL_LIBSRC)/rlstdc.h - -builtins/bind.o: $(HIST_LIBSRC)/history.h $(RL_LIBSRC)/rlstdc.h -builtins/fc.o: $(HIST_LIBSRC)/history.h $(RL_LIBSRC)/rlstdc.h -builtins/history.o: $(HIST_LIBSRC)/history.h $(RL_LIBSRC)/rlstdc.h - -builtins/common.o: $(TILDE_LIBSRC)/tilde.h -builtins/cd.o: $(TILDE_LIBSRC)/tilde.h - -builtins/alias.o: $(DEFSRC)/alias.def -builtins/bind.o: $(DEFSRC)/bind.def -builtins/break.o: $(DEFSRC)/break.def -builtins/builtin.o: $(DEFSRC)/builtin.def -builtins/caller.o: $(DEFSRC)/caller.def -builtins/cd.o: $(DEFSRC)/cd.def -builtins/colon.o: $(DEFSRC)/colon.def -builtins/command.o: $(DEFSRC)/command.def -builtins/complete.o: $(DEFSRC)/complete.def -builtins/declare.o: $(DEFSRC)/declare.def -builtins/echo.o: $(DEFSRC)/echo.def -builtins/enable.o: $(DEFSRC)/enable.def -builtins/eval.o: $(DEFSRC)/eval.def -builtins/exec.o: $(DEFSRC)/exec.def -builtins/exit.o: $(DEFSRC)/exit.def -builtins/fc.o: $(DEFSRC)/fc.def -builtins/fg_bg.o: $(DEFSRC)/fg_bg.def -builtins/getopts.o: $(DEFSRC)/getopts.def -builtins/hash.o: $(DEFSRC)/hash.def -builtins/help.o: $(DEFSRC)/help.def -builtins/history.o: $(DEFSRC)/history.def -builtins/inlib.o: $(DEFSRC)/inlib.def -builtins/jobs.o: $(DEFSRC)/jobs.def -builtins/kill.o: $(DEFSRC)/kill.def -builtins/let.o: $(DEFSRC)/let.def -builtins/mapfile.o: $(DEFSRC)/mapfile.def -builtins/pushd.o: $(DEFSRC)/pushd.def -builtins/read.o: $(DEFSRC)/read.def -builtins/reserved.o: $(DEFSRC)/reserved.def -builtins/return.o: $(DEFSRC)/return.def -builtins/set.o: $(DEFSRC)/set.def -builtins/setattr.o: $(DEFSRC)/setattr.def -builtins/shift.o: $(DEFSRC)/shift.def -builtins/shopt.o: $(DEFSRC)/shopt.def -builtins/source.o: $(DEFSRC)/source.def -builtins/suspend.o: $(DEFSRC)/suspend.def -builtins/test.o: $(DEFSRC)/test.def -builtins/times.o: $(DEFSRC)/times.def -builtins/trap.o: $(DEFSRC)/trap.def -builtins/type.o: $(DEFSRC)/type.def -builtins/ulimit.o: $(DEFSRC)/ulimit.def -builtins/umask.o: $(DEFSRC)/umask.def -builtins/wait.o: $(DEFSRC)/wait.def +$(DEFDIR)/bind.o: $(RL_LIBSRC)/chardefs.h $(RL_LIBSRC)/readline.h +$(DEFDIR)/bind.o: $(RL_LIBSRC)/keymaps.h $(RL_LIBSRC)/rlstdc.h + +$(DEFDIR)/common.o: $(HIST_LIBSRC)/history.h $(RL_LIBSRC)/rlstdc.h +$(DEFDIR)/evalfile.o: $(HIST_LIBSRC)/history.h $(RL_LIBSRC)/rlstdc.h +$(DEFDIR)/evalstring.o: $(HIST_LIBSRC)/history.h $(RL_LIBSRC)/rlstdc.h +$(DEFDIR)/bind.o: $(HIST_LIBSRC)/history.h $(RL_LIBSRC)/rlstdc.h +$(DEFDIR)/fc.o: $(HIST_LIBSRC)/history.h $(RL_LIBSRC)/rlstdc.h +$(DEFDIR)/history.o: $(HIST_LIBSRC)/history.h $(RL_LIBSRC)/rlstdc.h +$(DEFDIR)/shopt.o: $(HIST_LIBSRC)/history.h $(RL_LIBSRC)/rlstdc.h + +$(DEFDIR)/common.o: $(TILDE_LIBSRC)/tilde.h +$(DEFDIR)/cd.o: $(TILDE_LIBSRC)/tilde.h + +$(DEFDIR)/alias.o: $(DEFSRC)/alias.def +$(DEFDIR)/bind.o: $(DEFSRC)/bind.def +$(DEFDIR)/break.o: $(DEFSRC)/break.def +$(DEFDIR)/builtin.o: $(DEFSRC)/builtin.def +$(DEFDIR)/caller.o: $(DEFSRC)/caller.def +$(DEFDIR)/cd.o: $(DEFSRC)/cd.def +$(DEFDIR)/colon.o: $(DEFSRC)/colon.def +$(DEFDIR)/command.o: $(DEFSRC)/command.def +$(DEFDIR)/complete.o: $(DEFSRC)/complete.def +$(DEFDIR)/declare.o: $(DEFSRC)/declare.def +$(DEFDIR)/echo.o: $(DEFSRC)/echo.def +$(DEFDIR)/enable.o: $(DEFSRC)/enable.def +$(DEFDIR)/eval.o: $(DEFSRC)/eval.def +$(DEFDIR)/exec.o: $(DEFSRC)/exec.def +$(DEFDIR)/exit.o: $(DEFSRC)/exit.def +$(DEFDIR)/fc.o: $(DEFSRC)/fc.def +$(DEFDIR)/fg_bg.o: $(DEFSRC)/fg_bg.def +$(DEFDIR)/getopts.o: $(DEFSRC)/getopts.def +$(DEFDIR)/hash.o: $(DEFSRC)/hash.def +$(DEFDIR)/help.o: $(DEFSRC)/help.def +$(DEFDIR)/history.o: $(DEFSRC)/history.def +$(DEFDIR)/inlib.o: $(DEFSRC)/inlib.def +$(DEFDIR)/jobs.o: $(DEFSRC)/jobs.def +$(DEFDIR)/kill.o: $(DEFSRC)/kill.def +$(DEFDIR)/let.o: $(DEFSRC)/let.def +$(DEFDIR)/mapfile.o: $(DEFSRC)/mapfile.def +$(DEFDIR)/pushd.o: $(DEFSRC)/pushd.def +$(DEFDIR)/read.o: $(DEFSRC)/read.def +$(DEFDIR)/reserved.o: $(DEFSRC)/reserved.def +$(DEFDIR)/return.o: $(DEFSRC)/return.def +$(DEFDIR)/set.o: $(DEFSRC)/set.def +$(DEFDIR)/setattr.o: $(DEFSRC)/setattr.def +$(DEFDIR)/shift.o: $(DEFSRC)/shift.def +$(DEFDIR)/shopt.o: $(DEFSRC)/shopt.def +$(DEFDIR)/source.o: $(DEFSRC)/source.def +$(DEFDIR)/suspend.o: $(DEFSRC)/suspend.def +$(DEFDIR)/test.o: $(DEFSRC)/test.def +$(DEFDIR)/times.o: $(DEFSRC)/times.def +$(DEFDIR)/trap.o: $(DEFSRC)/trap.def +$(DEFDIR)/type.o: $(DEFSRC)/type.def +$(DEFDIR)/ulimit.o: $(DEFSRC)/ulimit.def +$(DEFDIR)/umask.o: $(DEFSRC)/umask.def +$(DEFDIR)/wait.o: $(DEFSRC)/wait.def diff --git a/NEWS b/NEWS index 62d22127f..e2f9cc7b7 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,205 @@ +This is a terse description of the new features added to bash-5.3 since +the release of bash-5.2. As always, the manual page (doc/bash.1) is +the place to look for complete descriptions. + +1. New Features in Bash + +a. When checking whether a script file argument is a binary file, check the + first two lines of a script if the first line begins with `#!'. + +b. Bash does a better job of preserving user-supplied quotes around a word + completion, instead of requoting it. + +c. Bash reports the starting line number in an error message about an + unterminated compound command like `if' without a `fi'. + +d. Implement the POSIX requirement that running the `jobs' builtin removes + jobs from the jobs list. + +f. Call bash signal handlers while executing programmable completion commands, + instead of readline's. + +g. Print an error message if a regular expression used with [[ fails to compile. + +h. The `umask' builtin now has additional features for full POSIX conformance. + +i. `type -a -P' reports both hashed pathnames and the result of a $PATH search. + +j. `trap' has a new -P option that prints the trap action associated with each + signal argument. + +k. The `command' builtin preceding a declaration builtin (e.g., `declare') + preserves the special asisgnment statement parsing for the declaration + builtin. This is a new POSIX requirement. + +l. `printf' uses the `alternate form' for %q and %Q to force single quoting. + +m. `printf' now interprets %ls (%S) and %lc (%C) as referring to wide strings + and characters, respectively, when in a multibyte locale. + +n. The shell can be compiled with a different default value for the + patsub_replacement option. + +o. Check for window size changes during trap commands, `bind -x' commands, + and programmable completion. + +p. Treat a NULL value for $PATH as equivalent to ".". + +p. New loadable builtins: kv, strptime + +q. GLOBSORT: new variable to specify how to sort the results of pathname + expansion (name, size, blocks, mtime, atime, ctime, numeric, none) in + ascending or descending order. + +r. `compgen' has a new option: -V varname. If supplied, it stores the generated + completions into VARNAME instead of printing them on stdout. + +s. New form of command substitution: ${ command; } or ${|command;} to capture + the output of COMMAND without forking a child process and using pipes. + +t. array_expand_once: new shopt option, replaces assoc_expand_once + +u. complete/compopt new option: fullquote; sets rl_full_quoting_desired so all + possible completions are quoted as if they were filenames. + +v. Command timing now allows precisions up to 6 digits instead of 3 in + $TIMEFORMAT. + +w. BASH_MONOSECONDS: new dynamic variable that returns the value of the + system's monotonic clock, if one is available. + +x. BASH_TRAPSIG: new variable, set to the numeric signal number of the trap + being executed while it's running. + +y. The checkwinsize option can be used in subshell commands started from + interactive shells. + +z. In posix mode, the test command < and > binary primaries compare strings + using the current locale. + +aa. bind -x allows new key binding syntax: separate the key sequence and the + command string with whitespace, but require the command string to be + double-quoted if this is used. This allows different quoting options for + the command string. + +bb. Print commands bound to key sequences using `bind -x' with the new key + binding syntax it allows. + +cc. `read' has a new `-E' option to use readline but with the default bash + completion (including programmable completion). + +dd. New bindable readline command name: `bash-vi-complete'. + +ee. New test builtin behavior when parsing a parenthesized subexpression and + test was given more than 4 arguments: scan forward for a closing paren and + call posixtest() if there are 4 or fewer arguments between the parentheses. + Added for compatibility with coreutils test, dependent on the shell + compatibility level. Such expressions remain ambiguous. + +ff. MULTIPLE_COPROCS is now enabled by default. + +gg. The `bind' builtin interprets additional non-option arguments after -p or + -P as bindable command names and restricts output to the bindings for + those names. + +hh. Bash now uses the login shell for $BASH if the shell is named `su' or `-su'. + +ii. Bash now prints job notifications if an interactive shell is running a trap, + even though the shell is not interactive at that moment. + +jj. Programmable completion allows a new compspec loaded after a completion + function returns 124 to be used in more cases. + +kk. ./source has a new -p PATH option, which makes it use the PATH argument + instead of $PATH to look for the file. + +ll. Documentation has been significantly updated. + +mm. `wait -n' can now return terminated process substitutions, jobs about + which the user has already been notified (like `wait' without options), + +nn. `wait -n' removes jobs from the jobs table or list of terminated children + when in posix mode. + +oo. Changed the `wait' builtin behavior regarding process substitutions to + match the documentation. + +pp. There is a new `bash_source_fullpath' shopt option, which makes bash put + full pathnames into BASH_SOURCE, and a way to set a default value for it + at configure time. + +qq. Posix mode now forces job notifications to occur when the new edition of + POSIX specifies (since it now specifies them). + +rr. Interactive shells don't print job notifications while sourcing scripts. + +ss. The parser prints more information about the command it's trying to parse + when it encounters EOF before completing the command. + +tt. Posix mode no longer requires function names to be valid shell identifiers. + +uu. If `exit' is run in a trap and not supplied an exit status argument, it + uses the value of $? from before the trap only if it's run at the trap's + `top level' and would cause the trap to end (that is, not in a subshell). + This is from Posix interp 1602. + +vv. There is a new `fltexpr' loadable builtin to perform floating-point + arithmetic similarly to `let'. + +ww. The `install-strip' and `strip' Makefile targets now deal with cross- + compiling. + +2. New Features in Readline + +a. Output a newline if there is no prompt and readline reads an empty line. + +b. The history library falls back to stdio when writing the history list if + mmap fails. + +c. New bindable variable `search-ignore-case', causes readline to perform + case-insensitive incremental and non-incremental history searches. + +d. rl_full_quoting_desired: new application-settable variable, causes all + completions to be quoted as if they were filenames. + +e. rl_macro_display_hook: new application-settable function pointer, used if + the application wants to print macro values itself instead of letting + readline do it + +f. rl_reparse_colors: new application-callable function, reparses $LS_COLORS + (presumably after the user changes it) + +g. rl_completion_rewrite_hook: new application-settable function pointer, + called to modify the word being completed before comparing it against + pathnames from the file system. + +h. execute-named-command: a new bindable command that reads the name of a + readline command from the standard input and executes it. Bound to M-x + in emacs mode by default. + +i. Incremental and non-incremental searches now allow ^V/^Q (or, in the former + case, anything bound to quoted-insert) to quote characters in the search + string. + +j. There is a new rl_print_keybinding function that prints the key bindings + for a single bindable function specified by name. + +k. Documentation has been significantly updated. + +l. New `force-meta-prefix' bindable variable, which forces the use of ESC as + the meta prefix when using "\M-" in key bindings instead of overloading + convert-meta. + +m. The default value for `readline-colored-completion-prefix' no longer has a + leading `.'; the original report was based on a misunderstanding. + +n. There is a new bindable command, `export-completions', which writes the + possible completions for a word to the standard output in a defined format. + +o. Readline can reset its idea of the screen dimensions when executing after + a SIGCONT. + +------------------------------------------------------------------------------- This is a terse description of the new features added to bash-5.2 since the release of bash-5.1. As always, the manual page (doc/bash.1) is the place to look for complete descriptions. diff --git a/POSIX b/POSIX index 4e78dbb75..a34084cfb 100644 --- a/POSIX +++ b/POSIX @@ -1,112 +1,204 @@ -6.11 Bash POSIX Mode -==================== - -Starting Bash with the '--posix' command-line option or executing 'set --o posix' while Bash is running will cause Bash to conform more closely +6.11 Bash and POSIX +=================== + +6.11.1 What is POSIX? +--------------------- + +POSIX is the name for a family of standards based on Unix. A number of +Unix services, tools, and functions are part of the standard, ranging +from the basic system calls and C library functions to common +applications and tools to system administration and management. + +The POSIX Shell and Utilities standard was originally developed by IEEE +Working Group 1003.2 (POSIX.2). The first edition of the 1003.2 +standard was published in 1992. It was merged with the original IEEE +1003.1 Working Group and is currently maintained by the Austin Group (a +joint working group of the IEEE, The Open Group and ISO/IEC SC22/WG15). +Today the Shell and Utilities are a volume within the set of documents +that make up IEEE Std 1003.1-2024, and thus the former POSIX.2 (from +1992) is now part of the current unified POSIX standard. + +The Shell and Utilities volume concentrates on the command interpreter +interface and utility programs commonly executed from the command line +or by other programs. The standard is freely available on the web at +. + +Bash is concerned with the aspects of the shell's behavior defined by +the POSIX Shell and Utilities volume. The shell command language has of +course been standardized, including the basic flow control and program +execution constructs, I/O redirection and pipelines, argument handling, +variable expansion, and quoting. + +The special builtins, which must be implemented as part of the shell to +provide the desired functionality, are specified as being part of the +shell; examples of these are ‘eval’ and ‘export’. Other utilities +appear in the sections of POSIX not devoted to the shell which are +commonly (and in some cases must be) implemented as builtin commands, +such as ‘read’ and ‘test’. POSIX also specifies aspects of the shell's +interactive behavior, including job control and command line editing. +Only vi-style line editing commands have been standardized; emacs +editing commands were left out due to objections. + +6.11.2 Bash POSIX Mode +---------------------- + +Although Bash is an implementation of the POSIX shell specification, +there are areas where the Bash default behavior differs from the +specification. The Bash “posix mode” changes the Bash behavior in these +areas so that it conforms more strictly to the standard. + +Starting Bash with the ‘--posix’ command-line option or executing ‘set +-o posix’ while Bash is running will cause Bash to conform more closely to the POSIX standard by changing the behavior to match that specified by POSIX in areas where the Bash default differs. -When invoked as 'sh', Bash enters POSIX mode after reading the startup +When invoked as ‘sh’, Bash enters POSIX mode after reading the startup files. -The following list is what's changed when 'POSIX mode' is in effect: +The following list is what's changed when POSIX mode is in effect: - 1. Bash ensures that the 'POSIXLY_CORRECT' variable is set. + 1. Bash ensures that the ‘POSIXLY_CORRECT’ variable is set. - 2. When a command in the hash table no longer exists, Bash will - re-search '$PATH' to find the new location. This is also available - with 'shopt -s checkhash'. + 2. Bash reads and executes the POSIX startup files (‘$ENV’) rather + than the normal Bash files (*note Bash Startup Files::. - 3. Bash will not insert a command without the execute bit set into the - command hash table, even if it returns it as a (last-ditch) result - from a '$PATH' search. + 3. Alias expansion is always enabled, even in non-interactive shells. - 4. The message printed by the job control code and builtins when a job - exits with a non-zero status is 'Done(status)'. + 4. Reserved words appearing in a context where reserved words are + recognized do not undergo alias expansion. - 5. The message printed by the job control code and builtins when a job - is stopped is 'Stopped(SIGNAME)', where SIGNAME is, for example, - 'SIGTSTP'. + 5. Alias expansion is performed when initially parsing a command + substitution. The default (non-posix) mode generally defers it, + when enabled, until the command substitution is executed. This + means that command substitution will not expand aliases that are + defined after the command substitution is initially parsed (e.g., + as part of a function definition). - 6. Alias expansion is always enabled, even in non-interactive shells. + 6. The ‘time’ reserved word may be used by itself as a simple command. + When used in this way, it displays timing statistics for the shell + and its completed children. The ‘TIMEFORMAT’ variable controls the + format of the timing information. - 7. Reserved words appearing in a context where reserved words are - recognized do not undergo alias expansion. + 7. The parser does not recognize ‘time’ as a reserved word if the next + token begins with a ‘-’. - 8. Alias expansion is performed when initially parsing a command - substitution. The default mode generally defers it, when enabled, - until the command substitution is executed. This means that - command substitution will not expand aliases that are defined after - the command substitution is initially parsed (e.g., as part of a - function definition). + 8. When parsing and expanding a ${...} expansion that appears within + double quotes, single quotes are no longer special and cannot be + used to quote a closing brace or other special character, unless + the operator is one of those defined to perform pattern removal. + In this case, they do not have to appear as matched pairs. - 9. The POSIX 'PS1' and 'PS2' expansions of '!' to the history number - and '!!' to '!' are enabled, and parameter expansion is performed - on the values of 'PS1' and 'PS2' regardless of the setting of the - 'promptvars' option. + 9. Redirection operators do not perform filename expansion on the word + in a redirection unless the shell is interactive. - 10. The POSIX startup files are executed ('$ENV') rather than the - normal Bash files. + 10. Redirection operators do not perform word splitting on the word in + a redirection. - 11. Tilde expansion is only performed on assignments preceding a - command name, rather than on all assignment statements on the line. + 11. Function names may not be the same as one of the POSIX special + builtins. - 12. The default history file is '~/.sh_history' (this is the default - value of '$HISTFILE'). + 12. Tilde expansion is only performed on assignments preceding a + command name, rather than on all assignment statements on the line. - 13. Redirection operators do not perform filename expansion on the - word in the redirection unless the shell is interactive. + 13. While variable indirection is available, it may not be applied to + the ‘#’ and ‘?’ special parameters. - 14. Redirection operators do not perform word splitting on the word in - the redirection. + 14. Expanding the ‘*’ special parameter in a pattern context where the + expansion is double-quoted does not treat the ‘$*’ as if it were + double-quoted. - 15. Function names must be valid shell 'name's. That is, they may not - contain characters other than letters, digits, and underscores, and - may not start with a digit. Declaring a function with an invalid - name causes a fatal syntax error in non-interactive shells. + 15. A double quote character (‘"’) is treated specially when it + appears in a backquoted command substitution in the body of a + here-document that undergoes expansion. That means, for example, + that a backslash preceding a double quote character will escape it + and the backslash will be removed. + + 16. Command substitutions don't set the ‘?’ special parameter. The + exit status of a simple command without a command word is still the + exit status of the last command substitution that occurred while + evaluating the variable assignments and redirections in that + command, but that does not happen until after all of the + assignments and redirections. + + 17. Literal tildes that appear as the first character in elements of + the ‘PATH’ variable are not expanded as described above under *note + Tilde Expansion::. - 16. Function names may not be the same as one of the POSIX special + 18. Command lookup finds POSIX special builtins before shell + functions, including output printed by the ‘type’ and ‘command’ builtins. - 17. POSIX special builtins are found before shell functions during - command lookup. + 19. Even if a shell function whose name contains a slash was defined + before entering POSIX mode, the shell will not execute a function + whose name contains one or more slashes. - 18. When printing shell function definitions (e.g., by 'type'), Bash - does not print the 'function' keyword. + 20. When a command in the hash table no longer exists, Bash will + re-search ‘$PATH’ to find the new location. This is also available + with ‘shopt -s checkhash’. - 19. Literal tildes that appear as the first character in elements of - the 'PATH' variable are not expanded as described above under *note - Tilde Expansion::. + 21. Bash will not insert a command without the execute bit set into + the command hash table, even if it returns it as a (last-ditch) + result from a ‘$PATH’ search. - 20. The 'time' reserved word may be used by itself as a command. When - used in this way, it displays timing statistics for the shell and - its completed children. The 'TIMEFORMAT' variable controls the - format of the timing information. + 22. The message printed by the job control code and builtins when a + job exits with a non-zero status is 'Done(status)'. - 21. When parsing and expanding a ${...} expansion that appears within - double quotes, single quotes are no longer special and cannot be - used to quote a closing brace or other special character, unless - the operator is one of those defined to perform pattern removal. - In this case, they do not have to appear as matched pairs. + 23. The message printed by the job control code and builtins when a + job is stopped is 'Stopped(SIGNAME)', where SIGNAME is, for + example, ‘SIGTSTP’. + + 24. If the shell is interactive, Bash does not perform job + notifications between executing commands in lists separated by ‘;’ + or newline. Non-interactive shells print status messages after a + foreground job in a list completes. + + 25. If the shell is interactive, Bash waits until the next prompt + before printing the status of a background job that changes status + or a foreground job that terminates due to a signal. + Non-interactive shells print status messages after a foreground job + completes. + + 26. Bash permanently removes jobs from the jobs table after notifying + the user of their termination via the ‘wait’ or ‘jobs’ builtins. + It removes the job from the jobs list after notifying the user of + its termination, but the status is still available via ‘wait’, as + long as ‘wait’ is supplied a PID argument. + + 27. The ‘vi’ editing mode will invoke the ‘vi’ editor directly when + the ‘v’ command is run, instead of checking ‘$VISUAL’ and + ‘$EDITOR’. - 22. The parser does not recognize 'time' as a reserved word if the - next token begins with a '-'. + 28. Prompt expansion enables the POSIX ‘PS1’ and ‘PS2’ expansions of + ‘!’ to the history number and ‘!!’ to ‘!’, and Bash performs + parameter expansion on the values of ‘PS1’ and ‘PS2’ regardless of + the setting of the ‘promptvars’ option. - 23. The '!' character does not introduce history expansion within a - double-quoted string, even if the 'histexpand' option is enabled. + 29. The default history file is ‘~/.sh_history’ (this is the default + value the shell assigns to ‘$HISTFILE’). + + 30. The ‘!’ character does not introduce history expansion within a + double-quoted string, even if the ‘histexpand’ option is enabled. + + 31. When printing shell function definitions (e.g., by ‘type’), Bash + does not print the ‘function’ reserved word unless necessary. + + 32. Non-interactive shells exit if a syntax error in an arithmetic + expansion results in an invalid expression. - 24. If a POSIX special builtin returns an error status, a + 33. Non-interactive shells exit if a parameter expansion error occurs. + + 34. If a POSIX special builtin returns an error status, a non-interactive shell exits. The fatal errors are those listed in the POSIX standard, and include things like passing incorrect options, redirection errors, variable assignment errors for assignments preceding the command name, and so on. - 25. A non-interactive shell exits with an error status if a variable + 35. A non-interactive shell exits with an error status if a variable assignment error occurs when no command name follows the assignment statements. A variable assignment error occurs, for example, when trying to assign a value to a readonly variable. - 26. A non-interactive shell exits with an error status if a variable + 36. A non-interactive shell exits with an error status if a variable assignment error occurs in an assignment statement preceding a special builtin, but not with any other simple command. For any other simple command, the shell aborts execution of that command, @@ -114,151 +206,182 @@ The following list is what's changed when 'POSIX mode' is in effect: perform any further processing of the command in which the error occurred"). - 27. A non-interactive shell exits with an error status if the - iteration variable in a 'for' statement or the selection variable - in a 'select' statement is a readonly variable. + 37. A non-interactive shell exits with an error status if the + iteration variable in a ‘for’ statement or the selection variable + in a ‘select’ statement is a readonly variable or has an invalid + name. - 28. Non-interactive shells exit if FILENAME in '.' FILENAME is not + 38. Non-interactive shells exit if FILENAME in ‘.’ FILENAME is not found. - 29. Non-interactive shells exit if a syntax error in an arithmetic - expansion results in an invalid expression. - - 30. Non-interactive shells exit if a parameter expansion error occurs. - - 31. Non-interactive shells exit if there is a syntax error in a script - read with the '.' or 'source' builtins, or in a string processed by - the 'eval' builtin. + 39. Non-interactive shells exit if there is a syntax error in a script + read with the ‘.’ or ‘source’ builtins, or in a string processed by + the ‘eval’ builtin. - 32. While variable indirection is available, it may not be applied to - the '#' and '?' special parameters. + 40. Non-interactive shells exit if the ‘export’, ‘readonly’ or ‘unset’ + builtin commands get an argument that is not a valid identifier, + and they are not operating on shell functions. These errors force + an exit because these are special builtins. - 33. Expanding the '*' special parameter in a pattern context where the - expansion is double-quoted does not treat the '$*' as if it were - double-quoted. - - 34. Assignment statements preceding POSIX special builtins persist in + 41. Assignment statements preceding POSIX special builtins persist in the shell environment after the builtin completes. - 35. The 'command' builtin does not prevent builtins that take + 42. The ‘command’ builtin does not prevent builtins that take assignment statements as arguments from expanding them as - assignment statements; when not in POSIX mode, assignment builtins + assignment statements; when not in POSIX mode, declaration commands lose their assignment statement expansion properties when preceded - by 'command'. + by ‘command’. - 36. The 'bg' builtin uses the required format to describe each job + 43. Enabling POSIX mode has the effect of setting the + ‘inherit_errexit’ option, so subshells spawned to execute command + substitutions inherit the value of the ‘-e’ option from the parent + shell. When the ‘inherit_errexit’ option is not enabled, Bash + clears the ‘-e’ option in such subshells. + + 44. Enabling POSIX mode has the effect of setting the ‘shift_verbose’ + option, so numeric arguments to ‘shift’ that exceed the number of + positional parameters will result in an error message. + + 45. Enabling POSIX mode has the effect of setting the + ‘interactive_comments’ option (*note Comments::). + + 46. The ‘.’ and ‘source’ builtins do not search the current directory + for the filename argument if it is not found by searching ‘PATH’. + + 47. When the ‘alias’ builtin displays alias definitions, it does not + display them with a leading ‘alias ’ unless the ‘-p’ option is + supplied. + + 48. The ‘bg’ builtin uses the required format to describe each job placed in the background, which does not include an indication of whether the job is the current or previous job. - 37. The output of 'kill -l' prints all the signal names on a single - line, separated by spaces, without the 'SIG' prefix. + 49. When the ‘cd’ builtin is invoked in logical mode, and the pathname + constructed from ‘$PWD’ and the directory name supplied as an + argument does not refer to an existing directory, ‘cd’ will fail + instead of falling back to physical mode. - 38. The 'kill' builtin does not accept signal names with a 'SIG' - prefix. + 50. When the ‘cd’ builtin cannot change a directory because the length + of the pathname constructed from ‘$PWD’ and the directory name + supplied as an argument exceeds ‘PATH_MAX’ when canonicalized, ‘cd’ + will attempt to use the supplied directory name. - 39. The 'export' and 'readonly' builtin commands display their output + 51. When the ‘xpg_echo’ option is enabled, Bash does not attempt to + interpret any arguments to ‘echo’ as options. ‘echo’ displays each + argument after converting escape sequences. + + 52. The ‘export’ and ‘readonly’ builtin commands display their output in the format required by POSIX. - 40. The 'trap' builtin displays signal names without the leading - 'SIG'. + 53. When listing the history, the ‘fc’ builtin does not include an + indication of whether or not a history entry has been modified. - 41. The 'trap' builtin doesn't check the first argument for a possible - signal specification and revert the signal handling to the original - disposition if it is, unless that argument consists solely of - digits and is a valid signal number. If users want to reset the - handler for a given signal to the original disposition, they should - use '-' as the first argument. + 54. The default editor used by ‘fc’ is ‘ed’. - 42. 'trap -p' displays signals whose dispositions are set to SIG_DFL - and those that were ignored when the shell started. + 55. ‘fc’ treats extra arguments as an error instead of ignoring them. - 43. The '.' and 'source' builtins do not search the current directory - for the filename argument if it is not found by searching 'PATH'. + 56. If there are too many arguments supplied to ‘fc -s’, ‘fc’ prints + an error message and returns failure. - 44. Enabling POSIX mode has the effect of setting the - 'inherit_errexit' option, so subshells spawned to execute command - substitutions inherit the value of the '-e' option from the parent - shell. When the 'inherit_errexit' option is not enabled, Bash - clears the '-e' option in such subshells. + 57. The output of ‘kill -l’ prints all the signal names on a single + line, separated by spaces, without the ‘SIG’ prefix. - 45. Enabling POSIX mode has the effect of setting the 'shift_verbose' - option, so numeric arguments to 'shift' that exceed the number of - positional parameters will result in an error message. + 58. The ‘kill’ builtin does not accept signal names with a ‘SIG’ + prefix. - 46. When the 'alias' builtin displays alias definitions, it does not - display them with a leading 'alias ' unless the '-p' option is - supplied. + 59. The ‘kill’ builtin returns a failure status if any of the pid or + job arguments are invalid or if sending the specified signal to any + of them fails. In default mode, ‘kill’ returns success if the + signal was successfully sent to any of the specified processes. + + 60. The ‘printf’ builtin uses ‘double’ (via ‘strtod’) to convert + arguments corresponding to floating point conversion specifiers, + instead of ‘long double’ if it's available. The ‘L’ length + modifier forces ‘printf’ to use ‘long double’ if it's available. + + 61. The ‘pwd’ builtin verifies that the value it prints is the same as + the current directory, even if it is not asked to check the file + system with the ‘-P’ option. - 47. When the 'set' builtin is invoked without options, it does not + 62. The ‘read’ builtin may be interrupted by a signal for which a trap + has been set. If Bash receives a trapped signal while executing + ‘read’, the trap handler executes and ‘read’ returns an exit status + greater than 128. + + 63. When the ‘set’ builtin is invoked without options, it does not display shell function names and definitions. - 48. When the 'set' builtin is invoked without options, it displays + 64. When the ‘set’ builtin is invoked without options, it displays variable values without quotes, unless they contain shell metacharacters, even if the result contains nonprinting characters. - 49. When the 'cd' builtin is invoked in logical mode, and the pathname - constructed from '$PWD' and the directory name supplied as an - argument does not refer to an existing directory, 'cd' will fail - instead of falling back to physical mode. + 65. The ‘test’ builtin compares strings using the current locale when + evaluating the ‘<’ and ‘>’ binary operators. - 50. When the 'cd' builtin cannot change a directory because the length - of the pathname constructed from '$PWD' and the directory name - supplied as an argument exceeds 'PATH_MAX' when all symbolic links - are expanded, 'cd' will fail instead of attempting to use only the - supplied directory name. + 66. The ‘test’ builtin's ‘-t’ unary primary requires an argument. + Historical versions of ‘test’ made the argument optional in certain + cases, and Bash attempts to accommodate those for backwards + compatibility. - 51. The 'pwd' builtin verifies that the value it prints is the same as - the current directory, even if it is not asked to check the file - system with the '-P' option. + 67. The ‘trap’ builtin displays signal names without the leading + ‘SIG’. - 52. When listing the history, the 'fc' builtin does not include an - indication of whether or not a history entry has been modified. + 68. The ‘trap’ builtin doesn't check the first argument for a possible + signal specification and revert the signal handling to the original + disposition if it is, unless that argument consists solely of + digits and is a valid signal number. If users want to reset the + handler for a given signal to the original disposition, they should + use ‘-’ as the first argument. - 53. The default editor used by 'fc' is 'ed'. + 69. ‘trap -p’ without arguments displays signals whose dispositions + are set to SIG_DFL and those that were ignored when the shell + started, not just trapped signals. - 54. The 'type' and 'command' builtins will not report a non-executable + 70. The ‘type’ and ‘command’ builtins will not report a non-executable file as having been found, though the shell will attempt to execute - such a file if it is the only so-named file found in '$PATH'. + such a file if it is the only so-named file found in ‘$PATH’. - 55. The 'vi' editing mode will invoke the 'vi' editor directly when - the 'v' command is run, instead of checking '$VISUAL' and - '$EDITOR'. + 71. The ‘ulimit’ builtin uses a block size of 512 bytes for the ‘-c’ + and ‘-f’ options. - 56. When the 'xpg_echo' option is enabled, Bash does not attempt to - interpret any arguments to 'echo' as options. Each argument is - displayed, after escape characters are converted. + 72. The ‘unset’ builtin with the ‘-v’ option specified returns a fatal + error if it attempts to unset a ‘readonly’ or ‘non-unsettable’ + variable, which causes a non-interactive shell to exit. - 57. The 'ulimit' builtin uses a block size of 512 bytes for the '-c' - and '-f' options. + 73. When asked to unset a variable that appears in an assignment + statement preceding the command, the ‘unset’ builtin attempts to + unset a variable of the same name in the current or previous scope + as well. This implements the required "if an assigned variable is + further modified by the utility, the modifications made by the + utility shall persist" behavior. - 58. The arrival of 'SIGCHLD' when a trap is set on 'SIGCHLD' does not - interrupt the 'wait' builtin and cause it to return immediately. + 74. The arrival of ‘SIGCHLD’ when a trap is set on ‘SIGCHLD’ does not + interrupt the ‘wait’ builtin and cause it to return immediately. The trap command is run once for each child that exits. - 59. The 'read' builtin may be interrupted by a signal for which a trap - has been set. If Bash receives a trapped signal while executing - 'read', the trap handler executes and 'read' returns an exit status - greater than 128. - - 60. The 'printf' builtin uses 'double' (via 'strtod') to convert - arguments corresponding to floating point conversion specifiers, - instead of 'long double' if it's available. The 'L' length - modifier forces 'printf' to use 'long double' if it's available. + 75. Bash removes an exited background process's status from the list + of such statuses after the ‘wait’ builtin returns it. - 61. Bash removes an exited background process's status from the list - of such statuses after the 'wait' builtin is used to obtain it. +There is additional POSIX behavior that Bash does not implement by +default even when in POSIX mode. Specifically: -There is other POSIX behavior that Bash does not implement by default -even when in POSIX mode. Specifically: + 1. POSIX requires that word splitting be byte-oriented. That is, each + _byte_ in the value of ‘IFS’ potentially splits a word, even if + that byte is part of a multibyte character in ‘IFS’ or part of + multibyte character in the word. Bash allows multibyte characters + in the value of ‘IFS’, treating a valid multibyte character as a + single delimiter, and will not split a valid multibyte character + even if one of the bytes composing that character appears in ‘IFS’. + This is POSIX interpretation 1560, further modified by issue 1924. - 1. The 'fc' builtin checks '$EDITOR' as a program to edit history - entries if 'FCEDIT' is unset, rather than defaulting directly to - 'ed'. 'fc' uses 'ed' if 'EDITOR' is unset. + 2. The ‘fc’ builtin checks ‘$EDITOR’ as a program to edit history + entries if ‘FCEDIT’ is unset, rather than defaulting directly to + ‘ed’. ‘fc’ uses ‘ed’ if ‘EDITOR’ is unset. - 2. As noted above, Bash requires the 'xpg_echo' option to be enabled - for the 'echo' builtin to be fully conformant. + 3. As noted above, Bash requires the ‘xpg_echo’ option to be enabled + for the ‘echo’ builtin to be fully conformant. Bash can be configured to be POSIX-conformant by default, by specifying -the '--enable-strict-posix-default' to 'configure' when building (*note +the ‘--enable-strict-posix-default’ to ‘configure’ when building (*note Optional Features::). diff --git a/RBASH b/RBASH index 7d0a5e8d1..fedcd315d 100644 --- a/RBASH +++ b/RBASH @@ -1,52 +1,54 @@ 6.10 The Restricted Shell ========================= -If Bash is started with the name 'rbash', or the '--restricted' or '-r' -option is supplied at invocation, the shell becomes restricted. A +If Bash is started with the name ‘rbash’, or the ‘--restricted’ or ‘-r’ +option is supplied at invocation, the shell becomes RESTRICTED. A restricted shell is used to set up an environment more controlled than -the standard shell. A restricted shell behaves identically to 'bash' +the standard shell. A restricted shell behaves identically to ‘bash’ with the exception that the following are disallowed or not performed: - * Changing directories with the 'cd' builtin. - * Setting or unsetting the values of the 'SHELL', 'PATH', 'HISTFILE', - 'ENV', or 'BASH_ENV' variables. - * Specifying command names containing slashes. - * Specifying a filename containing a slash as an argument to the '.' + • Changing directories with the ‘cd’ builtin. + • Setting or unsetting the values of the ‘SHELL’, ‘PATH’, ‘HISTFILE’, + ‘ENV’, or ‘BASH_ENV’ variables. + • Specifying command names containing slashes. + • Specifying a filename containing a slash as an argument to the ‘.’ builtin command. - * Specifying a filename containing a slash as an argument to the - 'history' builtin command. - * Specifying a filename containing a slash as an argument to the '-p' - option to the 'hash' builtin command. - * Importing function definitions from the shell environment at + • Using the ‘-p’ option to the ‘.’ builtin command to specify a + search path. + • Specifying a filename containing a slash as an argument to the + ‘history’ builtin command. + • Specifying a filename containing a slash as an argument to the ‘-p’ + option to the ‘hash’ builtin command. + • Importing function definitions from the shell environment at startup. - * Parsing the value of 'SHELLOPTS' from the shell environment at + • Parsing the value of ‘SHELLOPTS’ from the shell environment at startup. - * Redirecting output using the '>', '>|', '<>', '>&', '&>', and '>>' + • Redirecting output using the ‘>’, ‘>|’, ‘<>’, ‘>&’, ‘&>’, and ‘>>’ redirection operators. - * Using the 'exec' builtin to replace the shell with another command. - * Adding or deleting builtin commands with the '-f' and '-d' options - to the 'enable' builtin. - * Using the 'enable' builtin command to enable disabled shell + • Using the ‘exec’ builtin to replace the shell with another command. + • Adding or deleting builtin commands with the ‘-f’ and ‘-d’ options + to the ‘enable’ builtin. + • Using the ‘enable’ builtin command to enable disabled shell builtins. - * Specifying the '-p' option to the 'command' builtin. - * Turning off restricted mode with 'set +r' or 'shopt -u - restricted_shell'. + • Specifying the ‘-p’ option to the ‘command’ builtin. + • Turning off restricted mode with ‘set +r’ or ‘shopt -u + restricted_shell’. These restrictions are enforced after any startup files are read. When a command that is found to be a shell script is executed (*note -Shell Scripts::), 'rbash' turns off any restrictions in the shell +Shell Scripts::), ‘rbash’ turns off any restrictions in the shell spawned to execute the script. The restricted shell mode is only one component of a useful restricted -environment. It should be accompanied by setting 'PATH' to a value that +environment. It should be accompanied by setting ‘PATH’ to a value that allows execution of only a few verified commands (commands that allow shell escapes are particularly vulnerable), changing the current -directory to a non-writable directory other than '$HOME' after login, +directory to a non-writable directory other than ‘$HOME’ after login, not allowing the restricted shell to execute shell scripts, and cleaning the environment of variables that cause some commands to modify their -behavior (e.g., 'VISUAL' or 'PAGER'). +behavior (e.g., ‘VISUAL’ or ‘PAGER’). Modern systems provide more secure ways to implement a restricted -environment, such as 'jails', 'zones', or 'containers'. +environment, such as ‘jails’, ‘zones’, or ‘containers’. diff --git a/README b/README index 90d0be5bf..b23715397 100644 --- a/README +++ b/README @@ -1,22 +1,22 @@ Introduction ============ -This is GNU Bash, version 5.2. Bash is the GNU Project's Bourne +This is GNU Bash, version 5.3. Bash is the GNU Project's Bourne Again SHell, a complete implementation of the POSIX shell spec, but also with interactive command line editing, job control on architectures that support it, csh-like features such as history substitution and brace expansion, and a slew of other features. For more information on the features of Bash that are new to this -type of shell, see the file `doc/bashref.texi'. There is also a -large Unix-style man page. The man page is the definitive description -of the shell's features. +type of shell, see the file `doc/bashref.info'. There is also a +large Unix-style man page. If the info fie and the man page conflict, +the man page is the definitive description of the shell's features. See the file POSIX for a discussion of how the Bash defaults differ from the POSIX spec and a description of the Bash `posix mode'. There are some user-visible incompatibilities between this version -of Bash and previous widely-distributed versions, bash-4.4, bash-5.0, -and bash-5.1. For details, see the file COMPAT. The NEWS file tersely +of Bash and previous widely-distributed versions, bash-5.0, bash-5.1, +and bash-5.2. The COMPAT file has the details. The NEWS file tersely lists features that are new in this release. Bash is free software, distributed under the terms of the [GNU] General @@ -28,7 +28,7 @@ A number of frequently-asked questions are answered in the file `doc/FAQ'. (That file is no longer updated.) To compile Bash, type `./configure', then `make'. Bash auto-configures -the build process, so no further intervention should be necessary. Bash +the build process, so no further intervention should be necessary. Bash builds with `gcc' by default if it is available. If you want to use `cc' instead, type @@ -40,13 +40,14 @@ may work: env CC=cc ./configure Read the file INSTALL in this directory for more information about how -to customize and control the build process. The file NOTES contains +to customize and control the build process, including how to build in a +directory different from the source directory. The file NOTES contains platform-specific installation and configuration information. If you are a csh user and wish to convert your csh aliases to Bash aliases, you may wish to use the script `examples/misc/alias-conv.sh' -as a starting point. The script `examples/misc/cshtobash' is a -more ambitious script that attempts to do a more complete job. +as a starting point. The script `examples/misc/cshtobash' is a more +ambitious script that attempts to do a more complete job. Reporting Bugs ============== @@ -61,11 +62,14 @@ time as bash. The discussion list `bug-bash@gnu.org' often contains information about new ports of Bash, or discussions of new features or behavior changes that people would like. This mailing list is also available -as a usenet newsgroup: gnu.bash.bug. +as a usenet newsgroup: gnu.bash.bug. + +The `help-bash@gnu.org' mailing list is used for questions about +using bash. When you send a bug report, please use the `bashbug' program that is -built at the same time as bash. If bash fails to build, try building -bashbug directly with `make bashbug'. If you cannot build `bashbug', +built at the same time as bash. If bash fails to build, try building +bashbug directly with `make bashbug'. If you cannot build `bashbug', please send mail to bug-bash@gnu.org with the following information: * the version number and release status of Bash (e.g., 2.05a-release) @@ -101,6 +105,11 @@ https://github.com/scop/bash-completion. If it's not a package from your vendor, you may install the included version. +There are a number of example dynamically loadable builtin commands in the +examples/loadables subdirectory. These are built and installed when bash is +installed. If you want to test or experiment with these builtins before +installing bash, you can run `make loadables' to build them. + Enjoy! Chet Ramey diff --git a/aclocal.m4 b/aclocal.m4 index cc97bd4b8..ae2d8aec9 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -3,7 +3,7 @@ dnl Bash specific tests dnl dnl Some derived from PDKSH 5.1.3 autoconf tests dnl -dnl Copyright (C) 1987-2021 Free Software Foundation, Inc. +dnl Copyright (C) 1987-2025 Free Software Foundation, Inc. dnl dnl @@ -69,11 +69,7 @@ AC_DEFUN(BASH_DECL_PRINTF, AC_CACHE_VAL(bash_cv_printf_declared, [AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include -#ifdef __STDC__ typedef int (*_bashfunc)(const char *, ...); -#else -typedef int (*_bashfunc)(); -#endif #include int main() @@ -238,6 +234,9 @@ AC_CACHE_VAL(bash_cv_dup2_broken, #include #include #include +#ifdef HAVE_UNISTD_H +# include +#endif /* HAVE_UNISTD_H */ int main() { @@ -432,6 +431,7 @@ AC_CACHE_VAL(bash_cv_sizeof_rlim_cur, #endif #include #include +int main() { struct rlimit r; @@ -457,6 +457,7 @@ AC_CACHE_VAL(bash_cv_sizeof_quad_t, #include #endif +int main() { #if HAVE_QUAD_T @@ -558,18 +559,8 @@ AC_CACHE_VAL(bash_cv_getenv_redef, # include #endif #include -#ifndef __STDC__ -# ifndef const -# define const -# endif -#endif char * -getenv (name) -#if defined (__linux__) || defined (__bsdi__) || defined (convex) - const char *name; -#else - char const *name; -#endif /* !__linux__ && !__bsdi__ && !convex */ +getenv (const char *name) { return "42"; } @@ -599,7 +590,6 @@ fi # We should check for putenv before calling this AC_DEFUN(BASH_FUNC_STD_PUTENV, [ -AC_REQUIRE([AC_C_PROTOTYPES]) AC_CACHE_CHECK([for standard-conformant putenv declaration], bash_cv_std_putenv, [AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #if HAVE_STDLIB_H @@ -608,16 +598,7 @@ AC_CACHE_CHECK([for standard-conformant putenv declaration], bash_cv_std_putenv, #if HAVE_STDDEF_H #include #endif -#ifndef __STDC__ -# ifndef const -# define const -# endif -#endif -#ifdef PROTOTYPES extern int putenv (char *); -#else -extern int putenv (); -#endif ]], [[return (putenv == 0);]] )], [bash_cv_std_putenv=yes], [bash_cv_std_putenv=no] )]) @@ -629,7 +610,6 @@ fi # We should check for unsetenv before calling this AC_DEFUN(BASH_FUNC_STD_UNSETENV, [ -AC_REQUIRE([AC_C_PROTOTYPES]) AC_CACHE_CHECK([for standard-conformant unsetenv declaration], bash_cv_std_unsetenv, [AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #if HAVE_STDLIB_H @@ -638,16 +618,7 @@ AC_CACHE_CHECK([for standard-conformant unsetenv declaration], bash_cv_std_unset #if HAVE_STDDEF_H #include #endif -#ifndef __STDC__ -# ifndef const -# define const -# endif -#endif -#ifdef PROTOTYPES extern int unsetenv (const char *); -#else -extern int unsetenv (); -#endif ]], [[return (unsetenv == 0);]] )], [bash_cv_std_unsetenv=yes], [bash_cv_std_unsetenv=no] )]) @@ -841,9 +812,7 @@ AC_CACHE_VAL(bash_cv_func_strcoll_broken, #include int -main(c, v) -int c; -char *v[]; +main(int c, char **v) { int r1, r2; char *deflocale, *defcoll; @@ -966,8 +935,8 @@ AC_CACHE_VAL(bash_cv_termcap_lib, [AC_CHECK_LIB(termcap, tgetent, bash_cv_termcap_lib=libtermcap, [AC_CHECK_LIB(tinfo, tgetent, bash_cv_termcap_lib=libtinfo, [AC_CHECK_LIB(curses, tgetent, bash_cv_termcap_lib=libcurses, - [AC_CHECK_LIB(ncurses, tgetent, bash_cv_termcap_lib=libncurses, - [AC_CHECK_LIB(ncursesw, tgetent, bash_cv_termcap_lib=libncursesw, + [AC_CHECK_LIB(ncursesw, tgetent, bash_cv_termcap_lib=libncursesw, + [AC_CHECK_LIB(ncurses, tgetent, bash_cv_termcap_lib=libncurses, bash_cv_termcap_lib=gnutermcap)])])])])])]) if test "X$_bash_needmsg" = "Xyes"; then AC_MSG_CHECKING(which library has the termcap functions) @@ -983,9 +952,15 @@ TERMCAP_DEP= elif test $bash_cv_termcap_lib = libtinfo; then TERMCAP_LIB=-ltinfo TERMCAP_DEP= +elif test $bash_cv_termcap_lib = libncursesw; then +TERMCAP_LIB=-lncursesw +TERMCAP_DEP= elif test $bash_cv_termcap_lib = libncurses; then TERMCAP_LIB=-lncurses TERMCAP_DEP= +elif test $bash_cv_termcap_lib = libcurses; then +TERMCAP_LIB=-lcurses +TERMCAP_DEP= elif test $bash_cv_termcap_lib = libc; then TERMCAP_LIB= TERMCAP_DEP= @@ -1050,7 +1025,7 @@ dnl like _AC_STRUCT_DIRENT(MEMBER) but public AC_DEFUN(BASH_STRUCT_DIRENT, [ AC_REQUIRE([AC_HEADER_DIRENT]) -AC_CHECK_MEMBERS(struct dirent.$1, bash_cv_dirent_has_$1=yes, bash_cv_dirent_has_$1=no, +AC_CHECK_MEMBERS(struct dirent.$1, [], [], [[ #include #include @@ -1074,35 +1049,9 @@ AC_CHECK_MEMBERS(struct dirent.$1, bash_cv_dirent_has_$1=yes, bash_cv_dirent_has ]]) ]) -AC_DEFUN(BASH_STRUCT_DIRENT_D_INO, -[AC_REQUIRE([AC_HEADER_DIRENT]) -AC_MSG_CHECKING(for struct dirent.d_ino) -AC_CACHE_VAL(bash_cv_dirent_has_d_ino, [BASH_STRUCT_DIRENT([d_ino])]) -AC_MSG_RESULT($bash_cv_dirent_has_d_ino) -if test $bash_cv_dirent_has_d_ino = yes; then -AC_DEFINE(HAVE_STRUCT_DIRENT_D_INO) -fi -]) - -AC_DEFUN(BASH_STRUCT_DIRENT_D_FILENO, -[AC_REQUIRE([AC_HEADER_DIRENT]) -AC_MSG_CHECKING(for struct dirent.d_fileno) -AC_CACHE_VAL(bash_cv_dirent_has_d_fileno, [BASH_STRUCT_DIRENT([d_fileno])]) -AC_MSG_RESULT($bash_cv_dirent_has_d_fileno) -if test $bash_cv_dirent_has_d_fileno = yes; then -AC_DEFINE(HAVE_STRUCT_DIRENT_D_FILENO) -fi -]) - -AC_DEFUN(BASH_STRUCT_DIRENT_D_NAMLEN, -[AC_REQUIRE([AC_HEADER_DIRENT]) -AC_MSG_CHECKING(for struct dirent.d_namlen) -AC_CACHE_VAL(bash_cv_dirent_has_d_namlen, [BASH_STRUCT_DIRENT([d_namlen])]) -AC_MSG_RESULT($bash_cv_dirent_has_d_namlen) -if test $bash_cv_dirent_has_d_namlen = yes; then -AC_DEFINE(HAVE_STRUCT_DIRENT_D_NAMLEN) -fi -]) +AC_DEFUN([BASH_STRUCT_DIRENT_D_INO], [BASH_STRUCT_DIRENT([d_ino])]) +AC_DEFUN([BASH_STRUCT_DIRENT_D_FILENO], [BASH_STRUCT_DIRENT([d_fileno])]) +AC_DEFUN([BASH_STRUCT_DIRENT_D_NAMLEN], [BASH_STRUCT_DIRENT([d_namlen])]) AC_DEFUN(BASH_STRUCT_TIMEVAL, [AC_MSG_CHECKING(for struct timeval in sys/time.h and time.h) @@ -1345,15 +1294,13 @@ AC_CACHE_VAL(bash_cv_must_reinstall_sighandlers, #endif #include -typedef void sigfunc(); +typedef void sigfunc(int); volatile int nsigint; #ifdef HAVE_POSIX_SIGNALS sigfunc * -set_signal_handler(sig, handler) - int sig; - sigfunc *handler; +set_signal_handler(int sig, sigfunc *handler) { struct sigaction act, oact; act.sa_handler = handler; @@ -1368,8 +1315,7 @@ set_signal_handler(sig, handler) #endif void -sigint(s) -int s; +sigint(int s) { nsigint++; } @@ -1607,13 +1553,15 @@ AC_DEFUN(BASH_CHECK_DEV_FD, [AC_MSG_CHECKING(whether /dev/fd is available) AC_CACHE_VAL(bash_cv_dev_fd, [bash_cv_dev_fd="" -if test -d /dev/fd && (exec test -r /dev/fd/0 < /dev/null) ; then +if test -d /dev/fd && (exec test -r /dev/fd/0 < /dev/null) ; then # check for systems like FreeBSD 5 that only provide /dev/fd/[012] if (exec test -r /dev/fd/3 3 int -main(c, v) -int c; -char **v; +main(int c, char **v) { int w; setlocale(LC_ALL, "en_US.UTF-8"); w = wcwidth (0x0301); + if (w != 0) + exit (0); + w = wcwidth (0x200b); exit (w == 0); /* exit 0 if wcwidth broken */ } ]])], [bash_cv_wcwidth_broken=yes], [bash_cv_wcwidth_broken=no], @@ -2093,31 +2047,17 @@ AC_DEFUN([BASH_FUNC_VSNPRINTF], if test X$ac_cv_func_vsnprintf = Xyes; then AC_CACHE_CHECK([for standard-conformant vsnprintf], [bash_cv_func_vsnprintf], [AC_RUN_IFELSE([AC_LANG_SOURCE([[ -#if HAVE_STDARG_H #include -#else -#include -#endif #include #include static int -#if HAVE_STDARG_H foo(const char *fmt, ...) -#else -foo(format, va_alist) - const char *format; - va_dcl -#endif { va_list args; int n; -#if HAVE_STDARG_H va_start(args, fmt); -#else - va_start(args); -#endif n = vsnprintf(0, 0, fmt, args); va_end (args); return n; @@ -2154,9 +2094,7 @@ AC_CACHE_VAL(bash_cv_wexitstatus_offset, #include int -main(c, v) - int c; - char **v; +main(int c, char **v) { pid_t pid, p; int s, i, n; @@ -2230,6 +2168,43 @@ main(int c, char **v) fi ]) +AC_DEFUN([BASH_FUNC_BRK], +[ + AC_MSG_CHECKING([for brk]) + AC_CACHE_VAL(ac_cv_func_brk, + [AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include ]], + [[ void *x = brk (0); ]])], + [ac_cv_func_brk=yes],[ac_cv_func_brk=no])]) + AC_MSG_RESULT($ac_cv_func_brk) + if test X$ac_cv_func_brk = Xyes; then + AC_CACHE_CHECK([for working brk], [bash_cv_func_brk], + [AC_RUN_IFELSE([AC_LANG_SOURCE([[ +#include +#include + +int +main(int c, char **v) +{ + void *x; + + x = brk (0); + exit ((x == (void *)-1) ? 1 : 0); +} +]])],[bash_cv_func_brk=yes],[bash_cv_func_brk=no],[AC_MSG_WARN([cannot check working brk if cross-compiling]) + bash_cv_func_brk=yes +])]) + if test $bash_cv_func_brk = no; then + ac_cv_func_brk=no + fi + fi + if test $ac_cv_func_brk = yes; then + AC_DEFINE(HAVE_BRK, 1, + [Define if you have a working brk function.]) + fi +]) + AC_DEFUN(BASH_FUNC_FNMATCH_EQUIV_FALLBACK, [AC_MSG_CHECKING(whether fnmatch can be used to check bracket equivalence classes) AC_CACHE_VAL(bash_cv_fnmatch_equiv_fallback, @@ -2265,3 +2240,68 @@ else fi AC_DEFINE_UNQUOTED([FNMATCH_EQUIV_FALLBACK], [$bash_cv_fnmatch_equiv_value], [Whether fnmatch can be used for bracket equivalence classes]) ]) + +AC_DEFUN([BASH_FUNC_STRCHRNUL], +[ + AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) + AC_CACHE_CHECK([whether strchrnul works], + [bash_cv_func_strchrnul_works], + [AC_RUN_IFELSE([AC_LANG_PROGRAM( +[[ +#include +]], +[[const char *buf = "abc"; + return strchrnul (buf, 'd') != buf + 3; +]] +)], +[bash_cv_func_strchrnul_works=yes], [bash_cv_func_strchrnul_works=no], +[bash_cv_func_strchrnul_works=no] +)]) + +if test "$bash_cv_func_strchrnul_works" = "no"; then +AC_LIBOBJ([strchrnul]) +fi +]) + +# AM_PROG_INSTALL_STRIP +# --------------------- +# One issue with vendor 'install' (even GNU) is that you can't +# specify the program used to strip binaries. This is especially +# annoying in cross-compiling environments, where the build's strip +# is unlikely to handle the host's binaries. +# Fortunately install-sh will honor a STRIPPROG variable, so we +# always use install-sh in "make install-strip", and initialize +# STRIPPROG with the value of the STRIP variable (set by the user). +AC_DEFUN([AM_PROG_INSTALL_STRIP], +[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl +# Installed binaries are usually stripped using 'strip' when the user +# run "make install-strip". However 'strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the 'STRIP' environment variable to overrule this program. +dnl Don't test for $cross_compiling = yes, because it might be 'maybe'. +#if test "$cross_compiling" != no; then + AC_CHECK_TOOL([STRIP], [strip], :) +#fi +INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" +AC_SUBST([INSTALL_STRIP_PROGRAM])]) + +AC_DEFUN([AM_AUX_DIR_EXPAND], +[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl +# Expand $ac_aux_dir to an absolute path. +am_aux_dir=`cd "$ac_aux_dir" && pwd` +]) + +# AM_PROG_INSTALL_SH +# ------------------ +# Define $install_sh. +AC_DEFUN([AM_PROG_INSTALL_SH], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +if test x"${install_sh+set}" != xset; then + case $am_aux_dir in + *\ * | *\ *) + install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; + *) + install_sh="\${SHELL} $am_aux_dir/install-sh" + esac +fi +AC_SUBST([install_sh])]) diff --git a/alias.c b/alias.c index 23f967fa8..cb52507c9 100644 --- a/alias.c +++ b/alias.c @@ -1,7 +1,7 @@ /* alias.c -- Not a full alias, but just the kind that we use in the shell. Csh style alias is somewhere else (`over there, in a box'). */ -/* Copyright (C) 1987-2021 Free Software Foundation, Inc. +/* Copyright (C) 1987-2022 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -48,17 +48,17 @@ #define ALIAS_HASH_BUCKETS 64 /* must be power of two */ -typedef int sh_alias_map_func_t PARAMS((alias_t *)); +typedef int sh_alias_map_func_t (alias_t *); -static void free_alias_data PARAMS((PTR_T)); -static alias_t **map_over_aliases PARAMS((sh_alias_map_func_t *)); -static void sort_aliases PARAMS((alias_t **)); -static int qsort_alias_compare PARAMS((alias_t **, alias_t **)); +static void free_alias_data (PTR_T); +static alias_t **map_over_aliases (sh_alias_map_func_t *); +static void sort_aliases (alias_t **); +static int qsort_alias_compare (alias_t **, alias_t **); #if defined (READLINE) -static int skipquotes PARAMS((char *, int)); -static int skipws PARAMS((char *, int)); -static int rd_token PARAMS((char *, int)); +static int skipquotes (char *, int); +static int skipws (char *, int); +static int rd_token (char *, int); #endif /* Non-zero means expand all words on the line. Otherwise, expand @@ -69,7 +69,7 @@ int alias_expand_all = 0; HASH_TABLE *aliases = (HASH_TABLE *)NULL; void -initialize_aliases () +initialize_aliases (void) { if (aliases == 0) aliases = hash_create (ALIAS_HASH_BUCKETS); @@ -78,8 +78,7 @@ initialize_aliases () /* Scan the list of aliases looking for one with NAME. Return NULL if the alias doesn't exist, else a pointer to the alias_t. */ alias_t * -find_alias (name) - char *name; +find_alias (const char *name) { BUCKET_CONTENTS *al; @@ -92,8 +91,7 @@ find_alias (name) /* Return the value of the alias for NAME, or NULL if there is none. */ char * -get_alias_value (name) - char *name; +get_alias_value (const char *name) { alias_t *alias; @@ -107,8 +105,7 @@ get_alias_value (name) /* Make a new alias from NAME and VALUE. If NAME can be found, then replace its value. */ void -add_alias (name, value) - char *name, *value; +add_alias (const char *name, const char *value) { BUCKET_CONTENTS *elt; alias_t *temp; @@ -158,8 +155,7 @@ add_alias (name, value) /* Delete a single alias structure. */ static void -free_alias_data (data) - PTR_T data; +free_alias_data (PTR_T data) { register alias_t *a; @@ -177,8 +173,7 @@ free_alias_data (data) the number of aliases left in the table, or -1 if the alias didn't exist. */ int -remove_alias (name) - char *name; +remove_alias (const char *name) { BUCKET_CONTENTS *elt; @@ -201,7 +196,7 @@ remove_alias (name) /* Delete all aliases. */ void -delete_all_aliases () +delete_all_aliases (void) { if (aliases == 0) return; @@ -217,11 +212,10 @@ delete_all_aliases () /* Return an array of aliases that satisfy the conditions tested by FUNCTION. If FUNCTION is NULL, return all aliases. */ static alias_t ** -map_over_aliases (function) - sh_alias_map_func_t *function; +map_over_aliases (sh_alias_map_func_t *function) { register int i; - register BUCKET_CONTENTS *tlist; + BUCKET_CONTENTS *tlist; alias_t *alias, **list; int list_index; @@ -246,16 +240,8 @@ map_over_aliases (function) return (list); } -static void -sort_aliases (array) - alias_t **array; -{ - qsort (array, strvec_len ((char **)array), sizeof (alias_t *), (QSFUNC *)qsort_alias_compare); -} - static int -qsort_alias_compare (as1, as2) - alias_t **as1, **as2; +qsort_alias_compare (alias_t **as1, alias_t **as2) { int result; @@ -265,9 +251,15 @@ qsort_alias_compare (as1, as2) return (result); } +static void +sort_aliases (alias_t **array) +{ + qsort (array, strvec_len ((char **)array), sizeof (alias_t *), (QSFUNC *)qsort_alias_compare); +} + /* Return a sorted list of all defined aliases */ alias_t ** -all_aliases () +all_aliases (void) { alias_t **list; @@ -281,8 +273,7 @@ all_aliases () } char * -alias_expand_word (s) - char *s; +alias_expand_word (const char *s) { alias_t *r; @@ -319,9 +310,7 @@ static int command_word; backslash-escaped characters. */ static int -skipquotes (string, start) - char *string; - int start; +skipquotes (char *string, int start) { register int i; int delimiter = string[start]; @@ -348,9 +337,7 @@ skipquotes (string, start) START. Return the new index into STRING, after zero or more characters have been skipped. */ static int -skipws (string, start) - char *string; - int start; +skipws (char *string, int start) { register int i; int pass_next, backslash_quoted_word; @@ -435,9 +422,7 @@ skipws (string, start) skipquotes () for quoted strings in the middle or at the end of tokens, so all characters show up (e.g. foo'' and foo""bar) */ static int -rd_token (string, start) - char *string; - int start; +rd_token (char *string, int start) { register int i; @@ -476,12 +461,13 @@ rd_token (string, start) /* Return a new line, with any aliases substituted. */ char * -alias_expand (string) - char *string; + +alias_expand (char *string) { - register int i, j, start; + int i, start; char *line, *token; - int line_len, tl, real_start, expand_next, expand_this_token; + size_t j, line_len; + int tl, real_start, expand_next, expand_this_token; alias_t *alias; line_len = strlen (string) + 1; @@ -560,7 +546,7 @@ alias_expand (string) (alias = find_alias (token))) { char *v; - int vlen, llen; + size_t vlen, llen; v = alias->value; vlen = strlen (v); @@ -577,7 +563,7 @@ alias_expand (string) } else { - int llen, tlen; + size_t llen, tlen; llen = strlen (line); tlen = i - real_start; /* tlen == strlen(token) */ diff --git a/alias.h b/alias.h index 4e2d67c0f..af4a54486 100644 --- a/alias.h +++ b/alias.h @@ -1,6 +1,6 @@ /* alias.h -- structure definitions. */ -/* Copyright (C) 1987-2020 Free Software Foundation, Inc. +/* Copyright (C) 1987-2022 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -38,36 +38,36 @@ typedef struct alias { /* The list of known aliases. */ extern HASH_TABLE *aliases; -extern void initialize_aliases PARAMS((void)); +extern void initialize_aliases (void); /* Scan the list of aliases looking for one with NAME. Return NULL if the alias doesn't exist, else a pointer to the alias. */ -extern alias_t *find_alias PARAMS((char *)); +extern alias_t *find_alias (const char *); /* Return the value of the alias for NAME, or NULL if there is none. */ -extern char *get_alias_value PARAMS((char *)); +extern char *get_alias_value (const char *); /* Make a new alias from NAME and VALUE. If NAME can be found, then replace its value. */ -extern void add_alias PARAMS((char *, char *)); +extern void add_alias (const char *, const char *); /* Remove the alias with name NAME from the alias list. Returns the index of the removed alias, or -1 if the alias didn't exist. */ -extern int remove_alias PARAMS((char *)); +extern int remove_alias (const char *); /* Remove all aliases. */ -extern void delete_all_aliases PARAMS((void)); +extern void delete_all_aliases (void); /* Return an array of all defined aliases. */ -extern alias_t **all_aliases PARAMS((void)); +extern alias_t **all_aliases (void); /* Expand a single word for aliases. */ -extern char *alias_expand_word PARAMS((char *)); +extern char *alias_expand_word (const char *); /* Return a new line, with any aliases expanded. */ -extern char *alias_expand PARAMS((char *)); +extern char *alias_expand (char *); /* Helper definition for the parser */ -extern void clear_string_list_expander PARAMS((alias_t *)); +extern void clear_string_list_expander (alias_t *); #endif /* _ALIAS_H_ */ diff --git a/array.c b/array.c index 910bbaad8..dbfe90968 100644 --- a/array.c +++ b/array.c @@ -9,7 +9,7 @@ * chet@ins.cwru.edu */ -/* Copyright (C) 1997-2021 Free Software Foundation, Inc. +/* Copyright (C) 1997-2023 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -61,7 +61,7 @@ ae->next = new; \ } while (0) -static char *array_to_string_internal PARAMS((ARRAY_ELEMENT *, ARRAY_ELEMENT *, char *, int)); +static char *array_to_string_internal (ARRAY_ELEMENT *, ARRAY_ELEMENT *, char *, int); static char *spacesep = " "; @@ -78,7 +78,7 @@ static char *spacesep = " "; #define UNSET_LASTREF(a) a->lastref = 0; ARRAY * -array_create() +array_create(void) { ARRAY *r; ARRAY_ELEMENT *head; @@ -94,8 +94,7 @@ array_create() } void -array_flush (a) -ARRAY *a; +array_flush (ARRAY *a) { register ARRAY_ELEMENT *r, *r1; @@ -113,8 +112,7 @@ ARRAY *a; } void -array_dispose(a) -ARRAY *a; +array_dispose(ARRAY *a) { if (a == 0) return; @@ -124,8 +122,7 @@ ARRAY *a; } ARRAY * -array_copy(a) -ARRAY *a; +array_copy(ARRAY *a) { ARRAY *a1; ARRAY_ELEMENT *ae, *new; @@ -149,9 +146,7 @@ ARRAY *a; * S to E, inclusive. */ ARRAY * -array_slice(array, s, e) -ARRAY *array; -ARRAY_ELEMENT *s, *e; +array_slice(ARRAY *array, ARRAY_ELEMENT *s, ARRAY_ELEMENT *e) { ARRAY *a; ARRAY_ELEMENT *p, *n; @@ -175,10 +170,7 @@ ARRAY_ELEMENT *s, *e; * element as the argument. */ void -array_walk(a, func, udata) -ARRAY *a; -sh_ae_map_func_t *func; -void *udata; +array_walk(ARRAY *a, sh_ae_map_func_t *func, void *udata) { register ARRAY_ELEMENT *ae; @@ -198,9 +190,7 @@ void *udata; * and returns NULL. */ ARRAY_ELEMENT * -array_shift(a, n, flags) -ARRAY *a; -int n, flags; +array_shift(ARRAY *a, int n, int flags) { register ARRAY_ELEMENT *ae, *ret; register int i; @@ -258,10 +248,7 @@ int n, flags; * shift. */ int -array_rshift (a, n, s) -ARRAY *a; -int n; -char *s; +array_rshift (ARRAY *a, int n, char *s) { register ARRAY_ELEMENT *ae, *new; @@ -294,23 +281,19 @@ char *s; } ARRAY_ELEMENT * -array_unshift_element(a) -ARRAY *a; +array_unshift_element(ARRAY *a) { return (array_shift (a, 1, 0)); } int -array_shift_element(a, v) -ARRAY *a; -char *v; +array_shift_element(ARRAY *a, char *v) { return (array_rshift (a, 1, v)); } ARRAY * -array_quote(array) -ARRAY *array; +array_quote(ARRAY *array) { ARRAY_ELEMENT *a; char *t; @@ -326,8 +309,7 @@ ARRAY *array; } ARRAY * -array_quote_escapes(array) -ARRAY *array; +array_quote_escapes(ARRAY *array) { ARRAY_ELEMENT *a; char *t; @@ -343,8 +325,7 @@ ARRAY *array; } ARRAY * -array_dequote(array) -ARRAY *array; +array_dequote(ARRAY *array) { ARRAY_ELEMENT *a; char *t; @@ -360,8 +341,7 @@ ARRAY *array; } ARRAY * -array_dequote_escapes(array) -ARRAY *array; +array_dequote_escapes(ARRAY *array) { ARRAY_ELEMENT *a; char *t; @@ -377,8 +357,7 @@ ARRAY *array; } ARRAY * -array_remove_quoted_nulls(array) -ARRAY *array; +array_remove_quoted_nulls(ARRAY *array) { ARRAY_ELEMENT *a; @@ -395,10 +374,7 @@ ARRAY *array; * Since arrays are sparse, unset array elements are not counted. */ char * -array_subrange (a, start, nelem, starsub, quoted, pflags) -ARRAY *a; -arrayind_t start, nelem; -int starsub, quoted, pflags; +array_subrange (ARRAY *a, arrayind_t start, arrayind_t nelem, int starsub, int quoted, int pflags) { ARRAY *a2; ARRAY_ELEMENT *h, *p; @@ -440,10 +416,7 @@ int starsub, quoted, pflags; } char * -array_patsub (a, pat, rep, mflags) -ARRAY *a; -char *pat, *rep; -int mflags; +array_patsub (ARRAY *a, char *pat, char *rep, int mflags) { char *t; int pchar, qflags, pflags; @@ -473,11 +446,7 @@ int mflags; } char * -array_modcase (a, pat, modop, mflags) -ARRAY *a; -char *pat; -int modop; -int mflags; +array_modcase (ARRAY *a, char *pat, int modop, int mflags) { char *t; int pchar, qflags, pflags; @@ -511,9 +480,7 @@ int mflags; * VALUE. */ ARRAY_ELEMENT * -array_create_element(indx, value) -arrayind_t indx; -char *value; +array_create_element(arrayind_t indx, char *value) { ARRAY_ELEMENT *r; @@ -526,8 +493,7 @@ char *value; #ifdef INCLUDE_UNUSED ARRAY_ELEMENT * -array_copy_element(ae) -ARRAY_ELEMENT *ae; +array_copy_element(ARRAY_ELEMENT *ae) { return(ae ? array_create_element(element_index(ae), element_value(ae)) : (ARRAY_ELEMENT *) NULL); @@ -535,8 +501,7 @@ ARRAY_ELEMENT *ae; #endif void -array_dispose_element(ae) -ARRAY_ELEMENT *ae; +array_dispose_element(ARRAY_ELEMENT *ae) { if (ae) { FREE(ae->value); @@ -548,10 +513,7 @@ ARRAY_ELEMENT *ae; * Add a new element with index I and value V to array A (a[i] = v). */ int -array_insert(a, i, v) -ARRAY *a; -arrayind_t i; -char *v; +array_insert(ARRAY *a, arrayind_t i, char *v) { register ARRAY_ELEMENT *new, *ae, *start; arrayind_t startind; @@ -637,9 +599,7 @@ char *v; * caller can dispose of it. */ ARRAY_ELEMENT * -array_remove(a, i) -ARRAY *a; -arrayind_t i; +array_remove(ARRAY *a, arrayind_t i) { register ARRAY_ELEMENT *ae, *start; arrayind_t startind; @@ -694,9 +654,7 @@ arrayind_t i; * Return the value of a[i]. */ char * -array_reference(a, i) -ARRAY *a; -arrayind_t i; +array_reference(ARRAY *a, arrayind_t i) { register ARRAY_ELEMENT *ae, *start; arrayind_t startind; @@ -748,8 +706,7 @@ arrayind_t i; by the rest of the code. */ WORD_LIST * -array_to_word_list(a) -ARRAY *a; +array_to_word_list(ARRAY *a) { WORD_LIST *list; ARRAY_ELEMENT *ae; @@ -763,8 +720,7 @@ ARRAY *a; } ARRAY * -array_from_word_list (list) -WORD_LIST *list; +array_from_word_list (WORD_LIST *list) { ARRAY *a; @@ -775,8 +731,7 @@ WORD_LIST *list; } WORD_LIST * -array_keys_to_word_list(a) -ARRAY *a; +array_keys_to_word_list(ARRAY *a) { WORD_LIST *list; ARRAY_ELEMENT *ae; @@ -794,8 +749,7 @@ ARRAY *a; } WORD_LIST * -array_to_kvpair_list(a) -ARRAY *a; +array_to_kvpair_list(ARRAY *a) { WORD_LIST *list; ARRAY_ELEMENT *ae; @@ -815,9 +769,7 @@ ARRAY *a; } ARRAY * -array_assign_list (array, list) -ARRAY *array; -WORD_LIST *list; +array_assign_list (ARRAY *array, WORD_LIST *list) { register WORD_LIST *l; register arrayind_t i; @@ -828,9 +780,7 @@ WORD_LIST *list; } char ** -array_to_argv (a, countp) -ARRAY *a; -int *countp; +array_to_argv (ARRAY *a, int *countp) { char **ret, *t; int i; @@ -855,10 +805,7 @@ int *countp; } ARRAY * -array_from_argv(a, vec, count) -ARRAY *a; -char **vec; -int count; +array_from_argv(ARRAY *a, char **vec, int count) { arrayind_t i; ARRAY_ELEMENT *ae; @@ -867,7 +814,7 @@ int count; if (a == 0 || array_num_elements (a) == 0) { for (i = 0; i < count; i++) - array_insert (a, i, t); + array_insert (a, i, vec[i]); return a; } @@ -908,10 +855,7 @@ int count; * to END, separated by SEP. */ static char * -array_to_string_internal (start, end, sep, quoted) -ARRAY_ELEMENT *start, *end; -char *sep; -int quoted; +array_to_string_internal (ARRAY_ELEMENT *start, ARRAY_ELEMENT *end, char *sep, int quoted) { char *result, *t; ARRAY_ELEMENT *ae; @@ -949,9 +893,7 @@ int quoted; } char * -array_to_kvpair (a, quoted) -ARRAY *a; -int quoted; +array_to_kvpair (ARRAY *a, int quoted) { char *result, *valstr, *is; char indstr[INT_STRLEN_BOUND(intmax_t) + 1]; @@ -1003,9 +945,7 @@ int quoted; } char * -array_to_assign (a, quoted) -ARRAY *a; -int quoted; +array_to_assign (ARRAY *a, int quoted) { char *result, *valstr, *is; char indstr[INT_STRLEN_BOUND(intmax_t) + 1]; @@ -1057,10 +997,7 @@ int quoted; } char * -array_to_string (a, sep, quoted) -ARRAY *a; -char *sep; -int quoted; +array_to_string (ARRAY *a, char *sep, int quoted) { if (a == 0) return((char *)NULL); @@ -1074,8 +1011,7 @@ int quoted; * Return an array consisting of elements in S, separated by SEP */ ARRAY * -array_from_string(s, sep) -char *s, *sep; +array_from_string(char *s, char *sep) { ARRAY *a; WORD_LIST *w; @@ -1098,8 +1034,7 @@ char *s, *sep; int interrupt_immediately = 0; int -signal_is_trapped(s) -int s; +signal_is_trapped(int s) { return 0; } @@ -1119,8 +1054,7 @@ programming_error(const char *s, ...) } WORD_DESC * -make_bare_word (s) -const char *s; +make_bare_word (const char *s) { WORD_DESC *w; @@ -1131,9 +1065,7 @@ const char *s; } WORD_LIST * -make_word_list(x, l) -WORD_DESC *x; -WORD_LIST *l; +make_word_list(WORD_DESC *x, WORD_LIST *l) { WORD_LIST *w; @@ -1144,9 +1076,7 @@ WORD_LIST *l; } WORD_LIST * -list_string(s, t, i) -char *s, *t; -int i; +list_string(char *s, char *t, int i) { char *r, *a; WORD_LIST *wl; @@ -1164,8 +1094,7 @@ int i; } GENERIC_LIST * -list_reverse (list) -GENERIC_LIST *list; +list_reverse (GENERIC_LIST *list) { register GENERIC_LIST *next, *prev; @@ -1179,22 +1108,19 @@ GENERIC_LIST *list; } char * -pat_subst(s, t, u, i) -char *s, *t, *u; -int i; +pat_subst(char *s, char *t, char *u, int i) { return ((char *)NULL); } char * -quote_string(s) -char *s; +quote_string(char *s) { return savestring(s); } -print_element(ae) -ARRAY_ELEMENT *ae; +void +print_element(ARRAY_ELEMENT *ae) { char lbuf[INT_STRLEN_BOUND (intmax_t) + 1]; @@ -1203,14 +1129,15 @@ ARRAY_ELEMENT *ae; element_value(ae)); } -print_array(a) -ARRAY *a; +void +print_array(ARRAY *a) { printf("\n"); array_walk(a, print_element, (void *)NULL); } -main() +int +main(int c, char **v) { ARRAY *a, *new_a, *copy_of_a; ARRAY_ELEMENT *ae, *aew; diff --git a/array.h b/array.h index 4214e8b41..47712e88a 100644 --- a/array.h +++ b/array.h @@ -1,7 +1,7 @@ /* array.h -- definitions for the interface exported by array.c that allows the rest of the shell to manipulate array variables. */ -/* Copyright (C) 1997-2021 Free Software Foundation, Inc. +/* Copyright (C) 1997-2022 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -50,70 +50,70 @@ typedef struct array_element { #define ARRAY_DEFAULT_SIZE 1024 -typedef int sh_ae_map_func_t PARAMS((ARRAY_ELEMENT *, void *)); +typedef int sh_ae_map_func_t (ARRAY_ELEMENT *, void *); /* Basic operations on entire arrays */ #ifdef ALT_ARRAY_IMPLEMENTATION -extern void array_alloc PARAMS((ARRAY *, arrayind_t)); -extern void array_resize PARAMS((ARRAY *, arrayind_t)); -extern void array_expand PARAMS((ARRAY *, arrayind_t)); -extern void array_dispose_elements PARAMS((ARRAY_ELEMENT **)); +extern void array_alloc (ARRAY *, arrayind_t); +extern void array_resize (ARRAY *, arrayind_t); +extern void array_expand (ARRAY *, arrayind_t); +extern void array_dispose_elements (ARRAY_ELEMENT **); #endif -extern ARRAY *array_create PARAMS((void)); -extern void array_flush PARAMS((ARRAY *)); -extern void array_dispose PARAMS((ARRAY *)); -extern ARRAY *array_copy PARAMS((ARRAY *)); +extern ARRAY *array_create (void); +extern void array_flush (ARRAY *); +extern void array_dispose (ARRAY *); +extern ARRAY *array_copy (ARRAY *); #ifndef ALT_ARRAY_IMPLEMENTATION -extern ARRAY *array_slice PARAMS((ARRAY *, ARRAY_ELEMENT *, ARRAY_ELEMENT *)); +extern ARRAY *array_slice (ARRAY *, ARRAY_ELEMENT *, ARRAY_ELEMENT *); #else -extern ARRAY *array_slice PARAMS((ARRAY *, arrayind_t, arrayind_t)); +extern ARRAY *array_slice (ARRAY *, arrayind_t, arrayind_t); #endif -extern void array_walk PARAMS((ARRAY *, sh_ae_map_func_t *, void *)); +extern void array_walk (ARRAY *, sh_ae_map_func_t *, void *); #ifndef ALT_ARRAY_IMPLEMENTATION -extern ARRAY_ELEMENT *array_shift PARAMS((ARRAY *, int, int)); +extern ARRAY_ELEMENT *array_shift (ARRAY *, int, int); #else -extern ARRAY_ELEMENT **array_shift PARAMS((ARRAY *, int, int)); +extern ARRAY_ELEMENT **array_shift (ARRAY *, int, int); #endif -extern int array_rshift PARAMS((ARRAY *, int, char *)); -extern ARRAY_ELEMENT *array_unshift_element PARAMS((ARRAY *)); -extern int array_shift_element PARAMS((ARRAY *, char *)); +extern int array_rshift (ARRAY *, int, char *); +extern ARRAY_ELEMENT *array_unshift_element (ARRAY *); +extern int array_shift_element (ARRAY *, char *); -extern ARRAY *array_quote PARAMS((ARRAY *)); -extern ARRAY *array_quote_escapes PARAMS((ARRAY *)); -extern ARRAY *array_dequote PARAMS((ARRAY *)); -extern ARRAY *array_dequote_escapes PARAMS((ARRAY *)); -extern ARRAY *array_remove_quoted_nulls PARAMS((ARRAY *)); +extern ARRAY *array_quote (ARRAY *); +extern ARRAY *array_quote_escapes (ARRAY *); +extern ARRAY *array_dequote (ARRAY *); +extern ARRAY *array_dequote_escapes (ARRAY *); +extern ARRAY *array_remove_quoted_nulls (ARRAY *); -extern char *array_subrange PARAMS((ARRAY *, arrayind_t, arrayind_t, int, int, int)); -extern char *array_patsub PARAMS((ARRAY *, char *, char *, int)); -extern char *array_modcase PARAMS((ARRAY *, char *, int, int)); +extern char *array_subrange (ARRAY *, arrayind_t, arrayind_t, int, int, int); +extern char *array_patsub (ARRAY *, char *, char *, int); +extern char *array_modcase (ARRAY *, char *, int, int); /* Basic operations on array elements. */ -extern ARRAY_ELEMENT *array_create_element PARAMS((arrayind_t, char *)); -extern ARRAY_ELEMENT *array_copy_element PARAMS((ARRAY_ELEMENT *)); -extern void array_dispose_element PARAMS((ARRAY_ELEMENT *)); +extern ARRAY_ELEMENT *array_create_element (arrayind_t, char *); +extern ARRAY_ELEMENT *array_copy_element (ARRAY_ELEMENT *); +extern void array_dispose_element (ARRAY_ELEMENT *); -extern int array_insert PARAMS((ARRAY *, arrayind_t, char *)); -extern ARRAY_ELEMENT *array_remove PARAMS((ARRAY *, arrayind_t)); -extern char *array_reference PARAMS((ARRAY *, arrayind_t)); +extern int array_insert (ARRAY *, arrayind_t, char *); +extern ARRAY_ELEMENT *array_remove (ARRAY *, arrayind_t); +extern char *array_reference (ARRAY *, arrayind_t); /* Converting to and from arrays */ -extern WORD_LIST *array_to_word_list PARAMS((ARRAY *)); -extern ARRAY *array_from_word_list PARAMS((WORD_LIST *)); -extern WORD_LIST *array_keys_to_word_list PARAMS((ARRAY *)); -extern WORD_LIST *array_to_kvpair_list PARAMS((ARRAY *)); +extern WORD_LIST *array_to_word_list (ARRAY *); +extern ARRAY *array_from_word_list (WORD_LIST *); +extern WORD_LIST *array_keys_to_word_list (ARRAY *); +extern WORD_LIST *array_to_kvpair_list (ARRAY *); -extern ARRAY *array_assign_list PARAMS((ARRAY *, WORD_LIST *)); +extern ARRAY *array_assign_list (ARRAY *, WORD_LIST *); -extern char **array_to_argv PARAMS((ARRAY *, int *)); -extern ARRAY *array_from_argv PARAMS((ARRAY *, char **, int)); +extern char **array_to_argv (ARRAY *, int *); +extern ARRAY *array_from_argv (ARRAY *, char **, int); -extern char *array_to_kvpair PARAMS((ARRAY *, int)); -extern char *array_to_assign PARAMS((ARRAY *, int)); -extern char *array_to_string PARAMS((ARRAY *, char *, int)); -extern ARRAY *array_from_string PARAMS((char *, char *)); +extern char *array_to_kvpair (ARRAY *, int); +extern char *array_to_assign (ARRAY *, int); +extern char *array_to_string (ARRAY *, char *, int); +extern ARRAY *array_from_string (char *, char *); /* Flags for array_shift */ #define AS_DISPOSE 0x01 @@ -137,8 +137,8 @@ extern ARRAY *array_from_string PARAMS((char *, char *)); #define element_forw(ae) ((ae)->next) #define element_back(ae) ((ae)->prev) #else -extern arrayind_t element_forw PARAMS((ARRAY *, arrayind_t)); -extern arrayind_t element_back PARAMS((ARRAY *, arrayind_t)); +extern arrayind_t element_forw (ARRAY *, arrayind_t); +extern arrayind_t element_back (ARRAY *, arrayind_t); #endif @@ -177,6 +177,6 @@ extern arrayind_t element_back PARAMS((ARRAY *, arrayind_t)); #define ALL_ELEMENT_SUB(c) ((c) == '@' || (c) == '*') /* In eval.c, but uses ARRAY * */ -extern int execute_array_command PARAMS((ARRAY *, void *)); +extern int execute_array_command (ARRAY *, void *); #endif /* _ARRAY_H_ */ diff --git a/array2.c b/array2.c index fa8be00d6..49745cc95 100644 --- a/array2.c +++ b/array2.c @@ -9,7 +9,7 @@ * chet@ins.cwru.edu */ -/* Copyright (C) 1997-2021 Free Software Foundation, Inc. +/* Copyright (C) 1997-2023 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -47,15 +47,13 @@ #define ARRAY_MAX_DOUBLE 16777216 -static ARRAY_ELEMENT **array_copy_elements PARAMS((ARRAY *)); -static char *array_to_string_internal PARAMS((ARRAY *, arrayind_t, arrayind_t, char *, int)); +static ARRAY_ELEMENT **array_copy_elements (ARRAY *); +static char *array_to_string_internal (ARRAY *, arrayind_t, arrayind_t, char *, int); static char *spacesep = " "; void -array_alloc (a, n) -ARRAY *a; -arrayind_t n; +array_alloc (ARRAY *a, arrayind_t n) { arrayind_t i; @@ -68,9 +66,7 @@ arrayind_t n; } void -array_resize (a, n) -ARRAY *a; -arrayind_t n; +array_resize (ARRAY *a, arrayind_t n) { ARRAY_ELEMENT **e, *ae; arrayind_t i, nsize; @@ -90,9 +86,7 @@ arrayind_t n; } void -array_expand (a, n) -ARRAY *a; -arrayind_t n; +array_expand (ARRAY *a, arrayind_t n) { arrayind_t nsize; @@ -107,7 +101,7 @@ arrayind_t n; } ARRAY * -array_create() +array_create(void) { ARRAY *r; @@ -120,8 +114,7 @@ array_create() } void -array_flush (a) -ARRAY *a; +array_flush (ARRAY *a) { int r; @@ -141,8 +134,7 @@ ARRAY *a; } void -array_dispose_elements(elist) -ARRAY_ELEMENT **elist; +array_dispose_elements(ARRAY_ELEMENT **elist) { arrayind_t i; @@ -154,8 +146,7 @@ ARRAY_ELEMENT **elist; } void -array_dispose(a) -ARRAY *a; +array_dispose(ARRAY *a) { if (a == 0) return; @@ -165,8 +156,7 @@ ARRAY *a; } static ARRAY_ELEMENT ** -array_copy_elements (a) -ARRAY *a; +array_copy_elements (ARRAY *a) { ARRAY_ELEMENT **ret; arrayind_t i; @@ -180,8 +170,7 @@ ARRAY *a; } ARRAY * -array_copy(a) -ARRAY *a; +array_copy(ARRAY *a) { ARRAY *a1; @@ -203,9 +192,7 @@ ARRAY *a; * S to E, inclusive. The callers do the bounds checking. */ ARRAY * -array_slice(array, s, e) -ARRAY *array; -arrayind_t s, e; +array_slice(ARRAY *array, arrayind_t s, arrayind_t e) { ARRAY *a; ARRAY_ELEMENT *p, *n; @@ -239,10 +226,7 @@ arrayind_t s, e; * element as the argument. */ void -array_walk(a, func, udata) -ARRAY *a; -sh_ae_map_func_t *func; -void *udata; +array_walk(ARRAY *a, sh_ae_map_func_t *func, void *udata) { arrayind_t i; register ARRAY_ELEMENT *ae; @@ -266,9 +250,7 @@ void *udata; * returns NULL. */ ARRAY_ELEMENT ** -array_shift(a, n, flags) -ARRAY *a; -int n, flags; +array_shift(ARRAY *a, int n, int flags) { ARRAY_ELEMENT **r, *ae; register arrayind_t ni, ri; @@ -354,10 +336,7 @@ if (j < n) * shift. */ int -array_rshift (a, n, s) -ARRAY *a; -int n; -char *s; +array_rshift (ARRAY *a, int n, char *s) { register ARRAY_ELEMENT *ae, *new; arrayind_t ni, nsize; @@ -399,8 +378,7 @@ char *s; } ARRAY_ELEMENT * -array_unshift_element(a) -ARRAY *a; +array_unshift_element(ARRAY *a) { ARRAY_ELEMENT **r, *ret; @@ -411,16 +389,13 @@ ARRAY *a; } int -array_shift_element(a, v) -ARRAY *a; -char *v; +array_shift_element(ARRAY *a, char *v) { return (array_rshift (a, 1, v)); } ARRAY * -array_quote(array) -ARRAY *array; +array_quote(ARRAY *array) { register arrayind_t i; ARRAY_ELEMENT *a; @@ -439,8 +414,7 @@ ARRAY *array; } ARRAY * -array_quote_escapes(array) -ARRAY *array; +array_quote_escapes(ARRAY *array) { register arrayind_t i; ARRAY_ELEMENT *a; @@ -459,8 +433,7 @@ ARRAY *array; } ARRAY * -array_dequote(array) -ARRAY *array; +array_dequote(ARRAY *array) { register arrayind_t i; ARRAY_ELEMENT *a; @@ -480,8 +453,7 @@ ARRAY *array; } ARRAY * -array_dequote_escapes(array) -ARRAY *array; +array_dequote_escapes(ARRAY *array) { register arrayind_t i; ARRAY_ELEMENT *a; @@ -500,8 +472,7 @@ ARRAY *array; } ARRAY * -array_remove_quoted_nulls(array) -ARRAY *array; +array_remove_quoted_nulls(ARRAY *array) { register arrayind_t i; ARRAY_ELEMENT *a; @@ -522,10 +493,7 @@ ARRAY *array; * Since arrays are sparse, unset array elements are not counted. */ char * -array_subrange (a, start, nelem, starsub, quoted, pflags) -ARRAY *a; -arrayind_t start, nelem; -int starsub, quoted, pflags; +array_subrange (ARRAY *a, arrayind_t start, arrayind_t nelem, int starsub, int quoted, int pflags) { ARRAY *a2; arrayind_t s, e; @@ -568,10 +536,7 @@ int starsub, quoted, pflags; } char * -array_patsub (a, pat, rep, mflags) -ARRAY *a; -char *pat, *rep; -int mflags; +array_patsub (ARRAY *a, char *pat, char *rep, int mflags) { char *t; int pchar, qflags, pflags; @@ -601,11 +566,7 @@ int mflags; } char * -array_modcase (a, pat, modop, mflags) -ARRAY *a; -char *pat; -int modop; -int mflags; +array_modcase (ARRAY *a, char *pat, int modop, int mflags) { char *t; int pchar, qflags, pflags; @@ -639,9 +600,7 @@ int mflags; * VALUE. */ ARRAY_ELEMENT * -array_create_element(indx, value) -arrayind_t indx; -char *value; +array_create_element(arrayind_t indx, char *value) { ARRAY_ELEMENT *r; @@ -652,16 +611,14 @@ char *value; } ARRAY_ELEMENT * -array_copy_element(ae) -ARRAY_ELEMENT *ae; +array_copy_element(ARRAY_ELEMENT *ae) { return(ae ? array_create_element(element_index(ae), element_value(ae)) : (ARRAY_ELEMENT *) NULL); } void -array_dispose_element(ae) -ARRAY_ELEMENT *ae; +array_dispose_element(ARRAY_ELEMENT *ae) { if (ae) { FREE(ae->value); @@ -673,10 +630,7 @@ ARRAY_ELEMENT *ae; * Add a new element with index I and value V to array A (a[i] = v). */ int -array_insert(a, i, v) -ARRAY *a; -arrayind_t i; -char *v; +array_insert(ARRAY *a, arrayind_t i, char *v) { register ARRAY_ELEMENT *new, *old; arrayind_t nsize; @@ -709,9 +663,7 @@ char *v; * caller can dispose of it. */ ARRAY_ELEMENT * -array_remove(a, i) -ARRAY *a; -arrayind_t i; +array_remove(ARRAY *a, arrayind_t i) { register ARRAY_ELEMENT *ae; arrayind_t ind; @@ -746,9 +698,7 @@ arrayind_t i; * Return the value of a[i]. */ char * -array_reference(a, i) -ARRAY *a; -arrayind_t i; +array_reference(ARRAY *a, arrayind_t i) { register ARRAY_ELEMENT *ae; @@ -765,8 +715,7 @@ arrayind_t i; by the rest of the code. */ WORD_LIST * -array_to_word_list(a) -ARRAY *a; +array_to_word_list(ARRAY *a) { register arrayind_t i; WORD_LIST *list; @@ -785,8 +734,7 @@ ARRAY *a; } ARRAY * -array_from_word_list (list) -WORD_LIST *list; +array_from_word_list (WORD_LIST *list) { ARRAY *a; @@ -797,8 +745,7 @@ WORD_LIST *list; } WORD_LIST * -array_keys_to_word_list(a) -ARRAY *a; +array_keys_to_word_list(ARRAY *a) { arrayind_t ind; WORD_LIST *list; @@ -819,8 +766,7 @@ ARRAY *a; } WORD_LIST * -array_to_kvpair_list(a) -ARRAY *a; +array_to_kvpair_list (ARRAY *a) { arrayind_t ind; WORD_LIST *list; @@ -843,9 +789,7 @@ ARRAY *a; } ARRAY * -array_assign_list (array, list) -ARRAY *array; -WORD_LIST *list; +array_assign_list (ARRAY *array, WORD_LIST *list) { register WORD_LIST *l; register arrayind_t i; @@ -856,9 +800,7 @@ WORD_LIST *list; } char ** -array_to_argv (a, countp) -ARRAY *a; -int *countp; +array_to_argv (ARRAY *a, int *countp) { char **ret, *t; int i; @@ -883,10 +825,7 @@ int *countp; } ARRAY * -array_from_argv(a, vec, count) -ARRAY *a; -char **vec; -int count; +array_from_argv(ARRAY *a, char **vec, int count) { arrayind_t i; char *t; @@ -935,9 +874,7 @@ int count; * Return the next non-null array element after A[IND] */ arrayind_t -element_forw(a, ind) -ARRAY *a; -arrayind_t ind; +element_forw(ARRAY *a, arrayind_t ind) { register arrayind_t i; @@ -953,9 +890,7 @@ arrayind_t ind; * Return the previous non-null array element before A[IND] */ arrayind_t -element_back (a, ind) -ARRAY *a; -arrayind_t ind; +element_back (ARRAY *a, arrayind_t ind) { register arrayind_t i; @@ -972,11 +907,7 @@ arrayind_t ind; * to END, separated by SEP. */ static char * -array_to_string_internal (a, start, end, sep, quoted) -ARRAY *a; -arrayind_t start, end; -char *sep; -int quoted; +array_to_string_internal (ARRAY *a, arrayind_t start, arrayind_t end, char *sep, int quoted) { arrayind_t i; char *result, *t; @@ -1014,9 +945,7 @@ int quoted; } char * -array_to_kvpair (a, quoted) -ARRAY *a; -int quoted; +array_to_kvpair (ARRAY *a, int quoted) { arrayind_t ind; char *result, *valstr, *is; @@ -1071,9 +1000,7 @@ int quoted; } char * -array_to_assign (a, quoted) -ARRAY *a; -int quoted; +array_to_assign (ARRAY *a, int quoted) { arrayind_t ind; char *result, *valstr, *is; @@ -1128,10 +1055,7 @@ int quoted; } char * -array_to_string (a, sep, quoted) -ARRAY *a; -char *sep; -int quoted; +array_to_string (ARRAY *a, char *sep, int quoted) { if (a == 0) return((char *)NULL); @@ -1145,8 +1069,7 @@ int quoted; * Return an array consisting of elements in S, separated by SEP */ ARRAY * -array_from_string(s, sep) -char *s, *sep; +array_from_string(char *s, char *sep) { ARRAY *a; WORD_LIST *w; @@ -1169,8 +1092,7 @@ char *s, *sep; int interrupt_immediately = 0; int -signal_is_trapped(s) -int s; +signal_is_trapped(int s) { return 0; } @@ -1190,8 +1112,7 @@ programming_error(const char *s, ...) } WORD_DESC * -make_bare_word (s) -const char *s; +make_bare_word (const char *s) { WORD_DESC *w; @@ -1202,9 +1123,7 @@ const char *s; } WORD_LIST * -make_word_list(x, l) -WORD_DESC *x; -WORD_LIST *l; +make_word_list(WORD_DESC *x, WORD_LIST *l) { WORD_LIST *w; @@ -1215,9 +1134,7 @@ WORD_LIST *l; } WORD_LIST * -list_string(s, t, i) -char *s, *t; -int i; +list_string(char *s, char *t, int i) { char *r, *a; WORD_LIST *wl; @@ -1235,8 +1152,7 @@ int i; } GENERIC_LIST * -list_reverse (list) -GENERIC_LIST *list; +list_reverse (GENERIC_LIST *list) { register GENERIC_LIST *next, *prev; @@ -1250,22 +1166,19 @@ GENERIC_LIST *list; } char * -pat_subst(s, t, u, i) -char *s, *t, *u; -int i; +pat_subst(char *s, char *t, char *u, int i) { return ((char *)NULL); } char * -quote_string(s) -char *s; +quote_string(char *s) { return savestring(s); } -print_element(ae) -ARRAY_ELEMENT *ae; +void +print_element(ARRAY_ELEMENT *ae) { char lbuf[INT_STRLEN_BOUND (intmax_t) + 1]; @@ -1274,14 +1187,15 @@ ARRAY_ELEMENT *ae; element_value(ae)); } -print_array(a) -ARRAY *a; +void +print_array(ARRAY *a) { printf("\n"); array_walk(a, print_element, (void *)NULL); } -main() +int +main(int c, char **v) { ARRAY *a, *new_a, *copy_of_a; ARRAY_ELEMENT *ae, *aew; diff --git a/arrayfunc.c b/arrayfunc.c index 412562276..715460d59 100644 --- a/arrayfunc.c +++ b/arrayfunc.c @@ -1,6 +1,6 @@ /* arrayfunc.c -- High-level array functions used by other parts of the shell. */ -/* Copyright (C) 2001-2021 Free Software Foundation, Inc. +/* Copyright (C) 2001-2025 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -45,22 +45,19 @@ # define RBRACK ']' #endif -/* This variable means to not expand associative array subscripts more than - once, when performing variable expansion. */ -int assoc_expand_once = 0; - -/* Ditto for indexed array subscripts -- currently unused */ +/* This variable means to not expand associative or indexed array subscripts + more than once, when performing variable expansion. */ int array_expand_once = 0; -static SHELL_VAR *bind_array_var_internal PARAMS((SHELL_VAR *, arrayind_t, char *, char *, int)); -static SHELL_VAR *assign_array_element_internal PARAMS((SHELL_VAR *, char *, char *, char *, int, char *, int, array_eltstate_t *)); +static SHELL_VAR *bind_array_var_internal (SHELL_VAR *, arrayind_t, char *, const char *, int); +static SHELL_VAR *assign_array_element_internal (SHELL_VAR *, const char *, char *, char *, int, const char *, int, array_eltstate_t *); -static void assign_assoc_from_kvlist PARAMS((SHELL_VAR *, WORD_LIST *, HASH_TABLE *, int)); +static void assign_assoc_from_kvlist (SHELL_VAR *, WORD_LIST *, HASH_TABLE *, int); -static char *quote_assign PARAMS((const char *)); -static void quote_array_assignment_chars PARAMS((WORD_LIST *)); -static char *quote_compound_array_word PARAMS((char *, int)); -static char *array_value_internal PARAMS((const char *, int, int, array_eltstate_t *)); +static char *quote_assign (const char *); +static void quote_array_assignment_chars (WORD_LIST *); +static char *quote_compound_array_word (char *, int); +static char *array_value_internal (const char *, int, int, array_eltstate_t *); /* Standard error message to use when encountering an invalid array subscript */ const char * const bash_badsub_errmsg = N_("bad array subscript"); @@ -74,8 +71,7 @@ const char * const bash_badsub_errmsg = N_("bad array subscript"); /* Convert a shell variable to an array variable. The original value is saved as array[0]. */ SHELL_VAR * -convert_var_to_array (var) - SHELL_VAR *var; +convert_var_to_array (SHELL_VAR *var) { char *oldval; ARRAY *array; @@ -112,8 +108,7 @@ convert_var_to_array (var) /* Convert a shell variable to an array variable. The original value is saved as array[0]. */ SHELL_VAR * -convert_var_to_assoc (var) - SHELL_VAR *var; +convert_var_to_assoc (SHELL_VAR *var) { char *oldval; HASH_TABLE *hash; @@ -147,13 +142,28 @@ convert_var_to_assoc (var) return var; } +/* Copy the array (ARRAY *) or assoc (HASH_TABLE *) from variable V1 to V2, + and return V2. */ +SHELL_VAR * +arrayvar_copyval (SHELL_VAR *v1, SHELL_VAR *v2) +{ + FREE (value_cell (v2)); + VUNSETATTR (v2, (att_array | att_assoc)); + if (array_p (v1)) + { + var_setarray (v2, array_copy (array_cell (v1))); + VSETATTR (v2, att_array); + } + else if (assoc_p (v1)) + { + var_setassoc (v2, assoc_copy (assoc_cell (v1))); + VSETATTR (v2, att_assoc); + } + return v2; +} + char * -make_array_variable_value (entry, ind, key, value, flags) - SHELL_VAR *entry; - arrayind_t ind; - char *key; - char *value; - int flags; +make_array_variable_value (SHELL_VAR *entry, arrayind_t ind, const char *key, const char *value, int flags) { SHELL_VAR *dentry; char *newval; @@ -195,12 +205,7 @@ make_array_variable_value (entry, ind, key, value, flags) XXX - make sure that any dynamic associative array variables recreate the hash table on each assignment. BASH_CMDS and BASH_ALIASES already do this */ static SHELL_VAR * -bind_assoc_var_internal (entry, hash, key, value, flags) - SHELL_VAR *entry; - HASH_TABLE *hash; - char *key; - char *value; - int flags; +bind_assoc_var_internal (SHELL_VAR *entry, HASH_TABLE *hash, char *key, const char *value, int flags) { char *newval; @@ -208,7 +213,10 @@ bind_assoc_var_internal (entry, hash, key, value, flags) newval = make_array_variable_value (entry, 0, key, value, flags); if (entry->assign_func) - (*entry->assign_func) (entry, newval, 0, key); + { + (*entry->assign_func) (entry, newval, 0, key); + FREE (key); + } else assoc_insert (hash, key, newval); @@ -223,12 +231,7 @@ bind_assoc_var_internal (entry, hash, key, value, flags) /* Perform ENTRY[IND]=VALUE or ENTRY[KEY]=VALUE. This is not called for every assignment to an associative array; see assign_compound_array_list below. */ static SHELL_VAR * -bind_array_var_internal (entry, ind, key, value, flags) - SHELL_VAR *entry; - arrayind_t ind; - char *key; - char *value; - int flags; +bind_array_var_internal (SHELL_VAR *entry, arrayind_t ind, char *key, const char *value, int flags) { char *newval; @@ -256,11 +259,7 @@ bind_array_var_internal (entry, ind, key, value, flags) If NAME does not exist, just create an array variable, no matter what IND's value may be. */ SHELL_VAR * -bind_array_variable (name, ind, value, flags) - char *name; - arrayind_t ind; - char *value; - int flags; +bind_array_variable (const char *name, arrayind_t ind, const char *value, int flags) { SHELL_VAR *entry; @@ -277,7 +276,7 @@ bind_array_variable (name, ind, value, flags) } if (entry == (SHELL_VAR *) 0) entry = make_new_array_variable (name); - else if ((readonly_p (entry) && (flags&ASS_FORCE) == 0) || noassign_p (entry)) + else if (ASSIGN_DISALLOWED (entry, flags)) { if (readonly_p (entry)) err_readonly (name); @@ -291,24 +290,15 @@ bind_array_variable (name, ind, value, flags) } SHELL_VAR * -bind_array_element (entry, ind, value, flags) - SHELL_VAR *entry; - arrayind_t ind; - char *value; - int flags; +bind_array_element (SHELL_VAR *entry, arrayind_t ind, char *value, int flags) { return (bind_array_var_internal (entry, ind, 0, value, flags)); } SHELL_VAR * -bind_assoc_variable (entry, name, key, value, flags) - SHELL_VAR *entry; - char *name; - char *key; - char *value; - int flags; +bind_assoc_variable (SHELL_VAR *entry, const char *name, char *key, const char *value, int flags) { - if ((readonly_p (entry) && (flags&ASS_FORCE) == 0) || noassign_p (entry)) + if (ASSIGN_DISALLOWED (entry, flags)) { if (readonly_p (entry)) err_readonly (name); @@ -341,20 +331,13 @@ flush_eltstate (array_eltstate_t *estatep) assign VALUE to that array element by calling bind_array_variable(). Flags are ASS_ assignment flags */ SHELL_VAR * -assign_array_element (name, value, flags, estatep) - char *name, *value; - int flags; - array_eltstate_t *estatep; +assign_array_element (const char *name, const char *value, int flags, array_eltstate_t *estatep) { char *sub, *vname; int sublen, isassoc, avflags; SHELL_VAR *entry; - avflags = 0; - if (flags & ASS_NOEXPAND) - avflags |= AV_NOEXPAND; - if (flags & ASS_ONEWORD) - avflags |= AV_ONEWORD; + avflags = convert_assign_flags_to_arrayval_flags (flags); vname = array_variable_name (name, avflags, &sub, &sublen); if (vname == 0) @@ -391,16 +374,14 @@ assign_array_element (name, value, flags, estatep) return entry; } +/* Assign VALUE to the index computed from SUB of length SUBLEN of array + VNAME. NAME is the complete variable reference. FLAGS are ASS_ assignment + flags. ENTRY is the SHELL_VAR corresponding to VNAME. The caller + initializes ESTATEP, and we set it to the values we compute. */ static SHELL_VAR * -assign_array_element_internal (entry, name, vname, sub, sublen, value, flags, estatep) - SHELL_VAR *entry; - char *name; /* only used for error messages */ - char *vname; - char *sub; - int sublen; - char *value; - int flags; - array_eltstate_t *estatep; +assign_array_element_internal (SHELL_VAR *entry, const char *name, char *vname, + char *sub, int sublen, const char *value, + int flags, array_eltstate_t *estatep) { char *akey, *nkey; arrayind_t ind; @@ -425,6 +406,9 @@ assign_array_element_internal (entry, name, vname, sub, sublen, value, flags, es if (estatep) nkey = savestring (akey); /* assoc_insert/assoc_replace frees akey */ entry = bind_assoc_variable (entry, vname, akey, value, flags); + /* If we didn't perform the assignment, free the key we allocated */ + if (entry == 0 || (ASSIGN_DISALLOWED (entry, flags))) + FREE (akey); if (estatep) { estatep->type = ARRAY_ASSOC; @@ -434,7 +418,11 @@ assign_array_element_internal (entry, name, vname, sub, sublen, value, flags, es } else { - ind = array_expand_index (entry, sub, sublen, 0); + /* convert ASS_ flags to AV_FLAGS here */ + int avflags; + + avflags = convert_assign_flags_to_arrayval_flags (flags); + ind = array_expand_index (entry, sub, sublen, avflags); /* negative subscripts to indexed arrays count back from end */ if (entry && ind < 0) ind = (array_p (entry) ? array_max_index (array_cell (entry)) : 0) + 1 + ind; @@ -460,11 +448,10 @@ assign_array_element_internal (entry, name, vname, sub, sublen, value, flags, es convert it to an indexed array. If FLAGS&1 is non-zero, an existing variable is checked for the readonly or noassign attribute in preparation for assignment (e.g., by the `read' builtin). If FLAGS&2 is non-zero, we - create an associative array. */ + create an associative array. If FLAGS&4 is non-zero, we return noassign + variables instead of NULL because the caller wants to handle them. */ SHELL_VAR * -find_or_make_array_variable (name, flags) - char *name; - int flags; +find_or_make_array_variable (const char *name, int flags) { SHELL_VAR *var; @@ -492,10 +479,12 @@ find_or_make_array_variable (name, flags) if (var == 0) var = (flags & 2) ? make_new_assoc_variable (name) : make_new_array_variable (name); - else if ((flags & 1) && (readonly_p (var) || noassign_p (var))) + else if ((flags & 1) && ASSIGN_DISALLOWED(var, 0)) { if (readonly_p (var)) err_readonly (name); + if ((flags & 4) && noassign_p (var)) + return (var); return ((SHELL_VAR *)NULL); } else if ((flags & 2) && array_p (var)) @@ -515,9 +504,7 @@ find_or_make_array_variable (name, flags) /* Perform a compound assignment statement for array NAME, where VALUE is the text between the parens: NAME=( VALUE ) */ SHELL_VAR * -assign_array_from_string (name, value, flags) - char *name, *value; - int flags; +assign_array_from_string (const char *name, char *value, int flags) { SHELL_VAR *var; int vflags; @@ -525,10 +512,11 @@ assign_array_from_string (name, value, flags) vflags = 1; if (flags & ASS_MKASSOC) vflags |= 2; + vflags |= 4; /* we want to handle noassign variables ourselves */ var = find_or_make_array_variable (name, vflags); - if (var == 0) - return ((SHELL_VAR *)NULL); + if (var == 0 || noassign_p (var)) + return (var); return (assign_array_var_from_string (var, value, flags)); } @@ -536,10 +524,7 @@ assign_array_from_string (name, value, flags) /* Sequentially assign the indices of indexed array variable VAR from the words in LIST. */ SHELL_VAR * -assign_array_var_from_word_list (var, list, flags) - SHELL_VAR *var; - WORD_LIST *list; - int flags; +assign_array_var_from_word_list (SHELL_VAR *var, WORD_LIST *list, int flags) { register arrayind_t i; register WORD_LIST *l; @@ -549,7 +534,19 @@ assign_array_var_from_word_list (var, list, flags) i = (flags & ASS_APPEND) ? array_max_index (a) + 1 : 0; for (l = list; l; l = l->next, i++) - bind_array_var_internal (var, i, 0, l->word->word, flags & ~ASS_APPEND); + { + if (a && i < 0) /* overflow */ + { + char *num; + + num = itos (i); + report_error ("%s[%s]: %s", var->name, num, bash_badsub_errmsg); + free (num); + return (var); /* XXX */ + } + + bind_array_var_internal (var, i, 0, l->word->word, flags & ~ASS_APPEND); + } VUNSETATTR (var, att_invisible); /* no longer invisible */ @@ -557,14 +554,11 @@ assign_array_var_from_word_list (var, list, flags) } WORD_LIST * -expand_compound_array_assignment (var, value, flags) - SHELL_VAR *var; - char *value; - int flags; +expand_compound_array_assignment (SHELL_VAR *var, char *value, int flags) { WORD_LIST *list, *nlist; char *val; - int ni; + size_t ni; /* This condition is true when invoked from the declare builtin with a command like @@ -624,17 +618,22 @@ expand_compound_array_assignment (var, value, flags) } #if ASSOC_KVPAIR_ASSIGNMENT +/* If non-zero, we split the words in kv-pair compound array assignments in + addition to performing the other expansions. */ +int split_kvpair_assignments = 0; + +/* We have a set of key-value pairs that should be expanded and split + (because they are not assignment statements). They are not expanded + and split in expand_compound_array_assignment because assoc_p (var) + is true. We defer the expansion until now. */ static void -assign_assoc_from_kvlist (var, nlist, h, flags) - SHELL_VAR *var; - WORD_LIST *nlist; - HASH_TABLE *h; - int flags; +assign_assoc_from_kvlist (SHELL_VAR *var, WORD_LIST *nlist, HASH_TABLE *h, int flags) { - WORD_LIST *list; + WORD_LIST *list, *explist; char *akey, *aval, *k, *v; - for (list = nlist; list; list = list->next) + explist = split_kvpair_assignments ? expand_words_no_vars (nlist) : nlist; + for (list = explist; list; list = list->next) { k = list->word->word; v = list->next ? list->next->word->word : 0; @@ -642,7 +641,7 @@ assign_assoc_from_kvlist (var, nlist, h, flags) if (list->next) list = list->next; - akey = expand_subscript_string (k, 0); + akey = split_kvpair_assignments ? savestring (k) : expand_subscript_string (k, 0); if (akey == 0 || *akey == 0) { err_badarraysub (k); @@ -650,7 +649,7 @@ assign_assoc_from_kvlist (var, nlist, h, flags) continue; } - aval = expand_assignment_string_to_string (v, 0); + aval = split_kvpair_assignments ? savestring (v) : expand_assignment_string_to_string (v, 0); if (aval == 0) { aval = (char *)xmalloc (1); @@ -658,22 +657,24 @@ assign_assoc_from_kvlist (var, nlist, h, flags) } bind_assoc_var_internal (var, h, akey, aval, flags); + free (aval); } + + if (explist != nlist) + dispose_words (explist); } /* Return non-zero if L appears to be a key-value pair associative array compound assignment. */ int -kvpair_assignment_p (l) - WORD_LIST *l; +kvpair_assignment_p (WORD_LIST *l) { return (l && (l->word->flags & W_ASSIGNMENT) == 0 && l->word->word[0] != '['); /*]*/ } char * -expand_and_quote_kvpair_word (w) - char *w; +expand_and_quote_kvpair_word (const char *w) { char *r, *s, *t; @@ -695,17 +696,14 @@ expand_and_quote_kvpair_word (w) If this is an associative array, we perform the assignments into NHASH and set NHASH to be the value of VAR after processing the assignments in NLIST */ -void -assign_compound_array_list (var, nlist, flags) - SHELL_VAR *var; - WORD_LIST *nlist; - int flags; +int +assign_compound_array_list (SHELL_VAR *var, WORD_LIST *nlist, int flags) { ARRAY *a; HASH_TABLE *h, *nhash; WORD_LIST *list; char *w, *val, *nval, *savecmd; - int len, iflags, free_val; + int len, iflags, free_val, any_failed; arrayind_t ind, last_ind; char *akey; @@ -715,6 +713,8 @@ assign_compound_array_list (var, nlist, flags) akey = (char *)0; ind = 0; + any_failed = 0; + /* Now that we are ready to assign values to the array, kill the existing value. */ if ((flags & ASS_APPEND) == 0) @@ -725,8 +725,6 @@ assign_compound_array_list (var, nlist, flags) nhash = assoc_create (h->nbuckets); } - last_ind = (a && (flags & ASS_APPEND)) ? array_max_index (a) + 1 : 0; - #if ASSOC_KVPAIR_ASSIGNMENT if (assoc_p (var) && kvpair_assignment_p (nlist)) { @@ -738,10 +736,12 @@ assign_compound_array_list (var, nlist, flags) var_setassoc (var, nhash); assoc_dispose (h); } - return; + return 1; /* XXX - check return value */ } #endif + last_ind = (a && (flags & ASS_APPEND)) ? array_max_index (a) + 1 : 0; + for (list = nlist; list; list = list->next) { /* Don't allow var+=(values) to make assignments in VALUES append to @@ -760,10 +760,11 @@ assign_compound_array_list (var, nlist, flags) /* XXX - changes for `+=' */ if (w[len] != ']' || (w[len+1] != '=' && (w[len+1] != '+' || w[len+2] != '='))) { - if (assoc_p (var)) + if (assoc_p (var) || last_ind < 0) { err_badarraysub (w); - continue; + any_failed++; + break; } nval = make_variable_value (var, w, flags); if (var->assign_func) @@ -778,26 +779,33 @@ assign_compound_array_list (var, nlist, flags) if (len == 1) { err_badarraysub (w); - continue; + any_failed++; + break; } if (ALL_ELEMENT_SUB (w[1]) && len == 2 && array_p (var)) { set_exit_status (EXECUTION_FAILURE); report_error (_("%s: cannot assign to non-numeric index"), w); - continue; + any_failed++; + break; } if (array_p (var)) { - ind = array_expand_index (var, w + 1, len, 0); + int avflags; + + /* convert ASS_ FLAGS to AV_ flags here */ + avflags = convert_assign_flags_to_arrayval_flags (flags); + ind = array_expand_index (var, w + 1, len, avflags); /* negative subscripts to indexed arrays count back from end */ if (ind < 0) ind = array_max_index (array_cell (var)) + 1 + ind; if (ind < 0) { err_badarraysub (w); - continue; + any_failed++; + break; } last_ind = ind; @@ -813,7 +821,8 @@ assign_compound_array_list (var, nlist, flags) { err_badarraysub (w); FREE (akey); - continue; + any_failed++; + break; } } @@ -830,7 +839,8 @@ assign_compound_array_list (var, nlist, flags) { set_exit_status (EXECUTION_FAILURE); report_error (_("%s: %s: must use subscript when assigning associative array"), var->name, w); - continue; + any_failed++; + break; } else /* No [ind]=value, just a stray `=' */ { @@ -838,6 +848,16 @@ assign_compound_array_list (var, nlist, flags) val = w; } + if (array_p (var) && ind < 0) /* overflow */ + { + char *num; + + num = itos (ind); + report_error ("%s[%s]: %s", var->name, num, bash_badsub_errmsg); + free (num); + return 0; + } + free_val = 0; /* See above; we need to expand the value here */ if (assoc_p (var)) @@ -853,7 +873,7 @@ assign_compound_array_list (var, nlist, flags) savecmd = this_command_name; if (integer_p (var)) - this_command_name = (char *)NULL; /* no command name for errors */ + this_command_name = 0; /* no command name for errors */ if (assoc_p (var)) bind_assoc_var_internal (var, nhash, akey, val, iflags); else @@ -871,23 +891,36 @@ assign_compound_array_list (var, nlist, flags) var_setassoc (var, nhash); assoc_dispose (h); } + +#if ARRAY_EXPORT + if (var && exported_p (var)) + { + INVALIDATE_EXPORTSTR (var); + array_needs_making = 1; + } +#endif + + return (any_failed ? 0 : 1); } /* Perform a compound array assignment: VAR->name=( VALUE ). The - VALUE has already had the parentheses stripped. */ + VALUE has already had the parentheses stripped. FLAGS are ASS_ + assignment flags. */ SHELL_VAR * -assign_array_var_from_string (var, value, flags) - SHELL_VAR *var; - char *value; - int flags; +assign_array_var_from_string (SHELL_VAR *var, char *value, int flags) { WORD_LIST *nlist; + int aflags, r; if (value == 0) return var; nlist = expand_compound_array_assignment (var, value, flags); - assign_compound_array_list (var, nlist, flags); + /* This is where we set ASS_NOEXPAND and ASS_ONEWORD if we need to, since + expand_compound_array_assignment performs word expansions. Honors + array_expand_once; allows @ and * as associative array keys. */ + aflags = flags | (array_expand_once ? ASS_NOEXPAND : 0) | ASS_ALLOWALLSUB; + r = assign_compound_array_list (var, nlist, aflags); if (nlist) dispose_words (nlist); @@ -895,15 +928,14 @@ assign_array_var_from_string (var, value, flags) if (var) VUNSETATTR (var, att_invisible); /* no longer invisible */ - return (var); + return (r == 0 ? (SHELL_VAR *)0 : var); } /* Quote globbing chars and characters in $IFS before the `=' in an assignment statement (usually a compound array assignment) to protect them from unwanted filename expansion or word splitting. */ static char * -quote_assign (string) - const char *string; +quote_assign (const char *string) { size_t slen; int saw_eq; @@ -949,9 +981,7 @@ quote_assign (string) indexed arrays. W has already undergone word expansions. If W has no [IND]=, just single-quote and return it. */ static char * -quote_compound_array_word (w, type) - char *w; - int type; +quote_compound_array_word (char *w, int type) { char *nword, *sub, *value, *t; int ind, wlen, i; @@ -985,6 +1015,7 @@ quote_compound_array_word (w, type) if (t != w+ind) free (t); strcpy (nword + i, value); + free (value); return nword; } @@ -997,9 +1028,7 @@ quote_compound_array_word (w, type) Used for compound assignments to associative arrays that are arguments to declaration builtins (declare -A a=( list )). */ char * -expand_and_quote_assoc_word (w, type) - char *w; - int type; +expand_and_quote_assoc_word (char *w, int type) { char *nword, *key, *value, *s, *t; int ind, wlen, i; @@ -1050,9 +1079,7 @@ expand_and_quote_assoc_word (w, type) the = sign (and any `+') alone. If it's not an assignment, just single- quote the word. This is used for indexed arrays. */ void -quote_compound_array_list (list, type) - WORD_LIST *list; - int type; +quote_compound_array_list (WORD_LIST *list, int type) { char *s, *t; WORD_LIST *l; @@ -1078,8 +1105,7 @@ quote_compound_array_list (list, type) /* For each word in a compound array assignment, if the word looks like [ind]=value, quote globbing chars and characters in $IFS before the `='. */ static void -quote_array_assignment_chars (list) - WORD_LIST *list; +quote_array_assignment_chars (WORD_LIST *list) { char *nword; WORD_LIST *l; @@ -1112,14 +1138,12 @@ quote_array_assignment_chars (list) the subscript, we just assume the subscript ends with a close bracket, if one is present, and use what's inside the brackets. */ int -unbind_array_element (var, sub, flags) - SHELL_VAR *var; - char *sub; - int flags; +unbind_array_element (SHELL_VAR *var, char *sub, int flags) { arrayind_t ind; char *akey; ARRAY_ELEMENT *ae; + int avflags; /* Assume that the caller (unset_builtin) passes us a null-terminated SUB, so we don't have to use VA_ONEWORD or parse the subscript again with @@ -1176,7 +1200,9 @@ unbind_array_element (var, sub, flags) } /* Fall through for behavior 3 */ } - ind = array_expand_index (var, sub, strlen (sub) + 1, 0); + + avflags = convert_validarray_flags_to_arrayval_flags (flags); + ind = array_expand_index (var, sub, strlen (sub) + 1, avflags); /* negative subscripts to indexed arrays count back from end */ if (ind < 0) ind = array_max_index (array_cell (var)) + 1 + ind; @@ -1192,7 +1218,8 @@ unbind_array_element (var, sub, flags) else /* array_p (var) == 0 && assoc_p (var) == 0 */ { akey = this_command_name; - ind = array_expand_index (var, sub, strlen (sub) + 1, 0); + avflags = convert_validarray_flags_to_arrayval_flags (flags); + ind = array_expand_index (var, sub, strlen (sub) + 1, avflags); this_command_name = akey; if (ind == 0) { @@ -1209,9 +1236,7 @@ unbind_array_element (var, sub, flags) /* Format and output an array assignment in compound form VAR=(VALUES), suitable for re-use as input. */ void -print_array_assignment (var, quoted) - SHELL_VAR *var; - int quoted; +print_array_assignment (SHELL_VAR *var, int quoted) { char *vstr; @@ -1229,9 +1254,7 @@ print_array_assignment (var, quoted) /* Format and output an associative array assignment in compound form VAR=(VALUES), suitable for re-use as input. */ void -print_assoc_assignment (var, quoted) - SHELL_VAR *var; - int quoted; +print_assoc_assignment (SHELL_VAR *var, int quoted) { char *vstr; @@ -1254,8 +1277,6 @@ print_assoc_assignment (var, quoted) /* Return 1 if NAME is a properly-formed array reference v[sub]. */ -/* Return 1 if NAME is a properly-formed array reference v[sub]. */ - /* When NAME is a properly-formed array reference and a non-null argument SUBP is supplied, '[' and ']' that enclose the subscript are replaced by '\0', and the pointer to the subscript in NAME is assigned to *SUBP, so that NAME @@ -1264,10 +1285,7 @@ print_assoc_assignment (var, quoted) not be modified. */ /* We need to reserve 1 for FLAGS, which we pass to skipsubscript. */ int -tokenize_array_reference (name, flags, subp) - char *name; - int flags; - char **subp; +tokenize_array_reference (const char *name, int flags, char **subp) { char *t; int r, len, isassoc, ssflags; @@ -1278,7 +1296,7 @@ tokenize_array_reference (name, flags, subp) if (t) { *t = '\0'; - r = legal_identifier (name); + r = valid_identifier (name); if (flags & VA_NOEXPAND) /* Don't waste a lookup if we don't need one */ isassoc = (entry = find_variable (name)) && assoc_p (entry); *t = '['; @@ -1327,20 +1345,15 @@ tokenize_array_reference (name, flags, subp) /* We need to reserve 1 for FLAGS, which we pass to skipsubscript. */ int -valid_array_reference (name, flags) - const char *name; - int flags; +valid_array_reference (const char *name, int flags) { - return tokenize_array_reference ((char *)name, flags, (char **)NULL); + return tokenize_array_reference (name, flags, (char **)NULL); } -/* Expand the array index beginning at S and extending LEN characters. */ +/* Expand the array index beginning at S and extending LEN characters. FLAGS + are AV_ flags saying how to compute the array value. */ arrayind_t -array_expand_index (var, s, len, flags) - SHELL_VAR *var; - char *s; - int len; - int flags; +array_expand_index (SHELL_VAR *var, const char *s, int len, int flags) { char *exp, *t, *savecmd; int expok, eflag; @@ -1349,14 +1362,14 @@ array_expand_index (var, s, len, flags) exp = (char *)xmalloc (len); strncpy (exp, s, len - 1); exp[len - 1] = '\0'; -#if 0 /* TAG: maybe bash-5.2 */ +#if 0 /* XXX - not dependent on compatibility mode for now */ + if (shell_compatibility_level <= 52 || (flags & AV_NOEXPAND) == 0) +#else if ((flags & AV_NOEXPAND) == 0) +#endif t = expand_arith_string (exp, Q_DOUBLE_QUOTES|Q_ARITH|Q_ARRAYSUB); /* XXX - Q_ARRAYSUB for future use */ else t = exp; -#else - t = expand_arith_string (exp, Q_DOUBLE_QUOTES|Q_ARITH|Q_ARRAYSUB); /* XXX - Q_ARRAYSUB for future use */ -#endif savecmd = this_command_name; this_command_name = (char *)NULL; eflag = (shell_compatibility_level > 51) ? 0 : EXP_EXPANDED; @@ -1382,11 +1395,7 @@ array_expand_index (var, s, len, flags) in *SUBP. If LENP is non-null, the length of the subscript is returned in *LENP. This returns newly-allocated memory. */ char * -array_variable_name (s, flags, subp, lenp) - const char *s; - int flags; - char **subp; - int *lenp; +array_variable_name (const char *s, int flags, char **subp, int *lenp) { char *t, *ret; int ind, ni, ssflags; @@ -1436,11 +1445,7 @@ array_variable_name (s, flags, subp, lenp) non-null, return a pointer to the start of the subscript in *SUBP. If LENP is non-null, the length of the subscript is returned in *LENP. */ SHELL_VAR * -array_variable_part (s, flags, subp, lenp) - const char *s; - int flags; - char **subp; - int *lenp; +array_variable_part (const char *s, int flags, char **subp, int *lenp) { char *t; SHELL_VAR *var; @@ -1475,10 +1480,7 @@ array_variable_part (s, flags, subp, lenp) is non-null it gets 1 if the array reference is name[*], 2 if the reference is name[@], and 0 otherwise. */ static char * -array_value_internal (s, quoted, flags, estatep) - const char *s; - int quoted, flags; - array_eltstate_t *estatep; +array_value_internal (const char *s, int quoted, int flags, array_eltstate_t *estatep) { int len, isassoc, subtype; arrayind_t ind; @@ -1552,6 +1554,12 @@ array_value_internal (s, quoted, flags, estatep) retval = quote_string (temp); free (temp); } + else if (t[0] == '*' && quoted == 0 && (flags & AV_ASSIGNRHS)) + { + temp = string_list_dollar_star (l, quoted, PF_ASSIGNRHS); + retval = quote_nosplit (temp); + free (temp); + } else /* ${name[@]} or unquoted ${name[*]} */ retval = string_list_dollar_at (l, quoted, (flags & AV_ASSIGNRHS) ? PF_ASSIGNRHS : 0); @@ -1636,10 +1644,7 @@ array_value_internal (s, quoted, flags, estatep) /* Return a string containing the elements described by the array and subscript contained in S, obeying quoting for subscripts * and @. */ char * -array_value (s, quoted, flags, estatep) - const char *s; - int quoted, flags; - array_eltstate_t *estatep; +array_value (const char *s, int quoted, int flags, array_eltstate_t *estatep) { char *retval; @@ -1652,10 +1657,7 @@ array_value (s, quoted, flags, estatep) is used by other parts of the shell such as the arithmetic expression evaluator in expr.c. */ char * -get_array_value (s, flags, estatep) - const char *s; - int flags; - array_eltstate_t *estatep; +get_array_value (const char *s, int flags, array_eltstate_t *estatep) { char *retval; @@ -1664,9 +1666,7 @@ get_array_value (s, flags, estatep) } char * -array_keys (s, quoted, pflags) - char *s; - int quoted, pflags; +array_keys (const char *s, int quoted, int pflags) { int len; char *retval, *t, *temp; diff --git a/arrayfunc.h b/arrayfunc.h index 69112b579..41e4b079b 100644 --- a/arrayfunc.h +++ b/arrayfunc.h @@ -1,6 +1,6 @@ /* arrayfunc.h -- declarations for miscellaneous array functions in arrayfunc.c */ -/* Copyright (C) 2001-2021 Free Software Foundation, Inc. +/* Copyright (C) 2001-2023 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -48,11 +48,8 @@ typedef struct element_state #if defined (ARRAY_VARS) -/* This variable means to not expand associative array subscripts more than - once, when performing variable expansion. */ -extern int assoc_expand_once; - -/* The analog for indexed array subscripts */ +/* This variable means to not expand associative or indexed array subscripts + more than once, when performing variable expansion. */ extern int array_expand_once; /* Flags for array_value_internal and callers array_value/get_array_value; also @@ -73,49 +70,51 @@ extern int array_expand_once; #define VA_ONEWORD 0x002 #define VA_ALLOWALL 0x004 /* allow @ to mean all elements of the array */ -extern SHELL_VAR *convert_var_to_array PARAMS((SHELL_VAR *)); -extern SHELL_VAR *convert_var_to_assoc PARAMS((SHELL_VAR *)); +extern SHELL_VAR *convert_var_to_array (SHELL_VAR *); +extern SHELL_VAR *convert_var_to_assoc (SHELL_VAR *); + +extern SHELL_VAR *arrayvar_copyval (SHELL_VAR *, SHELL_VAR *); -extern char *make_array_variable_value PARAMS((SHELL_VAR *, arrayind_t, char *, char *, int)); +extern char *make_array_variable_value (SHELL_VAR *, arrayind_t, const char *, const char *, int); -extern SHELL_VAR *bind_array_variable PARAMS((char *, arrayind_t, char *, int)); -extern SHELL_VAR *bind_array_element PARAMS((SHELL_VAR *, arrayind_t, char *, int)); -extern SHELL_VAR *assign_array_element PARAMS((char *, char *, int, array_eltstate_t *)); +extern SHELL_VAR *bind_array_variable (const char *, arrayind_t, const char *, int); +extern SHELL_VAR *bind_array_element (SHELL_VAR *, arrayind_t, char *, int); +extern SHELL_VAR *assign_array_element (const char *, const char *, int, array_eltstate_t *); -extern SHELL_VAR *bind_assoc_variable PARAMS((SHELL_VAR *, char *, char *, char *, int)); +extern SHELL_VAR *bind_assoc_variable (SHELL_VAR *, const char *, char *, const char *, int); -extern SHELL_VAR *find_or_make_array_variable PARAMS((char *, int)); +extern SHELL_VAR *find_or_make_array_variable (const char *, int); -extern SHELL_VAR *assign_array_from_string PARAMS((char *, char *, int)); -extern SHELL_VAR *assign_array_var_from_word_list PARAMS((SHELL_VAR *, WORD_LIST *, int)); +extern SHELL_VAR *assign_array_from_string (const char *, char *, int); +extern SHELL_VAR *assign_array_var_from_word_list (SHELL_VAR *, WORD_LIST *, int); -extern WORD_LIST *expand_compound_array_assignment PARAMS((SHELL_VAR *, char *, int)); -extern void assign_compound_array_list PARAMS((SHELL_VAR *, WORD_LIST *, int)); -extern SHELL_VAR *assign_array_var_from_string PARAMS((SHELL_VAR *, char *, int)); +extern WORD_LIST *expand_compound_array_assignment (SHELL_VAR *, char *, int); +extern int assign_compound_array_list (SHELL_VAR *, WORD_LIST *, int); +extern SHELL_VAR *assign_array_var_from_string (SHELL_VAR *, char *, int); -extern char *expand_and_quote_assoc_word PARAMS((char *, int)); -extern void quote_compound_array_list PARAMS((WORD_LIST *, int)); +extern char *expand_and_quote_assoc_word (char *, int); +extern void quote_compound_array_list (WORD_LIST *, int); -extern int kvpair_assignment_p PARAMS((WORD_LIST *)); -extern char *expand_and_quote_kvpair_word PARAMS((char *)); +extern int kvpair_assignment_p (WORD_LIST *); +extern char *expand_and_quote_kvpair_word (const char *); -extern int unbind_array_element PARAMS((SHELL_VAR *, char *, int)); -extern int skipsubscript PARAMS((const char *, int, int)); +extern int unbind_array_element (SHELL_VAR *, char *, int); +extern int skipsubscript (const char *, int, int); -extern void print_array_assignment PARAMS((SHELL_VAR *, int)); -extern void print_assoc_assignment PARAMS((SHELL_VAR *, int)); +extern void print_array_assignment (SHELL_VAR *, int); +extern void print_assoc_assignment (SHELL_VAR *, int); -extern arrayind_t array_expand_index PARAMS((SHELL_VAR *, char *, int, int)); -extern int valid_array_reference PARAMS((const char *, int)); -extern int tokenize_array_reference PARAMS((char *, int, char **)); +extern arrayind_t array_expand_index (SHELL_VAR *, const char *, int, int); +extern int valid_array_reference (const char *, int); +extern int tokenize_array_reference (const char *, int, char **); -extern char *array_value PARAMS((const char *, int, int, array_eltstate_t *)); -extern char *get_array_value PARAMS((const char *, int, array_eltstate_t *)); +extern char *array_value (const char *, int, int, array_eltstate_t *); +extern char *get_array_value (const char *, int, array_eltstate_t *); -extern char *array_keys PARAMS((char *, int, int)); +extern char *array_keys (const char *, int, int); -extern char *array_variable_name PARAMS((const char *, int, char **, int *)); -extern SHELL_VAR *array_variable_part PARAMS((const char *, int, char **, int *)); +extern char *array_variable_name (const char *, int, char **, int *); +extern SHELL_VAR *array_variable_part (const char *, int, char **, int *); extern void init_eltstate (array_eltstate_t *); extern void flush_eltstate (array_eltstate_t *); @@ -137,4 +136,59 @@ extern void flush_eltstate (array_eltstate_t *); #endif +/* Functions to convert from other flag values to AV_ array variable flags */ + +#if defined (ASS_NOEXPAND) +static inline int +convert_assign_flags_to_arrayval_flags (int aflags) +{ + int avflags; + + avflags = 0; + if (aflags & ASS_NOEXPAND) + avflags |= AV_NOEXPAND; + if (aflags & ASS_ONEWORD) + avflags |= AV_ONEWORD; + if (aflags & ASS_NOEVAL) + avflags |= AV_NOEXPAND; + if (aflags & ASS_ALLOWALLSUB) + avflags |= AV_ATSTARKEYS; + return avflags; +} +#endif + +#if defined (VA_NOEXPAND) +static inline int +convert_validarray_flags_to_arrayval_flags (int vflags) +{ + int avflags; + + avflags = 0; + if (vflags & VA_NOEXPAND) + avflags |= AV_NOEXPAND; + if (vflags & VA_ONEWORD) + avflags |= AV_ONEWORD; + if (vflags & VA_ALLOWALL) + avflags |= AV_ATSTARKEYS; + return avflags; +} +#endif + +#if defined (ASS_NOEXPAND) +static inline int +convert_assign_flags_to_validarray_flags (int flags) +{ + int vflags; + + vflags = 0; + if (flags & ASS_NOEXPAND) + vflags |= VA_NOEXPAND; + if (flags & ASS_ONEWORD) + vflags |= VA_ONEWORD; + if (flags & ASS_ALLOWALLSUB) + vflags |= VA_ALLOWALL; + return vflags; +} +#endif + #endif /* !_ARRAYFUNC_H_ */ diff --git a/assoc.c b/assoc.c index cbb5c7e4f..5a8e81800 100644 --- a/assoc.c +++ b/assoc.c @@ -7,7 +7,7 @@ * chet@ins.cwru.edu */ -/* Copyright (C) 2008,2009,2011-2021 Free Software Foundation, Inc. +/* Copyright (C) 2008,2009,2011-2023 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -44,13 +44,12 @@ #include "assoc.h" #include "builtins/common.h" -static WORD_LIST *assoc_to_word_list_internal PARAMS((HASH_TABLE *, int)); +static WORD_LIST *assoc_to_word_list_internal (HASH_TABLE *, int); /* assoc_create == hash_create */ void -assoc_dispose (hash) - HASH_TABLE *hash; +assoc_dispose (HASH_TABLE *hash) { if (hash) { @@ -60,17 +59,13 @@ assoc_dispose (hash) } void -assoc_flush (hash) - HASH_TABLE *hash; +assoc_flush (HASH_TABLE *hash) { hash_flush (hash, 0); } int -assoc_insert (hash, key, value) - HASH_TABLE *hash; - char *key; - char *value; +assoc_insert (HASH_TABLE *hash, char *key, char *value) { BUCKET_CONTENTS *b; @@ -89,10 +84,7 @@ assoc_insert (hash, key, value) /* Like assoc_insert, but returns b->data instead of freeing it */ PTR_T -assoc_replace (hash, key, value) - HASH_TABLE *hash; - char *key; - char *value; +assoc_replace (HASH_TABLE *hash, char *key, char *value) { BUCKET_CONTENTS *b; PTR_T t; @@ -111,9 +103,7 @@ assoc_replace (hash, key, value) } void -assoc_remove (hash, string) - HASH_TABLE *hash; - char *string; +assoc_remove (HASH_TABLE *hash, const char *string) { BUCKET_CONTENTS *b; @@ -127,9 +117,7 @@ assoc_remove (hash, string) } char * -assoc_reference (hash, string) - HASH_TABLE *hash; - char *string; +assoc_reference (HASH_TABLE *hash, const char *string) { BUCKET_CONTENTS *b; @@ -143,8 +131,7 @@ assoc_reference (hash, string) /* Quote the data associated with each element of the hash table ASSOC, using quote_string */ HASH_TABLE * -assoc_quote (h) - HASH_TABLE *h; +assoc_quote (HASH_TABLE *h) { int i; BUCKET_CONTENTS *tlist; @@ -167,8 +154,7 @@ assoc_quote (h) /* Quote escape characters in the data associated with each element of the hash table ASSOC, using quote_escapes */ HASH_TABLE * -assoc_quote_escapes (h) - HASH_TABLE *h; +assoc_quote_escapes (HASH_TABLE *h) { int i; BUCKET_CONTENTS *tlist; @@ -189,8 +175,7 @@ assoc_quote_escapes (h) } HASH_TABLE * -assoc_dequote (h) - HASH_TABLE *h; +assoc_dequote (HASH_TABLE *h) { int i; BUCKET_CONTENTS *tlist; @@ -211,8 +196,7 @@ assoc_dequote (h) } HASH_TABLE * -assoc_dequote_escapes (h) - HASH_TABLE *h; +assoc_dequote_escapes (HASH_TABLE *h) { int i; BUCKET_CONTENTS *tlist; @@ -233,8 +217,7 @@ assoc_dequote_escapes (h) } HASH_TABLE * -assoc_remove_quoted_nulls (h) - HASH_TABLE *h; +assoc_remove_quoted_nulls (HASH_TABLE *h) { int i; BUCKET_CONTENTS *tlist; @@ -258,10 +241,7 @@ assoc_remove_quoted_nulls (h) * the STARTth element and spanning NELEM members. Null elements are counted. */ char * -assoc_subrange (hash, start, nelem, starsub, quoted, pflags) - HASH_TABLE *hash; - arrayind_t start, nelem; - int starsub, quoted, pflags; +assoc_subrange (HASH_TABLE *hash, arrayind_t start, arrayind_t nelem, int starsub, int quoted, int pflags) { WORD_LIST *l, *save, *h, *t; int i, j; @@ -296,14 +276,12 @@ assoc_subrange (hash, start, nelem, starsub, quoted, pflags) dispose_words (save); return (ret); - } +/* Substitute REP for each match of PAT in each element of hash table H, + qualified by FLAGS to say what kind of quoting to do. */ char * -assoc_patsub (h, pat, rep, mflags) - HASH_TABLE *h; - char *pat, *rep; - int mflags; +assoc_patsub (HASH_TABLE *h, char *pat, char *rep, int mflags) { char *t; int pchar, qflags, pflags; @@ -334,11 +312,7 @@ assoc_patsub (h, pat, rep, mflags) } char * -assoc_modcase (h, pat, modop, mflags) - HASH_TABLE *h; - char *pat; - int modop; - int mflags; +assoc_modcase (HASH_TABLE *h, char *pat, int modop, int mflags) { char *t; int pchar, qflags, pflags; @@ -369,9 +343,7 @@ assoc_modcase (h, pat, modop, mflags) } char * -assoc_to_kvpair (hash, quoted) - HASH_TABLE *hash; - int quoted; +assoc_to_kvpair (HASH_TABLE *hash, int quoted) { char *ret; char *istr, *vstr; @@ -439,9 +411,7 @@ assoc_to_kvpair (hash, quoted) } char * -assoc_to_assign (hash, quoted) - HASH_TABLE *hash; - int quoted; +assoc_to_assign (HASH_TABLE *hash, int quoted) { char *ret; char *istr, *vstr; @@ -508,9 +478,7 @@ assoc_to_assign (hash, quoted) } static WORD_LIST * -assoc_to_word_list_internal (h, t) - HASH_TABLE *h; - int t; +assoc_to_word_list_internal (HASH_TABLE *h, int t) { WORD_LIST *list; int i; @@ -531,22 +499,19 @@ assoc_to_word_list_internal (h, t) } WORD_LIST * -assoc_to_word_list (h) - HASH_TABLE *h; +assoc_to_word_list (HASH_TABLE *h) { return (assoc_to_word_list_internal (h, 0)); } WORD_LIST * -assoc_keys_to_word_list (h) - HASH_TABLE *h; +assoc_keys_to_word_list (HASH_TABLE *h) { return (assoc_to_word_list_internal (h, 1)); } WORD_LIST * -assoc_to_kvpair_list (h) - HASH_TABLE *h; +assoc_to_kvpair_list (HASH_TABLE *h) { WORD_LIST *list; int i; @@ -569,10 +534,7 @@ assoc_to_kvpair_list (h) } char * -assoc_to_string (h, sep, quoted) - HASH_TABLE *h; - char *sep; - int quoted; +assoc_to_string (HASH_TABLE *h, char *sep, int quoted) { BUCKET_CONTENTS *tlist; int i; diff --git a/assoc.h b/assoc.h index 664d13740..46dc0aef6 100644 --- a/assoc.h +++ b/assoc.h @@ -1,7 +1,7 @@ /* assoc.h -- definitions for the interface exported by assoc.c that allows the rest of the shell to manipulate associative array variables. */ -/* Copyright (C) 2008,2009-2021 Free Software Foundation, Inc. +/* Copyright (C) 2008,2009-2023 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -36,31 +36,31 @@ #define assoc_walk(h, f) (hash_walk((h), (f)) -extern void assoc_dispose PARAMS((HASH_TABLE *)); -extern void assoc_flush PARAMS((HASH_TABLE *)); +extern void assoc_dispose (HASH_TABLE *); +extern void assoc_flush (HASH_TABLE *); -extern int assoc_insert PARAMS((HASH_TABLE *, char *, char *)); -extern PTR_T assoc_replace PARAMS((HASH_TABLE *, char *, char *)); -extern void assoc_remove PARAMS((HASH_TABLE *, char *)); +extern int assoc_insert (HASH_TABLE *, char *, char *); +extern PTR_T assoc_replace (HASH_TABLE *, char *, char *); +extern void assoc_remove (HASH_TABLE *, const char *); -extern char *assoc_reference PARAMS((HASH_TABLE *, char *)); +extern char *assoc_reference (HASH_TABLE *, const char *); -extern char *assoc_subrange PARAMS((HASH_TABLE *, arrayind_t, arrayind_t, int, int, int)); -extern char *assoc_patsub PARAMS((HASH_TABLE *, char *, char *, int)); -extern char *assoc_modcase PARAMS((HASH_TABLE *, char *, int, int)); +extern char *assoc_subrange (HASH_TABLE *, arrayind_t, arrayind_t, int, int, int); +extern char *assoc_patsub (HASH_TABLE *, char *, char *, int); +extern char *assoc_modcase (HASH_TABLE *, char *, int, int); -extern HASH_TABLE *assoc_quote PARAMS((HASH_TABLE *)); -extern HASH_TABLE *assoc_quote_escapes PARAMS((HASH_TABLE *)); -extern HASH_TABLE *assoc_dequote PARAMS((HASH_TABLE *)); -extern HASH_TABLE *assoc_dequote_escapes PARAMS((HASH_TABLE *)); -extern HASH_TABLE *assoc_remove_quoted_nulls PARAMS((HASH_TABLE *)); +extern HASH_TABLE *assoc_quote (HASH_TABLE *); +extern HASH_TABLE *assoc_quote_escapes (HASH_TABLE *); +extern HASH_TABLE *assoc_dequote (HASH_TABLE *); +extern HASH_TABLE *assoc_dequote_escapes (HASH_TABLE *); +extern HASH_TABLE *assoc_remove_quoted_nulls (HASH_TABLE *); -extern char *assoc_to_kvpair PARAMS((HASH_TABLE *, int)); -extern char *assoc_to_assign PARAMS((HASH_TABLE *, int)); +extern char *assoc_to_kvpair (HASH_TABLE *, int); +extern char *assoc_to_assign (HASH_TABLE *, int); -extern WORD_LIST *assoc_to_word_list PARAMS((HASH_TABLE *)); -extern WORD_LIST *assoc_keys_to_word_list PARAMS((HASH_TABLE *)); -extern WORD_LIST *assoc_to_kvpair_list PARAMS((HASH_TABLE *)); +extern WORD_LIST *assoc_to_word_list (HASH_TABLE *); +extern WORD_LIST *assoc_keys_to_word_list (HASH_TABLE *); +extern WORD_LIST *assoc_to_kvpair_list (HASH_TABLE *); -extern char *assoc_to_string PARAMS((HASH_TABLE *, char *, int)); +extern char *assoc_to_string (HASH_TABLE *, char *, int); #endif /* _ASSOC_H_ */ diff --git a/bashansi.h b/bashansi.h index dd2a544cd..16772d226 100644 --- a/bashansi.h +++ b/bashansi.h @@ -1,6 +1,6 @@ /* bashansi.h -- Typically included information required by picky compilers. */ -/* Copyright (C) 1993-2021 Free Software Foundation, Inc. +/* Copyright (C) 1993-2024 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -35,4 +35,28 @@ # include "ansi_stdlib.h" #endif /* !HAVE_STDLIB_H */ +/* If bool is not a compiler builtin, prefer stdbool.h if we have it */ +#if !defined (HAVE_C_BOOL) +# if defined (HAVE_STDBOOL_H) +# include +# else +# undef bool +typedef unsigned char bool; +# define true 1 +# define false 0 +# endif +#endif + +/* Include , or define substitutes (config.h handles ptrdiff_t). */ +#ifdef HAVE_STDDEF_H +# include +#endif +/* Substitutes for definitions in stddef.h */ +#ifndef NULL +# define NULL 0 +#endif +#ifndef offsetof +# define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) +#endif + #endif /* !_BASHANSI_H_ */ diff --git a/bashhist.c b/bashhist.c index 90cd8c34f..03971c449 100644 --- a/bashhist.c +++ b/bashhist.c @@ -1,6 +1,6 @@ /* bashhist.c -- bash interface to the GNU history library. */ -/* Copyright (C) 1993-2021 Free Software Foundation, Inc. +/* Copyright (C) 1993-2024 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -68,10 +68,10 @@ extern int rl_done, rl_dispatching; /* should really include readline.h */ extern int errno; #endif -static int histignore_item_func PARAMS((struct ign *)); -static int check_history_control PARAMS((char *)); -static void hc_erasedups PARAMS((char *)); -static void really_add_history PARAMS((char *)); +static int histignore_item_func (struct ign *); +static int check_history_control (char *); +static void hc_erasedups (char *); +static void really_add_history (char *); static struct ignorevar histignore = { @@ -193,25 +193,27 @@ int hist_verify; int dont_save_function_defs; #if defined (BANG_HISTORY) -static int bash_history_inhibit_expansion PARAMS((char *, int)); +/* The usual history no-expand characters plus the shell metacharacters that + would result in an empty history event. */ +static char *bash_history_no_expand_chars = " \t\n\r=;&|()<>"; + +static int bash_history_inhibit_expansion (char *, int); #endif #if defined (READLINE) -static void re_edit PARAMS((char *)); +static void re_edit (char *); #endif -static int history_expansion_p PARAMS((char *)); -static int shell_comment PARAMS((char *)); -static int should_expand PARAMS((char *)); -static HIST_ENTRY *last_history_entry PARAMS((void)); -static char *expand_histignore_pattern PARAMS((char *)); -static int history_should_ignore PARAMS((char *)); +static int history_expansion_p (char *); +static int shell_comment (char *); +static int should_expand (char *); +static HIST_ENTRY *last_history_entry (void); +static char *expand_histignore_pattern (char *); +static int history_should_ignore (char *); #if defined (BANG_HISTORY) /* Is the history expansion starting at string[i] one that should not be expanded? */ static int -bash_history_inhibit_expansion (string, i) - char *string; - int i; +bash_history_inhibit_expansion (char *string, int i) { int t, si; char hx[2]; @@ -232,6 +234,7 @@ bash_history_inhibit_expansion (string, i) else if (i > 1 && string[i - 1] == '$' && string[i] == '!') return (1); #if defined (EXTENDED_GLOB) + /* This is on all the time now; see bash_history_no_expand_characters above */ else if (extended_glob && i > 1 && string[i+1] == '(' && member (')', string + i + 2)) return (1); #endif @@ -267,30 +270,31 @@ bash_history_inhibit_expansion (string, i) #endif void -bash_initialize_history () +bash_initialize_history (void) { history_quotes_inhibit_expansion = 1; history_search_delimiter_chars = ";&()|<>"; #if defined (BANG_HISTORY) history_inhibit_expansion_function = bash_history_inhibit_expansion; + history_no_expand_chars = bash_history_no_expand_chars; sv_histchars ("histchars"); #endif } void -bash_history_reinit (interact) - int interact; +bash_history_reinit (int interact) { #if defined (BANG_HISTORY) history_expansion = (interact == 0) ? histexp_flag : HISTEXPAND_DEFAULT; history_expansion_inhibited = (interact == 0) ? 1 - histexp_flag : 0; /* changed in bash_history_enable() */ history_inhibit_expansion_function = bash_history_inhibit_expansion; + history_no_expand_chars = bash_history_no_expand_chars; #endif remember_on_history = enable_history_list; } void -bash_history_disable () +bash_history_disable (void) { remember_on_history = 0; #if defined (BANG_HISTORY) @@ -299,12 +303,13 @@ bash_history_disable () } void -bash_history_enable () +bash_history_enable (void) { remember_on_history = enable_history_list = 1; #if defined (BANG_HISTORY) history_expansion_inhibited = 0; history_inhibit_expansion_function = bash_history_inhibit_expansion; + history_no_expand_chars = bash_history_no_expand_chars; #endif sv_history_control ("HISTCONTROL"); sv_histignore ("HISTIGNORE"); @@ -312,7 +317,7 @@ bash_history_enable () /* Load the history list from the history file. */ void -load_history () +load_history (void) { char *hf; @@ -331,7 +336,8 @@ load_history () if (hf && *hf && file_exists (hf)) { - read_history (hf); + while (read_history (hf) == EINTR) /* 0 on success */ + QUIT; /* We have read all of the lines from the history file, even if we read more lines than $HISTSIZE. Remember the total number of lines we read so we don't count the last N lines as new over and over @@ -343,7 +349,7 @@ load_history () } void -bash_clear_history () +bash_clear_history (void) { clear_history (); history_lines_this_session = 0; @@ -352,8 +358,7 @@ bash_clear_history () /* Delete and free the history list entry at offset I. */ int -bash_delete_histent (i) - int i; +bash_delete_histent (int i) { HIST_ENTRY *discard; @@ -367,8 +372,7 @@ bash_delete_histent (i) } int -bash_delete_history_range (first, last) - int first, last; +bash_delete_history_range (int first, int last) { register int i; HIST_ENTRY **discard_list; @@ -385,7 +389,7 @@ bash_delete_history_range (first, last) } int -bash_delete_last_history () +bash_delete_last_history (void) { register int i; HIST_ENTRY **hlist, *histent; @@ -412,10 +416,16 @@ bash_delete_last_history () return r; } +char * +bash_default_histfile (void) +{ + return (bash_tilde_expand (posixly_correct ? "~/.sh_history" : "~/.bash_history", 0)); +} + #ifdef INCLUDE_UNUSED /* Write the existing history out to the history file. */ void -save_history () +save_history (void) { char *hf; int r; @@ -437,8 +447,7 @@ save_history () #endif int -maybe_append_history (filename) - char *filename; +maybe_append_history (char *filename) { int fd, result, histlen; struct stat buf; @@ -452,7 +461,7 @@ maybe_append_history (filename) fd = open (filename, O_WRONLY|O_CREAT, 0600); if (fd < 0) { - builtin_error (_("%s: cannot create: %s"), filename, strerror (errno)); + builtin_error ("%s: %s: %s", filename, _("cannot create"), strerror (errno)); return (EXECUTION_FAILURE); } close (fd); @@ -476,7 +485,7 @@ maybe_append_history (filename) /* If this is an interactive shell, then append the lines executed this session to the history file. */ int -maybe_save_shell_history () +maybe_save_shell_history (void) { int result; char *hf; @@ -523,8 +532,7 @@ maybe_save_shell_history () #if defined (READLINE) /* Tell readline () that we have some text for it to edit. */ static void -re_edit (text) - char *text; +re_edit (char *text) { if (bash_input.type == st_stdin) bash_re_edit (text); @@ -533,8 +541,7 @@ re_edit (text) /* Return 1 if this line needs history expansion. */ static int -history_expansion_p (line) - char *line; +history_expansion_p (char *line) { register char *s; @@ -552,9 +559,7 @@ history_expansion_p (line) REMEMBER_ON_HISTORY can veto, and does. Right now this does history expansion. */ char * -pre_process_line (line, print_changes, addit) - char *line; - int print_changes, addit; +pre_process_line (char *line, int print_changes, int addit) { char *history_value; char *return_value; @@ -650,8 +655,7 @@ pre_process_line (line, print_changes, addit) first non-whitespace character. Return 0 if the line does not contain a comment. */ static int -shell_comment (line) - char *line; +shell_comment (char *line) { char *p; int n; @@ -672,8 +676,7 @@ shell_comment (line) /* Remove shell comments from LINE. A `#' and anything after it is a comment. This isn't really useful yet, since it doesn't handle quoting. */ static char * -filter_comments (line) - char *line; +filter_comments (char *line) { char *p; @@ -688,8 +691,7 @@ filter_comments (line) /* Check LINE against what HISTCONTROL says to do. Returns 1 if the line should be saved; 0 if it should be discarded. */ static int -check_history_control (line) - char *line; +check_history_control (char *line) { HIST_ENTRY *temp; int r; @@ -721,8 +723,7 @@ check_history_control (line) /* Remove all entries matching LINE from the history list. Triggered when HISTCONTROL includes `erasedups'. */ static void -hc_erasedups (line) - char *line; +hc_erasedups (char *line) { HIST_ENTRY *temp; int r; @@ -756,8 +757,7 @@ hc_erasedups (line) entered. We also make sure to save multiple-line quoted strings or other constructs. */ void -maybe_add_history (line) - char *line; +maybe_add_history (char *line) { int is_comment; @@ -786,9 +786,7 @@ maybe_add_history (line) history if it's OK. Used by `history -s' as well as maybe_add_history(). Returns 1 if the line was saved in the history, 0 otherwise. */ int -check_add_history (line, force) - char *line; - int force; +check_add_history (char *line, int force) { if (check_history_control (line) && history_should_ignore (line) == 0) { @@ -825,8 +823,7 @@ int syslog_history = 1; #endif void -bash_syslog_history (line) - const char *line; +bash_syslog_history (const char *line) { char trunc[SYSLOG_MAXLEN], *msg; char loghdr[SYSLOG_MAXHDR]; @@ -869,10 +866,10 @@ bash_syslog_history (line) complete parser construct, append LINE to the last history line instead of adding it as a new line. */ void -bash_add_history (line) - char *line; +bash_add_history (char *line) { - int add_it, offset, curlen, is_comment; + int add_it, offset, is_comment; + size_t curlen; HIST_ENTRY *current, *old; char *chars_to_add, *new_line; @@ -913,8 +910,8 @@ bash_add_history (line) newline, since that is what happens when the line is parsed. */ curlen = strlen (current->line); - if (dstack.delimiter_depth == 0 && current->line[curlen - 1] == '\\' && - current->line[curlen - 2] != '\\') + if (dstack.delimiter_depth == 0 && curlen > 0 && current->line[curlen - 1] == '\\' && + (curlen < 2 || current->line[curlen - 2] != '\\')) { current->line[curlen - 1] = '\0'; curlen--; @@ -925,7 +922,7 @@ bash_add_history (line) entry ends with a newline, and we're going to add a semicolon, don't. In some cases, it results in a syntax error (e.g., before a close brace), and it should not be needed. */ - if (dstack.delimiter_depth == 0 && current->line[curlen - 1] == '\n' && *chars_to_add == ';') + if (dstack.delimiter_depth == 0 && curlen > 0 && current->line[curlen - 1] == '\n' && *chars_to_add == ';') chars_to_add++; new_line = (char *)xmalloc (1 @@ -959,8 +956,7 @@ bash_add_history (line) } static void -really_add_history (line) - char *line; +really_add_history (char *line) { hist_last_line_added = 1; hist_last_line_pushed = 0; @@ -969,15 +965,14 @@ really_add_history (line) } int -history_number () +history_number (void) { using_history (); return ((remember_on_history || enable_history_list) ? history_base + where_history () : 1); } -static int -should_expand (s) - char *s; +static inline int +should_expand (char *s) { char *p; @@ -992,8 +987,7 @@ should_expand (s) } static int -histignore_item_func (ign) - struct ign *ign; +histignore_item_func (struct ign *ign) { if (should_expand (ign->val)) ign->flags |= HIGN_EXPAND; @@ -1001,14 +995,13 @@ histignore_item_func (ign) } void -setup_history_ignore (varname) - char *varname; +setup_history_ignore (const char *varname) { setup_ignore_patterns (&histignore); } static HIST_ENTRY * -last_history_entry () +last_history_entry (void) { HIST_ENTRY *he; @@ -1019,7 +1012,7 @@ last_history_entry () } char * -last_history_line () +last_history_line (void) { HIST_ENTRY *he; @@ -1030,8 +1023,7 @@ last_history_line () } static char * -expand_histignore_pattern (pat) - char *pat; +expand_histignore_pattern (char *pat) { HIST_ENTRY *phe; char *ret; @@ -1049,8 +1041,7 @@ expand_histignore_pattern (pat) /* Return 1 if we should not put LINE into the history according to the patterns in HISTIGNORE. */ static int -history_should_ignore (line) - char *line; +history_should_ignore (char *line) { register int i, match; char *npat; diff --git a/bashhist.h b/bashhist.h index 615f5d256..e3ca4fd8f 100644 --- a/bashhist.h +++ b/bashhist.h @@ -1,6 +1,6 @@ /* bashhist.h -- interface to the bash history functions in bashhist.c. */ -/* Copyright (C) 1993-2020 Free Software Foundation, Inc. +/* Copyright (C) 1993-2023 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -64,26 +64,27 @@ extern int history_expansion_inhibited; extern int double_quotes_inhibit_history_expansion; # endif /* BANG_HISTORY */ -extern void bash_initialize_history PARAMS((void)); -extern void bash_history_reinit PARAMS((int)); -extern void bash_history_disable PARAMS((void)); -extern void bash_history_enable PARAMS((void)); -extern void bash_clear_history PARAMS((void)); -extern int bash_delete_histent PARAMS((int)); -extern int bash_delete_history_range PARAMS((int, int)); -extern int bash_delete_last_history PARAMS((void)); -extern void load_history PARAMS((void)); -extern void save_history PARAMS((void)); -extern int maybe_append_history PARAMS((char *)); -extern int maybe_save_shell_history PARAMS((void)); -extern char *pre_process_line PARAMS((char *, int, int)); -extern void maybe_add_history PARAMS((char *)); -extern void bash_add_history PARAMS((char *)); -extern int check_add_history PARAMS((char *, int)); -extern int history_number PARAMS((void)); - -extern void setup_history_ignore PARAMS((char *)); - -extern char *last_history_line PARAMS((void)); +extern void bash_initialize_history (void); +extern void bash_history_reinit (int); +extern void bash_history_disable (void); +extern void bash_history_enable (void); +extern void bash_clear_history (void); +extern int bash_delete_histent (int); +extern int bash_delete_history_range (int, int); +extern int bash_delete_last_history (void); +extern void load_history (void); +extern void save_history (void); +extern char *bash_default_histfile (void); +extern int maybe_append_history (char *); +extern int maybe_save_shell_history (void); +extern char *pre_process_line (char *, int, int); +extern void maybe_add_history (char *); +extern void bash_add_history (char *); +extern int check_add_history (char *, int); +extern int history_number (void); + +extern void setup_history_ignore (const char *); + +extern char *last_history_line (void); #endif /* _BASHHIST_H_ */ diff --git a/bashline.c b/bashline.c index c85b05b69..2b4da758b 100644 --- a/bashline.c +++ b/bashline.c @@ -1,6 +1,6 @@ /* bashline.c -- Bash's interface to the readline library. */ -/* Copyright (C) 1987-2022 Free Software Foundation, Inc. +/* Copyright (C) 1987-2025 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -104,126 +104,127 @@ #define RL_BOOLEAN_VARIABLE_VALUE(s) ((s)[0] == 'o' && (s)[1] == 'n' && (s)[2] == '\0') #if defined (BRACE_COMPLETION) -extern int bash_brace_completion PARAMS((int, int)); +extern int bash_brace_completion (int, int); #endif /* BRACE_COMPLETION */ /* To avoid including curses.h/term.h/termcap.h and that whole mess. */ #ifdef _MINIX -extern int tputs PARAMS((const char *string, int nlines, void (*outx)(int))); +extern int tputs (const char *string, int nlines, void (*outx)(int)); #else -extern int tputs PARAMS((const char *string, int nlines, int (*outx)(int))); +extern int tputs (const char *string, int nlines, int (*outx)(int)); #endif /* Forward declarations */ /* Functions bound to keys in Readline for Bash users. */ -static int shell_expand_line PARAMS((int, int)); -static int display_shell_version PARAMS((int, int)); +static int shell_expand_line (int, int); +static int display_shell_version (int, int); -static int bash_ignore_filenames PARAMS((char **)); -static int bash_ignore_everything PARAMS((char **)); -static int bash_progcomp_ignore_filenames PARAMS((char **)); +static int bash_ignore_filenames (char **); +static int bash_ignore_everything (char **); +static int bash_progcomp_ignore_filenames (char **); #if defined (BANG_HISTORY) -static char *history_expand_line_internal PARAMS((char *)); -static int history_expand_line PARAMS((int, int)); -static int tcsh_magic_space PARAMS((int, int)); +static char *history_expand_line_internal (char *); +static int history_expand_line (int, int); +static int tcsh_magic_space (int, int); #endif /* BANG_HISTORY */ #ifdef ALIAS -static int alias_expand_line PARAMS((int, int)); +static int alias_expand_line (int, int); #endif #if defined (BANG_HISTORY) && defined (ALIAS) -static int history_and_alias_expand_line PARAMS((int, int)); +static int history_and_alias_expand_line (int, int); #endif -static int bash_forward_shellword PARAMS((int, int)); -static int bash_backward_shellword PARAMS((int, int)); -static int bash_kill_shellword PARAMS((int, int)); -static int bash_backward_kill_shellword PARAMS((int, int)); -static int bash_transpose_shellwords PARAMS((int, int)); +static int bash_forward_shellword (int, int); +static int bash_backward_shellword (int, int); +static int bash_kill_shellword (int, int); +static int bash_backward_kill_shellword (int, int); +static int bash_transpose_shellwords (int, int); -static int bash_spell_correct_shellword PARAMS((int, int)); +static int bash_spell_correct_shellword (int, int); /* Helper functions for Readline. */ -static char *restore_tilde PARAMS((char *, char *)); -static char *maybe_restore_tilde PARAMS((char *, char *)); - -static char *bash_filename_rewrite_hook PARAMS((char *, int)); - -static void bash_directory_expansion PARAMS((char **)); -static int bash_filename_stat_hook PARAMS((char **)); -static int bash_command_name_stat_hook PARAMS((char **)); -static int bash_directory_completion_hook PARAMS((char **)); -static int filename_completion_ignore PARAMS((char **)); -static int bash_push_line PARAMS((void)); - -static int executable_completion PARAMS((const char *, int)); - -static rl_icppfunc_t *save_directory_hook PARAMS((void)); -static void restore_directory_hook PARAMS((rl_icppfunc_t)); - -static int directory_exists PARAMS((const char *, int)); - -static void cleanup_expansion_error PARAMS((void)); -static void maybe_make_readline_line PARAMS((char *)); -static void set_up_new_line PARAMS((char *)); - -static int check_redir PARAMS((int)); -static char **attempt_shell_completion PARAMS((const char *, int, int)); -static char *variable_completion_function PARAMS((const char *, int)); -static char *hostname_completion_function PARAMS((const char *, int)); -static char *command_subst_completion_function PARAMS((const char *, int)); - -static void build_history_completion_array PARAMS((void)); -static char *history_completion_generator PARAMS((const char *, int)); -static int dynamic_complete_history PARAMS((int, int)); -static int bash_dabbrev_expand PARAMS((int, int)); - -static void initialize_hostname_list PARAMS((void)); -static void add_host_name PARAMS((char *)); -static void snarf_hosts_from_file PARAMS((char *)); -static char **hostnames_matching PARAMS((char *)); - -static void _ignore_completion_names PARAMS((char **, sh_ignore_func_t *)); -static int name_is_acceptable PARAMS((const char *)); -static int test_for_directory PARAMS((const char *)); -static int test_for_canon_directory PARAMS((const char *)); -static int return_zero PARAMS((const char *)); - -static char *bash_dequote_filename PARAMS((char *, int)); -static char *quote_word_break_chars PARAMS((char *)); -static int bash_check_expchar PARAMS((char *, int, int *, int *)); -static void set_filename_quote_chars PARAMS((int, int, int)); -static void set_filename_bstab PARAMS((const char *)); -static char *bash_quote_filename PARAMS((char *, int, char *)); +static char *restore_tilde (const char *, char *); +static char *maybe_restore_tilde (char *, char *); + +static char *bash_filename_rewrite_hook (char *, int); + +static void bash_directory_expansion (char **); +static char *bash_expand_filename (char *); +static int bash_filename_stat_hook (char **); +static int bash_command_name_stat_hook (char **); +static int bash_directory_completion_hook (char **); +static int filename_completion_ignore (char **); +static int bash_push_line (void); + +static int executable_completion (const char *, int); + +static rl_icppfunc_t *save_directory_hook (void); +static void restore_directory_hook (rl_icppfunc_t); + +static int directory_exists (const char *, int); + +static void cleanup_expansion_error (void); +static void maybe_make_readline_line (const char *); +static void set_up_new_line (char *); + +static int check_redir (int); +static char **attempt_shell_completion (const char *, int, int); +static char *variable_completion_function (const char *, int); +static char *hostname_completion_function (const char *, int); +static char *command_subst_completion_function (const char *, int); + +static void build_history_completion_array (void); +static char *history_completion_generator (const char *, int); +static int dynamic_complete_history (int, int); +static int bash_dabbrev_expand (int, int); + +static void initialize_hostname_list (void); +static void add_host_name (const char *); +static void snarf_hosts_from_file (const char *); +static char **hostnames_matching (const char *); + +static void _ignore_completion_names (char **, sh_ignore_func_t *); +static int name_is_acceptable (const char *); +static int test_for_directory (const char *); +static int test_for_canon_directory (const char *); +static int return_zero (const char *); + +static char *bash_dequote_filename (char *, int); +static char *quote_word_break_chars (char *); +static int bash_check_expchar (char *, int, int *, int *); +static void set_filename_quote_chars (int, int, int); +static void set_filename_bstab (const char *); +static char *bash_quote_filename (char *, int, char *); #ifdef _MINIX -static void putx PARAMS((int)); +static void putx (int); #else -static int putx PARAMS((int)); +static int putx (int); #endif -static int readline_get_char_offset PARAMS((int)); -static void readline_set_char_offset PARAMS((int, int *)); +static int readline_get_char_offset (int); +static void readline_set_char_offset (int, int *); -static Keymap get_cmd_xmap_from_edit_mode PARAMS((void)); -static Keymap get_cmd_xmap_from_keymap PARAMS((Keymap)); +static Keymap get_cmd_xmap_from_edit_mode (void); +static Keymap get_cmd_xmap_from_keymap (Keymap); -static void init_unix_command_map PARAMS((void)); -static int isolate_sequence PARAMS((char *, int, int, int *)); +static void init_unix_command_map (void); +static int isolate_sequence (char *, int, int, int *); -static int set_saved_history PARAMS((void)); +static int set_saved_history (void); #if defined (ALIAS) -static int posix_edit_macros PARAMS((int, int)); +static int posix_edit_macros (int, int); #endif -static int bash_event_hook PARAMS((void)); +static int bash_event_hook (void); #if defined (PROGRAMMABLE_COMPLETION) -static int find_cmd_start PARAMS((int)); -static int find_cmd_end PARAMS((int)); -static char *find_cmd_name PARAMS((int, int *, int *)); -static char *prog_complete_return PARAMS((const char *, int)); +static int find_cmd_start (int); +static int find_cmd_end (int); +static char *find_cmd_name (int, int *, int *); +static char *prog_complete_return (const char *, int); static char **prog_complete_matches; #endif @@ -239,40 +240,40 @@ extern sh_timer *read_timeout; #define SPECIFIC_COMPLETION_FUNCTIONS #if defined (SPECIFIC_COMPLETION_FUNCTIONS) -static int bash_specific_completion PARAMS((int, rl_compentry_func_t *)); - -static int bash_complete_filename_internal PARAMS((int)); -static int bash_complete_username_internal PARAMS((int)); -static int bash_complete_hostname_internal PARAMS((int)); -static int bash_complete_variable_internal PARAMS((int)); -static int bash_complete_command_internal PARAMS((int)); - -static int bash_complete_filename PARAMS((int, int)); -static int bash_possible_filename_completions PARAMS((int, int)); -static int bash_complete_username PARAMS((int, int)); -static int bash_possible_username_completions PARAMS((int, int)); -static int bash_complete_hostname PARAMS((int, int)); -static int bash_possible_hostname_completions PARAMS((int, int)); -static int bash_complete_variable PARAMS((int, int)); -static int bash_possible_variable_completions PARAMS((int, int)); -static int bash_complete_command PARAMS((int, int)); -static int bash_possible_command_completions PARAMS((int, int)); - -static int completion_glob_pattern PARAMS((char *)); -static char *glob_complete_word PARAMS((const char *, int)); -static int bash_glob_completion_internal PARAMS((int)); -static int bash_glob_complete_word PARAMS((int, int)); -static int bash_glob_expand_word PARAMS((int, int)); -static int bash_glob_list_expansions PARAMS((int, int)); +static int bash_specific_completion (int, rl_compentry_func_t *); + +static int bash_complete_filename_internal (int); +static int bash_complete_username_internal (int); +static int bash_complete_hostname_internal (int); +static int bash_complete_variable_internal (int); +static int bash_complete_command_internal (int); + +static int bash_complete_filename (int, int); +static int bash_possible_filename_completions (int, int); +static int bash_complete_username (int, int); +static int bash_possible_username_completions (int, int); +static int bash_complete_hostname (int, int); +static int bash_possible_hostname_completions (int, int); +static int bash_complete_variable (int, int); +static int bash_possible_variable_completions (int, int); +static int bash_complete_command (int, int); +static int bash_possible_command_completions (int, int); + +static int completion_glob_pattern (const char *); +static char *glob_complete_word (const char *, int); +static int bash_glob_completion_internal (int); +static int bash_glob_complete_word (int, int); +static int bash_glob_expand_word (int, int); +static int bash_glob_list_expansions (int, int); #endif /* SPECIFIC_COMPLETION_FUNCTIONS */ -static int edit_and_execute_command PARAMS((int, int, int, char *)); +static int edit_and_execute_command (int, int, int, const char *); #if defined (VI_MODE) -static int vi_edit_and_execute_command PARAMS((int, int)); -static int bash_vi_complete PARAMS((int, int)); +static int vi_edit_and_execute_command (int, int); +static int bash_vi_complete (int, int); #endif -static int emacs_edit_and_execute_command PARAMS((int, int)); +static int emacs_edit_and_execute_command (int, int); /* Non-zero once initialize_readline () has been called. */ int bash_readline_initialized = 0; @@ -328,10 +329,13 @@ static int dabbrev_expand_active = 0; COMPLETE_DQUOTE = double-quoting the filename COMPLETE_SQUOTE = single_quoting the filename COMPLETE_BSQUOTE = backslash-quoting special chars in the filename + COMPLETE_DQUOTE2 = double-quote filename, but leave $ and ` unquoted */ #define COMPLETE_DQUOTE 1 #define COMPLETE_SQUOTE 2 #define COMPLETE_BSQUOTE 3 +#define COMPLETE_DQUOTE2 4 + static int completion_quoting_style = COMPLETE_BSQUOTE; /* Flag values for the final argument to bash_default_completion */ @@ -342,8 +346,7 @@ static rl_command_func_t *vi_tab_binding = rl_complete; /* Change the readline VI-mode keymaps into or out of Posix.2 compliance. Called when the shell is put into or out of `posix' mode. */ void -posix_readline_initialize (on_or_off) - int on_or_off; +posix_readline_initialize (int on_or_off) { static char kseq[2] = { CTRL ('I'), 0 }; /* TAB */ @@ -364,7 +367,7 @@ posix_readline_initialize (on_or_off) } void -reset_completer_word_break_chars () +reset_completer_word_break_chars (void) { rl_completer_word_break_characters = perform_hostname_completion ? savestring (bash_completer_word_break_characters) : savestring (bash_nohostname_word_break_characters); } @@ -372,8 +375,7 @@ reset_completer_word_break_chars () /* When this function returns, rl_completer_word_break_characters points to dynamically allocated memory. */ int -enable_hostname_completion (on_or_off) - int on_or_off; +enable_hostname_completion (int on_or_off) { int old_value; char *nv, *nval; @@ -446,7 +448,7 @@ enable_hostname_completion (on_or_off) /* Called once from parse.y if we are going to use readline. */ void -initialize_readline () +initialize_readline (void) { rl_command_func_t *func; char kseq[2]; @@ -591,13 +593,7 @@ initialize_readline () /* Tell the completer that we want a crack first. */ rl_attempted_completion_function = attempt_shell_completion; - /* Tell the completer that we might want to follow symbolic links or - do other expansion on directory names. */ - set_directory_hook (); - - rl_filename_rewrite_hook = bash_filename_rewrite_hook; - - rl_filename_stat_hook = bash_filename_stat_hook; + bashline_set_filename_hooks (); /* Tell the filename completer we want a chance to ignore some names. */ rl_ignore_some_completions_function = filename_completion_ignore; @@ -610,6 +606,7 @@ initialize_readline () rl_bind_key_if_unbound_in_map ('@', posix_edit_macros, vi_movement_keymap); # endif + rl_add_defun ("bash-vi-complete", bash_vi_complete, -1); rl_bind_key_in_map ('\\', bash_vi_complete, vi_movement_keymap); rl_bind_key_in_map ('*', bash_vi_complete, vi_movement_keymap); rl_bind_key_in_map ('=', bash_vi_complete, vi_movement_keymap); @@ -650,19 +647,19 @@ initialize_readline () } void -bashline_reinitialize () +bashline_reinitialize (void) { bash_readline_initialized = 0; } void -bashline_set_event_hook () +bashline_set_event_hook (void) { rl_signal_event_hook = bash_event_hook; } void -bashline_reset_event_hook () +bashline_reset_event_hook (void) { rl_signal_event_hook = 0; } @@ -673,7 +670,7 @@ bashline_reset_event_hook () word. This just resets all the completion functions to the right thing. It's called from throw_to_top_level(). */ void -bashline_reset () +bashline_reset (void) { tilde_initialize (); rl_attempted_completion_function = attempt_shell_completion; @@ -684,8 +681,9 @@ bashline_reset () rl_filename_quote_characters = default_filename_quote_characters; set_filename_bstab (rl_filename_quote_characters); - set_directory_hook (); - rl_filename_stat_hook = bash_filename_stat_hook; + rl_filename_quoting_function = bash_quote_filename; + + bashline_set_filename_hooks (); bashline_reset_event_hook (); @@ -698,7 +696,7 @@ static char *push_to_readline = (char *)NULL; /* Push the contents of push_to_readline into the readline buffer. */ static int -bash_push_line () +bash_push_line (void) { if (push_to_readline) { @@ -713,8 +711,7 @@ bash_push_line () /* Call this to set the initial text for the next line to read from readline. */ int -bash_re_edit (line) - char *line; +bash_re_edit (const char *line) { FREE (push_to_readline); @@ -726,8 +723,7 @@ bash_re_edit (line) } static int -display_shell_version (count, c) - int count, c; +display_shell_version (int count, int c) { rl_crlf (); show_shell_version (0); @@ -753,17 +749,17 @@ display_shell_version (count, c) static char **hostname_list = (char **)NULL; /* The physical size of the above list. */ -static int hostname_list_size; +static size_t hostname_list_size; /* The number of hostnames in the above list. */ -static int hostname_list_length; +static size_t hostname_list_length; /* Whether or not HOSTNAME_LIST has been initialized. */ int hostname_list_initialized = 0; /* Initialize the hostname completion table. */ static void -initialize_hostname_list () +initialize_hostname_list (void) { char *temp; @@ -781,8 +777,7 @@ initialize_hostname_list () /* Add NAME to the list of hosts. */ static void -add_host_name (name) - char *name; +add_host_name (const char *name) { if (hostname_list_length + 2 > hostname_list_size) { @@ -797,14 +792,17 @@ add_host_name (name) #define cr_whitespace(c) ((c) == '\r' || (c) == '\n' || whitespace(c)) static void -snarf_hosts_from_file (filename) - char *filename; +snarf_hosts_from_file (const char *filename) { FILE *file; char *temp, buffer[256], name[256]; register int i, start; +#ifdef __MSYS__ + file = fopen (filename, "rt"); +#else file = fopen (filename, "r"); +#endif if (file == 0) return; @@ -864,7 +862,7 @@ snarf_hosts_from_file (filename) /* Return the hostname list. */ char ** -get_hostname_list () +get_hostname_list (void) { if (hostname_list_initialized == 0) initialize_hostname_list (); @@ -872,7 +870,7 @@ get_hostname_list () } void -clear_hostname_list () +clear_hostname_list (void) { register int i; @@ -887,11 +885,11 @@ clear_hostname_list () Initialize the hostname list the first time if necessary. The array is malloc ()'ed, but not the individual strings. */ static char ** -hostnames_matching (text) - char *text; +hostnames_matching (const char *text) { - register int i, len, nmatch, rsize; + int i, nmatch; char **result; + size_t rsize, len; if (hostname_list_initialized == 0) initialize_hostname_list (); @@ -919,7 +917,7 @@ hostnames_matching (text) continue; /* OK, it matches. Add it to the list. */ - if (nmatch >= (rsize - 1)) + if (nmatch + 1 >= rsize) { rsize = (rsize + 16) - (rsize % 16); result = strvec_resize (result, rsize); @@ -941,9 +939,7 @@ hostnames_matching (text) #define POSIX_VI_EDIT_COMMAND "fc -e vi" static int -edit_and_execute_command (count, c, editing_mode, edit_command) - int count, c, editing_mode; - char *edit_command; +edit_and_execute_command (int count, int c, int editing_mode, const char *edit_command) { char *command, *metaval; int r, rrs, metaflag; @@ -957,8 +953,11 @@ edit_and_execute_command (count, c, editing_mode, edit_command) if (rl_explicit_arg) { - command = (char *)xmalloc (strlen (edit_command) + 8); - sprintf (command, "%s %d", edit_command, count); + size_t clen; + /* 32 exceeds strlen (itos (INTMAX_MAX)) (19) */ + clen = strlen (edit_command) + 32; + command = (char *)xmalloc (clen); + snprintf (command, clen, "%s %d", edit_command, count); } else { @@ -1017,27 +1016,24 @@ edit_and_execute_command (count, c, editing_mode, edit_command) #if defined (VI_MODE) static int -vi_edit_and_execute_command (count, c) - int count, c; +vi_edit_and_execute_command (int count, int key) { if (posixly_correct) - return (edit_and_execute_command (count, c, VI_EDITING_MODE, POSIX_VI_EDIT_COMMAND)); + return (edit_and_execute_command (count, key, VI_EDITING_MODE, POSIX_VI_EDIT_COMMAND)); else - return (edit_and_execute_command (count, c, VI_EDITING_MODE, VI_EDIT_COMMAND)); + return (edit_and_execute_command (count, key, VI_EDITING_MODE, VI_EDIT_COMMAND)); } #endif /* VI_MODE */ static int -emacs_edit_and_execute_command (count, c) - int count, c; +emacs_edit_and_execute_command (int count, int key) { - return (edit_and_execute_command (count, c, EMACS_EDITING_MODE, EMACS_EDIT_COMMAND)); + return (edit_and_execute_command (count, key, EMACS_EDITING_MODE, EMACS_EDIT_COMMAND)); } #if defined (ALIAS) static int -posix_edit_macros (count, key) - int count, key; +posix_edit_macros (int count, int key) { int c; char alias_name[3], *alias_value, *macro; @@ -1065,8 +1061,7 @@ posix_edit_macros (count, key) #define WORDDELIM(c) (shellmeta(c) || shellblank(c)) static int -bash_forward_shellword (count, key) - int count, key; +bash_forward_shellword (int count, int key) { size_t slen; int c, p; @@ -1174,8 +1169,7 @@ bash_forward_shellword (count, key) } static int -bash_backward_shellword (count, key) - int count, key; +bash_backward_shellword (int count, int key) { size_t slen; int c, p, prev_p; @@ -1236,8 +1230,7 @@ bash_backward_shellword (count, key) } static int -bash_kill_shellword (count, key) - int count, key; +bash_kill_shellword (int count, int key) { int p; @@ -1258,8 +1251,7 @@ bash_kill_shellword (count, key) } static int -bash_backward_kill_shellword (count, key) - int count, key; +bash_backward_kill_shellword (int count, int key) { int p; @@ -1279,8 +1271,7 @@ bash_backward_kill_shellword (count, key) } static int -bash_transpose_shellwords (count, key) - int count, key; +bash_transpose_shellwords (int count, int key) { char *word1, *word2; int w1_beg, w1_end, w2_beg, w2_end; @@ -1337,16 +1328,45 @@ bash_transpose_shellwords (count, key) return 0; } -/* Directory name spelling correction on the current word (not shellword). - COUNT > 1 is not exactly correct yet. */ +/* Directory name spelling correction on the current or previous shellword. */ static int -bash_spell_correct_shellword (count, key) - int count, key; +bash_spell_correct_shellword (int count, int key) { - int opoint, wbeg, wend; + int wbeg, wend, n, p; char *text, *newdir; - opoint = rl_point; + /* If we have a negative count, move back that many shellwords and then + move forward. Do it one at a time so we get an accurate count of the + number of words we moved back -- we only want to correct that many. */ + if (count < 0) + { + n = 0; + while (rl_point > 0 && count++) + { + p = rl_point; + bash_backward_shellword (1, key); + /* We probably moved to column 0 with leading spaces on the line */ + if (rl_point == 0 && WORDDELIM (rl_line_buffer[rl_point])) + { + rl_point = p; + break; + } + n++; + } + count = n; + } + else if (WORDDELIM (rl_line_buffer[rl_point])) /* count > 0 */ + { + /* between words with a positive count, move forward to word start */ + while (rl_point < rl_end && WORDDELIM (rl_line_buffer[rl_point])) + rl_point++; /* word delims are single-byte characters */ + } + + /* First make sure we're at the end of the word we want to begin with + so the initial bash_backward_shellword works right. */ + if (rl_point < rl_end && WORDDELIM (rl_line_buffer[rl_point]) == 0) + bash_forward_shellword (1, key); + while (count) { bash_backward_shellword (1, key); @@ -1358,6 +1378,11 @@ bash_spell_correct_shellword (count, key) break; text = rl_copy_text (wbeg, wend); + if (text == 0 || *text == 0) + { + FREE (text); + break; + } newdir = dirspell (text); if (newdir) @@ -1380,7 +1405,7 @@ bash_spell_correct_shellword (count, key) count--; if (count) - bash_forward_shellword (1, key); /* XXX */ + bash_forward_shellword (1, key); /* XXX */ } return 0; @@ -1397,48 +1422,47 @@ bash_spell_correct_shellword (count, key) #define COMMAND_SEPARATORS_PLUS_WS ";|&{(` \t" /* )} */ +static inline int +check_extglob (int ti) +{ +#if defined (EXTENDED_GLOB) + int this_char, prev_char; + + this_char = rl_line_buffer[ti]; + prev_char = (ti > 0) ? rl_line_buffer[ti - 1] : 0; + + if (extended_glob && ti > 0 && this_char == '(' && /*)*/ + member (prev_char, "?*+@!") && char_is_quoted (rl_line_buffer, ti - 1) == 0) + return (1); +#endif + return (0); +} + /* check for redirections and other character combinations that are not command separators */ -static int -check_redir (ti) - int ti; +static inline int +check_redir (int ti) { - register int this_char, prev_char; + int this_char, prev_char, next_char; /* Handle the two character tokens `>&', `<&', and `>|'. We are not in a command position after one of these. */ this_char = rl_line_buffer[ti]; prev_char = (ti > 0) ? rl_line_buffer[ti - 1] : 0; + next_char = (ti < rl_end) ? rl_line_buffer[ti + 1] : 0; if ((this_char == '&' && (prev_char == '<' || prev_char == '>')) || (this_char == '|' && prev_char == '>')) return (1); - else if (this_char == '{' && prev_char == '$') /*}*/ - return (1); -#if 0 /* Not yet */ - else if (this_char == '(' && prev_char == '$') /*)*/ - return (1); - else if (this_char == '(' && prev_char == '<') /*)*/ - return (1); -#if defined (EXTENDED_GLOB) - else if (extended_glob && this_char == '(' && prev_char == '!') /*)*/ - return (1); -#endif -#endif - else if (char_is_quoted (rl_line_buffer, ti)) + else if (this_char == '{' && prev_char == '$' && FUNSUB_CHAR (next_char) == 0) /*}*/ return (1); + return (0); } #if defined (PROGRAMMABLE_COMPLETION) -/* - * XXX - because of the <= start test, and setting os = s+1, this can - * potentially return os > start. This is probably not what we want to - * happen, but fix later after 2.05a-release. - */ static int -find_cmd_start (start) - int start; +find_cmd_start (int start) { register int s, os, ns; @@ -1486,8 +1510,7 @@ find_cmd_start (start) } static int -find_cmd_end (end) - int end; +find_cmd_end (int end) { register int e; @@ -1496,9 +1519,7 @@ find_cmd_end (end) } static char * -find_cmd_name (start, sp, ep) - int start; - int *sp, *ep; +find_cmd_name (int start, int *sp, int *ep) { char *name; register int s, e; @@ -1520,9 +1541,7 @@ find_cmd_name (start, sp, ep) } static char * -prog_complete_return (text, matchnum) - const char *text; - int matchnum; +prog_complete_return (const char *text, int matchnum) { static int ind; @@ -1539,9 +1558,7 @@ prog_complete_return (text, matchnum) /* Try and catch completion attempts that are syntax errors or otherwise invalid. */ static int -invalid_completion (text, ind) - const char *text; - int ind; +invalid_completion (const char *text, int ind) { int pind; @@ -1567,9 +1584,7 @@ invalid_completion (text, ind) /* Do some completion on TEXT. The indices of TEXT in RL_LINE_BUFFER are at START and END. Return an array of matches, or NULL if none. */ static char ** -attempt_shell_completion (text, start, end) - const char *text; - int start, end; +attempt_shell_completion (const char *text, int start, int end) { int in_command_position, ti, qc, dflags; char **matches, *command_separator_chars; @@ -1585,8 +1600,7 @@ attempt_shell_completion (text, start, end) complete_fullquote = 1; /* full filename quoting by default */ rl_filename_quote_characters = default_filename_quote_characters; set_filename_bstab (rl_filename_quote_characters); - set_directory_hook (); - rl_filename_stat_hook = bash_filename_stat_hook; + bashline_set_filename_hooks (); rl_sort_completion_matches = 1; /* sort by default */ @@ -1624,9 +1638,13 @@ attempt_shell_completion (text, start, end) } else if (member (rl_line_buffer[ti], command_separator_chars)) { - in_command_position++; + if (char_is_quoted (rl_line_buffer, ti) == 0) + in_command_position++; - if (check_redir (ti) == 1) + if (in_command_position && rl_line_buffer[ti] == '(' && check_extglob (ti) == 1) /*)*/ + in_command_position = -1; + + if (in_command_position && check_redir (ti) == 1) in_command_position = -1; /* sentinel that we're not the first word on the line */ } else @@ -1693,6 +1711,10 @@ attempt_shell_completion (text, start, end) s1 = s = e1; break; } + else if (s > e) + { + s = s1 = start; e = e1 = end; /* reset */ + } /* Skip over assignment statements preceding a command name. If we don't find a command name at all, we can perform command name completion. If we find a partial command name, we should perform @@ -1712,10 +1734,12 @@ attempt_shell_completion (text, start, end) end == index of where word to be completed ends if (s == start) we are doing command word completion for sure if (e1 == end) we are at the end of the command name and completing it */ - if (start == 0 && end == 0 && e != 0 && text[0] == '\0') /* beginning of non-empty line */ + if (start == 0 && end == 0 && e != 0 && e1 < rl_end && text[0] == '\0') /* beginning of non-empty line */ foundcs = 0; else if (start == end && start == s1 && e != 0 && e1 > end) /* beginning of command name, leading whitespace */ foundcs = 0; + else if (start == 0 && start == end && start < s1 && e != 0 && e1 > end && text[0] == '\0' && have_progcomps) /* no command name, leading whitespace only */ + prog_complete_matches = programmable_completions (EMPTYCMD, text, s, e, &foundcs); else if (e == 0 && e == s && text[0] == '\0' && have_progcomps) /* beginning of empty line */ prog_complete_matches = programmable_completions (EMPTYCMD, text, s, e, &foundcs); else if (start == end && text[0] == '\0' && s1 > start && whitespace (rl_line_buffer[start])) @@ -1759,7 +1783,14 @@ attempt_shell_completion (text, start, end) /* If we have defined a compspec for the initial (command) word, call it and process the results like any other programmable completion. */ if (in_command_position && have_progcomps && foundcs == 0 && iw_compspec) - prog_complete_matches = programmable_completions (INITIALWORD, text, s, e, &foundcs); + { + /* Do some sanity checking on S and E. Room for more here. */ + if (s > rl_point) + s = rl_point; + if (e > rl_end) + e = rl_end; + prog_complete_matches = programmable_completions (INITIALWORD, text, s, e, &foundcs); + } FREE (n); /* XXX - if we found a COMPSPEC for the command, just return whatever @@ -1794,9 +1825,7 @@ attempt_shell_completion (text, start, end) } char ** -bash_default_completion (text, start, end, qc, compflags) - const char *text; - int start, end, qc, compflags; +bash_default_completion (const char *text, int start, int end, int qc, int compflags) { char **matches, *t; @@ -1807,6 +1836,8 @@ bash_default_completion (text, start, end, qc, compflags) { if (qc != '\'' && text[1] == '(') /* ) */ matches = rl_completion_matches (text, command_subst_completion_function); + else if (qc != '\'' && text[1] == '{' && FUNSUB_CHAR (text[2])) /* } */ + matches = rl_completion_matches (text, command_subst_completion_function); else { matches = rl_completion_matches (text, variable_completion_function); @@ -1873,7 +1904,12 @@ bash_default_completion (text, start, end, qc, compflags) rl_completion_suppress_append = 1; rl_filename_completion_desired = 0; } +#if 1 + else if (matches[0] && matches[1] && STREQ (matches[0], matches[1]) && + matches[2] && STREQ (matches[1], matches[2]) && CMD_IS_DIR (matches[0])) +#else else if (matches[0] && matches[1] && STREQ (matches[0], matches[1]) && CMD_IS_DIR (matches[0])) +#endif /* There are multiple instances of the same match (duplicate completions haven't yet been removed). In this case, all of the matches will be the same, and the duplicate removal code @@ -1891,7 +1927,7 @@ bash_default_completion (text, start, end, qc, compflags) /* This could be a globbing pattern, so try to expand it using pathname expansion. */ - if (!matches && completion_glob_pattern ((char *)text)) + if (!matches && completion_glob_pattern (text)) { matches = rl_completion_matches (text, glob_complete_word); /* A glob expression that matches more than one filename is problematic. @@ -1901,19 +1937,28 @@ bash_default_completion (text, start, end, qc, compflags) strvec_dispose (matches); matches = (char **)0; } - else if (matches && matches[1] && rl_completion_type == '!') + else if (matches && matches[1] && (rl_completion_type == '!' || rl_completion_type == '@')) { rl_completion_suppress_append = 1; rl_filename_completion_desired = 0; } + else if (matches && matches[1] && rl_completion_type == '?') + { + size_t ind; + ind = (end > start) ? end - start - 1 : 0; + if (text[ind] == '/') + { + rl_completion_suppress_append = 1; + rl_filename_completion_desired = 0; + } + } } return (matches); } static int -bash_command_name_stat_hook (name) - char **name; +bash_command_name_stat_hook (char **name) { char *cname, *result; @@ -1928,6 +1973,7 @@ bash_command_name_stat_hook (name) result = search_for_command (cname, 0); if (result) { + FREE (*name); *name = result; return 1; } @@ -1935,21 +1981,15 @@ bash_command_name_stat_hook (name) } static int -executable_completion (filename, searching_path) - const char *filename; - int searching_path; +executable_completion (const char *filename, int searching_path) { char *f, c; int r; /* This gets an unquoted filename, so we need to quote special characters in the filename before the completion hook gets it. */ -#if 0 - f = savestring (filename); -#else c = 0; f = bash_quote_filename ((char *)filename, SINGLE_MATCH, &c); -#endif bash_directory_completion_hook (&f); r = searching_path ? executable_file (f) : executable_or_directory (f); @@ -1962,9 +2002,7 @@ executable_completion (filename, searching_path) that match. It also scans aliases, function names, and the shell_builtin table. */ char * -command_word_completion_function (hint_text, state) - const char *hint_text; - int state; +command_word_completion_function (const char *hint_text, int state) { static char *hint = (char *)NULL; static char *path = (char *)NULL; @@ -1974,10 +2012,12 @@ command_word_completion_function (hint_text, state) static char *dequoted_hint = (char *)NULL; static char *directory_part = (char *)NULL; static char **glob_matches = (char **)NULL; - static int path_index, hint_len, istate, igncase; + static int path_index, istate, igncase; + static size_t hint_len; static int mapping_over, local_index, searching_path, hint_is_dir; static int old_glob_ignore_case, globpat; static SHELL_VAR **varlist = (SHELL_VAR **)NULL; + static int orig_found_quote; #if defined (ALIAS) static alias_t **alias_list = (alias_t **)NULL; #endif /* ALIAS */ @@ -1993,6 +2033,7 @@ command_word_completion_function (hint_text, state) free (dequoted_hint); if (hint) free (hint); + dequoted_hint = hint = (char *)NULL; mapping_over = searching_path = 0; hint_is_dir = CMD_IS_DIR (hint_text); @@ -2009,7 +2050,13 @@ command_word_completion_function (hint_text, state) glob_matches = (char **)NULL; } - globpat = completion_glob_pattern ((char *)hint_text); + if (directory_part) + { + free (directory_part); + directory_part = (char *)NULL; + } + + globpat = completion_glob_pattern (hint_text); /* If this is an absolute program name, do not check it against aliases, reserved words, functions or builtins. We must check @@ -2086,8 +2133,10 @@ command_word_completion_function (hint_text, state) if (rl_completion_found_quote && rl_completion_quote_character == 0) dequoted_hint = bash_dequote_filename (hint, 0); - - path = get_string_value ("PATH"); + + orig_found_quote = rl_completion_found_quote; + + path = path_value ("PATH", 0); path_index = dot_in_path = 0; /* Initialize the variables for each type of command word. */ @@ -2203,7 +2252,11 @@ globword: local_index = 0; if (glob_matches[1] && rl_completion_type == TAB) /* multiple matches are bad */ - return ((char *)NULL); + { + strvec_dispose (glob_matches); + glob_matches = (char **)NULL; + return ((char *)NULL); + } } while (val = glob_matches[local_index++]) @@ -2246,6 +2299,8 @@ globword: { char *current_path; + rl_completion_found_quote = orig_found_quote; + /* Get the next directory from the path. If there is none, then we are all done. */ if (path == 0 || path[path_index] == 0 || @@ -2275,14 +2330,30 @@ globword: free (fnhint); if (filename_hint) free (filename_hint); + fnhint = filename_hint = (char *)NULL; - filename_hint = sh_makepath (current_path, hint, 0); + /* We can have characters that need to be quoted in either the $PATH + element or the dequoted filename. Since we only want to call a + quoting function on the entire path once, and we've already dequoted + the hint text we were passed (dequoted_hint), build the path using + the dequoted hint text and quote it if we need to. Readline will only + call the dequoting function if rl_completion_found_quote != 0, so + we have to force it. */ + + filename_hint = sh_makepath (current_path, dequoted_hint, 0); /* Need a quoted version (though it doesn't matter much in most cases) because rl_filename_completion_function dequotes the filename it gets, assuming that it's been quoted as part of the input line buffer. */ +#if 1 if (strpbrk (filename_hint, "\"'\\")) - fnhint = sh_backslash_quote (filename_hint, filename_bstab, 0); +#else + if (strpbrk (filename_hint, rl_filename_quote_characters)) +#endif + { + fnhint = sh_backslash_quote (filename_hint, filename_bstab, 0); + rl_completion_found_quote = 4; /* just has to be non-zero */ + } else fnhint = filename_hint; free (current_path); /* XXX */ @@ -2336,10 +2407,20 @@ globword: if (temp) { temp++; +#if 0 + /* We're comparing an unquoted filename read from the directory + (temp, returned by rl_filename_completion_function) against + the possibly-quoted hint text. We should compare against + the dequoted hint text. */ if (igncase == 0) freetemp = match = strncmp (temp, hint, hint_len) == 0; else freetemp = match = strncasecmp (temp, hint, hint_len) == 0; +#else + /* Why duplicate the comparison rl_filename_completion_function + already performs? */ + freetemp = match = 1; +#endif if (match) temp = savestring (temp); } @@ -2370,6 +2451,7 @@ globword: t1 = make_absolute (val, t); free (t); cval = sh_canonpath (t1, PATH_CHECKDOTDOT|PATH_CHECKEXISTS); + free (t1); } else #endif @@ -2397,9 +2479,7 @@ globword: /* Completion inside an unterminated command substitution. */ static char * -command_subst_completion_function (text, state) - const char *text; - int state; +command_subst_completion_function (const char *text, int state) { static char **matches = (char **)NULL; static const char *orig_start; @@ -2416,13 +2496,18 @@ command_subst_completion_function (text, state) text++; else if (*text == '$' && text[1] == '(') /* ) */ text += 2; + else if (*text == '$' && text[1] == '{' && FUNSUB_CHAR (text[2])) /*}*/ + text += 3; /* nofork command substitution */ /* If the text was quoted, suppress any quote character that the readline completion code would insert. */ rl_completion_suppress_quote = 1; start_len = text - orig_start; filename_text = savestring (text); if (matches) - free (matches); + { + strvec_dispose (matches); + matches = (char **)NULL; + } /* * At this point we can entertain the idea of re-parsing @@ -2480,9 +2565,7 @@ command_subst_completion_function (text, state) /* Okay, now we write the entry_function for variable completion. */ static char * -variable_completion_function (text, state) - const char *text; - int state; +variable_completion_function (const char *text, int state) { static char **varlist = (char **)NULL; static int varlist_index; @@ -2540,9 +2623,7 @@ variable_completion_function (text, state) /* How about a completion function for hostnames? */ static char * -hostname_completion_function (text, state) - const char *text; - int state; +hostname_completion_function (const char *text, int state) { static char **list = (char **)NULL; static int list_index = 0; @@ -2583,16 +2664,14 @@ hostname_completion_function (text, state) * A completion function for service names from /etc/services (or wherever). */ char * -bash_servicename_completion_function (text, state) - const char *text; - int state; +bash_servicename_completion_function (const char *text, int state) { #if defined (__WIN32__) || defined (__OPENNT) || !defined (HAVE_GETSERVENT) return ((char *)NULL); #else static char *sname = (char *)NULL; static struct servent *srvent; - static int snamelen; + static size_t snamelen; char *value; char **alist, *aentry; int afound; @@ -2641,16 +2720,14 @@ bash_servicename_completion_function (text, state) * A completion function for group names from /etc/group (or wherever). */ char * -bash_groupname_completion_function (text, state) - const char *text; - int state; +bash_groupname_completion_function (const char *text, int state) { #if defined (__WIN32__) || defined (__OPENNT) || !defined (HAVE_GRP_H) return ((char *)NULL); #else static char *gname = (char *)NULL; static struct group *grent; - static int gnamelen; + static size_t gnamelen; char *value; if (state == 0) @@ -2686,8 +2763,7 @@ bash_groupname_completion_function (text, state) is done, pre_process_line() returns what it was passed, so we need to allocate a new line here. */ static char * -history_expand_line_internal (line) - char *line; +history_expand_line_internal (char *line) { char *new_line; int old_verify; @@ -2704,7 +2780,7 @@ history_expand_line_internal (line) /* There was an error in expansion. Let the preprocessor print the error here. */ static void -cleanup_expansion_error () +cleanup_expansion_error (void) { char *to_free; #if defined (BANG_HISTORY) @@ -2729,8 +2805,7 @@ cleanup_expansion_error () undo record to get from the readline line buffer contents to the new line and make NEW_LINE the current readline line. */ static void -maybe_make_readline_line (new_line) - char *new_line; +maybe_make_readline_line (const char *new_line) { if (new_line && strcmp (new_line, rl_line_buffer) != 0) { @@ -2744,15 +2819,27 @@ maybe_make_readline_line (new_line) } } -/* Make NEW_LINE be the current readline line. This frees NEW_LINE. */ +/* Make NEW_LINE be the current readline line. This frees NEW_LINE. We use + several heuristics to decide where to put rl_point. */ + static void -set_up_new_line (new_line) - char *new_line; +set_up_new_line (char *new_line) { - int old_point, at_end; + + int old_point, old_end, dist, nb; + char *s, *t; + + /* If we didn't expand anything, don't change anything. */ + if (STREQ (new_line, rl_line_buffer)) + { + free (new_line); + return; + } old_point = rl_point; - at_end = rl_point == rl_end; + old_end = rl_end; + dist = rl_end - rl_point; + nb = rl_end - old_end; /* If the line was history and alias expanded, then make that be one thing to undo. */ @@ -2760,21 +2847,37 @@ set_up_new_line (new_line) free (new_line); /* Place rl_point where we think it should go. */ - if (at_end) + if (dist == 0) rl_point = rl_end; - else if (old_point < rl_end) + else if (old_point == 0) + { + /* this is what the old code did, but separate it out so we can treat + it differently */ + rl_point = 0; + if (!whitespace (rl_line_buffer[rl_point])) + rl_forward_word (1, 0); + } + else if (rl_point < old_point+nb) { + /* let's assume that this means the new point is within the changed region */ rl_point = old_point; if (!whitespace (rl_line_buffer[rl_point])) rl_forward_word (1, 0); } + else + rl_point = rl_end - dist; /* try to put point the same distance from end */ + + if (rl_point < 0) + rl_point = 0; + else if (rl_point > rl_end) + rl_point = rl_end; + rl_mark = 0; /* XXX */ } #if defined (ALIAS) /* Expand aliases in the current readline line. */ static int -alias_expand_line (count, ignore) - int count, ignore; +alias_expand_line (int count, int ignore) { char *new_line; @@ -2796,8 +2899,7 @@ alias_expand_line (count, ignore) #if defined (BANG_HISTORY) /* History expand the line. */ static int -history_expand_line (count, ignore) - int count, ignore; +history_expand_line (int count, int ignore) { char *new_line; @@ -2818,8 +2920,7 @@ history_expand_line (count, ignore) /* Expand history substitutions in the current line and then insert a space (hopefully close to where we were before). */ static int -tcsh_magic_space (count, ignore) - int count, ignore; +tcsh_magic_space (int count, int ignore) { int dist_from_end, old_point; @@ -2841,10 +2942,9 @@ tcsh_magic_space (count, ignore) /* History and alias expand the line. */ static int -history_and_alias_expand_line (count, ignore) - int count, ignore; +history_and_alias_expand_line (int count, int ignore) { - char *new_line, *t; + char *new_line; new_line = 0; #if defined (BANG_HISTORY) @@ -2879,8 +2979,7 @@ history_and_alias_expand_line (count, ignore) because we want the variable expansions as a separate undo'able set of operations. */ static int -shell_expand_line (count, ignore) - int count, ignore; +shell_expand_line (int count, int ignore) { char *new_line, *t; WORD_LIST *expanded_string; @@ -2981,14 +3080,15 @@ static struct ignorevar fignore = }; static void -_ignore_completion_names (names, name_func) - char **names; - sh_ignore_func_t *name_func; +_ignore_completion_names (char **names, sh_ignore_func_t *name_func) { char **newnames; - int idx, nidx; + size_t idx, nidx; char **oldnames; - int oidx; + int oidx, allow_empty; + + /* allow_empty is used to make force_fignore apply only to FIGNORE completions. */ + allow_empty = (name_func == name_is_acceptable) ? force_fignore : 1; /* If there is only one completion, see if it is acceptable. If it is not, free it up. In any case, short-circuit and return. This is a @@ -2996,7 +3096,7 @@ _ignore_completion_names (names, name_func) if there is only one completion; it is the completion itself. */ if (names[1] == (char *)0) { - if (force_fignore) + if (allow_empty) if ((*name_func) (names[0]) == 0) { free (names[0]); @@ -3012,7 +3112,7 @@ _ignore_completion_names (names, name_func) ; newnames = strvec_create (nidx + 1); - if (force_fignore == 0) + if (allow_empty == 0) { oldnames = strvec_create (nidx - 1); oidx = 0; @@ -3023,7 +3123,7 @@ _ignore_completion_names (names, name_func) { if ((*name_func) (names[idx])) newnames[nidx++] = names[idx]; - else if (force_fignore == 0) + else if (allow_empty == 0) oldnames[oidx++] = names[idx]; else free (names[idx]); @@ -3034,7 +3134,7 @@ _ignore_completion_names (names, name_func) /* If none are acceptable then let the completer handle it. */ if (nidx == 1) { - if (force_fignore) + if (allow_empty) { free (names[0]); names[0] = (char *)NULL; @@ -3046,7 +3146,7 @@ _ignore_completion_names (names, name_func) return; } - if (force_fignore == 0) + if (allow_empty == 0) { while (oidx) free (oldnames[--oidx]); @@ -3072,15 +3172,14 @@ _ignore_completion_names (names, name_func) } static int -name_is_acceptable (name) - const char *name; +name_is_acceptable (const char *name) { struct ign *p; - int nlen; + size_t nlen; for (nlen = strlen (name), p = fignore.ignores; p->val; p++) { - if (nlen > p->len && p->len > 0 && STREQ (p->val, &name[nlen - p->len])) + if (nlen >= p->len && p->len > 0 && STREQ (p->val, &name[nlen - p->len])) return (0); } @@ -3089,16 +3188,14 @@ name_is_acceptable (name) #if 0 static int -ignore_dot_names (name) - char *name; +ignore_dot_names (const char *name) { return (name[0] != '.'); } #endif static int -filename_completion_ignore (names) - char **names; +filename_completion_ignore (char **names) { #if 0 if (glob_dot_filenames == 0) @@ -3117,13 +3214,25 @@ filename_completion_ignore (names) /* Return 1 if NAME is a directory. NAME undergoes tilde expansion. */ static int -test_for_directory (name) - const char *name; +test_for_directory (const char *name) { char *fn; int r; fn = bash_tilde_expand (name, 0); + +#if __CYGWIN + /* stat("//server") can only be successful as a directory, but can take + seconds to time out on failure. It is much faster to assume that + "//server" is a valid name than it is to wait for a stat, even if it + gives false positives on bad names. */ + if (fn[0] == '/' && fn[1] == '/' && ! strchr (&fn[2], '/')) + { + free (fn); + return 1; + } +#endif + r = file_isdir (fn); free (fn); @@ -3131,8 +3240,7 @@ test_for_directory (name) } static int -test_for_canon_directory (name) - const char *name; +test_for_canon_directory (const char *name) { char *fn; int r; @@ -3147,31 +3255,27 @@ test_for_canon_directory (name) /* Remove files from NAMES, leaving directories. */ static int -bash_ignore_filenames (names) - char **names; +bash_ignore_filenames (char **names) { _ignore_completion_names (names, test_for_directory); return 0; } static int -bash_progcomp_ignore_filenames (names) - char **names; +bash_progcomp_ignore_filenames (char **names) { _ignore_completion_names (names, test_for_canon_directory); return 0; } static int -return_zero (name) - const char *name; +return_zero (const char *name) { return 0; } static int -bash_ignore_everything (names) - char **names; +bash_ignore_everything (char **names) { _ignore_completion_names (names, return_zero); return 0; @@ -3181,10 +3285,9 @@ bash_ignore_everything (names) is an expanded filename. DIRECTORY_PART is the tilde-prefix portion of the un-tilde-expanded version of VAL (what the user typed). */ static char * -restore_tilde (val, directory_part) - char *val, *directory_part; +restore_tilde (const char *val, char *directory_part) { - int l, vl, dl2, xl; + size_t l, vl, dl2, xl; char *dh2, *expdir, *ret, *v; vl = strlen (val); @@ -3238,8 +3341,7 @@ restore_tilde (val, directory_part) } static char * -maybe_restore_tilde (val, directory_part) - char *val, *directory_part; +maybe_restore_tilde (char *val, char *directory_part) { rl_icppfunc_t *save; char *ret; @@ -3255,8 +3357,7 @@ maybe_restore_tilde (val, directory_part) rl_filename_completion_function. This must be called with the address of a pointer to malloc'd memory. */ static void -bash_directory_expansion (dirname) - char **dirname; +bash_directory_expansion (char **dirname) { char *d, *nd; @@ -3285,9 +3386,7 @@ bash_directory_expansion (dirname) /* If necessary, rewrite directory entry */ static char * -bash_filename_rewrite_hook (fname, fnlen) - char *fname; - int fnlen; +bash_filename_rewrite_hook (char *fname, int fnlen) { char *conv; @@ -3300,7 +3399,7 @@ bash_filename_rewrite_hook (fname, fnlen) /* Functions to save and restore the appropriate directory hook */ /* This is not static so the shopt code can call it */ void -set_directory_hook () +set_directory_hook (void) { if (dircomplete_expand) { @@ -3315,7 +3414,7 @@ set_directory_hook () } static rl_icppfunc_t * -save_directory_hook () +save_directory_hook (void) { rl_icppfunc_t *ret; @@ -3334,8 +3433,7 @@ save_directory_hook () } static void -restore_directory_hook (hookf) - rl_icppfunc_t *hookf; +restore_directory_hook (rl_icppfunc_t *hookf) { if (dircomplete_expand) rl_directory_completion_hook = hookf; @@ -3343,12 +3441,24 @@ restore_directory_hook (hookf) rl_directory_rewrite_hook = hookf; } +/* Set the readline hooks that affect how directories and filenames are + converted. Extern so other parts of the shell can use. */ +void +bashline_set_filename_hooks (void) +{ + /* Tell the completer that we might want to follow symbolic links or + do other expansion on directory names. */ + set_directory_hook (); + + rl_filename_rewrite_hook = bash_filename_rewrite_hook; + rl_completion_rewrite_hook = bash_filename_rewrite_hook; + rl_filename_stat_hook = bash_filename_stat_hook; +} + /* Check whether not DIRNAME, with any trailing slash removed, exists. If SHOULD_DEQUOTE is non-zero, we dequote the directory name first. */ static int -directory_exists (dirname, should_dequote) - const char *dirname; - int should_dequote; +directory_exists (const char *dirname, int should_dequote) { char *new_dirname; int dirlen, r; @@ -3368,12 +3478,42 @@ directory_exists (dirname, should_dequote) free (new_dirname); return (r); } + +static char * +bash_expand_filename (char *filename) +{ + char *newname; + int global_nounset; + WORD_LIST *wl; + + newname = savestring (filename); + /* no error messages, and expand_prompt_string doesn't longjmp so we don't + have to worry about restoring this setting. */ + global_nounset = unbound_vars_is_error; + unbound_vars_is_error = 0; + wl = expand_prompt_string (newname, 0, W_NOCOMSUB|W_NOPROCSUB|W_COMPLETE); /* does the right thing */ + unbound_vars_is_error = global_nounset; + free (newname); + + if (wl == 0) + return filename; + else + { + newname = string_list (wl); + dispose_words (wl); + if (newname && *newname && STREQ (newname, filename)) + { + free (newname); + return filename; + } + return newname; + } +} /* Expand a filename before the readline completion code passes it to stat(2). The filename will already have had tilde expansion performed. */ static int -bash_filename_stat_hook (dirname) - char **dirname; +bash_filename_stat_hook (char **dirname) { char *local_dirname, *new_dirname, *t; int should_expand_dirname, return_value; @@ -3452,8 +3592,7 @@ bash_filename_stat_hook (dirname) the DIRNAME argument, 0 otherwise. It should make sure not to modify DIRNAME if it returns 0. */ static int -bash_directory_completion_hook (dirname) - char **dirname; +bash_directory_completion_hook (char **dirname) { char *local_dirname, *new_dirname, *t; int return_value, should_expand_dirname, nextch, closer; @@ -3516,7 +3655,7 @@ bash_directory_completion_hook (dirname) if (no_symbolic_links == 0 && (local_dirname[0] != '.' || local_dirname[1])) { char *temp1, *temp2; - int len1, len2; + size_t len1, len2; /* If we have a relative path (local_dirname[0] != '/' && local_dirname[0] != '.') @@ -3590,11 +3729,11 @@ bash_directory_completion_hook (dirname) } static char **history_completion_array = (char **)NULL; -static int harry_size; -static int harry_len; +static size_t harry_size; +static size_t harry_len; static void -build_history_completion_array () +build_history_completion_array (void) { register int i, j; HIST_ENTRY **hlist; @@ -3634,17 +3773,16 @@ build_history_completion_array () } /* Sort the complete list of tokens. */ - if (dabbrev_expand_active == 0) + if (harry_len > 1 && dabbrev_expand_active == 0) qsort (history_completion_array, harry_len, sizeof (char *), (QSFUNC *)strvec_strcmp); } } static char * -history_completion_generator (hint_text, state) - const char *hint_text; - int state; +history_completion_generator (const char *hint_text, int state) { - static int local_index, len; + static int local_index; + static size_t len; static const char *text; /* If this is the first call to the generator, then initialize the @@ -3669,8 +3807,7 @@ history_completion_generator (hint_text, state) } static int -dynamic_complete_history (count, key) - int count, key; +dynamic_complete_history (int count, int key) { int r; rl_compentry_func_t *orig_func; @@ -3699,8 +3836,7 @@ dynamic_complete_history (count, key) } static int -bash_dabbrev_expand (count, key) - int count, key; +bash_dabbrev_expand (int count, int key) { int r, orig_suppress, orig_sort; rl_compentry_func_t *orig_func; @@ -3739,43 +3875,37 @@ bash_dabbrev_expand (count, key) #if defined (SPECIFIC_COMPLETION_FUNCTIONS) static int -bash_complete_username (ignore, ignore2) - int ignore, ignore2; +bash_complete_username (int ignore, int ignore2) { return bash_complete_username_internal (rl_completion_mode (bash_complete_username)); } static int -bash_possible_username_completions (ignore, ignore2) - int ignore, ignore2; +bash_possible_username_completions (int ignore, int ignore2) { return bash_complete_username_internal ('?'); } static int -bash_complete_username_internal (what_to_do) - int what_to_do; +bash_complete_username_internal (int what_to_do) { return bash_specific_completion (what_to_do, rl_username_completion_function); } static int -bash_complete_filename (ignore, ignore2) - int ignore, ignore2; +bash_complete_filename (int ignore, int ignore2) { return bash_complete_filename_internal (rl_completion_mode (bash_complete_filename)); } static int -bash_possible_filename_completions (ignore, ignore2) - int ignore, ignore2; +bash_possible_filename_completions (int ignore, int ignore2) { return bash_complete_filename_internal ('?'); } static int -bash_complete_filename_internal (what_to_do) - int what_to_do; +bash_complete_filename_internal (int what_to_do) { rl_compentry_func_t *orig_func; rl_completion_func_t *orig_attempt_func; @@ -3809,71 +3939,61 @@ bash_complete_filename_internal (what_to_do) } static int -bash_complete_hostname (ignore, ignore2) - int ignore, ignore2; +bash_complete_hostname (int ignore, int ignore2) { return bash_complete_hostname_internal (rl_completion_mode (bash_complete_hostname)); } static int -bash_possible_hostname_completions (ignore, ignore2) - int ignore, ignore2; +bash_possible_hostname_completions (int ignore, int ignore2) { return bash_complete_hostname_internal ('?'); } static int -bash_complete_variable (ignore, ignore2) - int ignore, ignore2; +bash_complete_variable (int ignore, int ignore2) { return bash_complete_variable_internal (rl_completion_mode (bash_complete_variable)); } static int -bash_possible_variable_completions (ignore, ignore2) - int ignore, ignore2; +bash_possible_variable_completions (int ignore, int ignore2) { return bash_complete_variable_internal ('?'); } static int -bash_complete_command (ignore, ignore2) - int ignore, ignore2; +bash_complete_command (int ignore, int ignore2) { return bash_complete_command_internal (rl_completion_mode (bash_complete_command)); } static int -bash_possible_command_completions (ignore, ignore2) - int ignore, ignore2; +bash_possible_command_completions (int ignore, int ignore2) { return bash_complete_command_internal ('?'); } static int -bash_complete_hostname_internal (what_to_do) - int what_to_do; +bash_complete_hostname_internal (int what_to_do) { return bash_specific_completion (what_to_do, hostname_completion_function); } static int -bash_complete_variable_internal (what_to_do) - int what_to_do; +bash_complete_variable_internal (int what_to_do) { return bash_specific_completion (what_to_do, variable_completion_function); } static int -bash_complete_command_internal (what_to_do) - int what_to_do; +bash_complete_command_internal (int what_to_do) { return bash_specific_completion (what_to_do, command_word_completion_function); } static int -completion_glob_pattern (string) - char *string; +completion_glob_pattern (const char *string) { return (glob_pattern_p (string) == 1); } @@ -3882,22 +4002,22 @@ static char *globtext; static char *globorig; static char * -glob_complete_word (text, state) - const char *text; - int state; +glob_complete_word (const char *text, int state) { static char **matches = (char **)NULL; static int ind; - int glen; + size_t glen; char *ret, *ttext; if (state == 0) { rl_filename_completion_desired = 1; FREE (matches); + matches = (char **)NULL; if (globorig != globtext) FREE (globorig); FREE (globtext); + globorig = globtext = (char *)NULL; ttext = bash_tilde_expand (text, 0); @@ -3928,8 +4048,7 @@ glob_complete_word (text, state) } static int -bash_glob_completion_internal (what_to_do) - int what_to_do; +bash_glob_completion_internal (int what_to_do) { return bash_specific_completion (what_to_do, glob_complete_word); } @@ -3937,10 +4056,7 @@ bash_glob_completion_internal (what_to_do) /* A special quoting function so we don't end up quoting globbing characters in the word if there are no matches or multiple matches. */ static char * -bash_glob_quote_filename (s, rtype, qcp) - char *s; - int rtype; - char *qcp; +bash_glob_quote_filename (char *s, int rtype, char *qcp) { if (globorig && qcp && *qcp == '\0' && STREQ (s, globorig)) return (savestring (s)); @@ -3949,8 +4065,7 @@ bash_glob_quote_filename (s, rtype, qcp) } static int -bash_glob_complete_word (count, key) - int count, key; +bash_glob_complete_word (int count, int key) { int r; rl_quote_func_t *orig_quoting_function; @@ -3967,23 +4082,19 @@ bash_glob_complete_word (count, key) } static int -bash_glob_expand_word (count, key) - int count, key; +bash_glob_expand_word (int count, int key) { return bash_glob_completion_internal ('*'); } static int -bash_glob_list_expansions (count, key) - int count, key; +bash_glob_list_expansions (int count, int key) { return bash_glob_completion_internal ('?'); } static int -bash_specific_completion (what_to_do, generator) - int what_to_do; - rl_compentry_func_t *generator; +bash_specific_completion (int what_to_do, rl_compentry_func_t *generator) { rl_compentry_func_t *orig_func; rl_completion_func_t *orig_attempt_func; @@ -4009,13 +4120,40 @@ bash_specific_completion (what_to_do, generator) #endif /* SPECIFIC_COMPLETION_FUNCTIONS */ #if defined (VI_MODE) +/* This does pretty much what _rl_vi_advance_point does. */ +static inline int +vi_advance_point (void) +{ + int point; + DECLARE_MBSTATE; + + point = rl_point; + if (rl_point < rl_end) +#if defined (HANDLE_MULTIBYTE) + { + if (locale_mb_cur_max == 1) + rl_point++; + else + { + point = rl_point; + ADVANCE_CHAR (rl_line_buffer, rl_end, rl_point); + if (point == rl_point || rl_point > rl_end) + rl_point = rl_end; + } + } +#else + rl_point++: +#endif + return point; +} + /* Completion, from vi mode's point of view. This is a modified version of rl_vi_complete which uses the bash globbing code to implement what POSIX - specifies, which is to append a `*' and attempt filename generation (which - has the side effect of expanding any globbing characters in the word). */ + specifies, which is to optinally append a `*' and attempt filename + generation (which has the side effect of expanding any globbing characters + in the word). */ static int -bash_vi_complete (count, key) - int count, key; +bash_vi_complete (int count, int key) { #if defined (SPECIFIC_COMPLETION_FUNCTIONS) int p, r; @@ -4025,7 +4163,7 @@ bash_vi_complete (count, key) { if (!whitespace (rl_line_buffer[rl_point + 1])) rl_vi_end_word (1, 'E'); - rl_point++; + vi_advance_point (); } /* Find boundaries of current word, according to vi definition of a @@ -4070,26 +4208,23 @@ bash_vi_complete (count, key) quotes, and backslashes). It allows single quotes to appear within double quotes, and vice versa. It should be smarter. */ static char * -bash_dequote_filename (text, quote_char) - char *text; - int quote_char; +bash_dequote_filename (char *text, int quote_char) { char *ret, *p, *r; - int l, quoted; + int quoted; + size_t l; l = strlen (text); ret = (char *)xmalloc (l + 1); for (quoted = quote_char, p = text, r = ret; p && *p; p++) { - /* Allow backslash-escaped characters to pass through unscathed. */ - if (*p == '\\') + /* Allow backslash-escaped characters to pass through unscathed. Backslashes + aren't special in single quotes. */ + if (quoted != '\'' && *p == '\\') { - /* Backslashes are preserved within single quotes. */ - if (quoted == '\'') - *r++ = *p; /* Backslashes are preserved within double quotes unless the character is one that is defined to be escaped */ - else if (quoted == '"' && ((sh_syntaxtab[(unsigned char)p[1]] & CBSDQUOTE) == 0)) + if (quoted == '"' && ((sh_syntaxtab[(unsigned char)p[1]] & CBSDQUOTE) == 0)) *r++ = *p; *r++ = *++p; @@ -4119,11 +4254,10 @@ bash_dequote_filename (text, quote_char) word break characters with backslashes. Pass backslash-quoted characters through without examination. */ static char * -quote_word_break_chars (text) - char *text; +quote_word_break_chars (char *text) { char *ret, *r, *s; - int l; + size_t l; l = strlen (text); ret = (char *)xmalloc ((2 * l) + 1); @@ -4160,10 +4294,7 @@ quote_word_break_chars (text) used in case DIRNAME is going to be expanded. If DIRNAME is just going to be quoted, NEED_CLOSER will be 0. */ static int -bash_check_expchar (dirname, need_closer, nextp, closerp) - char *dirname; - int need_closer; - int *nextp, *closerp; +bash_check_expchar (char *dirname, int need_closer, int *nextp, int *closerp) { char *t; int ret, n, c; @@ -4219,10 +4350,10 @@ bash_check_expchar (dirname, need_closer, nextp, closerp) of characters to be backslash-escaped. This is the only place custom_filename_quote_characters is modified. */ static void -set_filename_quote_chars (expchar, nextch, closer) - int expchar, nextch, closer; +set_filename_quote_chars (int expchar, int nextch, int closer) { - int i, j, c; + size_t i, j; + int c; if (rl_filename_quote_characters && *rl_filename_quote_characters) { @@ -4244,8 +4375,7 @@ set_filename_quote_chars (expchar, nextch, closer) be backslash-quoted. The table will be used for sh_backslash_quote from this file. */ static void -set_filename_bstab (string) - const char *string; +set_filename_bstab (const char *string) { const char *s; @@ -4261,14 +4391,11 @@ set_filename_bstab (string) quote_word_break_chars on the result. This returns newly-allocated memory. */ static char * -bash_quote_filename (s, rtype, qcp) - char *s; - int rtype; - char *qcp; +bash_quote_filename (char *s, int rtype, char *qcp) { char *rtext, *mtext, *ret; - int rlen, cs; - int expchar, nextch, closer; + size_t rlen; + int cs, expchar, nextch, closer; rtext = (char *)NULL; @@ -4291,6 +4418,17 @@ bash_quote_filename (s, rtype, qcp) (expchar = bash_check_expchar (s, 0, &nextch, &closer)) && file_exists (s) == 0) { + /* If it looks like the name is subject to expansion, see if we want to + double-quote it. */ + if (expchar == '$' || expchar == '`') + { + char *newname; + newname = bash_expand_filename (s); + if (newname && strpbrk (newname, rl_filename_quote_characters)) + cs = COMPLETE_DQUOTE2; + if (newname != s) + free (newname); + } /* Usually this will have been set by bash_directory_completion_hook, but there are cases where it will not be. */ if (rl_filename_quote_characters != custom_filename_quote_characters) @@ -4300,7 +4438,12 @@ bash_quote_filename (s, rtype, qcp) else if (*qcp == '\0' && cs == COMPLETE_BSQUOTE && mbschr (s, '\n')) cs = COMPLETE_SQUOTE; else if (*qcp == '"') - cs = COMPLETE_DQUOTE; + { + if ((expchar = bash_check_expchar (s, 0, &nextch, &closer)) == '$' || expchar == '`') + cs = COMPLETE_DQUOTE2; + else + cs = COMPLETE_DQUOTE; + } else if (*qcp == '\'') cs = COMPLETE_SQUOTE; #if defined (BANG_HISTORY) @@ -4324,6 +4467,9 @@ bash_quote_filename (s, rtype, qcp) switch (cs) { + case COMPLETE_DQUOTE2: + rtext = sh_mkdoublequoted (mtext, strlen (mtext), 1); /* For now */ + break; case COMPLETE_DQUOTE: rtext = sh_double_quote (mtext); break; @@ -4383,8 +4529,7 @@ static void #else static int #endif -putx(c) - int c; +putx(int c) { int x; x = putc (c, rl_outstream); @@ -4394,8 +4539,7 @@ putx(c) } static int -readline_get_char_offset (ind) - int ind; +readline_get_char_offset (int ind) { int r, old_ch; @@ -4413,9 +4557,7 @@ readline_get_char_offset (ind) } static void -readline_set_char_offset (ind, varp) - int ind; - int *varp; +readline_set_char_offset (int ind, int *varp) { int i; @@ -4435,16 +4577,36 @@ readline_set_char_offset (ind, varp) } } +void +uw_rl_set_signals (void *ignore) +{ + rl_set_signals (); +} + +static void +unbind_readline_variables (void) +{ + check_unbind_variable ("READLINE_LINE"); + check_unbind_variable ("READLINE_POINT"); + check_unbind_variable ("READLINE_MARK"); + check_unbind_variable ("READLINE_ARGUMENT"); + array_needs_making = 1; +} + +static void +uw_unbind_readline_variables (void *ignore) +{ + unbind_readline_variables (); +} + int -bash_execute_unix_command (count, key) - int count; /* ignored */ - int key; +bash_execute_unix_command (int count, int key) { - int type; + int type, pflags; register int i, r; intmax_t mi; sh_parser_state_t ps; - char *cmd, *value, *ce, old_ch; + char *cmd, *value, *ce; SHELL_VAR *v; char ibuf[INT_STRLEN_BOUND(int) + 1]; Keymap cmd_xmap; @@ -4455,7 +4617,7 @@ bash_execute_unix_command (count, key) kslen = rl_key_sequence_length; /* If we have a numeric argument, chop it off the front of the key sequence */ - if (count > 1 || rl_explicit_arg) + if (count != 1 || rl_explicit_arg) { i = rl_trim_arg_from_keyseq (rl_executing_keyseq, rl_key_sequence_length, rl_get_keymap ()); if (i > 0) @@ -4507,7 +4669,7 @@ bash_execute_unix_command (count, key) if (v) VSETATTR (v, att_exported); - if (count > 1 || rl_explicit_arg) + if (count != 1 || rl_explicit_arg) { value = inttostr (count, ibuf, sizeof (ibuf)); v = bind_int_variable ("READLINE_ARGUMENT", value, 0); @@ -4516,9 +4678,14 @@ bash_execute_unix_command (count, key) } array_needs_making = 1; + begin_unwind_frame ("execute-unix-command"); save_parser_state (&ps); rl_clear_signals (); - r = parse_and_execute (savestring (cmd), "bash_execute_unix_command", SEVAL_NOHIST); + add_unwind_protect (uw_unbind_readline_variables, 0); + add_unwind_protect (uw_restore_parser_state, &ps); + add_unwind_protect (uw_rl_set_signals, 0); + pflags = interactive_shell ? (SEVAL_NOTIFY|SEVAL_NOHIST) : SEVAL_NOHIST; + r = parse_and_execute (savestring (cmd), "bash_execute_unix_command", pflags); rl_set_signals (); restore_parser_state (&ps); @@ -4526,18 +4693,15 @@ bash_execute_unix_command (count, key) maybe_make_readline_line (v ? value_cell (v) : 0); v = find_variable ("READLINE_POINT"); - if (v && legal_number (value_cell (v), &mi)) + if (v && valid_number (value_cell (v), &mi)) readline_set_char_offset (mi, &rl_point); v = find_variable ("READLINE_MARK"); - if (v && legal_number (value_cell (v), &mi)) + if (v && valid_number (value_cell (v), &mi)) readline_set_char_offset (mi, &rl_mark); - check_unbind_variable ("READLINE_LINE"); - check_unbind_variable ("READLINE_POINT"); - check_unbind_variable ("READLINE_MARK"); - check_unbind_variable ("READLINE_ARGUMENT"); - array_needs_making = 1; + unbind_readline_variables (); + discard_unwind_frame ("execute-unix-command"); /* and restore the readline buffer and display after command execution. */ /* If we clear the last line of the prompt above, redraw only that last @@ -4551,21 +4715,35 @@ bash_execute_unix_command (count, key) return 0; } +/* This only has to handle macros/shell commandsfrom print_unix_command_map */ +static void +print_unix_command (const char *kseq, const char *value, int readable, const char *prefix) +{ + if (readable) + fprintf (rl_outstream, "\"%s%s\" \"%s\"\n", prefix ? prefix : "", kseq, value ? value : ""); + else + fprintf (rl_outstream, "%s%s outputs %s\n", prefix ? prefix : "", kseq, value ? value : ""); +} + int -print_unix_command_map () +print_unix_command_map (void) { Keymap save, cmd_xmap; + rl_macro_print_func_t *old_printer; save = rl_get_keymap (); cmd_xmap = get_cmd_xmap_from_keymap (save); rl_set_keymap (cmd_xmap); + old_printer = rl_macro_display_hook; + rl_macro_display_hook = print_unix_command; rl_macro_dumper (1); + rl_macro_display_hook = old_printer; rl_set_keymap (save); return 0; } static void -init_unix_command_map () +init_unix_command_map (void) { emacs_std_cmd_xmap = rl_make_bare_keymap (); @@ -4581,7 +4759,7 @@ init_unix_command_map () } static Keymap -get_cmd_xmap_from_edit_mode () +get_cmd_xmap_from_edit_mode (void) { if (emacs_std_cmd_xmap == 0) init_unix_command_map (); @@ -4600,8 +4778,7 @@ get_cmd_xmap_from_edit_mode () } static Keymap -get_cmd_xmap_from_keymap (kmap) - Keymap kmap; +get_cmd_xmap_from_keymap (Keymap kmap) { if (emacs_std_cmd_xmap == 0) init_unix_command_map (); @@ -4623,9 +4800,7 @@ get_cmd_xmap_from_keymap (kmap) } static int -isolate_sequence (string, ind, need_dquote, startp) - char *string; - int ind, need_dquote, *startp; +isolate_sequence (char *string, int ind, int need_dquote, int *startp) { register int i; int c, passc, delim; @@ -4672,17 +4847,16 @@ isolate_sequence (string, ind, need_dquote, startp) } int -bind_keyseq_to_unix_command (line) - char *line; +bind_keyseq_to_unix_command (char *line) { Keymap kmap, cmd_xmap; char *kseq, *value; - int i, kstart; + int i, kstart, translate; kmap = rl_get_keymap (); /* We duplicate some of the work done by rl_parse_and_bind here, but - this code only has to handle `"keyseq": ["]command["]' and can + this code only has to handle `"keyseq"[:][ \t]+["]command["]' and can generate an error for anything else. */ i = isolate_sequence (line, 0, 1, &kstart); if (i < 0) @@ -4691,16 +4865,26 @@ bind_keyseq_to_unix_command (line) /* Create the key sequence string to pass to rl_generic_bind */ kseq = substring (line, kstart, i); - for ( ; line[i] && line[i] != ':'; i++) + /* Allow colon or whitespace to separate the key sequence and command string. */ + for ( ; line[i] && line[i] != ':' && whitespace (line[i]) == 0; i++) ; - if (line[i] != ':') + if (line[i] != ':' && whitespace (line[i]) == 0) { - builtin_error (_("%s: missing colon separator"), line); + builtin_error (_("%s: missing separator"), line); FREE (kseq); return -1; } - i = isolate_sequence (line, i + 1, 0, &kstart); + /* If we have a whitespace separator we're going to call rl_macro_bind so + we get the readline-translated version of the value (backslash-escapes + handled, etc.) */ + translate = line[i] != ':'; + + /* Kind of tricky. If we use whitespace as a delimiter, we can backslash- + quote double quotes and have them preserved in the value. However, we + still want to be able to auto-detect quoted strings and only require + them with whitespace delimiters. */ + i = isolate_sequence (line, i + 1, translate, &kstart); if (i < 0) { FREE (kseq); @@ -4712,7 +4896,10 @@ bind_keyseq_to_unix_command (line) /* Save the command to execute and the key sequence in the CMD_XMAP */ cmd_xmap = get_cmd_xmap_from_keymap (kmap); - rl_generic_bind (ISMACR, kseq, value, cmd_xmap); + if (translate) + rl_macro_bind (kseq, value, cmd_xmap); + else + rl_generic_bind (ISMACR, kseq, value, cmd_xmap); /* and bind the key sequence in the current keymap to a function that understands how to execute from CMD_XMAP */ @@ -4723,8 +4910,7 @@ bind_keyseq_to_unix_command (line) } int -unbind_unix_command (kseq) - char *kseq; +unbind_unix_command (char *kseq) { Keymap cmd_xmap; @@ -4741,8 +4927,7 @@ unbind_unix_command (kseq) but return only directories as matches. Dequotes the filename before attempting to find matches. */ char ** -bash_directory_completion_matches (text) - const char *text; +bash_directory_completion_matches (const char *text) { char **m1; char *dfn; @@ -4770,8 +4955,7 @@ bash_directory_completion_matches (text) } char * -bash_dequote_text (text) - const char *text; +bash_dequote_text (const char *text) { char *dtxt; int qc; @@ -4786,7 +4970,7 @@ bash_dequote_text (text) and fatal signals without executing too much code in a signal handler context. */ static int -bash_event_hook () +bash_event_hook (void) { int sig; diff --git a/bashline.h b/bashline.h index d40228e29..430e369fe 100644 --- a/bashline.h +++ b/bashline.h @@ -1,6 +1,6 @@ /* bashline.h -- interface to the bash readline functions in bashline.c. */ -/* Copyright (C) 1993-2019 Free Software Foundation, Inc. +/* Copyright (C) 1993-2024 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -35,35 +35,38 @@ extern int dircomplete_expand; extern int dircomplete_expand_relpath; extern int complete_fullquote; -extern void posix_readline_initialize PARAMS((int)); -extern void reset_completer_word_break_chars PARAMS((void)); -extern int enable_hostname_completion PARAMS((int)); -extern void initialize_readline PARAMS((void)); -extern void bashline_reset PARAMS((void)); -extern void bashline_reinitialize PARAMS((void)); -extern int bash_re_edit PARAMS((char *)); +extern void posix_readline_initialize (int); +extern void reset_completer_word_break_chars (void); +extern int enable_hostname_completion (int); +extern void initialize_readline (void); +extern void bashline_reset (void); +extern void bashline_reinitialize (void); +extern int bash_re_edit (const char *); -extern void bashline_set_event_hook PARAMS((void)); -extern void bashline_reset_event_hook PARAMS((void)); +extern void bashline_set_event_hook (void); +extern void bashline_reset_event_hook (void); -extern int bind_keyseq_to_unix_command PARAMS((char *)); -extern int bash_execute_unix_command PARAMS((int, int)); -extern int print_unix_command_map PARAMS((void)); -extern int unbind_unix_command PARAMS((char *)); +extern void uw_rl_set_signals (void *); -extern char **bash_default_completion PARAMS((const char *, int, int, int, int)); +extern int bind_keyseq_to_unix_command (char *); +extern int bash_execute_unix_command (int, int); +extern int print_unix_command_map (void); +extern int unbind_unix_command (char *); -extern void set_directory_hook PARAMS((void)); +extern char **bash_default_completion (const char *, int, int, int, int); + +extern void bashline_set_filename_hooks (void); +extern void set_directory_hook (void); /* Used by programmable completion code. */ -extern char *command_word_completion_function PARAMS((const char *, int)); -extern char *bash_groupname_completion_function PARAMS((const char *, int)); -extern char *bash_servicename_completion_function PARAMS((const char *, int)); +extern char *command_word_completion_function (const char *, int); +extern char *bash_groupname_completion_function (const char *, int); +extern char *bash_servicename_completion_function (const char *, int); -extern char **get_hostname_list PARAMS((void)); -extern void clear_hostname_list PARAMS((void)); +extern char **get_hostname_list (void); +extern void clear_hostname_list (void); -extern char **bash_directory_completion_matches PARAMS((const char *)); -extern char *bash_dequote_text PARAMS((const char *)); +extern char **bash_directory_completion_matches (const char *); +extern char *bash_dequote_text (const char *); #endif /* _BASHLINE_H_ */ diff --git a/bashtypes.h b/bashtypes.h index 01afef4b4..9d666d4f1 100644 --- a/bashtypes.h +++ b/bashtypes.h @@ -1,6 +1,6 @@ /* bashtypes.h -- Bash system types. */ -/* Copyright (C) 1993-2009 Free Software Foundation, Inc. +/* Copyright (C) 1993-2009,2024 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -35,6 +35,18 @@ # include #endif +/* Fix PRIdMAX on systems where it's broken. */ +#ifdef PRI_MACROS_BROKEN +# undef PRIdMAX +#endif +#ifndef PRIdMAX +# if HAVE_LONG_LONG +# define PRIdMAX "lld" +# else +# define PRIdMAX "ld" +# endif +#endif + #if HAVE_STDINT_H # include #endif diff --git a/bracecomp.c b/bracecomp.c index 2ea8ba971..1effa9aa7 100644 --- a/bracecomp.c +++ b/bracecomp.c @@ -4,7 +4,7 @@ /* Original version by tromey@cns.caltech.edu, Fri Feb 7 1992. */ -/* Copyright (C) 1993-2020 Free Software Foundation, Inc. +/* Copyright (C) 1993-2020,2022 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -41,12 +41,11 @@ #include "shell.h" #include -static int _strcompare PARAMS((char **, char **)); +static int _strcompare (const char **, const char **); /* Find greatest common prefix of two strings. */ static int -string_gcd (s1, s2) - char *s1, *s2; +string_gcd (char *s1, char *s2) { register int i; @@ -63,13 +62,12 @@ string_gcd (s1, s2) } static char * -really_munge_braces (array, real_start, real_end, gcd_zero) - char **array; - int real_start, real_end, gcd_zero; +really_munge_braces (char **array, int real_start, int real_end, int gcd_zero) { int start, end, gcd; char *result, *subterm, *x; - int result_size, flag, tlen; + size_t result_size; + int flag, tlen; flag = 0; @@ -150,8 +148,7 @@ really_munge_braces (array, real_start, real_end, gcd_zero) } static int -_strcompare (s1, s2) - char **s1, **s2; +_strcompare (const char **s1, const char **s2) { int result; @@ -163,8 +160,7 @@ _strcompare (s1, s2) } static int -hack_braces_completion (names) - char **names; +hack_braces_completion (char **names) { register int i; char *temp; @@ -187,8 +183,7 @@ hack_braces_completion (names) /* We handle quoting ourselves within hack_braces_completion, so we turn off rl_filename_quoting_desired and rl_filename_quoting_function. */ int -bash_brace_completion (count, ignore) - int count, ignore; +bash_brace_completion (int count, int ignore) { rl_compignore_func_t *orig_ignore_func; rl_compentry_func_t *orig_entry_func; diff --git a/braces.c b/braces.c index e91d326ea..fb9230e06 100644 --- a/braces.c +++ b/braces.c @@ -1,7 +1,7 @@ /* braces.c -- code for doing word expansion in curly braces. */ -/* Copyright (C) 1987-2020 Free Software Foundation, Inc. - +/* Copyright (C) 1987-2020,2022-2025 Free Software Foundation, Inc. +` This file is part of GNU Bash, the Bourne Again SHell. Bash is free software: you can redistribute it and/or modify @@ -32,12 +32,14 @@ #endif #include +#include #include "bashansi.h" #include "bashintl.h" #if defined (SHELL) # include "shell.h" +# include "parser.h" /* FUNSUB_CHAR */ #else # if defined (TEST) typedef char *WORD_DESC; @@ -59,7 +61,12 @@ extern int errno; #define BRACE_SEQ_SPECIFIER ".." -extern int asprintf PARAMS((char **, const char *, ...)) __attribute__((__format__ (printf, 2, 3))); +/* What kind of brace expansion do we think we have? brace_gobbler() decides. */ +#define BRACE_COMMA 0x01 +#define BRACE_SEQ 0x02 +#define BRACE_NONE 0x04 + +extern int asprintf (char **, const char *, ...) __attribute__((__format__ (printf, 2, 3))); /* Basic idea: @@ -73,19 +80,12 @@ extern int asprintf PARAMS((char **, const char *, ...)) __attribute__((__format /* The character which is used to separate arguments. */ static const int brace_arg_separator = ','; -#if defined (PARAMS) -static int brace_gobbler PARAMS((char *, size_t, int *, int)); -static char **expand_amble PARAMS((char *, size_t, int)); -static char **expand_seqterm PARAMS((char *, size_t)); -static char **mkseq PARAMS((intmax_t, intmax_t, intmax_t, int, int)); -static char **array_concat PARAMS((char **, char **)); -#else -static int brace_gobbler (); -static char **expand_amble (); -static char **expand_seqterm (); -static char **mkseq(); -static char **array_concat (); -#endif +static int brace_gobbler (char *, size_t, int *, int *, int); +static char **expand_amble (char *, size_t, int); +static char **expand_seqterm (char *, size_t); +static int valid_seqterm (char *, size_t); +static char **mkseq (intmax_t, intmax_t, intmax_t, int, size_t); +static char **array_concat (char **, char **); #if 0 static void @@ -101,15 +101,14 @@ dump_result (a) /* Return an array of strings; the brace expansion of TEXT. */ char ** -brace_expand (text) - char *text; +brace_expand (char *text) { - register int start; + int start; size_t tlen; char *preamble, *postamble, *amble; size_t alen; char **tack, **result; - int i, j, c, c1; + int i, j, c, c1, etype; DECLARE_MBSTATE; @@ -117,20 +116,31 @@ brace_expand (text) tlen = strlen (text); i = 0; #if defined (CSH_BRACE_COMPAT) - c = brace_gobbler (text, tlen, &i, '{'); /* } */ + c = brace_gobbler (text, tlen, &i, (int *)NULL, '{'); /* } */ #else /* Make sure that when we exit this loop, c == 0 or text[i] begins a valid brace expansion sequence. */ do { - c = brace_gobbler (text, tlen, &i, '{'); /* } */ + c = brace_gobbler (text, tlen, &i, (int *)NULL, '{'); /* } */ + if (i >= tlen) + break; c1 = c; /* Verify that c begins a valid brace expansion word. If it doesn't, we go on. Loop stops when there are no more open braces in the word. */ if (c) { start = j = i + 1; /* { */ - c = brace_gobbler (text, tlen, &j, '}'); + c = brace_gobbler (text, tlen, &j, &etype, '}'); +#if 1 + /* One alternative is to perform validity checking on the sequence + terms here. If the sequence expression is invalid, we just skip + over the open brace and go on, leaving other brace expressions in + the candidate sequence expression to be expanded. */ + if (etype == BRACE_SEQ && valid_seqterm (text + start, j - start) == 0) + c = 0; +#endif + if (c == 0) /* it's not */ { i++; @@ -165,7 +175,7 @@ brace_expand (text) /* Find the amble. This is the stuff inside this set of braces. */ start = ++i; - c = brace_gobbler (text, tlen, &i, '}'); + c = brace_gobbler (text, tlen, &i, &etype, '}'); /* What if there isn't a matching close brace? */ if (c == 0) @@ -211,8 +221,8 @@ brace_expand (text) #if defined (SHELL) INITIALIZE_MBSTATE; - /* If the amble does not contain an unquoted BRACE_ARG_SEPARATOR, then - just return without doing any expansion. */ + /* If the amble does not contain an unquoted BRACE_ARG_SEPARATOR, and we + think we have a BRACE_COMMA-separated sequence, then do no expansion. */ j = 0; while (amble[j]) { @@ -223,18 +233,23 @@ brace_expand (text) continue; } - if (amble[j] == brace_arg_separator) + if (amble[j] == brace_arg_separator && etype == BRACE_COMMA) break; ADVANCE_CHAR (amble, alen, j); } - if (amble[j] == 0) + /* If we think we have a sequence expression, try to expand it. */ + if (amble[j] == 0 && etype == BRACE_SEQ) { + /* The other alternative (see call to valid_seqterm() above) is to + perform the validity checking in expand_seqterm(). If we do this, + and the sequence isn't valid, we just treat the entire candidate + sequence expansion as a single unexpanded string. */ tack = expand_seqterm (amble, alen); if (tack) goto add_tack; - else if (text[i + 1]) + else if (i < tlen && text[i + 1]) { /* If the sequence expansion fails (e.g., because the integers overflow), but there is more in the string, try and process @@ -282,10 +297,7 @@ add_tack: expand each slot which needs it, until there are no more slots which need it. */ static char ** -expand_amble (text, tlen, flags) - char *text; - size_t tlen; - int flags; +expand_amble (char *text, size_t tlen, int flags) { char **result, **partial, **tresult; char *tem; @@ -301,7 +313,7 @@ expand_amble (text, tlen, flags) c = 1; while (c) { - c = brace_gobbler (text, tlen, &i, brace_arg_separator); + c = brace_gobbler (text, tlen, &i, (int *)NULL, brace_arg_separator); #if defined (SHELL) tem = substring (text, start, i); #else @@ -316,7 +328,8 @@ expand_amble (text, tlen, flags) result = partial; else { - register int lr, lp, j; + size_t lr, lp; + int j; lr = strvec_len (result); lp = strvec_len (partial); @@ -357,53 +370,37 @@ expand_amble (text, tlen, flags) #define ST_ZINT 3 static char ** -mkseq (start, end, incr, type, width) - intmax_t start, end, incr; - int type, width; +mkseq (intmax_t start, intmax_t end, intmax_t incr, int type, size_t width) { - intmax_t n, prevn; - int i, nelem; + intmax_t prevn, n, abs_incr; + size_t nelem, i; char **result, *t; + char lbuf[INT_BUFSIZE_BOUND (uintmax_t)]; if (incr == 0) incr = 1; - if (start > end && incr > 0) - incr = -incr; - else if (start < end && incr < 0) - { - if (incr == INTMAX_MIN) /* Don't use -INTMAX_MIN */ - return ((char **)NULL); - incr = -incr; - } - - /* Check that end-start will not overflow INTMAX_MIN, INTMAX_MAX. The +3 - and -2, not strictly necessary, are there because of the way the number - of elements and value passed to strvec_create() are calculated below. */ - if (SUBOVERFLOW (end, start, INTMAX_MIN+3, INTMAX_MAX-2)) + abs_incr = incr; + if (incr < 0 && ckd_sub (&abs_incr, 0, incr)) return ((char **)NULL); - prevn = sh_imaxabs (end - start); - /* Need to check this way in case INT_MAX == INTMAX_MAX */ - if (INT_MAX == INTMAX_MAX && (ADDOVERFLOW (prevn, 2, INT_MIN, INT_MAX))) + /* Make sure incr agrees with start and end */ + if ((start < end) == (incr < 0) && ckd_sub (&incr, 0, incr)) return ((char **)NULL); - /* Make sure the assignment to nelem below doesn't end up <= 0 due to - intmax_t overflow */ - else if (ADDOVERFLOW ((prevn/sh_imaxabs(incr)), 1, INTMAX_MIN, INTMAX_MAX)) + + /* prevn = sh_imaxabs (end - start); */ + if (start < end ? ckd_sub (&prevn, end, start) : ckd_sub (&prevn, start, end)) return ((char **)NULL); - /* XXX - TOFIX: potentially allocating a lot of extra memory if - imaxabs(incr) != 1 */ - /* Instead of a simple nelem = prevn + 1, something like: - nelem = (prevn / imaxabs(incr)) + 1; - would work */ - if ((prevn / sh_imaxabs (incr)) > INT_MAX - 3) /* check int overflow */ + /* nelem = floor (abs ((end - start) / incr)) plus 1 for first element plus + trailing null. Account for trailing null up here for overflow check */ + if (ckd_add (&nelem, prevn / abs_incr, 2)) return ((char **)NULL); - nelem = (prevn / sh_imaxabs(incr)) + 1; - result = strvec_mcreate (nelem + 1); + + result = strvec_mcreate (nelem); if (result == 0) { - internal_error (_("brace expansion: failed to allocate memory for %u elements"), (unsigned int)nelem); + internal_error (_("brace expansion: failed to allocate memory for %s elements"), uinttostr (nelem - 1, lbuf, sizeof (lbuf))); return ((char **)NULL); } @@ -422,13 +419,26 @@ mkseq (start, end, incr, type, width) QUIT; #endif if (type == ST_INT) - result[i++] = t = itos (n); + t = itos (n); else if (type == ST_ZINT) { - int len, arg; - arg = n; - len = asprintf (&t, "%0*d", width, arg); - result[i++] = t; + size_t tlen; + + t = itos (n); + tlen = strlen (t); + if (tlen < width) /* zero-pad the result directly to avoid sprintf */ + { + char *t0; + t0 = t; + t = realloc (t, width + 1); + if (t == 0) + free (t0); + else + { + memmove (t + (width - tlen), t, tlen + 1); + memset (t + (n < 0), '0', width - tlen); + } + } } else { @@ -437,30 +447,27 @@ mkseq (start, end, incr, type, width) t[0] = n; t[1] = '\0'; } - result[i++] = t; } + result[i++] = t; + /* We failed to allocate memory for this number, so we bail. */ if (t == 0) { - char *p, lbuf[INT_STRLEN_BOUND(intmax_t) + 1]; + char *p; /* Easier to do this than mess around with various intmax_t printf formats (%ld? %lld? %jd?) and PRIdMAX. */ - p = inttostr (n, lbuf, sizeof (lbuf)); + p = uinttostr (n, lbuf, sizeof (lbuf)); internal_error (_("brace expansion: failed to allocate memory for `%s'"), p); strvec_dispose (result); return ((char **)NULL); } - /* Handle overflow and underflow of n+incr */ - if (ADDOVERFLOW (n, incr, INTMAX_MIN, INTMAX_MAX)) - break; + if (i >= nelem - 1) + break; n += incr; - - if ((incr < 0 && n < end) || (incr > 0 && n > end)) - break; } while (1); @@ -468,13 +475,50 @@ mkseq (start, end, incr, type, width) return (result); } +/* For now. */ +static int +valid_seqterm (char *text, size_t tlen) +{ + char *t, *lhs, *rhs; + int lhs_t, rhs_t; + int c; + + c = text[tlen]; /* XXX - text[tlen] == RBRACE */ + text[tlen] = '\0'; /* don't be tricked by something later in the string */ + t = strstr (text, BRACE_SEQ_SPECIFIER); + text[tlen] = c; + + if (t == 0) + return 0; /* invalid */ + + lhs = text; + rhs = t + sizeof(BRACE_SEQ_SPECIFIER) - 1; + + /*{*/ + if (lhs[0] == BRACE_SEQ_SPECIFIER[0] || rhs[0] == '}') + return 0; /* invalid */ + + /* Now figure out whether LHS and RHS are integers or letters. Both + sides have to match. Minimal checking here, just enough to throw out the + obvious invalid candidates. */ + lhs_t = (ISDIGIT (lhs[0]) || ((lhs[0] == '+' || lhs[0] == '-') && ISDIGIT (lhs[1]))) ? ST_INT : + (ISALPHA (lhs[0]) && lhs[1] == '.') ? ST_CHAR : ST_BAD; + + rhs_t = (ISDIGIT (rhs[0]) || ((rhs[0] == '+' || rhs[0] == '-') && ISDIGIT (rhs[1]))) ? ST_INT : +/*{*/ (ISALPHA (rhs[0]) && (rhs[1] == '}' || rhs[1] == '.')) ? ST_CHAR : ST_BAD; + + if (lhs_t != rhs_t || lhs_t == ST_BAD || rhs_t == ST_BAD) + return 0; /* invalid */ + + return 1; +} + static char ** -expand_seqterm (text, tlen) - char *text; - size_t tlen; +expand_seqterm (char *text, size_t tlen) { char *t, *lhs, *rhs; - int lhs_t, rhs_t, lhs_l, rhs_l, width; + int lhs_t, rhs_t; + size_t lhs_l, rhs_l, width; intmax_t lhs_v, rhs_v, incr; intmax_t tl, tr; char **result, *ep, *oep; @@ -496,7 +540,7 @@ expand_seqterm (text, tlen) /* Now figure out whether LHS and RHS are integers or letters. Both sides have to match. */ - lhs_t = (legal_number (lhs, &tl)) ? ST_INT : + lhs_t = (valid_number (lhs, &tl)) ? ST_INT : ((ISALPHA (lhs[0]) && lhs[1] == 0) ? ST_CHAR : ST_BAD); /* Decide on rhs and whether or not it looks like the user specified @@ -591,20 +635,17 @@ expand_seqterm (text, tlen) an inner set of braces. */ static int -brace_gobbler (text, tlen, indx, satisfy) - char *text; - size_t tlen; - int *indx; - int satisfy; +brace_gobbler (char *text, size_t tlen, int *indx, int *typep, int satisfy) { - register int i, c, quoted, level, commas, pass_next; + int i, c, quoted, level, commas, pass_next, btype; #if defined (SHELL) - int si; + size_t si; char *t; #endif DECLARE_MBSTATE; level = quoted = pass_next = 0; + btype = BRACE_NONE; #if defined (CSH_BRACE_COMPAT) commas = 1; #else @@ -636,8 +677,30 @@ brace_gobbler (text, tlen, indx, satisfy) #if defined (SHELL) /* If compiling for the shell, treat ${...} like \{...} */ - if (c == '$' && text[i+1] == '{' && quoted != '\'') /* } */ + if (c == '$' && i < tlen && text[i+1] == '{' && quoted != '\'') /* } */ { +#if 1 + /* nofork command substitution */ + if (i < tlen - 1 && FUNSUB_CHAR (text[i+2])) + { + int o, f; +funsub: + o = no_longjmp_on_fatal_error; + no_longjmp_on_fatal_error = 1; + f = (quoted == '"') ? Q_DOUBLE_QUOTES : 0; + si = i + 2; + t = extract_function_subst (text, &si, f, SX_NOALLOC|SX_NOLONGJMP|SX_NOERROR); + i = si + 1; + no_longjmp_on_fatal_error = o; + if (i > tlen) + { + i = tlen; + c = 0; + break; + } + continue; + } +#endif pass_next = 1; i++; if (quoted == 0) @@ -652,7 +715,7 @@ brace_gobbler (text, tlen, indx, satisfy) quoted = 0; #if defined (SHELL) /* The shell allows quoted command substitutions */ - if (quoted == '"' && c == '$' && text[i+1] == '(') /*)*/ + if (quoted == '"' && c == '$' && i < tlen && text[i+1] == '(') /*)*/ goto comsub; #endif #if defined (SHELL) @@ -672,14 +735,23 @@ brace_gobbler (text, tlen, indx, satisfy) #if defined (SHELL) /* Pass new-style command and process substitutions through unchanged. */ - if ((c == '$' || c == '<' || c == '>') && text[i+1] == '(') /* ) */ + if ((c == '$' || c == '<' || c == '>') && i < tlen && text[i+1] == '(') /* ) */ { + int o; + comsub: + o = no_longjmp_on_fatal_error; + no_longjmp_on_fatal_error = 1; si = i + 2; - t = extract_command_subst (text, &si, 0); - i = si; - free (t); - i++; + t = extract_command_subst (text, &si, SX_NOALLOC|SX_NOLONGJMP|SX_NOERROR); + i = si + 1; + no_longjmp_on_fatal_error = o; + if (i > tlen) + { + i = tlen; + c = 0; + break; + } continue; } #endif @@ -706,10 +778,17 @@ comsub: level--; #if !defined (CSH_BRACE_COMPAT) else if (satisfy == '}' && c == brace_arg_separator && level == 0) - commas++; + { + btype = BRACE_COMMA; + commas++; + } else if (satisfy == '}' && STREQN (text+i, BRACE_SEQ_SPECIFIER, 2) && - text[i+2] != satisfy && level == 0) - commas++; + text[i+2] != satisfy && level == 0 && btype == BRACE_NONE) + { + /* The check against BRACE_NONE gives the comma higher precedence */ + btype = BRACE_SEQ; + commas++; + } #endif #if defined (SHELL) @@ -720,6 +799,8 @@ comsub: } *indx = i; + if (typep) + *typep = btype; return (c); } @@ -729,11 +810,11 @@ comsub: are free ()'ed. ARR1 can be NULL, in that case, a new version of ARR2 is returned. */ static char ** -array_concat (arr1, arr2) - char **arr1, **arr2; +array_concat (char **arr1, char **arr2) { - register int i, j, len, len1, len2; - register char **result; + int i, j, len; + size_t len1, len2; + char **result; if (arr1 == 0) return (arr2); /* XXX - see if we can get away without copying? */ @@ -767,6 +848,17 @@ array_concat (arr1, arr2) for (j = 0; j < len2; j++) { +#if defined (SHELL) + if (ISINTERRUPT) + { + result[len] = (char *)NULL; + strvec_dispose (result); + result = (char **)NULL; + strvec_dispose (arr1); /* caller expects us to free arr1 */ + } + QUIT; +#endif + result[len] = (char *)xmalloc (1 + strlen_1 + strlen (arr2[j])); strcpy (result[len], arr1[i]); strcpy (result[len] + strlen_1, arr2[j]); @@ -784,29 +876,25 @@ array_concat (arr1, arr2) #include void * -xmalloc(n) - size_t n; +xmalloc(size_t n) { return (malloc (n)); } void * -xrealloc(p, n) - void *p; - size_t n; +xrealloc(void *p, size_t n) { return (realloc (p, n)); } int -internal_error (format, arg1, arg2) - char *format, *arg1, *arg2; +internal_error (char *format, char *arg1, char *arg2) { fprintf (stderr, format, arg1, arg2); fprintf (stderr, "\n"); } -main () +main (int c, char **v) { char example[256]; diff --git a/buildconf.h.in b/buildconf.h.in new file mode 100644 index 000000000..b99d26ce9 --- /dev/null +++ b/buildconf.h.in @@ -0,0 +1,51 @@ +/* buildconf.h -- config definitions from build environment for tools needed + at build time */ + +/* Copyright (C) 2024 Free Software Foundation, Inc. + + This file is part of GNU Bash, the Bourne Again SHell. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see . +*/ + +#if !defined (BUILDCONF_H_) +#define BUILDCONF_H_ + +/* assume C90/POSIX-1992 compilation environment if cross-compiling */ + +/* pacify glibc */ +#ifndef _POSIX_C_SOURCE +# define _POSIX_C_SOURCE 2 +# define _XOPEN_SOURCE 500 +#endif + +#define HAVE_LOCALE_H 1 + +#define HAVE_UNISTD_H 1 +#define HAVE_STRING_H 1 +#define HAVE_STDLIB_H 1 + +#define HAVE_RENAME + +/* defining this implies a C23 environment */ +#undef HAVE_C_BOOL + +/* Don't assume this; it's from C99; let syntax.h define a replacement */ +/* #undef HAVE_ISBLANK */ + +#undef PROCESS_SUBSTITUTION + +#undef EXTENDED_GLOB + +#endif /* BUILDCONF_H */ diff --git a/builtins/Makefile.in b/builtins/Makefile.in index 642878c6c..7e0ec3242 100644 --- a/builtins/Makefile.in +++ b/builtins/Makefile.in @@ -1,6 +1,6 @@ # This Makefile for building libbuiltins.a is in -*- text -*- for Emacs. # -# Copyright (C) 1996-2022 Free Software Foundation, Inc. +# Copyright (C) 1996-2024 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -56,6 +56,8 @@ BUILD_DIR = @BUILD_DIR@ LIBBUILD = ${BUILD_DIR}/lib +DEBUG = @DEBUG@ + PROFILE_FLAGS = @PROFILE_FLAGS@ CFLAGS = @CFLAGS@ CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@ @CROSS_COMPILE@ @@ -77,6 +79,9 @@ BASHINCDIR = ${topdir}/include RL_INCLUDEDIR = @RL_INCLUDEDIR@ +HIST_LIBSRC = ${topdir}/lib/readline +RL_LIBSRC = ${topdir}/lib/readline + INTL_LIBSRC = ${topdir}/lib/intl INTL_BUILDDIR = ${LIBBUILD}/intl INTL_LIBDIR = ${INTL_BUILDDIR} @@ -92,9 +97,10 @@ HELPFILES_TARGET = @HELPFILES_TARGET@ INCLUDES = -I. -I.. @RL_INCLUDE@ -I$(topdir) -I$(BASHINCDIR) -I$(topdir)/lib -I$(srcdir) ${INTL_INC} -BASE_CCFLAGS = ${PROFILE_FLAGS} $(DEFS) $(LOCAL_DEFS) $(SYSTEM_FLAGS) \ +BASE_CCFLAGS = ${PROFILE_FLAGS} $(DEFS) $(LOCAL_DEFS) \ ${INCLUDES} $(STYLE_CFLAGS) $(LOCAL_CFLAGS) +ADDON_CFLAGS= CCFLAGS = ${ADDON_CFLAGS} $(BASE_CCFLAGS) $(CPPFLAGS) $(CFLAGS) CCFLAGS_FOR_BUILD = $(BASE_CCFLAGS) $(CPPFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) @@ -108,6 +114,8 @@ DIRECTDEFINE = -D $(srcdir) HELPDIRDEFINE = @HELPDIRDEFINE@ HELPSTRINGS = @HELPSTRINGS@ +STDCKDINT_H = @STDCKDINT_H@ + # xxx this is bad style RL_LIBSRC = $(topdir)/lib/readline @@ -252,6 +260,8 @@ documentation: builtins.texi builtins.texi: $(MKBUILTINS) ./$(MKBUILTINS) -documentonly $(DEFSRC) +.PHONY: basic-clean clean maintainer-clean distclean mostlyclean maybe-clean + clean: $(RM) $(OFILES) $(CREATED_FILES) libbuiltins.a $(RM) $(MKBUILTINS) gen-helpfiles $(CREATED_OBJECTS) @@ -265,8 +275,9 @@ distclean maintainer-clean: clean $(OFILES): $(MKBUILTINS) ../config.h -../version.h: ../config.h ../Makefile Makefile - -( cd ${BUILD_DIR} && ${MAKE} ${MFLAGS} version.h ) +# sketchy rule here +#../version.h: ../config.h ../Makefile Makefile +# -( cd ${BUILD_DIR} && ${MAKE} ${BASH_MAKEFLAGS} version.h ) # maintainer special - for now po: builtins.c @@ -275,7 +286,7 @@ po: builtins.c ${LIBINTL_H}: @echo making $@ in ${INTL_BUILDDIR} @(cd ${INTL_BUILDDIR} && \ - $(MAKE) $(MFLAGS) libintl.h) || exit 1 + $(MAKE) $(BASH_MAKEFLAGS) libintl.h) || exit 1 # dependencies @@ -343,6 +354,7 @@ common.o: $(topdir)/builtins.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h common.o: $(topdir)/subst.h $(topdir)/execute_cmd.h $(topdir)/error.h common.o: $(topdir)/externs.h ../pathnames.h ./builtext.h common.o: $(BASHINCDIR)/chartypes.h +common.o: $(BASHINCDIR)/unlocked-io.h evalfile.o: $(topdir)/bashtypes.h $(BASHINCDIR)/posixstat.h ${BASHINCDIR}/filecntl.h evalfile.o: $(topdir)/bashansi.h $(BASHINCDIR)/ansi_stdlib.h evalfile.o: $(topdir)/shell.h $(topdir)/syntax.h ../config.h $(topdir)/bashjmp.h @@ -439,6 +451,7 @@ echo.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/ echo.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h echo.o: $(BASHINCDIR)/maxpath.h ../pathnames.h echo.o: $(srcdir)/common.h +echo.o: $(BASHINCDIR)/unlocked-io.h enable.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h enable.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h enable.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h @@ -468,6 +481,7 @@ exit.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/jobs.h exit.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h exit.o: $(topdir)/execute_cmd.h exit.o: $(BASHINCDIR)/maxpath.h ./builtext.h ../pathnames.h +exit.o: $(BASHINCDIR)/unlocked-io.h fc.o: $(topdir)/bashtypes.h $(BASHINCDIR)/posixstat.h fc.o: $(topdir)/builtins.h $(topdir)/command.h $(srcdir)/bashgetopt.h fc.o: $(topdir)/bashhist.h $(topdir)/parser.h @@ -478,6 +492,7 @@ fc.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/shell.h $(topdir)/syntax.h fc.o: $(topdir)/flags.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h fc.o: $(topdir)/bashansi.h $(BASHINCDIR)/ansi_stdlib.h $(BASHINCDIR)/chartypes.h fc.o: ../pathnames.h +fc.o: $(BASHINCDIR)/unlocked-io.h fg_bg.o: $(topdir)/bashtypes.h $(srcdir)/bashgetopt.h fg_bg.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h fg_bg.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h @@ -498,6 +513,7 @@ hash.o: $(topdir)/findcmd.h $(topdir)/hashlib.h $(topdir)/sig.h hash.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h hash.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h hash.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h +hash.o: $(BASHINCDIR)/unlocked-io.h hash.o: $(topdir)/conftypes.h $(topdir)/execute_cmd.h hash.o: $(srcdir)/common.h $(BASHINCDIR)/maxpath.h ../pathnames.h help.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h @@ -507,6 +523,7 @@ help.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h help.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h help.o: $(topdir)/conftypes.h $(topdir)/execute_cmd.h help.o: ${srcdir}/common.h $(topdir)/sig.h ../pathnames.h +help.o: $(BASHINCDIR)/unlocked-io.h history.o: $(topdir)/bashtypes.h history.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h history.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h @@ -515,6 +532,7 @@ history.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/sig.h $(topdir)/pars history.o: ${BASHINCDIR}/filecntl.h $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h history.o: $(topdir)/variables.h $(topdir)/conftypes.h $(topdir)/bashhist.h $(BASHINCDIR)/maxpath.h history.o: ../pathnames.h +history.o: $(BASHINCDIR)/unlocked-io.h inlib.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h inlib.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h inlib.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h @@ -538,6 +556,7 @@ let.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/s let.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h let.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h let.o: ../pathnames.h +let.o: $(BASHINCDIR)/unlocked-io.h printf.o: ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/bashjmp.h printf.o: $(topdir)/command.h $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h printf.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h @@ -547,6 +566,8 @@ printf.o: $(topdir)/variables.h $(topdir)/conftypes.h $(BASHINCDIR)/stdc.h $(src printf.o: $(topdir)/bashtypes.h ${srcdir}/common.h $(BASHINCDIR)/chartypes.h printf.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h printf.o: ../pathnames.h +printf.o: $(BASHINCDIR)/unlocked-io.h +printf.o: ${STDCKDINT_H} ${BASHINCDIR}/intprops-internal.h pushd.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h pushd.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h pushd.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h @@ -554,6 +575,7 @@ pushd.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/sig.h pushd.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h pushd.o: $(BASHINCDIR)/maxpath.h $(srcdir)/common.h ./builtext.h pushd.o: ../pathnames.h +pushd.o: $(BASHINCDIR)/unlocked-io.h read.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h read.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h read.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h @@ -562,6 +584,7 @@ read.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/v read.o: $(BASHINCDIR)/shtty.h $(topdir)/sig.h read.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h read.o: $(topdir)/arrayfunc.h ../pathnames.h +read.o: $(BASHINCDIR)/unlocked-io.h return.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h return.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h return.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h @@ -622,6 +645,7 @@ times.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir) times.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h times.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h times.o: $(BASHINCDIR)/posixtime.h ../pathnames.h +times.o: $(BASHINCDIR)/unlocked-io.h trap.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h trap.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/externs.h trap.o: $(topdir)/quit.h $(srcdir)/common.h $(BASHINCDIR)/maxpath.h $(topdir)/sig.h @@ -671,7 +695,34 @@ mapfile.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h mapfile.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/variables.h $(topdir)/conftypes.h mapfile.o: $(topdir)/arrayfunc.h ../pathnames.h -#bind.o: $(RL_LIBSRC)chardefs.h $(RL_LIBSRC)readline.h $(RL_LIBSRC)keymaps.h +bind.o: $(RL_LIBSRC)/rlconf.h +bind.o: $(RL_LIBSRC)/keymaps.h $(RL_LIBSRC)/rlstdc.h +bind.o: $(RL_LIBSRC)/chardefs.h $(RL_LIBSRC)/readline.h +bind.o: $(RL_LIBSRC)/rltypedefs.h ${RL_LIBSRC}/rlmbutil.h +complete.o: $(RL_LIBSRC)/rlconf.h +complete.o: $(RL_LIBSRC)/keymaps.h $(RL_LIBSRC)/rlstdc.h +complete.o: $(RL_LIBSRC)/chardefs.h $(RL_LIBSRC)/readline.h +complete.o: $(RL_LIBSRC)/rltypedefs.h ${RL_LIBSRC}/rlmbutil.h +history.o: $(RL_LIBSRC)/rlconf.h +history.o: $(RL_LIBSRC)/keymaps.h $(RL_LIBSRC)/rlstdc.h +history.o: $(RL_LIBSRC)/chardefs.h $(RL_LIBSRC)/readline.h +history.o: $(RL_LIBSRC)/rltypedefs.h ${RL_LIBSRC}/rlmbutil.h +read.o: $(RL_LIBSRC)/rlconf.h +read.o: $(RL_LIBSRC)/keymaps.h $(RL_LIBSRC)/rlstdc.h +read.o: $(RL_LIBSRC)/chardefs.h $(RL_LIBSRC)/readline.h +read.o: $(RL_LIBSRC)/rltypedefs.h ${RL_LIBSRC}/rlmbutil.h +set.o: $(RL_LIBSRC)/rlconf.h +set.o: $(RL_LIBSRC)/keymaps.h $(RL_LIBSRC)/rlstdc.h +set.o: $(RL_LIBSRC)/chardefs.h $(RL_LIBSRC)/readline.h +set.o: $(RL_LIBSRC)/rltypedefs.h ${RL_LIBSRC}/rlmbutil.h + +common.o: $(HIST_LIBSRC)/history.h $(RL_LIBSRC)/rlstdc.h +evalfile.o: $(HIST_LIBSRC)/history.h $(RL_LIBSRC)/rlstdc.h +evalstring.o: $(HIST_LIBSRC)/history.h $(RL_LIBSRC)/rlstdc.h +bind.o: $(HIST_LIBSRC)/history.h $(RL_LIBSRC)/rlstdc.h +fc.o: $(HIST_LIBSRC)/history.h $(RL_LIBSRC)/rlstdc.h +history.o: $(HIST_LIBSRC)/history.h $(RL_LIBSRC)/rlstdc.h +shopt.o: $(HIST_LIBSRC)/history.h $(RL_LIBSRC)/rlstdc.h # libintl dependencies bind.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h diff --git a/builtins/alias.def b/builtins/alias.def index 0ab906964..0deb9d34b 100644 --- a/builtins/alias.def +++ b/builtins/alias.def @@ -1,7 +1,7 @@ This file is alias.def, from which is created alias.c It implements the builtins "alias" and "unalias" in Bash. -Copyright (C) 1987-2020 Free Software Foundation, Inc. +Copyright (C) 1987-2023 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -63,12 +63,11 @@ $END /* Flags for print_alias */ #define AL_REUSABLE 0x01 -static void print_alias PARAMS((alias_t *, int)); +static int print_alias (alias_t *, int); /* Hack the alias command in a Korn shell way. */ int -alias_builtin (list) - WORD_LIST *list; +alias_builtin (WORD_LIST *list) { int any_failed, offset, pflag, dflags; alias_t **alias_list, *t; @@ -104,13 +103,14 @@ alias_builtin (list) if (alias_list == 0) return (EXECUTION_SUCCESS); + any_failed = EXECUTION_SUCCESS; for (offset = 0; alias_list[offset]; offset++) - print_alias (alias_list[offset], dflags); + if (any_failed = print_alias (alias_list[offset], dflags) != EXECUTION_SUCCESS) + break; free (alias_list); /* XXX - Do not free the strings. */ - if (list == 0) - return (sh_chkwrite (EXECUTION_SUCCESS)); + return (any_failed != EXECUTION_SUCCESS ? EXECUTION_FAILURE : sh_chkwrite (EXECUTION_SUCCESS)); } any_failed = 0; @@ -126,7 +126,7 @@ alias_builtin (list) name[offset] = '\0'; value = name + offset + 1; - if (legal_alias_name (name, 0) == 0) + if (valid_alias_name (name, 0) == 0) { builtin_error (_("`%s': invalid alias name"), name); any_failed++; @@ -138,7 +138,10 @@ alias_builtin (list) { t = find_alias (name); if (t) - print_alias (t, dflags); + { + if (print_alias (t, dflags) != EXECUTION_SUCCESS) + return (EXECUTION_FAILURE); + } else { sh_notfound (name); @@ -167,10 +170,9 @@ $END #if defined (ALIAS) /* Remove aliases named in LIST from the aliases database. */ int -unalias_builtin (list) - register WORD_LIST *list; +unalias_builtin (WORD_LIST *list) { - register alias_t *alias; + alias_t *alias; int opt, aflag; aflag = 0; @@ -206,11 +208,7 @@ unalias_builtin (list) aflag = 0; while (list) { - alias = find_alias (list->word->word); - - if (alias) - remove_alias (alias->name); - else + if (remove_alias (list->word->word) < 0) { sh_notfound (list->word->word); aflag++; @@ -223,10 +221,8 @@ unalias_builtin (list) } /* Output ALIAS in such a way as to allow it to be read back in. */ -static void -print_alias (alias, flags) - alias_t *alias; - int flags; +static int +print_alias (alias_t *alias, int flags) { char *value; @@ -236,6 +232,6 @@ print_alias (alias, flags) printf ("%s=%s\n", alias->name, value); free (value); - fflush (stdout); + return (sh_chkwrite (EXECUTION_SUCCESS)); } #endif /* ALIAS */ diff --git a/builtins/bashgetopt.c b/builtins/bashgetopt.c index d40ffa23a..92c015592 100644 --- a/builtins/bashgetopt.c +++ b/builtins/bashgetopt.c @@ -1,6 +1,6 @@ /* bashgetopt.c -- `getopt' for use by the builtins. */ -/* Copyright (C) 1992-2021 Free Software Foundation, Inc. +/* Copyright (C) 1992-2022 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -48,9 +48,7 @@ WORD_LIST *lcurrent = (WORD_LIST *)NULL; WORD_LIST *loptend; /* Points to the first non-option argument in the list */ int -internal_getopt(list, opts) -WORD_LIST *list; -char *opts; +internal_getopt(WORD_LIST *list, char *opts) { register int c; register char *cp; @@ -154,7 +152,7 @@ char *opts; list_optflags = 0; } } else { - if (lcurrent->next && legal_number(lcurrent->next->word->word, (intmax_t *)0)) { + if (lcurrent->next && valid_number(lcurrent->next->word->word, (intmax_t *)0)) { lcurrent = lcurrent->next; list_optarg = lcurrent->word->word; list_optflags = lcurrent->word->flags; @@ -187,7 +185,7 @@ char *opts; */ void -reset_internal_getopt () +reset_internal_getopt (void) { lhead = lcurrent = loptend = (WORD_LIST *)NULL; sp = 1; diff --git a/builtins/bashgetopt.h b/builtins/bashgetopt.h index 79be34315..4f58b4ba5 100644 --- a/builtins/bashgetopt.h +++ b/builtins/bashgetopt.h @@ -1,6 +1,6 @@ /* bashgetopt.h -- extern declarations for stuff defined in bashgetopt.c. */ -/* Copyright (C) 1993-2021 Free Software Foundation, Inc. +/* Copyright (C) 1993-2022 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -37,7 +37,7 @@ extern int list_opttype; extern WORD_LIST *lcurrent; extern WORD_LIST *loptend; -extern int internal_getopt PARAMS((WORD_LIST *, char *)); -extern void reset_internal_getopt PARAMS((void)); +extern int internal_getopt (WORD_LIST *, char *); +extern void reset_internal_getopt (void); #endif /* !__BASH_GETOPT_H */ diff --git a/builtins/bind.def b/builtins/bind.def index 53a65ac7c..5f8a47435 100644 --- a/builtins/bind.def +++ b/builtins/bind.def @@ -1,7 +1,7 @@ This file is bind.def, from which is created bind.c. It implements the builtin "bind" in Bash. -Copyright (C) 1987-2021 Free Software Foundation, Inc. +Copyright (C) 1987-2024 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -57,6 +57,9 @@ Options: -X List key sequences bound with -x and associated commands in a form that can be reused as input. +If arguments remain after option processing, the -p and -P options treat +them as readline command names and restrict output to those names. + Exit Status: bind returns 0 unless an unrecognized option is given or an error occurs. $END @@ -86,9 +89,9 @@ extern int errno; #include "bashgetopt.h" #include "common.h" -static int query_bindings PARAMS((char *)); -static int unbind_command PARAMS((char *)); -static int unbind_keyseq PARAMS((char *)); +static int query_bindings (char *); +static int unbind_command (char *); +static int unbind_keyseq (char *); #define BIND_RETURN(x) do { return_code = x; goto bind_exit; } while (0) @@ -108,23 +111,16 @@ static int unbind_keyseq PARAMS((char *)); #define XXFLAG 0x2000 int -bind_builtin (list) - WORD_LIST *list; +bind_builtin (WORD_LIST *list) { int return_code; Keymap kmap, saved_keymap; int flags, opt; char *initfile, *map_name, *fun_name, *unbind_name, *remove_seq, *cmd_seq, *t; + WORD_LIST *savelist; if (no_line_editing) - { -#if 0 - builtin_error (_("line editing not enabled")); - return (EXECUTION_FAILURE); -#else - builtin_warning (_("line editing not enabled")); -#endif - } + builtin_warning (_("line editing not enabled")); kmap = saved_keymap = (Keymap) NULL; flags = 0; @@ -192,7 +188,7 @@ bind_builtin (list) case 'X': flags |= XXFLAG; break; - case GETOPT_HELP: + CASE_HELPOPT; default: builtin_usage (); BIND_RETURN (EX_USAGE); @@ -227,10 +223,39 @@ bind_builtin (list) rl_list_funmap_names (); if (flags & PFLAG) - rl_function_dumper (1); + { + if (shell_compatibility_level <= 52 || list == 0) + rl_function_dumper (1); + else + { + /* Allow both -p and -P to have a crack at the additional + arguments, just like supplying both -p and -P without + arguments displays the full set of bindings twice in + two separate formats. Otherwise, -p takes all the + arguments and -P prints all the bindings. */ + savelist = (flags & PPFLAG) ? list : (WORD_LIST *)NULL; + while (list) + { + rl_print_keybinding (list->word->word, kmap, 1); + list = list->next; + } + list = savelist; + } + } + /* should combine this with the above clause */ if (flags & PPFLAG) - rl_function_dumper (0); + { + if (shell_compatibility_level <= 52 || list == 0) + rl_function_dumper (0); + else + while (list) + { + rl_print_keybinding (list->word->word, kmap, 0); + list = list->next; + } + } + if (flags & SFLAG) rl_macro_dumper (1); @@ -249,7 +274,7 @@ bind_builtin (list) if (rl_read_init_file (initfile) != 0) { t = printable_filename (initfile, 0); - builtin_error (_("%s: cannot read: %s"), t, strerror (errno)); + builtin_error ("%s: %s: %s", t, _("cannot read"), strerror (errno)); if (t != initfile) free (t); BIND_RETURN (EXECUTION_FAILURE); @@ -277,7 +302,8 @@ bind_builtin (list) /* Process the rest of the arguments as binding specifications. */ while (list) { - int olen, nlen, d, i; + size_t olen, nlen; + int d, i; char **obindings, **nbindings; obindings = rl_invoking_keyseqs (bash_execute_unix_command); @@ -315,8 +341,7 @@ bind_builtin (list) } static int -query_bindings (name) - char *name; +query_bindings (char *name) { rl_command_func_t *function; char **keyseqs; @@ -347,8 +372,7 @@ query_bindings (name) } static int -unbind_command (name) - char *name; +unbind_command (char *name) { rl_command_func_t *function; @@ -364,8 +388,7 @@ unbind_command (name) } static int -unbind_keyseq (seq) - char *seq; +unbind_keyseq (char *seq) { char *kseq; int kslen, type; diff --git a/builtins/break.def b/builtins/break.def index b73ed5e5b..b0c0a780e 100644 --- a/builtins/break.def +++ b/builtins/break.def @@ -1,7 +1,7 @@ This file is break.def, from which is created break.c. It implements the builtins "break" and "continue" in Bash. -Copyright (C) 1987-2020 Free Software Foundation, Inc. +Copyright (C) 1987-2022 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -46,7 +46,7 @@ $END #include "../execute_cmd.h" #include "common.h" -static int check_loop_level PARAMS((void)); +static int check_loop_level (void); /* The depth of while's and until's. */ int loop_level = 0; @@ -60,8 +60,7 @@ int continuing = 0; /* Set up to break x levels, where x defaults to 1, but can be specified as the first argument. */ int -break_builtin (list) - WORD_LIST *list; +break_builtin (WORD_LIST *list) { intmax_t newbreak; @@ -70,10 +69,14 @@ break_builtin (list) if (check_loop_level () == 0) return (EXECUTION_SUCCESS); - (void)get_numeric_arg (list, 1, &newbreak); + /* This will not return if an error is encountered. */ + (void)get_numeric_arg (list, interactive_shell ? 2 : 1, &newbreak); if (newbreak <= 0) { + /* skip over `--' option to get the right error message */ + if (list && list->word && ISOPTION (list->word->word, '-')) + list = list->next; sh_erange (list->word->word, _("loop count")); breaking = loop_level; return (EXECUTION_FAILURE); @@ -102,8 +105,7 @@ $END /* Set up to continue x levels, where x defaults to 1, but can be specified as the first argument. */ int -continue_builtin (list) - WORD_LIST *list; +continue_builtin (WORD_LIST *list) { intmax_t newcont; @@ -112,10 +114,14 @@ continue_builtin (list) if (check_loop_level () == 0) return (EXECUTION_SUCCESS); - (void)get_numeric_arg (list, 1, &newcont); + /* This will not return if an error is encountered. */ + (void)get_numeric_arg (list, interactive_shell ? 2 : 1, &newcont); if (newcont <= 0) { + /* skip over `--' option to get the right error message */ + if (list && list->word && ISOPTION (list->word->word, '-')) + list = list->next; sh_erange (list->word->word, _("loop count")); breaking = loop_level; return (EXECUTION_FAILURE); @@ -132,7 +138,7 @@ continue_builtin (list) /* Return non-zero if a break or continue command would be okay. Print an error message if break or continue is meaningless here. */ static int -check_loop_level () +check_loop_level (void) { #if defined (BREAK_COMPLAINS) if (loop_level == 0 && posixly_correct == 0) diff --git a/builtins/builtin.def b/builtins/builtin.def index 74060ee09..3ceb50a6d 100644 --- a/builtins/builtin.def +++ b/builtins/builtin.def @@ -1,7 +1,7 @@ This file is builtin.def, from which is created builtin.c. It implements the builtin "builtin" in Bash. -Copyright (C) 1987-2017 Free Software Foundation, Inc. +Copyright (C) 1987-2017,2022 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -50,8 +50,7 @@ $END /* Run the command mentioned in list directly, without going through the normal alias/function/builtin/filename lookup process. */ int -builtin_builtin (list) - WORD_LIST *list; +builtin_builtin (WORD_LIST *list) { sh_builtin_func_t *function; register char *command; diff --git a/builtins/caller.def b/builtins/caller.def index 1000979dd..e0909cf56 100644 --- a/builtins/caller.def +++ b/builtins/caller.def @@ -2,7 +2,7 @@ This file is caller.def, from which is created caller.c. It implements the builtin "caller" in Bash. Copyright (C) 2002-2008 Rocky Bernstein for Free Software Foundation, Inc. -Copyright (C) 2008-2019 Free Software Foundation, Inc. +Copyright (C) 2008-2019,2023 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -69,8 +69,7 @@ extern int errno; #endif /* !errno */ int -caller_builtin (list) - WORD_LIST *list; +caller_builtin (WORD_LIST *list) { #if !defined (ARRAY_VARS) printf ("1 NULL\n"); @@ -109,7 +108,7 @@ caller_builtin (list) if (funcname_a == 0 || array_empty (funcname_a)) return (EXECUTION_FAILURE); - if (legal_number (list->word->word, &num)) + if (valid_number (list->word->word, &num)) { lineno_s = array_reference (bash_lineno_a, num); source_s = array_reference (bash_source_a, num+1); @@ -140,7 +139,12 @@ N_("Returns the context of the current subroutine call.\n\ provide a stack trace.\n\ \n\ The value of EXPR indicates how many call frames to go back before the\n\ - current one; the top frame is frame 0."), + current one; the top frame is frame 0.\n\ + \n\ + Exit Status:\n\ + Returns 0 unless the shell is not executing a shell function or EXPR\n\ + is invalid." +), (char *)NULL }; diff --git a/builtins/cd.def b/builtins/cd.def index b87c5d9d2..5b39cb52b 100644 --- a/builtins/cd.def +++ b/builtins/cd.def @@ -1,7 +1,7 @@ This file is cd.def, from which is created cd.c. It implements the builtins "cd" and "pwd" in Bash. -Copyright (C) 1987-2022 Free Software Foundation, Inc. +Copyright (C) 1987-2024 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -56,13 +56,13 @@ extern int errno; extern const char * const bash_getcwd_errstr; -static int bindpwd PARAMS((int)); -static int setpwd PARAMS((char *)); -static char *resetpwd PARAMS((char *)); -static int change_to_directory PARAMS((char *, int, int)); +static int bindpwd (int); +static int setpwd (char *); +static char *resetpwd (char *); +static int change_to_directory (char *, int, int); -static int cdxattr PARAMS((char *, char **)); -static void resetxattr PARAMS((void)); +static int cdxattr (char *, char **); +static void resetxattr (void); /* Change this to 1 to get cd spelling correction by default. */ int cdspelling = 0; @@ -75,7 +75,7 @@ static int xattrfd = -1; $BUILTIN cd $FUNCTION cd_builtin -$SHORT_DOC cd [-L|[-P [-e]] [-@]] [dir] +$SHORT_DOC cd [-L|[-P [-e]]] [-@] [dir] Change the shell working directory. Change the current directory to DIR. The default DIR is the value of the @@ -115,8 +115,7 @@ $END /* Just set $PWD, don't change OLDPWD. Used by `pwd -P' in posix mode. */ static int -setpwd (dirname) - char *dirname; +setpwd (char *dirname) { int old_anm; SHELL_VAR *tvar; @@ -134,8 +133,7 @@ setpwd (dirname) } static int -bindpwd (no_symlinks) - int no_symlinks; +bindpwd (int no_symlinks) { char *dirname, *pwdvar; int old_anm, r, canon_failed; @@ -160,10 +158,9 @@ bindpwd (no_symlinks) pwdvar = get_string_value ("PWD"); tvar = bind_variable ("OLDPWD", pwdvar, 0); - if (tvar && readonly_p (tvar)) + if (tvar == 0 || readonly_p (tvar)) r = EXECUTION_FAILURE; - - if (old_anm == 0 && array_needs_making && exported_p (tvar)) + else if (old_anm == 0 && array_needs_making && exported_p (tvar)) { update_export_env_inplace ("OLDPWD=", 7, pwdvar); array_needs_making = 0; @@ -183,8 +180,7 @@ bindpwd (no_symlinks) /* Call get_working_directory to reset the value of the_current_working_directory () */ static char * -resetpwd (caller) - char *caller; +resetpwd (char *caller) { char *tdir; @@ -194,10 +190,9 @@ resetpwd (caller) return (tdir); } +/* return new constructed directory name in *NDIRP */ static int -cdxattr (dir, ndirp) - char *dir; /* don't assume we can always free DIR */ - char **ndirp; /* return new constructed directory name */ +cdxattr (char *dir, char **ndirp) { #if defined (O_XATTR) int apfd, fd, r, e; @@ -241,7 +236,7 @@ cdxattr (dir, ndirp) /* Clean up the O_XATTR baggage. Currently only closes xattrfd */ static void -resetxattr () +resetxattr (void) { #if defined (O_XATTR) if (xattrfd >= 0) @@ -264,8 +259,7 @@ resetxattr () so the programming interface is simple, and it handles errors and restrictions properly. */ int -cd_builtin (list) - WORD_LIST *list; +cd_builtin (WORD_LIST *list) { char *dirname, *cdpath, *path, *temp; int path_index, no_symlinks, opt, lflag, e; @@ -320,9 +314,9 @@ cd_builtin (list) if (list == 0) { /* `cd' without arguments is equivalent to `cd $HOME' */ - dirname = get_string_value ("HOME"); + dirname = get_string_value ("HOME"); /* POSIX cd step 2 */ - if (dirname == 0) + if (dirname == 0) /* POSIX cd step 1 */ { builtin_error (_("HOME not set")); return (EXECUTION_FAILURE); @@ -333,16 +327,14 @@ cd_builtin (list) else if (list->next) { builtin_error (_("too many arguments")); - return (EXECUTION_FAILURE); + return (EX_USAGE); } #endif -#if 0 else if (list->word->word[0] == '\0') { - builtin_error (_("null directory")); + builtin_error (_("null directory")); /* POSIX cd implementation defined */ return (EXECUTION_FAILURE); } -#endif else if (list->word->word[0] == '-' && list->word->word[1] == '\0') { /* This is `cd -', equivalent to `cd $OLDPWD' */ @@ -353,19 +345,14 @@ cd_builtin (list) builtin_error (_("OLDPWD not set")); return (EXECUTION_FAILURE); } -#if 0 - lflag = interactive ? LCD_PRINTPATH : 0; -#else - lflag = LCD_PRINTPATH; /* According to SUSv3 */ -#endif + lflag = LCD_PRINTPATH; /* POSIX cd `-' operand */ } - else if (absolute_pathname (list->word->word)) + else dirname = list->word->word; - else if (privileged_mode == 0 && (cdpath = get_string_value ("CDPATH"))) - { - dirname = list->word->word; - /* Find directory in $CDPATH. */ + if (privileged_mode == 0 && absolute_pathname (dirname) == 0 && (cdpath = get_string_value ("CDPATH"))) + { + /* Find directory in $CDPATH, POSIX cd step 5. */ path_index = 0; while (path = extract_colon_unit (cdpath, &path_index)) { @@ -395,23 +382,7 @@ cd_builtin (list) else free (temp); } - -#if 0 - /* changed for bash-4.2 Posix cd description steps 5-6 */ - /* POSIX.2 says that if `.' does not appear in $CDPATH, we don't - try the current directory, so we just punt now with an error - message if POSIXLY_CORRECT is non-zero. The check for cdpath[0] - is so we don't mistakenly treat a CDPATH value of "" as not - specifying the current directory. */ - if (posixly_correct && cdpath[0]) - { - builtin_error ("%s: %s", dirname, strerror (ENOENT)); - return (EXECUTION_FAILURE); - } -#endif } - else - dirname = list->word->word; /* When we get here, DIRNAME is the directory to change to. If we chdir successfully, just return. */ @@ -456,6 +427,7 @@ cd_builtin (list) builtin_error ("%s: %s", temp, strerror (e)); if (temp != dirname) free (temp); + /* posix says to return >1 if eflag && no_symlinks?? */ return (EXECUTION_FAILURE); } @@ -482,8 +454,7 @@ static int verbatim_pwd; /* Print the name of the current working directory. */ int -pwd_builtin (list) - WORD_LIST *list; +pwd_builtin (WORD_LIST *list) { char *directory; int opt, pflag; @@ -548,9 +519,7 @@ pwd_builtin (list) to the working directory. Return 1 on success, 0 on failure. */ static int -change_to_directory (newdir, nolinks, xattr) - char *newdir; - int nolinks, xattr; +change_to_directory (char *newdir, int nolinks, int xattr) { char *t, *tdir, *ndir; int err, canon_failed, r, ndlen; @@ -568,8 +537,11 @@ change_to_directory (newdir, nolinks, xattr) /* TDIR is either the canonicalized absolute pathname of NEWDIR (nolinks == 0) or the absolute physical pathname of NEWDIR (nolinks != 0). */ - tdir = nolinks ? sh_physpath (t, 0) - : sh_canonpath (t, PATH_CHECKDOTDOT|PATH_CHECKEXISTS); + if (t && *t) + tdir = nolinks ? sh_physpath (t, 0) + : sh_canonpath (t, PATH_CHECKDOTDOT|PATH_CHECKEXISTS); + else + tdir = NULL; ndlen = strlen (newdir); @@ -662,9 +634,17 @@ change_to_directory (newdir, nolinks, xattr) /* We're not in physical mode (nolinks == 0), but we failed to change to the canonicalized directory name (TDIR). Try what the user passed - verbatim. If we succeed, reinitialize the_current_working_directory. - POSIX requires that we just fail here, so we do in posix mode. */ - if (posixly_correct == 0 && chdir (newdir) == 0) + verbatim. If we succeed, reinitialize the_current_working_directory. */ + + /* The first block is step 9 in the POSIX cd algorithm. */ + if (posixly_correct && ndlen < PATH_MAX && strlen (tdir) >= PATH_MAX) + r = chdir (newdir); + else if (posixly_correct == 0) + r = chdir (newdir); + else + r = -1; + + if (r == 0) { t = resetpwd ("cd"); if (t == 0) diff --git a/builtins/colon.def b/builtins/colon.def index 6891b0799..7fe8cf00f 100644 --- a/builtins/colon.def +++ b/builtins/colon.def @@ -1,7 +1,7 @@ This file is colon.def, from which is created colon.c. It implements the builtin ":" in Bash. -Copyright (C) 1987-2019 Free Software Foundation, Inc. +Copyright (C) 1987-2019,2022 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -61,16 +61,14 @@ $END /* Return a successful result. */ int -colon_builtin (ignore) - WORD_LIST *ignore; +colon_builtin (WORD_LIST *ignore) { return (0); } /* Return an unsuccessful result. */ int -false_builtin (ignore) - WORD_LIST *ignore; +false_builtin (WORD_LIST *ignore) { return (1); } diff --git a/builtins/command.def b/builtins/command.def index 3efdbe6bc..21cc982b5 100644 --- a/builtins/command.def +++ b/builtins/command.def @@ -1,7 +1,7 @@ This file is command.def, from which is created command.c. It implements the builtin "command" in Bash. -Copyright (C) 1987-2020 Free Software Foundation, Inc. +Copyright (C) 1987-2025 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -32,7 +32,8 @@ on disk when a function with the same name exists. Options: -p use a default value for PATH that is guaranteed to find all of the standard utilities - -v print a description of COMMAND similar to the `type' builtin + -v print a single word indicating the command or filename that + invokes COMMAND -V print a more verbose description of each COMMAND Exit Status: @@ -53,18 +54,18 @@ $END #include "../shell.h" #include "../execute_cmd.h" #include "../flags.h" +#include "../parser.h" #include "bashgetopt.h" #include "common.h" #if defined (_CS_PATH) && defined (HAVE_CONFSTR) && !HAVE_DECL_CONFSTR -extern size_t confstr PARAMS((int, char *, size_t)); +extern size_t confstr (int, char *, size_t); #endif /* Run the commands mentioned in LIST without paying attention to shell functions. */ int -command_builtin (list) - WORD_LIST *list; +command_builtin (WORD_LIST *list) { int result, verbose, use_standard_path, opt; COMMAND *command; @@ -124,20 +125,22 @@ command_builtin (list) #define COMMAND_BUILTIN_FLAGS (CMD_NO_FUNCTIONS | CMD_INHIBIT_EXPANSION | CMD_COMMAND_BUILTIN | (use_standard_path ? CMD_STDPATH : 0)) - INTERNAL_DEBUG (("command_builtin: running execute_command for `%s'", list->word->word)); + /* This code isn't executed any more; look at execute_cmd.c:execute_simple_command() + where command is treated as a pseudo-reserved prefix so we can optimize + away forks where possible. */ /* We don't want this to be reparsed (consider command echo 'foo &'), so just make a simple_command structure and call execute_command with it. */ - command = make_bare_simple_command (); + command = make_bare_simple_command (line_number); command->value.Simple->words = (WORD_LIST *)copy_word_list (list); command->value.Simple->redirects = (REDIRECT *)NULL; command->flags |= COMMAND_BUILTIN_FLAGS; command->value.Simple->flags |= COMMAND_BUILTIN_FLAGS; - add_unwind_protect ((char *)dispose_command, command); + add_unwind_protect (uw_dispose_command, command); result = execute_command (command); + dispose_command (command); - run_unwind_frame ("command_builtin"); - + discard_unwind_frame ("command_builtin"); return (result); } diff --git a/builtins/common.c b/builtins/common.c index 19b00c4d0..a681cee43 100644 --- a/builtins/common.c +++ b/builtins/common.c @@ -1,6 +1,6 @@ /* common.c - utility functions for all builtins */ -/* Copyright (C) 1987-2021 Free Software Foundation, Inc. +/* Copyright (C) 1987-2024 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -34,12 +34,7 @@ #include #include - -#if defined (PREFER_STDARG) -# include -#else -# include -#endif +#include #include "../bashansi.h" #include "../bashintl.h" @@ -85,7 +80,7 @@ sh_builtin_func_t *this_shell_builtin = (sh_builtin_func_t *)NULL; shell. */ static void -builtin_error_prolog () +builtin_error_prolog (void) { char *name; @@ -100,19 +95,13 @@ builtin_error_prolog () } void -#if defined (PREFER_STDARG) builtin_error (const char *format, ...) -#else -builtin_error (format, va_alist) - const char *format; - va_dcl -#endif { va_list args; builtin_error_prolog (); - SH_VA_START (args, format); + va_start (args, format); vfprintf (stderr, format, args); va_end (args); @@ -120,20 +109,14 @@ builtin_error (format, va_alist) } void -#if defined (PREFER_STDARG) builtin_warning (const char *format, ...) -#else -builtin_warning (format, va_alist) - const char *format; - va_dcl -#endif { va_list args; builtin_error_prolog (); fprintf (stderr, _("warning: ")); - SH_VA_START (args, format); + va_start (args, format); vfprintf (stderr, format, args); va_end (args); @@ -142,7 +125,7 @@ builtin_warning (format, va_alist) /* Print a usage summary for the currently-executing builtin command. */ void -builtin_usage () +builtin_usage (void) { if (this_command_name && *this_command_name) fprintf (stderr, _("%s: usage: "), this_command_name); @@ -153,22 +136,25 @@ builtin_usage () /* Return if LIST is NULL else barf and jump to top_level. Used by some builtins that do not accept arguments. */ void -no_args (list) - WORD_LIST *list; +no_args (WORD_LIST *list, int fatal) { if (list) { builtin_error (_("too many arguments")); top_level_cleanup (); - jump_to_top_level (DISCARD); + set_exit_status (EX_BADUSAGE); + /* for now, the caller determines whether this is a fatal error */ + if (interactive_shell == 0 && fatal) + jump_to_top_level (EXITPROG); + else + jump_to_top_level (DISCARD); } } /* Check that no options were given to the currently-executing builtin, and return 0 if there were options. */ int -no_options (list) - WORD_LIST *list; +no_options (WORD_LIST *list) { int opt; @@ -187,22 +173,19 @@ no_options (list) } void -sh_needarg (s) - char *s; +sh_needarg (const char *s) { builtin_error (_("%s: option requires an argument"), s); } void -sh_neednumarg (s) - char *s; +sh_neednumarg (const char *s) { builtin_error (_("%s: numeric argument required"), s); } void -sh_notfound (s) - char *s; +sh_notfound (const char *s) { builtin_error (_("%s: not found"), s); } @@ -210,29 +193,25 @@ sh_notfound (s) /* Function called when one of the builtin commands detects an invalid option. */ void -sh_invalidopt (s) - char *s; +sh_invalidopt (const char *s) { builtin_error (_("%s: invalid option"), s); } void -sh_invalidoptname (s) - char *s; +sh_invalidoptname (const char *s) { builtin_error (_("%s: invalid option name"), s); } void -sh_invalidid (s) - char *s; +sh_invalidid (const char *s) { builtin_error (_("`%s': not a valid identifier"), s); } void -sh_invalidnum (s) - char *s; +sh_invalidnum (const char *s) { char *msg; @@ -246,36 +225,31 @@ sh_invalidnum (s) } void -sh_invalidsig (s) - char *s; +sh_invalidsig (const char *s) { builtin_error (_("%s: invalid signal specification"), s); } void -sh_badpid (s) - char *s; +sh_badpid (const char *s) { builtin_error (_("`%s': not a pid or valid job spec"), s); } void -sh_readonly (s) - const char *s; +sh_readonly (const char *s) { builtin_error (_("%s: readonly variable"), s); } void -sh_noassign (s) - const char *s; +sh_noassign (const char *s) { internal_error (_("%s: cannot assign"), s); /* XXX */ } void -sh_erange (s, desc) - char *s, *desc; +sh_erange (const char *s, const char *desc) { if (s) builtin_error (_("%s: %s out of range"), s, desc ? desc : _("argument")); @@ -285,27 +259,31 @@ sh_erange (s, desc) #if defined (JOB_CONTROL) void -sh_badjob (s) - char *s; +sh_badjob (const char *s) { builtin_error (_("%s: no such job"), s); } void -sh_nojobs (s) - char *s; +sh_nojobs (const char *s) { if (s) builtin_error (_("%s: no job control"), s); else builtin_error (_("no job control")); } + +void +sh_invalidjob (const char *s) +{ + builtin_error (_("%s: invalid job specification"), s); +} + #endif #if defined (RESTRICTED_SHELL) void -sh_restricted (s) - char *s; +sh_restricted (const char *s) { if (s) builtin_error (_("%s: restricted"), s); @@ -315,34 +293,31 @@ sh_restricted (s) #endif void -sh_notbuiltin (s) - char *s; +sh_notbuiltin (const char *s) { builtin_error (_("%s: not a shell builtin"), s); } void -sh_wrerror () +sh_wrerror (void) { #if defined (DONT_REPORT_BROKEN_PIPE_WRITE_ERRORS) && defined (EPIPE) if (errno != EPIPE) #endif /* DONT_REPORT_BROKEN_PIPE_WRITE_ERRORS && EPIPE */ - builtin_error (_("write error: %s"), strerror (errno)); + builtin_error ("%s: %s", _("write error"), strerror (errno)); } void -sh_ttyerror (set) - int set; +sh_ttyerror (int set) { if (set) - builtin_error (_("error setting terminal attributes: %s"), strerror (errno)); + builtin_error ("%s: %s", _("error setting terminal attributes"), strerror (errno)); else - builtin_error (_("error getting terminal attributes: %s"), strerror (errno)); + builtin_error ("%s: %s", _("error getting terminal attributes"), strerror (errno)); } int -sh_chkwrite (s) - int s; +sh_chkwrite (int s) { QUIT; fflush (stdout); @@ -367,9 +342,7 @@ sh_chkwrite (s) in the list in *IP, if IP is non-null. A convenience function for loadable builtins; also used by `test'. */ char ** -make_builtin_argv (list, ip) - WORD_LIST *list; - int *ip; +make_builtin_argv (WORD_LIST *list, int *ip) { char **argv; @@ -383,9 +356,7 @@ make_builtin_argv (list, ip) only discard the ones that are to be replaced. Set POSPARAM_COUNT to the number of args assigned (length of LIST). */ void -remember_args (list, destructive) - WORD_LIST *list; - int destructive; +remember_args (WORD_LIST *list, int destructive) { register int i; @@ -413,7 +384,7 @@ remember_args (list, destructive) { dispose_words (rest_of_args); rest_of_args = copy_word_list (list); - posparam_count += list_length (list); + posparam_count += list_length ((GENERIC_LIST *)list); } if (destructive) @@ -423,8 +394,7 @@ remember_args (list, destructive) } void -shift_args (times) - int times; +shift_args (int times) { WORD_LIST *temp; int count; @@ -456,7 +426,7 @@ shift_args (times) } int -number_of_args () +number_of_args (void) { #if 0 register WORD_LIST *list; @@ -479,19 +449,19 @@ static int changed_dollar_vars; /* Have the dollar variables been reset to new values since we last checked? */ int -dollar_vars_changed () +dollar_vars_changed (void) { return (changed_dollar_vars); } void -set_dollar_vars_unchanged () +set_dollar_vars_unchanged (void) { changed_dollar_vars = 0; } void -set_dollar_vars_changed () +set_dollar_vars_changed (void) { if (variable_context) changed_dollar_vars |= ARGS_FUNC; @@ -515,10 +485,7 @@ set_dollar_vars_changed () current command; if FATAL is 0, return an indication of an invalid number by setting *NUMOK == 0 and return -1. */ int -get_numeric_arg (list, fatal, count) - WORD_LIST *list; - int fatal; - intmax_t *count; +get_numeric_arg (WORD_LIST *list, int fatal, intmax_t *count) { char *arg; @@ -531,20 +498,17 @@ get_numeric_arg (list, fatal, count) if (list) { arg = list->word->word; - if (arg == 0 || (legal_number (arg, count) == 0)) + if (arg == 0 || (valid_number (arg, count) == 0)) { sh_neednumarg (list->word->word ? list->word->word : "`'"); if (fatal == 0) return 0; - else if (fatal == 1) /* fatal == 1; abort */ - throw_to_top_level (); - else /* fatal == 2; discard current command */ - { - top_level_cleanup (); - jump_to_top_level (DISCARD); - } + set_exit_status (EX_BADUSAGE); + /* fatal == 1: abort; fatal == 2: discard current command */ + top_level_cleanup (); + jump_to_top_level ((fatal == 1) ? EXITPROG : DISCARD); } - no_args (list->next); + no_args (list->next, 0); } return (1); @@ -552,8 +516,7 @@ get_numeric_arg (list, fatal, count) /* Get an eight-bit status value from LIST */ int -get_exitstat (list) - WORD_LIST *list; +get_exitstat (WORD_LIST *list) { int status; intmax_t sval; @@ -564,24 +527,30 @@ get_exitstat (list) if (list == 0) { - /* If we're not running the DEBUG trap, the return builtin, when not - given any arguments, uses the value of $? before the trap ran. If - given an argument, return uses it. This means that the trap can't - change $?. The DEBUG trap gets to change $?, though, since that is - part of its reason for existing, and because the extended debug mode - does things with the return value. */ - if (this_shell_builtin == return_builtin && running_trap > 0 && running_trap != DEBUG_TRAP+1) + /* If we're not running the DEBUG trap, and haven't executed a shell + function from the trap action, the return builtin, when not given + any arguments, uses the value of $? before the trap ran. The business + about executing a shell function from the trap action is from POSIX + interp 1602 (10/2022). If given an argument, return uses it + unconditionally. This means that the trap can't change $?. The DEBUG + trap gets to change $?, though, since that is part of its reason for + existing, and because the extended debug mode does things with the + return value. */ + if (this_shell_builtin == return_builtin && running_trap > 0 && running_trap != DEBUG_TRAP+1 && trap_return_context == funcnest + sourcenest) + return (trap_saved_exit_value); + /* The same interp applies to the exit builtin. */ + if (this_shell_builtin == exit_builtin && running_trap > 0 && running_trap != DEBUG_TRAP+1 && trap_return_context == funcnest + sourcenest) return (trap_saved_exit_value); return (last_command_exit_value); } arg = list->word->word; - if (arg == 0 || legal_number (arg, &sval) == 0) + if (arg == 0 || valid_number (arg, &sval) == 0) { sh_neednumarg (list->word->word ? list->word->word : "`'"); - return EX_BADUSAGE; + return EX_USAGE; } - no_args (list->next); + no_args (list->next, 0); status = sval & 255; return status; @@ -590,8 +559,7 @@ get_exitstat (list) /* Return the octal number parsed from STRING, or -1 to indicate that the string contained a bad number. */ int -read_octal (string) - char *string; +read_octal (char *string) { int result, digits; @@ -621,8 +589,7 @@ read_octal (string) char *the_current_working_directory = (char *)NULL; char * -get_working_directory (for_whom) - char *for_whom; +get_working_directory (const char *for_whom) { if (no_symbolic_links) { @@ -639,9 +606,11 @@ get_working_directory (for_whom) #endif if (the_current_working_directory == 0) { - fprintf (stderr, _("%s: error retrieving current directory: %s: %s\n"), - (for_whom && *for_whom) ? for_whom : get_name_for_error (), - _(bash_getcwd_errstr), strerror (errno)); + fprintf (stderr, "%s: %s: %s: %s\n", + (for_whom && *for_whom) ? for_whom : get_name_for_error (), + _("error retrieving current directory"), + _(bash_getcwd_errstr), + strerror (errno)); return (char *)NULL; } } @@ -651,8 +620,7 @@ get_working_directory (for_whom) /* Make NAME our internal idea of the current working directory. */ void -set_working_directory (name) - char *name; +set_working_directory (const char *name) { FREE (the_current_working_directory); the_current_working_directory = savestring (name); @@ -666,13 +634,12 @@ set_working_directory (name) #if defined (JOB_CONTROL) int -get_job_by_name (name, flags) - const char *name; - int flags; +get_job_by_name (const char *name, int flags) { - register int i, wl, cl, match, job; - register PROCESS *p; - register JOB *j; + int i, match, job; + size_t wl, cl; + PROCESS *p; + JOB *j; job = NO_JOB; wl = strlen (name); @@ -721,8 +688,7 @@ get_job_by_name (name, flags) /* Return the job spec found in LIST. */ int -get_job_spec (list) - WORD_LIST *list; +get_job_spec (WORD_LIST *list) { register char *word; int job, jflags; @@ -737,6 +703,14 @@ get_job_spec (list) if (*word == '%') word++; + else +#if 1 + /* This could be builtin_error or sh_invalidjob() */ + builtin_warning (_("%s: job specification requires leading `%%'"), word); +#else + /* TAG:bash-5.4 10/23/2024 */ + return (BAD_JOBSPEC); +#endif if (DIGIT (*word) && all_digits (word)) { @@ -770,9 +744,7 @@ get_job_spec (list) * NOTE: `kill' calls this function with forcecols == 0 */ int -display_signal_list (list, forcecols) - WORD_LIST *list; - int forcecols; +display_signal_list (WORD_LIST *list, int forcecols) { register int i, column; char *name; @@ -818,7 +790,7 @@ display_signal_list (list, forcecols) /* List individual signal names or numbers. */ while (list) { - if (legal_number (list->word->word, &lsignum)) + if (valid_number (list->word->word, &lsignum)) { /* This is specified by Posix.2 so that exit statuses can be mapped into signal numbers. */ @@ -875,9 +847,7 @@ display_signal_list (list, forcecols) Return the address of the builtin. DISABLED_OKAY means find it even if the builtin is disabled. */ struct builtin * -builtin_address_internal (name, disabled_okay) - char *name; - int disabled_okay; +builtin_address_internal (const char *name, int disabled_okay) { int hi, lo, mid, j; @@ -915,8 +885,7 @@ builtin_address_internal (name, disabled_okay) /* Return the pointer to the function implementing builtin command NAME. */ sh_builtin_func_t * -find_shell_builtin (name) - char *name; +find_shell_builtin (const char *name) { current_builtin = builtin_address_internal (name, 0); return (current_builtin ? current_builtin->function : (sh_builtin_func_t *)NULL); @@ -924,8 +893,7 @@ find_shell_builtin (name) /* Return the address of builtin with NAME, whether it is enabled or not. */ sh_builtin_func_t * -builtin_address (name) - char *name; +builtin_address (const char *name) { current_builtin = builtin_address_internal (name, 1); return (current_builtin ? current_builtin->function : (sh_builtin_func_t *)NULL); @@ -934,8 +902,7 @@ builtin_address (name) /* Return the function implementing the builtin NAME, but only if it is a POSIX.2 special builtin. */ sh_builtin_func_t * -find_special_builtin (name) - char *name; +find_special_builtin (const char *name) { current_builtin = builtin_address_internal (name, 0); return ((current_builtin && (current_builtin->flags & SPECIAL_BUILTIN)) ? @@ -944,8 +911,7 @@ find_special_builtin (name) } static int -shell_builtin_compare (sbp1, sbp2) - struct builtin *sbp1, *sbp2; +shell_builtin_compare (const struct builtin *sbp1, const struct builtin *sbp2) { int result; @@ -958,7 +924,7 @@ shell_builtin_compare (sbp1, sbp2) /* Sort the table of shell builtins so that the binary search will work in find_shell_builtin. */ void -initialize_shell_builtins () +initialize_shell_builtins (void) { qsort (shell_builtins, num_shell_builtins, sizeof (struct builtin), (QSFUNC *)shell_builtin_compare); @@ -966,7 +932,7 @@ initialize_shell_builtins () #if !defined (HELP_BUILTIN) void -builtin_help () +builtin_help (void) { printf ("%s: %s\n", this_command_name, _("help not available in this version")); } @@ -980,10 +946,7 @@ builtin_help () /* Assign NAME=VALUE, passing FLAGS to the assignment functions. */ SHELL_VAR * -builtin_bind_variable (name, value, flags) - char *name; - char *value; - int flags; +builtin_bind_variable (char *name, char *value, int flags) { SHELL_VAR *v; int vflags, bindflags; @@ -991,12 +954,11 @@ builtin_bind_variable (name, value, flags) #if defined (ARRAY_VARS) /* Callers are responsible for calling this with array references that have already undergone valid_array_reference checks (read, printf). */ - vflags = assoc_expand_once ? (VA_NOEXPAND|VA_ONEWORD) : 0; - bindflags = flags | (assoc_expand_once ? ASS_NOEXPAND : 0) | ASS_ALLOWALLSUB; - if (flags & ASS_NOEXPAND) - vflags |= VA_NOEXPAND; - if (flags & ASS_ONEWORD) - vflags |= VA_ONEWORD; + /* XXX - should we unconditionally set ASS_NOEXPAND if the shell + compatibility level is > 52? */ + bindflags = flags | (array_expand_once ? ASS_NOEXPAND : 0) | ASS_ALLOWALLSUB; + vflags = convert_assign_flags_to_validarray_flags (flags); + vflags |= array_expand_once ? (VA_NOEXPAND|VA_ONEWORD) : 0; if (valid_array_reference (name, vflags) == 0) v = bind_variable (name, value, flags); @@ -1013,10 +975,7 @@ builtin_bind_variable (name, value, flags) } SHELL_VAR * -builtin_bind_var_to_int (name, val, flags) - char *name; - intmax_t val; - int flags; +builtin_bind_var_to_int (char *name, intmax_t val, int flags) { SHELL_VAR *v; @@ -1026,13 +985,11 @@ builtin_bind_var_to_int (name, val, flags) #if defined (ARRAY_VARS) SHELL_VAR * -builtin_find_indexed_array (array_name, flags) - char *array_name; - int flags; +builtin_find_indexed_array (char *array_name, int flags) { SHELL_VAR *entry; - if ((flags & 2) && legal_identifier (array_name) == 0) + if ((flags & 2) && valid_identifier (array_name) == 0) { sh_invalidid (array_name); return (SHELL_VAR *)NULL; @@ -1061,8 +1018,7 @@ builtin_find_indexed_array (array_name, flags) /* Like check_unbind_variable, but for use by builtins (only matters for error messages). */ int -builtin_unbind_variable (vname) - const char *vname; +builtin_unbind_variable (const char *vname) { SHELL_VAR *v; @@ -1081,16 +1037,13 @@ builtin_unbind_variable (vname) } int -builtin_arrayref_flags (w, baseflags) - WORD_DESC *w; - int baseflags; +builtin_arrayref_flags (WORD_DESC *w, int baseflags) { - char *t; int vflags; vflags = baseflags; - /* Don't require assoc_expand_once if we have an argument that's already + /* Don't require array_expand_once if we have an argument that's already passed through valid_array_reference and been expanded once. That doesn't protect it from normal expansions like word splitting, so proper quoting is still required. */ @@ -1099,7 +1052,7 @@ builtin_arrayref_flags (w, baseflags) # if 0 /* This is a little sketchier but handles quoted arguments. */ - if (assoc_expand_once && (t = strchr (w->word, '[')) && t[strlen(t) - 1] == ']') + if (array_expand_once && (t = strchr (w->word, '[')) && t[strlen(t) - 1] == ']') vflags |= VA_ONEWORD|VA_NOEXPAND; # endif @@ -1114,17 +1067,16 @@ builtin_arrayref_flags (w, baseflags) #if defined (ARRAY_VARS) int -set_expand_once (nval, uwp) - int nval, uwp; +set_expand_once (int nval, int uwp) { int oa; - oa = assoc_expand_once; + oa = array_expand_once; if (shell_compatibility_level > 51) /* XXX - internal */ { if (uwp) - unwind_protect_int (assoc_expand_once); - assoc_expand_once = nval; + unwind_protect_int (array_expand_once); + array_expand_once = nval; } return oa; } diff --git a/builtins/common.h b/builtins/common.h index a170f8fcf..a169f494c 100644 --- a/builtins/common.h +++ b/builtins/common.h @@ -52,6 +52,7 @@ do { \ #define SEVAL_ONECMD 0x100 /* only allow a single command */ #define SEVAL_NOHISTEXP 0x200 /* inhibit history expansion */ #define SEVAL_NOOPTIMIZE 0x400 /* don't try to set optimization flags */ +#define SEVAL_NOTIFY 0x800 /* want job notifications */ /* Flags for describe_command, shared between type.def and command.def */ #define CDESC_ALL 0x001 /* type -a */ @@ -81,163 +82,165 @@ do { \ #define MAX_ATTRIBUTES 16 /* Functions from common.c */ -extern void builtin_error PARAMS((const char *, ...)) __attribute__((__format__ (printf, 1, 2))); -extern void builtin_warning PARAMS((const char *, ...)) __attribute__((__format__ (printf, 1, 2))); -extern void builtin_usage PARAMS((void)); -extern void no_args PARAMS((WORD_LIST *)); -extern int no_options PARAMS((WORD_LIST *)); +extern void builtin_error (const char *, ...) __attribute__((__format__ (printf, 1, 2))); +extern void builtin_warning (const char *, ...) __attribute__((__format__ (printf, 1, 2))); +extern void builtin_usage (void); +extern void no_args (WORD_LIST *, int); +extern int no_options (WORD_LIST *); /* common error message functions */ -extern void sh_needarg PARAMS((char *)); -extern void sh_neednumarg PARAMS((char *)); -extern void sh_notfound PARAMS((char *)); -extern void sh_invalidopt PARAMS((char *)); -extern void sh_invalidoptname PARAMS((char *)); -extern void sh_invalidid PARAMS((char *)); -extern void sh_invalidnum PARAMS((char *)); -extern void sh_invalidsig PARAMS((char *)); -extern void sh_readonly PARAMS((const char *)); -extern void sh_noassign PARAMS((const char *)); -extern void sh_erange PARAMS((char *, char *)); -extern void sh_badpid PARAMS((char *)); -extern void sh_badjob PARAMS((char *)); -extern void sh_nojobs PARAMS((char *)); -extern void sh_restricted PARAMS((char *)); -extern void sh_notbuiltin PARAMS((char *)); -extern void sh_wrerror PARAMS((void)); -extern void sh_ttyerror PARAMS((int)); -extern int sh_chkwrite PARAMS((int)); - -extern char **make_builtin_argv PARAMS((WORD_LIST *, int *)); -extern void remember_args PARAMS((WORD_LIST *, int)); -extern void shift_args PARAMS((int)); -extern int number_of_args PARAMS((void)); - -extern int dollar_vars_changed PARAMS((void)); -extern void set_dollar_vars_unchanged PARAMS((void)); -extern void set_dollar_vars_changed PARAMS((void)); - -extern int get_numeric_arg PARAMS((WORD_LIST *, int, intmax_t *)); -extern int get_exitstat PARAMS((WORD_LIST *)); -extern int read_octal PARAMS((char *)); +extern void sh_needarg (const char *); +extern void sh_neednumarg (const char *); +extern void sh_notfound (const char *); +extern void sh_invalidopt (const char *); +extern void sh_invalidoptname (const char *); +extern void sh_invalidid (const char *); +extern void sh_invalidnum (const char *); +extern void sh_invalidsig (const char *); +extern void sh_readonly (const char *); +extern void sh_noassign (const char *); +extern void sh_erange (const char *, const char *); +extern void sh_badpid (const char *); +extern void sh_badjob (const char *); +extern void sh_nojobs (const char *); +extern void sh_invalidjob (const char *); +extern void sh_restricted (const char *); +extern void sh_notbuiltin (const char *); +extern void sh_wrerror (void); +extern void sh_ttyerror (int); +extern int sh_chkwrite (int); + +extern char **make_builtin_argv (WORD_LIST *, int *); +extern void remember_args (WORD_LIST *, int); +extern void shift_args (int); +extern int number_of_args (void); + +extern int dollar_vars_changed (void); +extern void set_dollar_vars_unchanged (void); +extern void set_dollar_vars_changed (void); + +extern int get_numeric_arg (WORD_LIST *, int, intmax_t *); +extern int get_exitstat (WORD_LIST *); +extern int read_octal (char *); /* Keeps track of the current working directory. */ extern char *the_current_working_directory; -extern char *get_working_directory PARAMS((char *)); -extern void set_working_directory PARAMS((char *)); +extern char *get_working_directory (const char *); +extern void set_working_directory (const char *); #if defined (JOB_CONTROL) -extern int get_job_by_name PARAMS((const char *, int)); -extern int get_job_spec PARAMS((WORD_LIST *)); +extern int get_job_by_name (const char *, int); +extern int get_job_spec (WORD_LIST *); #endif -extern int display_signal_list PARAMS((WORD_LIST *, int)); +extern int display_signal_list (WORD_LIST *, int); /* It's OK to declare a function as returning a Function * without providing a definition of what a `Function' is. */ -extern struct builtin *builtin_address_internal PARAMS((char *, int)); -extern sh_builtin_func_t *find_shell_builtin PARAMS((char *)); -extern sh_builtin_func_t *builtin_address PARAMS((char *)); -extern sh_builtin_func_t *find_special_builtin PARAMS((char *)); -extern void initialize_shell_builtins PARAMS((void)); +extern struct builtin *builtin_address_internal (const char *, int); +extern sh_builtin_func_t *find_shell_builtin (const char *); +extern sh_builtin_func_t *builtin_address (const char *); +extern sh_builtin_func_t *find_special_builtin (const char *); +extern void initialize_shell_builtins (void); #if defined (ARRAY_VARS) -extern int set_expand_once PARAMS((int, int)); +extern int set_expand_once (int, int); #endif /* Functions from exit.def */ -extern void bash_logout PARAMS((void)); +extern void bash_logout (void); /* Functions from getopts.def */ -extern void getopts_reset PARAMS((int)); +extern void getopts_reset (int); /* Functions from help.def */ -extern void builtin_help PARAMS((void)); +extern void builtin_help (void); /* Functions from read.def */ -extern void read_tty_cleanup PARAMS((void)); -extern int read_tty_modified PARAMS((void)); +extern void read_tty_cleanup (void); +extern int read_tty_modified (void); -extern int read_builtin_timeout PARAMS((int)); -extern void check_read_timeout PARAMS((void)); +extern int read_builtin_timeout (int); +extern void check_read_timeout (void); /* Functions from set.def */ -extern int minus_o_option_value PARAMS((char *)); -extern void list_minus_o_opts PARAMS((int, int)); -extern char **get_minus_o_opts PARAMS((void)); -extern int set_minus_o_option PARAMS((int, char *)); +extern int minus_o_option_value (char *); +extern void list_minus_o_opts (int, int); +extern char **get_minus_o_opts (void); +extern int set_minus_o_option (int, char *); -extern void set_shellopts PARAMS((void)); -extern void parse_shellopts PARAMS((char *)); -extern void initialize_shell_options PARAMS((int)); +extern void set_shellopts (void); +extern void parse_shellopts (char *); +extern void initialize_shell_options (int); -extern void reset_shell_options PARAMS((void)); +extern void reset_shell_options (void); -extern char *get_current_options PARAMS((void)); -extern void set_current_options PARAMS((const char *)); +extern char *get_current_options (void); +extern void set_current_options (const char *); /* Functions from shopt.def */ -extern void reset_shopt_options PARAMS((void)); -extern char **get_shopt_options PARAMS((void)); +extern void reset_shopt_options (void); +extern char **get_shopt_options (void); -extern int shopt_setopt PARAMS((char *, int)); -extern int shopt_listopt PARAMS((char *, int)); +extern int shopt_setopt (char *, int); +extern int shopt_listopt (char *, int); -extern int set_login_shell PARAMS((char *, int)); +extern int set_login_shell (char *, int); -extern void set_bashopts PARAMS((void)); -extern void parse_bashopts PARAMS((char *)); -extern void initialize_bashopts PARAMS((int)); +extern void set_bashopts (void); +extern void parse_bashopts (char *); +extern void initialize_bashopts (int); -extern void set_compatibility_opts PARAMS((void)); +extern void set_compatibility_opts (void); /* Functions from type.def */ -extern int describe_command PARAMS((char *, int)); +extern int describe_command (char *, int); /* Functions from setattr.def */ -extern int set_or_show_attributes PARAMS((WORD_LIST *, int, int)); -extern int show_all_var_attributes PARAMS((int, int)); -extern int show_local_var_attributes PARAMS((int, int)); -extern int show_var_attributes PARAMS((SHELL_VAR *, int, int)); -extern int show_name_attributes PARAMS((char *, int)); -extern int show_localname_attributes PARAMS((char *, int)); -extern int show_func_attributes PARAMS((char *, int)); -extern void set_var_attribute PARAMS((char *, int, int)); -extern int var_attribute_string PARAMS((SHELL_VAR *, int, char *)); +extern int set_or_show_attributes (WORD_LIST *, int, int); +extern int show_all_var_attributes (int, int); +extern int show_local_var_attributes (int, int); +extern int show_var_attributes (SHELL_VAR *, int, int); +extern int show_name_attributes (char *, int); +extern int show_localname_attributes (char *, int); +extern int show_func_attributes (char *, int); +extern void set_var_attribute (char *, int, int); +extern int var_attribute_string (SHELL_VAR *, int, char *); /* Functions from pushd.def */ -extern char *get_dirstack_from_string PARAMS((char *)); -extern char *get_dirstack_element PARAMS((intmax_t, int)); -extern void set_dirstack_element PARAMS((intmax_t, int, char *)); -extern WORD_LIST *get_directory_stack PARAMS((int)); +extern char *get_dirstack_from_string (char *); +extern char *get_dirstack_element (intmax_t, int); +extern void set_dirstack_element (intmax_t, int, char *); +extern WORD_LIST *get_directory_stack (int); /* Functions from evalstring.c */ -extern int parse_and_execute PARAMS((char *, const char *, int)); -extern int evalstring PARAMS((char *, const char *, int)); -extern void parse_and_execute_cleanup PARAMS((int)); -extern int parse_string PARAMS((char *, const char *, int, COMMAND **, char **)); -extern int should_suppress_fork PARAMS((COMMAND *)); -extern int can_optimize_connection PARAMS((COMMAND *)); -extern int can_optimize_cat_file PARAMS((COMMAND *)); -extern void optimize_connection_fork PARAMS((COMMAND *)); -extern void optimize_subshell_command PARAMS((COMMAND *)); -extern void optimize_shell_function PARAMS((COMMAND *)); +extern int parse_and_execute (char *, const char *, int); +extern int evalstring (char *, const char *, int); +extern void parse_and_execute_cleanup (int); +extern int parse_string (char *, const char *, int, COMMAND **, char **); +extern int should_optimize_fork (COMMAND *, int); +extern int should_suppress_fork (COMMAND *); +extern int can_optimize_connection (COMMAND *); +extern int can_optimize_cat_file (COMMAND *); +extern void optimize_connection_fork (COMMAND *); +extern void optimize_subshell_command (COMMAND *); +extern void optimize_shell_function (COMMAND *); /* Functions from evalfile.c */ -extern int maybe_execute_file PARAMS((const char *, int)); -extern int force_execute_file PARAMS((const char *, int)); -extern int source_file PARAMS((const char *, int)); -extern int fc_execute_file PARAMS((const char *)); +extern int maybe_execute_file (const char *, int); +extern int force_execute_file (const char *, int); +extern int source_file (const char *, int); +extern int fc_execute_file (const char *); /* variables from common.c */ extern sh_builtin_func_t *this_shell_builtin; extern sh_builtin_func_t *last_shell_builtin; -extern SHELL_VAR *builtin_bind_variable PARAMS((char *, char *, int)); -extern SHELL_VAR *builtin_bind_var_to_int PARAMS((char *, intmax_t, int)); -extern int builtin_unbind_variable PARAMS((const char *)); +extern SHELL_VAR *builtin_bind_variable (char *, char *, int); +extern SHELL_VAR *builtin_bind_var_to_int (char *, intmax_t, int); +extern int builtin_unbind_variable (const char *); -extern SHELL_VAR *builtin_find_indexed_array PARAMS((char *, int)); -extern int builtin_arrayref_flags PARAMS((WORD_DESC *, int)); +extern SHELL_VAR *builtin_find_indexed_array (char *, int); +extern int builtin_arrayref_flags (WORD_DESC *, int); /* variables from evalfile.c */ extern int sourcelevel; @@ -275,9 +278,9 @@ extern int wait_intr_flag; #if defined (ARRAY_VARS) #define SET_VFLAGS(wordflags, vflags, bindflags) \ do { \ - vflags = assoc_expand_once ? VA_NOEXPAND : 0; \ - bindflags = assoc_expand_once ? ASS_NOEXPAND : 0; \ - if (assoc_expand_once && (wordflags & W_ARRAYREF)) \ + vflags = array_expand_once ? VA_NOEXPAND : 0; \ + bindflags = array_expand_once ? ASS_NOEXPAND : 0; \ + if (array_expand_once && (wordflags & W_ARRAYREF)) \ vflags |= VA_ONEWORD|VA_NOEXPAND; \ if (vflags & VA_NOEXPAND) \ bindflags |= ASS_NOEXPAND; \ diff --git a/builtins/complete.def b/builtins/complete.def index 6d600efb5..236cd42c9 100644 --- a/builtins/complete.def +++ b/builtins/complete.def @@ -1,7 +1,7 @@ This file is complete.def, from which is created complete.c. It implements the builtins "complete", "compgen", and "compopt" in Bash. -Copyright (C) 1999-2021 Free Software Foundation, Inc. +Copyright (C) 1999-2023 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -27,8 +27,8 @@ $SHORT_DOC complete [-abcdefgjksuv] [-pr] [-DEI] [-o option] [-A action] [-G glo Specify how arguments are to be completed by Readline. For each NAME, specify how arguments are to be completed. If no options -are supplied, existing completion specifications are printed in a way that -allows them to be reused as input. +or NAMEs are supplied, display existing completion specifications in a way +that allows them to be reused as input. Options: -p print existing completion specifications in a reusable format @@ -84,23 +84,23 @@ struct _optflags { int Iflag; }; -static int find_compact PARAMS((char *)); -static int find_compopt PARAMS((char *)); +static int find_compact (char *); +static int find_compopt (char *); -static int build_actions PARAMS((WORD_LIST *, struct _optflags *, unsigned long *, unsigned long *)); +static int build_actions (WORD_LIST *, struct _optflags *, unsigned long *, unsigned long *, char **); -static int remove_cmd_completions PARAMS((WORD_LIST *)); +static int remove_cmd_completions (WORD_LIST *); -static int print_one_completion PARAMS((char *, COMPSPEC *)); -static int print_compitem PARAMS((BUCKET_CONTENTS *)); -static void print_compopts PARAMS((const char *, COMPSPEC *, int)); -static void print_all_completions PARAMS((void)); -static int print_cmd_completions PARAMS((WORD_LIST *)); +static int print_one_completion (char *, COMPSPEC *); +static int print_compitem (BUCKET_CONTENTS *); +static void print_compopts (const char *, COMPSPEC *, int); +static void print_all_completions (void); +static int print_cmd_completions (WORD_LIST *); -static void print_compoptions PARAMS((unsigned long, int)); -static void print_compactions PARAMS((unsigned long)); -static void print_arg PARAMS((const char *, const char *, int)); -static void print_cmd_name PARAMS((const char *)); +static void print_compoptions (unsigned long, int); +static void print_compactions (unsigned long); +static void print_arg (const char *, const char *, int); +static void print_cmd_name (const char *); static char *Garg, *Warg, *Parg, *Sarg, *Xarg, *Farg, *Carg; @@ -145,6 +145,7 @@ static const struct _compopt { { "default", COPT_DEFAULT }, { "dirnames", COPT_DIRNAMES }, { "filenames",COPT_FILENAMES}, + { "fullquote",COPT_FULLQUOTE}, { "noquote", COPT_NOQUOTE }, { "nosort", COPT_NOSORT }, { "nospace", COPT_NOSPACE }, @@ -153,8 +154,7 @@ static const struct _compopt { }; static int -find_compact (name) - char *name; +find_compact (char *name) { register int i; @@ -165,8 +165,7 @@ find_compact (name) } static int -find_compopt (name) - char *name; +find_compopt (char *name) { register int i; @@ -182,6 +181,8 @@ find_compopt (name) bitmap of compspec options (arguments to `-o'). PP, if non-null, gets 1 if -p is supplied; RP, if non-null, gets 1 if -r is supplied. If either is null, the corresponding option generates an error. + VNAMEP is a pointer to a string to store the name of the output variable + supplied with the -V option. This also sets variables corresponding to options that take arguments as a side effect; the caller should ensure that those variables are set to NULL before calling build_actions. Return value: @@ -191,10 +192,7 @@ find_compopt (name) */ static int -build_actions (list, flagp, actp, optp) - WORD_LIST *list; - struct _optflags *flagp; - unsigned long *actp, *optp; +build_actions (WORD_LIST *list, struct _optflags *flagp, unsigned long *actp, unsigned long *optp, char **vnamep) { int opt, ind, opt_given; unsigned long acts, copts; @@ -204,7 +202,7 @@ build_actions (list, flagp, actp, optp) opt_given = 0; reset_internal_getopt (); - while ((opt = internal_getopt (list, "abcdefgjko:prsuvA:G:W:P:S:X:F:C:DEI")) != -1) + while ((opt = internal_getopt (list, "abcdefgjko:prsuvA:G:W:P:S:X:F:C:V:DEI")) != -1) { opt_given = 1; switch (opt) @@ -346,6 +344,25 @@ build_actions (list, flagp, actp, optp) case 'S': Sarg = list_optarg; break; + case 'V': +#if defined (ARRAY_VARS) + if (vnamep) + { + *vnamep = list_optarg; + if (valid_identifier (list_optarg) == 0) + { + sh_invalidid (list_optarg); + return (EX_USAGE); + } + } + else +#endif + { + sh_invalidopt ("-V"); + builtin_usage (); + return (EX_USAGE); + } + break; case 'W': Warg = list_optarg; break; @@ -367,8 +384,7 @@ build_actions (list, flagp, actp, optp) /* Add, remove, and display completion specifiers. */ int -complete_builtin (list) - WORD_LIST *list; +complete_builtin (WORD_LIST *list) { int opt_given, rval; unsigned long acts, copts; @@ -391,7 +407,7 @@ complete_builtin (list) /* Build the actions from the arguments. Also sets the [A-Z]arg variables as a side effect if they are supplied as options. */ - rval = build_actions (list, &oflags, &acts, &copts); + rval = build_actions (list, &oflags, &acts, &copts, (char **)NULL); if (rval == EX_USAGE) return (rval); opt_given = rval != EXECUTION_FAILURE; @@ -473,8 +489,7 @@ complete_builtin (list) } static int -remove_cmd_completions (list) - WORD_LIST *list; +remove_cmd_completions (WORD_LIST *list) { WORD_LIST *l; int ret; @@ -491,9 +506,7 @@ remove_cmd_completions (list) } static void -print_compoptions (copts, full) - unsigned long copts; - int full; +print_compoptions (unsigned long copts, int full) { const struct _compopt *co; @@ -505,8 +518,7 @@ print_compoptions (copts, full) } static void -print_compactions (acts) - unsigned long acts; +print_compactions (unsigned long acts) { const struct _compacts *ca; @@ -522,9 +534,7 @@ print_compactions (acts) } static void -print_arg (arg, flag, quote) - const char *arg, *flag; - int quote; +print_arg (const char *arg, const char *flag, int quote) { char *x; @@ -538,8 +548,7 @@ print_arg (arg, flag, quote) } static void -print_cmd_name (cmd) - const char *cmd; +print_cmd_name (const char *cmd) { char *x; @@ -562,9 +571,7 @@ print_cmd_name (cmd) } static int -print_one_completion (cmd, cs) - char *cmd; - COMPSPEC *cs; +print_one_completion (char *cmd, COMPSPEC *cs) { printf ("complete "); @@ -592,10 +599,7 @@ print_one_completion (cmd, cs) } static void -print_compopts (cmd, cs, full) - const char *cmd; - COMPSPEC *cs; - int full; +print_compopts (const char *cmd, COMPSPEC *cs, int full) { printf ("compopt "); @@ -606,8 +610,7 @@ print_compopts (cmd, cs, full) } static int -print_compitem (item) - BUCKET_CONTENTS *item; +print_compitem (BUCKET_CONTENTS *item) { COMPSPEC *cs; char *cmd; @@ -619,14 +622,13 @@ print_compitem (item) } static void -print_all_completions () +print_all_completions (void) { progcomp_walk (print_compitem); } static int -print_cmd_completions (list) - WORD_LIST *list; +print_cmd_completions (WORD_LIST *list) { WORD_LIST *l; COMPSPEC *cs; @@ -650,20 +652,22 @@ print_cmd_completions (list) $BUILTIN compgen $DEPENDS_ON PROGRAMMABLE_COMPLETION $FUNCTION compgen_builtin -$SHORT_DOC compgen [-abcdefgjksuv] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [word] +$SHORT_DOC compgen [-V varname] [-abcdefgjksuv] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [word] Display possible completions depending on the options. Intended to be used from within a shell function generating possible -completions. If the optional WORD argument is supplied, matches against -WORD are generated. +completions. If the optional WORD argument is present, generate matches +against WORD. + +If the -V option is supplied, store the possible completions in the indexed +array VARNAME instead of printing them to the standard output. Exit Status: Returns success unless an invalid option is supplied or an error occurs. $END int -compgen_builtin (list) - WORD_LIST *list; +compgen_builtin (WORD_LIST *list) { int rval; unsigned long acts, copts; @@ -671,7 +675,9 @@ compgen_builtin (list) STRINGLIST *sl; char *word, **matches; char *old_line; - int old_ind; + int old_ind, old_completion, old_quoting, old_suppress; + SHELL_VAR *var; + char *varname; if (list == 0) return (EXECUTION_SUCCESS); @@ -679,10 +685,11 @@ compgen_builtin (list) acts = copts = (unsigned long)0L; Garg = Warg = Parg = Sarg = Xarg = Farg = Carg = (char *)NULL; cs = (COMPSPEC *)NULL; + varname = 0; /* Build the actions from the arguments. Also sets the [A-Z]arg variables as a side effect if they are supplied as options. */ - rval = build_actions (list, (struct _optflags *)NULL, &acts, &copts); + rval = build_actions (list, (struct _optflags *)NULL, &acts, &copts, &varname); if (rval == EX_USAGE) return (rval); if (rval == EXECUTION_FAILURE) @@ -713,6 +720,12 @@ compgen_builtin (list) rval = EXECUTION_FAILURE; + old_completion = rl_filename_completion_desired; + old_quoting = rl_filename_quoting_desired; + old_suppress = rl_completion_suppress_append; + + bashline_set_filename_hooks (); + /* probably don't have to save these, just being safe */ old_line = pcomp_line; old_ind = pcomp_ind; @@ -741,15 +754,29 @@ compgen_builtin (list) strvec_dispose (matches); } - if (sl) + rl_filename_completion_desired = old_completion; + rl_filename_quoting_desired = old_quoting; + rl_completion_suppress_append = old_suppress; + +#if defined (ARRAY_VARS) + if (varname) { - if (sl->list && sl->list_len) + var = builtin_find_indexed_array (varname, 1); + if (var && sl && sl->list && sl->list_len) { + array_from_argv (array_cell (var), sl->list, sl->list_len); rval = EXECUTION_SUCCESS; - strlist_print (sl, (char *)NULL); } - strlist_dispose (sl); } + else +#endif + if (sl && sl->list && sl->list_len) + { + rval = EXECUTION_SUCCESS; + strlist_print (sl, (char *)NULL); + } + if (sl) + strlist_dispose (sl); compspec_dispose (cs); return (rval); @@ -787,8 +814,7 @@ have a completion specification defined. $END int -compopt_builtin (list) - WORD_LIST *list; +compopt_builtin (WORD_LIST *list) { int opts_on, opts_off, *opts, opt, oind, ret, Dflag, Eflag, Iflag; WORD_LIST *l, *wl; diff --git a/builtins/declare.def b/builtins/declare.def index 7a1b60c8a..8f7f48343 100644 --- a/builtins/declare.def +++ b/builtins/declare.def @@ -1,7 +1,7 @@ This file is declare.def, from which is created declare.c. It implements the builtins "declare" and "local" in Bash. -Copyright (C) 1987-2021 Free Software Foundation, Inc. +Copyright (C) 1987-2024 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -49,7 +49,8 @@ Options which set attributes: -u to convert the value of each NAME to upper case on assignment -x to make NAMEs export -Using `+' instead of `-' turns off the given attribute. +Using `+' instead of `-' turns off the given attribute, except for a, +A, and r. Variables with the integer attribute have arithmetic evaluation (see the `let' command) performed when the variable is assigned a value. @@ -90,16 +91,15 @@ $END #include "builtext.h" #include "bashgetopt.h" -static SHELL_VAR *declare_find_variable PARAMS((const char *, int, int)); -static char *declare_build_newname PARAMS((char *, char *, int, char *, int)); -static char *declare_transform_name PARAMS((char *, int, int)); +static SHELL_VAR *declare_find_variable (const char *, int, int); +static char *declare_build_newname (char *, char *, int, char *, int); +static char *declare_transform_name (char *, int, int); -static int declare_internal PARAMS((register WORD_LIST *, int)); +static int declare_internal (register WORD_LIST *, int); /* Declare or change variable attributes. */ int -declare_builtin (list) - register WORD_LIST *list; +declare_builtin (WORD_LIST *list) { return (declare_internal (list, 0)); } @@ -112,6 +112,9 @@ Define local variables. Create a local variable called NAME, and give it VALUE. OPTION can be any option accepted by `declare'. +If any NAME is "-", local saves the set of shell options and restores +them when the function returns. + Local variables can only be used within a function; they are visible only to the function where they are defined and its children. @@ -120,8 +123,7 @@ Returns success unless an invalid option is supplied, a variable assignment error occurs, or the shell is not executing a function. $END int -local_builtin (list) - register WORD_LIST *list; +local_builtin (WORD_LIST *list) { /* Catch a straight `local --help' before checking function context */ if (list && list->word && STREQ (list->word->word, "--help")) @@ -146,21 +148,15 @@ local_builtin (list) #endif static SHELL_VAR * -declare_find_variable (name, mkglobal, chklocal) - const char *name; - int mkglobal, chklocal; +declare_find_variable (const char *name, int mkglobal, int chklocal) { SHELL_VAR *var; if (mkglobal == 0) return (find_variable (name)); else if (chklocal) - { - var = find_variable (name); - if (var && local_p (var) && var->context == variable_context) - return var; - return (find_global_variable (name)); - } + /* Changed to find variables at previous local scopes 6/12/2024 */ + return (find_variable (name)); else return (find_global_variable (name)); } @@ -169,11 +165,7 @@ declare_find_variable (name, mkglobal, chklocal) NAME[SUBSCRIPT][[+]=VALUE] from expanding a nameref into NAME */ static char * -declare_build_newname (name, subscript_start, offset, value, aflags) - char *name, *subscript_start; - int offset; - char *value; - int aflags; +declare_build_newname (char *name, char *subscript_start, int offset, char *value, int aflags) { size_t namelen, savelen; char *ret; @@ -203,9 +195,7 @@ declare_build_newname (name, subscript_start, offset, value, aflags) } static char * -declare_transform_name (name, flags_on, flags_off) - char *name; - int flags_on, flags_off; +declare_transform_name (char *name, int flags_on, int flags_off) { SHELL_VAR *var, *v; char *newname; @@ -227,11 +217,48 @@ declare_transform_name (name, flags_on, flags_off) return (newname); } +/* Some option combinations that don't make any sense */ +static int +declare_invalid_opts (int flags_on, int flags_off) +{ + if ((flags_on & att_function) && (flags_on & (att_array|att_assoc|att_integer|att_nameref))) + { + char *optchar; + + if (flags_on & att_nameref) + optchar = "-n"; + else if (flags_on & att_integer) + optchar = "-i"; + else if (flags_on & att_assoc) + optchar = "-A"; + else if (flags_on & att_array) + optchar = "-a"; + + sh_invalidopt (optchar); + return (EXECUTION_FAILURE); + } + else if ((flags_on & att_assoc) && (flags_off & att_assoc)) + { + sh_invalidopt ("-A"); + return (EX_BADUSAGE); + } + else if ((flags_on & att_array) && (flags_off & att_array)) + { + sh_invalidopt ("-a"); + return (EX_BADUSAGE); + } + else if ((flags_on & att_assoc) && (flags_on & att_array)) + { + sh_invalidopt ("-a"); + return (EX_BADUSAGE); + } + + return 0; +} + /* The workhorse function. */ static int -declare_internal (list, local_var) - register WORD_LIST *list; - int local_var; +declare_internal (WORD_LIST *list, int local_var) { int flags_on, flags_off, *flags; int any_failed, assign_error, pflag, nodefs, opt, onref, offref; @@ -255,6 +282,10 @@ declare_internal (list, local_var) case 'a': #if defined (ARRAY_VARS) *flags |= att_array; +#if 0 + if (flags == &flags_on) + *flags &= ~att_assoc; /* last one wins */ +#endif break; #else builtin_usage (); @@ -263,6 +294,10 @@ declare_internal (list, local_var) case 'A': #if defined (ARRAY_VARS) *flags |= att_assoc; +#if 0 + if (flags == &flags_on) + *flags &= ~att_array; /* last one wins */ +#endif break; #else builtin_usage (); @@ -278,7 +313,7 @@ declare_internal (list, local_var) case 'f': *flags |= att_function; break; - case 'G': + case 'G': /* undocumented, used internally */ if (flags == &flags_on) chklocal = 1; /*FALLTHROUGH*/ @@ -370,24 +405,11 @@ declare_internal (list, local_var) return (sh_chkwrite (any_failed ? EXECUTION_FAILURE : EXECUTION_SUCCESS)); } - /* Some option combinations that don't make any sense */ - if ((flags_on & att_function) && (flags_on & (att_array|att_assoc|att_integer|att_nameref))) - { - char *optchar; - - if (flags_on & att_nameref) - optchar = "-n"; - else if (flags_on & att_integer) - optchar = "-i"; - else if (flags_on & att_assoc) - optchar = "-A"; - else if (flags_on & att_array) - optchar = "-a"; - - sh_invalidopt (optchar); - return (EXECUTION_FAILURE); - } - + /* check for some invalid option combinations that are usage errors */ + opt = declare_invalid_opts (flags_on, flags_off); + if (opt != 0) + return (opt); + #define NEXT_VARIABLE() free (name); list = list->next; continue /* There are arguments left, so we are making variables. */ @@ -404,7 +426,7 @@ declare_internal (list, local_var) name = savestring (list->word->word); wflags = list->word->flags; #if defined (ARRAY_VARS) - assoc_noexpand = assoc_expand_once && (wflags & W_ASSIGNMENT); + assoc_noexpand = array_expand_once && (wflags & W_ASSIGNMENT); #else assoc_noexpand = 0; #endif @@ -442,9 +464,14 @@ declare_internal (list, local_var) /* Can't define functions using assignment statements */ if (offset && (flags_on & att_function)) /* declare -f [-rix] foo=bar */ { - builtin_error (_("cannot use `-f' to make functions")); - free (name); - return (EXECUTION_FAILURE); + if (var = find_function (name)) + offset = 0; + else + { + builtin_error (_("cannot use `-f' to make functions")); + free (name); + return (EXECUTION_FAILURE); + } } /* There should be a way, however, to let people look at a particular @@ -456,7 +483,7 @@ declare_internal (list, local_var) /* Should we restrict this when the shell is in posix mode even if the function was created before the shell entered posix mode? Previous versions of the shell enforced the restriction. */ - if (posixly_correct && legal_identifier (name) == 0) + if (posixly_correct && valid_identifier (name) == 0) { sh_invalidid (name); assign_error++; @@ -583,7 +610,7 @@ restart_new_var_name: #endif /* Ensure the argument is a valid, well-formed shell identifier. */ - if (legal_identifier (name) == 0) + if (valid_identifier (name) == 0) { sh_invalidid (name); assign_error++; @@ -644,6 +671,10 @@ restart_new_var_name: any_failed++; NEXT_VARIABLE (); } + /* See below; ksh93 doesn't allow the nameref attribute to be removed + from a readonly nameref that has a value, even if it doesn't + reference an existing variable, so we don't allow it for + compatibility. */ if (var && nameref_p (var) && readonly_p (var) && nameref_cell (var) && (flags_off & att_nameref)) { sh_readonly (name); @@ -683,7 +714,7 @@ restart_new_var_name: if (refvar && nameref_p (refvar) == 0) refvar = 0; /* If the nameref is readonly but doesn't have a value, ksh93 - allows the nameref attribute to be removed. If it's readonly + allows the nameref attribute to be removed. If it's readonly and has a value, even if the value doesn't reference an existing variable, we disallow the modification */ if (refvar && nameref_cell (refvar) && readonly_p (refvar)) @@ -847,11 +878,24 @@ restart_new_var_name: NEXT_VARIABLE (); } /* Cannot use declare to assign value to readonly or noassign variable. */ - else if ((readonly_p (var) || noassign_p (var)) && offset) + else if (ASSIGN_DISALLOWED (var, 0) && offset) { if (readonly_p (var)) - sh_readonly (name); - assign_error++; + { + sh_readonly (name); + assign_error++; + } + /* just ignore attempts to assign to noassign variables; returning + EXECUTION_FAILURE would cause set -e to exit the shell. */ + NEXT_VARIABLE (); + } + /* Cannot set or unset invalid attributes on readonly variables */ + else if (readonly_p (var) && ((flags_on & invalid_readonly_attrs) || (flags_off & invalid_readonly_attrs))) + { + /* The restrictions on namerefs and readonly variables are handled + above. */ + sh_readonly (name_cell (var)); + any_failed++; NEXT_VARIABLE (); } @@ -884,7 +928,7 @@ restart_new_var_name: simple_array_assign = 1; else if ((making_array_special || creating_array || array_exists) && offset) { - int vlen; + size_t vlen; vlen = STRLEN (value); /*itrace("declare_builtin: name = %s value = %s flags = %d", name, value, wflags);*/ @@ -1001,7 +1045,10 @@ restart_new_var_name: /* If we found this variable in the temporary environment, as with `var=value declare -x var', make sure it is treated identically to `var=value export var'. Do the same for `declare -r' and - `readonly'. Preserve the attributes, except for att_tempvar. */ + `readonly'. Preserve the attributes, except for att_tempvar. + This doesn't happen in functions, since declare in shell functions + always creates local variables (that inherit their value from the + tempenv variable). We don't check variable_context; maybe we should. */ /* XXX -- should this create a variable in the global scope, or modify the local variable flags? ksh93 has it modify the global scope. @@ -1010,22 +1057,32 @@ restart_new_var_name: if ((flags_on & (att_exported|att_readonly)) && tempvar_p (var)) { SHELL_VAR *tv; - char *tvalue; + /* Temporary environment? Or in the local variable context? */ tv = find_tempenv_variable (name_cell (var)); if (tv) { - tvalue = var_isset (var) ? savestring (value_cell (var)) : savestring (""); - tv = bind_variable (name_cell (var), tvalue, 0); + /* We don't bother with modifying the temporary env because + we're already using it. */ + tv = bind_variable (name_cell (var), value_cell (var), ASS_NOTEMPENV); + if (tv) { +#if defined (ARRAY_VARS) + /* copy array value if array variable */ + if ((array_p (var) || assoc_p (var))) + arrayvar_copyval (var, tv); +#endif + /* then copy attributes */ tv->attributes |= var->attributes & ~att_tempvar; - if (tv->context > 0) + if (tv->context > 0 && local_p (var) == 0) /* just paranoia here */ VSETATTR (tv, att_propagate); } - free (tvalue); } - VSETATTR (var, att_propagate); + /* XXX - don't propagate local variables back to a previous scope, + even in posix mode. */ + if (local_p (var) == 0) + VSETATTR (var, att_propagate); } /* Turn on nameref attribute we deferred above. */ diff --git a/builtins/echo.def b/builtins/echo.def index 4e2243dbe..37b0bbac1 100644 --- a/builtins/echo.def +++ b/builtins/echo.def @@ -1,7 +1,7 @@ This file is echo.def, from which is created echo.c. It implements the builtin "echo" in Bash. -Copyright (C) 1987-2018 Free Software Foundation, Inc. +Copyright (C) 1987-2018,2022 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -107,10 +107,10 @@ int xpg_echo = 0; `-n', then don't print a trailing newline. We also support the echo syntax from Version 9 Unix systems. */ int -echo_builtin (list) - WORD_LIST *list; +echo_builtin (WORD_LIST *list) { - int display_return, do_v9, i, len; + int display_return, do_v9, i; + size_t len; char *temp, *s; do_v9 = xpg_echo; diff --git a/builtins/enable.def b/builtins/enable.def index 27d341a6f..72da559cf 100644 --- a/builtins/enable.def +++ b/builtins/enable.def @@ -1,7 +1,7 @@ This file is enable.def, from which is created enable.c. It implements the builtin "enable" in Bash. -Copyright (C) 1987-2021 Free Software Foundation, Inc. +Copyright (C) 1987-2024 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -41,6 +41,11 @@ Options controlling dynamic loading: Without options, each NAME is enabled. +On systems with dynamic loading, the shell variable BASH_LOADABLES_PATH +defines a search path for the directory containing FILENAMEs that do +not contain a slash. It may include "." to force a search of the current +directory. + To use the `test' found in $PATH instead of the shell builtin version, type `enable -n test'. @@ -85,13 +90,13 @@ $END #define SFLAG 0x20 #if defined (HAVE_DLOPEN) && defined (HAVE_DLSYM) -static int dyn_load_builtin PARAMS((WORD_LIST *, int, char *)); +static int dyn_load_builtin (WORD_LIST *, int, char *); #endif #if defined (HAVE_DLCLOSE) -static int dyn_unload_builtin PARAMS((char *)); -static void delete_builtin PARAMS((struct builtin *)); -static int local_dlclose PARAMS((void *)); +static int dyn_unload_builtin (char *); +static void delete_builtin (struct builtin *); +static int local_dlclose (void *); #endif #define STRUCT_SUFFIX "_struct" @@ -99,15 +104,14 @@ static int local_dlclose PARAMS((void *)); #define LOAD_SUFFIX "_builtin_load" #define UNLOAD_SUFFIX "_builtin_unload" -static void list_some_builtins PARAMS((int)); -static int enable_shell_command PARAMS((char *, int)); +static void list_some_builtins (int); +static int enable_shell_command (char *, int); /* Enable/disable shell commands present in LIST. If list is not specified, then print out a list of shell commands showing which are enabled and which are disabled. */ int -enable_builtin (list) - WORD_LIST *list; +enable_builtin (WORD_LIST *list) { int result, flags; int opt, filter; @@ -194,6 +198,8 @@ enable_builtin (list) result = EXECUTION_FAILURE; /* normalize return value */ #if defined (PROGRAMMABLE_COMPLETION) set_itemlist_dirty (&it_builtins); + set_itemlist_dirty (&it_enabled); + set_itemlist_dirty (&it_disabled); #endif } #endif @@ -209,6 +215,8 @@ enable_builtin (list) } #if defined (PROGRAMMABLE_COMPLETION) set_itemlist_dirty (&it_builtins); + set_itemlist_dirty (&it_enabled); + set_itemlist_dirty (&it_disabled); #endif } #endif @@ -216,32 +224,41 @@ enable_builtin (list) { while (list) { - opt = enable_shell_command (list->word->word, flags & NFLAG); + char *command; + + command = list->word->word; + opt = enable_shell_command (command, flags & NFLAG); next = list->next; #if defined (HAVE_DLOPEN) && defined (HAVE_DLSYM) /* If we try to enable a non-existent builtin, and we have dynamic loading, try the equivalent of `enable -f name name'. */ - if (opt == EX_NOTFOUND) +#if defined (RESTRICTED_SHELL) + if (*command && (flags & NFLAG) == 0 && opt == EX_NOTFOUND && restricted == 0) +#else + if (*command && (flags & NFLAG) == 0 && opt == EX_NOTFOUND) +#endif { int dflags, r; dflags = ENABLED|SILENT|((flags & SFLAG) ? SPECIAL : 0); list->next = 0; - r = dyn_load_builtin (list, dflags, list->word->word); + r = dyn_load_builtin (list, dflags, command); list->next = next; if (r == EXECUTION_SUCCESS) opt = r; #if defined (PROGRAMMABLE_COMPLETION) set_itemlist_dirty (&it_builtins); + set_itemlist_dirty (&it_enabled); + set_itemlist_dirty (&it_disabled); #endif } #endif if (opt == EX_NOTFOUND) { - sh_notbuiltin (list->word->word); + sh_notbuiltin (command); result = EXECUTION_FAILURE; } else if (opt != EXECUTION_SUCCESS) @@ -254,10 +271,9 @@ enable_builtin (list) } /* List some builtins. - FILTER is a mask with two slots: ENABLED and DISABLED. */ + FILTER is a mask with three slots: SPECIAL, ENABLED, and DISABLED. */ static void -list_some_builtins (filter) - int filter; +list_some_builtins (int filter) { register int i; @@ -281,9 +297,7 @@ list_some_builtins (filter) /* Enable the shell command NAME. If DISABLE_P is non-zero, then disable NAME instead. */ static int -enable_shell_command (name, disable_p) - char *name; - int disable_p; +enable_shell_command (char *name, int disable_p) { struct builtin *b; @@ -318,15 +332,13 @@ enable_shell_command (name, disable_p) #endif static int -dyn_load_builtin (list, flags, filename) - WORD_LIST *list; - int flags; - char *filename; +dyn_load_builtin (WORD_LIST *list, int flags, char *filename) { WORD_LIST *l; void *handle; - int total, size, new, replaced, r; + int total, replaced, r; + size_t size, new; char *struct_name, *name, *funcname; sh_load_func_t *loadfunc; struct builtin **new_builtins, *b, *new_shell_builtins, *old_builtin; @@ -339,32 +351,33 @@ dyn_load_builtin (list, flags, filename) #define RTLD_LAZY 1 #endif - handle = 0; - if (absolute_program (filename) == 0) - { - loadables_path = get_string_value ("BASH_LOADABLES_PATH"); - if (loadables_path) - { - load_path = find_in_path (filename, loadables_path, FS_NODIRS|FS_EXEC_PREFERRED); - if (load_path) - { #if defined (_AIX) - handle = dlopen (load_path, RTLD_NOW|RTLD_GLOBAL); +# define DLFLAGS (RTLD_NOW|RTLD_GLOBAL) #else - handle = dlopen (load_path, RTLD_LAZY); +# define DLFLAGS RTLD_LAZY #endif /* !_AIX */ - free (load_path); - } + + handle = 0; + if (absolute_program (filename)) + handle = dlopen (filename, DLFLAGS); + else if (loadables_path = path_value ("BASH_LOADABLES_PATH", 1)) + { + /* If we have a loadables path, don't fall back to the current directory. */ + load_path = find_in_path (filename, loadables_path, FS_NODIRS|FS_EXEC_PREFERRED); + if (load_path) + { + handle = dlopen (load_path, DLFLAGS); + free (load_path); } } + else /* no loadables path, look in current directory */ + { + char *openname; - /* Fall back to current directory for now */ - if (handle == 0) -#if defined (_AIX) - handle = dlopen (filename, RTLD_NOW|RTLD_GLOBAL); -#else - handle = dlopen (filename, RTLD_LAZY); -#endif /* !_AIX */ + openname = make_absolute (filename, "."); + handle = dlopen (openname, DLFLAGS); + free (openname); + } if (handle == 0) { @@ -387,9 +400,14 @@ dyn_load_builtin (list, flags, filename) /* For each new builtin in the shared object, find it and its describing structure. If this is overwriting an existing builtin, do so, otherwise save the loaded struct for creating the new list of builtins. */ - for (replaced = new = 0; list; list = list->next) + for (replaced = 0, new = 0; list; list = list->next) { name = list->word->word; + if (absolute_program (name)) + { + builtin_error (_("%s: builtin names may not contain slashes"), name); + continue; + } size = strlen (name); struct_name = (char *)xmalloc (size + 8); @@ -433,6 +451,8 @@ dyn_load_builtin (list, flags, filename) b->flags &= ~STATIC_BUILTIN; if (flags & SPECIAL) b->flags |= SPECIAL_BUILTIN; + if (flags & DISABLED) + b->flags &= ~BUILTIN_ENABLED; b->handle = handle; if (old_builtin) @@ -483,18 +503,13 @@ dyn_load_builtin (list, flags, filename) #if defined (HAVE_DLCLOSE) static void -delete_builtin (b) - struct builtin *b; +delete_builtin (struct builtin *b) { int ind, size; struct builtin *new_shell_builtins; /* XXX - funky pointer arithmetic - XXX */ -#ifdef __STDC__ ind = b - shell_builtins; -#else - ind = ((int)b - (int)shell_builtins) / sizeof (struct builtin); -#endif size = num_shell_builtins * sizeof (struct builtin); new_shell_builtins = (struct builtin *)xmalloc (size); @@ -519,8 +534,7 @@ delete_builtin (b) /* Tenon's MachTen has a dlclose that doesn't return a value, so we finesse it with a local wrapper. */ static int -local_dlclose (handle) - void *handle; +local_dlclose (void *handle) { #if !defined (__MACHTEN__) return (dlclose (handle)); @@ -531,14 +545,14 @@ local_dlclose (handle) } static int -dyn_unload_builtin (name) - char *name; +dyn_unload_builtin (char *name) { struct builtin *b; void *handle; char *funcname; sh_unload_func_t *unloadfunc; - int ref, i, size; + int ref, i; + size_t size; b = builtin_address_internal (name, 1); if (b == 0) diff --git a/builtins/eval.def b/builtins/eval.def index f459bce34..0160b9618 100644 --- a/builtins/eval.def +++ b/builtins/eval.def @@ -1,7 +1,7 @@ This file is eval.def, from which is created eval.c. It implements the builtin "eval" in Bash. -Copyright (C) 1987-2016 Free Software Foundation, Inc. +Copyright (C) 1987-2016,2022 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -46,8 +46,7 @@ $END /* Parse the string that these words make, and execute the command found. */ int -eval_builtin (list) - WORD_LIST *list; +eval_builtin (WORD_LIST *list) { if (no_options (list)) return (EX_USAGE); diff --git a/builtins/evalfile.c b/builtins/evalfile.c index 604de577e..1fee9880e 100644 --- a/builtins/evalfile.c +++ b/builtins/evalfile.c @@ -1,6 +1,6 @@ /* evalfile.c - read and evaluate commands from a file or file descriptor */ -/* Copyright (C) 1996-2017 Free Software Foundation, Inc. +/* Copyright (C) 1996-2017,2022-2024 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -58,7 +58,7 @@ extern int errno; #endif -/* Flags for _evalfile() */ +/* Flags for evalfile_internal() */ #define FEVAL_ENOENTOK 0x001 #define FEVAL_BUILTIN 0x002 #define FEVAL_UNWINDPROT 0x004 @@ -68,18 +68,18 @@ extern int errno; #define FEVAL_CHECKBINARY 0x040 #define FEVAL_REGFILE 0x080 #define FEVAL_NOPUSHARGS 0x100 +#define FEVAL_RETRY 0x200 /* How many `levels' of sourced files we have. */ int sourcelevel = 0; static int -_evalfile (filename, flags) - const char *filename; - int flags; +evalfile_internal (const char *filename, int flags) { volatile int old_interactive; procenv_t old_return_catch; - int return_val, fd, result, pflags, i, nnull; + int return_val, fd, result, pflags, nnull; + size_t i; ssize_t nr; /* return value from read(2) */ char *string; struct stat finfo; @@ -98,24 +98,23 @@ _evalfile (filename, flags) USE_VAR(pflags); -#if defined (ARRAY_VARS) - GET_ARRAY_FROM_VAR ("FUNCNAME", funcname_v, funcname_a); - GET_ARRAY_FROM_VAR ("BASH_SOURCE", bash_source_v, bash_source_a); - GET_ARRAY_FROM_VAR ("BASH_LINENO", bash_lineno_v, bash_lineno_a); -# if defined (DEBUGGER) - GET_ARRAY_FROM_VAR ("BASH_ARGV", bash_argv_v, bash_argv_a); - GET_ARRAY_FROM_VAR ("BASH_ARGC", bash_argc_v, bash_argc_a); -# endif -#endif - - fd = open (filename, O_RDONLY); + errno = 0; + do + { + fd = open (filename, O_RDONLY); + result = errno; + if (fd < 0 && result == EINTR) + QUIT; + errno = result; + } + while (fd < 0 && errno == EINTR && (flags & FEVAL_RETRY)); if (fd < 0 || (fstat (fd, &finfo) == -1)) { - i = errno; + result = errno; if (fd >= 0) close (fd); - errno = i; + errno = result; file_error_and_exit: if (((flags & FEVAL_ENOENTOK) == 0) || errno != ENOENT) @@ -153,7 +152,7 @@ file_error_and_exit: (*errfunc) (_("%s: file is too large"), filename); close (fd); return ((flags & FEVAL_BUILTIN) ? EXECUTION_FAILURE : -1); - } + } if (S_ISREG (finfo.st_mode) && file_size <= SSIZE_MAX) { @@ -161,6 +160,8 @@ file_error_and_exit: nr = read (fd, string, file_size); if (nr >= 0) string[nr] = '\0'; + if (nr != file_size) + nr = -1; /* XXX - didn't get the whole file */ } else nr = zmapfd (fd, &string, 0); @@ -185,7 +186,7 @@ file_error_and_exit: check_binary_file (string, (nr > 80) ? 80 : nr)) { free (string); - (*errfunc) (_("%s: cannot execute binary file"), filename); + (*errfunc) ("%s: %s", filename, _("cannot execute binary file")); return ((flags & FEVAL_BUILTIN) ? EX_BINARY_FILE : -1); } @@ -203,7 +204,7 @@ file_error_and_exit: if ((flags & FEVAL_BUILTIN) && ++nnull > 256) { free (string); - (*errfunc) (_("%s: cannot execute binary file"), filename); + (*errfunc) ("%s: %s", filename, _("cannot execute binary file")); return ((flags & FEVAL_BUILTIN) ? EX_BINARY_FILE : -1); } } @@ -211,13 +212,15 @@ file_error_and_exit: if (flags & FEVAL_UNWINDPROT) { - begin_unwind_frame ("_evalfile"); + begin_unwind_frame ("evalfile_internal"); unwind_protect_int (return_catch_flag); unwind_protect_jmp_buf (return_catch); if (flags & FEVAL_NONINT) unwind_protect_int (interactive); unwind_protect_int (sourcelevel); + unwind_protect_int (want_job_notifications); + unwind_protect_int (retain_fifos); } else { @@ -231,9 +234,21 @@ file_error_and_exit: return_catch_flag++; sourcelevel++; + if (interactive_shell && shell_compatibility_level <= 52) + want_job_notifications++; + + retain_fifos++; /* XXX */ #if defined (ARRAY_VARS) - array_push (bash_source_a, (char *)filename); + GET_ARRAY_FROM_VAR ("FUNCNAME", funcname_v, funcname_a); + GET_ARRAY_FROM_VAR ("BASH_SOURCE", bash_source_v, bash_source_a); + GET_ARRAY_FROM_VAR ("BASH_LINENO", bash_lineno_v, bash_lineno_a); +# if defined (DEBUGGER) + GET_ARRAY_FROM_VAR ("BASH_ARGV", bash_argv_v, bash_argv_a); + GET_ARRAY_FROM_VAR ("BASH_ARGC", bash_argc_v, bash_argc_a); +# endif + + push_source (bash_source_a, (char *)filename); t = itos (executing_line_number ()); array_push (bash_lineno_a, t); free (t); @@ -247,7 +262,7 @@ file_error_and_exit: fa->funcname_a = funcname_a; fa->funcname_v = funcname_v; if (flags & FEVAL_UNWINDPROT) - add_unwind_protect (restore_funcarray_state, fa); + add_unwind_protect (uw_restore_funcarray_state, fa); # if defined (DEBUGGER) /* Have to figure out a better way to do this when `source' is supplied @@ -260,7 +275,7 @@ file_error_and_exit: tt[0] = '1'; tt[1] = '\0'; array_push (bash_argc_a, tt); if (flags & FEVAL_UNWINDPROT) - add_unwind_protect (pop_args, 0); + add_unwind_protect (uw_pop_args, 0); } # endif #endif @@ -285,7 +300,7 @@ file_error_and_exit: result = parse_and_execute (string, filename, pflags); if (flags & FEVAL_UNWINDPROT) - run_unwind_frame ("_evalfile"); + run_unwind_frame ("evalfile_internal"); else { if (flags & FEVAL_NONINT) @@ -304,6 +319,9 @@ file_error_and_exit: #endif return_catch_flag--; sourcelevel--; + if (interactive_shell && shell_compatibility_level <= 52) + want_job_notifications--; + retain_fifos--; COPY_PROCENV (old_return_catch, return_catch); } @@ -316,43 +334,38 @@ file_error_and_exit: } int -maybe_execute_file (fname, force_noninteractive) - const char *fname; - int force_noninteractive; +maybe_execute_file (const char *fname, int force_noninteractive) { char *filename; int result, flags; filename = bash_tilde_expand (fname, 0); - flags = FEVAL_ENOENTOK; + flags = FEVAL_ENOENTOK|FEVAL_RETRY; if (force_noninteractive) flags |= FEVAL_NONINT; - result = _evalfile (filename, flags); + result = evalfile_internal (filename, flags); free (filename); return result; } int -force_execute_file (fname, force_noninteractive) - const char *fname; - int force_noninteractive; +force_execute_file (const char *fname, int force_noninteractive) { char *filename; int result, flags; filename = bash_tilde_expand (fname, 0); - flags = 0; + flags = FEVAL_RETRY; if (force_noninteractive) flags |= FEVAL_NONINT; - result = _evalfile (filename, flags); + result = evalfile_internal (filename, flags); free (filename); return result; } #if defined (HISTORY) int -fc_execute_file (filename) - const char *filename; +fc_execute_file (const char *filename) { int flags; @@ -360,14 +373,12 @@ fc_execute_file (filename) remember_on_history is set. We use FEVAL_BUILTIN to return the result of parse_and_execute. */ flags = FEVAL_ENOENTOK|FEVAL_HISTORY|FEVAL_REGFILE|FEVAL_BUILTIN; - return (_evalfile (filename, flags)); + return (evalfile_internal (filename, flags)); } #endif /* HISTORY */ int -source_file (filename, sflags) - const char *filename; - int sflags; +source_file (const char *filename, int sflags) { int flags, rval; @@ -377,7 +388,7 @@ source_file (filename, sflags) /* POSIX shells exit if non-interactive and file error. */ if (posixly_correct && interactive_shell == 0 && executing_command_builtin == 0) flags |= FEVAL_LONGJMP; - rval = _evalfile (filename, flags); + rval = evalfile_internal (filename, flags); run_return_trap (); return rval; diff --git a/builtins/evalstring.c b/builtins/evalstring.c index 53a7c0b87..2b15b9dd7 100644 --- a/builtins/evalstring.c +++ b/builtins/evalstring.c @@ -1,6 +1,6 @@ /* evalstring.c - evaluate a string as one or more shell commands. */ -/* Copyright (C) 1996-2022 Free Software Foundation, Inc. +/* Copyright (C) 1996-2025 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -63,36 +63,53 @@ extern int errno; int parse_and_execute_level = 0; -static int cat_file PARAMS((REDIRECT *)); +static int cat_file (REDIRECT *); #define PE_TAG "parse_and_execute top" #define PS_TAG "parse_string top" #if defined (HISTORY) static void -set_history_remembering () +uw_set_history_remembering (void *ignore) { remember_on_history = enable_history_list; } + #endif static void -restore_lastcom (x) - char *x; +uw_restore_lastcom (void *x) { FREE (the_printed_command_except_trap); the_printed_command_except_trap = x; } +static void +uw_set_current_prompt_level (void *x) +{ + set_current_prompt_level ((intptr_t) x); +} + +static void +uw_pop_stream (void *x) +{ + pop_stream (); +} + +static void +uw_parser_restore_alias (void *x) +{ + parser_restore_alias (); +} + int -should_optimize_fork (command, subshell) - COMMAND *command; - int subshell; +should_optimize_fork (COMMAND *command, int subshell) { return (running_trap == 0 && command->type == cm_simple && signal_is_trapped (EXIT_TRAP) == 0 && signal_is_trapped (ERROR_TRAP) == 0 && + (variable_context == 0 || signal_is_trapped (RETURN_TRAP) == 0) && any_signals_trapped () < 0 && (subshell || (command->redirects == 0 && command->value.Simple->redirects == 0)) && ((command->flags & CMD_TIME_PIPELINE) == 0) && @@ -102,9 +119,10 @@ should_optimize_fork (command, subshell) /* This has extra tests to account for STARTUP_STATE == 2, which is for -c command but has been extended to command and process substitution (basically any time you call parse_and_execute in a subshell). */ +/* ssh_reading_startup_files will never be non-zero unless someone goes + and uncomments SSH_SOURCE_BASHRC in config-top.h */ int -should_suppress_fork (command) - COMMAND *command; +should_suppress_fork (COMMAND *command) { int subshell; @@ -112,22 +130,22 @@ should_suppress_fork (command) return (startup_state == 2 && parse_and_execute_level == 1 && *bash_input.location.string == '\0' && parser_expanding_alias () == 0 && + job_control_active_p () == 0 && + ssh_reading_startup_files == 0 && should_optimize_fork (command, subshell)); } int -can_optimize_connection (command) - COMMAND *command; +can_optimize_connection (COMMAND *command) { - return (*bash_input.location.string == '\0' && + return ((bash_input.type != st_string || *bash_input.location.string == '\0') && parser_expanding_alias () == 0 && (command->value.Connection->connector == AND_AND || command->value.Connection->connector == OR_OR || command->value.Connection->connector == ';') && command->value.Connection->second->type == cm_simple); } void -optimize_connection_fork (command) - COMMAND *command; +optimize_connection_fork (COMMAND *command) { if (command->type == cm_connection && (command->value.Connection->connector == AND_AND || command->value.Connection->connector == OR_OR || command->value.Connection->connector == ';') && @@ -141,8 +159,7 @@ optimize_connection_fork (command) } void -optimize_subshell_command (command) - COMMAND *command; +optimize_subshell_command (COMMAND *command) { if (should_optimize_fork (command, 0)) { @@ -160,8 +177,7 @@ optimize_subshell_command (command) } void -optimize_shell_function (command) - COMMAND *command; +optimize_shell_function (COMMAND *command) { COMMAND *fc; @@ -172,16 +188,15 @@ optimize_shell_function (command) fc->flags |= CMD_NO_FORK; fc->value.Simple->flags |= CMD_NO_FORK; } - else if (fc->type == cm_connection && can_optimize_connection (fc) && should_suppress_fork (fc->value.Connection->second)) + else if (fc->type == cm_connection && can_optimize_connection (fc)) { - fc->value.Connection->second->flags |= CMD_NO_FORK; - fc->value.Connection->second->value.Simple->flags |= CMD_NO_FORK; - } + fc->value.Connection->second->flags |= CMD_TRY_OPTIMIZING; + fc->value.Connection->second->value.Simple->flags |= CMD_TRY_OPTIMIZING; + } } int -can_optimize_cat_file (command) - COMMAND *command; +can_optimize_cat_file (COMMAND *command) { return (command->type == cm_simple && !command->redirects && (command->flags & CMD_TIME_PIPELINE) == 0 && @@ -194,8 +209,7 @@ can_optimize_cat_file (command) /* How to force parse_and_execute () to clean up after itself. */ void -parse_and_execute_cleanup (old_running_trap) - int old_running_trap; +parse_and_execute_cleanup (int old_running_trap) { if (running_trap > 0) { @@ -215,10 +229,7 @@ parse_and_execute_cleanup (old_running_trap) } static void -parse_prologue (string, flags, tag) - char *string; - int flags; - char *tag; +parse_prologue (char *string, int flags, char *tag) { char *orig_string, *lastcom; int x; @@ -232,14 +243,17 @@ parse_prologue (string, flags, tag) unwind_protect_int (line_number); unwind_protect_int (line_number_for_err_trap); unwind_protect_int (loop_level); - unwind_protect_int (executing_list); + unwind_protect_int (interrupt_execution); unwind_protect_int (comsub_ignore_return); + unwind_protect_int (builtin_ignoring_errexit); if (flags & (SEVAL_NONINT|SEVAL_INTERACT)) unwind_protect_int (interactive); + if (flags & SEVAL_NOTIFY) + unwind_protect_int (want_job_notifications); #if defined (HISTORY) if (parse_and_execute_level == 0) - add_unwind_protect (set_history_remembering, (char *)NULL); + add_unwind_protect (uw_set_history_remembering, (char *)NULL); else unwind_protect_int (remember_on_history); /* can be used in scripts */ # if defined (BANG_HISTORY) @@ -250,18 +264,18 @@ parse_prologue (string, flags, tag) if (interactive_shell) { x = get_current_prompt_level (); - add_unwind_protect (set_current_prompt_level, x); + add_unwind_protect (uw_set_current_prompt_level, (void *) (intptr_t) x); } if (the_printed_command_except_trap) { lastcom = savestring (the_printed_command_except_trap); - add_unwind_protect (restore_lastcom, lastcom); + add_unwind_protect (uw_restore_lastcom, lastcom); } - add_unwind_protect (pop_stream, (char *)NULL); + add_unwind_protect (uw_pop_stream, (char *)NULL); if (parser_expanding_alias ()) - add_unwind_protect (parser_restore_alias, (char *)NULL); + add_unwind_protect (uw_parser_restore_alias, (char *)NULL); if (orig_string && ((flags & SEVAL_NOFREE) == 0)) add_unwind_protect (xfree, orig_string); @@ -270,6 +284,9 @@ parse_prologue (string, flags, tag) if (flags & (SEVAL_NONINT|SEVAL_INTERACT)) interactive = (flags & SEVAL_NONINT) ? 0 : 1; + if (flags & SEVAL_NOTIFY) + want_job_notifications = 1; + #if defined (HISTORY) if (flags & SEVAL_NOHIST) bash_history_disable (); @@ -291,15 +308,13 @@ parse_prologue (string, flags, tag) (flags & SEVAL_RESETLINE) -> reset line_number to 1 (flags & SEVAL_NOHISTEXP) -> history_expansion_inhibited -> 1 (flags & SEVAL_NOOPTIMIZE) -> don't try to turn on optimizing flags + (flags & SEVAL_NOTIFY) -> print job status notifications */ int -parse_and_execute (string, from_file, flags) - char *string; - const char *from_file; - int flags; +parse_and_execute (char *string, const char *from_file, int flags) { - int code, lreset; + int code, lreset, ignore_return; volatile int should_jump_to_top_level, last_result; COMMAND *volatile command; volatile sigset_t pe_sigmask; @@ -309,6 +324,8 @@ parse_and_execute (string, from_file, flags) parse_and_execute_level++; lreset = flags & SEVAL_RESETLINE; + ignore_return = (this_shell_builtin == eval_builtin || this_shell_builtin == source_builtin) && + builtin_ignoring_errexit; #if defined (HAVE_POSIX_SIGNALS) /* If we longjmp and are going to go on, use this to restore signal mask */ @@ -408,6 +425,7 @@ parse_and_execute (string, from_file, flags) run_unwind_frame ("pe_dispose"); last_result = last_command_exit_value = EXECUTION_FAILURE; /* XXX */ set_pipestatus_from_exit (last_command_exit_value); + if (subshell_environment) { should_jump_to_top_level = 1; @@ -461,6 +479,8 @@ parse_and_execute (string, from_file, flags) should_jump_to_top_level = 0; last_result = last_command_exit_value = EX_BADUSAGE; set_pipestatus_from_exit (last_command_exit_value); + dispose_command (command); + global_command = (COMMAND *)NULL; reset_parser (); break; } @@ -468,14 +488,17 @@ parse_and_execute (string, from_file, flags) bitmap = new_fd_bitmap (FD_BITMAP_SIZE); begin_unwind_frame ("pe_dispose"); - add_unwind_protect (dispose_fd_bitmap, bitmap); - add_unwind_protect (dispose_command, command); /* XXX */ + add_unwind_protect (uw_dispose_fd_bitmap, bitmap); + add_unwind_protect (uw_dispose_command, command); /* XXX */ global_command = (COMMAND *)NULL; if ((subshell_environment & SUBSHELL_COMSUB) && comsub_ignore_return) command->flags |= CMD_IGNORE_RETURN; + if (ignore_return) + command->flags |= CMD_IGNORE_RETURN; + #if defined (ONESHOT) /* * IF @@ -522,9 +545,12 @@ parse_and_execute (string, from_file, flags) the global value of the flag (expaliases_flag) changes). */ local_expalias = expand_aliases; local_alflag = expaliases_flag; - if (subshell_environment & SUBSHELL_COMSUB) + if ((subshell_environment & SUBSHELL_COMSUB) || executing_funsub) expand_aliases = expaliases_flag; + /* This functionality is now implemented as part of + subst.c:command_substitute(). */ +#if 0 /* See if this is a candidate for $( value.Simple->redirects); last_result = (r < 0) ? EXECUTION_FAILURE : EXECUTION_SUCCESS; } else +#endif last_result = execute_command_internal (command, 0, NO_PIPE, NO_PIPE, bitmap); dispose_command (command); @@ -543,7 +571,7 @@ parse_and_execute (string, from_file, flags) discard_unwind_frame ("pe_dispose"); /* If the global value didn't change, we restore what we had. */ - if ((subshell_environment & SUBSHELL_COMSUB) && local_alflag == expaliases_flag) + if (((subshell_environment & SUBSHELL_COMSUB) || executing_funsub) && local_alflag == expaliases_flag) expand_aliases = local_expalias; if (flags & SEVAL_ONECMD) @@ -599,12 +627,7 @@ parse_and_execute (string, from_file, flags) command substitutions during parsing to obey Posix rules about finding the end of the command and balancing parens. */ int -parse_string (string, from_file, flags, cmdp, endp) - char *string; - const char *from_file; - int flags; - COMMAND **cmdp; - char **endp; +parse_string (char *string, const char *from_file, int flags, COMMAND **cmdp, char **endp) { int code, nc; volatile int should_jump_to_top_level; @@ -612,6 +635,7 @@ parse_string (string, from_file, flags, cmdp, endp) char *ostring; volatile sigset_t ps_sigmask; + /* unwind-protects common to this and parse_and_execute */ parse_prologue (string, flags, PS_TAG); #if defined (HAVE_POSIX_SIGNALS) @@ -682,6 +706,10 @@ parse_string (string, from_file, flags, cmdp, endp) else dispose_command (global_command); global_command = (COMMAND *)NULL; + /* Presumably this is an error if we haven't consumed the + entire string, but we let the caller deal with it. */ + if (flags & SEVAL_ONECMD) + break; } else { @@ -697,7 +725,8 @@ parse_string (string, from_file, flags, cmdp, endp) if (current_token == yacc_EOF || current_token == shell_eof_token) { - if (current_token == shell_eof_token) + /* check for EOFTOKEN out of paranoia */ + if ((parser_state & PST_EOFTOKEN) && (current_token == shell_eof_token)) rewind_input_string (); break; } @@ -716,10 +745,10 @@ out: us, after doing cleanup */ if (should_jump_to_top_level) { - if (parse_and_execute_level == 0) - top_level_cleanup (); if (code == DISCARD) return -DISCARD; + if (parse_and_execute_level == 0) + top_level_cleanup (); jump_to_top_level (code); } @@ -727,12 +756,10 @@ out: } int -open_redir_file (r, fnp) - REDIRECT *r; - char **fnp; +open_redir_file (REDIRECT *r, char **fnp) { char *fn; - int fd, rval; + int fd; if (r->instruction != r_input_direction) return -1; @@ -753,7 +780,7 @@ open_redir_file (r, fnp) fd = open(fn, O_RDONLY); if (fd < 0) { - file_error (fn); + internal_error ("%s: %s", fn, strerror (errno)); free (fn); if (fnp) *fnp = 0; @@ -772,8 +799,7 @@ open_redir_file (r, fnp) returning errors as appropriate, then just cats the file to the standard output. */ static int -cat_file (r) - REDIRECT *r; +cat_file (REDIRECT *r) { char *fn; int fd, rval; @@ -791,10 +817,7 @@ cat_file (r) } int -evalstring (string, from_file, flags) - char *string; - const char *from_file; - int flags; +evalstring (char *string, const char *from_file, int flags) { volatile int r, rflag, rcatch; volatile int was_trap; diff --git a/builtins/exec.def b/builtins/exec.def index add908229..285f9ddfe 100644 --- a/builtins/exec.def +++ b/builtins/exec.def @@ -1,7 +1,7 @@ This file is exec.def, from which is created exec.c. It implements the builtin "exec" in Bash. -Copyright (C) 1987-2021 Free Software Foundation, Inc. +Copyright (C) 1987-2021,2022,2024,2025 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -85,8 +85,7 @@ int no_exit_on_failed_exec; /* If the user wants this to look like a login shell, then prepend a `-' onto NAME and return the new name. */ static char * -mkdashname (name) - char *name; +mkdashname (char *name) { char *ret; @@ -97,15 +96,15 @@ mkdashname (name) } int -exec_builtin (list) - WORD_LIST *list; +exec_builtin (WORD_LIST *list) { - int exit_value = EXECUTION_FAILURE; + int exit_value; int cleanenv, login, opt, orig_job_control; char *argv0, *command, **args, **env, *newname, *com2; cleanenv = login = orig_job_control = 0; exec_argv0 = argv0 = (char *)NULL; + exit_value = EXECUTION_FAILURE; reset_internal_getopt (); while ((opt = internal_getopt (list, "cla:")) != -1) @@ -129,12 +128,13 @@ exec_builtin (list) } list = loptend; - /* First, let the redirections remain. */ - dispose_redirects (redirection_undo_list); - redirection_undo_list = (REDIRECT *)NULL; - + /* First, let the redirections remain if exec is called without operands */ if (list == 0) - return (EXECUTION_SUCCESS); + { + dispose_redirects (redirection_undo_list); + redirection_undo_list = (REDIRECT *)NULL; + return (EXECUTION_SUCCESS); + } #if defined (RESTRICTED_SHELL) if (restricted) @@ -155,9 +155,9 @@ exec_builtin (list) if (file_isdir (args[0])) { #if defined (EISDIR) - builtin_error (_("%s: cannot execute: %s"), args[0], strerror (EISDIR)); + builtin_error ("%s: %s: %s", args[0], _("cannot execute"), strerror (EISDIR)); #else - builtin_error (_("%s: cannot execute: %s"), args[0], strerror (errno)); + builtin_error ("%s: %s: %s", args[0], _("cannot execute"), strerror (errno)); #endif exit_value = EX_NOEXEC; } @@ -225,29 +225,32 @@ exec_builtin (list) default_tty_job_signals (); /* undo initialize_job_signals */ #endif /* JOB_CONTROL */ -#if defined (BUFFERED_INPUT) if (default_buffered_input >= 0) sync_buffered_stream (default_buffered_input); -#endif exit_value = shell_execve (command, args, env); + opt = errno; - /* We have to set this to NULL because shell_execve has called realloc() - to stuff more items at the front of the array, which may have caused - the memory to be freed by realloc(). We don't want to free it twice. */ - args = (char **)NULL; if (cleanenv == 0) adjust_shell_level (1); - if (exit_value == EX_NOTFOUND) /* no duplicate error message */ + /* These are the return statuses for which shell_execve will print a message. */ + if (exit_value == EX_NOTFOUND || exit_value == EX_BINARY_FILE || exit_value == EX_NOEXEC) goto failed_exec; - else if (executable_file (command) == 0) + /* These are the errno values for which shell_execve will print a message. */ +#if defined (EISDIR) + else if (opt == EISDIR || opt == E2BIG || opt == ENOMEM) +#else + else if (opt == E2BIG || opt == ENOMEM) +#endif + goto failed_exec; + else /* catchall */ { - builtin_error (_("%s: cannot execute: %s"), command, strerror (errno)); - exit_value = EX_NOEXEC; /* As per Posix.2, 3.14.6 */ + builtin_error ("%s: %s: %s", command, _("cannot execute"), strerror (opt)); + if (executable_file (command) == 0) + exit_value = EX_NOEXEC; /* As per Posix.2, 3.14.6 */ + errno = opt; } - else - file_error (command); failed_exec: FREE (command); diff --git a/builtins/exit.def b/builtins/exit.def index 9c85bc582..32b55420b 100644 --- a/builtins/exit.def +++ b/builtins/exit.def @@ -1,7 +1,7 @@ This file is exit.def, from which is created exit.c. It implements the builtins "exit", and "logout" in Bash. -Copyright (C) 1987-2021 Free Software Foundation, Inc. +Copyright (C) 1987-2024 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -48,14 +48,11 @@ $END #include "common.h" #include "builtext.h" /* for jobs_builtin */ -extern int check_jobs_at_exit; - -static int exit_or_logout PARAMS((WORD_LIST *)); +static int exit_or_logout (WORD_LIST *); static int sourced_logout; int -exit_builtin (list) - WORD_LIST *list; +exit_builtin (WORD_LIST *list) { CHECK_HELPOPT (list); @@ -79,8 +76,7 @@ $END /* How to logout. */ int -logout_builtin (list) - WORD_LIST *list; +logout_builtin (WORD_LIST *list) { CHECK_HELPOPT (list); @@ -94,8 +90,7 @@ logout_builtin (list) } static int -exit_or_logout (list) - WORD_LIST *list; +exit_or_logout (WORD_LIST *list) { int exit_value; @@ -143,8 +138,11 @@ exit_or_logout (list) /* If we're running the exit trap (running_trap == 1, since running_trap gets set to SIG+1), and we don't have a argument given to `exit' (list == 0), use the exit status we saved before running the trap - commands (trap_saved_exit_value). */ + commands (trap_saved_exit_value). get_exitstat() handles the case of + running exit from any other trap action (POSIX interp 1602). */ exit_value = (running_trap == 1 && list == 0) ? trap_saved_exit_value : get_exitstat (list); + if (exit_value > EX_SHERRBASE) /* some kind of error */ + return (exit_value); bash_logout (); @@ -156,7 +154,7 @@ exit_or_logout (list) } void -bash_logout () +bash_logout (void) { /* Run our `~/.bash_logout' file if it exists, and this is a login shell. */ if (login_shell && sourced_logout++ == 0 && subshell_environment == 0) diff --git a/builtins/fc.def b/builtins/fc.def index 9b8a997de..1d88a49a1 100644 --- a/builtins/fc.def +++ b/builtins/fc.def @@ -1,7 +1,7 @@ This file is fc.def, from which is created fc.c. It implements the builtin "fc" in Bash. -Copyright (C) 1987-2021 Free Software Foundation, Inc. +Copyright (C) 1987-2024 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -45,6 +45,8 @@ A useful alias to use with this is r='fc -s', so that typing `r cc' runs the last command beginning with `cc' and typing `r' re-executes the last command. +The history builtin also operates on the history list. + Exit Status: Returns success or status of executed command; non-zero if an error occurs. $END @@ -94,9 +96,11 @@ extern int errno; #define HN_LISTING 0x01 #define HN_FIRST 0x02 -extern int unlink PARAMS((const char *)); +#ifndef HAVE_UNISTD_H +extern int unlink (const char *); +#endif -extern FILE *sh_mktmpfp PARAMS((char *, int, char **)); +extern FILE *sh_mktmpfp (char *, int, char **); extern int suppress_debug_trap_verbose; @@ -154,22 +158,28 @@ typedef struct repl { } \ } while (0) -static char *fc_dosubs PARAMS((char *, REPL *)); -static char *fc_gethist PARAMS((char *, HIST_ENTRY **, int)); -static int fc_gethnum PARAMS((char *, HIST_ENTRY **, int)); -static int fc_number PARAMS((WORD_LIST *)); -static void fc_replhist PARAMS((char *)); +static char *fc_dosubs (char *, REPL *); +static char *fc_gethist (char *, HIST_ENTRY **, int); +static int fc_gethnum (char *, HIST_ENTRY **, int); +static int fc_number (WORD_LIST *); +static void fc_replhist (char *); #ifdef INCLUDE_UNUSED -static char *fc_readline PARAMS((FILE *)); -static void fc_addhist PARAMS((char *)); +static char *fc_readline (FILE *); +static void fc_addhist (char *); #endif static void -set_verbose_flag () +uw_set_verbose_flag (void *ignore) { echo_input_at_read = verbose_flag; } +static void +uw_unlink (void *fn) +{ + unlink ((const char *)fn); +} + /* String to execute on a file that we want to edit. */ #define FC_EDIT_COMMAND "${FCEDIT:-${EDITOR:-vi}}" #if defined (STRICT_POSIX) @@ -179,8 +189,7 @@ set_verbose_flag () #endif int -fc_builtin (list) - WORD_LIST *list; +fc_builtin (WORD_LIST *list) { register int i; register char *sep; @@ -279,6 +288,15 @@ fc_builtin (list) return (EXECUTION_FAILURE); } + if (posixly_correct && list && list->next) + { + builtin_error (_("too many arguments")); + if (rlist) + FREE_RLIST (); + + return (EXECUTION_FAILURE); + } + if (rlist) { newcom = fc_dosubs (command, rlist); @@ -441,7 +459,7 @@ fc_builtin (list) stream = sh_mktmpfp ("bash-fc", MT_USERANDOM|MT_USETMPDIR, &fn); if (stream == 0) { - builtin_error (_("%s: cannot open temp file: %s"), fn ? fn : "", strerror (errno)); + builtin_error ("%s: %s: %s", fn ? fn : "", _("cannot open temp file"), strerror (errno)); FREE (fn); return (EXECUTION_FAILURE); } @@ -515,8 +533,8 @@ fc_builtin (list) will be echoed as they are read by the parser. */ begin_unwind_frame ("fc builtin"); add_unwind_protect (xfree, fn); - add_unwind_protect (unlink, fn); - add_unwind_protect (set_verbose_flag, (char *)NULL); + add_unwind_protect (uw_unlink, fn); + add_unwind_protect (uw_set_verbose_flag, (char *)NULL); unwind_protect_int (suppress_debug_trap_verbose); echo_input_at_read = 1; suppress_debug_trap_verbose = 1; @@ -529,8 +547,7 @@ fc_builtin (list) /* Return 1 if LIST->word->word is a legal number for fc's use. */ static int -fc_number (list) - WORD_LIST *list; +fc_number (WORD_LIST *list) { char *s; @@ -539,7 +556,7 @@ fc_number (list) s = list->word->word; if (*s == '-') s++; - return (legal_number (s, (intmax_t *)NULL)); + return (valid_number (s, (intmax_t *)NULL)); } /* Return an absolute index into HLIST which corresponds to COMMAND. If @@ -549,14 +566,12 @@ fc_number (list) are executing them. If MODE includes HN_FIRST we are looking for the first history number specification. */ static int -fc_gethnum (command, hlist, mode) - char *command; - HIST_ENTRY **hlist; - int mode; +fc_gethnum (char *command, HIST_ENTRY **hlist, int mode) { - int sign, n, clen, rh; - register int i, j, last_hist, real_last, listing; - register char *s; + int sign, n, rh; + size_t clen; + int i, j, last_hist, real_last, listing; + char *s; listing = mode & HN_LISTING; sign = 1; @@ -654,10 +669,7 @@ fc_gethnum (command, hlist, mode) COMMAND in HLIST, and return a malloc()'ed copy of it. MODE is 1 if we are listing commands, 0 if we are executing them. */ static char * -fc_gethist (command, hlist, mode) - char *command; - HIST_ENTRY **hlist; - int mode; +fc_gethist (char *command, HIST_ENTRY **hlist, int mode) { int i; @@ -677,10 +689,12 @@ fc_gethist (command, hlist, mode) one at a time. This can read unlimited length lines. The caller should free the storage. */ static char * -fc_readline (stream) - FILE *stream; +fc_readline (FILE *stream) { register int c; +#ifdef __MSYS__ + register int d; +#endif int line_len = 0, lindex = 0; char *line = (char *)NULL; @@ -689,6 +703,11 @@ fc_readline (stream) if ((lindex + 2) >= line_len) line = (char *)xrealloc (line, (line_len += 128)); +#ifdef __MSYS__ + if (d == '\r') + lindex--; +#endif + if (c == '\n') { line[lindex++] = '\n'; @@ -697,6 +716,10 @@ fc_readline (stream) } else line[lindex++] = c; + +#ifdef __MSYS__ + d = c; +#endif } if (!lindex) @@ -721,9 +744,7 @@ fc_readline (stream) Return a pointer to a malloc'ed string which contains the substituted command. */ static char * -fc_dosubs (command, subs) - char *command; - REPL *subs; +fc_dosubs (char *command, REPL *subs) { register char *new, *t; register REPL *r; @@ -742,10 +763,9 @@ fc_dosubs (command, subs) become the history entry, and that `fc' should never appear in the history list. This way you can do `r' to your heart's content. */ static void -fc_replhist (command) - char *command; +fc_replhist (char *command) { - int n; + size_t n; if (command == 0 || *command == '\0') return; @@ -764,8 +784,7 @@ fc_replhist (command) #ifdef INCLUDE_UNUSED /* Add LINE to the history, after removing a single trailing newline. */ static void -fc_addhist (line) - char *line; +fc_addhist (char *line) { register int n; diff --git a/builtins/fg_bg.def b/builtins/fg_bg.def index 0fb53223d..84ac36ca2 100644 --- a/builtins/fg_bg.def +++ b/builtins/fg_bg.def @@ -1,7 +1,7 @@ This file is fg_bg.def, from which is created fg_bg.c. It implements the builtins "bg" and "fg" in Bash. -Copyright (C) 1987-2020 Free Software Foundation, Inc. +Copyright (C) 1987-2024 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -52,12 +52,11 @@ $END #include "bashgetopt.h" #if defined (JOB_CONTROL) -static int fg_bg PARAMS((WORD_LIST *, int)); +static int fg_bg (WORD_LIST *, int); /* How to bring a job into the foreground. */ int -fg_builtin (list) - WORD_LIST *list; +fg_builtin (WORD_LIST *list) { int fg_bit; register WORD_LIST *t; @@ -101,8 +100,7 @@ $END #if defined (JOB_CONTROL) /* How to put a job into the background. */ int -bg_builtin (list) - WORD_LIST *list; +bg_builtin (WORD_LIST *list) { int r; @@ -135,9 +133,7 @@ bg_builtin (list) /* How to put a job into the foreground/background. */ static int -fg_bg (list, foreground) - WORD_LIST *list; - int foreground; +fg_bg (WORD_LIST *list, int foreground) { sigset_t set, oset; int job, status, old_async_pid; @@ -148,7 +144,9 @@ fg_bg (list, foreground) if (INVALID_JOB (job)) { - if (job != DUP_JOB) + if (job == BAD_JOBSPEC) + sh_invalidjob (list->word->word); + else if (job != DUP_JOB) sh_badjob (list ? list->word->word : _("current")); goto failure; diff --git a/builtins/gen-helpfiles.c b/builtins/gen-helpfiles.c index d27d306b1..4a5ac15fc 100644 --- a/builtins/gen-helpfiles.c +++ b/builtins/gen-helpfiles.c @@ -1,6 +1,6 @@ /* gen-helpfiles - create files containing builtin help text */ -/* Copyright (C) 2012-2021 Free Software Foundation, Inc. +/* Copyright (C) 2012-2023 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -72,10 +72,6 @@ extern int errno; #endif -#if !defined (__STDC__) && !defined (strcpy) -extern char *strcpy (); -#endif /* !__STDC__ && !strcpy */ - #define whitespace(c) (((c) == ' ') || ((c) == '\t')) /* Flag values that builtins can have. */ @@ -99,15 +95,13 @@ char *helpfile_directory; /* Forward declarations. */ -int write_helpfiles PARAMS((struct builtin *)); +int write_helpfiles (struct builtin *); /* For each file mentioned on the command line, process it and write the information to STRUCTFILE and EXTERNFILE, while creating the production file if necessary. */ int -main (argc, argv) - int argc; - char **argv; +main (int argc, char **argv) { int arg_index = 1; @@ -138,10 +132,7 @@ main (argc, argv) internationalization (gettext) and the single-string vs. multiple-strings issues. */ void -write_documentation (stream, documentation, indentation) - FILE *stream; - char *documentation; - int indentation; +write_documentation (FILE *stream, char *documentation, int indentation) { if (stream == 0) return; @@ -151,8 +142,7 @@ write_documentation (stream, documentation, indentation) } int -write_helpfiles (builtins) - struct builtin *builtins; +write_helpfiles (struct builtin *builtins) { char *helpfile, *bname, *fname; FILE *helpfp; diff --git a/builtins/getopt.c b/builtins/getopt.c index 9529bc37d..6fbb6edb1 100644 --- a/builtins/getopt.c +++ b/builtins/getopt.c @@ -1,6 +1,6 @@ /* getopt.c - getopt for Bash. Used by the getopt builtin. */ -/* Copyright (C) 1993-2009 Free Software Foundation, Inc. +/* Copyright (C) 1993-2009,2022 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -111,10 +111,7 @@ int sh_badopt = 0; #define NEEDARG(x) fprintf (stderr, _("%s: option requires an argument -- %c\n"), argv[0], x) int -sh_getopt (argc, argv, optstring) - int argc; - char *const *argv; - const char *optstring; +sh_getopt (int argc, char *const *argv, const char *optstring) { char c, *temp; @@ -216,10 +213,9 @@ sh_getopt (argc, argv, optstring) } void -sh_getopt_restore_state (argv) - char **argv; +sh_getopt_restore_state (char **argv) { - if (nextchar) + if (nextchar && argv && argv[sh_curopt]) nextchar = argv[sh_curopt] + sh_charindex; } @@ -233,14 +229,13 @@ sh_getopt_alloc_istate () } void -sh_getopt_dispose_istate (gs) - sh_getopt_state_t *gs; +sh_getopt_dispose_istate (sh_getopt_state_t *gs) { free (gs); } sh_getopt_state_t * -sh_getopt_save_istate () +sh_getopt_save_istate (void) { sh_getopt_state_t *ret; @@ -257,8 +252,7 @@ sh_getopt_save_istate () } void -sh_getopt_restore_istate (state) - sh_getopt_state_t *state; +sh_getopt_restore_istate (sh_getopt_state_t *state) { sh_optarg = state->gs_optarg; sh_optind = state->gs_optind; @@ -271,8 +265,7 @@ sh_getopt_restore_istate (state) #if 0 void -sh_getopt_debug_restore_state (argv) - char **argv; +sh_getopt_debug_restore_state (char **argv) { if (nextchar && nextchar != argv[sh_curopt] + sh_charindex) { @@ -288,9 +281,7 @@ sh_getopt_debug_restore_state (argv) the above definition of `sh_getopt'. */ int -main (argc, argv) - int argc; - char **argv; +main (int argc, char **argv) { int c; int digit_sh_optind = 0; diff --git a/builtins/getopt.h b/builtins/getopt.h index fd9785975..a17bc0ba9 100644 --- a/builtins/getopt.h +++ b/builtins/getopt.h @@ -1,6 +1,6 @@ /* getopt.h - declarations for getopt. */ -/* Copyright (C) 1989-2020 Free Software Foundation, Inc. +/* Copyright (C) 1989-2022 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -59,7 +59,7 @@ extern int sh_optopt; /* Set to 1 when an unrecognized option is encountered. */ extern int sh_badopt; -extern int sh_getopt PARAMS((int, char *const *, const char *)); +extern int sh_getopt (int, char *const *, const char *); typedef struct sh_getopt_state { @@ -71,12 +71,12 @@ typedef struct sh_getopt_state int gs_flags; } sh_getopt_state_t; -extern void sh_getopt_restore_state PARAMS((char **)); +extern void sh_getopt_restore_state (char **); -extern sh_getopt_state_t *sh_getopt_alloc_istate PARAMS((void)); -extern void sh_getopt_dispose_istate PARAMS((sh_getopt_state_t *)); +extern sh_getopt_state_t *sh_getopt_alloc_istate (void); +extern void sh_getopt_dispose_istate (sh_getopt_state_t *); -extern sh_getopt_state_t *sh_getopt_save_istate PARAMS((void)); -extern void sh_getopt_restore_istate PARAMS((sh_getopt_state_t *)); +extern sh_getopt_state_t *sh_getopt_save_istate (void); +extern void sh_getopt_restore_istate (sh_getopt_state_t *); #endif /* _SH_GETOPT_H */ diff --git a/builtins/getopts.def b/builtins/getopts.def index 4c39c474c..20c8d0591 100644 --- a/builtins/getopts.def +++ b/builtins/getopts.def @@ -1,7 +1,7 @@ This file is getopts.def, from which is created getopts.c. It implements the builtin "getopts" in Bash. -Copyright (C) 1987-2019 Free Software Foundation, Inc. +Copyright (C) 1987-2024 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -86,23 +86,21 @@ $END #define G_INVALID_OPT -2 #define G_ARG_MISSING -3 -static int getopts_unbind_variable PARAMS((char *)); -static int getopts_bind_variable PARAMS((char *, char *)); -static int dogetopts PARAMS((int, char **)); +static int getopts_unbind_variable (char *); +static int getopts_bind_variable (char *, char *); +static int dogetopts (int, char **); /* getopts_reset is magic code for when OPTIND is reset. N is the value that has just been assigned to OPTIND. */ void -getopts_reset (newind) - int newind; +getopts_reset (int newind) { sh_optind = newind; sh_badopt = 0; } static int -getopts_unbind_variable (name) - char *name; +getopts_unbind_variable (char *name) { #if 0 return (unbind_variable (name)); @@ -112,15 +110,14 @@ getopts_unbind_variable (name) } static int -getopts_bind_variable (name, value) - char *name, *value; +getopts_bind_variable (char *name, char *value) { SHELL_VAR *v; - if (legal_identifier (name)) + if (valid_identifier (name)) { v = bind_variable (name, value, 0); - if (v && (readonly_p (v) || noassign_p (v))) + if (v && ASSIGN_DISALLOWED (v, 0)) return (EX_MISCERROR); return (v ? EXECUTION_SUCCESS : EXECUTION_FAILURE); } @@ -159,9 +156,7 @@ getopts_bind_variable (name, value) */ static int -dogetopts (argc, argv) - int argc; - char **argv; +dogetopts (int argc, char **argv) { int ret, special_error, old_opterr, i, n; char strval[2], numval[16]; @@ -312,29 +307,21 @@ dogetopts (argc, argv) /* The getopts builtin. Build an argv, and call dogetopts with it. */ int -getopts_builtin (list) - WORD_LIST *list; +getopts_builtin (WORD_LIST *list) { char **av; int ac, ret; + if (no_options (list)) + return (EX_USAGE); + list = loptend; /* skip over possible `--' */ + if (list == 0) { builtin_usage (); return EX_USAGE; } - reset_internal_getopt (); - if ((ret = internal_getopt (list, "")) != -1) - { - if (ret == GETOPT_HELP) - builtin_help (); - else - builtin_usage (); - return (EX_USAGE); - } - list = loptend; - av = make_builtin_argv (list, &ac); ret = dogetopts (ac, av); free ((char *)av); diff --git a/builtins/hash.def b/builtins/hash.def index 03ae5474d..fc96d5946 100644 --- a/builtins/hash.def +++ b/builtins/hash.def @@ -1,7 +1,7 @@ This file is hash.def, from which is created hash.c. It implements the builtin "hash" in Bash. -Copyright (C) 1987-2021 Free Software Foundation, Inc. +Copyright (C) 1987-2024 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -68,20 +68,17 @@ $END #include "common.h" #include "bashgetopt.h" -extern int dot_found_in_search; - -static int add_hashed_command PARAMS((char *, int)); -static int print_hash_info PARAMS((BUCKET_CONTENTS *)); -static int print_portable_hash_info PARAMS((BUCKET_CONTENTS *)); -static int print_hashed_commands PARAMS((int)); -static int list_hashed_filename_targets PARAMS((WORD_LIST *, int)); +static int add_hashed_command (char *, int); +static int print_hash_info (BUCKET_CONTENTS *); +static int print_portable_hash_info (BUCKET_CONTENTS *); +static int print_hashed_commands (int); +static int list_hashed_filename_targets (WORD_LIST *, int); /* Print statistics on the current state of hashed commands. If LIST is not empty, then rehash (or hash in the first place) the specified commands. */ int -hash_builtin (list) - WORD_LIST *list; +hash_builtin (WORD_LIST *list) { int expunge_hash_table, list_targets, list_portably, delete, opt; char *w, *pathname; @@ -126,11 +123,19 @@ hash_builtin (list) if (list == 0 && (delete || list_targets)) { sh_needarg (delete ? "-d" : "-t"); - return (EXECUTION_FAILURE); + return (sh_chkwrite (EXECUTION_FAILURE)); + } + + /* It's an error to specify a pathname to hash to, but no name to hash. */ + if (pathname && list == 0) + { + builtin_usage (); + return (EX_USAGE); } /* We want hash -r to be silent, but hash -- to print hashing info, so we test expunge_hash_table. */ + if (list == 0 && expunge_hash_table == 0) { opt = print_hashed_commands (list_portably); @@ -147,11 +152,11 @@ hash_builtin (list) /* If someone runs `hash -r -t xyz' he will be disappointed. */ if (list_targets) return (list_hashed_filename_targets (list, list_portably)); - + #if defined (RESTRICTED_SHELL) if (restricted && pathname) { - if (strchr (pathname, '/')) + if (absolute_program (pathname)) { sh_restricted (pathname); return (EXECUTION_FAILURE); @@ -206,9 +211,7 @@ hash_builtin (list) } static int -add_hashed_command (w, quiet) - char *w; - int quiet; +add_hashed_command (char *w, int quiet) { int rv; char *full_path; @@ -233,16 +236,14 @@ add_hashed_command (w, quiet) /* Print information about current hashed info. */ static int -print_hash_info (item) - BUCKET_CONTENTS *item; +print_hash_info (BUCKET_CONTENTS *item) { printf ("%4d\t%s\n", item->times_found, pathdata(item)->path); return 0; } static int -print_portable_hash_info (item) - BUCKET_CONTENTS *item; +print_portable_hash_info (BUCKET_CONTENTS *item) { char *fp, *fn; @@ -257,8 +258,7 @@ print_portable_hash_info (item) } static int -print_hashed_commands (fmt) - int fmt; +print_hashed_commands (int fmt) { if (hashed_filenames == 0 || HASH_ENTRIES (hashed_filenames) == 0) return (0); @@ -270,9 +270,7 @@ print_hashed_commands (fmt) } static int -list_hashed_filename_targets (list, fmt) - WORD_LIST *list; - int fmt; +list_hashed_filename_targets (WORD_LIST *list, int fmt) { int all_found, multiple; char *target; @@ -301,5 +299,5 @@ list_hashed_filename_targets (list, fmt) free (target); } - return (all_found ? EXECUTION_SUCCESS : EXECUTION_FAILURE); + return (sh_chkwrite (all_found ? EXECUTION_SUCCESS : EXECUTION_FAILURE)); } diff --git a/builtins/help.def b/builtins/help.def index 346d93fe8..e7e9789d8 100644 --- a/builtins/help.def +++ b/builtins/help.def @@ -1,7 +1,7 @@ This file is help.def, from which is created help.c. It implements the builtin "help" in Bash. -Copyright (C) 1987-2021 Free Software Foundation, Inc. +Copyright (C) 1987-2025 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -58,7 +58,7 @@ $END #include #include -#include +#include "../bashansi.h" #include "../bashintl.h" @@ -79,22 +79,22 @@ extern int errno; extern const char * const bash_copyright; extern const char * const bash_license; -static void show_builtin_command_help PARAMS((void)); -static int open_helpfile PARAMS((char *)); -static void show_desc PARAMS((char *, int)); -static void show_manpage PARAMS((char *, int)); -static void show_longdoc PARAMS((int)); +static void show_builtin_command_help (void); +static int open_helpfile (const char *); +static void show_desc (char *, int); +static void show_manpage (char *, int); +static void show_longdoc (int); /* Print out a list of the known functions in the shell, and what they do. If LIST is supplied, print out the list which matches for each pattern specified. */ int -help_builtin (list) - WORD_LIST *list; +help_builtin (WORD_LIST *list) { register int i; char *pattern, *name; - int plen, match_found, sflag, dflag, mflag, m, pass, this_found; + int match_found, sflag, dflag, mflag, m, pass, this_found; + size_t plen; dflag = sflag = mflag = 0; reset_internal_getopt (); @@ -190,37 +190,28 @@ help_builtin (list) } void -builtin_help () +builtin_help (void) { int ind; - ptrdiff_t d; current_builtin = builtin_address_internal (this_command_name, 0); if (current_builtin == 0) return; - d = current_builtin - shell_builtins; - -#if defined (__STDC__) - ind = (int)d; -#else - ind = (int)d / sizeof (struct builtin); -#endif - + ind = current_builtin - shell_builtins; printf ("%s: %s\n", this_command_name, _(shell_builtins[ind].short_doc)); show_longdoc (ind); } static int -open_helpfile (name) - char *name; +open_helpfile (const char *name) { int fd; fd = open (name, O_RDONLY); if (fd == -1) { - builtin_error (_("%s: cannot open: %s"), name, strerror (errno)); + builtin_error ("%s: %s: %s", name, _("cannot open"), strerror (errno)); return -1; } return fd; @@ -230,8 +221,7 @@ open_helpfile (name) used, the long_doc array contains one string -- the full pathname of the help file for this builtin. */ static void -show_longdoc (i) - int i; +show_longdoc (int i) { register int j; char * const *doc; @@ -253,15 +243,14 @@ show_longdoc (i) } static void -show_desc (name, i) - char *name; - int i; +show_desc (char *name, int i) { - register int j, r; - char **doc, *line; + int j; + ssize_t r; + char * const *doc, *line; int fd, usefile; - doc = (char **)shell_builtins[i].long_doc; + doc = shell_builtins[i].long_doc; usefile = (doc && doc[0] && *doc[0] == '/' && doc[1] == (char *)NULL); if (usefile) @@ -270,19 +259,22 @@ show_desc (name, i) if (fd < 0) return; r = zmapfd (fd, &line, doc[0]); + if (r < 0) + { + builtin_error ("%s: %s: %s", doc[0], _("read error"), strerror (errno)); + free (line); + line = (char *)NULL; + } close (fd); - /* XXX - handle errors if zmapfd returns < 0 */ } else line = doc ? doc[0] : (char *)NULL; printf ("%s - ", name); - for (j = 0; line && line[j]; j++) - { - putchar (line[j]); - if (line[j] == '\n') - break; - } + /* Don't assume LINE ends with a newline. */ + for (j = 0; line && line[j] && line[j] != '\n'; j++) + putchar (line[j]); + putchar ('\n'); fflush (stdout); @@ -292,15 +284,15 @@ show_desc (name, i) /* Print builtin help in pseudo-manpage format. */ static void -show_manpage (name, i) - char *name; - int i; +show_manpage (char *name, int i) { register int j; - char **doc, *line; + ssize_t r; + char * const *doc; + char *line; int fd, usefile; - doc = (char **)shell_builtins[i].long_doc; + doc = shell_builtins[i].long_doc; usefile = (doc && doc[0] && *doc[0] == '/' && doc[1] == (char *)NULL); if (usefile) @@ -308,7 +300,13 @@ show_manpage (name, i) fd = open_helpfile (doc[0]); if (fd < 0) return; - zmapfd (fd, &line, doc[0]); + r = zmapfd (fd, &line, doc[0]); + if (r < 0) + { + builtin_error ("%s: %s: %s", doc[0], _("read error"), strerror (errno)); + free (line); + line = (char *)NULL; + } close (fd); } else @@ -323,6 +321,10 @@ show_manpage (name, i) if (line[j] == '\n') break; } + /* If the line doesn't end with a newline, e.g., if it's a loadable builtin, + add one. */ + if (line[j] != '\n') + putchar ('\n'); printf ("\n"); /* SYNOPSIS */ @@ -366,14 +368,10 @@ show_manpage (name, i) } static void -dispcolumn (i, buf, bufsize, width, height) - int i; - char *buf; - size_t bufsize; - int width, height; +dispcolumn (int i, char *buf, size_t bufsize, int width, int height) { int j; - int dispcols; + size_t dispcols; char *helpdoc; /* first column */ @@ -408,11 +406,7 @@ dispcolumn (i, buf, bufsize, width, height) #if defined (HANDLE_MULTIBYTE) static void -wdispcolumn (i, buf, bufsize, width, height) - int i; - char *buf; - size_t bufsize; - int width, height; +wdispcolumn (int i, char *buf, size_t bufsize, int width, int height) { int j; int dispcols, dispchars; @@ -513,9 +507,9 @@ wdispcolumn (i, buf, bufsize, width, height) #endif /* HANDLE_MULTIBYTE */ static void -show_builtin_command_help () +show_builtin_command_help (void) { - int i, j; + int i; int height, width; char *t, blurb[128]; diff --git a/builtins/history.def b/builtins/history.def index 6918d8a42..4c36416c2 100644 --- a/builtins/history.def +++ b/builtins/history.def @@ -1,7 +1,7 @@ This file is history.def, from which is created history.c. It implements the builtin "history" in Bash. -Copyright (C) 1987-2021 Free Software Foundation, Inc. +Copyright (C) 1987-2025 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -33,6 +33,8 @@ Options: -c clear the history list by deleting all of the entries -d offset delete the history entry at position OFFSET. Negative offsets count back from the end of the history list + -d start-end delete the history entries beginning at position START + through position END. -a append history lines from this session to the history file -n read all history lines not already read from the history file @@ -46,7 +48,11 @@ Options: -s append the ARGs to the history list as a single entry If FILENAME is given, it is used as the history file. Otherwise, -if HISTFILE has a value, that is used, else ~/.bash_history. +if HISTFILE has a value, that is used. If FILENAME is not supplied +and HISTFILE is unset or null, the -a, -n, -r, and -w options have +no effect and return success. + +The fc builtin also operates on the history list. If the HISTTIMEFORMAT variable is set and not null, its value is used as a format string for strftime(3) to print the time stamp associated @@ -86,10 +92,10 @@ $END extern int errno; #endif -static char *histtime PARAMS((HIST_ENTRY *, const char *)); -static int display_history PARAMS((WORD_LIST *)); -static void push_history PARAMS((WORD_LIST *)); -static int expand_and_print_history PARAMS((WORD_LIST *)); +static char *histtime (HIST_ENTRY *, const char *); +static int display_history (WORD_LIST *); +static void push_history (WORD_LIST *); +static int expand_and_print_history (WORD_LIST *); #define AFLAG 0x01 #define RFLAG 0x02 @@ -105,8 +111,7 @@ static int expand_and_print_history PARAMS((WORD_LIST *)); #endif int -history_builtin (list) - WORD_LIST *list; +history_builtin (WORD_LIST *list) { int flags, opt, result, old_history_lines, obase, ind; char *filename, *delete_arg, *range; @@ -186,7 +191,7 @@ history_builtin (list) { intmax_t delete_start, delete_end; *range++ = '\0'; - if (legal_number (delete_arg, &delete_start) == 0 || legal_number (range, &delete_end) == 0) + if (valid_number (delete_arg, &delete_start) == 0 || valid_number (range, &delete_end) == 0) { range[-1] = '-'; sh_erange (delete_arg, _("history position")); @@ -223,9 +228,9 @@ history_builtin (list) } else if (flags & DFLAG) { - if (legal_number (delete_arg, &delete_offset) == 0) + if (valid_number (delete_arg, &delete_offset) == 0) { - sh_erange (delete_arg, _("history position")); + sh_invalidnum (delete_arg); return (EXECUTION_FAILURE); } /* check for negative offsets, count back from end of list */ @@ -268,8 +273,18 @@ history_builtin (list) filename = list ? list->word->word : get_string_value ("HISTFILE"); result = EXECUTION_SUCCESS; + if (filename == 0 || *filename == 0) + { + if (interactive_shell == 0 || interactive) + if (list && filename == list->word->word) + builtin_error (_("empty filename")); + else + builtin_error (_("%s: parameter null or not set"), "HISTFILE"); + return (interactive ? EXECUTION_SUCCESS : EXECUTION_FAILURE); + } + #if defined (RESTRICTED_SHELL) - if (restricted && strchr (filename, '/')) + if (restricted && absolute_program (filename)) { sh_restricted (filename); return (EXECUTION_FAILURE); @@ -285,6 +300,11 @@ history_builtin (list) result = read_history (filename); history_lines_in_file = history_lines_read_from_file; /* history_lines_in_file = where_history () + history_base - 1; */ +#if 0 + /* Report read errors from the history library. */ + if (result > 0) + builtin_error ("%s: %s: %s", filename, _("read error"), strerror (errno)); +#endif } else if (flags & NFLAG) /* Read `new' history from file. */ { @@ -299,6 +319,12 @@ history_builtin (list) history_lines_in_file = history_lines_read_from_file; /* history_lines_in_file = where_history () + history_base - 1; */ +#if 0 + /* Report read errors from the history library. */ + if (result > 0) + builtin_error ("%s: %s: %s", filename, _("read error"), strerror (errno)); +#endif + /* If we're rewriting the history file at shell exit rather than just appending the lines from this session to it, the question is whether we reset history_lines_this_session to 0, losing any history entries @@ -322,9 +348,7 @@ history_builtin (list) #define histdata(i) (hlist[(i)]->data) static char * -histtime (hlist, histtimefmt) - HIST_ENTRY *hlist; - const char *histtimefmt; +histtime (HIST_ENTRY *hlist, const char *histtimefmt) { static char timestr[TIMELEN_MAX]; time_t t; @@ -343,8 +367,7 @@ histtime (hlist, histtimefmt) } static int -display_history (list) - WORD_LIST *list; +display_history (WORD_LIST *list) { register int i; intmax_t limit; @@ -354,7 +377,7 @@ display_history (list) if (list) { if (get_numeric_arg (list, 0, &limit) == 0) - return (EXECUTION_FAILURE); + return (EX_USAGE); if (limit < 0) limit = -limit; @@ -395,8 +418,7 @@ display_history (list) /* Remove the last entry in the history list and add each argument in LIST to the history. */ static void -push_history (list) - WORD_LIST *list; +push_history (WORD_LIST *list) { char *s; @@ -432,8 +454,7 @@ push_history (list) #if defined (BANG_HISTORY) static int -expand_and_print_history (list) - WORD_LIST *list; +expand_and_print_history (WORD_LIST *list) { char *s; int r, result; diff --git a/builtins/jobs.def b/builtins/jobs.def index 1ce098d08..643f43f14 100644 --- a/builtins/jobs.def +++ b/builtins/jobs.def @@ -1,7 +1,7 @@ This file is jobs.def, from which is created jobs.c. It implements the builtins "jobs" and "disown" in Bash. -Copyright (C) 1987-2020 Free Software Foundation, Inc. +Copyright (C) 1987-2023 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -61,6 +61,7 @@ $END #include "../shell.h" #include "../jobs.h" #include "../execute_cmd.h" +#include "../parser.h" #include "bashgetopt.h" #include "common.h" @@ -68,7 +69,7 @@ $END #define JSTATE_RUNNING 0x1 #define JSTATE_STOPPED 0x2 -static int execute_list_with_replacements PARAMS((WORD_LIST *)); +static int execute_list_with_replacements (WORD_LIST *); /* The `jobs' command. Prints outs a list of active jobs. If the argument `-l' is given, then the process id's are printed also. @@ -79,8 +80,7 @@ static int execute_list_with_replacements PARAMS((WORD_LIST *)); group leader and execute the command. The -r and -s options mean to print info about running and stopped jobs only, respectively. */ int -jobs_builtin (list) - WORD_LIST *list; +jobs_builtin (WORD_LIST *list) { int form, execute, state, opt, any_failed, job; sigset_t set, oset; @@ -136,6 +136,9 @@ jobs_builtin (list) { case JSTATE_ANY: list_all_jobs (form); + /* POSIX says to remove terminated jobs from the list after the jobs + builtin reports their status. */ + notify_and_cleanup (-1); /* the notify part will be a no-op */ break; case JSTATE_RUNNING: list_running_jobs (form); @@ -152,7 +155,7 @@ jobs_builtin (list) BLOCK_CHILD (set, oset); job = get_job_spec (list); - if ((job == NO_JOB) || jobs == 0 || get_job_by_jid (job) == 0) + if ((job == NO_JOB) || jobs == 0 || INVALID_JOB (job) || get_job_by_jid (job) == 0) { sh_badjob (list->word->word); any_failed++; @@ -163,12 +166,16 @@ jobs_builtin (list) UNBLOCK_CHILD (oset); list = list->next; } + /* POSIX says to remove terminated jobs from the list after the jobs + builtin reports their status. */ + if (posixly_correct == 0 || interactive_shell == 0 || interactive == 0) + notify_and_cleanup (-1); /* XXX - why here? list_one_job already deletes dead jobs */ + return (any_failed ? EXECUTION_FAILURE : EXECUTION_SUCCESS); } static int -execute_list_with_replacements (list) - WORD_LIST *list; +execute_list_with_replacements (WORD_LIST *list) { register WORD_LIST *l; int job, result; @@ -195,13 +202,13 @@ execute_list_with_replacements (list) /* Next make a new simple command and execute it. */ begin_unwind_frame ("jobs_builtin"); - command = make_bare_simple_command (); + command = make_bare_simple_command (line_number); command->value.Simple->words = copy_word_list (list); command->value.Simple->redirects = (REDIRECT *)NULL; command->flags |= CMD_INHIBIT_EXPANSION; command->value.Simple->flags |= CMD_INHIBIT_EXPANSION; - add_unwind_protect (dispose_command, command); + add_unwind_protect (uw_dispose_command, command); result = execute_command (command); dispose_command (command); @@ -231,8 +238,7 @@ $END #if defined (JOB_CONTROL) int -disown_builtin (list) - WORD_LIST *list; +disown_builtin (WORD_LIST *list) { int opt, job, retval, nohup_only, running_jobs, all_jobs; sigset_t set, oset; @@ -275,13 +281,16 @@ disown_builtin (list) do { BLOCK_CHILD (set, oset); - job = (list && legal_number (list->word->word, &pid_value) && pid_value == (pid_t) pid_value) + job = (list && valid_number (list->word->word, &pid_value) && pid_value == (pid_t) pid_value) ? get_job_by_pid ((pid_t) pid_value, 0, 0) : get_job_spec (list); if (job == NO_JOB || jobs == 0 || INVALID_JOB (job)) { - sh_badjob (list ? list->word->word : _("current")); + if (job == BAD_JOBSPEC) + sh_invalidjob (list->word->word); + else + sh_badjob (list ? list->word->word : _("current")); retval = EXECUTION_FAILURE; } else if (nohup_only) diff --git a/builtins/kill.def b/builtins/kill.def index c655092e7..66ed752ef 100644 --- a/builtins/kill.def +++ b/builtins/kill.def @@ -1,7 +1,7 @@ This file is kill.def, from which is created kill.c. It implements the builtin "kill" in Bash. -Copyright (C) 1987-2020 Free Software Foundation, Inc. +Copyright (C) 1987-2025 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -70,7 +70,7 @@ $END extern int errno; #endif /* !errno */ -static void kill_error PARAMS((pid_t, int)); +static void kill_error (pid_t, int); #if !defined (CONTINUE_AFTER_KILL_ERROR) # define CONTINUE_OR_FAIL return (EXECUTION_FAILURE) @@ -82,10 +82,9 @@ static void kill_error PARAMS((pid_t, int)); kill -KILL %1? No, if you fill up the process table this way you can still kill some. */ int -kill_builtin (list) - WORD_LIST *list; +kill_builtin (WORD_LIST *list) { - int sig, any_succeeded, listing, saw_signal, dflags; + int sig, any_succeeded, any_failed, listing, saw_signal, dflags; char *sigspec, *word; pid_t pid; intmax_t pid_value; @@ -97,7 +96,7 @@ kill_builtin (list) } CHECK_HELPOPT (list); - any_succeeded = listing = saw_signal = 0; + any_succeeded = any_failed = listing = saw_signal = 0; sig = SIGTERM; sigspec = "TERM"; @@ -190,7 +189,7 @@ use_sigspec: word++; /* Use the entire argument in case of minus sign presence. */ - if (*word && legal_number (list->word->word, &pid_value) && (pid_value == (pid_t)pid_value)) + if (*word && valid_number (list->word->word, &pid_value) && (pid_value == (pid_t)pid_value)) { pid = (pid_t) pid_value; @@ -200,6 +199,7 @@ use_sigspec: sh_invalidsig (sigspec); else kill_error (pid, errno); + any_failed++; CONTINUE_OR_FAIL; } else @@ -208,7 +208,11 @@ use_sigspec: #if defined (JOB_CONTROL) else if (*list->word->word && *list->word->word != '%') { +#if 1 + sh_badpid (list->word->word); +#else builtin_error (_("%s: arguments must be process or job IDs"), list->word->word); +#endif CONTINUE_OR_FAIL; } else if (*word) @@ -244,6 +248,7 @@ use_sigspec: sh_invalidsig (sigspec); else kill_error (pid, errno); + any_failed++; CONTINUE_OR_FAIL; } else @@ -259,13 +264,14 @@ use_sigspec: list = list->next; } - return (any_succeeded ? EXECUTION_SUCCESS : EXECUTION_FAILURE); + if (posixly_correct) + return ((any_failed == 0) ? EXECUTION_SUCCESS : EXECUTION_FAILURE); + else + return (any_succeeded ? EXECUTION_SUCCESS : EXECUTION_FAILURE); } static void -kill_error (pid, e) - pid_t pid; - int e; +kill_error (pid_t pid, int e) { char *x; diff --git a/builtins/let.def b/builtins/let.def index d090a45bc..df4e3c4f2 100644 --- a/builtins/let.def +++ b/builtins/let.def @@ -80,8 +80,7 @@ $END /* Arithmetic LET function. */ int -let_builtin (list) - WORD_LIST *list; +let_builtin (WORD_LIST *list) { intmax_t ret; int expok; @@ -110,8 +109,7 @@ let_builtin (list) #ifdef INCLUDE_UNUSED int -exp_builtin (list) - WORD_LIST *list; +exp_builtin (WORD_LIST *list) { char *exp; intmax_t ret; diff --git a/builtins/mapfile.def b/builtins/mapfile.def index 4ddd72338..31528fa8f 100644 --- a/builtins/mapfile.def +++ b/builtins/mapfile.def @@ -2,7 +2,7 @@ This file is mapfile.def, from which is created mapfile.c. It implements the builtin "mapfile" in Bash. Copyright (C) 2005-2006 Rocky Bernstein for Free Software Foundation, Inc. -Copyright (C) 2008-2021 Free Software Foundation, Inc. +Copyright (C) 2008-2024 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -92,7 +92,7 @@ extern int errno; #if defined (ARRAY_VARS) -static int run_callback PARAMS((const char *, unsigned int, const char *)); +static int run_callback (const char *, unsigned int, const char *); #define DEFAULT_ARRAY_NAME "MAPFILE" #define DEFAULT_VARIABLE_NAME "MAPLINE" /* not used right now */ @@ -104,13 +104,8 @@ static int run_callback PARAMS((const char *, unsigned int, const char *)); #define MAPF_CLEARARRAY 0x01 #define MAPF_CHOP 0x02 -static int delim; - static int -run_callback (callback, curindex, curline) - const char *callback; - unsigned int curindex; - const char *curline; +run_callback (const char *callback, unsigned int curindex, const char *curline) { unsigned int execlen; char *execstr, *qline; @@ -134,9 +129,7 @@ run_callback (callback, curindex, curline) } static void -do_chop(line, delim) - char *line; - unsigned char delim; +do_chop(char *line, unsigned char delim) { int length; @@ -146,12 +139,8 @@ do_chop(line, delim) } static int -mapfile (fd, line_count_goal, origin, nskip, callback_quantum, callback, array_name, delim, flags) - int fd; - long line_count_goal, origin, nskip, callback_quantum; - char *callback, *array_name; - int delim; - int flags; +mapfile (int fd, long line_count_goal, long origin, long nskip, long callback_quantum, + char *callback, char *array_name, int delim, int flags) { char *line; size_t line_length; @@ -231,10 +220,9 @@ mapfile (fd, line_count_goal, origin, nskip, callback_quantum, callback, array_n } int -mapfile_builtin (list) - WORD_LIST *list; +mapfile_builtin (WORD_LIST *list) { - int opt, code, fd, flags; + int opt, code, fd, flags, delim; intmax_t intval; long lines, origin, nskip, callback_quantum; char *array_name, *callback; @@ -255,7 +243,7 @@ mapfile_builtin (list) delim = *list_optarg; break; case 'u': - code = legal_number (list_optarg, &intval); + code = valid_number (list_optarg, &intval); if (code == 0 || intval < 0 || intval != (int)intval) { builtin_error (_("%s: invalid file descriptor specification"), list_optarg); @@ -266,13 +254,13 @@ mapfile_builtin (list) if (sh_validfd (fd) == 0) { - builtin_error (_("%d: invalid file descriptor: %s"), fd, strerror (errno)); + builtin_error ("%d: %s: %s", fd, _("invalid file descriptor"), strerror (errno)); return (EXECUTION_FAILURE); } break; case 'n': - code = legal_number (list_optarg, &intval); + code = valid_number (list_optarg, &intval); if (code == 0 || intval < 0 || intval != (unsigned)intval) { builtin_error (_("%s: invalid line count"), list_optarg); @@ -283,7 +271,7 @@ mapfile_builtin (list) break; case 'O': - code = legal_number (list_optarg, &intval); + code = valid_number (list_optarg, &intval); if (code == 0 || intval < 0 || intval != (unsigned)intval) { builtin_error (_("%s: invalid array origin"), list_optarg); @@ -300,7 +288,7 @@ mapfile_builtin (list) callback = list_optarg; break; case 'c': - code = legal_number (list_optarg, &intval); + code = valid_number (list_optarg, &intval); if (code == 0 || intval <= 0 || intval != (unsigned)intval) { builtin_error (_("%s: invalid callback quantum"), list_optarg); @@ -310,7 +298,7 @@ mapfile_builtin (list) callback_quantum = intval; break; case 's': - code = legal_number (list_optarg, &intval); + code = valid_number (list_optarg, &intval); if (code == 0 || intval < 0 || intval != (unsigned)intval) { builtin_error (_("%s: invalid line count"), list_optarg); @@ -342,7 +330,7 @@ mapfile_builtin (list) else array_name = list->word->word; - if (legal_identifier (array_name) == 0) + if (valid_identifier (array_name) == 0) { sh_invalidid (array_name); return (EXECUTION_FAILURE); @@ -354,8 +342,7 @@ mapfile_builtin (list) #else int -mapfile_builtin (list) - WORD_LIST *list; +mapfile_builtin (WORD_LIST *list) { builtin_error (_("array variable support required")); return (EXECUTION_FAILURE); diff --git a/builtins/mkbuiltins.c b/builtins/mkbuiltins.c index f505ebde1..c4cacdfc2 100644 --- a/builtins/mkbuiltins.c +++ b/builtins/mkbuiltins.c @@ -1,7 +1,7 @@ /* mkbuiltins.c - Create builtins.c, builtext.h, and builtdoc.c from a single source file called builtins.def. */ -/* Copyright (C) 1987-2022 Free Software Foundation, Inc. +/* Copyright (C) 1987-2025 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -23,11 +23,7 @@ # include #else /* CROSS_COMPILING */ /* A conservative set of defines based on POSIX/SUS3/XPG6 */ -# define HAVE_UNISTD_H -# define HAVE_STRING_H -# define HAVE_STDLIB_H - -# define HAVE_RENAME +# include #endif /* CROSS_COMPILING */ #if defined (HAVE_UNISTD_H) @@ -59,11 +55,8 @@ extern int errno; #endif -static char *xmalloc (), *xrealloc (); - -#if !defined (__STDC__) && !defined (strcpy) -extern char *strcpy (); -#endif /* !__STDC__ && !strcpy */ +static void *xmalloc (size_t); +static void *xrealloc (void *, size_t); #define savestring(x) strcpy (xmalloc (1 + strlen (x)), (x)) #define whitespace(c) (((c) == ' ') || ((c) == '\t')) @@ -175,13 +168,14 @@ char *localvar_builtins[] = /* The builtin commands that are special to the POSIX search order. */ char *posix_builtins[] = { - "alias", "bg", "cd", "command", "false", "fc", "fg", "getopts", "jobs", - "kill", "newgrp", "pwd", "read", "true", "umask", "unalias", "wait", + "alias", "bg", "cd", "command", "false", "fc", "fg", "getopts", "hash", + "jobs", "kill", "newgrp", "pwd", "read", "true", "type", "ulimit", + "umask", "unalias", "wait", (char *)NULL }; /* The builtin commands that can take array references as arguments and pay - attention to `assoc_expand_once'. These are the ones that don't assign + attention to `array_expand_once'. These are the ones that don't assign values, but need to avoid double expansions. */ char *arrayvar_builtins[] = { @@ -191,47 +185,47 @@ char *arrayvar_builtins[] = }; /* Forward declarations. */ -static int is_special_builtin (); -static int is_assignment_builtin (); -static int is_localvar_builtin (); -static int is_posix_builtin (); -static int is_arrayvar_builtin (); +static int is_special_builtin (char *); +static int is_assignment_builtin (char *); +static int is_localvar_builtin (char *); +static int is_posix_builtin (char *); +static int is_arrayvar_builtin (char *); #if !defined (HAVE_RENAME) -static int rename (); +static int rename (char *, char *); #endif -void extract_info (); +void extract_info (char *, FILE *, FILE *); + +void file_error (char *); +void line_error (DEF_FILE *, char *, char *, char *); -void file_error (); -void line_error (); +void write_file_headers (FILE *, FILE *); +void write_file_footers (FILE *, FILE *); +void write_ifdefs (FILE *, char **); +void write_endifs (FILE *, char **); +void write_documentation (FILE *, char **, int, int); +void write_dummy_declarations (FILE *, ARRAY *); +void write_longdocs (FILE *, ARRAY *); +void write_builtins (DEF_FILE *, FILE *, FILE *); -void write_file_headers (); -void write_file_footers (); -void write_ifdefs (); -void write_endifs (); -void write_documentation (); -void write_longdocs (); -void write_builtins (); +int write_helpfiles (ARRAY *); -int write_helpfiles (); +static int _find_in_table (char *, char **); -void free_defs (); -void add_documentation (); +void free_defs (DEF_FILE *); +void add_documentation (DEF_FILE *, char *); -void must_be_building (); -void remove_trailing_whitespace (); +void must_be_building (char *, DEF_FILE *); +void remove_trailing_whitespace (char *); #define document_name(b) ((b)->docname ? (b)->docname : (b)->name) - /* For each file mentioned on the command line, process it and write the information to STRUCTFILE and EXTERNFILE, while creating the production file if necessary. */ int -main (argc, argv) - int argc; - char **argv; +main (int argc, char **argv) { int arg_index = 1; FILE *structfile, *externfile; @@ -384,8 +378,7 @@ main (argc, argv) /* Make a new array, and return a pointer to it. The array will contain elements of size WIDTH, and is initialized to no elements. */ ARRAY * -array_create (width) - int width; +array_create (int width) { ARRAY *array; @@ -404,8 +397,7 @@ array_create (width) /* Copy the array of strings in ARRAY. */ ARRAY * -copy_string_array (array) - ARRAY *array; +copy_string_array (ARRAY *array) { register int i; ARRAY *copy; @@ -431,9 +423,7 @@ copy_string_array (array) /* Add ELEMENT to ARRAY, growing the array if necessary. */ void -array_add (element, array) - char *element; - ARRAY *array; +array_add (char *element, ARRAY *array) { if (array->sindex + 2 > array->size) array->array = (char **)xrealloc @@ -445,8 +435,7 @@ array_add (element, array) /* Free an allocated array and data pointer. */ void -array_free (array) - ARRAY *array; +array_free (ARRAY *array) { if (array->array) free (array->array); @@ -461,8 +450,7 @@ array_free (array) /* **************************************************************** */ /* The definition of a function. */ -typedef int Function (); -typedef int mk_handler_func_t PARAMS((char *, DEF_FILE *, char *)); +typedef int mk_handler_func_t (char *, DEF_FILE *, char *); /* Structure handles processor directives. */ typedef struct { @@ -470,14 +458,14 @@ typedef struct { mk_handler_func_t *function; } HANDLER_ENTRY; -extern int builtin_handler PARAMS((char *, DEF_FILE *, char *)); -extern int function_handler PARAMS((char *, DEF_FILE *, char *)); -extern int short_doc_handler PARAMS((char *, DEF_FILE *, char *)); -extern int comment_handler PARAMS((char *, DEF_FILE *, char *)); -extern int depends_on_handler PARAMS((char *, DEF_FILE *, char *)); -extern int produces_handler PARAMS((char *, DEF_FILE *, char *)); -extern int end_handler PARAMS((char *, DEF_FILE *, char *)); -extern int docname_handler PARAMS((char *, DEF_FILE *, char *)); +extern int builtin_handler (char *, DEF_FILE *, char *); +extern int function_handler (char *, DEF_FILE *, char *); +extern int short_doc_handler (char *, DEF_FILE *, char *); +extern int comment_handler (char *, DEF_FILE *, char *); +extern int depends_on_handler (char *, DEF_FILE *, char *); +extern int produces_handler (char *, DEF_FILE *, char *); +extern int end_handler (char *, DEF_FILE *, char *); +extern int docname_handler (char *, DEF_FILE *, char *); HANDLER_ENTRY handlers[] = { { "BUILTIN", builtin_handler }, @@ -494,8 +482,7 @@ HANDLER_ENTRY handlers[] = { /* Return the entry in the table of handlers for NAME. */ HANDLER_ENTRY * -find_directive (directive) - char *directive; +find_directive (char *directive) { register int i; @@ -524,9 +511,7 @@ int output_cpp_line_info = 0; builtins found in each $BUILTIN. Plain text found before the $PRODUCES is ignored, as is "$$ comment text". */ void -extract_info (filename, structfile, externfile) - char *filename; - FILE *structfile, *externfile; +extract_info (char *filename, FILE *structfile, FILE *externfile) { register int i; DEF_FILE *defs; @@ -609,7 +594,7 @@ extract_info (filename, structfile, externfile) if (!handler) { - line_error (defs, "Unknown directive `%s'", directive); + line_error (defs, "Unknown directive `%s'", directive, ""); free (directive); continue; } @@ -666,8 +651,7 @@ extract_info (filename, structfile, externfile) #define free_safely(x) if (x) free (x) static void -free_builtin (builtin) - BUILTIN_DESC *builtin; +free_builtin (BUILTIN_DESC *builtin) { register int i; @@ -689,8 +673,7 @@ free_builtin (builtin) /* Free all of the memory allocated to a DEF_FILE. */ void -free_defs (defs) - DEF_FILE *defs; +free_defs (DEF_FILE *defs) { register int i; register BUILTIN_DESC *builtin; @@ -722,8 +705,7 @@ free_defs (defs) /* Strip surrounding whitespace from STRING, and return a pointer to the start of it. */ char * -strip_whitespace (string) - char *string; +strip_whitespace (char *string) { while (whitespace (*string)) string++; @@ -734,8 +716,7 @@ strip_whitespace (string) /* Remove only the trailing whitespace from STRING. */ void -remove_trailing_whitespace (string) - char *string; +remove_trailing_whitespace (char *string) { register int i; @@ -752,35 +733,29 @@ remove_trailing_whitespace (string) DEFS is the DEF_FILE in which the directive is found. If there is no argument, produce an error. */ char * -get_arg (for_whom, defs, string) - char *for_whom, *string; - DEF_FILE *defs; +get_arg (char *for_whom, DEF_FILE *defs, char *string) { char *new; new = strip_whitespace (string); if (!*new) - line_error (defs, "%s requires an argument", for_whom); + line_error (defs, "%s requires an argument", for_whom, ""); return (savestring (new)); } /* Error if not building a builtin. */ void -must_be_building (directive, defs) - char *directive; - DEF_FILE *defs; +must_be_building (char *directive, DEF_FILE *defs) { if (!building_builtin) - line_error (defs, "%s must be inside of a $BUILTIN block", directive); + line_error (defs, "%s must be inside of a $BUILTIN block", directive, ""); } /* Return the current builtin. */ BUILTIN_DESC * -current_builtin (directive, defs) - char *directive; - DEF_FILE *defs; +current_builtin (char *directive, DEF_FILE *defs) { must_be_building (directive, defs); if (defs->builtins) @@ -792,9 +767,7 @@ current_builtin (directive, defs) /* Add LINE to the long documentation for the current builtin. Ignore blank lines until the first non-blank line has been seen. */ void -add_documentation (defs, line) - DEF_FILE *defs; - char *line; +add_documentation (DEF_FILE *defs, char *line) { register BUILTIN_DESC *builtin; @@ -813,10 +786,7 @@ add_documentation (defs, line) /* How to handle the $BUILTIN directive. */ int -builtin_handler (self, defs, arg) - char *self; - DEF_FILE *defs; - char *arg; +builtin_handler (char *self, DEF_FILE *defs, char *arg) { BUILTIN_DESC *new; char *name; @@ -824,7 +794,7 @@ builtin_handler (self, defs, arg) /* If we are already building a builtin, we cannot start a new one. */ if (building_builtin) { - line_error (defs, "%s found before $END", self); + line_error (defs, "%s found before $END", self, ""); return (-1); } @@ -865,10 +835,7 @@ builtin_handler (self, defs, arg) /* How to handle the $FUNCTION directive. */ int -function_handler (self, defs, arg) - char *self; - DEF_FILE *defs; - char *arg; +function_handler (char *self, DEF_FILE *defs, char *arg) { register BUILTIN_DESC *builtin; @@ -876,7 +843,7 @@ function_handler (self, defs, arg) if (builtin == 0) { - line_error (defs, "syntax error: no current builtin for $FUNCTION directive"); + line_error (defs, "syntax error: no current builtin for $FUNCTION directive", "", ""); exit (1); } if (builtin->function) @@ -890,10 +857,7 @@ function_handler (self, defs, arg) /* How to handle the $DOCNAME directive. */ int -docname_handler (self, defs, arg) - char *self; - DEF_FILE *defs; - char *arg; +docname_handler (char *self, DEF_FILE *defs, char *arg) { register BUILTIN_DESC *builtin; @@ -910,10 +874,7 @@ docname_handler (self, defs, arg) /* How to handle the $SHORT_DOC directive. */ int -short_doc_handler (self, defs, arg) - char *self; - DEF_FILE *defs; - char *arg; +short_doc_handler (char *self, DEF_FILE *defs, char *arg) { register BUILTIN_DESC *builtin; @@ -930,20 +891,14 @@ short_doc_handler (self, defs, arg) /* How to handle the $COMMENT directive. */ int -comment_handler (self, defs, arg) - char *self; - DEF_FILE *defs; - char *arg; +comment_handler (char *self, DEF_FILE *defs, char *arg) { return (0); } /* How to handle the $DEPENDS_ON directive. */ int -depends_on_handler (self, defs, arg) - char *self; - DEF_FILE *defs; - char *arg; +depends_on_handler (char *self, DEF_FILE *defs, char *arg) { register BUILTIN_DESC *builtin; char *dependent; @@ -961,10 +916,7 @@ depends_on_handler (self, defs, arg) /* How to handle the $PRODUCES directive. */ int -produces_handler (self, defs, arg) - char *self; - DEF_FILE *defs; - char *arg; +produces_handler (char *self, DEF_FILE *defs, char *arg) { /* If just hacking documentation, don't change any of the production files. */ @@ -995,10 +947,7 @@ produces_handler (self, defs, arg) /* How to handle the $END directive. */ int -end_handler (self, defs, arg) - char *self; - DEF_FILE *defs; - char *arg; +end_handler (char *self, DEF_FILE *defs, char *arg) { must_be_building (self, defs); building_builtin = 0; @@ -1013,9 +962,7 @@ end_handler (self, defs, arg) /* Produce an error for DEFS with FORMAT and ARGS. */ void -line_error (defs, format, arg1, arg2) - DEF_FILE *defs; - char *format, *arg1, *arg2; +line_error (DEF_FILE *defs, char *format, char *arg1, char *arg2) { if (defs->filename[0] != '/') fprintf (stderr, "%s", error_directory ? error_directory : "./"); @@ -1027,8 +974,7 @@ line_error (defs, format, arg1, arg2) /* Print error message for FILENAME. */ void -file_error (filename) - char *filename; +file_error (char *filename) { perror (filename); exit (2); @@ -1040,30 +986,27 @@ file_error (filename) /* */ /* **************************************************************** */ -static void memory_error_and_abort (); +static void memory_error_and_abort (void); -static char * -xmalloc (bytes) - int bytes; +static void * +xmalloc (size_t bytes) { - char *temp = (char *)malloc (bytes); + void *temp = malloc (bytes); if (!temp) memory_error_and_abort (); return (temp); } -static char * -xrealloc (pointer, bytes) - char *pointer; - int bytes; +static void * +xrealloc (void *pointer, size_t bytes) { - char *temp; + void *temp; if (!pointer) - temp = (char *)malloc (bytes); + temp = malloc (bytes); else - temp = (char *)realloc (pointer, bytes); + temp = realloc (pointer, bytes); if (!temp) memory_error_and_abort (); @@ -1072,7 +1015,7 @@ xrealloc (pointer, bytes) } static void -memory_error_and_abort () +memory_error_and_abort (void) { fprintf (stderr, "mkbuiltins: out of virtual memory\n"); abort (); @@ -1087,8 +1030,7 @@ memory_error_and_abort () /* Return a pointer to a newly allocated builtin which is an exact copy of BUILTIN. */ BUILTIN_DESC * -copy_builtin (builtin) - BUILTIN_DESC *builtin; +copy_builtin (BUILTIN_DESC *builtin) { BUILTIN_DESC *new; @@ -1109,8 +1051,7 @@ copy_builtin (builtin) /* How to save away a builtin. */ void -save_builtin (builtin) - BUILTIN_DESC *builtin; +save_builtin (BUILTIN_DESC *builtin) { BUILTIN_DESC *newbuiltin; @@ -1187,8 +1128,7 @@ char *structfile_footer[] = { /* Write out any necessary opening information for STRUCTFILE and EXTERNFILE. */ void -write_file_headers (structfile, externfile) - FILE *structfile, *externfile; +write_file_headers (FILE *structfile, FILE *externfile) { register int i; @@ -1214,8 +1154,7 @@ write_file_headers (structfile, externfile) /* Write out any necessary closing information for STRUCTFILE and EXTERNFILE. */ void -write_file_footers (structfile, externfile) - FILE *structfile, *externfile; +write_file_footers (FILE *structfile, FILE *externfile) { register int i; @@ -1230,9 +1169,7 @@ write_file_footers (structfile, externfile) /* Write out the information accumulated in DEFS to STRUCTFILE and EXTERNFILE. */ void -write_builtins (defs, structfile, externfile) - DEF_FILE *defs; - FILE *structfile, *externfile; +write_builtins (DEF_FILE *defs, FILE *structfile, FILE *externfile) { register int i; @@ -1258,7 +1195,7 @@ write_builtins (defs, structfile, externfile) if (externfile) { if (builtin->function) - fprintf (externfile, "extern int %s PARAMS((WORD_LIST *));\n", + fprintf (externfile, "extern int %s (WORD_LIST *);\n", builtin->function); fprintf (externfile, "extern char * const %s_doc[];\n", @@ -1336,9 +1273,7 @@ write_builtins (defs, structfile, externfile) /* Write out the long documentation strings in BUILTINS to STREAM. */ void -write_longdocs (stream, builtins) - FILE *stream; - ARRAY *builtins; +write_longdocs (FILE *stream, ARRAY *builtins) { register int i; register BUILTIN_DESC *builtin; @@ -1375,9 +1310,7 @@ write_longdocs (stream, builtins) } void -write_dummy_declarations (stream, builtins) - FILE *stream; - ARRAY *builtins; +write_dummy_declarations (FILE *stream, ARRAY *builtins) { register int i; BUILTIN_DESC *builtin; @@ -1401,9 +1334,7 @@ write_dummy_declarations (stream, builtins) If a define is preceded by an `!', then the sense of the test is reversed. */ void -write_ifdefs (stream, defines) - FILE *stream; - char **defines; +write_ifdefs (FILE *stream, char **defines) { register int i; @@ -1432,9 +1363,7 @@ write_ifdefs (stream, defines) STREAM is the stream to write the information to. DEFINES is a null terminated array of define names. */ void -write_endifs (stream, defines) - FILE *stream; - char **defines; +write_endifs (FILE *stream, char **defines) { register int i; @@ -1459,10 +1388,7 @@ write_endifs (stream, defines) internationalization (gettext) and the single-string vs. multiple-strings issues. */ void -write_documentation (stream, documentation, indentation, flags) - FILE *stream; - char **documentation; - int indentation, flags; +write_documentation (FILE *stream, char **documentation, int indentation, int flags) { register int i, j; register char *line; @@ -1590,8 +1516,7 @@ write_documentation (stream, documentation, indentation, flags) } int -write_helpfiles (builtins) - ARRAY *builtins; +write_helpfiles (ARRAY *builtins) { char *helpfile, *bname; FILE *helpfp; @@ -1632,8 +1557,7 @@ write_helpfiles (builtins) } static int -_find_in_table (name, name_table) - char *name, *name_table[]; +_find_in_table (char *name, char **name_table) { register int i; @@ -1644,44 +1568,38 @@ _find_in_table (name, name_table) } static int -is_special_builtin (name) - char *name; +is_special_builtin (char *name) { return (_find_in_table (name, special_builtins)); } static int -is_assignment_builtin (name) - char *name; +is_assignment_builtin (char *name) { return (_find_in_table (name, assignment_builtins)); } static int -is_localvar_builtin (name) - char *name; +is_localvar_builtin (char *name) { return (_find_in_table (name, localvar_builtins)); } static int -is_posix_builtin (name) - char *name; +is_posix_builtin (char *name) { return (_find_in_table (name, posix_builtins)); } static int -is_arrayvar_builtin (name) - char *name; +is_arrayvar_builtin (char *name) { return (_find_in_table (name, arrayvar_builtins)); } #if !defined (HAVE_RENAME) static int -rename (from, to) - char *from, *to; +rename (char *from, char *to) { unlink (to); if (link (from, to) < 0) diff --git a/builtins/printf.def b/builtins/printf.def index d10cbabcd..7d7f8c266 100644 --- a/builtins/printf.def +++ b/builtins/printf.def @@ -1,7 +1,7 @@ This file is printf.def, from which is created printf.c. It implements the builtin "printf" in Bash. -Copyright (C) 1997-2021 Free Software Foundation, Inc. +Copyright (C) 1997-2025 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -35,8 +35,8 @@ sequences, which are converted and copied to the standard output; and format specifications, each of which causes printing of the next successive argument. -In addition to the standard format specifications described in printf(1), -printf interprets: +In addition to the standard format characters csndiouxXeEfFgGaA described +in printf(3), printf interprets: %b expand backslash escape sequences in the corresponding argument %q quote the argument in a way that can be reused as shell input @@ -68,12 +68,9 @@ $END # define INT_MIN (-2147483647-1) #endif -#if defined (PREFER_STDARG) -# include -#else -# include -#endif +#include +#include #include #include @@ -93,28 +90,60 @@ $END #include "bashgetopt.h" #include "common.h" -#if defined (PRI_MACROS_BROKEN) -# undef PRIdMAX -#endif - -#if !defined (PRIdMAX) -# if HAVE_LONG_LONG -# define PRIdMAX "lld" -# else -# define PRIdMAX "ld" -# endif -#endif - #if !defined (errno) extern int errno; #endif +/* We free the buffer used by mklong() if it's `too big'. */ +#define PRETURN(value) \ + do \ + { \ + QUIT; \ + retval = value; \ + if (conv_bufsize > 4096 ) \ + { \ + free (conv_buf); \ + conv_bufsize = 0; \ + conv_buf = 0; \ + } \ + if (vflag) \ + { \ + SHELL_VAR *v; \ + v = builtin_bind_variable (vname, vbuf, bindflags); \ + stupidly_hack_special_variables (vname); \ + if (v == 0 || ASSIGN_DISALLOWED (v, 0)) \ + retval = EXECUTION_FAILURE; \ + if (vbsize > 4096) \ + { \ + free (vbuf); \ + vbsize = 0; \ + vbuf = 0; \ + } \ + else if (vbuf) \ + vbuf[0] = 0; \ + } \ + else \ + { \ + if (ferror (stdout) == 0) \ + fflush (stdout); \ + QUIT; \ + if (ferror (stdout)) \ + { \ + sh_wrerror (); \ + clearerr (stdout); \ + retval = EXECUTION_FAILURE; \ + } \ + } \ + return (retval); \ + } \ + while (0) + #define PC(c) \ do { \ char b[2]; \ tw++; \ b[0] = c; b[1] = '\0'; \ - if (vflag) \ + if (vflag) \ vbadd (b, 1); \ else \ putchar (c); \ @@ -124,7 +153,9 @@ extern int errno; #define PF(f, func) \ do { \ int nw; \ - clearerr (stdout); \ + if (vflag == 0) \ + clearerr (stdout); \ + errno = 0; \ if (have_fieldwidth && have_precision) \ nw = vflag ? vbprintf (f, fieldwidth, precision, func) : printf (f, fieldwidth, precision, func); \ else if (have_fieldwidth) \ @@ -133,56 +164,16 @@ extern int errno; nw = vflag ? vbprintf (f, precision, func) : printf (f, precision, func); \ else \ nw = vflag ? vbprintf (f, func) : printf (f, func); \ - tw += nw; \ - QUIT; \ - if (ferror (stdout)) \ + if (nw < 0 || (vflag == 0 && ferror (stdout))) \ { \ - sh_wrerror (); \ - clearerr (stdout); \ - return (EXECUTION_FAILURE); \ + QUIT; \ + builtin_error ("%s", strerror (errno)); \ + PRETURN (EXECUTION_FAILURE); \ } \ + tw += nw; \ + QUIT; \ } while (0) -/* We free the buffer used by mklong() if it's `too big'. */ -#define PRETURN(value) \ - do \ - { \ - QUIT; \ - if (vflag) \ - { \ - SHELL_VAR *v; \ - v = builtin_bind_variable (vname, vbuf, bindflags); \ - stupidly_hack_special_variables (vname); \ - if (v == 0 || readonly_p (v) || noassign_p (v)) \ - return (EXECUTION_FAILURE); \ - } \ - if (conv_bufsize > 4096 ) \ - { \ - free (conv_buf); \ - conv_bufsize = 0; \ - conv_buf = 0; \ - } \ - if (vbsize > 4096) \ - { \ - free (vbuf); \ - vbsize = 0; \ - vbuf = 0; \ - } \ - else if (vbuf) \ - vbuf[0] = 0; \ - if (ferror (stdout) == 0) \ - fflush (stdout); \ - QUIT; \ - if (ferror (stdout)) \ - { \ - sh_wrerror (); \ - clearerr (stdout); \ - return (EXECUTION_FAILURE); \ - } \ - return (value); \ - } \ - while (0) - #define SKIP1 "#'-+ 0" #define LENMODS "hjlLtz" @@ -193,41 +184,52 @@ extern int errno; extern time_t shell_start_time; #if !HAVE_ASPRINTF -extern int asprintf PARAMS((char **, const char *, ...)) __attribute__((__format__ (printf, 2, 3))); +extern int asprintf (char **, const char *, ...) __attribute__((__format__ (printf, 2, 3))); #endif #if !HAVE_VSNPRINTF -extern int vsnprintf PARAMS((char *, size_t, const char *, va_list)) __attribute__((__format__ (printf, 3, 0))); +extern int vsnprintf (char *, size_t, const char *, va_list) __attribute__((__format__ (printf, 3, 0))); #endif -static void printf_erange PARAMS((char *)); -static int printstr PARAMS((char *, char *, int, int, int)); -static int tescape PARAMS((char *, char *, int *, int *)); -static char *bexpand PARAMS((char *, int, int *, int *)); -static char *vbadd PARAMS((char *, int)); -static int vbprintf PARAMS((const char *, ...)) __attribute__((__format__ (printf, 1, 2))); -static char *mklong PARAMS((char *, char *, size_t)); -static int getchr PARAMS((void)); -static char *getstr PARAMS((void)); -static int getint PARAMS((void)); -static intmax_t getintmax PARAMS((void)); -static uintmax_t getuintmax PARAMS((void)); +static inline void printf_erange (char *); +static inline void report_erange (char *, char *); +static int printstr (char *, char *, size_t, int, int); +static int tescape (char *, char *, int *, int *); +static char *bexpand (char *, size_t, int *, size_t *); +static char *vbadd (char *, int); +static int vbprintf (const char *, ...) __attribute__((__format__ (printf, 1, 2))); +static char *mklong (char *, char *, size_t); +static int getchr (void); +static char *getstr (void); +static int getint (int); +static intmax_t getintmax (void); +static uintmax_t getuintmax (void); #if defined (HAVE_LONG_DOUBLE) && HAVE_DECL_STRTOLD && !defined(STRTOLD_BROKEN) typedef long double floatmax_t; # define USE_LONG_DOUBLE 1 # define FLOATMAX_CONV "L" +# define FLOATMAX_CONVLEN 1 # define strtofltmax strtold #else typedef double floatmax_t; # define USE_LONG_DOUBLE 0 # define FLOATMAX_CONV "" +# define FLOATMAX_CONVLEN 0 # define strtofltmax strtod #endif -static double getdouble PARAMS((void)); -static floatmax_t getfloatmax PARAMS((void)); +static double getdouble (void); +static floatmax_t getfloatmax (void); -static intmax_t asciicode PARAMS((void)); +static intmax_t asciicode (void); + +#if defined (HANDLE_MULTIBYTE) +static wchar_t *getwidestr (size_t *); +static wint_t getwidechar (void); +static char *convwidestr (wchar_t *, int); +static char *convwidechar (wint_t, int); +static int printwidestr (char *, wchar_t *, size_t, int, int); +#endif static WORD_LIST *garglist, *orig_arglist; static int retval; @@ -238,23 +240,51 @@ static int vflag = 0; static int bindflags = 0; static char *vbuf, *vname; static size_t vbsize; -static int vblen; +static size_t vblen; + +/* printf format numbered argument support */ +static char **narg_argv; +static int narg_argc; +static int narg_maxind; +static int narg_curind; static intmax_t tw; static char *conv_buf; static size_t conv_bufsize; +static inline int +decodeint (char **str, int diagnose, int overflow_return) +{ + int pr, v; + char *ps; + + ps = *str; + pr = *ps++ - '0'; + v = 0; + + /* use C23 macros to check overflow */ + for (; DIGIT (*ps); ps++) + { + v |= ckd_mul (&pr, pr, 10); + v |= ckd_add (&pr, pr, *ps - '0'); + } + if (v && diagnose) + report_erange (*str, ps); + + *str = ps; + return (v ? overflow_return : pr); +} + int -printf_builtin (list) - WORD_LIST *list; +printf_builtin (WORD_LIST *list) { int ch, fieldwidth, precision; - int have_fieldwidth, have_precision, use_Lmod, altform; + int have_fieldwidth, have_precision, use_Lmod, altform, longform; char convch, thisch, nextch, *format, *modstart, *precstart, *fmt, *start; #if defined (HANDLE_MULTIBYTE) char mbch[25]; /* 25 > MB_LEN_MAX, plus can handle 4-byte UTF-8 and large Unicode characters*/ - int mbind, mblen; + int mbind, mblen, mb_cur_max; #endif #if defined (ARRAY_VARS) int arrayflags; @@ -273,9 +303,9 @@ printf_builtin (list) bindflags = 0; #if defined (ARRAY_VARS) SET_VFLAGS (list_optflags, arrayflags, bindflags); - retval = legal_identifier (vname) || valid_array_reference (vname, arrayflags); + retval = valid_identifier (vname) || valid_array_reference (vname, arrayflags); #else - retval = legal_identifier (vname); + retval = valid_identifier (vname); #endif if (retval) { @@ -312,9 +342,10 @@ printf_builtin (list) SHELL_VAR *v; v = builtin_bind_variable (vname, "", 0); stupidly_hack_special_variables (vname); - return ((v == 0 || readonly_p (v) || noassign_p (v)) ? EXECUTION_FAILURE : EXECUTION_SUCCESS); + return ((v == 0 || ASSIGN_DISALLOWED (v, 0)) ? EXECUTION_FAILURE : EXECUTION_SUCCESS); } + /* If the format string is empty after preprocessing, return immediately. */ if (list->word->word == 0 || list->word->word[0] == '\0') return (EXECUTION_SUCCESS); @@ -324,9 +355,7 @@ printf_builtin (list) garglist = orig_arglist = list->next; - /* If the format string is empty after preprocessing, return immediately. */ - if (format == 0 || *format == 0) - return (EXECUTION_SUCCESS); + mb_cur_max = MB_CUR_MAX; /* Basic algorithm is to scan the format string for conversion specifications -- once one is found, find out if the field @@ -341,7 +370,7 @@ printf_builtin (list) for (fmt = format; *fmt; fmt++) { precision = fieldwidth = 0; - have_fieldwidth = have_precision = altform = 0; + have_fieldwidth = have_precision = altform = longform = 0; precstart = 0; if (*fmt == '\\') @@ -366,7 +395,16 @@ printf_builtin (list) if (*fmt != '%') { +#if defined (HANDLE_MULTIBYTE) + size_t l; + int i; + l = mbcharlen (fmt, mb_cur_max); + for (i = 0; i < l; i++, fmt++) + PC (*fmt); + fmt--; /* for loop will increment it for us again */ +#else PC (*fmt); +#endif continue; } @@ -390,7 +428,9 @@ printf_builtin (list) { fmt++; have_fieldwidth = 1; - fieldwidth = getint (); + /* Handle field with overflow by ignoring fieldwidth for now. + getint() prints a message. */ + fieldwidth = getint (0); } else while (DIGIT (*fmt)) @@ -404,7 +444,10 @@ printf_builtin (list) { fmt++; have_precision = 1; - precision = getint (); + /* Handle precision overflow by ignoring precision for now. + getint() prints a message. + "A negative precision is treated as if it were missing." */ + precision = getint (-1); } else { @@ -431,6 +474,7 @@ printf_builtin (list) while (*fmt && strchr (LENMODS, *fmt)) { use_Lmod |= USE_LONG_DOUBLE && *fmt == 'L'; + longform |= *fmt == 'l'; fmt++; } @@ -450,27 +494,98 @@ printf_builtin (list) switch(convch) { case 'c': + case 'C': { char p; +#if defined (HANDLE_MULTIBYTE) + if ((longform || convch == 'C') && locale_mb_cur_max > 1) + { + wchar_t wc, ws[2]; + int r; + + wc = getwidechar (); + ws[0] = wc; + ws[1] = L'\0'; + + /* If %lc is supplied a null argument, posix interp 1647 + says it should produce a single null byte. */ + if (wc == L'\0') + r = printstr (start, "", 1, fieldwidth, precision); + else + r = printwidestr (start, ws, 1, fieldwidth, precision); + if (r < 0) + PRETURN (EXECUTION_FAILURE); + break; + } +#endif p = getchr (); PF(start, p); break; } case 's': + case 'S': { char *p; +#if defined (HANDLE_MULTIBYTE) + if ((longform || convch == 'S') && locale_mb_cur_max > 1) + { + wchar_t *wp; + size_t slen; + int r; + + wp = getwidestr (&slen); + r = printwidestr (start, wp, slen, fieldwidth, precision); + FREE (wp); + if (r < 0) + PRETURN (EXECUTION_FAILURE); + break; + } +#endif +#if 0 /*TAG:bash-5.4*/ + /* If altform, treat like %b */ + if (altform == 0) +#endif + { + p = getstr (); + PF(start, p); + break; + } + } + /*FALLTHROUGH*/ + + case 'b': /* expand escapes in argument */ + { + char *p, *xp; + size_t rlen; + int r; p = getstr (); - PF(start, p); + ch = r = 0; + rlen = 0; + xp = bexpand (p, strlen (p), &ch, &rlen); + + if (xp) + { + /* Have to use printstr because of possible NUL bytes + in XP -- printf does not handle that well. */ + r = printstr (start, xp, rlen, fieldwidth, precision); + if (r < 0) + retval = EXECUTION_FAILURE; + free (xp); + } + + if (ch || r < 0) + PRETURN (retval); break; } case '(': { char *timefmt, timebuf[TIMELEN_MAX], *t; - int n; + size_t n; + int r; intmax_t arg; time_t secs; struct tm *tm; @@ -488,8 +603,8 @@ printf_builtin (list) break; *t++ = *fmt++; } - *t = '\0'; - if (*++fmt != 'T') + *t = '\0'; /*(*/ + if (*fmt != ')' || *++fmt != 'T') { builtin_warning (_("`%c': invalid time format specification"), *fmt); fmt = start; @@ -530,16 +645,9 @@ printf_builtin (list) /* convert to %s format that preserves fieldwidth and precision */ modstart[0] = 's'; modstart[1] = '\0'; - n = printstr (start, timebuf, strlen (timebuf), fieldwidth, precision); /* XXX - %s for now */ - if (n < 0) - { - if (ferror (stdout) == 0) - { - sh_wrerror (); - clearerr (stdout); - } - PRETURN (EXECUTION_FAILURE); - } + r = printstr (start, timebuf, strlen (timebuf), fieldwidth, precision); /* XXX - %s for now */ + if (r < 0) + PRETURN (EXECUTION_FAILURE); break; } @@ -550,7 +658,7 @@ printf_builtin (list) var = getstr (); if (var && *var) { - if (legal_identifier (var)) + if (valid_identifier (var)) bind_var_to_int (var, tw, 0); else { @@ -561,80 +669,52 @@ printf_builtin (list) break; } - case 'b': /* expand escapes in argument */ - { - char *p, *xp; - int rlen, r; - - p = getstr (); - ch = rlen = r = 0; - xp = bexpand (p, strlen (p), &ch, &rlen); - - if (xp) - { - /* Have to use printstr because of possible NUL bytes - in XP -- printf does not handle that well. */ - r = printstr (start, xp, rlen, fieldwidth, precision); - if (r < 0) - { - if (ferror (stdout) == 0) - { - sh_wrerror (); - clearerr (stdout); - } - retval = EXECUTION_FAILURE; - } - free (xp); - } - - if (ch || r < 0) - PRETURN (retval); - break; - } - case 'q': /* print with shell quoting */ case 'Q': { char *p, *xp; - int r, mpr; + int r; size_t slen; r = 0; p = getstr (); /* Decode precision and apply it to the unquoted string. */ - if (convch == 'Q' && precstart) + if (convch == 'Q' && (have_precision || precstart)) { - mpr = *precstart++ - '0'; - while (DIGIT (*precstart)) - mpr = (mpr * 10) + (*precstart++ - '0'); - /* Error if precision > INT_MAX here? */ - precision = (mpr < 0 || mpr > INT_MAX) ? INT_MAX : mpr; + if (precstart) + { + char *prec; + prec = precstart; + precision = decodeint (&prec, 0, -1); + } slen = strlen (p); /* printf precision works in bytes. */ - if (precision < slen) + if (precision >= 0 && precision < slen) p[precision] = '\0'; } if (p && *p == 0) /* XXX - getstr never returns null */ xp = savestring ("''"); else if (ansic_shouldquote (p)) xp = ansic_quote (p, 0, (int *)0); + else if (altform) + xp = sh_single_quote (p); else xp = sh_backslash_quote (p, 0, 3); if (xp) { + slen = strlen (xp); if (convch == 'Q') { - slen = strlen (xp); - if (slen > precision) - precision = slen; + /* check for string length overflow when adjusting precision */ + if (ckd_add (&precision, slen, 0)) + { + builtin_error ("%%Q: %s %s", _("string length"), strerror (ERANGE)); + precision = -1; + } } /* Use printstr to get fieldwidth and precision right. */ - r = printstr (start, xp, strlen (xp), fieldwidth, precision); - if (r < 0) - { - sh_wrerror (); - clearerr (stdout); - } + r = printstr (start, xp, slen, fieldwidth, precision); + /* Let PRETURN print the error message. */ free (xp); } @@ -650,8 +730,8 @@ printf_builtin (list) long p; intmax_t pp; - p = pp = getintmax (); - if (p != pp) + pp = getintmax (); + if (pp < LONG_MIN || pp > LONG_MAX) { f = mklong (start, PRIdMAX, sizeof (PRIdMAX) - 2); PF (f, pp); @@ -662,6 +742,7 @@ printf_builtin (list) in "long". This also works around some long long and/or intmax_t library bugs in the common case, e.g. glibc 2.2 x86. */ + p = pp; f = mklong (start, "l", 1); PF (f, p); } @@ -709,7 +790,7 @@ printf_builtin (list) floatmax_t p; p = getfloatmax (); - f = mklong (start, FLOATMAX_CONV, USE_LONG_DOUBLE); + f = mklong (start, FLOATMAX_CONV, FLOATMAX_CONVLEN); PF (f, p); } else /* posixly_correct */ @@ -735,7 +816,7 @@ printf_builtin (list) modstart[1] = nextch; } - if (ferror (stdout)) + if (vflag == 0 && ferror (stdout)) { /* PRETURN will print error message. */ PRETURN (EXECUTION_FAILURE); @@ -749,28 +830,41 @@ printf_builtin (list) PRETURN (retval); } -static void -printf_erange (s) - char *s; +static inline void +printf_erange (char *s) +{ + builtin_error ("%s: %s", s, strerror(ERANGE)); + conversion_error = 1; +} + +static inline void +report_erange (char *s, char *e) { - builtin_error (_("warning: %s: %s"), s, strerror(ERANGE)); + unsigned char sc; + + sc = *e; + *e = 0; + printf_erange (s); + *e = sc; } /* We duplicate a lot of what printf(3) does here. */ +/* FMT: format + STRING: expanded string argument + LEN: length of expanded string + FIELDWIDTH: argument for width of `*' + PRECISION: argument for precision of `*' + + Returns -1 on detectable write error, 0 otherwise. */ + static int -printstr (fmt, string, len, fieldwidth, precision) - char *fmt; /* format */ - char *string; /* expanded string argument */ - int len; /* length of expanded string */ - int fieldwidth; /* argument for width of `*' */ - int precision; /* argument for precision of `*' */ +printstr (char *fmt, char *string, size_t len, int fieldwidth, int precision) { #if 0 char *s; #endif int padlen, nc, ljust, i; int fw, pr; /* fieldwidth and precision */ - intmax_t mfw, mpr; if (string == 0) string = ""; @@ -783,8 +877,6 @@ printstr (fmt, string, len, fieldwidth, precision) ljust = fw = 0; pr = -1; - mfw = 0; - mpr = -1; /* skip flags */ while (strchr (SKIP1, *fmt)) @@ -806,13 +898,7 @@ printstr (fmt, string, len, fieldwidth, precision) } } else if (DIGIT (*fmt)) - { - mfw = *fmt++ - '0'; - while (DIGIT (*fmt)) - mfw = (mfw * 10) + (*fmt++ - '0'); - /* Error if fieldwidth > INT_MAX here? */ - fw = (mfw < 0 || mfw > INT_MAX) ? INT_MAX : mfw; - } + fw = decodeint (&fmt, 1, 0); /* get precision, if present. doesn't handle negative precisions */ if (*fmt == '.') @@ -825,13 +911,11 @@ printstr (fmt, string, len, fieldwidth, precision) } else if (DIGIT (*fmt)) { - mpr = *fmt++ - '0'; - while (DIGIT (*fmt)) - mpr = (mpr * 10) + (*fmt++ - '0'); - /* Error if precision > INT_MAX here? */ - pr = (mpr < 0 || mpr > INT_MAX) ? INT_MAX : mpr; - if (pr < precision && precision < INT_MAX) - pr = precision; /* XXX */ + pr = decodeint (&fmt, 1, -1); + /* pr < precision means we adjusted precision in printf_builtin + for the quoted string length (%Q), so we use the adjusted value */ + if (pr < precision) + pr = precision; } else pr = 0; /* "a null digit string is treated as zero" */ @@ -867,8 +951,103 @@ printstr (fmt, string, len, fieldwidth, precision) for (; padlen < 0; padlen++) PC (' '); - return (ferror (stdout) ? -1 : 0); + return ((vflag == 0 && ferror (stdout)) ? -1 : 0); +} + +#if defined (HANDLE_MULTIBYTE) +/* A wide-character version of printstr */ +static int +printwidestr (char *fmt, wchar_t *wstring, size_t len, int fieldwidth, int precision) +{ + char *s; + char *string; + int padlen, nc, ljust, i; + int fw, pr; /* fieldwidth and precision */ + + if (wstring == 0) + wstring = L""; + +#if 0 + s = fmt; +#endif + if (*fmt == '%') + fmt++; + + ljust = fw = 0; + pr = -1; + + /* skip flags */ + while (strchr (SKIP1, *fmt)) + { + if (*fmt == '-') + ljust = 1; + fmt++; + } + + /* get fieldwidth, if present. rely on caller to clamp fieldwidth at INT_MAX */ + if (*fmt == '*') + { + fmt++; + fw = fieldwidth; + if (fw < 0) + { + fw = -fw; + ljust = 1; + } + } + else if (DIGIT (*fmt)) + fw = decodeint (&fmt, 1, 0); + + /* get precision, if present. doesn't handle negative precisions */ + if (*fmt == '.') + { + fmt++; + if (*fmt == '*') + { + fmt++; + pr = precision; + } + else if (DIGIT (*fmt)) + { + pr = decodeint (&fmt, 1, -1); + /* pr < precision means we adjusted precision in printf_builtin + for the quoted string length (%Q), so we use the adjusted value */ + if (pr < precision) + pr = precision; + } + else + pr = 0; /* "a null digit string is treated as zero" */ + } + + /* chars from wide string to print */ + nc = (pr >= 0 && pr <= len) ? pr : len; + + padlen = fw - nc; + if (padlen < 0) + padlen = 0; + if (ljust) + padlen = -padlen; + + /* leading pad characters */ + for (; padlen > 0; padlen--) + PC (' '); + + /* convert WSTRING to multibyte character STRING, honoring PRECISION */ + string = convwidestr (wstring, pr); + + /* output STRING, assuming that convwidestr has taken care of the precision + and returned only the necessary bytes. */ + for (i = 0; string[i]; i++) + PC (string[i]); + + /* output any necessary trailing padding */ + for (; padlen < 0; padlen++) + PC (' '); + + free (string); + return ((vflag == 0 && ferror (stdout)) ? -1 : 0); } +#endif /* Convert STRING by expanding the escape sequences specified by the POSIX standard for printf's `%b' format string. If SAWC is non-null, @@ -884,10 +1063,7 @@ printstr (fmt, string, len, fieldwidth, precision) do the \c short-circuiting, and \c is treated as an unrecognized escape sequence; we also bypass the other processing specific to %b arguments. */ static int -tescape (estart, cp, lenp, sawc) - char *estart; - char *cp; - int *lenp, *sawc; +tescape (char *estart, char *cp, int *lenp, int *sawc) { register char *p; int temp, c, evalue; @@ -899,11 +1075,7 @@ tescape (estart, cp, lenp, sawc) switch (c = *p++) { -#if defined (__STDC__) case 'a': *cp = '\a'; break; -#else - case 'a': *cp = '\007'; break; -#endif case 'b': *cp = '\b'; break; @@ -1001,16 +1173,15 @@ tescape (estart, cp, lenp, sawc) } static char * -bexpand (string, len, sawc, lenp) - char *string; - int len, *sawc, *lenp; +bexpand (char *string, size_t len, int *sawc, size_t *lenp) { - int temp; - char *ret, *r, *s, c; + int temp, c; + char *ret, *r, *s, *send; #if defined (HANDLE_MULTIBYTE) char mbch[25]; int mbind, mblen; #endif + DECLARE_MBSTATE; if (string == 0 || len == 0) { @@ -1023,15 +1194,32 @@ bexpand (string, len, sawc, lenp) return (ret); } +#if defined (HANDLE_MULTIBYTE) + /* same logic as lib/sh/strtrans.c:ansicstr() */ + temp = 4*len + 4; + if (temp < 12) + temp = 12; /* ensure enough for eventual u32cesc */ + ret = (char *)xmalloc (temp); +#else ret = (char *)xmalloc (len + 1); +#endif + + send = string + len; for (r = ret, s = string; s && *s; ) { - c = *s++; - if (c != '\\' || *s == '\0') + if (s[1] == '\0') { - *r++ = c; + *r++ = *s; + break; + } + else if (*s != '\\') + { + COPY_CHAR_P (r, s, send); continue; } + else + s++; /* *s == '\\' */ + temp = 0; #if defined (HANDLE_MULTIBYTE) memset (mbch, '\0', sizeof (mbch)); @@ -1061,9 +1249,7 @@ bexpand (string, len, sawc, lenp) } static char * -vbadd (buf, blen) - char *buf; - int blen; +vbadd (char *buf, int blen) { size_t nlen; @@ -1085,37 +1271,35 @@ vbadd (buf, blen) #ifdef DEBUG if (strlen (vbuf) != vblen) - internal_error ("printf:vbadd: vblen (%d) != strlen (vbuf) (%d)", vblen, (int)strlen (vbuf)); + internal_error ("printf:vbadd: vblen (%zu) != strlen (vbuf) (%zu)", vblen, strlen (vbuf)); #endif return vbuf; } static int -#if defined (PREFER_STDARG) vbprintf (const char *format, ...) -#else -vbprintf (format, va_alist) - const char *format; - va_dcl -#endif { va_list args; size_t nlen; int blen; - SH_VA_START (args, format); + va_start (args, format); blen = vsnprintf (vbuf + vblen, vbsize - vblen, format, args); va_end (args); + if (blen < 0) + return (blen); nlen = vblen + blen + 1; if (nlen >= vbsize) { vbsize = ((nlen + 63) >> 6) << 6; vbuf = (char *)xrealloc (vbuf, vbsize); - SH_VA_START (args, format); + va_start (args, format); blen = vsnprintf (vbuf + vblen, vbsize - vblen, format, args); va_end (args); + if (blen < 0) + return (blen); } vblen += blen; @@ -1123,17 +1307,14 @@ vbprintf (format, va_alist) #ifdef DEBUG if (strlen (vbuf) != vblen) - internal_error ("printf:vbprintf: vblen (%d) != strlen (vbuf) (%d)", vblen, (int)strlen (vbuf)); + internal_error ("printf:vbprintf: vblen (%zu) != strlen (vbuf) (%zu)", vblen, strlen (vbuf)); #endif return (blen); } static char * -mklong (str, modifiers, mlen) - char *str; - char *modifiers; - size_t mlen; +mklong (char *str, char *modifiers, size_t mlen) { size_t len, slen; @@ -1154,202 +1335,335 @@ mklong (str, modifiers, mlen) return (conv_buf); } +static inline char * +getarg (void) +{ + return (garglist ? garglist->word->word : 0); +} + +static inline void +advancearg (void) +{ + garglist = garglist->next; +} + static int -getchr () +getchr (void) { int ret; + char *arg; - if (garglist == 0) + arg = getarg (); + + if (arg == 0) return ('\0'); - ret = (int)garglist->word->word[0]; - garglist = garglist->next; + ret = (int)arg[0]; + + advancearg (); return ret; } static char * -getstr () +getstr (void) { char *ret; - if (garglist == 0) + ret = getarg (); + if (ret == 0) return (""); - ret = garglist->word->word; - garglist = garglist->next; + advancearg (); return ret; } +/* POSIX.2 says ``...a diagnostic message shall be written to standard + error, and the utility shall not exit with a zero exit status, but + shall continue processing any remaining operands and shall write the + value accumulated at the time the error was detected to standard + output.'' */ + +static inline void +chk_converror (char *s, char *ep) +{ + if (*ep || ep == s) + { + sh_invalidnum (s); + conversion_error = 1; + } + else if (errno == ERANGE) + printf_erange (s); +} + +/* Don't call getintmax here because it may consume an argument on error, and + we call this to get field width/precision arguments. */ static int -getint () +getint (int overflow_retval) { intmax_t ret; + char *ep, *arg; + int overflow; - ret = getintmax (); + arg = getarg (); - if (garglist == 0) - return ret; + if (arg == 0) + return (0); - if (ret > INT_MAX) - { - printf_erange (garglist->word->word); - ret = INT_MAX; - } - else if (ret < INT_MIN) - { - printf_erange (garglist->word->word); - ret = INT_MIN; - } + if (arg[0] == '\'' || arg[0] == '"') + return asciicode (); + + errno = 0; + ret = strtoimax (arg, &ep, 0); + if (overflow = (errno == ERANGE) || (ret < INT_MIN || ret > INT_MAX)) + errno = ERANGE; /* force errno */ - return ((int)ret); + chk_converror (arg, ep); + + advancearg (); + return (overflow ? overflow_retval : (int)ret); } static intmax_t -getintmax () +getintmax (void) { intmax_t ret; - char *ep; + char *ep, *arg; + + arg = getarg (); - if (garglist == 0) + if (arg == 0) return (0); - if (garglist->word->word[0] == '\'' || garglist->word->word[0] == '"') + if (arg[0] == '\'' || arg[0] == '"') return asciicode (); errno = 0; - ret = strtoimax (garglist->word->word, &ep, 0); + ret = strtoimax (arg, &ep, 0); - if (*ep) - { - sh_invalidnum (garglist->word->word); - /* POSIX.2 says ``...a diagnostic message shall be written to standard - error, and the utility shall not exit with a zero exit status, but - shall continue processing any remaining operands and shall write the - value accumulated at the time the error was detected to standard - output.'' Yecch. */ -#if 0 - ret = 0; /* return partially-converted value from strtoimax */ -#endif - conversion_error = 1; - } - else if (errno == ERANGE) - printf_erange (garglist->word->word); + chk_converror (arg, ep); - garglist = garglist->next; + advancearg (); return (ret); } static uintmax_t -getuintmax () +getuintmax (void) { uintmax_t ret; - char *ep; + char *ep, *arg; - if (garglist == 0) + arg = getarg (); + + if (arg == 0) return (0); - if (garglist->word->word[0] == '\'' || garglist->word->word[0] == '"') + if (arg[0] == '\'' || arg[0] == '"') return asciicode (); errno = 0; - ret = strtoumax (garglist->word->word, &ep, 0); - - if (*ep) - { - sh_invalidnum (garglist->word->word); -#if 0 - /* Same POSIX.2 conversion error requirements as getintmax(). */ - ret = 0; -#endif - conversion_error = 1; - } - else if (errno == ERANGE) - printf_erange (garglist->word->word); + ret = strtoumax (arg, &ep, 0); - garglist = garglist->next; + chk_converror (arg, ep); + + advancearg (); return (ret); } static double -getdouble () +getdouble (void) { double ret; - char *ep; + char *ep, *arg; + + arg = getarg (); - if (garglist == 0) + if (arg == 0) return (0); - if (garglist->word->word[0] == '\'' || garglist->word->word[0] == '"') + if (arg[0] == '\'' || arg[0] == '"') return asciicode (); errno = 0; - ret = strtod (garglist->word->word, &ep); + ret = strtod (arg, &ep); - if (*ep) - { - sh_invalidnum (garglist->word->word); - conversion_error = 1; - } - else if (errno == ERANGE) - printf_erange (garglist->word->word); + chk_converror (arg, ep); - garglist = garglist->next; + advancearg (); return (ret); } static floatmax_t -getfloatmax () +getfloatmax (void) { floatmax_t ret; - char *ep; + char *ep, *arg; + + arg = getarg (); - if (garglist == 0) + if (arg == 0) return (0); - if (garglist->word->word[0] == '\'' || garglist->word->word[0] == '"') + if (arg[0] == '\'' || arg[0] == '"') return asciicode (); errno = 0; - ret = strtofltmax (garglist->word->word, &ep); + ret = strtofltmax (arg, &ep); - if (*ep) - { - sh_invalidnum (garglist->word->word); -#if 0 - /* Same thing about POSIX.2 conversion error requirements. */ - ret = 0; -#endif - conversion_error = 1; - } - else if (errno == ERANGE) - printf_erange (garglist->word->word); + chk_converror (arg, ep); - garglist = garglist->next; + advancearg (); return (ret); } /* NO check is needed for garglist here. */ static intmax_t -asciicode () +asciicode (void) { register intmax_t ch; + char *arg; #if defined (HANDLE_MULTIBYTE) wchar_t wc; - size_t slen; - int mblength; + size_t slen, mblength; #endif DECLARE_MBSTATE; + arg = getarg (); #if defined (HANDLE_MULTIBYTE) - slen = strlen (garglist->word->word+1); + slen = strlen (arg+1); wc = 0; - mblength = mbtowc (&wc, garglist->word->word+1, slen); - if (mblength > 0) + mblength = mbrtowc (&wc, arg+1, slen, &state); + if (MB_INVALIDCH (mblength) == 0) ch = wc; /* XXX */ else #endif - ch = (unsigned char)garglist->word->word[1]; + ch = (unsigned char)arg[1]; - garglist = garglist->next; + advancearg (); return (ch); } + +#if defined (HANDLE_MULTIBYTE) +static wchar_t * +getwidestr (size_t *lenp) +{ + wchar_t *ws; + const char *mbs; + size_t slen, mblength; + char *arg; + DECLARE_MBSTATE; + + arg = getarg (); + if (arg == 0) + { + if (lenp) + *lenp = 0; + return NULL; + } + + mbs = arg; + slen = strlen (mbs); + ws = (wchar_t *)xmalloc ((slen + 1) * sizeof (wchar_t)); + mblength = mbsrtowcs (ws, &mbs, slen + 1, &state); + if (lenp) + *lenp = mblength; + + if (MB_INVALIDCH (mblength)) + { + int i; + for (i = 0; i < slen; i++) + ws[i] = (wchar_t)arg[i]; + ws[slen] = L'\0'; + if (lenp) + *lenp = slen; + } + + advancearg (); + return (ws); +} + +static wint_t +getwidechar (void) +{ + wchar_t wc; + size_t slen, mblength; + char *arg; + DECLARE_MBSTATE; + + arg = getarg (); + if (arg == 0) + return L'\0'; + + wc = 0; + mblength = mbrtowc (&wc, arg, locale_mb_cur_max, &state); + if (MB_INVALIDCH (mblength)) + wc = (wchar_t)arg[0]; + + advancearg (); + return (wc); +} + +/* The basic approach is to take the wide character string, apply any + precision in terms of characters (otherwise the precision is useless), + compute the size of the output buffer, call wcsrtombs to convert back + to multibyte characters, and return the result. */ +static char * +convwidestr (wchar_t *ws, int prec) +{ + const wchar_t *ts; + wchar_t wc; + char *ret; + size_t rlen, rsize; + DECLARE_MBSTATE; + + ts = (const wchar_t *)ws; + + if (prec >= 0) + { + rsize = prec * MB_CUR_MAX; + ret = (char *)xmalloc (rsize + 1); +#if defined (HAVE_WCSNRTOMBS) + rlen = wcsnrtombs (ret, &ts, prec, rsize, &state); +#else + wc = ws[prec]; + ws[prec] = L'\0'; + rlen = wcsrtombs (ret, &ts, rsize, &state); + ws[prec] = wc; +#endif + } + else + { + rlen = wcsrtombs (NULL, &ts, 0, &state); + if (rlen != (size_t)-1) + { + memset (&state, '\0', sizeof (mbstate_t)); + ret = (char *)xmalloc (rlen + 1); + rlen = wcsrtombs (ret, &ts, rlen, &state); + } + else + ret = (char *)xmalloc (1); + } + if (MB_INVALIDCH (rlen)) + rlen = 0; + + ret[rlen] = '\0'; + return ret; +} + +static char * +convwidechar (wint_t wi, int prec) +{ + wchar_t wc; + char *ret; + size_t rlen; + DECLARE_MBSTATE; + + wc = (wchar_t)wi; + ret = (char *)xmalloc (MB_LEN_MAX + 1); + rlen = wcrtomb (ret, wc, &state); + if (MB_INVALIDCH (rlen)) + rlen = 0; + + ret[rlen] = '\0'; + return ret; +} +#endif diff --git a/builtins/psize.c b/builtins/psize.c index 30881fb3f..d499a1de6 100644 --- a/builtins/psize.c +++ b/builtins/psize.c @@ -1,6 +1,6 @@ /* psize.c - Find pipe size. */ -/* Copyright (C) 1987, 1991 Free Software Foundation, Inc. +/* Copyright (C) 1987, 1991, 2022 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -48,17 +48,14 @@ extern int errno; int nw; sighandler -sigpipe (sig) - int sig; +sigpipe (int sig) { fprintf (stderr, "%d\n", nw); exit (0); } int -main (argc, argv) - int argc; - char **argv; +main (int argc, char **argv) { char buf[128]; register int i; diff --git a/builtins/pushd.def b/builtins/pushd.def index 829f827d5..b3a6f5d37 100644 --- a/builtins/pushd.def +++ b/builtins/pushd.def @@ -1,7 +1,7 @@ This file is pushd.def, from which is created pushd.c. It implements the builtins "pushd", "popd", and "dirs" in Bash. -Copyright (C) 1987-2020 Free Software Foundation, Inc. +Copyright (C) 1987-2024 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -116,6 +116,10 @@ $END #include #if defined (PUSHD_AND_POPD) +#ifdef LOADABLE_BUILTIN +# include "builtins.h" +#endif + #include #if defined (HAVE_SYS_PARAM_H) # include @@ -140,10 +144,6 @@ $END #include "common.h" #include "builtext.h" -#ifdef LOADABLE_BUILTIN -# include "builtins.h" -#endif - #if !defined (errno) extern int errno; #endif /* !errno */ @@ -152,17 +152,17 @@ extern int errno; static char **pushd_directory_list = (char **)NULL; /* Number of existing slots in this list. */ -static int directory_list_size; +static size_t directory_list_size; /* Offset to the end of the list. */ static int directory_list_offset; -static void pushd_error PARAMS((int, char *)); -static void clear_directory_stack PARAMS((void)); -static int cd_to_string PARAMS((char *)); -static int change_to_temp PARAMS((char *)); -static void add_dirstack_element PARAMS((char *)); -static int get_dirstack_index PARAMS((intmax_t, int, int *)); +static void pushd_error (int, char *); +static void clear_directory_stack (void); +static int cd_to_string (char *); +static int change_to_temp (char *); +static void add_dirstack_element (char *); +static int get_dirstack_index (intmax_t, int, int *); #define NOCD 0x01 #define ROTATE 0x02 @@ -170,8 +170,7 @@ static int get_dirstack_index PARAMS((intmax_t, int, int *)); #define CLEARSTAK 0x08 int -pushd_builtin (list) - WORD_LIST *list; +pushd_builtin (WORD_LIST *list) { WORD_LIST *orig_list; char *temp, *current_directory, *top; @@ -228,7 +227,7 @@ pushd_builtin (list) break; else if (((direction = list->word->word[0]) == '+') || direction == '-') { - if (legal_number (list->word->word + 1, &num) == 0) + if (valid_number (list->word->word + 1, &num) == 0) { sh_invalidnum (list->word->word); builtin_usage (); @@ -316,8 +315,7 @@ pushd_builtin (list) If LIST is non-null it should consist of a word +N or -N, which says what element to delete from the stack. The default is the top one. */ int -popd_builtin (list) - WORD_LIST *list; +popd_builtin (WORD_LIST *list) { register int i; intmax_t which; @@ -341,7 +339,7 @@ popd_builtin (list) } else if (((direction = list->word->word[0]) == '+') || direction == '-') { - if (legal_number (list->word->word + 1, &which) == 0) + if (valid_number (list->word->word + 1, &which) == 0) { sh_invalidnum (list->word->word); builtin_usage (); @@ -365,6 +363,30 @@ popd_builtin (list) break; } +#if 0 + /* If we didn't find `which' but there are arguments remaining, assume we + got `--' */ + if (which_word == 0 && list) + { + if (((direction = list->word->word[0]) == '+') || direction == '-') + { + if (valid_number (list->word->word + 1, &which) == 0) + { + sh_invalidnum (list->word->word); + builtin_usage (); + return (EX_USAGE); + } + which_word = list->word->word; + } + else + { + builtin_error (_("%s: invalid argument"), list->word->word); + builtin_usage (); + return (EX_USAGE); + } + } +#endif + if (which > directory_list_offset || (which < -directory_list_offset) || (directory_list_offset == 0 && which == 0)) { pushd_error (directory_list_offset, which_word ? which_word : ""); @@ -406,8 +428,7 @@ popd_builtin (list) /* Print the current list of directories on the directory stack. */ int -dirs_builtin (list) - WORD_LIST *list; +dirs_builtin (WORD_LIST *list) { int flags, desired_index, index_flag, vflag; intmax_t i; @@ -440,7 +461,7 @@ dirs_builtin (list) else if (*list->word->word == '+' || *list->word->word == '-') { int sign; - if (legal_number (w = list->word->word + 1, &i) == 0) + if (valid_number (w = list->word->word + 1, &i) == 0) { sh_invalidnum (list->word->word); builtin_usage (); @@ -516,9 +537,7 @@ dirs_builtin (list) } static void -pushd_error (offset, arg) - int offset; - char *arg; +pushd_error (int offset, char *arg) { if (offset == 0) builtin_error (_("directory stack empty")); @@ -527,7 +546,7 @@ pushd_error (offset, arg) } static void -clear_directory_stack () +clear_directory_stack (void) { register int i; @@ -540,8 +559,7 @@ clear_directory_stack () so if the result is EXECUTION_FAILURE then an error message has already been printed. */ static int -cd_to_string (name) - char *name; +cd_to_string (char *name) { WORD_LIST *tlist; WORD_LIST *dir; @@ -555,8 +573,7 @@ cd_to_string (name) } static int -change_to_temp (temp) - char *temp; +change_to_temp (char *temp) { int tt; @@ -569,8 +586,7 @@ change_to_temp (temp) } static void -add_dirstack_element (dir) - char *dir; +add_dirstack_element (char *dir) { if (directory_list_offset == directory_list_size) pushd_directory_list = strvec_resize (pushd_directory_list, directory_list_size += 10); @@ -578,9 +594,7 @@ add_dirstack_element (dir) } static int -get_dirstack_index (ind, sign, indexp) - intmax_t ind; - int sign, *indexp; +get_dirstack_index (intmax_t ind, int sign, int *indexp) { if (indexp) *indexp = sign > 0 ? 1 : 2; @@ -603,8 +617,7 @@ get_dirstack_index (ind, sign, indexp) /* Used by the tilde expansion code. */ char * -get_dirstack_from_string (string) - char *string; +get_dirstack_from_string (char *string) { int ind, sign, index_flag; intmax_t i; @@ -615,7 +628,7 @@ get_dirstack_from_string (string) sign = (*string == '-') ? -1 : 1; string++; } - if (legal_number (string, &i) == 0) + if (valid_number (string, &i) == 0) return ((char *)NULL); index_flag = 0; @@ -630,9 +643,7 @@ get_dirstack_from_string (string) #ifdef INCLUDE_UNUSED char * -get_dirstack_element (ind, sign) - intmax_t ind; - int sign; +get_dirstack_element (intmax_t ind, int sign) { int i; @@ -643,10 +654,7 @@ get_dirstack_element (ind, sign) #endif void -set_dirstack_element (ind, sign, value) - intmax_t ind; - int sign; - char *value; +set_dirstack_element (intmax_t ind, int sign, char *value) { int i; @@ -658,8 +666,7 @@ set_dirstack_element (ind, sign, value) } WORD_LIST * -get_directory_stack (flags) - int flags; +get_directory_stack (int flags) { register int i; WORD_LIST *ret; diff --git a/builtins/read.def b/builtins/read.def index ddd91d32d..5135e2b11 100644 --- a/builtins/read.def +++ b/builtins/read.def @@ -1,7 +1,7 @@ This file is read.def, from which is created read.c. It implements the builtin "read" in Bash. -Copyright (C) 1987-2021 Free Software Foundation, Inc. +Copyright (C) 1987-2025 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -22,7 +22,7 @@ $PRODUCES read.c $BUILTIN read $FUNCTION read_builtin -$SHORT_DOC read [-ers] [-a array] [-d delim] [-i text] [-n nchars] [-N nchars] [-p prompt] [-t timeout] [-u fd] [name ...] +$SHORT_DOC read [-Eers] [-a array] [-d delim] [-i text] [-n nchars] [-N nchars] [-p prompt] [-t timeout] [-u fd] [name ...] Read a line from the standard input and split it into fields. Reads a single line from the standard input, or from file descriptor FD @@ -41,6 +41,8 @@ Options: -d delim continue until the first character of DELIM is read, rather than newline -e use Readline to obtain the line + -E use Readline to obtain the line and use the bash default + completion instead of Readline's default completion -i text use TEXT as the initial text for Readline -n nchars return after reading NCHARS characters rather than waiting for a newline, but honor a delimiter if fewer than @@ -86,7 +88,6 @@ $END #ifdef __CYGWIN__ # include -# include #endif #include "../bashintl.h" @@ -103,9 +104,7 @@ $END #include #endif -#if defined (BUFFERED_INPUT) -# include "input.h" -#endif +#include "input.h" #include "shmbutil.h" #include "timer.h" @@ -121,28 +120,29 @@ struct ttsave }; #if defined (READLINE) -static void reset_attempted_completion_function PARAMS((char *)); -static int set_itext PARAMS((void)); -static char *edit_line PARAMS((char *, char *)); -static void set_eol_delim PARAMS((int)); -static void reset_eol_delim PARAMS((char *)); -static void set_readline_timeout PARAMS((sh_timer *t, time_t, long)); +static void uw_reset_attempted_completion_function (void *); +static int set_itext (void); +static char *edit_line (char *, char *, int, int); +static void set_eol_delim (int); +static void reset_eol_delim (void *); +static void set_readline_timeout (sh_timer *t, time_t, long); +static void uw_bashline_reset_event_hook (void *); #endif -static SHELL_VAR *bind_read_variable PARAMS((char *, char *, int)); +static SHELL_VAR *bind_read_variable (char *, char *, int); #if defined (HANDLE_MULTIBYTE) -static int read_mbchar PARAMS((int, char *, int, int, int)); +static int read_mbchar (int, char *, int, int, int, int); #endif -static void ttyrestore PARAMS((struct ttsave *)); +static void ttyrestore (struct ttsave *); +static void uw_ttyrestore (void *); -static sighandler sigalrm PARAMS((int)); -static void reset_timeout PARAMS((void)); +static sighandler sigalrm (int); +static void reset_timeout (void); +static void uw_reset_timeout (void *); /* Try this to see what the rest of the shell can do with the information. */ sh_timer *read_timeout; static int reading, tty_modified; -static SigHandler *old_alrm; -static unsigned char delim; static struct ttsave termsave; @@ -153,8 +153,7 @@ static struct ttsave termsave; /* Set a flag that check_read_timeout can check. This relies on zread or read_builtin calling trap.c:check_signals() (which calls check_read_timeout()) */ static sighandler -sigalrm (s) - int s; +sigalrm (int s) { /* Display warning if this is called without read_timeout set? */ if (read_timeout) @@ -162,7 +161,7 @@ sigalrm (s) } static void -reset_timeout () +reset_timeout (void) { /* Cancel alarm before restoring signal handler. */ if (read_timeout) @@ -173,26 +172,50 @@ reset_timeout () read_timeout = 0; } +static void +uw_reset_timeout (void *ignore) +{ + reset_timeout (); +} + void -check_read_timeout () +check_read_timeout (void) { if (read_timeout && shtimer_chktimeout (read_timeout)) sh_longjmp (read_timeout->jmpenv, 1); } int -read_builtin_timeout (fd) - int fd; +read_builtin_timeout (int fd) { if ((read_timeout == 0) || (read_timeout->fd != fd) || (read_timeout->tmout.tv_sec == 0 && read_timeout->tmout.tv_usec == 0)) return 0; +#if defined (HAVE_SELECT) return ((read_timeout->flags & SHTIMER_ALARM) ? shtimer_alrm (read_timeout) : shtimer_select (read_timeout)); +#else + return (shtimer_alrm (read_timeout)); +#endif } +#if defined (READLINE) +void +reset_rl_instream (FILE *save_instream) +{ + fclose (rl_instream); + rl_instream = save_instream; +} + +void +uw_reset_rl_instream (void *fp) +{ + reset_rl_instream (fp); +} +#endif + /* Read the value of the shell variables whose names follow. The reading is done from the current input stream, whatever that may be. Successive words of the input line are assigned @@ -200,20 +223,23 @@ read_builtin_timeout (fd) gets the remainder of the words on the line. If no variables are mentioned in LIST, then the default variable is $REPLY. */ int -read_builtin (list) - WORD_LIST *list; +read_builtin (WORD_LIST *list) { - register char *varname; - int size, nr, pass_next, saw_escape, eof, opt, retval, code, print_ps2, nflag; + char *varname; + int nr, pass_next, saw_escape, eof, opt, retval, code, print_ps2, nflag; + size_t size; volatile int i; int input_is_tty, input_is_pipe, unbuffered_read, skip_ctlesc, skip_ctlnul; - int raw, edit, nchars, silent, have_timeout, ignore_delim, fd; + int edit, use_bash_completion; + int raw, nchars, silent, have_timeout, ignore_delim, fd; + int free_ifs; int lastsig, t_errno; int mb_cur_max; unsigned int tmsec, tmusec; long ival, uval; intmax_t intval; char c; + int delim; char *input_string, *orig_input_string, *ifs_chars, *prompt, *arrayname; char *e, *t, *t1, *ps2, *tofree; struct stat tsb; @@ -239,6 +265,8 @@ read_builtin (list) USE_VAR(input_is_pipe); /* USE_VAR(raw); */ USE_VAR(edit); + USE_VAR(use_bash_completion); + USE_VAR(delim); USE_VAR(tmsec); USE_VAR(tmusec); USE_VAR(nchars); @@ -260,6 +288,7 @@ read_builtin (list) i = 0; /* Index into the string that we are reading. */ raw = edit = 0; /* Not reading raw input by default. */ + use_bash_completion = 0; silent = 0; arrayname = prompt = (char *)NULL; fd = 0; /* file descriptor to read from */ @@ -276,7 +305,7 @@ read_builtin (list) ignore_delim = nflag = 0; reset_internal_getopt (); - while ((opt = internal_getopt (list, "ersa:d:i:n:p:t:u:N:")) != -1) + while ((opt = internal_getopt (list, "Eersa:d:i:n:p:t:u:N:")) != -1) { switch (opt) { @@ -294,6 +323,12 @@ read_builtin (list) edit = 1; #endif break; + case 'E': +#if defined (READLINE) + edit = use_bash_completion = 1; +#endif + break; + case 'i': #if defined (READLINE) itext = list_optarg; @@ -320,10 +355,9 @@ read_builtin (list) break; case 'N': ignore_delim = 1; - delim = -1; case 'n': nflag = 1; - code = legal_number (list_optarg, &intval); + code = valid_number (list_optarg, &intval); if (code == 0 || intval < 0 || intval != (int)intval) { sh_invalidnum (list_optarg); @@ -333,7 +367,7 @@ read_builtin (list) nchars = intval; break; case 'u': - code = legal_number (list_optarg, &intval); + code = valid_number (list_optarg, &intval); if (code == 0 || intval < 0 || intval != (int)intval) { builtin_error (_("%s: invalid file descriptor specification"), list_optarg); @@ -343,12 +377,12 @@ read_builtin (list) fd = intval; if (sh_validfd (fd) == 0) { - builtin_error (_("%d: invalid file descriptor: %s"), fd, strerror (errno)); + builtin_error ("%d: %s: %s", fd, _("invalid file descriptor"), strerror (errno)); return (EXECUTION_FAILURE); } break; case 'd': - delim = *list_optarg; + delim = (unsigned char)*list_optarg; break; CASE_HELPOPT; default: @@ -368,10 +402,10 @@ read_builtin (list) #if defined (ARRAY_VARS) if (list) SET_VFLAGS (list->word->flags, vflags, bindflags); - if (list && legal_identifier (list->word->word) == 0 && valid_array_reference (list->word->word, vflags) == 0) + if (list && valid_identifier (list->word->word) == 0 && valid_array_reference (list->word->word, vflags) == 0) #else bindflags = 0; - if (list && legal_identifier (list->word->word) == 0) + if (list && valid_identifier (list->word->word) == 0) #endif { sh_invalidid (list->word->word); @@ -383,18 +417,27 @@ read_builtin (list) delim = -1; /* IF IFS is unset, we use the default of " \t\n". */ - ifs_chars = getifs (); - if (ifs_chars == 0) /* XXX - shouldn't happen */ - ifs_chars = ""; + free_ifs = 0; /* If we want to read exactly NCHARS chars, don't split on IFS */ if (ignore_delim) ifs_chars = ""; + else + { + ifs_chars = getifs (); + if (ifs_chars == 0) /* XXX - shouldn't happen */ + ifs_chars = ""; + else + free_ifs = 1; + } for (skip_ctlesc = skip_ctlnul = 0, e = ifs_chars; *e; e++) skip_ctlesc |= *e == CTLESC, skip_ctlnul |= *e == CTLNUL; input_string = (char *)xmalloc (size = 112); /* XXX was 128 */ input_string[0] = '\0'; + pass_next = 0; /* Non-zero signifies last char was backslash. */ + saw_escape = 0; /* Non-zero is count of escape chars we added */ + /* More input and options validation */ if (nflag == 1 && nchars == 0) { @@ -420,14 +463,14 @@ read_builtin (list) sigemptyset (&chldset); sigprocmask (SIG_BLOCK, (sigset_t *)0, &chldset); sigaddset (&chldset, SIGCHLD); + sigemptyset (&prevset); + sigprocmask (SIG_SETMASK, (sigset_t *)0, &prevset); #endif begin_unwind_frame ("read_builtin"); -#if defined (BUFFERED_INPUT) if (interactive == 0 && default_buffered_input >= 0 && fd_is_bash_input (fd)) sync_buffered_stream (default_buffered_input); -#endif #if 1 input_is_tty = isatty (fd); @@ -436,7 +479,7 @@ read_builtin (list) #endif if (input_is_tty == 0) #ifndef __CYGWIN__ - input_is_pipe = (lseek (fd, 0L, SEEK_CUR) < 0) && (errno == ESPIPE); + input_is_pipe = fd_ispipe (fd); #else input_is_pipe = 1; #endif @@ -457,9 +500,6 @@ read_builtin (list) add_unwind_protect (xfree, rlbuf); #endif - pass_next = 0; /* Non-zero signifies last char was backslash. */ - saw_escape = 0; /* Non-zero signifies that we saw an escape char */ - if (tmsec > 0 || tmusec > 0) { /* Turn off the timeout if stdin is a regular file (e.g. from @@ -473,7 +513,7 @@ read_builtin (list) read_timeout = shtimer_alloc (); read_timeout->flags = SHTIMER_LONGJMP; -#if defined (HAVE_SELECT) +#if defined (HAVE_SELECT) || defined (HAVE_PSELECT) read_timeout->flags |= (edit || posixly_correct) ? SHTIMER_ALARM : SHTIMER_SELECT; #else read_timeout->flags |= SHTIMER_ALARM; @@ -489,7 +529,9 @@ read_builtin (list) if (code) { reset_timeout (); +#if defined (SIGCHLD) sigprocmask (SIG_SETMASK, &prevset, (sigset_t *)0); +#endif /* Tricky. The top of the unwind-protect stack is the free of input_string. We want to run all the rest and use input_string, @@ -512,14 +554,10 @@ read_builtin (list) } if (interactive_shell == 0) initialize_terminating_signals (); - add_unwind_protect (reset_timeout, (char *)NULL); + add_unwind_protect (uw_reset_timeout, NULL); #if defined (READLINE) if (edit) - { - add_unwind_protect (reset_attempted_completion_function, (char *)NULL); - add_unwind_protect (bashline_reset_event_hook, (char *)NULL); - set_readline_timeout (read_timeout, tmsec, tmusec); - } + set_readline_timeout (read_timeout, tmsec, tmusec); else #endif shtimer_set (read_timeout, tmsec, tmusec); @@ -541,7 +579,7 @@ read_builtin (list) if (delim != '\n') { set_eol_delim (delim); - add_unwind_protect (reset_eol_delim, (char *)NULL); + add_unwind_protect (reset_eol_delim, NULL); } } else @@ -558,7 +596,7 @@ read_builtin (list) if (i < 0) sh_ttyerror (1); tty_modified = 1; - add_unwind_protect ((Function *)ttyrestore, (char *)&termsave); + add_unwind_protect (uw_ttyrestore, &termsave); if (interactive_shell == 0) initialize_terminating_signals (); } @@ -576,7 +614,7 @@ read_builtin (list) sh_ttyerror (1); tty_modified = 1; - add_unwind_protect ((Function *)ttyrestore, (char *)&termsave); + add_unwind_protect (uw_ttyrestore, &termsave); if (interactive_shell == 0) initialize_terminating_signals (); } @@ -585,12 +623,34 @@ read_builtin (list) save_instream = 0; if (edit && fd != 0) { + int fd2; + FILE *fp2; + + if ((fd2 = dup (fd)) < 0 || (fp2 = fdopen (fd2, "r")) == 0) + { + builtin_error ("%d: %s", fd, strerror (errno)); + if (fd2 >= 0) + close (fd2); + run_unwind_frame ("read_builtin"); + if (free_ifs) + free (ifs_chars); + return (EXECUTION_FAILURE); + } + if (bash_readline_initialized == 0) initialize_readline (); - unwind_protect_var (rl_instream); save_instream = rl_instream; - rl_instream = fdopen (fd, "r"); + rl_instream = fp2; + add_unwind_protect (uw_reset_rl_instream, save_instream); + + fd = fd2; + } + + if (edit) + { + add_unwind_protect (uw_reset_attempted_completion_function, NULL); + add_unwind_protect (uw_bashline_reset_event_hook, NULL); } #endif @@ -614,10 +674,6 @@ read_builtin (list) fflush (stderr); } -#if defined (__CYGWIN__) && defined (O_TEXT) - setmode (0, O_TEXT); -#endif - ps2 = 0; for (print_ps2 = eof = retval = 0;;) { @@ -639,7 +695,7 @@ read_builtin (list) if (rlbuf == 0) { reading = 1; - rlbuf = edit_line (prompt ? prompt : "", itext); + rlbuf = edit_line (prompt ? prompt : "", itext, delim, use_bash_completion); reading = 0; rlind = 0; } @@ -690,11 +746,12 @@ read_builtin (list) if (retval <= 0) { - int t; + int x; - t = errno; + x = errno; if (retval < 0 && errno == EINTR) { + ZRESET (); check_signals (); /* in case we didn't call zread via zreadc */ lastsig = LASTSIG(); if (lastsig == 0) @@ -709,10 +766,14 @@ read_builtin (list) ttyrestore (&termsave); /* fix terminal before exiting */ CHECK_TERMSIG; eof = 1; - errno = t; /* preserve it for the error message below */ + errno = x; /* preserve it for the error message below */ break; } + /* Even if read returns a partial buffer, if we got an interrupt we're + going to throw it away. */ + ZRESET(); + QUIT; /* in case we didn't call check_signals() */ #if defined (READLINE) } @@ -724,13 +785,13 @@ read_builtin (list) /* XXX -- use i + mb_cur_max (at least 4) for multibyte/read_mbchar */ if (i + (mb_cur_max > 4 ? mb_cur_max : 4) >= size) { - char *t; - t = (char *)xrealloc (input_string, size += 128); + char *x; + x = (char *)xrealloc (input_string, size += 128); /* Only need to change unwind-protect if input_string changes */ - if (t != input_string) + if (x != input_string) { - input_string = t; + input_string = x; remove_unwind_protect (); add_unwind_protect (xfree, input_string); } @@ -741,11 +802,14 @@ read_builtin (list) if (pass_next) { pass_next = 0; - if (c == '\n') + if (c == '\n' || c == '\0') { if (skip_ctlesc == 0 && i > 0) - i--; /* back up over the CTLESC */ - if (interactive && input_is_tty && raw == 0) + { + i--; /* back up over the CTLESC */ + saw_escape--; /* one fewer CTLESC in the input */ + } + if (interactive && input_is_tty && raw == 0 && c == '\n') print_ps2 = 1; } else @@ -765,7 +829,7 @@ read_builtin (list) continue; } - if (ignore_delim == 0 && (unsigned char)c == delim) + if ((unsigned char)c == delim) break; if (c == '\0' && delim != '\0') @@ -779,7 +843,6 @@ read_builtin (list) add_char: input_string[i++] = c; - check_read_timeout (); #if defined (HANDLE_MULTIBYTE) /* XXX - what if C == 127? Can DEL introduce a multibyte sequence? */ @@ -806,7 +869,7 @@ add_char: else # endif if (locale_utf8locale == 0 || ((c & 0x80) != 0)) - i += read_mbchar (fd, input_string, i, c, unbuffered_read); + i += read_mbchar (fd, input_string, i, c, delim, unbuffered_read); } #endif @@ -814,9 +877,25 @@ add_char: if (nchars > 0 && nr >= nchars) break; + + check_read_timeout (); + } + /* Back up over trailing CTLESC if the input ends with an unescaped + backslash */ + if (pass_next && skip_ctlesc == 0) + { + i--; + saw_escape--; /* that CTLESC is no longer in the input */ } + /* I don't think this clause ever tests true. */ + if (skip_ctlnul && saw_escape && i == 1 && input_string[0] == CTLNUL) + saw_escape = 0; /* Avoid dequoting bare CTLNUL */ + input_string[i] = '\0'; - check_read_timeout (); + /* Don't check the timeout unless we didn't read anything and zread returned + EOF or error. */ + if (i == 0 && retval <= 0) + check_read_timeout (); #if defined (READLINE) if (edit) @@ -827,8 +906,10 @@ add_char: { t_errno = errno; if (errno != EINTR) - builtin_error (_("read error: %d: %s"), fd, strerror (errno)); + builtin_error ("%d: %s: %s", fd, _("read error"), strerror (errno)); run_unwind_frame ("read_builtin"); + if (free_ifs) + free (ifs_chars); return ((t_errno != EINTR) ? EXECUTION_FAILURE : 128+lastsig); } @@ -843,7 +924,7 @@ add_char: if (nchars > 0) rl_num_chars_to_read = 0; if (delim != '\n') - reset_eol_delim ((char *)NULL); + reset_eol_delim (NULL); } else #endif @@ -858,7 +939,7 @@ add_char: #if defined (READLINE) if (save_instream) - rl_instream = save_instream; /* can't portably free it */ + reset_rl_instream (save_instream); #endif discard_unwind_frame ("read_builtin"); @@ -878,6 +959,8 @@ assign_vars: if (var == 0) { free (input_string); + if (free_ifs) + free (ifs_chars); return EXECUTION_FAILURE; /* readonly or noassign */ } @@ -892,6 +975,8 @@ assign_vars: dispose_words (alist); } free (input_string); + if (free_ifs) + free (ifs_chars); return (retval); } #endif /* ARRAY_VARS */ @@ -922,12 +1007,14 @@ assign_vars: } else var = bind_variable ("REPLY", input_string, 0); - if (var == 0 || readonly_p (var) || noassign_p (var)) - retval = EXECUTION_FAILURE; + if (var == 0 || ASSIGN_DISALLOWED (var, 0)) + retval = EX_MISCERROR; else VUNSETATTR (var, att_invisible); free (input_string); + if (free_ifs) + free (ifs_chars); return (retval); } @@ -945,13 +1032,15 @@ assign_vars: varname = list->word->word; #if defined (ARRAY_VARS) SET_VFLAGS (list->word->flags, vflags, bindflags); - if (legal_identifier (varname) == 0 && valid_array_reference (varname, vflags) == 0) + if (valid_identifier (varname) == 0 && valid_array_reference (varname, vflags) == 0) #else - if (legal_identifier (varname) == 0) + if (valid_identifier (varname) == 0) #endif { sh_invalidid (varname); free (orig_input_string); + if (free_ifs) + free (ifs_chars); return (EXECUTION_FAILURE); } @@ -984,7 +1073,9 @@ assign_vars: if (var == 0) { free (orig_input_string); - return (EXECUTION_FAILURE); + if (free_ifs) + free (ifs_chars); + return (EX_MISCERROR); } stupidly_hack_special_variables (varname); @@ -994,13 +1085,15 @@ assign_vars: /* Now assign the rest of the line to the last variable argument. */ #if defined (ARRAY_VARS) SET_VFLAGS (list->word->flags, vflags, bindflags); - if (legal_identifier (list->word->word) == 0 && valid_array_reference (list->word->word, vflags) == 0) + if (valid_identifier (list->word->word) == 0 && valid_array_reference (list->word->word, vflags) == 0) #else - if (legal_identifier (list->word->word) == 0) + if (valid_identifier (list->word->word) == 0) #endif { sh_invalidid (list->word->word); free (orig_input_string); + if (free_ifs) + free (ifs_chars); return (EXECUTION_FAILURE); } @@ -1044,6 +1137,8 @@ assign_vars: else retval = EXECUTION_FAILURE; + if (free_ifs) + free (ifs_chars); FREE (tofree); free (orig_input_string); @@ -1051,26 +1146,20 @@ assign_vars: } static SHELL_VAR * -bind_read_variable (name, value, flags) - char *name, *value; - int flags; +bind_read_variable (char *name, char *value, int flags) { SHELL_VAR *v; v = builtin_bind_variable (name, value, flags); - return (v == 0 ? v - : ((readonly_p (v) || noassign_p (v)) ? (SHELL_VAR *)NULL : v)); + return ((v == 0 || ASSIGN_DISALLOWED (v, 0)) ? (SHELL_VAR *)NULL : v); } #if defined (HANDLE_MULTIBYTE) static int -read_mbchar (fd, string, ind, ch, unbuffered) - int fd; - char *string; - int ind, ch, unbuffered; +read_mbchar (int fd, char *string, int ind, int ch, int delim, int unbuffered) { char mbchar[MB_LEN_MAX + 1]; - int i, n, r; + int i, n, r, delim_ind; char c; size_t ret; mbstate_t ps, ps_back; @@ -1078,7 +1167,8 @@ read_mbchar (fd, string, ind, ch, unbuffered) memset (&ps, '\0', sizeof (mbstate_t)); memset (&ps_back, '\0', sizeof (mbstate_t)); - + + delim_ind = 0; mbchar[0] = ch; i = 1; for (n = 0; n <= MB_LEN_MAX; n++) @@ -1098,11 +1188,29 @@ read_mbchar (fd, string, ind, ch, unbuffered) r = zreadc (fd, &c); if (r <= 0) goto mbchar_return; + if ((unsigned char)c == delim) + delim_ind = i; mbchar[i++] = c; continue; } - else if (ret == (size_t)-1 || ret == (size_t)0 || ret > (size_t)0) - break; + else if (ret == (size_t)-1) + { + /* If we read (i > 1) a delimiter character (delim_ind >= 1) + that is a part of this invalid multibyte character, we can't + just add it to the input string and treat it as a byte. + We need to push it and everything we read after it back so a + subsequent zread will pick it up. */ + if (i > 1 && delim_ind >= 1) + { + size_t j; + for (j = delim_ind; j < i; j++) + zungetc ((unsigned char)mbchar[j]); + i = delim_ind; + } + break; /* invalid multibyte character */ + } + else if (ret == (size_t)0 || ret > (size_t)0) + break; /* valid multibyte character */ } mbchar_return: @@ -1116,22 +1224,27 @@ mbchar_return: static void -ttyrestore (ttp) - struct ttsave *ttp; +ttyrestore (struct ttsave *ttp) { ttsetattr (ttp->fd, &(ttp->attrs)); tty_modified = 0; } +static void +uw_ttyrestore (void *ttp) +{ + ttyrestore (ttp); +} + void -read_tty_cleanup () +read_tty_cleanup (void) { if (tty_modified) ttyrestore (&termsave); } int -read_tty_modified () +read_tty_modified (void) { return (tty_modified); } @@ -1142,15 +1255,20 @@ static rl_hook_func_t *old_startup_hook; static char *deftext; static void -reset_attempted_completion_function (cp) - char *cp; +uw_reset_attempted_completion_function (void *cp) { if (rl_attempted_completion_function == 0 && old_attempted_completion_function) rl_attempted_completion_function = old_attempted_completion_function; } +static void +uw_bashline_reset_event_hook (void *ignore) +{ + bashline_reset_event_hook (); +} + static int -set_itext () +set_itext (void) { int r1, r2; @@ -1168,18 +1286,19 @@ set_itext () } static char * -edit_line (p, itext) - char *p; - char *itext; +edit_line (char *p, char *itext, int delim, int keep_completion_func) { char *ret; - int len; + size_t len; if (bash_readline_initialized == 0) initialize_readline (); old_attempted_completion_function = rl_attempted_completion_function; - rl_attempted_completion_function = (rl_completion_func_t *)NULL; + /* If we don't indicate that we want to keep the attempted completion + function, reset it so we use the default readline word completion. */ + if (keep_completion_func == 0) + rl_attempted_completion_function = (rl_completion_func_t *)NULL; bashline_set_event_hook (); if (itext) { @@ -1190,7 +1309,8 @@ edit_line (p, itext) ret = readline (p); - rl_attempted_completion_function = old_attempted_completion_function; + if (keep_completion_func == 0) + rl_attempted_completion_function = old_attempted_completion_function; old_attempted_completion_function = (rl_completion_func_t *)NULL; bashline_reset_event_hook (); @@ -1206,16 +1326,14 @@ edit_line (p, itext) len = strlen (ret); ret = (char *)xrealloc (ret, len + 2); - ret[len++] = delim; + if (delim > 0) + ret[len++] = delim; ret[len] = '\0'; return ret; } static void -set_readline_timeout (t, sec, usec) - sh_timer *t; - time_t sec; - long usec; +set_readline_timeout (sh_timer *t, time_t sec, long usec) { t->tmout.tv_sec = sec; t->tmout.tv_usec = usec; @@ -1227,11 +1345,10 @@ static rl_command_func_t *old_delim_func; static int old_newline_ctype; static rl_command_func_t *old_newline_func; -static unsigned char delim_char; +static int delim_char; static void -set_eol_delim (c) - int c; +set_eol_delim (int c) { Keymap cmap; @@ -1239,26 +1356,27 @@ set_eol_delim (c) initialize_readline (); cmap = rl_get_keymap (); - /* Save the old delimiter char binding */ + /* Save the old newline binding and change it to self-insert */ old_newline_ctype = cmap[RETURN].type; old_newline_func = cmap[RETURN].function; - old_delim_ctype = cmap[c].type; - old_delim_func = cmap[c].function; - - /* Change newline to self-insert */ cmap[RETURN].type = ISFUNC; cmap[RETURN].function = rl_insert; - /* Bind the delimiter character to accept-line. */ - cmap[c].type = ISFUNC; - cmap[c].function = rl_newline; + /* Save any binding to the delimiter and bind the delimiter to accept-line */ + if (c >= 0) + { + old_delim_ctype = cmap[c].type; + old_delim_func = cmap[c].function; + + cmap[c].type = ISFUNC; + cmap[c].function = rl_newline; + } delim_char = c; } static void -reset_eol_delim (cp) - char *cp; +reset_eol_delim (void *ignore) { Keymap cmap; @@ -1267,7 +1385,10 @@ reset_eol_delim (cp) cmap[RETURN].type = old_newline_ctype; cmap[RETURN].function = old_newline_func; - cmap[delim_char].type = old_delim_ctype; - cmap[delim_char].function = old_delim_func; + if (delim_char >= 0) + { + cmap[delim_char].type = old_delim_ctype; + cmap[delim_char].function = old_delim_func; + } } #endif diff --git a/builtins/reserved.def b/builtins/reserved.def index 420042dcf..359754e34 100644 --- a/builtins/reserved.def +++ b/builtins/reserved.def @@ -19,6 +19,16 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Bash. If not, see . +$BUILTIN ! +$DOCNAME bang +$SHORT_DOC ! PIPELINE +Execute PIPELINE, which can be a simple command, and negate PIPELINE's +return status. + +Exit Status: +The logical negation of PIPELINE's return status. +$END + $BUILTIN for $SHORT_DOC for NAME [in WORDS ... ] ; do COMMANDS; done Execute commands for each member in a list. diff --git a/builtins/return.def b/builtins/return.def index 03c98eb11..049446dc1 100644 --- a/builtins/return.def +++ b/builtins/return.def @@ -1,7 +1,7 @@ This file is return.def, from which is created return.c. It implements the builtin "return" in Bash. -Copyright (C) 1987-2015 Free Software Foundation, Inc. +Copyright (C) 1987-2023 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -54,12 +54,17 @@ $END specified as an argument. if no argument is given, then the last exit status is used. */ int -return_builtin (list) - WORD_LIST *list; +return_builtin (WORD_LIST *list) { CHECK_HELPOPT (list); return_catch_value = get_exitstat (list); + /* return is a special builtin, so non-interactive shells in posix mode + exit on an invalid numeric argument. We have to do it this way because + the return_catch targets aren't set up to deal with EXITSHELL, so we + just jump_to_top_level directly. */ + if (interactive_shell == 0 && posixly_correct && executing_command_builtin == 0 && return_catch_value > EX_SHERRBASE) + return (return_catch_value); if (return_catch_flag) sh_longjmp (return_catch, 1); diff --git a/builtins/set.def b/builtins/set.def index 44f176919..13630c22d 100644 --- a/builtins/set.def +++ b/builtins/set.def @@ -1,7 +1,7 @@ This file is set.def, from which is created set.c. It implements the "set" and "unset" builtins in Bash. -Copyright (C) 1987-2021 Free Software Foundation, Inc. +Copyright (C) 1987-2024 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -141,6 +141,10 @@ Options: - Assign any remaining arguments to the positional parameters. The -x and -v options are turned off. +If -o is supplied with no option-name, set prints the current shell +option settings. If +o is supplied with no option-name, set prints a +series of set commands to recreate the current option settings. + Using + rather than - causes these flags to be turned off. The flags can also be used upon invocation of the shell. The current set of flags may be found in $-. The remaining n ARGs are positional @@ -151,24 +155,24 @@ Exit Status: Returns success unless an invalid option is given. $END -typedef int setopt_set_func_t PARAMS((int, char *)); -typedef int setopt_get_func_t PARAMS((char *)); +typedef int setopt_set_func_t (int, char *); +typedef int setopt_get_func_t (char *); -static int find_minus_o_option PARAMS((char *)); +static int find_minus_o_option (char *); -static void print_minus_o_option PARAMS((char *, int, int)); -static void print_all_shell_variables PARAMS((void)); +static void print_minus_o_option (char *, int, int); +static void print_all_shell_variables (void); -static int set_ignoreeof PARAMS((int, char *)); -static int set_posix_mode PARAMS((int, char *)); +static int set_ignoreeof (int, char *); +static int set_posix_mode (int, char *); #if defined (READLINE) -static int set_edit_mode PARAMS((int, char *)); -static int get_edit_mode PARAMS((char *)); +static int set_edit_mode (int, char *); +static int get_edit_mode (char *); #endif #if defined (HISTORY) -static int bash_set_history PARAMS((int, char *)); +static int bash_set_history (int, char *); #endif static const char * const on = "on"; @@ -245,8 +249,7 @@ const struct { : (*o_options[i].variable = (onoff == FLAG_ON))) static int -find_minus_o_option (name) - char *name; +find_minus_o_option (char *name) { register int i; @@ -257,8 +260,7 @@ find_minus_o_option (name) } int -minus_o_option_value (name) - char *name; +minus_o_option_value (char *name) { register int i; int *on_or_off; @@ -279,9 +281,7 @@ minus_o_option_value (name) #define MINUS_O_FORMAT "%-15s\t%s\n" static void -print_minus_o_option (name, value, pflag) - char *name; - int value, pflag; +print_minus_o_option (char *name, int value, int pflag) { if (pflag == 0) printf (MINUS_O_FORMAT, name, value ? on : off); @@ -290,8 +290,7 @@ print_minus_o_option (name, value, pflag) } void -list_minus_o_opts (mode, reusable) - int mode, reusable; +list_minus_o_opts (int mode, int reusable) { register int i; int *on_or_off, value; @@ -317,7 +316,7 @@ list_minus_o_opts (mode, reusable) } char ** -get_minus_o_opts () +get_minus_o_opts (void) { char **ret; int i; @@ -330,10 +329,11 @@ get_minus_o_opts () } char * -get_current_options () +get_current_options (void) { char *temp; - int i, posixopts; + int i; + size_t posixopts; posixopts = num_posix_options (); /* shopts modified by posix mode */ /* Make the buffer big enough to hold the set -o options and the shopt @@ -355,8 +355,7 @@ get_current_options () } void -set_current_options (bitmap) - const char *bitmap; +set_current_options (const char *bitmap) { int i, v, cv, *on_or_off; @@ -388,9 +387,7 @@ set_current_options (bitmap) } static int -set_ignoreeof (on_or_off, option_name) - int on_or_off; - char *option_name; +set_ignoreeof (int on_or_off, char *option_name) { ignoreeof = on_or_off == FLAG_ON; unbind_variable_noref ("ignoreeof"); @@ -403,9 +400,7 @@ set_ignoreeof (on_or_off, option_name) } static int -set_posix_mode (on_or_off, option_name) - int on_or_off; - char *option_name; +set_posix_mode (int on_or_off, char *option_name) { /* short-circuit on no-op */ if ((on_or_off == FLAG_ON && posixly_correct) || @@ -424,9 +419,7 @@ set_posix_mode (on_or_off, option_name) #if defined (READLINE) /* Magic. This code `knows' how readline handles rl_editing_mode. */ static int -set_edit_mode (on_or_off, option_name) - int on_or_off; - char *option_name; +set_edit_mode (int on_or_off, char *option_name) { int isemacs; @@ -434,7 +427,7 @@ set_edit_mode (on_or_off, option_name) { rl_variable_bind ("editing-mode", option_name); - if (interactive) + if (interactive && command_execution_string == 0) with_input_from_stdin (); no_line_editing = 0; } @@ -443,7 +436,7 @@ set_edit_mode (on_or_off, option_name) isemacs = rl_editing_mode == 1; if ((isemacs && *option_name == 'e') || (!isemacs && *option_name == 'v')) { - if (interactive) + if (interactive && command_execution_string == 0) with_input_from_stream (stdin, "stdin"); no_line_editing = 1; } @@ -452,8 +445,7 @@ set_edit_mode (on_or_off, option_name) } static int -get_edit_mode (name) - char *name; +get_edit_mode (char *name) { return (*name == 'e' ? no_line_editing == 0 && rl_editing_mode == 1 : no_line_editing == 0 && rl_editing_mode == 0); @@ -462,9 +454,7 @@ get_edit_mode (name) #if defined (HISTORY) static int -bash_set_history (on_or_off, option_name) - int on_or_off; - char *option_name; +bash_set_history (int on_or_off, char *option_name) { if (on_or_off == FLAG_ON) { @@ -483,9 +473,7 @@ bash_set_history (on_or_off, option_name) #endif int -set_minus_o_option (on_or_off, option_name) - int on_or_off; - char *option_name; +set_minus_o_option (int on_or_off, char *option_name) { register int i; @@ -515,7 +503,7 @@ set_minus_o_option (on_or_off, option_name) } static void -print_all_shell_variables () +print_all_shell_variables (void) { SHELL_VAR **vars; @@ -540,11 +528,12 @@ print_all_shell_variables () } void -set_shellopts () +set_shellopts (void) { char *value; char tflag[N_O_OPTIONS]; - int vsize, i, vptr, *ip, exported; + int i, *ip, exported; + size_t vsize, vptr; SHELL_VAR *v; for (vsize = i = 0; o_options[i].name; i++) @@ -584,17 +573,12 @@ set_shellopts () v = find_variable ("SHELLOPTS"); - /* Turn off the read-only attribute so we can bind the new value, and - note whether or not the variable was exported. */ - if (v) - { - VUNSETATTR (v, att_readonly); - exported = exported_p (v); - } - else - exported = 0; + /* Note whether or not the variable was exported so we can adjust after the + assignment. */ + exported = v ? exported_p (v) : 0; - v = bind_variable ("SHELLOPTS", value, 0); + /* ASS_FORCE so we don't have to temporarily turn off readonly */ + v = bind_variable ("SHELLOPTS", value, ASS_FORCE); /* Turn the read-only attribute back on, and turn off the export attribute if it was set implicitly by mark_modified_vars and SHELLOPTS was not @@ -607,8 +591,7 @@ set_shellopts () } void -parse_shellopts (value) - char *value; +parse_shellopts (char *value) { char *vname; int vptr; @@ -622,8 +605,7 @@ parse_shellopts (value) } void -initialize_shell_options (no_shellopts) - int no_shellopts; +initialize_shell_options (int no_shellopts) { char *temp; SHELL_VAR *var; @@ -651,11 +633,13 @@ initialize_shell_options (no_shellopts) called from execute_cmd.c:initialize_subshell() when setting up a subshell to run an executable shell script without a leading `#!'. */ void -reset_shell_options () +reset_shell_options (void) { pipefail_opt = 0; ignoreeof = 0; + interactive_comments = 1; + #if defined (STRICT_POSIX) posixly_correct = 1; #else @@ -671,8 +655,7 @@ reset_shell_options () then print out the values of the variables instead. If LIST contains non-flags, then set $1 - $9 to the successive words of LIST. */ int -set_builtin (list) - WORD_LIST *list; +set_builtin (WORD_LIST *list) { int on_or_off, flag_name, force_assignment, opts_changed, rv, r; register char *arg; @@ -830,15 +813,26 @@ $END #define NEXT_VARIABLE() any_failed++; list = list->next; continue; +#define RESTORE_NAME() \ +do { \ + tname = name + strlen (name); \ + if (tname == t - 1) /* probably a paranoid check */ \ + { \ + tname[0] = '['; \ + t[strlen (t)] = ']'; \ + } \ +} while (0) + int -unset_builtin (list) - WORD_LIST *list; +unset_builtin (WORD_LIST *list) { int unset_function, unset_variable, unset_array, opt, nameref, any_failed; int global_unset_func, global_unset_var, vflags, base_vflags, valid_id; + int posix_utility_error; char *name, *tname; - unset_function = unset_variable = unset_array = nameref = any_failed = 0; + unset_function = unset_variable = unset_array = nameref = 0; + posix_utility_error = any_failed = 0; global_unset_func = global_unset_var = 0; reset_internal_getopt (); @@ -873,7 +867,7 @@ unset_builtin (list) nameref = 0; #if defined (ARRAY_VARS) - base_vflags = assoc_expand_once ? VA_NOEXPAND : 0; + base_vflags = array_expand_once ? VA_NOEXPAND : 0; #endif while (list) @@ -891,23 +885,26 @@ unset_builtin (list) #if defined (ARRAY_VARS) vflags = builtin_arrayref_flags (list->word, base_vflags); -#endif - -#if defined (ARRAY_VARS) unset_array = 0; /* XXX valid array reference second arg was 0 */ - if (!unset_function && nameref == 0 && tokenize_array_reference (name, vflags, &t)) + /* XXX tokenize_array_reference modifies NAME if it succeeds */ + if (unset_function == 0 && nameref == 0 && tokenize_array_reference (name, vflags, &t)) unset_array = 1; #endif + /* Get error checking out of the way first. The low-level functions just perform the unset, relying on the caller to verify. */ - valid_id = legal_identifier (name); + valid_id = valid_identifier (name); /* Whether or not we are in posix mode, if neither -f nor -v appears, skip over trying to unset variables with invalid names and just treat them as potential shell function names. */ if (global_unset_func == 0 && global_unset_var == 0 && valid_id == 0) { +#if defined (ARRAY_VARS) + if (unset_array) + RESTORE_NAME (); +#endif unset_variable = unset_array = 0; unset_function = 1; } @@ -918,6 +915,7 @@ unset_builtin (list) if (unset_function == 0 && valid_id == 0) { sh_invalidid (name); + posix_utility_error++; NEXT_VARIABLE (); } @@ -930,6 +928,7 @@ unset_builtin (list) if (var && unset_function == 0 && non_unsettable_p (var)) { builtin_error (_("%s: cannot unset"), name); + posix_utility_error++; NEXT_VARIABLE (); } @@ -941,8 +940,20 @@ unset_builtin (list) find a function after unsuccessfully searching for a variable, note that we're acting on a function now as if -f were supplied. The readonly check below takes care of it. */ - if (var == 0 && nameref == 0 && unset_variable == 0 && unset_function == 0) + if (var == 0 && nameref == 0 && unset_variable == 0 && unset_function == 0) { +#if defined (ARRAY_VARS) + /* We modified NAME in the call to tokenize_array_reference, so we + need to restore it here. We turned the original `[' and `]' into + NULL, to isolate the array name and subscript. This only happens + if tokenize_array_reference succeeds with a non-NULL subscript + pointer, and UNSET_ARRAY is set to 1 only in this case. */ + if (unset_array) + { + RESTORE_NAME(); + unset_array = 0; + } +#endif if (var = find_function (name)) unset_function = 1; } @@ -952,6 +963,7 @@ unset_builtin (list) { builtin_error (_("%s: cannot unset: readonly %s"), var->name, unset_function ? "function" : "variable"); + posix_utility_error++; NEXT_VARIABLE (); } @@ -987,6 +999,7 @@ unset_builtin (list) int len; tname = savestring (nameref_cell (var)); + tem = 0; if (var = array_variable_part (tname, 0, &t, &len)) { /* change to what unbind_array_element now expects */ @@ -1000,16 +1013,22 @@ unset_builtin (list) #endif tem = unbind_variable (nameref_cell (var)); } + else if (posixly_correct && var && tempvar_p (var)) + tem = posix_unbind_tempvar (name); else tem = unbind_variable (name); } + else if (posixly_correct && unset_function == 0 && nameref == 0 && var && tempvar_p (var)) + tem = posix_unbind_tempvar (name); else tem = unset_function ? unbind_func (name) : (nameref ? unbind_nameref (name) : unbind_variable (name)); /* This is what Posix.2 says: ``If neither -f nor -v is specified, the name refers to a variable; if a variable by - that name does not exist, a function by that name, if any, - shall be unset.'' */ + that name does not exist, it is unspecified whether a function + by that name, if any, shall be unset.'' The unspecified part is a + recent addition, so we continue to try to unset a shell function if + we don't find a variable named NAME. */ if (tem == -1 && nameref == 0 && unset_function == 0 && unset_variable == 0) tem = unbind_func (name); @@ -1024,5 +1043,5 @@ unset_builtin (list) list = list->next; } - return (any_failed ? EXECUTION_FAILURE : EXECUTION_SUCCESS); + return (any_failed ? (posix_utility_error ? EX_UTILERROR : EXECUTION_FAILURE) : EXECUTION_SUCCESS); } diff --git a/builtins/setattr.def b/builtins/setattr.def index 50c8edf68..b43131975 100644 --- a/builtins/setattr.def +++ b/builtins/setattr.def @@ -1,7 +1,7 @@ This file is setattr.def, from which is created setattr.c. It implements the builtins "export" and "readonly", in Bash. -Copyright (C) 1987-2021 Free Software Foundation, Inc. +Copyright (C) 1987-2025 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -38,19 +38,19 @@ $PRODUCES setattr.c #include "../flags.h" #include "common.h" #include "bashgetopt.h" +#include "builtext.h" extern sh_builtin_func_t *this_shell_builtin; -#ifdef ARRAY_VARS -extern int declare_builtin PARAMS((WORD_LIST *)); -#endif - #define READONLY_OR_EXPORT \ (this_shell_builtin == readonly_builtin || this_shell_builtin == export_builtin) +#define SPECIAL_LOCAL(n) \ + (this_shell_builtin == local_builtin && n[0] == '-' && n[1] == 0) + $BUILTIN export $FUNCTION export_builtin -$SHORT_DOC export [-fn] [name[=value] ...] or export -p +$SHORT_DOC export [-fn] [name[=value] ...] or export -p [-f] Set export attribute for shell variables. Marks each NAME for automatic export to the environment of subsequently @@ -59,7 +59,7 @@ executed commands. If VALUE is supplied, assign VALUE before exporting. Options: -f refer to shell functions -n remove the export property from each NAME - -p display a list of all exported variables and functions + -p display a list of all exported variables or functions An argument of `--' disables further option processing. @@ -73,8 +73,7 @@ $END exported attribute from variables named in LIST. An argument of -f indicates that the names present in LIST refer to functions. */ int -export_builtin (list) - register WORD_LIST *list; +export_builtin (WORD_LIST *list) { return (set_or_show_attributes (list, att_exported, 0)); } @@ -104,8 +103,7 @@ $END /* For each variable name in LIST, make that variable readonly. Given an empty LIST, print out all existing readonly variables. */ int -readonly_builtin (list) - register WORD_LIST *list; +readonly_builtin (WORD_LIST *list) { return (set_or_show_attributes (list, att_readonly, 0)); } @@ -120,12 +118,10 @@ readonly_builtin (list) ATTRIBUTE. An arg of `-n' says to remove the attribute from the the remaining names in LIST (doesn't work for readonly). */ int -set_or_show_attributes (list, attribute, nodefs) - register WORD_LIST *list; - int attribute, nodefs; +set_or_show_attributes (WORD_LIST *list, int attribute, int nodefs) { register SHELL_VAR *var; - int assign, undo, any_failed, assign_error, opt; + int assign, undo, any_failed, assign_error, util_error, opt, retval; int functions_only, arrays_only, assoc_only; int aflags; char *name; @@ -137,7 +133,9 @@ set_or_show_attributes (list, attribute, nodefs) #endif functions_only = arrays_only = assoc_only = 0; - undo = any_failed = assign_error = 0; + undo = any_failed = assign_error = util_error = 0; + retval = EXECUTION_SUCCESS; + /* Read arguments from the front of the list. */ reset_internal_getopt (); while ((opt = internal_getopt (list, ATTROPTS)) != -1) @@ -215,11 +213,16 @@ set_or_show_attributes (list, attribute, nodefs) } } - if (legal_identifier (name) == 0) + if (valid_identifier (name) == 0) { sh_invalidid (name); if (assign) assign_error++; + else if (posixly_correct) + { + util_error++; + break; /* exit immediately on bad identifier */ + } else any_failed++; list = list->next; @@ -342,16 +345,21 @@ set_or_show_attributes (list, attribute, nodefs) } } - return (assign_error ? EX_BADASSIGN - : ((any_failed == 0) ? EXECUTION_SUCCESS - : EXECUTION_FAILURE)); + /* various failure modes */ + if (assign_error) + retval = EX_BADASSIGN; + else if (util_error) /* only posix mode sets this */ + retval = EX_UTILERROR; + else if (any_failed) + retval = EXECUTION_FAILURE; + + return (retval); } /* Show all variable variables (v == 1) or functions (v == 0) with attributes. */ int -show_all_var_attributes (v, nodefs) - int v, nodefs; +show_all_var_attributes (int v, int nodefs) { SHELL_VAR **variable_list, *var; int any_failed; @@ -378,8 +386,7 @@ show_all_var_attributes (v, nodefs) /* Show all local variable variables with their attributes. This shows unset local variables (all_local_variables called with 0 argument). */ int -show_local_var_attributes (v, nodefs) - int v, nodefs; +show_local_var_attributes (int v, int nodefs) { SHELL_VAR **variable_list, *var; int any_failed; @@ -403,11 +410,9 @@ show_local_var_attributes (v, nodefs) return (any_failed == 0 ? EXECUTION_SUCCESS : EXECUTION_FAILURE); } +/* Fill in FLAGS with attribute characters */ int -var_attribute_string (var, pattr, flags) - SHELL_VAR *var; - int pattr; - char *flags; /* filled in with attributes */ +var_attribute_string (SHELL_VAR *var, int pattr, char *flags) { int i; @@ -476,9 +481,7 @@ var_attribute_string (var, pattr, flags) or `readonly') instead of `declare', and doesn't print function defs when called by `export' or `readonly'. */ int -show_var_attributes (var, pattr, nodefs) - SHELL_VAR *var; - int pattr, nodefs; +show_var_attributes (SHELL_VAR *var, int pattr, int nodefs) { char flags[MAX_ATTRIBUTES], *x; int i; @@ -533,9 +536,7 @@ show_var_attributes (var, pattr, nodefs) } int -show_name_attributes (name, nodefs) - char *name; - int nodefs; +show_name_attributes (char *name, int nodefs) { SHELL_VAR *var; @@ -551,9 +552,7 @@ show_name_attributes (name, nodefs) } int -show_localname_attributes (name, nodefs) - char *name; - int nodefs; +show_localname_attributes (char *name, int nodefs) { SHELL_VAR *var; @@ -561,7 +560,11 @@ show_localname_attributes (name, nodefs) if (var && local_p (var) && var->context == variable_context) /* show every variable with attributes, even unset ones */ { - show_var_attributes (var, READONLY_OR_EXPORT, nodefs); + /* There is no equivalent `declare -'. */ + if (STREQ (var->name, "-")) + printf ("local -\n"); + else + show_var_attributes (var, READONLY_OR_EXPORT, nodefs); return (0); } else @@ -569,9 +572,7 @@ show_localname_attributes (name, nodefs) } int -show_func_attributes (name, nodefs) - char *name; - int nodefs; +show_func_attributes (char *name, int nodefs) { SHELL_VAR *var; @@ -586,10 +587,10 @@ show_func_attributes (name, nodefs) return (1); } +/* This is only called by readonly/export, so we can implement posix-mode + semantics for special variables. */ void -set_var_attribute (name, attribute, undo) - char *name; - int attribute, undo; +set_var_attribute (char *name, int attribute, int undo) { SHELL_VAR *var, *tv, *v, *refvar; char *tvalue; @@ -598,10 +599,8 @@ set_var_attribute (name, attribute, undo) var = find_variable (name); else { + /* var=value readonly var */ tv = find_tempenv_variable (name); - /* XXX -- need to handle case where tv is a temp variable in a - function-scope context, since function_env has been merged into - the local variables table. */ if (tv && tempvar_p (tv)) { tvalue = var_isset (tv) ? savestring (value_cell (tv)) : savestring (""); @@ -640,6 +639,9 @@ set_var_attribute (name, attribute, undo) } else { + /* Handle case where var is a temp variable in a function-scope + context, since function_env has been merged into the local + variables table (see below). */ var = find_variable_notempenv (name); if (var == 0) { @@ -659,7 +661,13 @@ set_var_attribute (name, attribute, undo) if (var) VSETATTR (var, att_invisible); } - else if (var->context != 0) + /* We don't want to do this for local variables or variables we found + in previous temporary environment contexts. */ +#if 0 + else if (var->context != 0 && local_p (var) == 0) +#else + else if (var->context != 0 && local_p (var) == 0 && tempvar_p (var) == 0) +#endif VSETATTR (var, att_propagate); } } diff --git a/builtins/shift.def b/builtins/shift.def index bb9af01b5..34bf9c8ab 100644 --- a/builtins/shift.def +++ b/builtins/shift.def @@ -1,7 +1,7 @@ This file is shift.def, from which is created shift.c. It implements the builtin "shift" in Bash. -Copyright (C) 1987-2020 Free Software Foundation, Inc. +Copyright (C) 1987-2022 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -54,8 +54,7 @@ int print_shift_error; anything in it, it is a number which says where to start the shifting. Return > 0 if `times' > $#, otherwise 0. */ int -shift_builtin (list) - WORD_LIST *list; +shift_builtin (WORD_LIST *list) { intmax_t times; int itimes, nargs; @@ -63,12 +62,15 @@ shift_builtin (list) CHECK_HELPOPT (list); if (get_numeric_arg (list, 0, ×) == 0) - return (EXECUTION_FAILURE); + return (EX_USAGE); if (times == 0) return (EXECUTION_SUCCESS); else if (times < 0) { + /* skip over `--' option to get the right error message */ + if (list && list->word && ISOPTION (list->word->word, '-')) + list = list->next; sh_erange (list ? list->word->word : NULL, _("shift count")); return (EXECUTION_FAILURE); } @@ -76,7 +78,13 @@ shift_builtin (list) if (times > nargs) { if (print_shift_error) - sh_erange (list ? list->word->word : NULL, _("shift count")); + { + /* skip over `--' option to get the right error message */ + if (list && list->word && ISOPTION (list->word->word, '-')) + list = list->next; + + sh_erange (list ? list->word->word : NULL, _("shift count")); + } return (EXECUTION_FAILURE); } else if (times == nargs) diff --git a/builtins/shopt.def b/builtins/shopt.def index ba97e7028..cf6f6be12 100644 --- a/builtins/shopt.def +++ b/builtins/shopt.def @@ -1,7 +1,7 @@ This file is shopt.def, from which is created shopt.c. It implements the Bash `shopt' builtin. -Copyright (C) 1994-2021 Free Software Foundation, Inc. +Copyright (C) 1994-2025 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -52,8 +52,6 @@ $END #include -#include "version.h" - #include "../bashintl.h" #include "../shell.h" @@ -72,7 +70,7 @@ $END #define UNSETOPT 0 #define SETOPT 1 -#define OPTFMT "%-15s\t%s\n" +#define OPTFMT "%-20s\t%s\n" extern int allow_null_glob_expansion, fail_glob_expansion, glob_dot_filenames; extern int cdable_vars, mail_warning, source_uses_path; @@ -97,6 +95,7 @@ extern int localvar_unset; extern int varassign_redir_autoclose; extern int singlequote_translations; extern int patsub_replacement; +extern int bash_source_fullpath; #if defined (EXTENDED_GLOB) extern int extended_glob; @@ -109,7 +108,7 @@ extern int force_fignore; extern int dircomplete_spelling, dircomplete_expand; extern int complete_fullquote; -extern int enable_hostname_completion PARAMS((int)); +extern int enable_hostname_completion (int); #endif #if defined (PROGRAMMABLE_COMPLETION) @@ -122,7 +121,6 @@ extern int debugging_mode; #endif #if defined (ARRAY_VARS) -extern int assoc_expand_once; extern int array_expand_once; int expand_once_flag; #endif @@ -131,33 +129,33 @@ int expand_once_flag; extern int syslog_history; #endif -static void shopt_error PARAMS((char *)); +static void shopt_error (char *); -static int set_shellopts_after_change PARAMS((char *, int)); -static int set_compatibility_level PARAMS((char *, int)); +static int set_shellopts_after_change (char *, int); +static int set_compatibility_level (char *, int); #if defined (RESTRICTED_SHELL) -static int set_restricted_shell PARAMS((char *, int)); +static int set_restricted_shell (char *, int); #endif #if defined (READLINE) -static int shopt_enable_hostname_completion PARAMS((char *, int)); -static int shopt_set_complete_direxpand PARAMS((char *, int)); +static int shopt_enable_hostname_completion (char *, int); +static int shopt_set_complete_direxpand (char *, int); #endif #if defined (ARRAY_VARS) -static int set_assoc_expand PARAMS((char *, int)); +static int set_array_expand (char *, int); #endif #if defined (EXTENDED_GLOB) int extglob_flag = EXTGLOB_DEFAULT; -static int shopt_set_extglob PARAMS((char *, int)); +static int shopt_set_extglob (char *, int); #endif int expaliases_flag = 0; -static int shopt_set_expaliases PARAMS((char *, int)); +static int shopt_set_expaliases (char *, int); -static int shopt_set_debug_mode PARAMS((char *, int)); +static int shopt_set_debug_mode (char *, int); static int shopt_login_shell; static int shopt_compat31; @@ -168,7 +166,7 @@ static int shopt_compat42; static int shopt_compat43; static int shopt_compat44; -typedef int shopt_set_func_t PARAMS((char *, int)); +typedef int shopt_set_func_t (char *, int); /* If you add a new variable name here, make sure to set the default value appropriately in reset_shopt_options. */ @@ -178,9 +176,13 @@ static struct { int *value; shopt_set_func_t *set_func; } shopt_vars[] = { +#if defined (ARRAY_VARS) + { "array_expand_once", &expand_once_flag, set_array_expand }, + { "assoc_expand_once", &expand_once_flag, set_array_expand }, +#endif { "autocd", &autocd, (shopt_set_func_t *)NULL }, #if defined (ARRAY_VARS) - { "assoc_expand_once", &expand_once_flag, set_assoc_expand }, + { "bash_source_fullpath", &bash_source_fullpath, (shopt_set_func_t *)NULL }, #endif { "cdable_vars", &cdable_vars, (shopt_set_func_t *)NULL }, { "cdspell", &cdspelling, (shopt_set_func_t *)NULL }, @@ -276,14 +278,14 @@ static struct { static const char * const on = "on"; static const char * const off = "off"; -static int find_shopt PARAMS((char *)); -static int toggle_shopts PARAMS((int, WORD_LIST *, int)); -static void print_shopt PARAMS((char *, int, int)); -static int list_shopts PARAMS((WORD_LIST *, int)); -static int list_some_shopts PARAMS((int, int)); -static int list_shopt_o_options PARAMS((WORD_LIST *, int)); -static int list_some_o_options PARAMS((int, int)); -static int set_shopt_o_options PARAMS((int, WORD_LIST *, int)); +static int find_shopt (char *); +static int toggle_shopts (int, WORD_LIST *, int); +static void print_shopt (char *, int, int); +static int list_shopts (WORD_LIST *, int); +static int list_some_shopts (int, int); +static int list_shopt_o_options (WORD_LIST *, int); +static int list_some_o_options (int, int); +static int set_shopt_o_options (int, WORD_LIST *, int); #define SFLAG 0x01 #define UFLAG 0x02 @@ -292,8 +294,7 @@ static int set_shopt_o_options PARAMS((int, WORD_LIST *, int)); #define PFLAG 0x10 int -shopt_builtin (list) - WORD_LIST *list; +shopt_builtin (WORD_LIST *list) { int opt, flags, rval; @@ -351,7 +352,7 @@ shopt_builtin (list) /* Reset the options managed by `shopt' to the values they would have at shell startup. Variables from shopt_vars. */ void -reset_shopt_options () +reset_shopt_options (void) { autocd = cdable_vars = cdspelling = 0; check_hashed_filenames = CHECKHASH_DEFAULT; @@ -375,7 +376,8 @@ reset_shopt_options () source_uses_path = promptvars = 1; varassign_redir_autoclose = 0; singlequote_translations = 0; - patsub_replacement = 1; + patsub_replacement = PATSUB_REPLACE_DEFAULT; + bash_source_fullpath = BASH_SOURCE_FULLPATH_DEFAULT; #if defined (JOB_CONTROL) check_jobs_at_exit = 0; @@ -384,9 +386,10 @@ reset_shopt_options () #if defined (EXTENDED_GLOB) extended_glob = extglob_flag = EXTGLOB_DEFAULT; #endif + glob_always_skip_dot_and_dotdot = 1; /* new default as of bash-5.2 */ #if defined (ARRAY_VARS) - expand_once_flag = assoc_expand_once = 0; + expand_once_flag = array_expand_once = 0; #endif #if defined (HISTORY) @@ -430,12 +433,15 @@ reset_shopt_options () xpg_echo = 0; #endif /* DEFAULT_ECHO_TO_XPG */ +#if defined (DEBUGGER) + debugging_mode = 0; +#endif + shopt_login_shell = login_shell; } static int -find_shopt (name) - char *name; +find_shopt (char *name) { int i; @@ -446,17 +452,13 @@ find_shopt (name) } static void -shopt_error (s) - char *s; +shopt_error (char *s) { builtin_error (_("%s: invalid shell option name"), s); } static int -toggle_shopts (mode, list, quiet) - int mode; - WORD_LIST *list; - int quiet; +toggle_shopts (int mode, WORD_LIST *list, int quiet) { WORD_LIST *l; int ind, rval; @@ -485,9 +487,7 @@ toggle_shopts (mode, list, quiet) } static void -print_shopt (name, val, flags) - char *name; - int val, flags; +print_shopt (char *name, int val, int flags) { if (flags & PFLAG) printf ("shopt %s %s\n", val ? "-s" : "-u", name); @@ -498,9 +498,7 @@ print_shopt (name, val, flags) /* List the values of all or any of the `shopt' options. Returns 0 if all were listed or all variables queried were on; 1 otherwise. */ static int -list_shopts (list, flags) - WORD_LIST *list; - int flags; +list_shopts (WORD_LIST *list, int flags) { WORD_LIST *l; int i, val, rval; @@ -536,8 +534,7 @@ list_shopts (list, flags) } static int -list_some_shopts (mode, flags) - int mode, flags; +list_some_shopts (int mode, int flags) { int val, i; @@ -551,9 +548,7 @@ list_some_shopts (mode, flags) } static int -list_shopt_o_options (list, flags) - WORD_LIST *list; - int flags; +list_shopt_o_options (WORD_LIST *list, int flags) { WORD_LIST *l; int val, rval; @@ -588,8 +583,7 @@ list_shopt_o_options (list, flags) } static int -list_some_o_options (mode, flags) - int mode, flags; +list_some_o_options (int mode, int flags) { if ((flags & QFLAG) == 0) list_minus_o_opts (mode, (flags & PFLAG)); @@ -597,10 +591,7 @@ list_some_o_options (mode, flags) } static int -set_shopt_o_options (mode, list, quiet) - int mode; - WORD_LIST *list; - int quiet; +set_shopt_o_options (int mode, WORD_LIST *list, int quiet) { WORD_LIST *l; int rval; @@ -617,18 +608,14 @@ set_shopt_o_options (mode, list, quiet) /* If we set or unset interactive_comments with shopt, make sure the change is reflected in $SHELLOPTS. */ static int -set_shellopts_after_change (option_name, mode) - char *option_name; - int mode; +set_shellopts_after_change (char *option_name, int mode) { set_shellopts (); return (0); } static int -shopt_set_debug_mode (option_name, mode) - char *option_name; - int mode; +shopt_set_debug_mode (char *option_name, int mode) { #if defined (DEBUGGER) error_trace_mode = function_trace_mode = debugging_mode; @@ -640,9 +627,7 @@ shopt_set_debug_mode (option_name, mode) } static int -shopt_set_expaliases (option_name, mode) - char *option_name; - int mode; +shopt_set_expaliases (char *option_name, int mode) { expand_aliases = expaliases_flag; return 0; @@ -650,9 +635,7 @@ shopt_set_expaliases (option_name, mode) #if defined (EXTENDED_GLOB) static int -shopt_set_extglob (option_name, mode) - char *option_name; - int mode; +shopt_set_extglob (char *option_name, int mode) { extended_glob = extglob_flag; return 0; @@ -661,26 +644,21 @@ shopt_set_extglob (option_name, mode) #if defined (READLINE) static int -shopt_enable_hostname_completion (option_name, mode) - char *option_name; - int mode; +shopt_enable_hostname_completion (char *option_name, int mode) { return (enable_hostname_completion (mode)); } #endif static int -set_compatibility_level (option_name, mode) - char *option_name; - int mode; +set_compatibility_level (char *option_name, int mode) { int ind, oldval; char *rhs; /* If we're unsetting one of the compatibility options, make sure the current value is in the range of the compatNN space. */ - if (mode == 0) - oldval = shell_compatibility_level; + oldval = (mode == 0) ? shell_compatibility_level : 0; /* If we're setting something, redo some of the work we did above in toggle_shopt(). Unset everything and reset the appropriate option @@ -709,10 +687,10 @@ set_compatibility_level (option_name, mode) shell_compatibility_level = 43; else if (shopt_compat44) shell_compatibility_level = 44; - else if (oldval > 44 && shell_compatibility_level < DEFAULT_COMPAT_LEVEL) + else if (oldval > 44 && shell_compatibility_level < default_compatibility_level) ; else - shell_compatibility_level = DEFAULT_COMPAT_LEVEL; + shell_compatibility_level = default_compatibility_level; /* Make sure the current compatibility level is reflected in BASH_COMPAT */ rhs = itos (shell_compatibility_level); @@ -725,14 +703,17 @@ set_compatibility_level (option_name, mode) /* Set and unset the various compatibility options from the value of shell_compatibility_level; used by sv_shcompat */ void -set_compatibility_opts () +set_compatibility_opts (void) { shopt_compat31 = shopt_compat32 = 0; shopt_compat40 = shopt_compat41 = shopt_compat42 = shopt_compat43 = 0; shopt_compat44 = 0; + if (shell_compatibility_level == default_compatibility_level) + return; + switch (shell_compatibility_level) { - case DEFAULT_COMPAT_LEVEL: + case 52: /* completeness */ case 51: /* completeness */ case 50: break; @@ -755,9 +736,7 @@ set_compatibility_opts () #if defined (READLINE) static int -shopt_set_complete_direxpand (option_name, mode) - char *option_name; - int mode; +shopt_set_complete_direxpand (char *option_name, int mode) { set_directory_hook (); return 0; @@ -768,9 +747,7 @@ shopt_set_complete_direxpand (option_name, mode) /* Don't allow the value of restricted_shell to be modified. */ static int -set_restricted_shell (option_name, mode) - char *option_name; - int mode; +set_restricted_shell (char *option_name, int mode) { static int save_restricted = -1; @@ -784,19 +761,18 @@ set_restricted_shell (option_name, mode) /* Not static so shell.c can call it to initialize shopt_login_shell */ int -set_login_shell (option_name, mode) - char *option_name; - int mode; +set_login_shell (char *option_name, int mode) { shopt_login_shell = login_shell != 0; return (0); } char ** -get_shopt_options () +get_shopt_options (void) { char **ret; - int n, i; + int i; + size_t n; n = sizeof (shopt_vars) / sizeof (shopt_vars[0]); ret = strvec_create (n + 1); @@ -812,9 +788,7 @@ get_shopt_options () * REUSABLE is 1 if we want to print output in a form that may be reused. */ int -shopt_setopt (name, mode) - char *name; - int mode; +shopt_setopt (char *name, int mode) { WORD_LIST *wl; int r; @@ -826,9 +800,7 @@ shopt_setopt (name, mode) } int -shopt_listopt (name, reusable) - char *name; - int reusable; +shopt_listopt (char *name, int reusable) { int i; @@ -847,11 +819,12 @@ shopt_listopt (name, reusable) } void -set_bashopts () +set_bashopts (void) { char *value; char tflag[N_SHOPT_OPTIONS]; - int vsize, i, vptr, *ip, exported; + int i, exported; + size_t vsize, vptr; SHELL_VAR *v; for (vsize = i = 0; shopt_vars[i].name; i++) @@ -882,17 +855,12 @@ set_bashopts () v = find_variable ("BASHOPTS"); - /* Turn off the read-only attribute so we can bind the new value, and - note whether or not the variable was exported. */ - if (v) - { - VUNSETATTR (v, att_readonly); - exported = exported_p (v); - } - else - exported = 0; + /* Note whether or not the variable was exported so we can adjust after the + assignment. */ + exported = v ? exported_p (v) : 0; - v = bind_variable ("BASHOPTS", value, 0); + /* ASS_FORCE so we don't have to temporarily turn off readonly */ + v = bind_variable ("BASHOPTS", value, ASS_FORCE); /* Turn the read-only attribute back on, and turn off the export attribute if it was set implicitly by mark_modified_vars and SHELLOPTS was not @@ -905,8 +873,7 @@ set_bashopts () } void -parse_bashopts (value) - char *value; +parse_bashopts (char *value) { char *vname; int vptr, ind; @@ -926,8 +893,7 @@ parse_bashopts (value) } void -initialize_bashopts (no_bashopts) - int no_bashopts; +initialize_bashopts (int no_bashopts) { char *temp; SHELL_VAR *var; @@ -953,14 +919,12 @@ initialize_bashopts (no_bashopts) #if defined (ARRAY_VARS) static int -set_assoc_expand (option_name, mode) - char *option_name; - int mode; +set_array_expand (char *option_name, int mode) { #if 0 /* leave this disabled */ if (shell_compatibility_level <= 51) #endif - assoc_expand_once = expand_once_flag; + array_expand_once = expand_once_flag; return 0; } #endif diff --git a/builtins/source.def b/builtins/source.def index 5b2f994db..41c664f9d 100644 --- a/builtins/source.def +++ b/builtins/source.def @@ -1,7 +1,7 @@ This file is source.def, from which is created source.c. It implements the builtins "." and "source" in Bash. -Copyright (C) 1987-2020 Free Software Foundation, Inc. +Copyright (C) 1987-2024 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -22,13 +22,14 @@ $PRODUCES source.c $BUILTIN source $FUNCTION source_builtin -$SHORT_DOC source filename [arguments] +$SHORT_DOC source [-p path] filename [arguments] Execute commands from a file in the current shell. -Read and execute commands from FILENAME in the current shell. The -entries in $PATH are used to find the directory containing FILENAME. -If any ARGUMENTS are supplied, they become the positional parameters -when FILENAME is executed. +Read and execute commands from FILENAME in the current shell. If the +-p option is supplied, the PATH argument is treated as a colon- +separated list of directories to search for FILENAME. If -p is not +supplied, $PATH is searched to find FILENAME. If any ARGUMENTS are +supplied, they become the positional parameters when FILENAME is executed. Exit Status: Returns the status of the last command executed in FILENAME; fails if @@ -38,13 +39,14 @@ $END $BUILTIN . $DOCNAME dot $FUNCTION source_builtin -$SHORT_DOC . filename [arguments] +$SHORT_DOC . [-p path] filename [arguments] Execute commands from a file in the current shell. -Read and execute commands from FILENAME in the current shell. The -entries in $PATH are used to find the directory containing FILENAME. -If any ARGUMENTS are supplied, they become the positional parameters -when FILENAME is executed. +Read and execute commands from FILENAME in the current shell. If the +-p option is supplied, the PATH argument is treated as a colon- +separated list of directories to search for FILENAME. If -p is not +supplied, $PATH is searched to find FILENAME. If any ARGUMENTS are +supplied, they become the positional parameters when FILENAME is executed. Exit Status: Returns the status of the last command executed in FILENAME; fails if @@ -80,9 +82,10 @@ $END extern int errno; #endif /* !errno */ -static void maybe_pop_dollar_vars PARAMS((void)); +static void uw_maybe_pop_dollar_vars (void *); -/* If non-zero, `.' uses $PATH to look up the script to be sourced. */ +/* If non-zero, `.' uses $PATH to look up the script to be sourced when -p is + not supplied. */ int source_uses_path = 1; /* If non-zero, `.' looks in the current directory if the filename argument @@ -96,7 +99,7 @@ int source_searches_cwd = 1; not executing a shell function, we leave the new values alone and free the saved values. */ static void -maybe_pop_dollar_vars () +uw_maybe_pop_dollar_vars (void *ignore) { if (variable_context == 0 && (dollar_vars_changed () & ARGS_SETBLTIN)) dispose_saved_dollar_vars (); @@ -113,14 +116,26 @@ maybe_pop_dollar_vars () take place in there. So, I open the file, place it into a large string, close the file, and then execute the string. */ int -source_builtin (list) - WORD_LIST *list; +source_builtin (WORD_LIST *list) { - int result; - char *filename, *debug_trap, *x; + int result, search_cwd, opt; + char *filename, *debug_trap, *x, *pathstring; - if (no_options (list)) - return (EX_USAGE); + pathstring = 0; + reset_internal_getopt (); + while ((opt = internal_getopt (list, "p:")) != -1) + { + switch (opt) + { + case 'p': + pathstring = list_optarg; + break; + CASE_HELPOPT; + default: + builtin_usage (); + return (EX_USAGE); + } + } list = loptend; if (list == 0) @@ -131,24 +146,34 @@ source_builtin (list) } #if defined (RESTRICTED_SHELL) - if (restricted && strchr (list->word->word, '/')) + if (restricted && (pathstring || absolute_program (list->word->word))) { sh_restricted (list->word->word); return (EXECUTION_FAILURE); } #endif + /* normalize pathstring */ + if (pathstring && *pathstring == 0) + pathstring = "."; + + /* XXX - If we supply -p PATH, don't default to searching $PWD */ + search_cwd = pathstring == 0 && source_searches_cwd; + filename = (char *)NULL; /* XXX -- should this be absolute_pathname? */ - if (posixly_correct && strchr (list->word->word, '/')) + if (posixly_correct && absolute_program (list->word->word)) filename = savestring (list->word->word); else if (absolute_pathname (list->word->word)) filename = savestring (list->word->word); + else if (pathstring) + filename = find_in_path (list->word->word, pathstring, FS_READABLE); else if (source_uses_path) filename = find_path_file (list->word->word); + if (filename == 0) { - if (source_searches_cwd == 0) + if (search_cwd == 0) { x = printable_filename (list->word->word, 0); builtin_error (_("%s: file not found"), x); @@ -171,7 +196,7 @@ source_builtin (list) if (list->next) { push_dollar_vars (); - add_unwind_protect ((Function *)maybe_pop_dollar_vars, (char *)NULL); + add_unwind_protect (uw_maybe_pop_dollar_vars, NULL); if (debugging_mode || shell_compatibility_level <= 44) init_bash_argv (); /* Initialize BASH_ARGV and BASH_ARGC */ remember_args (list->next, 1); @@ -188,7 +213,7 @@ source_builtin (list) { debug_trap = savestring (debug_trap); add_unwind_protect (xfree, debug_trap); - add_unwind_protect (maybe_set_debug_trap, debug_trap); + add_unwind_protect (uw_maybe_set_debug_trap, debug_trap); restore_default_signal (DEBUG_TRAP); } diff --git a/builtins/suspend.def b/builtins/suspend.def index 4f3a56c9c..73922ef3f 100644 --- a/builtins/suspend.def +++ b/builtins/suspend.def @@ -56,7 +56,7 @@ $END #include "common.h" #include "bashgetopt.h" -static sighandler suspend_continue PARAMS((int)); +static sighandler suspend_continue (int); static SigHandler *old_cont; #if 0 @@ -65,8 +65,7 @@ static SigHandler *old_stop; /* Continue handler. */ static sighandler -suspend_continue (sig) - int sig; +suspend_continue (int sig) { set_signal_handler (SIGCONT, old_cont); #if 0 @@ -78,8 +77,7 @@ suspend_continue (sig) /* Suspending the shell. If -f is the arg, then do the suspend no matter what. Otherwise, complain if a login shell. */ int -suspend_builtin (list) - WORD_LIST *list; +suspend_builtin (WORD_LIST *list) { int opt, force; @@ -98,7 +96,7 @@ suspend_builtin (list) } list = loptend; - no_args (list); + no_args (list, 0); if (force == 0) { diff --git a/builtins/test.def b/builtins/test.def index bd9a203b6..da7870c77 100644 --- a/builtins/test.def +++ b/builtins/test.def @@ -1,7 +1,7 @@ This file is test.def, from which is created test.c. It implements the builtin "test" in Bash. -Copyright (C) 1987-2015 Free Software Foundation, Inc. +Copyright (C) 1987-2015,2022 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -131,8 +131,7 @@ $END /* TEST/[ builtin. */ int -test_builtin (list) - WORD_LIST *list; +test_builtin (WORD_LIST *list) { char **argv; int argc, result; diff --git a/builtins/times.def b/builtins/times.def index f31f43331..b6d9faf25 100644 --- a/builtins/times.def +++ b/builtins/times.def @@ -1,7 +1,7 @@ This file is times.def, from which is created times.c. It implements the builtin "times" in Bash. -Copyright (C) 1987-2009 Free Software Foundation, Inc. +Copyright (C) 1987-2009,2022 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -43,7 +43,6 @@ $END #include #include "../bashtypes.h" -#include "../shell.h" #include @@ -55,12 +54,15 @@ $END # include #endif +#define NEED_CLOCK_FUNCS_DECL +#define NEED_TIMEVAL_FUNCS_DECL + +#include "../shell.h" #include "common.h" /* Print the totals for system and user time used. */ int -times_builtin (list) - WORD_LIST *list; +times_builtin (WORD_LIST *list) { #if defined (HAVE_GETRUSAGE) && defined (HAVE_TIMEVAL) && defined (RUSAGE_SELF) struct rusage self, kids; diff --git a/builtins/trap.def b/builtins/trap.def index 94229433c..f28bde8e8 100644 --- a/builtins/trap.def +++ b/builtins/trap.def @@ -1,7 +1,7 @@ This file is trap.def, from which is created trap.c. It implements the builtin "trap" in Bash. -Copyright (C) 1987-2021 Free Software Foundation, Inc. +Copyright (C) 1987-2023 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -22,31 +22,38 @@ $PRODUCES trap.c $BUILTIN trap $FUNCTION trap_builtin -$SHORT_DOC trap [-lp] [[arg] signal_spec ...] +$SHORT_DOC trap [-Plp] [[action] signal_spec ...] Trap signals and other events. Defines and activates handlers to be run when the shell receives signals or other conditions. -ARG is a command to be read and executed when the shell receives the -signal(s) SIGNAL_SPEC. If ARG is absent (and a single SIGNAL_SPEC +ACTION is a command to be read and executed when the shell receives the +signal(s) SIGNAL_SPEC. If ACTION is absent (and a single SIGNAL_SPEC is supplied) or `-', each specified signal is reset to its original -value. If ARG is the null string each SIGNAL_SPEC is ignored by the +value. If ACTION is the null string each SIGNAL_SPEC is ignored by the shell and by the commands it invokes. -If a SIGNAL_SPEC is EXIT (0) ARG is executed on exit from the shell. If -a SIGNAL_SPEC is DEBUG, ARG is executed before every simple command. If -a SIGNAL_SPEC is RETURN, ARG is executed each time a shell function or a -script run by the . or source builtins finishes executing. A SIGNAL_SPEC -of ERR means to execute ARG each time a command's failure would cause the -shell to exit when the -e option is enabled. +If a SIGNAL_SPEC is EXIT (0) ACTION is executed on exit from the shell. +If a SIGNAL_SPEC is DEBUG, ACTION is executed before every simple command +and selected other commands. If a SIGNAL_SPEC is RETURN, ACTION is +executed each time a shell function or a script run by the . or source +builtins finishes executing. A SIGNAL_SPEC of ERR means to execute ACTION +each time a command's failure would cause the shell to exit when the -e +option is enabled. If no arguments are supplied, trap prints the list of commands associated -with each signal. +with each trapped signal in a form that may be reused as shell input to +restore the same signal dispositions. Options: -l print a list of signal names and their corresponding numbers - -p display the trap commands associated with each SIGNAL_SPEC + -p display the trap commands associated with each SIGNAL_SPEC in a + form that may be reused as shell input; or for all trapped + signals if no arguments are supplied + -P display the trap commands associated with each SIGNAL_SPEC. At least + one SIGNAL_SPEC must be supplied. -P and -p cannot be used + together. Each SIGNAL_SPEC is either a signal name in or a signal number. Signal names are case insensitive and the SIG prefix is optional. A @@ -75,13 +82,13 @@ $END #include "common.h" #include "bashgetopt.h" -static void showtrap PARAMS((int, int)); -static int display_traps PARAMS((WORD_LIST *, int)); +static void showtrap (int, int); +static int display_traps (WORD_LIST *, int); /* The trap command: - trap - trap + trap + trap trap -l trap -p [sigspec ...] trap [--] @@ -97,17 +104,21 @@ static int display_traps PARAMS((WORD_LIST *, int)); #define REVERT 1 /* Revert to this signals original value. */ #define IGNORE 2 /* Ignore this signal. */ +/* Flags saying how to display the trap list. */ +#define DISP_TRAPCMD 1 +#define DISP_ALLSIGS 2 +#define DISP_ACTIONONLY 4 + int -trap_builtin (list) - WORD_LIST *list; +trap_builtin (WORD_LIST *list) { - int list_signal_names, display, result, opt; + int list_signal_names, result, opt, dflags; - list_signal_names = display = 0; + list_signal_names = dflags = 0; result = EXECUTION_SUCCESS; reset_internal_getopt (); - while ((opt = internal_getopt (list, "lp")) != -1) + while ((opt = internal_getopt (list, "lpP")) != -1) { switch (opt) { @@ -115,7 +126,10 @@ trap_builtin (list) list_signal_names++; break; case 'p': - display++; + dflags |= DISP_TRAPCMD; + break; + case 'P': + dflags |= DISP_ACTIONONLY; break; CASE_HELPOPT; default: @@ -127,13 +141,26 @@ trap_builtin (list) opt = DSIG_NOCASE|DSIG_SIGPREFIX; /* flags for decode_signal */ + if ((dflags & DISP_TRAPCMD) && (dflags & DISP_ACTIONONLY)) + { + builtin_error ("cannot specify both -p and -P"); + return EX_USAGE; + } + if ((dflags & DISP_ACTIONONLY) && list == 0) + { + builtin_error ("-P requires at least one signal name"); + return EX_USAGE; + } + if (list_signal_names) return (sh_chkwrite (display_signal_list ((WORD_LIST *)NULL, 1))); - else if (display || list == 0) + else if (dflags || list == 0) { initialize_terminating_signals (); get_all_original_signals (); - return (sh_chkwrite (display_traps (list, display && posixly_correct))); + if (dflags & DISP_TRAPCMD) + dflags |= posixly_correct ? DISP_ALLSIGS : 0; + return (sh_chkwrite (display_traps (list, dflags))); } else { @@ -207,7 +234,13 @@ trap_builtin (list) { case SIGINT: /* XXX - should we do this if original disposition - was SIG_IGN? */ + was SIG_IGN? Yes, because setup_async_signals can + set the original disposition to SIG_IGN to keep + restore_signal from restoring the SIGINT + disposition from when the shell was invoked, and + we want to allow an asynchronous subshell to + use `trap' to restore the default disposition or + set a trap command. */ if (interactive) set_signal_handler (SIGINT, sigint_sighandler); /* special cases for interactive == 0 */ @@ -218,8 +251,13 @@ trap_builtin (list) break; case SIGQUIT: - /* Always ignore SIGQUIT. */ - set_signal_handler (SIGQUIT, SIG_IGN); + /* Always ignore SIGQUIT, but allow a posix-mode shell + that is running asynchronously and has ignored + SIGQUIT to reset it to the default. POSIX interp 751. */ + if (posixly_correct && signal_is_async_ignored (SIGQUIT)) + set_signal_handler (SIGQUIT, termsig_sighandler); + else + set_signal_handler (SIGQUIT, SIG_IGN); break; case SIGTERM: #if defined (JOB_CONTROL) @@ -246,8 +284,7 @@ trap_builtin (list) } static void -showtrap (i, show_default) - int i, show_default; +showtrap (int i, int show_default) { char *t, *p, *sn; int free_t; @@ -286,13 +323,18 @@ showtrap (i, show_default) FREE (t); } +/* Flags saying how to display the trap list. */ +#define DISP_TRAPCMD 1 +#define DISP_ALLSIGS 2 +#define DISP_ACTIONONLY 4 + + static int -display_traps (list, show_all) - WORD_LIST *list; - int show_all; +display_traps (WORD_LIST *list, int flags) { - int result, i; + int result, i, show_all; + show_all = flags & DISP_ALLSIGS; if (list == 0) { for (i = 0; i < BASH_NSIG; i++) @@ -308,6 +350,16 @@ display_traps (list, show_all) sh_invalidsig (list->word->word); result = EXECUTION_FAILURE; } + else if (flags & DISP_ACTIONONLY) + { + char *t; + t = trap_list[i]; + if (t == (char *)DEFAULT_SIG || signal_is_hard_ignored (i)) + continue; + else if (t == (char *)IGNORE_SIG) + t = ""; + printf ("%s\n", t); + } else showtrap (i, show_all); } diff --git a/builtins/type.def b/builtins/type.def index a8e47c0ac..6eaa3f03f 100644 --- a/builtins/type.def +++ b/builtins/type.def @@ -1,7 +1,7 @@ This file is type.def, from which is created type.c. It implements the builtin "type" in Bash. -Copyright (C) 1987-2020 Free Software Foundation, Inc. +Copyright (C) 1987-2023 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -64,6 +64,7 @@ $END #include "../bashintl.h" #include "../shell.h" +#include "../builtins.h" #include "../parser.h" #include "../execute_cmd.h" #include "../findcmd.h" @@ -76,8 +77,6 @@ $END #include "common.h" #include "bashgetopt.h" -extern int find_reserved_word PARAMS((char *)); - /* For each word in LIST, find out what the shell is going to do with it as a simple command. i.e., which file would this shell use to execve, or if it is a builtin command, or an alias. Possible flag @@ -107,8 +106,7 @@ extern int find_reserved_word PARAMS((char *)); */ int -type_builtin (list) - WORD_LIST *list; +type_builtin (WORD_LIST *list) { int dflags, any_failed, opt; WORD_LIST *this; @@ -163,7 +161,7 @@ type_builtin (list) dflags |= CDESC_TYPE; dflags &= ~(CDESC_PATH_ONLY|CDESC_SHORTDESC); break; - case 'P': /* shorthand for type -ap */ + case 'P': /* force path search only plus hash table lookup */ dflags |= (CDESC_PATH_ONLY|CDESC_FORCE_PATH); dflags &= ~(CDESC_TYPE|CDESC_SHORTDESC); break; @@ -210,11 +208,9 @@ type_builtin (list) * return after finding it once. */ int -describe_command (command, dflags) - char *command; - int dflags; +describe_command (char *command, int dflags) { - int found, i, found_file, f, all; + int found, i, found_file, f, all, skipbuiltin; char *full_path, *x, *pathlist; SHELL_VAR *func; #if defined (ALIAS) @@ -242,7 +238,7 @@ describe_command (command, dflags) found = 1; - if (all == 0) + if (all == 0) /* type -p returns, any executable file would not have precedence */ return (1); } #endif /* ALIAS */ @@ -263,6 +259,24 @@ describe_command (command, dflags) return (1); } + /* In posix mode, we find special builtins before shell functions. */ + /* find_shell_builtin sets current_builtin as a side effect */ + skipbuiltin = 0; + if (posixly_correct && (dflags & CDESC_FORCE_PATH) == 0 && find_shell_builtin (command) != 0 && (current_builtin->flags & SPECIAL_BUILTIN)) + { + if (dflags & CDESC_TYPE) + puts ("builtin"); + else if (dflags & CDESC_SHORTDESC) + printf (_("%s is a special shell builtin\n"), command); + else if (dflags & CDESC_REUSABLE) + printf ("%s\n", command); + + skipbuiltin = found = 1; + + if (all == 0) + return (1); + } + /* Command is a function? */ if (((dflags & (CDESC_FORCE_PATH|CDESC_NOFUNCS)) == 0) && (func = find_function (command))) { @@ -289,13 +303,14 @@ describe_command (command, dflags) } /* Command is a builtin? */ - if (((dflags & CDESC_FORCE_PATH) == 0) && find_shell_builtin (command)) + /* find_shell_builtin sets current_builtin as a side effect */ + if (skipbuiltin == 0 && ((dflags & CDESC_FORCE_PATH) == 0) && find_shell_builtin (command)) { if (dflags & CDESC_TYPE) puts ("builtin"); else if (dflags & CDESC_SHORTDESC) { - if (posixly_correct && find_special_builtin (command) != 0) + if (posixly_correct && (current_builtin->flags & SPECIAL_BUILTIN)) printf (_("%s is a special shell builtin\n"), command); else printf (_("%s is a shell builtin\n"), command); @@ -345,7 +360,8 @@ describe_command (command, dflags) printf ("%s\n", full_path); free (full_path); - return (1); + if (all == 0) + return (1); } } @@ -371,6 +387,7 @@ describe_command (command, dflags) probably doesn't exist. Check whether or not the command is an executable file. If it's not, don't report a match. This is the default posix mode behavior */ + /* This code path isn't executed any more as of 3/2023. */ if (STREQ (full_path, command) || posixly_correct) { f = file_status (full_path); diff --git a/builtins/ulimit.def b/builtins/ulimit.def index fd9f7a3df..1251dfa6e 100644 --- a/builtins/ulimit.def +++ b/builtins/ulimit.def @@ -1,7 +1,7 @@ This file is ulimit.def, from which is created ulimit.c. It implements the builtin "ulimit" in Bash. -Copyright (C) 1987-2021 Free Software Foundation, Inc. +Copyright (C) 1987-2025 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -63,9 +63,13 @@ current soft limit, the current hard limit, and no limit, respectively. Otherwise, the current value of the specified resource is printed. If no option is given, then -f is assumed. -Values are in 1024-byte increments, except for -t, which is in seconds, --p, which is in increments of 512 bytes, and -u, which is an unscaled -number of processes. +Values are in 1024-byte increments, except for -t, which is in seconds; +-p, which is in increments of 512 bytes; -R, which is in microseconds; +-b, which is in bytes; and -e, -i, -k, -n, -q, -r, -u, -x, and -P, +which accept unscaled values. + +When in posix mode, values supplied with -c and -f are in 512-byte +increments. Exit Status: Returns success unless an invalid option is supplied or an error occurs. @@ -93,6 +97,7 @@ $END #include "common.h" #include "bashgetopt.h" #include "pipesize.h" +#include #if !defined (errno) extern int errno; @@ -130,7 +135,7 @@ extern int errno; #if !defined (RLIMTYPE) # define RLIMTYPE long -# define string_to_rlimtype(s) strtol(s, (char **)NULL, 10) +# define string_to_rlimtype(s, ep) strtol(s, ep, 10) # define print_rlimtype(num, nl) printf ("%ld%s", num, nl ? "\n" : "") #endif @@ -152,7 +157,9 @@ extern int errno; # define RLIMIT_FILESIZE 256 #endif -#define RLIMIT_PIPESIZE 257 +#ifndef RLIMIT_PIPESIZE +# define RLIMIT_PIPESIZE 257 +#endif #ifdef RLIMIT_NOFILE # define RLIMIT_OPENFILES RLIMIT_NOFILE @@ -204,22 +211,22 @@ extern int errno; #define BLOCKSIZE(x) (((x) == POSIXBLK) ? (posixly_correct ? 512 : 1024) : (x)) -static int _findlim PARAMS((int)); +static int _findlim (int); -static int ulimit_internal PARAMS((int, char *, int, int)); +static int ulimit_internal (int, char *, int, int); -static int get_limit PARAMS((int, RLIMTYPE *, RLIMTYPE *)); -static int set_limit PARAMS((int, RLIMTYPE, int)); +static int get_limit (int, RLIMTYPE *, RLIMTYPE *); +static int set_limit (int, RLIMTYPE, int); -static void printone PARAMS((int, RLIMTYPE, int)); -static void print_all_limits PARAMS((int)); +static void printone (int, RLIMTYPE, int); +static void print_all_limits (int); -static int set_all_limits PARAMS((int, RLIMTYPE)); +static int set_all_limits (int, RLIMTYPE); -static int filesize PARAMS((RLIMTYPE *)); -static int pipesize PARAMS((RLIMTYPE *)); -static int getmaxuprc PARAMS((RLIMTYPE *)); -static int getmaxvm PARAMS((RLIMTYPE *, RLIMTYPE *)); +static int filesize (RLIMTYPE *); +static int pipesize (RLIMTYPE *); +static int getmaxuprc (RLIMTYPE *); +static int getmaxvm (RLIMTYPE *, RLIMTYPE *); typedef struct { int option; /* The ulimit option for this limit. */ @@ -299,13 +306,11 @@ typedef struct _cmd { static ULCMD *cmdlist; static int ncmd; -static int cmdlistsz; +static size_t cmdlistsz; #if !defined (HAVE_RESOURCE) && !defined (HAVE_ULIMIT) long -ulimit (cmd, newlim) - int cmd; - long newlim; +ulimit (int cmd, long newlim) { errno = EINVAL; return -1; @@ -313,8 +318,7 @@ ulimit (cmd, newlim) #endif /* !HAVE_RESOURCE && !HAVE_ULIMIT */ static int -_findlim (opt) - int opt; +_findlim (int opt) { register int i; @@ -329,8 +333,7 @@ static char optstring[4 + 2 * NCMDS]; /* Report or set limits associated with certain per-process resources. See the help documentation in builtins.c for a full description. */ int -ulimit_builtin (list) - register WORD_LIST *list; +ulimit_builtin (WORD_LIST *list) { register char *s; int c, limind, mode, opt, all_limits; @@ -441,14 +444,11 @@ ulimit_builtin (list) if (ulimit_internal (cmdlist[c].cmd, cmdlist[c].arg, mode, ncmd > 1) == EXECUTION_FAILURE) return (EXECUTION_FAILURE); - return (EXECUTION_SUCCESS); + return (sh_chkwrite (EXECUTION_SUCCESS)); } static int -ulimit_internal (cmd, cmdarg, mode, multiple) - int cmd; - char *cmdarg; - int mode, multiple; +ulimit_internal (int cmd, char *cmdarg, int mode, int multiple) { int opt, limind, setting; int block_factor; @@ -461,8 +461,9 @@ ulimit_internal (cmd, cmdarg, mode, multiple) opt = get_limit (limind, &soft_limit, &hard_limit); if (opt < 0) { - builtin_error (_("%s: cannot get limit: %s"), limits[limind].description, - strerror (errno)); + builtin_error ("%s: %s: %s", limits[limind].description, + _("cannot get limit"), + strerror (errno)); return (EXECUTION_FAILURE); } @@ -479,9 +480,16 @@ ulimit_internal (cmd, cmdarg, mode, multiple) real_limit = soft_limit; else if (STREQ (cmdarg, "unlimited")) real_limit = RLIM_INFINITY; - else if (all_digits (cmdarg)) + else if (DIGIT (*cmdarg) && (cmdarg[1] == 0 || DIGIT (cmdarg[1]))) { - limit = string_to_rlimtype (cmdarg); + char *endp; + limit = string_to_rlimtype (cmdarg, &endp); + if (*endp != '\0') + { + sh_invalidnum (cmdarg); + return (EXECUTION_FAILURE); + } + block_factor = BLOCKSIZE(limits[limind].block_factor); real_limit = limit * block_factor; @@ -499,8 +507,9 @@ ulimit_internal (cmd, cmdarg, mode, multiple) if (set_limit (limind, real_limit, mode) < 0) { - builtin_error (_("%s: cannot modify limit: %s"), limits[limind].description, - strerror (errno)); + builtin_error ("%s: %s: %s", limits[limind].description, + _("cannot modify limit"), + strerror (errno)); return (EXECUTION_FAILURE); } @@ -508,9 +517,7 @@ ulimit_internal (cmd, cmdarg, mode, multiple) } static int -get_limit (ind, softlim, hardlim) - int ind; - RLIMTYPE *softlim, *hardlim; +get_limit (int ind, RLIMTYPE *softlim, RLIMTYPE *hardlim) { RLIMTYPE value; #if defined (HAVE_RESOURCE) @@ -569,10 +576,7 @@ get_limit (ind, softlim, hardlim) } static int -set_limit (ind, newlim, mode) - int ind; - RLIMTYPE newlim; - int mode; +set_limit (int ind, RLIMTYPE newlim, int mode) { #if defined (HAVE_RESOURCE) struct rlimit limit; @@ -634,8 +638,7 @@ set_limit (ind, newlim, mode) } static int -getmaxvm (softlim, hardlim) - RLIMTYPE *softlim, *hardlim; +getmaxvm (RLIMTYPE *softlim, RLIMTYPE *hardlim) { #if defined (HAVE_RESOURCE) struct rlimit datalim, stacklim; @@ -657,8 +660,7 @@ getmaxvm (softlim, hardlim) } static int -filesize(valuep) - RLIMTYPE *valuep; +filesize (RLIMTYPE *valuep) { #if !defined (HAVE_RESOURCE) long result; @@ -673,10 +675,22 @@ filesize(valuep) #endif } +/* The longtime problem here is that PIPE_BUF has atomicity restrictions, and + is not the true pipe capacity. Only a few systems can retrieve this at + runtime. */ static int -pipesize (valuep) - RLIMTYPE *valuep; +pipesize (RLIMTYPE *valuep) { +#if defined (HAVE_PATHCONF) && defined (_PC_PIPE_BUF) + long r; + + r = pathconf (".", _PC_PIPE_BUF); + if (r >= 0) + { + *valuep = (RLIMTYPE) r; + return 0; + } +#endif #if defined (PIPE_BUF) /* This is defined on Posix systems. */ *valuep = (RLIMTYPE) PIPE_BUF; @@ -699,8 +713,7 @@ pipesize (valuep) } static int -getmaxuprc (valuep) - RLIMTYPE *valuep; +getmaxuprc (RLIMTYPE *valuep) { long maxchild; @@ -718,8 +731,7 @@ getmaxuprc (valuep) } static void -print_all_limits (mode) - int mode; +print_all_limits (int mode) { register int i; RLIMTYPE softlim, hardlim; @@ -732,16 +744,14 @@ print_all_limits (mode) if (get_limit (i, &softlim, &hardlim) == 0) printone (i, (mode & LIMIT_SOFT) ? softlim : hardlim, 1); else if (errno != EINVAL) - builtin_error ("%s: cannot get limit: %s", limits[i].description, - strerror (errno)); + builtin_error ("%s: %s: %s", limits[i].description, + _("cannot get limit"), + strerror (errno)); } } static void -printone (limind, curlim, pdesc) - int limind; - RLIMTYPE curlim; - int pdesc; +printone (int limind, RLIMTYPE curlim, int pdesc) { char unitstr[64]; int factor; @@ -766,6 +776,7 @@ printone (limind, curlim, pdesc) print_rlimtype ((curlim / factor), 1); } +#ifdef NOTYET /* Set all limits to NEWLIM. NEWLIM currently must be RLIM_INFINITY, which causes all limits to be set as high as possible depending on mode (like csh `unlimit'). Returns -1 if NEWLIM is invalid, 0 if all limits @@ -780,9 +791,7 @@ printone (limind, curlim, pdesc) */ static int -set_all_limits (mode, newlim) - int mode; - RLIMTYPE newlim; +set_all_limits (int mode, RLIMTYPE newlim) { register int i; int retval = 0; @@ -799,11 +808,13 @@ set_all_limits (mode, newlim) for (retval = i = 0; limits[i].option > 0; i++) if (set_limit (i, newlim, mode) < 0) { - builtin_error (_("%s: cannot modify limit: %s"), limits[i].description, - strerror (errno)); + builtin_error ("%s: %s: %s", limits[i].description, + _("cannot modify limit"), + strerror (errno)); retval = 1; } return retval; } +#endif /* NOTYET */ #endif /* !_MINIX */ diff --git a/builtins/umask.def b/builtins/umask.def index 8041d56b7..67d1c1054 100644 --- a/builtins/umask.def +++ b/builtins/umask.def @@ -1,7 +1,7 @@ This file is umask.def, from which is created umask.c. It implements the builtin "umask" in Bash. -Copyright (C) 1987-2020 Free Software Foundation, Inc. +Copyright (C) 1987-2025 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -67,14 +67,13 @@ $END /* */ /* **************************************************************** */ -static void print_symbolic_umask PARAMS((mode_t)); -static int symbolic_umask PARAMS((WORD_LIST *)); +static void print_symbolic_umask (mode_t); +static int symbolic_umask (WORD_LIST *); /* Set or display the mask used by the system when creating files. Flag of -S means display the umask in a symbolic mode. */ int -umask_builtin (list) - WORD_LIST *list; +umask_builtin (WORD_LIST *list) { int print_symbolically, opt, umask_value, pflag; mode_t umask_arg; @@ -146,12 +145,7 @@ umask_builtin (list) /* Print the umask in a symbolic form. In the output, a letter is printed if the corresponding bit is clear in the umask. */ static void -#if defined (__STDC__) print_symbolic_umask (mode_t um) -#else -print_symbolic_umask (um) - mode_t um; -#endif { char ubits[4], gbits[4], obits[4]; /* u=rwx,g=rwx,o=rwx */ int i; @@ -186,17 +180,41 @@ print_symbolic_umask (um) printf ("u=%s,g=%s,o=%s\n", ubits, gbits, obits); } +static inline mode_t +copyuser (mode_t mask) +{ + return ((mask & S_IRUSR) ? S_IRUGO : 0) | + ((mask & S_IWUSR) ? S_IWUGO : 0) | + ((mask & S_IXUSR) ? S_IXUGO : 0); +} + +static inline mode_t +copygroup (mode_t mask) +{ + return ((mask & S_IRGRP) ? S_IRUGO : 0) | + ((mask & S_IWGRP) ? S_IWUGO : 0) | + ((mask & S_IXGRP) ? S_IXUGO : 0); +} + +static inline mode_t +copyother (mode_t mask) +{ + return ((mask & S_IROTH) ? S_IRUGO : 0) | + ((mask & S_IWOTH) ? S_IWUGO : 0) | + ((mask & S_IXOTH) ? S_IXUGO : 0); +} + int -parse_symbolic_mode (mode, initial_bits) - char *mode; - int initial_bits; +parse_symbolic_mode (char *mode, mode_t initial_bits) { - int who, op, perm, bits, c; + char op, c; + mode_t who, perm, bits; char *s; for (s = mode, bits = initial_bits;;) { - who = op = perm = 0; + who = 0; + op = 0; /* Parse the `who' portion of the symbolic mode clause. */ while (member (*s, "agou")) @@ -220,7 +238,13 @@ parse_symbolic_mode (mode, initial_bits) } } + /* default `who' is `a' */ + if (who == 0) + who = S_IRWXU | S_IRWXG | S_IRWXO; + /* The operation is now sitting in *s. */ +start_op: + perm = 0; op = *s++; switch (op) { @@ -233,57 +257,91 @@ parse_symbolic_mode (mode, initial_bits) return (-1); } - /* Parse out the `perm' section of the symbolic mode clause. */ - while (member (*s, "rwx")) + /* Parse out the `action' section of the symbolic mode clause. An + action can be a set of permissions (rwxXst), a copy specification + (ugo), or another op (+-=). */ + while (member (*s, "rwxXstugo")) { - c = *s++; - - switch (c) + switch (*s) { + /* First the copy specification */ + case 'u': + perm = copyuser (initial_bits); + break; + case 'g': + perm = copygroup (initial_bits); + break; + case 'o': + perm = copyother (initial_bits); + break; + + /* Then the permissions. */ case 'r': perm |= S_IRUGO; break; case 'w': perm |= S_IWUGO; break; + case 'X': + /* for chmod, this includes S_ISDIR but that doesn't make sense for umask */ +#if defined (S_IFDIR) + if (this_shell_builtin != umask_builtin && (initial_bits & S_IFDIR) == 0) + break; +#endif + if ((initial_bits & S_IXUGO) == 0) + break; /* no-op if original mask doesn't include execute bits */ + /* FALLTHROUGH */ case 'x': perm |= S_IXUGO; break; + case 's': +#ifdef S_ISUID + perm |= S_ISUID | S_ISGID; + break; +#else + goto spec_error; +#endif + case 't': +#ifdef S_ISVTX + perm |= S_ISVTX; + break; +#else + goto spec_error; +#endif } + s++; } /* Now perform the operation or return an error for a bad permission string. */ - if (!*s || *s == ',') - { - if (who) - perm &= who; - - switch (op) - { - case '+': - bits |= perm; - break; - case '-': - bits &= ~perm; - break; - case '=': - if (who == 0) - who = S_IRWXU | S_IRWXG | S_IRWXO; - bits &= ~who; - bits |= perm; - break; + perm &= who; - /* No other values are possible. */ - } - - if (*s == '\0') - break; - else - s++; /* skip past ',' */ + switch (op) + { + case '+': + bits |= perm; + break; + case '-': + bits &= ~perm; + break; + case '=': + bits &= ~who; + bits |= perm; + break; } + + /* Break if the end of the action string, loop if we're going to parse + another `who', go back to parsing another op if we have an op spec + (+-=). Return an invalid mode character error for everything else. */ + if (*s == '\0') + break; + else if (*s == ',') + s++; /* skip past ',' */ + else if (*s == '+' || *s == '-' || *s == '=') + goto start_op; else { +spec_error: builtin_error (_("`%c': invalid symbolic mode character"), *s); return (-1); } @@ -296,10 +354,10 @@ parse_symbolic_mode (mode, initial_bits) by chmod. If the -S argument is given, then print the umask in a symbolic form. */ static int -symbolic_umask (list) - WORD_LIST *list; +symbolic_umask (WORD_LIST *list) { - int um, bits; + mode_t um; + int bits; /* Get the initial umask. Don't change it yet. */ um = umask (022); diff --git a/builtins/wait.def b/builtins/wait.def index b066d78d0..c8c735aa3 100644 --- a/builtins/wait.def +++ b/builtins/wait.def @@ -1,7 +1,7 @@ -'This file is wait.def, from which is created wait.c. +This file is wait.def, from which is created wait.c. It implements the builtin "wait" in Bash. -Copyright (C) 1987-2021 Free Software Foundation, Inc. +Copyright (C) 1987-2024 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -90,8 +90,9 @@ extern int wait_signal_received; procenv_t wait_intr_buf; int wait_intr_flag; -static int set_waitlist PARAMS((WORD_LIST *)); -static void unset_waitlist PARAMS((void)); +static int set_waitlist (WORD_LIST *); +static void unset_waitlist (void); +static int check_nonjobs (WORD_LIST *, struct procstat *); /* Wait for the pid in LIST to stop or die. If no arguments are given, then wait for all of the active background processes of the shell and return @@ -108,8 +109,7 @@ static void unset_waitlist PARAMS((void)); while (0) int -wait_builtin (list) - WORD_LIST *list; +wait_builtin (WORD_LIST *list) { int status, code, opt, nflag, vflags, bindflags; volatile int wflags; @@ -154,10 +154,10 @@ wait_builtin (list) int arrayflags; SET_VFLAGS (vflags, arrayflags, bindflags); - if (legal_identifier (vname) == 0 && valid_array_reference (vname, arrayflags) == 0) + if (valid_identifier (vname) == 0 && valid_array_reference (vname, arrayflags) == 0) #else bindflags = 0; - if (legal_identifier (vname) == 0) + if (valid_identifier (vname) == 0) #endif { sh_invalidid (vname); @@ -211,6 +211,22 @@ wait_builtin (list) #if defined (JOB_CONTROL) if (nflag) { +#if 1 /* TAG:bash-5.3 stevenpelley@gmail.com 01/22/2024 */ + /* First let's see if there are any requested pids that have already + been removed from the jobs list and saved on bgpids or are terminated + procsubs. */ + if (list) + { + status = check_nonjobs (list, &pstat); + if (status != -1) + { + if (vname) + builtin_bind_var_to_int (vname, pstat.pid, bindflags); + WAIT_RETURN (status); + } + } +#endif + if (list) { opt = set_waitlist (list); @@ -255,7 +271,7 @@ wait_builtin (list) w = list->word->word; if (DIGIT (*w)) { - if (legal_number (w, &pid_value) && pid_value == (pid_t)pid_value) + if (valid_number (w, &pid_value) && pid_value == (pid_t)pid_value) { pid = (pid_t)pid_value; status = wait_for_single_pid (pid, wflags|JWAIT_PERROR); @@ -328,30 +344,49 @@ wait_builtin (list) #if defined (JOB_CONTROL) /* Take each valid pid or jobspec in LIST and mark the corresponding job as - J_WAITING, so wait -n knows which jobs to wait for. Return the number of - jobs we found. */ + J_WAITING, so wait -n knows which jobs to wait for. + If we have process substitutions, allow wait -n to wait for procsubs by + pid by marking them with PROC_WAITING. + Return the number of jobs or procsubs we found. */ static int -set_waitlist (list) - WORD_LIST *list; +set_waitlist (WORD_LIST *list) { sigset_t set, oset; - int job, r, njob; - intmax_t pid; + int job, njob; + intmax_t ipid; + pid_t pid; + PROCESS *child; WORD_LIST *l; BLOCK_CHILD (set, oset); njob = 0; for (l = list; l; l = l->next) { - job = NO_JOB; - job = (l && legal_number (l->word->word, &pid) && pid == (pid_t) pid) - ? get_job_by_pid ((pid_t) pid, 0, 0) - : get_job_spec (l); + child = NULL; + + pid = (l && l->word && valid_number (l->word->word, &ipid) && ipid == (pid_t)ipid) ? (pid_t)ipid : NO_PID; + job = (pid != NO_PID) ? get_job_by_pid (pid, 0, 0) : get_job_spec (l); + if (job == NO_JOB || jobs == 0 || INVALID_JOB (job)) { - sh_badjob (l->word->word); +#if defined (PROCESS_SUBSTITUTION) + child = (pid >= 0) ? procsub_search (pid, 0) : NULL; +#endif + if (child) + { + /* If we don't have a valid job, maybe we have a procsub */ + njob++; + child->flags |= PROC_WAITING; + } + else if (l->word->word[0] == '%') + sh_badjob (l->word->word); + else if (job == BAD_JOBSPEC) + sh_invalidjob (l->word->word); + else + sh_badpid (l->word->word); continue; } + /* We don't check yet to see if one of the desired jobs has already terminated, but we could. We wait until wait_for_any_job(). This has the advantage of validating all the arguments. */ @@ -367,7 +402,7 @@ set_waitlist (list) /* Clean up after a call to wait -n jobs */ static void -unset_waitlist () +unset_waitlist (void) { int i; sigset_t set, oset; @@ -376,6 +411,66 @@ unset_waitlist () for (i = 0; i < js.j_jobslots; i++) if (jobs[i] && (jobs[i]->flags & J_WAITING)) jobs[i]->flags &= ~J_WAITING; +#if defined (PROCESS_SUBSTITUTION) + procsub_unsetflag (ANY_PID, PROC_WAITING, 0); +#endif + UNBLOCK_CHILD (oset); +} + +/* For each pid in LIST, check the bgpids list and the procsub list, if we + have process substitutions. */ +static int +check_nonjobs (WORD_LIST *list, struct procstat *pstat) +{ + sigset_t set, oset; + pid_t pid; + intmax_t ipid; + WORD_LIST *l; + PROCESS *child; + int r, s; + + r = -1; + + BLOCK_CHILD (set, oset); + for (l = list; l; l = l->next) + { + if (l && valid_number (l->word->word, &ipid) && ipid == (pid_t) ipid && ipid >= 0) + pid = ipid; + else if (l && l->word->word[0] == '%') + continue; /* skip job ids for now */ + else + { + r = -1; + continue; + } + + /* check bgpids */ + if ((s = retrieve_proc_status (pid, 0)) != -1) + { + pstat->pid = pid; + pstat->status = r = s; + /* If running in posix mode, `wait -n pid' deletes pid from bgpids, + just like `wait pid'. */ + if (posixly_correct) + delete_proc_status (pid, 0); + break; + } + +#if defined (PROCESS_SUBSTITUTION) + /* If this corresponds to a terminated procsub, return it. */ + if ((child = procsub_search (pid, 0)) && child->running == PS_DONE) + { + pstat->pid = pid; + pstat->status = r = process_exit_status (child->status); + procsub_delete (pid, 0); /* moves to bgpids list */ + if (posixly_correct) + delete_proc_status (pid, 0); + break; + } +#endif + } UNBLOCK_CHILD (oset); + + return r; } #endif diff --git a/command.h b/command.h index 6230354ba..189b00def 100644 --- a/command.h +++ b/command.h @@ -1,7 +1,7 @@ /* command.h -- The structures used internally to represent commands, and the extern declarations of the functions used to create them. */ -/* Copyright (C) 1993-2021 Free Software Foundation, Inc. +/* Copyright (C) 1993-2022 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -49,7 +49,7 @@ enum r_instruction { (ri == r_output_direction || ri == r_err_and_out) #define OUTPUT_REDIRECT(ri) \ - (ri == r_output_direction || ri == r_input_output || ri == r_err_and_out || ri == r_append_err_and_out) + (ri == r_output_direction || ri == r_input_output || ri == r_err_and_out || ri == r_append_err_and_out || ri == r_output_force) #define INPUT_REDIRECT(ri) \ (ri == r_input_direction || ri == r_inputa_direction || ri == r_input_output) @@ -366,6 +366,8 @@ typedef struct subshell_com { #define COPROC_RUNNING 0x01 #define COPROC_DEAD 0x02 +#define COPROC_STOPPED 0x04 +#define COPROC_FOREGROUND 0x08 /* why would you want to do this? */ typedef struct coproc { char *c_name; @@ -398,13 +400,13 @@ extern Coproc sh_coproc; /* Forward declarations of functions declared in copy_cmd.c. */ -extern FUNCTION_DEF *copy_function_def_contents PARAMS((FUNCTION_DEF *, FUNCTION_DEF *)); -extern FUNCTION_DEF *copy_function_def PARAMS((FUNCTION_DEF *)); +extern FUNCTION_DEF *copy_function_def_contents (FUNCTION_DEF *, FUNCTION_DEF *); +extern FUNCTION_DEF *copy_function_def (FUNCTION_DEF *); -extern WORD_DESC *copy_word PARAMS((WORD_DESC *)); -extern WORD_LIST *copy_word_list PARAMS((WORD_LIST *)); -extern REDIRECT *copy_redirect PARAMS((REDIRECT *)); -extern REDIRECT *copy_redirects PARAMS((REDIRECT *)); -extern COMMAND *copy_command PARAMS((COMMAND *)); +extern WORD_DESC *copy_word (WORD_DESC *); +extern WORD_LIST *copy_word_list (WORD_LIST *); +extern REDIRECT *copy_redirect (REDIRECT *); +extern REDIRECT *copy_redirects (REDIRECT *); +extern COMMAND *copy_command (COMMAND *); #endif /* _COMMAND_H_ */ diff --git a/config-bot.h b/config-bot.h index a687e4029..07e910f1e 100644 --- a/config-bot.h +++ b/config-bot.h @@ -36,17 +36,6 @@ # define HAVE_BSD_PGRP #endif -/* Try this without testing __STDC__ for the time being. */ -#if defined (HAVE_STDARG_H) -# define PREFER_STDARG -# define USE_VARARGS -#else -# if defined (HAVE_VARARGS_H) -# define PREFER_VARARGS -# define USE_VARARGS -# endif -#endif - #if defined (HAVE_SYS_SOCKET_H) && defined (HAVE_GETPEERNAME) && defined (HAVE_NETINET_IN_H) # define HAVE_NETWORK #endif diff --git a/config-top.h b/config-top.h index db4ab6ee3..c47ab01b7 100644 --- a/config-top.h +++ b/config-top.h @@ -1,6 +1,6 @@ /* config-top.h - various user-settable options not under the control of autoconf. */ -/* Copyright (C) 2002-2021 Free Software Foundation, Inc. +/* Copyright (C) 2002-2024 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -31,11 +31,6 @@ error messages about multiple directory arguments to `cd'. */ #define CD_COMPLAINS -/* Define BUFFERED_INPUT if you want the shell to do its own input - buffering, rather than using stdio. Do not undefine this; it's - required to preserve semantics required by POSIX. */ -#define BUFFERED_INPUT - /* Define ONESHOT if you want sh -c 'command' to avoid forking to execute `command' whenever possible. This is a big efficiency improvement. */ #define ONESHOT @@ -50,9 +45,9 @@ when a job like `cat jobs.c | exit 1' terminates due to a SIGPIPE. */ #define DONT_REPORT_SIGPIPE -/* Define DONT_REPORT_SIGTERM if you don't want to see `Terminates' message +/* Define DONT_REPORT_SIGTERM if you don't want to see `Terminated' message when a job exits due to SIGTERM, since that's the default signal sent - by the kill builtin. */ + by the kill builtin. Only effective for non-interactive shells. */ #define DONT_REPORT_SIGTERM /* Define DONT_REPORT_BROKEN_PIPE_WRITE_ERRORS if you don't want builtins @@ -74,7 +69,7 @@ the Posix.2 confstr () function, or CS_PATH define are not present. */ #ifndef STANDARD_UTILS_PATH #define STANDARD_UTILS_PATH \ - "/bin:/usr/bin:/sbin:/usr/sbin:/etc:/usr/etc" + "/bin:/usr/bin:/sbin:/usr/sbin" #endif /* The default path for enable -f */ @@ -145,7 +140,7 @@ /* Define as 1 if you want to enable code that implements multiple coprocs executing simultaneously */ #ifndef MULTIPLE_COPROCS -# define MULTIPLE_COPROCS 0 +# define MULTIPLE_COPROCS 1 #endif /* Define to 0 if you want the checkwinsize option off by default, 1 if you @@ -199,3 +194,18 @@ /* Undefine or define to 0 if you don't want to allow associative array assignment using a compound list of key-value pairs. */ #define ASSOC_KVPAIR_ASSIGNMENT 1 + +/* Define if you want read errors in non-interactive shells to be fatal + errors instead of the historical practice of treating them as EOF. The + next version of POSIX will require this (interp 1629). */ +#define FATAL_READERROR 1 + +/* Define to 0 if you want the `patsub_replacement' shell option to be disabled + by default. */ +#ifndef PATSUB_REPLACE_DEFAULT +#define PATSUB_REPLACE_DEFAULT 1 +#endif + +/* Define to 1 if you want posix mode to restrict shell function names to + shell NAMEs. */ +/* #define POSIX_RESTRICT_FUNCNAME 0 */ diff --git a/config.h.in b/config.h.in index d6d52930b..1367eaaa7 100644 --- a/config.h.in +++ b/config.h.in @@ -1,6 +1,6 @@ /* config.h -- Configuration file for bash. */ -/* Copyright (C) 1987-2009,2011-2012,2013-2019 Free Software Foundation, Inc. +/* Copyright (C) 1987-2009,2011-2012,2013-2024 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -178,6 +178,9 @@ /* Define to allow functions to be imported from the environment. */ #undef FUNCTION_IMPORT +/* Define to make the `bash_source_fullpath' option enabled by default. */ +#undef BASH_SOURCE_FULLPATH_DEFAULT + /* Define AFS if you are using Transarc's AFS. */ #undef AFS @@ -239,6 +242,8 @@ /* The number of bytes in a `wchar_t', if supported */ #undef SIZEOF_WCHAR_T +#undef HAVE_C_BOOL + /* System paths */ #define DEFAULT_MAIL_DIRECTORY "/usr/spool/mail" @@ -345,8 +350,11 @@ #undef uintmax_t /* Define to integer type wide enough to hold a pointer if doesn't define. */ +#undef intptr_t + +/* Define to unsigned integer type wide enough to hold a pointer if doesn't define. */ #undef uintptr_t - + /* Define to `int' if doesn't define. */ #undef uid_t @@ -426,6 +434,8 @@ #undef HAVE_STRUCT_DIRENT_D_NAMLEN +#undef HAVE_STRUCT_DIRENT_D_TYPE + #undef TIOCSTAT_IN_SYS_IOCTL #undef FIONREAD_IN_SYS_IOCTL @@ -477,6 +487,8 @@ /* Define if you have and it defines AUDIT_USER_TTY */ #undef HAVE_DECL_AUDIT_USER_TTY +#undef HAVE_DECL_BRK + #undef HAVE_DECL_CONFSTR #undef HAVE_DECL_PRINTF @@ -505,6 +517,22 @@ #undef HAVE_DECL_STRTOULL #undef HAVE_DECL_STRTOUMAX +/* These are checked with BASH_FUNC_UNLOCKED_IO */ + +#undef HAVE_DECL_CLEARERR_UNLOCKED +#undef HAVE_DECL_FEOF_UNLOCKED +#undef HAVE_DECL_FERROR_UNLOCKED +#undef HAVE_DECL_FFLUSH_UNLOCKED +#undef HAVE_DECL_FGETS_UNLOCKED +#undef HAVE_DECL_FPUTC_UNLOCKED +#undef HAVE_DECL_FPUTS_UNLOCKED +#undef HAVE_DECL_FREAD_UNLOCKED +#undef HAVE_DECL_FWRITE_UNLOCKED +#undef HAVE_DECL_GETC_UNLOCKED +#undef HAVE_DECL_GETCHAR_UNLOCKED +#undef HAVE_DECL_PUTC_UNLOCKED +#undef HAVE_DECL_PUTCHAR_UNLOCKED + /* Characteristics of system calls and C library functions. */ /* Define if the `getpgrp' function takes no argument. */ @@ -571,12 +599,18 @@ /* Define if you have the bcopy function. */ #undef HAVE_BCOPY +/* Define if you have the brk function. */ +#undef HAVE_BRK + /* Define if you have the bzero function. */ #undef HAVE_BZERO /* Define if you have the chown function. */ #undef HAVE_CHOWN +/* Define if you have the clock_gettime function. */ +#undef HAVE_CLOCK_GETTIME + /* Define if you have the confstr function. */ #undef HAVE_CONFSTR @@ -738,12 +772,18 @@ /* Define if you have the mbscmp function. */ #undef HAVE_MBSCMP +/* Define if you have the mbsncmp function. */ +#undef HAVE_MBSNCMP + /* Define if you have the mbsnrtowcs function. */ #undef HAVE_MBSNRTOWCS /* Define if you have the mbsrtowcs function. */ #undef HAVE_MBSRTOWCS +/* Define if you have the memfd_create function. */ +#undef HAVE_MEMFD_CREATE + /* Define if you have the memmove function. */ #undef HAVE_MEMMOVE @@ -822,6 +862,12 @@ #undef HAVE_SETRESUID #undef HAVE_DECL_SETRESUID +/* Define if you have the shm_open function. */ +#undef HAVE_SHM_OPEN + +/* Define if you have the shm_mkstemp function. */ +#undef HAVE_SHM_MKSTEMP + /* Define if you have the setvbuf function. */ #undef HAVE_SETVBUF @@ -834,6 +880,9 @@ /* Define if you have the snprintf function. */ #undef HAVE_SNPRINTF +/* Define if you have the statfs function. */ +#undef HAVE_STATFS + /* Define if you have the strcasecmp function. */ #undef HAVE_STRCASECMP @@ -855,6 +904,9 @@ /* Define if you have the strftime function. */ #undef HAVE_STRFTIME +/* Define if you have the strlcat function. */ +#undef HAVE_STRLCAT + /* Define if you have the strnlen function. */ #undef HAVE_STRNLEN @@ -900,6 +952,12 @@ /* Define if you have the tcgetpgrp function. */ #undef HAVE_TCGETPGRP +/* Define if you have the tcgetwinsize function. */ +#undef HAVE_TCGETWINSIZE + +/* Define if you have the tcsetwinsize function. */ +#undef HAVE_TCSETWINSIZE + /* Define if you have the times function. */ #undef HAVE_TIMES @@ -948,6 +1006,9 @@ /* Define if you have the wcsdup function. */ #undef HAVE_WCSDUP +/* Define if you have the wcsnrtombs function. */ +#undef HAVE_WCSNRTOMBS + /* Define if you have the wctype function. */ #undef HAVE_WCTYPE @@ -1166,6 +1227,32 @@ /* Additional defines for configuring lib/intl, maintained by autoscan/autoheader */ +/* System characteristics */ +#undef HAVE_LC_MESSAGE +#undef HAVE_LOCALE_NULL +#undef HAVE_NAMELESS_LOCALES +#undef HAVE_PER_THREAD_LOCALE +#undef HAVE_SOLARIS114_LOCALES + +/* Compiler characteristics */ +#undef FLEXIBLE_ARRAY_MEMBER + +#undef HAVE_VISIBILITY + +#undef HAVE_BUILTIN_EXPECT + +#undef HAVE_WEAK_SYMBOLS + +#define _GL_ATTRIBUTE_MALLOC +#define _GL_ATTRIBUTE_DEALLOC_FREE +#define _GL_ATTRIBUTE_FALLTHROUGH +#define _GL_ATTRIBUTE_PURE +#define _GL_UNUSED + +#define _GL_INLINE_HEADER_BEGIN +#define _GL_INLINE_HEADER_END +#define _GL_EXTERN_INLINE + /* Define if you have the header file. */ #undef HAVE_ARGZ_H @@ -1175,15 +1262,41 @@ /* Define if you have the header file. */ #undef HAVE_FCNTL_H +#undef HAVE_INTTYPES_H_WITH_UINTMAX + /* Define if you have the header file. */ #undef HAVE_MALLOC_H +#undef HAVE_STDINT_H_WITH_UINTMAX + /* Define if you have the header file. */ #undef HAVE_STDIO_EXT_H +/* Define if you have the header file. */ +#undef HAVE_THREADS_H + +/* Define if you have the header file. */ +#undef HAVE_XLOCALE_H + +/* Declarations */ +#undef HAVE_DECL_FEOF_UNLOCKED +#undef HAVE_DECL_FGETS_UNLOCKED +#undef HAVE_DECL__SNPRINTF +#undef HAVE_DECL__SNWPRINTF + /* Define if you have the `dcgettext' function. */ #undef HAVE_DCGETTEXT +#undef HAVE_GETUID +#undef HAVE_GETEUID + +#undef HAVE_GETGID +#undef HAVE_GETEGID + +#undef HAVE_GETLOCALENAME_L +#undef HAVE_GOOD_USELOCALE +#undef HAVE_ICONV + /* Define if you have the `localeconv' function. */ #undef HAVE_LOCALECONV @@ -1202,9 +1315,25 @@ /* Define if you have the `munmap' function. */ #undef HAVE_MUNMAP +/* Define if you have the `nanosleep' function. */ +#undef HAVE_NANOSLEEP + +/* Define if you have the `newlocale' function. */ +#undef HAVE_NEWLOCALE + /* Define if you have the `nl_langinfo' function. */ #undef HAVE_NL_LANGINFO +#undef HAVE_POSIX_PRINTF + +#undef HAVE_PTHREAD_API +#undef HAVE_PTHREAD_MUTEX_RECURSIVE +#undef HAVE_PTHREAD_RWLOCK +#undef HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER + +#undef HAVE_SNPRINTF_RETVAL_C99 +#undef HAVE_SNPRINTF_TRUNCATION_C99 + /* Define if you have the `stpcpy' function. */ #undef HAVE_STPCPY @@ -1214,6 +1343,18 @@ /* Define if you have the `strdup' function. */ #undef HAVE_STRDUP +#undef HAVE_TSEARCH + +/* Define if you have the `uselocale' function. */ +#undef HAVE_USELOCALE +#undef HAVE_WORKING_USELOCALE + +#undef HAVE_WCSLEN +#undef HAVE_WCSNLEN + +/* Define if you have the `wprintf' function. */ +#undef HAVE_WPRINTF + /* Define if you have the `__argz_count' function. */ #undef HAVE___ARGZ_COUNT @@ -1223,6 +1364,14 @@ /* Define if you have the `__argz_stringify' function. */ #undef HAVE___ARGZ_STRINGIFY +#undef HAVE___FSETLOCKING + +/* macOS specific defines */ + +#undef HAVE_CFLOCALECOPYPREFERREDLANGUAGES + +#undef HAVE_CFPREFERENCESCOPYAPPVALUE + /* End additions for lib/intl */ #include "config-bot.h" diff --git a/configure b/configure index 56e8e6fb6..a28a3fcfe 100755 --- a/configure +++ b/configure @@ -1,12 +1,12 @@ #! /bin/sh -# From configure.ac for Bash 5.2, version 5.046. +# From configure.ac for Bash 5.3, version 5.080. # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.71 for bash 5.2-release. +# Generated by GNU Autoconf 2.72 for bash 5.3-release. # # Report bugs to . # # -# Copyright (C) 1992-1996, 1998-2017, 2020-2021 Free Software Foundation, +# Copyright (C) 1992-1996, 1998-2017, 2020-2023 Free Software Foundation, # Inc. # # @@ -18,7 +18,6 @@ # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh -as_nop=: if test ${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1 then : emulate sh @@ -27,12 +26,13 @@ then : # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST -else $as_nop - case `(set -o) 2>/dev/null` in #( +else case e in #( + e) case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; +esac ;; esac fi @@ -104,7 +104,7 @@ IFS=$as_save_IFS ;; esac -# We did not find ourselves, most probably we were run as `sh COMMAND' +# We did not find ourselves, most probably we were run as 'sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 @@ -134,15 +134,14 @@ case $- in # (((( esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail -# out after a failed `exec'. +# out after a failed 'exec'. printf "%s\n" "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi # We don't want this to propagate to other subprocesses. { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then - as_bourne_compatible="as_nop=: -if test \${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1 + as_bourne_compatible="if test \${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1 then : emulate sh NULLCMD=: @@ -150,12 +149,13 @@ then : # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST -else \$as_nop - case \`(set -o) 2>/dev/null\` in #( +else case e in #( + e) case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; +esac ;; esac fi " @@ -173,8 +173,9 @@ as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ) then : -else \$as_nop - exitcode=1; echo positional parameters were not saved. +else case e in #( + e) exitcode=1; echo positional parameters were not saved. ;; +esac fi test x\$exitcode = x0 || exit 1 blah=\$(echo \$(echo blah)) @@ -188,14 +189,15 @@ test \$(( 1 + 1 )) = 2 || exit 1" if (eval "$as_required") 2>/dev/null then : as_have_required=yes -else $as_nop - as_have_required=no +else case e in #( + e) as_have_required=no ;; +esac fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null then : -else $as_nop - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +else case e in #( + e) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do @@ -228,12 +230,13 @@ IFS=$as_save_IFS if $as_found then : -else $as_nop - if { test -f "$SHELL" || test -f "$SHELL.exe"; } && +else case e in #( + e) if { test -f "$SHELL" || test -f "$SHELL.exe"; } && as_run=a "$SHELL" -c "$as_bourne_compatible""$as_required" 2>/dev/null then : CONFIG_SHELL=$SHELL as_have_required=yes -fi +fi ;; +esac fi @@ -255,7 +258,7 @@ case $- in # (((( esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail -# out after a failed `exec'. +# out after a failed 'exec'. printf "%s\n" "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi @@ -275,7 +278,8 @@ $0: manually run the script under such a shell if you do $0: have one." fi exit 1 -fi +fi ;; +esac fi fi SHELL=${CONFIG_SHELL-/bin/sh} @@ -314,14 +318,6 @@ as_fn_exit () as_fn_set_status $1 exit $1 } # as_fn_exit -# as_fn_nop -# --------- -# Do nothing but, unlike ":", preserve the value of $?. -as_fn_nop () -{ - return $? -} -as_nop=as_fn_nop # as_fn_mkdir_p # ------------- @@ -390,11 +386,12 @@ then : { eval $1+=\$2 }' -else $as_nop - as_fn_append () +else case e in #( + e) as_fn_append () { eval $1=\$$1\$2 - } + } ;; +esac fi # as_fn_append # as_fn_arith ARG... @@ -408,21 +405,14 @@ then : { as_val=$(( $* )) }' -else $as_nop - as_fn_arith () +else case e in #( + e) as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` - } + } ;; +esac fi # as_fn_arith -# as_fn_nop -# --------- -# Do nothing but, unlike ":", preserve the value of $?. -as_fn_nop () -{ - return $? -} -as_nop=as_fn_nop # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- @@ -496,6 +486,8 @@ as_cr_alnum=$as_cr_Letters$as_cr_digits /[$]LINENO/= ' <$as_myself | sed ' + t clear + :clear s/[$]LINENO.*/&-/ t lineno b @@ -544,7 +536,6 @@ esac as_echo='printf %s\n' as_echo_n='printf %s' - rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file @@ -556,9 +547,9 @@ if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -pR'. + # 1) On MSYS, both 'ln -s file dir' and 'ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; 'ln -s' creates a wrapper executable. + # In both cases, we have to default to 'cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then @@ -583,10 +574,12 @@ as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. -as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" +as_sed_cpp="y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g" +as_tr_cpp="eval sed '$as_sed_cpp'" # deprecated # Sed expression to map a string onto a valid variable name. -as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" +as_sed_sh="y%*+%pp%;s%[^_$as_cr_alnum]%_%g" +as_tr_sh="eval sed '$as_sed_sh'" # deprecated test -n "$DJDIR" || exec 7<&0 /dev/null && - as_fn_error $? "invalid feature name: \`$ac_useropt'" + as_fn_error $? "invalid feature name: '$ac_useropt'" ac_useropt_orig=$ac_useropt ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1053,7 +1054,7 @@ do ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid feature name: \`$ac_useropt'" + as_fn_error $? "invalid feature name: '$ac_useropt'" ac_useropt_orig=$ac_useropt ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1266,7 +1267,7 @@ do ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid package name: \`$ac_useropt'" + as_fn_error $? "invalid package name: '$ac_useropt'" ac_useropt_orig=$ac_useropt ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1282,7 +1283,7 @@ do ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid package name: \`$ac_useropt'" + as_fn_error $? "invalid package name: '$ac_useropt'" ac_useropt_orig=$ac_useropt ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1312,8 +1313,8 @@ do | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; - -*) as_fn_error $? "unrecognized option: \`$ac_option' -Try \`$0 --help' for more information" + -*) as_fn_error $? "unrecognized option: '$ac_option' +Try '$0 --help' for more information" ;; *=*) @@ -1321,7 +1322,7 @@ Try \`$0 --help' for more information" # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) - as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; + as_fn_error $? "invalid variable name: '$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; @@ -1371,7 +1372,7 @@ do as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done -# There might be people who depend on the old broken behavior: `$host' +# There might be people who depend on the old broken behavior: '$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias @@ -1439,7 +1440,7 @@ if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi -ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" +ac_msg="sources are in $srcdir, but 'cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` @@ -1467,7 +1468,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures bash 5.2-release to adapt to many kinds of systems. +'configure' configures bash 5.3-release to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1481,11 +1482,11 @@ Configuration: --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit - -q, --quiet, --silent do not print \`checking ...' messages + -q, --quiet, --silent do not print 'checking ...' messages --cache-file=FILE cache test results in FILE [disabled] - -C, --config-cache alias for \`--cache-file=config.cache' + -C, --config-cache alias for '--cache-file=config.cache' -n, --no-create do not create output files - --srcdir=DIR find the sources in DIR [configure dir or \`..'] + --srcdir=DIR find the sources in DIR [configure dir or '..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX @@ -1493,10 +1494,10 @@ Installation directories: --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] -By default, \`make install' will install all the files in -\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify -an installation prefix other than \`$ac_default_prefix' using \`--prefix', -for instance \`--prefix=\$HOME'. +By default, 'make install' will install all the files in +'$ac_default_prefix/bin', '$ac_default_prefix/lib' etc. You can specify +an installation prefix other than '$ac_default_prefix' using '--prefix', +for instance '--prefix=\$HOME'. For better control, use the options below. @@ -1533,7 +1534,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of bash 5.2-release:";; + short | recursive ) echo "Configuration of bash 5.3-release:";; esac cat <<\_ACEOF @@ -1551,6 +1552,8 @@ Optional Features: --enable-array-variables include shell array variables --enable-bang-history turn on csh-style history substitution + --enable-bash-source-fullpath-default + enable the bash_source_fullpath option by default --enable-brace-expansion include brace expansion --enable-casemod-attributes @@ -1619,10 +1622,11 @@ Optional Features: --enable-static-link link bash statically, for use as a root shell --disable-largefile omit support for large files --disable-nls do not use Native Language Support - --enable-threads={posix|solaris|pth|windows} + --enable-threads={isoc|posix|isoc+posix|windows} specify multithreading API --disable-threads build without multithread safety --disable-rpath do not hardcode runtime library paths + --enable-year2038 support timestamps after 2038 Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] @@ -1636,8 +1640,6 @@ Optional Packages: use a version of the readline library that is already installed --with-gnu-ld assume the C compiler uses GNU ld [default=no] - --with-libpth-prefix[=DIR] search for libpth in DIR/include and DIR/lib - --without-libpth-prefix don't search for libpth in includedir and libdir --with-libiconv-prefix[=DIR] search for libiconv in DIR/include and DIR/lib --without-libiconv-prefix don't search for libiconv in includedir and libdir --with-included-gettext use the GNU gettext library included here @@ -1665,15 +1667,15 @@ Some influential environment variables: LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory - CPP C preprocessor - YACC The `Yet Another Compiler Compiler' implementation to use. - Defaults to the first program found out of: `bison -y', `byacc', - `yacc'. + YACC The 'Yet Another Compiler Compiler' implementation to use. + Defaults to the first program found out of: 'bison -y', 'byacc', + 'yacc'. YFLAGS The list of arguments that will be passed by default to $YACC. This script will default YFLAGS to the empty string to avoid a - default value of `-d' given by some make applications. + default value of '-d' given by some make applications. + CPP C preprocessor -Use these variables to override the choices made by `configure' or to help +Use these variables to override the choices made by 'configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to . @@ -1740,10 +1742,10 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -bash configure 5.2-release -generated by GNU Autoconf 2.71 +bash configure 5.3-release +generated by GNU Autoconf 2.72 -Copyright (C) 2021 Free Software Foundation, Inc. +Copyright (C) 2023 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF @@ -1782,11 +1784,12 @@ printf "%s\n" "$ac_try_echo"; } >&5 } && test -s conftest.$ac_objext then : ac_retval=0 -else $as_nop - printf "%s\n" "$as_me: failed program was:" >&5 +else case e in #( + e) printf "%s\n" "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_retval=1 + ac_retval=1 ;; +esac fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval @@ -1805,8 +1808,8 @@ printf %s "checking for $2... " >&6; } if eval test \${$3+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> @@ -1814,10 +1817,12 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : eval "$3=yes" -else $as_nop - eval "$3=no" +else case e in #( + e) eval "$3=no" ;; +esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi eval ac_res=\$$3 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 @@ -1826,44 +1831,6 @@ printf "%s\n" "$ac_res" >&6; } } # ac_fn_c_check_header_compile -# ac_fn_c_try_cpp LINENO -# ---------------------- -# Try to preprocess conftest.$ac_ext, and return whether this succeeded. -ac_fn_c_try_cpp () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { { ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -printf "%s\n" "$ac_try_echo"; } >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } > conftest.i && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - } -then : - ac_retval=0 -else $as_nop - printf "%s\n" "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_cpp - # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. @@ -1895,11 +1862,12 @@ printf "%s\n" "$ac_try_echo"; } >&5 } then : ac_retval=0 -else $as_nop - printf "%s\n" "$as_me: failed program was:" >&5 +else case e in #( + e) printf "%s\n" "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_retval=1 + ac_retval=1 ;; +esac fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would @@ -1922,15 +1890,15 @@ printf %s "checking for $2... " >&6; } if eval test \${$3+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Define $2 to an innocuous variant, in case declares $2. For example, HP-UX 11i declares gettimeofday. */ #define $2 innocuous_$2 /* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $2 (); below. */ + which can conflict with char $2 (void); below. */ #include #undef $2 @@ -1941,7 +1909,7 @@ else $as_nop #ifdef __cplusplus extern "C" #endif -char $2 (); +char $2 (void); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ @@ -1960,11 +1928,13 @@ _ACEOF if ac_fn_c_try_link "$LINENO" then : eval "$3=yes" -else $as_nop - eval "$3=no" +else case e in #( + e) eval "$3=no" ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext + conftest$ac_exeext conftest.$ac_ext ;; +esac fi eval ac_res=\$$3 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 @@ -2003,12 +1973,13 @@ printf "%s\n" "$ac_try_echo"; } >&5 test $ac_status = 0; }; } then : ac_retval=0 -else $as_nop - printf "%s\n" "$as_me: program exited with status $ac_status" >&5 +else case e in #( + e) printf "%s\n" "$as_me: program exited with status $ac_status" >&5 printf "%s\n" "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_retval=$ac_status + ac_retval=$ac_status ;; +esac fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno @@ -2016,6 +1987,45 @@ fi } # ac_fn_c_try_run +# ac_fn_c_try_cpp LINENO +# ---------------------- +# Try to preprocess conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_cpp () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +printf "%s\n" "$ac_try_echo"; } >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } > conftest.i && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + } +then : + ac_retval=0 +else case e in #( + e) printf "%s\n" "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 ;; +esac +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_cpp + # ac_fn_c_check_type LINENO TYPE VAR INCLUDES # ------------------------------------------- # Tests whether TYPE exists after having included INCLUDES, setting cache @@ -2028,8 +2038,8 @@ printf %s "checking for $2... " >&6; } if eval test \${$3+y} then : printf %s "(cached) " >&6 -else $as_nop - eval "$3=no" +else case e in #( + e) eval "$3=no" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 @@ -2059,12 +2069,14 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : -else $as_nop - eval "$3=yes" +else case e in #( + e) eval "$3=yes" ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi eval ac_res=\$$3 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 @@ -2086,8 +2098,8 @@ printf %s "checking whether $as_decl_name is declared... " >&6; } if eval test \${$3+y} then : printf %s "(cached) " >&6 -else $as_nop - as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'` +else case e in #( + e) as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'` eval ac_save_FLAGS=\$$6 as_fn_append $6 " $5" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -2111,12 +2123,14 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : eval "$3=yes" -else $as_nop - eval "$3=no" +else case e in #( + e) eval "$3=no" ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext eval $6=\$ac_save_FLAGS - + ;; +esac fi eval ac_res=\$$3 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 @@ -2170,18 +2184,19 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_hi=$ac_mid; break -else $as_nop - as_fn_arith $ac_mid + 1 && ac_lo=$as_val +else case e in #( + e) as_fn_arith $ac_mid + 1 && ac_lo=$as_val if test $ac_lo -le $ac_mid; then ac_lo= ac_hi= break fi - as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val + as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext done -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int @@ -2216,20 +2231,23 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_lo=$ac_mid; break -else $as_nop - as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val +else case e in #( + e) as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val if test $ac_mid -le $ac_hi; then ac_lo= ac_hi= break fi - as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val + as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext done -else $as_nop - ac_lo= ac_hi= +else case e in #( + e) ac_lo= ac_hi= ;; +esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext # Binary search between lo and hi bounds. @@ -2252,8 +2270,9 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_hi=$ac_mid -else $as_nop - as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val +else case e in #( + e) as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext done @@ -2301,8 +2320,9 @@ _ACEOF if ac_fn_c_try_run "$LINENO" then : echo >>conftest.val; read $3 &6; } if eval test \${$4+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $5 int @@ -2343,8 +2363,8 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : eval "$4=yes" -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $5 int @@ -2360,12 +2380,15 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : eval "$4=yes" -else $as_nop - eval "$4=no" +else case e in #( + e) eval "$4=no" ;; +esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi eval ac_res=\$$4 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 @@ -2397,8 +2420,8 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by bash $as_me 5.2-release, which was -generated by GNU Autoconf 2.71. Invocation command line was +It was created by bash $as_me 5.3-release, which was +generated by GNU Autoconf 2.72. Invocation command line was $ $0$ac_configure_args_raw @@ -2644,10 +2667,10 @@ esac printf "%s\n" "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ - || { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} + || { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file -See \`config.log' for more details" "$LINENO" 5; } +See 'config.log' for more details" "$LINENO" 5; } fi done @@ -2683,9 +2706,7 @@ struct stat; /* Most of the following tests are stolen from RCS 5.7 src/conf.sh. */ struct buf { int x; }; struct buf * (*rcsopen) (struct buf *, struct stat *, int); -static char *e (p, i) - char **p; - int i; +static char *e (char **p, int i) { return p[i]; } @@ -2699,6 +2720,21 @@ static char *f (char * (*g) (char **, int), char **p, ...) return s; } +/* C89 style stringification. */ +#define noexpand_stringify(a) #a +const char *stringified = noexpand_stringify(arbitrary+token=sequence); + +/* C89 style token pasting. Exercises some of the corner cases that + e.g. old MSVC gets wrong, but not very hard. */ +#define noexpand_concat(a,b) a##b +#define expand_concat(a,b) noexpand_concat(a,b) +extern int vA; +extern int vbee; +#define aye A +#define bee B +int *pvA = &expand_concat(v,aye); +int *pvbee = &noexpand_concat(v,bee); + /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not \xHH hex character constants. These do not provoke an error unfortunately, instead are silently treated @@ -2726,16 +2762,19 @@ ok |= (argc == 0 || f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]); # Test code for whether the C compiler supports C99 (global declarations) ac_c_conftest_c99_globals=' -// Does the compiler advertise C99 conformance? +/* Does the compiler advertise C99 conformance? */ #if !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L # error "Compiler does not advertise C99 conformance" #endif +// See if C++-style comments work. + #include extern int puts (const char *); extern int printf (const char *, ...); extern int dprintf (int, const char *, ...); extern void *malloc (size_t); +extern void free (void *); // Check varargs macros. These examples are taken from C99 6.10.3.5. // dprintf is used instead of fprintf to avoid needing to declare @@ -2785,7 +2824,6 @@ typedef const char *ccp; static inline int test_restrict (ccp restrict text) { - // See if C++-style comments work. // Iterate through items via the restricted pointer. // Also check for declarations in for loops. for (unsigned int i = 0; *(text+i) != '\''\0'\''; ++i) @@ -2851,6 +2889,8 @@ ac_c_conftest_c99_main=' ia->datasize = 10; for (int i = 0; i < ia->datasize; ++i) ia->data[i] = i * 1.234; + // Work around memory leak warnings. + free (ia); // Check named initializers. struct named_init ni = { @@ -2872,7 +2912,7 @@ ac_c_conftest_c99_main=' # Test code for whether the C compiler supports C11 (global declarations) ac_c_conftest_c11_globals=' -// Does the compiler advertise C11 conformance? +/* Does the compiler advertise C11 conformance? */ #if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112L # error "Compiler does not advertise C11 conformance" #endif @@ -2987,9 +3027,11 @@ as_fn_append ac_header_c_list " sys/types.h sys_types_h HAVE_SYS_TYPES_H" as_fn_append ac_header_c_list " unistd.h unistd_h HAVE_UNISTD_H" as_fn_append ac_header_c_list " wchar.h wchar_h HAVE_WCHAR_H" as_fn_append ac_header_c_list " minix/config.h minix_config_h HAVE_MINIX_CONFIG_H" +as_fn_append ac_header_c_list " stdbool.h stdbool_h HAVE_STDBOOL_H" gt_needs="$gt_needs need-ngettext" as_fn_append ac_header_c_list " sys/param.h sys_param_h HAVE_SYS_PARAM_H" as_fn_append ac_func_c_list " getpagesize HAVE_GETPAGESIZE" +as_fn_append ac_header_c_list " threads.h threads_h HAVE_THREADS_H" as_fn_append ac_func_c_list " symlink HAVE_SYMLINK" as_fn_append ac_func_c_list " uselocale HAVE_USELOCALE" as_fn_append ac_header_c_list " xlocale.h xlocale_h HAVE_XLOCALE_H" @@ -3079,8 +3121,9 @@ IFS=$as_save_IFS if $as_found then : -else $as_nop - as_fn_error $? "cannot find required auxiliary files:$ac_missing_aux_files" "$LINENO" 5 +else case e in #( + e) as_fn_error $? "cannot find required auxiliary files:$ac_missing_aux_files" "$LINENO" 5 ;; +esac fi @@ -3108,12 +3151,12 @@ for ac_var in $ac_precious_vars; do eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 -printf "%s\n" "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: '$ac_var' was set to '$ac_old_val' in the previous run" >&5 +printf "%s\n" "$as_me: error: '$ac_var' was set to '$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 -printf "%s\n" "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: '$ac_var' was not set in the previous run" >&5 +printf "%s\n" "$as_me: error: '$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) @@ -3122,18 +3165,18 @@ printf "%s\n" "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 -printf "%s\n" "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: '$ac_var' has changed since the previous run:" >&5 +printf "%s\n" "$as_me: error: '$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 -printf "%s\n" "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in '$ac_var' since the previous run:" >&5 +printf "%s\n" "$as_me: warning: ignoring whitespace changes in '$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 -printf "%s\n" "$as_me: former value: \`$ac_old_val'" >&2;} - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 -printf "%s\n" "$as_me: current value: \`$ac_new_val'" >&2;} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: former value: '$ac_old_val'" >&5 +printf "%s\n" "$as_me: former value: '$ac_old_val'" >&2;} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: current value: '$ac_new_val'" >&5 +printf "%s\n" "$as_me: current value: '$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. @@ -3149,11 +3192,11 @@ printf "%s\n" "$as_me: current value: \`$ac_new_val'" >&2;} fi done if $ac_cache_corrupted; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 printf "%s\n" "$as_me: error: changes in the environment can compromise the build" >&2;} - as_fn_error $? "run \`${MAKE-make} distclean' and/or \`rm $cache_file' + as_fn_error $? "run '${MAKE-make} distclean' and/or 'rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## @@ -3172,10 +3215,10 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu -ac_config_headers="$ac_config_headers config.h" +ac_config_headers="$ac_config_headers config.h buildconf.h" -BASHVERS=5.2 +BASHVERS=5.3 RELSTATUS=release case "$RELSTATUS" in @@ -3195,15 +3238,16 @@ printf %s "checking build system type... " >&6; } if test ${ac_cv_build+y} then : printf %s "(cached) " >&6 -else $as_nop - ac_build_alias=$build_alias +else case e in #( + e) ac_build_alias=$build_alias test "x$ac_build_alias" = x && ac_build_alias=`$SHELL "${ac_aux_dir}config.guess"` test "x$ac_build_alias" = x && as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 ac_cv_build=`$SHELL "${ac_aux_dir}config.sub" $ac_build_alias` || as_fn_error $? "$SHELL ${ac_aux_dir}config.sub $ac_build_alias failed" "$LINENO" 5 - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 printf "%s\n" "$ac_cv_build" >&6; } @@ -3230,14 +3274,15 @@ printf %s "checking host system type... " >&6; } if test ${ac_cv_host+y} then : printf %s "(cached) " >&6 -else $as_nop - if test "x$host_alias" = x; then +else case e in #( + e) if test "x$host_alias" = x; then ac_cv_host=$ac_cv_build else ac_cv_host=`$SHELL "${ac_aux_dir}config.sub" $host_alias` || as_fn_error $? "$SHELL ${ac_aux_dir}config.sub $host_alias failed" "$LINENO" 5 fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 printf "%s\n" "$ac_cv_host" >&6; } @@ -3282,7 +3327,7 @@ m68k-sysv) opt_bash_malloc=no ;; # fixes file descriptor leak in closedir # These need additional investigation sparc-linux*) opt_bash_malloc=no ;; # sparc running linux; requires ELF *-aix*) opt_bash_malloc=no ;; # AIX machines -*-cygwin*) opt_bash_malloc=no ;; # Cygnus's CYGWIN environment +*-cygwin*|msys*) opt_bash_malloc=no ;; # Cygnus's CYGWIN environment # These lack a working sbrk(2) aarch64-freebsd*) opt_bash_malloc=no ;; riscv*-freebsd*) opt_bash_malloc=no ;; @@ -3298,6 +3343,8 @@ riscv*-freebsd*) opt_bash_malloc=no ;; *-nsk*) opt_bash_malloc=no ;; # HP NonStop *-haiku*) opt_bash_malloc=no ;; # Haiku OS *-genode*) opt_bash_malloc=no ;; # Genode has no sbrk +i370-openedition*) opt_bash_malloc=no LOCAL_LIBS=-lzoslib LIBS_FOR_BUILD=-lzoslib ;; # IBM z/OS machines +i370-*) opt_bash_malloc=no ;; # generic (?) IBM 370 machines esac # memory scrambling on free() @@ -3415,6 +3462,7 @@ opt_function_import=yes opt_dev_fd_stat_broken=no opt_alt_array_impl=no opt_translatable_strings=yes +opt_bash_source_fullpath_default=no ARRAY_O=array.o @@ -3440,6 +3488,7 @@ if test $opt_minimal_config = yes; then opt_casemod_attrs=no opt_casemod_expansions=no opt_extglob_default=no opt_translatable_strings=no opt_globascii_default=yes + opt_bash_source_fullpath_default=no fi # Check whether --enable-alias was given. @@ -3472,6 +3521,12 @@ then : enableval=$enable_bang_history; opt_bang_history=$enableval fi +# Check whether --enable-bash-source-fullpath-default was given. +if test ${enable_bash_source_fullpath_default+y} +then : + enableval=$enable_bash_source_fullpath_default; opt_bash_source_fullpath_default=$enableval +fi + # Check whether --enable-brace-expansion was given. if test ${enable_brace_expansion+y} then : @@ -3837,6 +3892,13 @@ fi if test $opt_translatable_strings = yes; then printf "%s\n" "#define TRANSLATABLE_STRINGS 1" >>confdefs.h +fi +if test $opt_bash_source_fullpath_default = yes; then +printf "%s\n" "#define BASH_SOURCE_FULLPATH_DEFAULT 1" >>confdefs.h + +else +printf "%s\n" "#define BASH_SOURCE_FULLPATH_DEFAULT 0" >>confdefs.h + fi if test $opt_memscramble = yes; then @@ -3915,8 +3977,8 @@ printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_CC+y} then : printf %s "(cached) " >&6 -else $as_nop - if test -n "$CC"; then +else case e in #( + e) if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -3938,7 +4000,8 @@ done done IFS=$as_save_IFS -fi +fi ;; +esac fi CC=$ac_cv_prog_CC if test -n "$CC"; then @@ -3960,8 +4023,8 @@ printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_CC+y} then : printf %s "(cached) " >&6 -else $as_nop - if test -n "$ac_ct_CC"; then +else case e in #( + e) if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -3983,7 +4046,8 @@ done done IFS=$as_save_IFS -fi +fi ;; +esac fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then @@ -4018,8 +4082,8 @@ printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_CC+y} then : printf %s "(cached) " >&6 -else $as_nop - if test -n "$CC"; then +else case e in #( + e) if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -4041,7 +4105,8 @@ done done IFS=$as_save_IFS -fi +fi ;; +esac fi CC=$ac_cv_prog_CC if test -n "$CC"; then @@ -4063,8 +4128,8 @@ printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_CC+y} then : printf %s "(cached) " >&6 -else $as_nop - if test -n "$CC"; then +else case e in #( + e) if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no @@ -4103,7 +4168,8 @@ if test $ac_prog_rejected = yes; then ac_cv_prog_CC="$as_dir$ac_word${1+' '}$@" fi fi -fi +fi ;; +esac fi CC=$ac_cv_prog_CC if test -n "$CC"; then @@ -4127,8 +4193,8 @@ printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_CC+y} then : printf %s "(cached) " >&6 -else $as_nop - if test -n "$CC"; then +else case e in #( + e) if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -4150,7 +4216,8 @@ done done IFS=$as_save_IFS -fi +fi ;; +esac fi CC=$ac_cv_prog_CC if test -n "$CC"; then @@ -4176,8 +4243,8 @@ printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_CC+y} then : printf %s "(cached) " >&6 -else $as_nop - if test -n "$ac_ct_CC"; then +else case e in #( + e) if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -4199,7 +4266,8 @@ done done IFS=$as_save_IFS -fi +fi ;; +esac fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then @@ -4237,8 +4305,8 @@ printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_CC+y} then : printf %s "(cached) " >&6 -else $as_nop - if test -n "$CC"; then +else case e in #( + e) if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -4260,7 +4328,8 @@ done done IFS=$as_save_IFS -fi +fi ;; +esac fi CC=$ac_cv_prog_CC if test -n "$CC"; then @@ -4282,8 +4351,8 @@ printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_CC+y} then : printf %s "(cached) " >&6 -else $as_nop - if test -n "$ac_ct_CC"; then +else case e in #( + e) if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -4305,7 +4374,8 @@ done done IFS=$as_save_IFS -fi +fi ;; +esac fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then @@ -4334,10 +4404,10 @@ fi fi -test -z "$CC" && { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +test -z "$CC" && { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH -See \`config.log' for more details" "$LINENO" 5; } +See 'config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 @@ -4409,8 +4479,8 @@ printf "%s\n" "$ac_try_echo"; } >&5 printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then : - # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. -# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' + # Autoconf-2.13 could set the ac_cv_exeext variable to 'no'. +# So ignore a value of 'no', otherwise this would lead to 'EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. @@ -4430,7 +4500,7 @@ do ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not - # safe: cross compilers may not add the suffix if given an `-o' + # safe: cross compilers may not add the suffix if given an '-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. @@ -4441,8 +4511,9 @@ do done test "$ac_cv_exeext" = no && ac_cv_exeext= -else $as_nop - ac_file='' +else case e in #( + e) ac_file='' ;; +esac fi if test -z "$ac_file" then : @@ -4451,13 +4522,14 @@ printf "%s\n" "no" >&6; } printf "%s\n" "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables -See \`config.log' for more details" "$LINENO" 5; } -else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } +See 'config.log' for more details" "$LINENO" 5; } +else case e in #( + e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 printf %s "checking for C compiler default output file name... " >&6; } @@ -4481,10 +4553,10 @@ printf "%s\n" "$ac_try_echo"; } >&5 printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then : - # If both `conftest.exe' and `conftest' are `present' (well, observable) -# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will -# work properly (i.e., refer to `conftest.exe'), while it won't with -# `rm'. + # If both 'conftest.exe' and 'conftest' are 'present' (well, observable) +# catch 'conftest.exe'. For instance with Cygwin, 'ls conftest' will +# work properly (i.e., refer to 'conftest.exe'), while it won't with +# 'rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in @@ -4494,11 +4566,12 @@ for ac_file in conftest.exe conftest conftest.*; do * ) break;; esac done -else $as_nop - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details" "$LINENO" 5; } +See 'config.log' for more details" "$LINENO" 5; } ;; +esac fi rm -f conftest conftest$ac_cv_exeext { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 @@ -4514,6 +4587,8 @@ int main (void) { FILE *f = fopen ("conftest.out", "w"); + if (!f) + return 1; return ferror (f) || fclose (f) != 0; ; @@ -4553,26 +4628,27 @@ printf "%s\n" "$ac_try_echo"; } >&5 if test "$cross_compiling" = maybe; then cross_compiling=yes else - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} as_fn_error 77 "cannot run C compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details" "$LINENO" 5; } +If you meant to cross compile, use '--host'. +See 'config.log' for more details" "$LINENO" 5; } fi fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 printf "%s\n" "$cross_compiling" >&6; } -rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out +rm -f conftest.$ac_ext conftest$ac_cv_exeext \ + conftest.o conftest.obj conftest.out ac_clean_files=$ac_clean_files_save { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 printf %s "checking for suffix of object files... " >&6; } if test ${ac_cv_objext+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -4604,16 +4680,18 @@ then : break;; esac done -else $as_nop - printf "%s\n" "$as_me: failed program was:" >&5 +else case e in #( + e) printf "%s\n" "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile -See \`config.log' for more details" "$LINENO" 5; } +See 'config.log' for more details" "$LINENO" 5; } ;; +esac fi -rm -f conftest.$ac_cv_objext conftest.$ac_ext +rm -f conftest.$ac_cv_objext conftest.$ac_ext ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 printf "%s\n" "$ac_cv_objext" >&6; } @@ -4624,8 +4702,8 @@ printf %s "checking whether the compiler supports GNU C... " >&6; } if test ${ac_cv_c_compiler_gnu+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -4642,12 +4720,14 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_compiler_gnu=yes -else $as_nop - ac_compiler_gnu=no +else case e in #( + e) ac_compiler_gnu=no ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 printf "%s\n" "$ac_cv_c_compiler_gnu" >&6; } @@ -4665,8 +4745,8 @@ printf %s "checking whether $CC accepts -g... " >&6; } if test ${ac_cv_prog_cc_g+y} then : printf %s "(cached) " >&6 -else $as_nop - ac_save_c_werror_flag=$ac_c_werror_flag +else case e in #( + e) ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" @@ -4684,8 +4764,8 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_cv_prog_cc_g=yes -else $as_nop - CFLAGS="" +else case e in #( + e) CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -4700,8 +4780,8 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : -else $as_nop - ac_c_werror_flag=$ac_save_c_werror_flag +else case e in #( + e) ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -4718,12 +4798,15 @@ if ac_fn_c_try_compile "$LINENO" then : ac_cv_prog_cc_g=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - ac_c_werror_flag=$ac_save_c_werror_flag + ac_c_werror_flag=$ac_save_c_werror_flag ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 printf "%s\n" "$ac_cv_prog_cc_g" >&6; } @@ -4750,8 +4833,8 @@ printf %s "checking for $CC option to enable C11 features... " >&6; } if test ${ac_cv_prog_cc_c11+y} then : printf %s "(cached) " >&6 -else $as_nop - ac_cv_prog_cc_c11=no +else case e in #( + e) ac_cv_prog_cc_c11=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -4768,25 +4851,28 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam test "x$ac_cv_prog_cc_c11" != "xno" && break done rm -f conftest.$ac_ext -CC=$ac_save_CC +CC=$ac_save_CC ;; +esac fi if test "x$ac_cv_prog_cc_c11" = xno then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 printf "%s\n" "unsupported" >&6; } -else $as_nop - if test "x$ac_cv_prog_cc_c11" = x +else case e in #( + e) if test "x$ac_cv_prog_cc_c11" = x then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 printf "%s\n" "none needed" >&6; } -else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c11" >&5 +else case e in #( + e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c11" >&5 printf "%s\n" "$ac_cv_prog_cc_c11" >&6; } - CC="$CC $ac_cv_prog_cc_c11" + CC="$CC $ac_cv_prog_cc_c11" ;; +esac fi ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c11 - ac_prog_cc_stdc=c11 + ac_prog_cc_stdc=c11 ;; +esac fi fi if test x$ac_prog_cc_stdc = xno @@ -4796,8 +4882,8 @@ printf %s "checking for $CC option to enable C99 features... " >&6; } if test ${ac_cv_prog_cc_c99+y} then : printf %s "(cached) " >&6 -else $as_nop - ac_cv_prog_cc_c99=no +else case e in #( + e) ac_cv_prog_cc_c99=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -4814,25 +4900,28 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam test "x$ac_cv_prog_cc_c99" != "xno" && break done rm -f conftest.$ac_ext -CC=$ac_save_CC +CC=$ac_save_CC ;; +esac fi if test "x$ac_cv_prog_cc_c99" = xno then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 printf "%s\n" "unsupported" >&6; } -else $as_nop - if test "x$ac_cv_prog_cc_c99" = x +else case e in #( + e) if test "x$ac_cv_prog_cc_c99" = x then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 printf "%s\n" "none needed" >&6; } -else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c99" >&5 +else case e in #( + e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c99" >&5 printf "%s\n" "$ac_cv_prog_cc_c99" >&6; } - CC="$CC $ac_cv_prog_cc_c99" + CC="$CC $ac_cv_prog_cc_c99" ;; +esac fi ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99 - ac_prog_cc_stdc=c99 + ac_prog_cc_stdc=c99 ;; +esac fi fi if test x$ac_prog_cc_stdc = xno @@ -4842,8 +4931,8 @@ printf %s "checking for $CC option to enable C89 features... " >&6; } if test ${ac_cv_prog_cc_c89+y} then : printf %s "(cached) " >&6 -else $as_nop - ac_cv_prog_cc_c89=no +else case e in #( + e) ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -4860,25 +4949,28 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext -CC=$ac_save_CC +CC=$ac_save_CC ;; +esac fi if test "x$ac_cv_prog_cc_c89" = xno then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 printf "%s\n" "unsupported" >&6; } -else $as_nop - if test "x$ac_cv_prog_cc_c89" = x +else case e in #( + e) if test "x$ac_cv_prog_cc_c89" = x then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 printf "%s\n" "none needed" >&6; } -else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 +else case e in #( + e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 printf "%s\n" "$ac_cv_prog_cc_c89" >&6; } - CC="$CC $ac_cv_prog_cc_c89" + CC="$CC $ac_cv_prog_cc_c89" ;; +esac fi ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89 - ac_prog_cc_stdc=c89 + ac_prog_cc_stdc=c89 ;; +esac fi fi @@ -4939,8 +5031,8 @@ printf %s "checking whether it is safe to define __EXTENSIONS__... " >&6; } if test ${ac_cv_safe_to_define___extensions__+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ # define __EXTENSIONS__ 1 @@ -4956,10 +5048,12 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_cv_safe_to_define___extensions__=yes -else $as_nop - ac_cv_safe_to_define___extensions__=no +else case e in #( + e) ac_cv_safe_to_define___extensions__=no ;; +esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_safe_to_define___extensions__" >&5 printf "%s\n" "$ac_cv_safe_to_define___extensions__" >&6; } @@ -4969,8 +5063,8 @@ printf %s "checking whether _XOPEN_SOURCE should be defined... " >&6; } if test ${ac_cv_should_define__xopen_source+y} then : printf %s "(cached) " >&6 -else $as_nop - ac_cv_should_define__xopen_source=no +else case e in #( + e) ac_cv_should_define__xopen_source=no if test $ac_cv_header_wchar_h = yes then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -4989,8 +5083,8 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _XOPEN_SOURCE 500 @@ -5008,10 +5102,12 @@ if ac_fn_c_try_compile "$LINENO" then : ac_cv_should_define__xopen_source=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext -fi +fi ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_should_define__xopen_source" >&5 printf "%s\n" "$ac_cv_should_define__xopen_source" >&6; } @@ -5036,6 +5132,8 @@ printf "%s\n" "$ac_cv_should_define__xopen_source" >&6; } printf "%s\n" "#define __STDC_WANT_IEC_60559_DFP_EXT__ 1" >>confdefs.h + printf "%s\n" "#define __STDC_WANT_IEC_60559_EXT__ 1" >>confdefs.h + printf "%s\n" "#define __STDC_WANT_IEC_60559_FUNCS_EXT__ 1" >>confdefs.h printf "%s\n" "#define __STDC_WANT_IEC_60559_TYPES_EXT__ 1" >>confdefs.h @@ -5055,8 +5153,9 @@ then : printf "%s\n" "#define _POSIX_1_SOURCE 2" >>confdefs.h -else $as_nop - MINIX= +else case e in #( + e) MINIX= ;; +esac fi if test $ac_cv_safe_to_define___extensions__ = yes then : @@ -5074,31 +5173,34 @@ if test ${enable_largefile+y} then : enableval=$enable_largefile; fi - -if test "$enable_largefile" != no; then - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for special C compiler options needed for large files" >&5 -printf %s "checking for special C compiler options needed for large files... " >&6; } -if test ${ac_cv_sys_largefile_CC+y} +if test "$enable_largefile,$enable_year2038" != no,no +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable large file support" >&5 +printf %s "checking for $CC option to enable large file support... " >&6; } +if test ${ac_cv_sys_largefile_opts+y} then : printf %s "(cached) " >&6 -else $as_nop - ac_cv_sys_largefile_CC=no - if test "$GCC" != yes; then - ac_save_CC=$CC - while :; do - # IRIX 6.2 and later do not support large files by default, - # so use the C compiler's -n32 option if that helps. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) ac_save_CC="$CC" + ac_opt_found=no + for ac_opt in "none needed" "-D_FILE_OFFSET_BITS=64" "-D_LARGE_FILES=1" "-n32"; do + if test x"$ac_opt" != x"none needed" +then : + CC="$ac_save_CC $ac_opt" +fi + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include - /* Check that off_t can represent 2**63 - 1 correctly. - We can't simply define LARGE_OFF_T to be 9223372036854775807, +#ifndef FTYPE +# define FTYPE off_t +#endif + /* Check that FTYPE can represent 2**63 - 1 correctly. + We can't simply define LARGE_FTYPE to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 31 << 31) - 1 + ((off_t) 1 << 31 << 31)) - int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 - && LARGE_OFF_T % 2147483647 == 1) +#define LARGE_FTYPE (((FTYPE) 1 << 31 << 31) - 1 + ((FTYPE) 1 << 31 << 31)) + int FTYPE_is_large[(LARGE_FTYPE % 2147483629 == 721 + && LARGE_FTYPE % 2147483647 == 1) ? 1 : -1]; int main (void) @@ -5108,47 +5210,88 @@ main (void) return 0; } _ACEOF - if ac_fn_c_try_compile "$LINENO" +if ac_fn_c_try_compile "$LINENO" then : - break -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam - CC="$CC -n32" + if test x"$ac_opt" = x"none needed" +then : + # GNU/Linux s390x and alpha need _FILE_OFFSET_BITS=64 for wide ino_t. + CC="$CC -DFTYPE=ino_t" if ac_fn_c_try_compile "$LINENO" then : - ac_cv_sys_largefile_CC=' -n32'; break + +else case e in #( + e) CC="$CC -D_FILE_OFFSET_BITS=64" + if ac_fn_c_try_compile "$LINENO" +then : + ac_opt='-D_FILE_OFFSET_BITS=64' +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam - break - done - CC=$ac_save_CC - rm -f conftest.$ac_ext - fi fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_largefile_CC" >&5 -printf "%s\n" "$ac_cv_sys_largefile_CC" >&6; } - if test "$ac_cv_sys_largefile_CC" != no; then - CC=$CC$ac_cv_sys_largefile_CC - fi + ac_cv_sys_largefile_opts=$ac_opt + ac_opt_found=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + test $ac_opt_found = no || break + done + CC="$ac_save_CC" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for _FILE_OFFSET_BITS value needed for large files" >&5 -printf %s "checking for _FILE_OFFSET_BITS value needed for large files... " >&6; } -if test ${ac_cv_sys_file_offset_bits+y} + test $ac_opt_found = yes || ac_cv_sys_largefile_opts="support not detected" ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_largefile_opts" >&5 +printf "%s\n" "$ac_cv_sys_largefile_opts" >&6; } + +ac_have_largefile=yes +case $ac_cv_sys_largefile_opts in #( + "none needed") : + ;; #( + "supported through gnulib") : + ;; #( + "support not detected") : + ac_have_largefile=no ;; #( + "-D_FILE_OFFSET_BITS=64") : + +printf "%s\n" "#define _FILE_OFFSET_BITS 64" >>confdefs.h + ;; #( + "-D_LARGE_FILES=1") : + +printf "%s\n" "#define _LARGE_FILES 1" >>confdefs.h + ;; #( + "-n32") : + CC="$CC -n32" ;; #( + *) : + as_fn_error $? "internal error: bad value for \$ac_cv_sys_largefile_opts" "$LINENO" 5 ;; +esac + +if test "$enable_year2038" != no +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option for timestamps after 2038" >&5 +printf %s "checking for $CC option for timestamps after 2038... " >&6; } +if test ${ac_cv_sys_year2038_opts+y} then : printf %s "(cached) " >&6 -else $as_nop - while :; do - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) ac_save_CPPFLAGS="$CPPFLAGS" + ac_opt_found=no + for ac_opt in "none needed" "-D_TIME_BITS=64" "-D__MINGW_USE_VC2005_COMPAT" "-U_USE_32_BIT_TIME_T -D__MINGW_USE_VC2005_COMPAT"; do + if test x"$ac_opt" != x"none needed" +then : + CPPFLAGS="$ac_save_CPPFLAGS $ac_opt" +fi + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include - /* Check that off_t can represent 2**63 - 1 correctly. - We can't simply define LARGE_OFF_T to be 9223372036854775807, - since some C++ compilers masquerading as C compilers - incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 31 << 31) - 1 + ((off_t) 1 << 31 << 31)) - int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 - && LARGE_OFF_T % 2147483647 == 1) - ? 1 : -1]; + + #include + /* Check that time_t can represent 2**32 - 1 correctly. */ + #define LARGE_TIME_T \\ + ((time_t) (((time_t) 1 << 30) - 1 + 3 * ((time_t) 1 << 30))) + int verify_time_t_range[(LARGE_TIME_T / 65537 == 65535 + && LARGE_TIME_T % 65537 == 0) + ? 1 : -1]; + int main (void) { @@ -5159,122 +5302,49 @@ main (void) _ACEOF if ac_fn_c_try_compile "$LINENO" then : - ac_cv_sys_file_offset_bits=no; break + ac_cv_sys_year2038_opts="$ac_opt" + ac_opt_found=yes fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#define _FILE_OFFSET_BITS 64 -#include - /* Check that off_t can represent 2**63 - 1 correctly. - We can't simply define LARGE_OFF_T to be 9223372036854775807, - since some C++ compilers masquerading as C compilers - incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 31 << 31) - 1 + ((off_t) 1 << 31 << 31)) - int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 - && LARGE_OFF_T % 2147483647 == 1) - ? 1 : -1]; -int -main (void) -{ + test $ac_opt_found = no || break + done + CPPFLAGS="$ac_save_CPPFLAGS" + test $ac_opt_found = yes || ac_cv_sys_year2038_opts="support not detected" ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_year2038_opts" >&5 +printf "%s\n" "$ac_cv_sys_year2038_opts" >&6; } - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - ac_cv_sys_file_offset_bits=64; break -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - ac_cv_sys_file_offset_bits=unknown - break -done -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_file_offset_bits" >&5 -printf "%s\n" "$ac_cv_sys_file_offset_bits" >&6; } -case $ac_cv_sys_file_offset_bits in #( - no | unknown) ;; - *) -printf "%s\n" "#define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits" >>confdefs.h -;; +ac_have_year2038=yes +case $ac_cv_sys_year2038_opts in #( + "none needed") : + ;; #( + "support not detected") : + ac_have_year2038=no ;; #( + "-D_TIME_BITS=64") : + +printf "%s\n" "#define _TIME_BITS 64" >>confdefs.h + ;; #( + "-D__MINGW_USE_VC2005_COMPAT") : + +printf "%s\n" "#define __MINGW_USE_VC2005_COMPAT 1" >>confdefs.h + ;; #( + "-U_USE_32_BIT_TIME_T"*) : + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "the 'time_t' type is currently forced to be 32-bit. It +will stop working after mid-January 2038. Remove +_USE_32BIT_TIME_T from the compiler flags. +See 'config.log' for more details" "$LINENO" 5; } ;; #( + *) : + as_fn_error $? "internal error: bad value for \$ac_cv_sys_year2038_opts" "$LINENO" 5 ;; esac -rm -rf conftest* - if test $ac_cv_sys_file_offset_bits = unknown; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for _LARGE_FILES value needed for large files" >&5 -printf %s "checking for _LARGE_FILES value needed for large files... " >&6; } -if test ${ac_cv_sys_large_files+y} -then : - printf %s "(cached) " >&6 -else $as_nop - while :; do - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - /* Check that off_t can represent 2**63 - 1 correctly. - We can't simply define LARGE_OFF_T to be 9223372036854775807, - since some C++ compilers masquerading as C compilers - incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 31 << 31) - 1 + ((off_t) 1 << 31 << 31)) - int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 - && LARGE_OFF_T % 2147483647 == 1) - ? 1 : -1]; -int -main (void) -{ - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - ac_cv_sys_large_files=no; break fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#define _LARGE_FILES 1 -#include - /* Check that off_t can represent 2**63 - 1 correctly. - We can't simply define LARGE_OFF_T to be 9223372036854775807, - since some C++ compilers masquerading as C compilers - incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 31 << 31) - 1 + ((off_t) 1 << 31 << 31)) - int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 - && LARGE_OFF_T % 2147483647 == 1) - ? 1 : -1]; -int -main (void) -{ - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - ac_cv_sys_large_files=1; break -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - ac_cv_sys_large_files=unknown - break -done -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_large_files" >&5 -printf "%s\n" "$ac_cv_sys_large_files" >&6; } -case $ac_cv_sys_large_files in #( - no | unknown) ;; - *) -printf "%s\n" "#define _LARGE_FILES $ac_cv_sys_large_files" >>confdefs.h -;; -esac -rm -rf conftest* - fi fi - SIGNAMES_O= SIGNAMES_H=lsignames.h @@ -5282,27 +5352,30 @@ SIGNAMES_H=lsignames.h CROSS_COMPILE= if test "x$cross_compiling" = "xyes"; then - case "${host}" in - *-cygwin*) - cross_cache=${srcdir}/cross-build/cygwin32.cache - ;; - *-mingw*) - cross_cache=${srcdir}/cross-build/cygwin32.cache - ;; - i[3456]86-*-beos*) - cross_cache=${srcdir}/cross-build/x86-beos.cache - ;; - *-qnx*) - cross_cache=${srcdir}/cross-build/qnx.cache - ;; - *) echo "configure: cross-compiling for $host is not supported" >&2 - ;; - esac - if test -n "${cross_cache}" && test -r "${cross_cache}"; then - echo "loading cross-build cache file ${cross_cache}" - . ${cross_cache} - fi - unset cross_cache +# case "${host}" in +# *-cygwin*) +# cross_cache=${srcdir}/cross-build/cygwin32.cache +# ;; +# *-msys*) +# cross_cache=${srcdir}/cross-build/msys32.cache +# ;; +# *-mingw*) +# cross_cache=${srcdir}/cross-build/cygwin32.cache +# ;; +# i[[3456]]86-*-beos*) +# cross_cache=${srcdir}/cross-build/x86-beos.cache +# ;; +# *-qnx*) +# cross_cache=${srcdir}/cross-build/qnx.cache +# ;; +# *) echo "configure: cross-compiling for $host is not supported" >&2 +# ;; +# esac +# if test -n "${cross_cache}" && test -r "${cross_cache}"; then +# echo "loading cross-build cache file ${cross_cache}" +# . ${cross_cache} +# fi +# unset cross_cache SIGNAMES_O='signames.o' CROSS_COMPILE='-DCROSS_COMPILING' @@ -5333,7 +5406,8 @@ if test "$opt_static_link" = yes; then if test "$GCC" = "yes"; then STATIC_LD="-static" case "$host_os" in - solaris2*|linux*) ;; + solaris2*) ;; + linux*) test "$opt_profiling" = "no" && LDFLAGS="$LDFLAGS -static" ;; *) LDFLAGS="$LDFLAGS -static" ;; # XXX experimental esac fi @@ -5353,11 +5427,9 @@ if test "X$cross_compiling" = "Xno"; then # CFLAGS set above to default value if not passed in environment if test -n "$want_auto_cflags" ; then CFLAGS_FOR_BUILD="${CFLAGS}" - BASE_CFLAGS_FOR_BUILD="${CFLAGS}" else # passed in environment CFLAGS_FOR_BUILD=${CFLAGS-'$(CFLAGS)'} - BASE_CFLAGS_FOR_BUILD=${CFLAGS-'$(CFLAGS)'} fi LIBS_FOR_BUILD=${LIBS_FOR_BUILD-'$(LIBS)'} else @@ -5365,7 +5437,6 @@ else CPPFLAGS_FOR_BUILD=${CPPFLAGS_FOR_BUILD-""} LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD-""} CFLAGS_FOR_BUILD=${CFLAGS_FOR_BUILD="-g"} - BASE_CFLAGS_FOR_BUILD=${BASE_CFLAGS_FOR_BUILD="-g"} LIBS_FOR_BUILD=${LIBS_FOR_BUILD-""} fi @@ -5382,405 +5453,145 @@ fi -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 -printf %s "checking how to run the C preprocessor... " >&6; } -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP= + +if test "$opt_readline" = yes && test "$opt_with_installed_readline" != "no" +then + # If the user specified --with-installed-readline=PREFIX and PREFIX + # is not `yes', set ac_cv_rl_prefix to PREFIX + test $opt_with_installed_readline != "yes" && ac_cv_rl_prefix=$opt_with_installed_readline + + +if test "X$bash_cv_termcap_lib" = "X"; then +_bash_needmsg=yes +else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking which library has the termcap functions" >&5 +printf %s "checking which library has the termcap functions... " >&6; } +_bash_needmsg= fi -if test -z "$CPP"; then - if test ${ac_cv_prog_CPP+y} +if test ${bash_cv_termcap_lib+y} then : printf %s "(cached) " >&6 -else $as_nop - # Double quotes because $CC needs to be expanded - for CPP in "$CC -E" "$CC -E -traditional-cpp" cpp /lib/cpp - do - ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - Syntax error -_ACEOF -if ac_fn_c_try_cpp "$LINENO" +else case e in #( + e) ac_fn_c_check_func "$LINENO" "tgetent" "ac_cv_func_tgetent" +if test "x$ac_cv_func_tgetent" = xyes then : - -else $as_nop - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -_ACEOF -if ac_fn_c_try_cpp "$LINENO" + bash_cv_termcap_lib=libc +else case e in #( + e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for tgetent in -ltermcap" >&5 +printf %s "checking for tgetent in -ltermcap... " >&6; } +if test ${ac_cv_lib_termcap_tgetent+y} then : - # Broken: success on invalid input. -continue -else $as_nop - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext + printf %s "(cached) " >&6 +else case e in #( + e) ac_check_lib_save_LIBS=$LIBS +LIBS="-ltermcap $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char tgetent (void); +int +main (void) +{ +return tgetent (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" then : - break -fi - - done - ac_cv_prog_CPP=$CPP - + ac_cv_lib_termcap_tgetent=yes +else case e in #( + e) ac_cv_lib_termcap_tgetent=no ;; +esac fi - CPP=$ac_cv_prog_CPP -else - ac_cv_prog_CPP=$CPP +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS ;; +esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 -printf "%s\n" "$CPP" >&6; } -ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - Syntax error -_ACEOF -if ac_fn_c_try_cpp "$LINENO" +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_termcap_tgetent" >&5 +printf "%s\n" "$ac_cv_lib_termcap_tgetent" >&6; } +if test "x$ac_cv_lib_termcap_tgetent" = xyes then : - -else $as_nop - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + bash_cv_termcap_lib=libtermcap +else case e in #( + e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for tgetent in -ltinfo" >&5 +printf %s "checking for tgetent in -ltinfo... " >&6; } +if test ${ac_cv_lib_tinfo_tgetent+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) ac_check_lib_save_LIBS=$LIBS +LIBS="-ltinfo $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char tgetent (void); +int +main (void) +{ +return tgetent (); + ; + return 0; +} _ACEOF -if ac_fn_c_try_cpp "$LINENO" +if ac_fn_c_try_link "$LINENO" then : - # Broken: success on invalid input. -continue -else $as_nop - # Passes both tests. -ac_preproc_ok=: -break + ac_cv_lib_tinfo_tgetent=yes +else case e in #( + e) ac_cv_lib_tinfo_tgetent=no ;; +esac fi -rm -f conftest.err conftest.i conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok -then : - -else $as_nop - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details" "$LINENO" 5; } +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS ;; +esac fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 -printf %s "checking for grep that handles long lines and -e... " >&6; } -if test ${ac_cv_path_GREP+y} +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_tinfo_tgetent" >&5 +printf "%s\n" "$ac_cv_lib_tinfo_tgetent" >&6; } +if test "x$ac_cv_lib_tinfo_tgetent" = xyes +then : + bash_cv_termcap_lib=libtinfo +else case e in #( + e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for tgetent in -lcurses" >&5 +printf %s "checking for tgetent in -lcurses... " >&6; } +if test ${ac_cv_lib_curses_tgetent+y} then : printf %s "(cached) " >&6 -else $as_nop - if test -z "$GREP"; then - ac_path_GREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - for ac_prog in grep ggrep - do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_GREP="$as_dir$ac_prog$ac_exec_ext" - as_fn_executable_p "$ac_path_GREP" || continue -# Check for GNU ac_path_GREP and select it if it is found. - # Check for GNU $ac_path_GREP -case `"$ac_path_GREP" --version 2>&1` in -*GNU*) - ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; -*) - ac_count=0 - printf %s 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - printf "%s\n" 'GREP' >> "conftest.nl" - "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_GREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_GREP="$ac_path_GREP" - ac_path_GREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_GREP_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_GREP"; then - as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 - fi -else - ac_cv_path_GREP=$GREP -fi - -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 -printf "%s\n" "$ac_cv_path_GREP" >&6; } - GREP="$ac_cv_path_GREP" - - -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 -printf %s "checking for egrep... " >&6; } -if test ${ac_cv_path_EGREP+y} -then : - printf %s "(cached) " >&6 -else $as_nop - if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 - then ac_cv_path_EGREP="$GREP -E" - else - if test -z "$EGREP"; then - ac_path_EGREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - for ac_prog in egrep - do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_EGREP="$as_dir$ac_prog$ac_exec_ext" - as_fn_executable_p "$ac_path_EGREP" || continue -# Check for GNU ac_path_EGREP and select it if it is found. - # Check for GNU $ac_path_EGREP -case `"$ac_path_EGREP" --version 2>&1` in -*GNU*) - ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; -*) - ac_count=0 - printf %s 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - printf "%s\n" 'EGREP' >> "conftest.nl" - "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_EGREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_EGREP="$ac_path_EGREP" - ac_path_EGREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_EGREP_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_EGREP"; then - as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 - fi -else - ac_cv_path_EGREP=$EGREP -fi - - fi -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 -printf "%s\n" "$ac_cv_path_EGREP" >&6; } - EGREP="$ac_cv_path_EGREP" - - -if test $ac_cv_c_compiler_gnu = yes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC needs -traditional" >&5 -printf %s "checking whether $CC needs -traditional... " >&6; } -if test ${ac_cv_prog_gcc_traditional+y} -then : - printf %s "(cached) " >&6 -else $as_nop - ac_pattern="Autoconf.*'x'" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -Autoconf TIOCGETP -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "$ac_pattern" >/dev/null 2>&1 -then : - ac_cv_prog_gcc_traditional=yes -else $as_nop - ac_cv_prog_gcc_traditional=no -fi -rm -rf conftest* - - - if test $ac_cv_prog_gcc_traditional = no; then - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -Autoconf TCGETA -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "$ac_pattern" >/dev/null 2>&1 -then : - ac_cv_prog_gcc_traditional=yes -fi -rm -rf conftest* - - fi -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_gcc_traditional" >&5 -printf "%s\n" "$ac_cv_prog_gcc_traditional" >&6; } - if test $ac_cv_prog_gcc_traditional = yes; then - CC="$CC -traditional" - fi -fi - - - -if test "$opt_readline" = yes && test "$opt_with_installed_readline" != "no" -then - # If the user specified --with-installed-readline=PREFIX and PREFIX - # is not `yes', set ac_cv_rl_prefix to PREFIX - test $opt_with_installed_readline != "yes" && ac_cv_rl_prefix=$opt_with_installed_readline - - -if test "X$bash_cv_termcap_lib" = "X"; then -_bash_needmsg=yes -else -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking which library has the termcap functions" >&5 -printf %s "checking which library has the termcap functions... " >&6; } -_bash_needmsg= -fi -if test ${bash_cv_termcap_lib+y} -then : - printf %s "(cached) " >&6 -else $as_nop - ac_fn_c_check_func "$LINENO" "tgetent" "ac_cv_func_tgetent" -if test "x$ac_cv_func_tgetent" = xyes -then : - bash_cv_termcap_lib=libc -else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for tgetent in -ltermcap" >&5 -printf %s "checking for tgetent in -ltermcap... " >&6; } -if test ${ac_cv_lib_termcap_tgetent+y} -then : - printf %s "(cached) " >&6 -else $as_nop - ac_check_lib_save_LIBS=$LIBS -LIBS="-ltermcap $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -char tgetent (); -int -main (void) -{ -return tgetent (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO" -then : - ac_cv_lib_termcap_tgetent=yes -else $as_nop - ac_cv_lib_termcap_tgetent=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_termcap_tgetent" >&5 -printf "%s\n" "$ac_cv_lib_termcap_tgetent" >&6; } -if test "x$ac_cv_lib_termcap_tgetent" = xyes -then : - bash_cv_termcap_lib=libtermcap -else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for tgetent in -ltinfo" >&5 -printf %s "checking for tgetent in -ltinfo... " >&6; } -if test ${ac_cv_lib_tinfo_tgetent+y} -then : - printf %s "(cached) " >&6 -else $as_nop - ac_check_lib_save_LIBS=$LIBS -LIBS="-ltinfo $LIBS" +else case e in #( + e) ac_check_lib_save_LIBS=$LIBS +LIBS="-lcurses $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -char tgetent (); + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char tgetent (void); int main (void) { @@ -5791,35 +5602,43 @@ return tgetent (); _ACEOF if ac_fn_c_try_link "$LINENO" then : - ac_cv_lib_tinfo_tgetent=yes -else $as_nop - ac_cv_lib_tinfo_tgetent=no + ac_cv_lib_curses_tgetent=yes +else case e in #( + e) ac_cv_lib_curses_tgetent=no ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS +LIBS=$ac_check_lib_save_LIBS ;; +esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_tinfo_tgetent" >&5 -printf "%s\n" "$ac_cv_lib_tinfo_tgetent" >&6; } -if test "x$ac_cv_lib_tinfo_tgetent" = xyes +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_tgetent" >&5 +printf "%s\n" "$ac_cv_lib_curses_tgetent" >&6; } +if test "x$ac_cv_lib_curses_tgetent" = xyes then : - bash_cv_termcap_lib=libtinfo -else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for tgetent in -lcurses" >&5 -printf %s "checking for tgetent in -lcurses... " >&6; } -if test ${ac_cv_lib_curses_tgetent+y} + bash_cv_termcap_lib=libcurses +else case e in #( + e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for tgetent in -lncursesw" >&5 +printf %s "checking for tgetent in -lncursesw... " >&6; } +if test ${ac_cv_lib_ncursesw_tgetent+y} then : printf %s "(cached) " >&6 -else $as_nop - ac_check_lib_save_LIBS=$LIBS -LIBS="-lcurses $LIBS" +else case e in #( + e) ac_check_lib_save_LIBS=$LIBS +LIBS="-lncursesw $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -char tgetent (); + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char tgetent (void); int main (void) { @@ -5830,35 +5649,43 @@ return tgetent (); _ACEOF if ac_fn_c_try_link "$LINENO" then : - ac_cv_lib_curses_tgetent=yes -else $as_nop - ac_cv_lib_curses_tgetent=no + ac_cv_lib_ncursesw_tgetent=yes +else case e in #( + e) ac_cv_lib_ncursesw_tgetent=no ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS +LIBS=$ac_check_lib_save_LIBS ;; +esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_tgetent" >&5 -printf "%s\n" "$ac_cv_lib_curses_tgetent" >&6; } -if test "x$ac_cv_lib_curses_tgetent" = xyes +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ncursesw_tgetent" >&5 +printf "%s\n" "$ac_cv_lib_ncursesw_tgetent" >&6; } +if test "x$ac_cv_lib_ncursesw_tgetent" = xyes then : - bash_cv_termcap_lib=libcurses -else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for tgetent in -lncurses" >&5 + bash_cv_termcap_lib=libncursesw +else case e in #( + e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for tgetent in -lncurses" >&5 printf %s "checking for tgetent in -lncurses... " >&6; } if test ${ac_cv_lib_ncurses_tgetent+y} then : printf %s "(cached) " >&6 -else $as_nop - ac_check_lib_save_LIBS=$LIBS +else case e in #( + e) ac_check_lib_save_LIBS=$LIBS LIBS="-lncurses $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -char tgetent (); + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char tgetent (void); int main (void) { @@ -5870,76 +5697,46 @@ _ACEOF if ac_fn_c_try_link "$LINENO" then : ac_cv_lib_ncurses_tgetent=yes -else $as_nop - ac_cv_lib_ncurses_tgetent=no +else case e in #( + e) ac_cv_lib_ncurses_tgetent=no ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS +LIBS=$ac_check_lib_save_LIBS ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ncurses_tgetent" >&5 printf "%s\n" "$ac_cv_lib_ncurses_tgetent" >&6; } if test "x$ac_cv_lib_ncurses_tgetent" = xyes then : bash_cv_termcap_lib=libncurses -else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for tgetent in -lncursesw" >&5 -printf %s "checking for tgetent in -lncursesw... " >&6; } -if test ${ac_cv_lib_ncursesw_tgetent+y} -then : - printf %s "(cached) " >&6 -else $as_nop - ac_check_lib_save_LIBS=$LIBS -LIBS="-lncursesw $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -char tgetent (); -int -main (void) -{ -return tgetent (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO" -then : - ac_cv_lib_ncursesw_tgetent=yes -else $as_nop - ac_cv_lib_ncursesw_tgetent=no +else case e in #( + e) bash_cv_termcap_lib=gnutermcap ;; +esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS + ;; +esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ncursesw_tgetent" >&5 -printf "%s\n" "$ac_cv_lib_ncursesw_tgetent" >&6; } -if test "x$ac_cv_lib_ncursesw_tgetent" = xyes -then : - bash_cv_termcap_lib=libncursesw -else $as_nop - bash_cv_termcap_lib=gnutermcap + ;; +esac fi - + ;; +esac fi - + ;; +esac fi - + ;; +esac fi - + ;; +esac fi -fi - -fi - -if test "X$_bash_needmsg" = "Xyes"; then -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking which library has the termcap functions" >&5 -printf %s "checking which library has the termcap functions... " >&6; } +if test "X$_bash_needmsg" = "Xyes"; then +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking which library has the termcap functions" >&5 +printf %s "checking which library has the termcap functions... " >&6; } fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: using $bash_cv_termcap_lib" >&5 printf "%s\n" "using $bash_cv_termcap_lib" >&6; } @@ -5953,9 +5750,15 @@ TERMCAP_DEP= elif test $bash_cv_termcap_lib = libtinfo; then TERMCAP_LIB=-ltinfo TERMCAP_DEP= +elif test $bash_cv_termcap_lib = libncursesw; then +TERMCAP_LIB=-lncursesw +TERMCAP_DEP= elif test $bash_cv_termcap_lib = libncurses; then TERMCAP_LIB=-lncurses TERMCAP_DEP= +elif test $bash_cv_termcap_lib = libcurses; then +TERMCAP_LIB=-lcurses +TERMCAP_DEP= elif test $bash_cv_termcap_lib = libc; then TERMCAP_LIB= TERMCAP_DEP= @@ -5996,13 +5799,13 @@ LDFLAGS="$LDFLAGS -L${ac_cv_rl_libdir}" if test ${ac_cv_rl_version+y} then : printf %s "(cached) " >&6 -else $as_nop - if test "$cross_compiling" = yes +else case e in #( + e) if test "$cross_compiling" = yes then : ac_cv_rl_version='8.0' -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -6030,13 +5833,16 @@ _ACEOF if ac_fn_c_try_run "$LINENO" then : ac_cv_rl_version=`cat conftest.rlv` -else $as_nop - ac_cv_rl_version='0.0' +else case e in #( + e) ac_cv_rl_version='0.0' ;; +esac fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi - + ;; +esac fi @@ -6139,11 +5945,13 @@ if test $opt_readline = yes; then # section for OS versions that don't allow unresolved symbols # to be compiled into dynamic libraries. case "$host_os" in - cygwin*) TILDE_LIB= ;; + cygwin*|msys*) TILDE_LIB= ;; esac else RL_LIBDIR='$(dot)/$(LIBSUBDIR)/readline' READLINE_DEP='$(READLINE_LIBRARY)' + # for dependencies + RL_INCLUDEDIR='$(RL_LIBDIR)' # section for OS versions that ship an older/broken version of # readline as a standard dynamic library and don't allow a # static version specified as -llibname to override the @@ -6156,6 +5964,7 @@ if test $opt_readline = yes; then else RL_LIBDIR='$(dot)/$(LIBSUBDIR)/readline' READLINE_LIB= READLINE_DEP= + RL_INCLUDEDIR= fi if test $opt_history = yes || test $opt_bang_history = yes; then if test $opt_history = yes; then @@ -6181,6 +5990,8 @@ if test $opt_history = yes || test $opt_bang_history = yes; then else HIST_LIBDIR='$(dot)/$(LIBSUBDIR)/readline' HISTORY_DEP='$(HISTORY_LIBRARY)' + # for dependencies + HIST_INCLUDEDIR='$(HIST_LIBDIR)' # section for OS versions that ship an older version of # readline as a standard dynamic library and don't allow a # static version specified as -llibname to override the @@ -6193,6 +6004,7 @@ if test $opt_history = yes || test $opt_bang_history = yes; then else HIST_LIBDIR='$(dot)/$(LIBSUBDIR)/readline' HISTORY_LIB= HISTORY_DEP= + HIST_INCLUDEDIR= fi @@ -6206,6 +6018,7 @@ fi + # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: @@ -6226,8 +6039,8 @@ if test -z "$INSTALL"; then if test ${ac_cv_path_install+y} then : printf %s "(cached) " >&6 -else $as_nop - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +else case e in #( + e) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS @@ -6281,7 +6094,8 @@ esac IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir - + ;; +esac fi if test ${ac_cv_path_install+y}; then INSTALL=$ac_cv_path_install @@ -6312,8 +6126,8 @@ printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_AR+y} then : printf %s "(cached) " >&6 -else $as_nop - if test -n "$AR"; then +else case e in #( + e) if test -n "$AR"; then ac_cv_prog_AR="$AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -6335,7 +6149,8 @@ done done IFS=$as_save_IFS -fi +fi ;; +esac fi AR=$ac_cv_prog_AR if test -n "$AR"; then @@ -6357,8 +6172,8 @@ printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_AR+y} then : printf %s "(cached) " >&6 -else $as_nop - if test -n "$ac_ct_AR"; then +else case e in #( + e) if test -n "$ac_ct_AR"; then ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -6380,7 +6195,8 @@ done done IFS=$as_save_IFS -fi +fi ;; +esac fi ac_ct_AR=$ac_cv_prog_ac_ct_AR if test -n "$ac_ct_AR"; then @@ -6415,8 +6231,8 @@ printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_RANLIB+y} then : printf %s "(cached) " >&6 -else $as_nop - if test -n "$RANLIB"; then +else case e in #( + e) if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -6438,7 +6254,8 @@ done done IFS=$as_save_IFS -fi +fi ;; +esac fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then @@ -6460,8 +6277,8 @@ printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_RANLIB+y} then : printf %s "(cached) " >&6 -else $as_nop - if test -n "$ac_ct_RANLIB"; then +else case e in #( + e) if test -n "$ac_ct_RANLIB"; then ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -6483,7 +6300,8 @@ done done IFS=$as_save_IFS -fi +fi ;; +esac fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then @@ -6518,8 +6336,8 @@ printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_YACC+y} then : printf %s "(cached) " >&6 -else $as_nop - if test -n "$YACC"; then +else case e in #( + e) if test -n "$YACC"; then ac_cv_prog_YACC="$YACC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -6541,7 +6359,8 @@ done done IFS=$as_save_IFS -fi +fi ;; +esac fi YACC=$ac_cv_prog_YACC if test -n "$YACC"; then @@ -6564,8 +6383,8 @@ ac_make=`printf "%s\n" "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if eval test \${ac_cv_prog_make_${ac_make}_set+y} then : printf %s "(cached) " >&6 -else $as_nop - cat >conftest.make <<\_ACEOF +else case e in #( + e) cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' @@ -6577,7 +6396,8 @@ case `${MAKE-make} -f conftest.make 2>/dev/null` in *) eval ac_cv_prog_make_${ac_make}_set=no;; esac -rm -f conftest.make +rm -f conftest.make ;; +esac fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 @@ -6590,6 +6410,132 @@ printf "%s\n" "no" >&6; } fi + +# Expand $ac_aux_dir to an absolute path. +am_aux_dir=`cd "$ac_aux_dir" && pwd` + +if test x"${install_sh+set}" != xset; then + case $am_aux_dir in + *\ * | *\ *) + install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; + *) + install_sh="\${SHELL} $am_aux_dir/install-sh" + esac +fi + +# Installed binaries are usually stripped using 'strip' when the user +# run "make install-strip". However 'strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the 'STRIP' environment variable to overrule this program. +#if test "$cross_compiling" != no; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. +set dummy ${ac_tool_prefix}strip; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_STRIP+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) if test -n "$STRIP"; then + ac_cv_prog_STRIP="$STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_STRIP="${ac_tool_prefix}strip" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi ;; +esac +fi +STRIP=$ac_cv_prog_STRIP +if test -n "$STRIP"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 +printf "%s\n" "$STRIP" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_STRIP"; then + ac_ct_STRIP=$STRIP + # Extract the first word of "strip", so it can be a program name with args. +set dummy strip; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_STRIP+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) if test -n "$ac_ct_STRIP"; then + ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_STRIP="strip" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi ;; +esac +fi +ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP +if test -n "$ac_ct_STRIP"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 +printf "%s\n" "$ac_ct_STRIP" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + if test "x$ac_ct_STRIP" = x; then + STRIP=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + STRIP=$ac_ct_STRIP + fi +else + STRIP="$ac_cv_prog_STRIP" +fi + +#fi +INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" + + case "$ac_cv_prog_YACC" in *bison*) ;; *) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: bison not available; needed to process parse.y" >&5 @@ -6662,6 +6608,16 @@ fi +# unlocked-io.m4 serial 16 + +# Copyright (C) 1998-2006, 2009-2024 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + + + # codeset.m4 serial 5 (gettext-0.18.2) @@ -6673,57 +6629,105 @@ fi -# fcntl-o.m4 serial 6 +# serial 10 +# Copyright (C) 2002-2006, 2008-2022 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. +# There are two types of parser skeletons: +# +# * Those that can be used with any Yacc implementation, including bison. +# For these, in the configure.ac, up to Autoconf 2.69, you could use +# AC_PROG_YACC +# In newer Autoconf versions, however, this macro is broken. See +# https://lists.gnu.org/archive/html/autoconf-patches/2013-03/msg00000.html +# https://lists.gnu.org/archive/html/bug-autoconf/2018-12/msg00001.html +# In the Makefile.am you could use +# $(SHELL) $(YLWRAP) $(srcdir)/foo.y \ +# y.tab.c foo.c \ +# y.tab.h foo.h \ +# y.output foo.output \ +# -- $(YACC) $(YFLAGS) $(AM_YFLAGS) +# or similar. +# +# * Those that make use of Bison extensions. For example, +# - %define api.pure requires bison 2.7 or newer, +# - %precedence requires bison 3.0 or newer. +# For these, in the configure.ac you will need an invocation of +# gl_PROG_BISON([VARIABLE], [MIN_BISON_VERSION]) +# Example: +# gl_PROG_BISON([PARSE_DATETIME_BISON], [2.4]) +# With this preparation, in the Makefile.am there are two ways to formulate +# the invocation. Both are direct, without use of 'ylwrap'. +# (a) You can invoke +# $(VARIABLE) -d $(SOME_BISON_OPTIONS) --output foo.c $(srcdir)/foo.y +# or similar. +# (b) If you want the invocation to honor an YFLAGS=... parameter passed to +# 'configure' or an YFLAGS environment variable present at 'configure' +# time, add an invocation of gl_BISON to the configure.ac, and write +# $(VARIABLE) -d $(YFLAGS) $(AM_YFLAGS) $(srcdir)/foo.y +# or similar. -# Test whether the flags O_NOATIME and O_NOFOLLOW actually work. -# Define HAVE_WORKING_O_NOATIME to 1 if O_NOATIME works, or to 0 otherwise. -# Define HAVE_WORKING_O_NOFOLLOW to 1 if O_NOFOLLOW works, or to 0 otherwise. +# This macro defines the autoconf variable VARIABLE to 'bison' if the specified +# minimum version of bison is found in $PATH, or to ':' otherwise. + + +# This macro sets the autoconf variables YACC (for old-style yacc Makefile +# rules) and YFLAGS (to allow options to be passed as 'configure' time). -# gettext.m4 serial 69 (gettext-0.19.9) +# fcntl-o.m4 serial 7 +# Test whether the flags O_NOATIME and O_NOFOLLOW actually work. +# Define HAVE_WORKING_O_NOATIME to 1 if O_NOATIME works, or to 0 otherwise. +# Define HAVE_WORKING_O_NOFOLLOW to 1 if O_NOFOLLOW works, or to 0 otherwise. +# serial 5 +# Check for flexible array member support. +# Copyright (C) 2006, 2009-2022 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. +# Written by Paul Eggert. +# gettext.m4 serial 72 (gettext-0.21.1) -# glibc2.m4 serial 3 -# Test for the GNU C Library, version 2.0 or newer. -# From Bruno Haible. -# glibc21.m4 serial 5 -# Test for the GNU C Library, version 2.1 or newer, or uClibc. -# From Bruno Haible. -# host-cpu-c-abi.m4 serial 11 +# glibc2.m4 serial 3 + +# Test for the GNU C Library, version 2.0 or newer. +# From Bruno Haible. -# iconv.m4 serial 21 +# iconv.m4 serial 24 @@ -6733,14 +6737,14 @@ fi -# intdiv0.m4 serial 6 (gettext-0.18.2) +# intdiv0.m4 serial 9 (gettext-0.21.1) -# intl.m4 serial 34 (gettext-0.19.9) +# intl.m4 serial 51 (gettext-0.21.1) @@ -6750,11 +6754,13 @@ fi -# intlmacosx.m4 serial 6 (gettext-0.19.9) +# intlmacosx.m4 serial 8 (gettext-0.20.2) -# intl-thread-locale.m4 serial 4 + + +# intl-thread-locale.m4 serial 9 @@ -6775,7 +6781,7 @@ fi -# inttypes.m4 serial 27 +# inttypes.m4 serial 36 @@ -6793,6 +6799,15 @@ fi # $2 is evaluated by the C preprocessor, $3 and $4 as compile-time constants. +# gl_INTTYPES_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. + + +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. @@ -6805,21 +6820,29 @@ fi -# lcmessage.m4 serial 7 (gettext-0.18.2) +# lcmessage.m4 serial 8 # Check whether LC_MESSAGES is available in . -# lib-ld.m4 serial 9 +# lib-ld.m4 serial 10 + + + + + + +# lib-link.m4 serial 33 + + -# lib-link.m4 serial 28 @@ -6830,6 +6853,7 @@ fi +# lib-prefix.m4 serial 20 @@ -6838,14 +6862,24 @@ fi -# lib-prefix.m4 serial 14 +# locale_h.m4 serial 28 +# gl_LOCALE_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. + + +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. + @@ -6857,14 +6891,14 @@ fi # Prerequisites of lib/glthread/lock.c. -# nls.m4 serial 5 (gettext-0.18) +# nls.m4 serial 6 (gettext-0.20.2) -# po.m4 serial 24a +# po.m4 serial 32 (gettext-0.21.1) @@ -6877,12 +6911,12 @@ fi -# printf-posix.m4 serial 6 (gettext-0.18.2) +# printf-posix.m4 serial 7 (gettext-0.21.1) -# progtest.m4 serial 7 (gettext-0.18.2) +# progtest.m4 serial 9 (gettext-0.21.1) @@ -6891,12 +6925,12 @@ fi -# pthread_rwlock_rdlock.m4 serial 2 +# pthread_rwlock_rdlock.m4 serial 4 -# size_max.m4 serial 11 +# size_max.m4 serial 12 @@ -6911,7 +6945,35 @@ fi -# threadlib.m4 serial 16 +# threadlib.m4 serial 32 + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -6956,7 +7018,7 @@ fi -# wint_t.m4 serial 7 +# wint_t.m4 serial 11 @@ -6968,13 +7030,41 @@ fi +# glibc21.m4 serial 5 + +# Test for the GNU C Library, version 2.1 or newer, or uClibc. +# From Bruno Haible. + + + +# host-cpu-c-abi.m4 serial 15 + + + + + + + + +# Check for bool that conforms to C2023. + + + + +# d-type.m4 +# serial 12 + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 printf %s "checking for an ANSI C-conforming const... " >&6; } if test ${ac_cv_c_const+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -7038,10 +7128,12 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_cv_c_const=yes -else $as_nop - ac_cv_c_const=no +else case e in #( + e) ac_cv_c_const=no ;; +esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5 printf "%s\n" "$ac_cv_c_const" >&6; } @@ -7056,8 +7148,8 @@ printf %s "checking for inline... " >&6; } if test ${ac_cv_c_inline+y} then : printf %s "(cached) " >&6 -else $as_nop - ac_cv_c_inline=no +else case e in #( + e) ac_cv_c_inline=no for ac_kw in inline __inline__ __inline; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -7075,7 +7167,8 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext test "$ac_cv_c_inline" != no && break done - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5 printf "%s\n" "$ac_cv_c_inline" >&6; } @@ -7100,8 +7193,8 @@ printf %s "checking whether byte ordering is bigendian... " >&6; } if test ${ac_cv_c_bigendian+y} then : printf %s "(cached) " >&6 -else $as_nop - ac_cv_c_bigendian=unknown +else case e in #( + e) ac_cv_c_bigendian=unknown # See if we're dealing with a universal compiler. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -7147,8 +7240,8 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext int main (void) { -#if ! (defined BYTE_ORDER && defined BIG_ENDIAN \ - && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \ +#if ! (defined BYTE_ORDER && defined BIG_ENDIAN \\ + && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \\ && LITTLE_ENDIAN) bogus endian macros #endif @@ -7179,8 +7272,9 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_cv_c_bigendian=yes -else $as_nop - ac_cv_c_bigendian=no +else case e in #( + e) ac_cv_c_bigendian=no ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi @@ -7224,8 +7318,9 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_cv_c_bigendian=yes -else $as_nop - ac_cv_c_bigendian=no +else case e in #( + e) ac_cv_c_bigendian=no ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi @@ -7252,22 +7347,23 @@ unsigned short int ascii_mm[] = int use_ebcdic (int i) { return ebcdic_mm[i] + ebcdic_ii[i]; } - extern int foo; - -int -main (void) -{ -return use_ascii (foo) == use_ebcdic (foo); - ; - return 0; -} + int + main (int argc, char **argv) + { + /* Intimidate the compiler so that it does not + optimize the arrays away. */ + char *p = argv[0]; + ascii_mm[1] = *p++; ebcdic_mm[1] = *p++; + ascii_ii[1] = *p++; ebcdic_ii[1] = *p++; + return use_ascii (argc) == use_ebcdic (*p); + } _ACEOF -if ac_fn_c_try_compile "$LINENO" +if ac_fn_c_try_link "$LINENO" then : - if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then + if grep BIGenDianSyS conftest$ac_exeext >/dev/null; then ac_cv_c_bigendian=yes fi - if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then + if grep LiTTleEnDian conftest$ac_exeext >/dev/null ; then if test "$ac_cv_c_bigendian" = unknown; then ac_cv_c_bigendian=no else @@ -7276,9 +7372,10 @@ then : fi fi fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int @@ -7301,14 +7398,17 @@ _ACEOF if ac_fn_c_try_run "$LINENO" then : ac_cv_c_bigendian=no -else $as_nop - ac_cv_c_bigendian=yes +else case e in #( + e) ac_cv_c_bigendian=yes ;; +esac fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi - fi + fi ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5 printf "%s\n" "$ac_cv_c_bigendian" >&6; } @@ -7328,31 +7428,8 @@ printf "%s\n" "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;; esac -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for preprocessor stringizing operator" >&5 -printf %s "checking for preprocessor stringizing operator... " >&6; } -if test ${ac_cv_c_stringize+y} -then : - printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#define x(y) #y -char *s = x(teststring); -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "#teststring" >/dev/null 2>&1 -then : - ac_cv_c_stringize=no -else $as_nop - ac_cv_c_stringize=yes -fi -rm -rf conftest* - -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_stringize" >&5 -printf "%s\n" "$ac_cv_c_stringize" >&6; } -if test $ac_cv_c_stringize = yes; then +if test "$ac_prog_cc_stdc" != no; then printf "%s\n" "#define HAVE_STRINGIZE 1" >>confdefs.h @@ -7364,8 +7441,8 @@ printf %s "checking for long double... " >&6; } if test ${ac_cv_type_long_double+y} then : printf %s "(cached) " >&6 -else $as_nop - if test "$GCC" = yes; then +else case e in #( + e) if test "$GCC" = yes; then ac_cv_type_long_double=yes else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -7388,11 +7465,13 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_cv_type_long_double=yes -else $as_nop - ac_cv_type_long_double=no +else case e in #( + e) ac_cv_type_long_double=no ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - fi + fi ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_long_double" >&5 printf "%s\n" "$ac_cv_type_long_double" >&6; } @@ -7402,22 +7481,13 @@ printf "%s\n" "#define HAVE_LONG_DOUBLE 1" >>confdefs.h fi -if test "$ac_prog_cc_stdc" != no; then - -printf "%s\n" "#define PROTOTYPES 1" >>confdefs.h - - -printf "%s\n" "#define __PROTOTYPES 1" >>confdefs.h - -fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether char is unsigned" >&5 printf %s "checking whether char is unsigned... " >&6; } if test ${ac_cv_c_char_unsigned+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int @@ -7434,10 +7504,12 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_cv_c_char_unsigned=no -else $as_nop - ac_cv_c_char_unsigned=yes +else case e in #( + e) ac_cv_c_char_unsigned=yes ;; +esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_char_unsigned" >&5 printf "%s\n" "$ac_cv_c_char_unsigned" >&6; } @@ -7451,8 +7523,8 @@ printf %s "checking for working volatile... " >&6; } if test ${ac_cv_c_volatile+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -7469,10 +7541,12 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_cv_c_volatile=yes -else $as_nop - ac_cv_c_volatile=no +else case e in #( + e) ac_cv_c_volatile=no ;; +esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_volatile" >&5 printf "%s\n" "$ac_cv_c_volatile" >&6; } @@ -7487,8 +7561,8 @@ printf %s "checking for C/C++ restrict keyword... " >&6; } if test ${ac_cv_c_restrict+y} then : printf %s "(cached) " >&6 -else $as_nop - ac_cv_c_restrict=no +else case e in #( + e) ac_cv_c_restrict=no # Put '__restrict__' first, to avoid problems with glibc and non-GCC; see: # https://lists.gnu.org/archive/html/bug-autoconf/2016-02/msg00006.html # Put 'restrict' last, because C++ lacks it. @@ -7519,7 +7593,8 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext test "$ac_cv_c_restrict" != no && break done - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_restrict" >&5 printf "%s\n" "$ac_cv_c_restrict" >&6; } @@ -7534,14 +7609,53 @@ printf "%s\n" "$ac_cv_c_restrict" >&6; } + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for bool, true, false" >&5 +printf %s "checking for bool, true, false... " >&6; } +if test ${gl_cv_c_bool+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #if true == false + #error "true == false" + #endif + extern bool b; + bool b = true == false; +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + gl_cv_c_bool=yes +else case e in #( + e) gl_cv_c_bool=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gl_cv_c_bool" >&5 +printf "%s\n" "$gl_cv_c_bool" >&6; } + if test "$gl_cv_c_bool" = yes; then + +printf "%s\n" "#define HAVE_C_BOOL 1" >>confdefs.h + + fi + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a race-free mkdir -p" >&5 printf %s "checking for a race-free mkdir -p... " >&6; } if test -z "$MKDIR_P"; then if test ${ac_cv_path_mkdir+y} then : printf %s "(cached) " >&6 -else $as_nop - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +else case e in #( + e) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin do IFS=$as_save_IFS @@ -7555,7 +7669,7 @@ do as_fn_executable_p "$as_dir$ac_prog$ac_exec_ext" || continue case `"$as_dir$ac_prog$ac_exec_ext" --version 2>&1` in #( 'mkdir ('*'coreutils) '* | \ - 'BusyBox '* | \ + *'BusyBox '* | \ 'mkdir (fileutils) '4.1*) ac_cv_path_mkdir=$as_dir$ac_prog$ac_exec_ext break 3;; @@ -7564,18 +7678,17 @@ do done done IFS=$as_save_IFS - + ;; +esac fi test -d ./--version && rmdir ./--version if test ${ac_cv_path_mkdir+y}; then MKDIR_P="$ac_cv_path_mkdir -p" else - # As a last resort, use the slow shell script. Don't cache a - # value for MKDIR_P within a source directory, because that will - # break other packages using the cache if that directory is - # removed, or if the value is a relative name. - MKDIR_P="$ac_install_sh -d" + # As a last resort, use plain mkdir -p, + # in the hope it doesn't have the bugs of ancient mkdir. + MKDIR_P='mkdir -p' fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 @@ -7586,8 +7699,8 @@ printf %s "checking for a sed that does not truncate output... " >&6; } if test ${ac_cv_path_SED+y} then : printf %s "(cached) " >&6 -else $as_nop - ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ +else case e in #( + e) ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ for ac_i in 1 2 3 4 5 6 7; do ac_script="$ac_script$as_nl$ac_script" done @@ -7612,9 +7725,10 @@ do as_fn_executable_p "$ac_path_SED" || continue # Check for GNU ac_path_SED and select it if it is found. # Check for GNU $ac_path_SED -case `"$ac_path_SED" --version 2>&1` in +case `"$ac_path_SED" --version 2>&1` in #( *GNU*) ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; +#( *) ac_count=0 printf %s 0123456789 >"conftest.in" @@ -7649,7 +7763,8 @@ IFS=$as_save_IFS else ac_cv_path_SED=$SED fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 printf "%s\n" "$ac_cv_path_SED" >&6; } @@ -7663,8 +7778,9 @@ printf %s "checking whether NLS is requested... " >&6; } if test ${enable_nls+y} then : enableval=$enable_nls; USE_NLS=$enableval -else $as_nop - USE_NLS=yes +else case e in #( + e) USE_NLS=yes ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $USE_NLS" >&5 @@ -7673,7 +7789,7 @@ printf "%s\n" "$USE_NLS" >&6; } - GETTEXT_MACRO_VERSION=0.19 + GETTEXT_MACRO_VERSION=0.20 @@ -7712,8 +7828,8 @@ printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_path_MSGFMT+y} then : printf %s "(cached) " >&6 -else $as_nop - case "$MSGFMT" in +else case e in #( + e) case "$MSGFMT" in [\\/]* | ?:[\\/]*) ac_cv_path_MSGFMT="$MSGFMT" # Let the user override the test with a path. ;; @@ -7736,6 +7852,7 @@ else $as_nop IFS="$ac_save_IFS" test -z "$ac_cv_path_MSGFMT" && ac_cv_path_MSGFMT=":" ;; +esac ;; esac fi MSGFMT="$ac_cv_path_MSGFMT" @@ -7754,8 +7871,8 @@ printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_path_GMSGFMT+y} then : printf %s "(cached) " >&6 -else $as_nop - case $GMSGFMT in +else case e in #( + e) case $GMSGFMT in [\\/]* | ?:[\\/]*) ac_cv_path_GMSGFMT="$GMSGFMT" # Let the user override the test with a path. ;; @@ -7781,6 +7898,7 @@ IFS=$as_save_IFS test -z "$ac_cv_path_GMSGFMT" && ac_cv_path_GMSGFMT="$MSGFMT" ;; +esac ;; esac fi GMSGFMT=$ac_cv_path_GMSGFMT @@ -7794,12 +7912,7 @@ fi - case `$MSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in - '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) MSGFMT_015=: ;; - *) MSGFMT_015=$MSGFMT ;; - esac - - case `$GMSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in + case `$GMSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) GMSGFMT_015=: ;; *) GMSGFMT_015=$GMSGFMT ;; esac @@ -7840,8 +7953,8 @@ printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_path_XGETTEXT+y} then : printf %s "(cached) " >&6 -else $as_nop - case "$XGETTEXT" in +else case e in #( + e) case "$XGETTEXT" in [\\/]* | ?:[\\/]*) ac_cv_path_XGETTEXT="$XGETTEXT" # Let the user override the test with a path. ;; @@ -7864,6 +7977,7 @@ else $as_nop IFS="$ac_save_IFS" test -z "$ac_cv_path_XGETTEXT" && ac_cv_path_XGETTEXT=":" ;; +esac ;; esac fi XGETTEXT="$ac_cv_path_XGETTEXT" @@ -7918,8 +8032,8 @@ printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_path_MSGMERGE+y} then : printf %s "(cached) " >&6 -else $as_nop - case "$MSGMERGE" in +else case e in #( + e) case "$MSGMERGE" in [\\/]* | ?:[\\/]*) ac_cv_path_MSGMERGE="$MSGMERGE" # Let the user override the test with a path. ;; @@ -7941,6 +8055,7 @@ else $as_nop IFS="$ac_save_IFS" test -z "$ac_cv_path_MSGMERGE" && ac_cv_path_MSGMERGE=":" ;; +esac ;; esac fi MSGMERGE="$ac_cv_path_MSGMERGE" @@ -7953,156 +8068,447 @@ printf "%s\n" "no" >&6; } fi + if LC_ALL=C $MSGMERGE --help | grep ' --for-msgfmt ' >/dev/null; then + MSGMERGE_FOR_MSGFMT_OPTION='--for-msgfmt' + else + if LC_ALL=C $MSGMERGE --help | grep ' --no-fuzzy-matching ' >/dev/null; then + MSGMERGE_FOR_MSGFMT_OPTION='--no-fuzzy-matching --no-location --quiet' + else + MSGMERGE_FOR_MSGFMT_OPTION='--no-location --quiet' + fi + fi + + test -n "${XGETTEXT_EXTRA_OPTIONS+set}" || XGETTEXT_EXTRA_OPTIONS= ac_config_commands="$ac_config_commands po-directories" - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C Library 2 or newer" >&5 -printf %s "checking whether we are using the GNU C Library 2 or newer... " >&6; } -if test ${ac_cv_gnu_library_2+y} +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 +printf %s "checking how to run the C preprocessor... " >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if test ${ac_cv_prog_CPP+y} then : printf %s "(cached) " >&6 -else $as_nop +else case e in #( + e) # Double quotes because $CC needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" cpp /lib/cpp + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -#include -#ifdef __GNU_LIBRARY__ - #if (__GLIBC__ >= 2) && !defined __UCLIBC__ - Lucky GNU user - #endif -#endif - +#include + Syntax error _ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "Lucky GNU user" >/dev/null 2>&1 +if ac_fn_c_try_cpp "$LINENO" then : - ac_cv_gnu_library_2=yes -else $as_nop - ac_cv_gnu_library_2=no -fi -rm -rf conftest* - - +else case e in #( + e) # Broken: fails on valid input. +continue ;; +esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_gnu_library_2" >&5 -printf "%s\n" "$ac_cv_gnu_library_2" >&6; } - - GLIBC2="$ac_cv_gnu_library_2" - - - +rm -f conftest.err conftest.i conftest.$ac_ext - CFLAG_VISIBILITY= - HAVE_VISIBILITY=0 - if test -n "$GCC"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the -Werror option is usable" >&5 -printf %s "checking whether the -Werror option is usable... " >&6; } -if test ${gl_cv_cc_vis_werror+y} -then : - printf %s "(cached) " >&6 -else $as_nop - gl_save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -Werror" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -int -main (void) -{ - - ; - return 0; -} +#include _ACEOF -if ac_fn_c_try_compile "$LINENO" +if ac_fn_c_try_cpp "$LINENO" then : - gl_cv_cc_vis_werror=yes -else $as_nop - gl_cv_cc_vis_werror=no + # Broken: success on invalid input. +continue +else case e in #( + e) # Passes both tests. +ac_preproc_ok=: +break ;; +esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - CFLAGS="$gl_save_CFLAGS" +rm -f conftest.err conftest.i conftest.$ac_ext -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gl_cv_cc_vis_werror" >&5 -printf "%s\n" "$gl_cv_cc_vis_werror" >&6; } - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for simple visibility declarations" >&5 -printf %s "checking for simple visibility declarations... " >&6; } -if test ${gl_cv_cc_visibility+y} +done +# Because of 'break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok then : - printf %s "(cached) " >&6 -else $as_nop - gl_save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -fvisibility=hidden" - if test $gl_cv_cc_vis_werror = yes; then - CFLAGS="$CFLAGS -Werror" - fi - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -extern __attribute__((__visibility__("hidden"))) int hiddenvar; - extern __attribute__((__visibility__("default"))) int exportedvar; - extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void); - extern __attribute__((__visibility__("default"))) int exportedfunc (void); - void dummyfunc (void) {} - -int -main (void) -{ + break +fi - ; - return 0; -} + done + ac_cv_prog_CPP=$CPP + ;; +esac +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 +printf "%s\n" "$CPP" >&6; } +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + Syntax error _ACEOF -if ac_fn_c_try_compile "$LINENO" +if ac_fn_c_try_cpp "$LINENO" then : - gl_cv_cc_visibility=yes -else $as_nop - gl_cv_cc_visibility=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - CFLAGS="$gl_save_CFLAGS" +else case e in #( + e) # Broken: fails on valid input. +continue ;; +esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gl_cv_cc_visibility" >&5 -printf "%s\n" "$gl_cv_cc_visibility" >&6; } - if test $gl_cv_cc_visibility = yes; then - CFLAG_VISIBILITY="-fvisibility=hidden" - HAVE_VISIBILITY=1 - fi - fi - - - -printf "%s\n" "#define HAVE_VISIBILITY $HAVE_VISIBILITY" >>confdefs.h - +rm -f conftest.err conftest.i conftest.$ac_ext -ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" -if test "x$ac_cv_type_size_t" = xyes + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO" then : + # Broken: success on invalid input. +continue +else case e in #( + e) # Passes both tests. +ac_preproc_ok=: +break ;; +esac +fi +rm -f conftest.err conftest.i conftest.$ac_ext -else $as_nop - -printf "%s\n" "#define size_t unsigned int" >>confdefs.h +done +# Because of 'break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok +then : +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "C preprocessor \"$CPP\" fails sanity check +See 'config.log' for more details" "$LINENO" 5; } ;; +esac fi +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for stdint.h" >&5 -printf %s "checking for stdint.h... " >&6; } -if test ${gl_cv_header_stdint_h+y} + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for egrep -e" >&5 +printf %s "checking for egrep -e... " >&6; } +if test ${ac_cv_path_EGREP_TRADITIONAL+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - #include -int +else case e in #( + e) if test -z "$EGREP_TRADITIONAL"; then + ac_path_EGREP_TRADITIONAL_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_prog in grep ggrep + do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP_TRADITIONAL="$as_dir$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_EGREP_TRADITIONAL" || continue +# Check for GNU ac_path_EGREP_TRADITIONAL and select it if it is found. + # Check for GNU $ac_path_EGREP_TRADITIONAL +case `"$ac_path_EGREP_TRADITIONAL" --version 2>&1` in #( +*GNU*) + ac_cv_path_EGREP_TRADITIONAL="$ac_path_EGREP_TRADITIONAL" ac_path_EGREP_TRADITIONAL_found=:;; +#( +*) + ac_count=0 + printf %s 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + printf "%s\n" 'EGREP_TRADITIONAL' >> "conftest.nl" + "$ac_path_EGREP_TRADITIONAL" -E 'EGR(EP|AC)_TRADITIONAL$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_EGREP_TRADITIONAL_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP_TRADITIONAL="$ac_path_EGREP_TRADITIONAL" + ac_path_EGREP_TRADITIONAL_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_EGREP_TRADITIONAL_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_EGREP_TRADITIONAL"; then + : + fi +else + ac_cv_path_EGREP_TRADITIONAL=$EGREP_TRADITIONAL +fi + + if test "$ac_cv_path_EGREP_TRADITIONAL" +then : + ac_cv_path_EGREP_TRADITIONAL="$ac_cv_path_EGREP_TRADITIONAL -E" +else case e in #( + e) if test -z "$EGREP_TRADITIONAL"; then + ac_path_EGREP_TRADITIONAL_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_prog in egrep + do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP_TRADITIONAL="$as_dir$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_EGREP_TRADITIONAL" || continue +# Check for GNU ac_path_EGREP_TRADITIONAL and select it if it is found. + # Check for GNU $ac_path_EGREP_TRADITIONAL +case `"$ac_path_EGREP_TRADITIONAL" --version 2>&1` in #( +*GNU*) + ac_cv_path_EGREP_TRADITIONAL="$ac_path_EGREP_TRADITIONAL" ac_path_EGREP_TRADITIONAL_found=:;; +#( +*) + ac_count=0 + printf %s 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + printf "%s\n" 'EGREP_TRADITIONAL' >> "conftest.nl" + "$ac_path_EGREP_TRADITIONAL" 'EGR(EP|AC)_TRADITIONAL$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_EGREP_TRADITIONAL_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP_TRADITIONAL="$ac_path_EGREP_TRADITIONAL" + ac_path_EGREP_TRADITIONAL_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_EGREP_TRADITIONAL_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_EGREP_TRADITIONAL"; then + as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_EGREP_TRADITIONAL=$EGREP_TRADITIONAL +fi + ;; +esac +fi ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP_TRADITIONAL" >&5 +printf "%s\n" "$ac_cv_path_EGREP_TRADITIONAL" >&6; } + EGREP_TRADITIONAL=$ac_cv_path_EGREP_TRADITIONAL + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C Library 2 or newer" >&5 +printf %s "checking whether we are using the GNU C Library 2 or newer... " >&6; } +if test ${ac_cv_gnu_library_2+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#ifdef __GNU_LIBRARY__ + #if (__GLIBC__ >= 2) && !defined __UCLIBC__ + Lucky GNU user + #endif +#endif + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP_TRADITIONAL "Lucky GNU user" >/dev/null 2>&1 +then : + ac_cv_gnu_library_2=yes +else case e in #( + e) ac_cv_gnu_library_2=no ;; +esac +fi +rm -rf conftest* + + + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_gnu_library_2" >&5 +printf "%s\n" "$ac_cv_gnu_library_2" >&6; } + + GLIBC2="$ac_cv_gnu_library_2" + + + + + CFLAG_VISIBILITY= + HAVE_VISIBILITY=0 + if test -n "$GCC"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the -Werror option is usable" >&5 +printf %s "checking whether the -Werror option is usable... " >&6; } +if test ${gl_cv_cc_vis_werror+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) gl_save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -Werror" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + gl_cv_cc_vis_werror=yes +else case e in #( + e) gl_cv_cc_vis_werror=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + CFLAGS="$gl_save_CFLAGS" + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gl_cv_cc_vis_werror" >&5 +printf "%s\n" "$gl_cv_cc_vis_werror" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for simple visibility declarations" >&5 +printf %s "checking for simple visibility declarations... " >&6; } +if test ${gl_cv_cc_visibility+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) gl_save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -fvisibility=hidden" + if test $gl_cv_cc_vis_werror = yes; then + CFLAGS="$CFLAGS -Werror" + fi + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +extern __attribute__((__visibility__("hidden"))) int hiddenvar; + extern __attribute__((__visibility__("default"))) int exportedvar; + extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void); + extern __attribute__((__visibility__("default"))) int exportedfunc (void); + void dummyfunc (void) {} + +int +main (void) +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + gl_cv_cc_visibility=yes +else case e in #( + e) gl_cv_cc_visibility=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + CFLAGS="$gl_save_CFLAGS" + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gl_cv_cc_visibility" >&5 +printf "%s\n" "$gl_cv_cc_visibility" >&6; } + if test $gl_cv_cc_visibility = yes; then + CFLAG_VISIBILITY="-fvisibility=hidden" + HAVE_VISIBILITY=1 + fi + fi + + + +printf "%s\n" "#define HAVE_VISIBILITY $HAVE_VISIBILITY" >>confdefs.h + + +ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" +if test "x$ac_cv_type_size_t" = xyes +then : + +else case e in #( + e) +printf "%s\n" "#define size_t unsigned int" >>confdefs.h + ;; +esac +fi + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for stdint.h" >&5 +printf %s "checking for stdint.h... " >&6; } +if test ${gl_cv_header_stdint_h+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + #include +int main (void) { uintmax_t i = (uintmax_t) -1; return !i; @@ -8113,10 +8519,12 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : gl_cv_header_stdint_h=yes -else $as_nop - gl_cv_header_stdint_h=no +else case e in #( + e) gl_cv_header_stdint_h=no ;; +esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_stdint_h" >&5 printf "%s\n" "$gl_cv_header_stdint_h" >&6; } @@ -8133,8 +8541,8 @@ printf %s "checking for working alloca.h... " >&6; } if test ${ac_cv_working_alloca_h+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int @@ -8149,11 +8557,13 @@ _ACEOF if ac_fn_c_try_link "$LINENO" then : ac_cv_working_alloca_h=yes -else $as_nop - ac_cv_working_alloca_h=no +else case e in #( + e) ac_cv_working_alloca_h=no ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext + conftest$ac_exeext conftest.$ac_ext ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_working_alloca_h" >&5 printf "%s\n" "$ac_cv_working_alloca_h" >&6; } @@ -8168,10 +8578,10 @@ printf %s "checking for alloca... " >&6; } if test ${ac_cv_func_alloca_works+y} then : printf %s "(cached) " >&6 -else $as_nop - if test $ac_cv_working_alloca_h = yes; then - ac_cv_func_alloca_works=yes -else +else case e in #( + e) ac_cv_func_alloca_works=$ac_cv_working_alloca_h +if test "$ac_cv_func_alloca_works" != yes +then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -8202,15 +8612,14 @@ _ACEOF if ac_fn_c_try_link "$LINENO" then : ac_cv_func_alloca_works=yes -else $as_nop - ac_cv_func_alloca_works=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext +fi ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_alloca_works" >&5 printf "%s\n" "$ac_cv_func_alloca_works" >&6; } -fi if test $ac_cv_func_alloca_works = yes; then @@ -8232,12 +8641,12 @@ printf %s "checking stack direction for C alloca... " >&6; } if test ${ac_cv_c_stack_direction+y} then : printf %s "(cached) " >&6 -else $as_nop - if test "$cross_compiling" = yes +else case e in #( + e) if test "$cross_compiling" = yes then : ac_cv_c_stack_direction=0 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int @@ -8260,13 +8669,16 @@ _ACEOF if ac_fn_c_try_run "$LINENO" then : ac_cv_c_stack_direction=1 -else $as_nop - ac_cv_c_stack_direction=-1 +else case e in #( + e) ac_cv_c_stack_direction=-1 ;; +esac fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_stack_direction" >&5 printf "%s\n" "$ac_cv_c_stack_direction" >&6; } @@ -8296,8 +8708,8 @@ printf %s "checking for working mmap... " >&6; } if test ${ac_cv_func_mmap_fixed_mapped+y} then : printf %s "(cached) " >&6 -else $as_nop - if test "$cross_compiling" = yes +else case e in #( + e) if test "$cross_compiling" = yes then : case "$host_os" in # (( # Guess yes on platforms where we know the result. @@ -8305,8 +8717,8 @@ then : # If we don't know, assume the worst. *) ac_cv_func_mmap_fixed_mapped=no ;; esac -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default /* malloc might have been renamed as rpl_malloc. */ @@ -8327,21 +8739,21 @@ $ac_includes_default VM page cache was not coherent with the file system buffer cache like early versions of FreeBSD and possibly contemporary NetBSD.) For shared mappings, we should conversely verify that changes get - propagated back to all the places they're supposed to be. - - Grep wants private fixed already mapped. - The main things grep needs to know about mmap are: - * does it exist and is it safe to write into the mmap'd area - * how to use it (BSD variants) */ + propagated back to all the places they're supposed to be. */ #include #include -/* This mess was copied from the GNU getpagesize.h. */ -#ifndef HAVE_GETPAGESIZE +#ifndef getpagesize +/* Prefer sysconf to the legacy getpagesize function, as getpagesize has + been removed from POSIX and is limited to page sizes that fit in 'int'. */ # ifdef _SC_PAGESIZE -# define getpagesize() sysconf(_SC_PAGESIZE) -# else /* no _SC_PAGESIZE */ +# define getpagesize() sysconf (_SC_PAGESIZE) +# elif defined _SC_PAGE_SIZE +# define getpagesize() sysconf (_SC_PAGE_SIZE) +# elif HAVE_GETPAGESIZE +int getpagesize (); +# else # ifdef HAVE_SYS_PARAM_H # include # ifdef EXEC_PAGESIZE @@ -8365,16 +8777,15 @@ $ac_includes_default # else /* no HAVE_SYS_PARAM_H */ # define getpagesize() 8192 /* punt totally */ # endif /* no HAVE_SYS_PARAM_H */ -# endif /* no _SC_PAGESIZE */ - -#endif /* no HAVE_GETPAGESIZE */ +# endif +#endif int main (void) { char *data, *data2, *data3; const char *cdata2; - int i, pagesize; + long i, pagesize; int fd, fd2; pagesize = getpagesize (); @@ -8408,8 +8819,7 @@ main (void) if (*(data2 + i)) return 7; close (fd2); - if (munmap (data2, pagesize)) - return 8; + /* 'return 8;' not currently used. */ /* Next, try to mmap the file at a fixed address which already has something else allocated at it. If we can, also make sure that @@ -8446,13 +8856,16 @@ _ACEOF if ac_fn_c_try_run "$LINENO" then : ac_cv_func_mmap_fixed_mapped=yes -else $as_nop - ac_cv_func_mmap_fixed_mapped=no +else case e in #( + e) ac_cv_func_mmap_fixed_mapped=no ;; +esac fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_mmap_fixed_mapped" >&5 printf "%s\n" "$ac_cv_func_mmap_fixed_mapped" >&6; } @@ -8470,8 +8883,8 @@ printf %s "checking whether integer division by zero raises SIGFPE... " >&6; } if test ${gt_cv_int_divbyzero_sigfpe+y} then : printf %s "(cached) " >&6 -else $as_nop - +else case e in #( + e) gt_cv_int_divbyzero_sigfpe= case "$host_os" in macos* | darwin[6-9]* | darwin[1-9][0-9]*) @@ -8496,24 +8909,27 @@ then : gt_cv_int_divbyzero_sigfpe="guessing no";; esac -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include +#include /* for exit() */ #include +#if !(defined _WIN32 && !defined __CYGWIN__) +#include /* for _exit() */ +#endif static void sigfpe_handler (int sig) { /* Exit with code 0 if SIGFPE, with code 1 if any other signal. */ - exit (sig != SIGFPE); + _exit (sig != SIGFPE); } int x = 1; int y = 0; int z; -int xnan; +int inan; int main () { @@ -8528,7 +8944,7 @@ int main () #endif z = x / y; - xnan = y / y; + inan = y / y; exit (2); } @@ -8536,21 +8952,24 @@ _ACEOF if ac_fn_c_try_run "$LINENO" then : gt_cv_int_divbyzero_sigfpe=yes -else $as_nop - gt_cv_int_divbyzero_sigfpe=no +else case e in #( + e) gt_cv_int_divbyzero_sigfpe=no ;; +esac fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gt_cv_int_divbyzero_sigfpe" >&5 printf "%s\n" "$gt_cv_int_divbyzero_sigfpe" >&6; } case "$gt_cv_int_divbyzero_sigfpe" in - *yes) value=1;; - *) value=0;; + *yes) value=1 ;; + *) value=0 ;; esac printf "%s\n" "#define INTDIV0_RAISES_SIGFPE $value" >>confdefs.h @@ -8562,8 +8981,8 @@ printf %s "checking for inttypes.h... " >&6; } if test ${gl_cv_header_inttypes_h+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -8580,10 +8999,12 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : gl_cv_header_inttypes_h=yes -else $as_nop - gl_cv_header_inttypes_h=no +else case e in #( + e) gl_cv_header_inttypes_h=no ;; +esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_inttypes_h" >&5 printf "%s\n" "$gl_cv_header_inttypes_h" >&6; } @@ -8599,8 +9020,8 @@ printf %s "checking for unsigned long long int... " >&6; } if test ${ac_cv_type_unsigned_long_long_int+y} then : printf %s "(cached) " >&6 -else $as_nop - ac_cv_type_unsigned_long_long_int=yes +else case e in #( + e) ac_cv_type_unsigned_long_long_int=yes case $ac_prog_cc_stdc in no | c89) ;; *) @@ -8639,12 +9060,14 @@ _ACEOF if ac_fn_c_try_link "$LINENO" then : -else $as_nop - ac_cv_type_unsigned_long_long_int=no +else case e in #( + e) ac_cv_type_unsigned_long_long_int=no ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext;; - esac + esac ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_unsigned_long_long_int" >&5 printf "%s\n" "$ac_cv_type_unsigned_long_long_int" >&6; } @@ -8672,59 +9095,6 @@ printf "%s\n" "#define HAVE_UINTMAX_T 1" >>confdefs.h fi - ac_fn_c_check_header_compile "$LINENO" "inttypes.h" "ac_cv_header_inttypes_h" "$ac_includes_default" -if test "x$ac_cv_header_inttypes_h" = xyes -then : - printf "%s\n" "#define HAVE_INTTYPES_H 1" >>confdefs.h - -fi - - if test $ac_cv_header_inttypes_h = yes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the inttypes.h PRIxNN macros are broken" >&5 -printf %s "checking whether the inttypes.h PRIxNN macros are broken... " >&6; } -if test ${gt_cv_inttypes_pri_broken+y} -then : - printf %s "(cached) " >&6 -else $as_nop - - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#ifdef PRId32 -char *p = PRId32; -#endif - -int -main (void) -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - gt_cv_inttypes_pri_broken=no -else $as_nop - gt_cv_inttypes_pri_broken=yes -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gt_cv_inttypes_pri_broken" >&5 -printf "%s\n" "$gt_cv_inttypes_pri_broken" >&6; } - fi - if test "$gt_cv_inttypes_pri_broken" = yes; then - -printf "%s\n" "#define PRI_MACROS_BROKEN 1" >>confdefs.h - - PRI_MACROS_BROKEN=1 - else - PRI_MACROS_BROKEN=0 - fi - - @@ -8734,26 +9104,40 @@ printf "%s\n" "#define PRI_MACROS_BROKEN 1" >>confdefs.h if test ${enable_threads+y} then : enableval=$enable_threads; gl_use_threads=$enableval -else $as_nop - if test -n "$gl_use_threads_default"; then +else case e in #( + e) if test -n "$gl_use_threads_default"; then gl_use_threads="$gl_use_threads_default" else case "$host_os" in - osf*) gl_use_threads=no ;; - cygwin*) + osf*) gl_use_threads=no ;; + cygwin*) case `uname -r` in 1.[0-5].*) gl_use_threads=no ;; *) gl_use_threads=yes ;; esac ;; + mingw*) + case "$gl_use_winpthreads_default" in + yes) gl_use_threads=posix ;; + no) gl_use_threads=windows ;; + *) gl_use_threads=yes ;; + esac + ;; *) gl_use_threads=yes ;; esac fi - + ;; +esac fi - if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then - # For using : + if test "$gl_use_threads" = yes \ + || test "$gl_use_threads" = isoc \ + || test "$gl_use_threads" = posix \ + || test "$gl_use_threads" = isoc+posix; then + # For using or : + + + if test -z "$gl_anythreadlib_early_done"; then case "$host_os" in osf*) # On OSF/1, the compiler needs the flag -D_REENTRANT so that it @@ -8769,839 +9153,836 @@ fi # need special flags to disable these optimizations. For example, the # definition of 'errno' in . case "$host_os" in - aix* | freebsd* | midnightbsd*) CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" ;; + aix* | freebsd*) CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" ;; solaris*) CPPFLAGS="$CPPFLAGS -D_REENTRANT" ;; esac + gl_anythreadlib_early_done=done fi + fi - if test "X$prefix" = "XNONE"; then - acl_final_prefix="$ac_default_prefix" - else - acl_final_prefix="$prefix" - fi - if test "X$exec_prefix" = "XNONE"; then - acl_final_exec_prefix='${prefix}' - else - acl_final_exec_prefix="$exec_prefix" - fi - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - eval acl_final_exec_prefix=\"$acl_final_exec_prefix\" - prefix="$acl_save_prefix" -# Check whether --with-gnu-ld was given. -if test ${with_gnu_ld+y} -then : - withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes -else $as_nop - with_gnu_ld=no -fi + gl_threads_api=none + LIBTHREAD= + LTLIBTHREAD= + LIBMULTITHREAD= + LTLIBMULTITHREAD= + if test "$gl_use_threads" != no; then -# Prepare PATH_SEPARATOR. -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which - # contains only /bin. Note that ksh looks also at the FPATH variable, - # so we have to set that as well for the test. - PATH_SEPARATOR=: - (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ - && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ - || PATH_SEPARATOR=';' - } -fi -if test -n "$LD"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ld" >&5 -printf %s "checking for ld... " >&6; } -elif test "$GCC" = yes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 -printf %s "checking for ld used by $CC... " >&6; } -elif test "$with_gnu_ld" = yes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 -printf %s "checking for GNU ld... " >&6; } -else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 -printf %s "checking for non-GNU ld... " >&6; } -fi -if test -n "$LD"; then - # Let the user override the test with a path. - : -else - if test ${acl_cv_path_LD+y} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether imported symbols can be declared weak" >&5 +printf %s "checking whether imported symbols can be declared weak... " >&6; } +if test ${gl_cv_have_weak+y} then : printf %s "(cached) " >&6 -else $as_nop - - acl_cv_path_LD= # Final result of this test - ac_prog=ld # Program to search in $PATH - if test "$GCC" = yes; then - # Check if gcc -print-prog-name=ld gives a path. - case $host in - *-*-mingw*) - # gcc leaves a trailing carriage return which upsets mingw - acl_output=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; - *) - acl_output=`($CC -print-prog-name=ld) 2>&5` ;; - esac - case $acl_output in - # Accept absolute paths. - [\\/]* | ?:[\\/]*) - re_direlt='/[^/][^/]*/\.\./' - # Canonicalize the pathname of ld - acl_output=`echo "$acl_output" | sed 's%\\\\%/%g'` - while echo "$acl_output" | grep "$re_direlt" > /dev/null 2>&1; do - acl_output=`echo $acl_output | sed "s%$re_direlt%/%"` - done - # Got the pathname. No search in PATH is needed. - acl_cv_path_LD="$acl_output" - ac_prog= - ;; - "") - # If it fails, then pretend we aren't using GCC. - ;; - *) - # If it is relative, then search for the first ld in PATH. - with_gnu_ld=unknown - ;; - esac - fi - if test -n "$ac_prog"; then - # Search for $ac_prog in $PATH. - acl_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH; do - IFS="$acl_save_ifs" - test -z "$ac_dir" && ac_dir=. - if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then - acl_cv_path_LD="$ac_dir/$ac_prog" - # Check to see if the program is GNU ld. I'd rather use --version, - # but apparently some variants of GNU ld only accept -v. - # Break only if it was the GNU/non-GNU ld that we prefer. - case `"$acl_cv_path_LD" -v 2>&1 conftest.$ac_ext +else case e in #( + e) case "$host_os" in + cygwin*) + gl_cv_have_weak="guessing no" + ;; + *) + gl_cv_have_weak=no + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#if defined __powerpc64__ || defined _ARCH_PPC64 - int ok; - #else - error fail - #endif - +extern void xyzzy (); +#pragma weak xyzzy +int +main (void) +{ +xyzzy(); + ; + return 0; +} _ACEOF -if ac_fn_c_try_compile "$LINENO" +if ac_fn_c_try_link "$LINENO" then : - # The compiler produces 64-bit code. Add option '-b64' so that the - # linker groks 64-bit object files. - case "$acl_cv_path_LD " in - *" -b64 "*) ;; - *) acl_cv_path_LD="$acl_cv_path_LD -b64" ;; - esac - + gl_cv_have_weak=maybe fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - ;; - sparc64-*-netbsd*) - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + if test $gl_cv_have_weak = maybe; then + if test "$cross_compiling" = yes +then : + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#if defined __sparcv9 || defined __arch64__ - int ok; - #else - error fail - #endif +#ifdef __ELF__ + Extensible Linking Format + #endif _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - -else $as_nop - # The compiler produces 32-bit code. Add option '-m elf32_sparc' - # so that the linker groks 32-bit object files. - case "$acl_cv_path_LD " in - *" -m elf32_sparc "*) ;; - *) acl_cv_path_LD="$acl_cv_path_LD -m elf32_sparc" ;; - esac - -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - ;; - esac - -fi - - LD="$acl_cv_path_LD" -fi -if test -n "$LD"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $LD" >&5 -printf "%s\n" "$LD" >&6; } -else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } - as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 -printf %s "checking if the linker ($LD) is GNU ld... " >&6; } -if test ${acl_cv_prog_gnu_ld+y} +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP_TRADITIONAL "Extensible Linking Format" >/dev/null 2>&1 then : - printf %s "(cached) " >&6 -else $as_nop - # I'd rather use --version here, but apparently some GNU lds only accept -v. -case `$LD -v 2>&1 &5 -printf "%s\n" "$acl_cv_prog_gnu_ld" >&6; } -with_gnu_ld=$acl_cv_prog_gnu_ld +rm -rf conftest* +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ - - - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5 -printf %s "checking for shared library run path origin... " >&6; } -if test ${acl_cv_rpath+y} +#include +#pragma weak fputs +int main () +{ + return (fputs == NULL); +} +_ACEOF +if ac_fn_c_try_run "$LINENO" then : - printf %s "(cached) " >&6 -else $as_nop - - CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \ - ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh - . ./conftest.sh - rm -f ./conftest.sh - acl_cv_rpath=done - + gl_cv_have_weak=yes +else case e in #( + e) gl_cv_have_weak=no ;; +esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $acl_cv_rpath" >&5 -printf "%s\n" "$acl_cv_rpath" >&6; } - wl="$acl_cv_wl" - acl_libext="$acl_cv_libext" - acl_shlibext="$acl_cv_shlibext" - acl_libname_spec="$acl_cv_libname_spec" - acl_library_names_spec="$acl_cv_library_names_spec" - acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" - acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" - acl_hardcode_direct="$acl_cv_hardcode_direct" - acl_hardcode_minus_L="$acl_cv_hardcode_minus_L" - # Check whether --enable-rpath was given. -if test ${enable_rpath+y} -then : - enableval=$enable_rpath; : -else $as_nop - enable_rpath=yes +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi + fi + ;; + esac + case " $LDFLAGS " in + *" -static "*) gl_cv_have_weak=no ;; + esac + case "$gl_cv_have_weak" in + *yes) + case "$host_os" in + freebsd* | dragonfly* | midnightbsd*) + : > conftest1.c + $CC $CPPFLAGS $CFLAGS $LDFLAGS -fPIC -shared -o libempty.so conftest1.c -lpthread >&5 2>&1 + cat < conftest2.c +#include +#pragma weak pthread_mutexattr_gettype +int main () +{ + return (pthread_mutexattr_gettype != NULL); +} +EOF + $CC $CPPFLAGS $CFLAGS $LDFLAGS -o conftest conftest2.c libempty.so >&5 2>&1 \ + || gl_cv_have_weak=no + rm -f conftest1.c libempty.so conftest2.c conftest + ;; + esac + ;; + esac + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gl_cv_have_weak" >&5 +printf "%s\n" "$gl_cv_have_weak" >&6; } + case "$gl_cv_have_weak" in + *yes) +printf "%s\n" "#define HAVE_WEAK_SYMBOLS 1" >>confdefs.h + ;; + esac - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking 32-bit host C ABI" >&5 -printf %s "checking 32-bit host C ABI... " >&6; } -if test ${gl_cv_host_cpu_c_abi_32bit+y} -then : - printf %s "(cached) " >&6 -else $as_nop - if test -n "$gl_cv_host_cpu_c_abi"; then - case "$gl_cv_host_cpu_c_abi" in - i386 | x86_64-x32 | arm | armhf | arm64-ilp32 | hppa | ia64-ilp32 | mips | mipsn32 | powerpc | riscv*-ilp32* | s390 | sparc) - gl_cv_host_cpu_c_abi_32bit=yes ;; - *) - gl_cv_host_cpu_c_abi_32bit=no ;; - esac - else - case "$host_cpu" in - - i[4567]86 ) - gl_cv_host_cpu_c_abi_32bit=yes - ;; + if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then - x86_64 ) - # On x86_64 systems, the C compiler may be generating code in one of - # these ABIs: - # - 64-bit instruction set, 64-bit pointers, 64-bit 'long': x86_64. - # - 64-bit instruction set, 64-bit pointers, 32-bit 'long': x86_64 - # with native Windows (mingw, MSVC). - # - 64-bit instruction set, 32-bit pointers, 32-bit 'long': x86_64-x32. - # - 32-bit instruction set, 32-bit pointers, 32-bit 'long': i386. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#if (defined __x86_64__ || defined __amd64__ \ - || defined _M_X64 || defined _M_AMD64) \ - && !(defined __ILP32__ || defined _ILP32) - int ok; - #else - error fail - #endif + : + fi + if test "$gl_use_threads" = isoc || test "$gl_use_threads" = isoc+posix; then -_ACEOF -if ac_fn_c_try_compile "$LINENO" + gl_have_isoc_threads="$ac_cv_header_threads_h" + fi + if test "$gl_use_threads" = yes \ + || test "$gl_use_threads" = posix \ + || test "$gl_use_threads" = isoc+posix; then + + + if test -z "$gl_pthreadlib_body_done"; then + gl_pthread_api=no + LIBPTHREAD= + LIBPMULTITHREAD= + # On OSF/1, the compiler needs the flag -pthread or -D_REENTRANT so that + # it groks . It's added above, in gl_ANYTHREADLIB_EARLY. + ac_fn_c_check_header_compile "$LINENO" "pthread.h" "ac_cv_header_pthread_h" "$ac_includes_default" +if test "x$ac_cv_header_pthread_h" = xyes then : - gl_cv_host_cpu_c_abi_32bit=no -else $as_nop - gl_cv_host_cpu_c_abi_32bit=yes + gl_have_pthread_h=yes +else case e in #( + e) gl_have_pthread_h=no ;; +esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - ;; - arm* | aarch64 ) - # Assume arm with EABI. - # On arm64 systems, the C compiler may be generating code in one of - # these ABIs: - # - aarch64 instruction set, 64-bit pointers, 64-bit 'long': arm64. - # - aarch64 instruction set, 32-bit pointers, 32-bit 'long': arm64-ilp32. - # - 32-bit instruction set, 32-bit pointers, 32-bit 'long': arm or armhf. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + if test "$gl_have_pthread_h" = yes; then + # Other possible tests: + # -lpthreads (FSU threads, PCthreads) + # -lgthreads + # Test whether both pthread_mutex_lock and pthread_mutexattr_init exist + # in libc. IRIX 6.5 has the first one in both libc and libpthread, but + # the second one only in libpthread, and lock.c needs it. + # + # If -pthread works, prefer it to -lpthread, since Ubuntu 14.04 + # needs -pthread for some reason. See: + # https://lists.gnu.org/r/bug-gnulib/2014-09/msg00023.html + save_LIBS=$LIBS + for gl_pthread in '' '-pthread'; do + LIBS="$LIBS $gl_pthread" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#if defined __aarch64__ && !(defined __ILP32__ || defined _ILP32) - int ok; - #else - error fail - #endif +#include + pthread_mutex_t m; + pthread_mutexattr_t ma; +int +main (void) +{ +pthread_mutex_lock (&m); + pthread_mutexattr_init (&ma); + ; + return 0; +} _ACEOF -if ac_fn_c_try_compile "$LINENO" +if ac_fn_c_try_link "$LINENO" then : - gl_cv_host_cpu_c_abi_32bit=no -else $as_nop - gl_cv_host_cpu_c_abi_32bit=yes + gl_pthread_api=yes + LIBPTHREAD=$gl_pthread + LIBPMULTITHREAD=$gl_pthread fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - ;; +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + LIBS=$save_LIBS + test $gl_pthread_api = yes && break + done + echo "$as_me:9360: gl_pthread_api=$gl_pthread_api" >&5 + echo "$as_me:9361: LIBPTHREAD=$LIBPTHREAD" >&5 - hppa1.0 | hppa1.1 | hppa2.0* | hppa64 ) - # On hppa, the C compiler may be generating 32-bit code or 64-bit - # code. In the latter case, it defines _LP64 and __LP64__. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + gl_pthread_in_glibc=no + # On Linux with glibc >= 2.34, libc contains the fully functional + # pthread functions. + case "$host_os" in + linux*) + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#ifdef __LP64__ - int ok; - #else - error fail - #endif +#include + #ifdef __GNU_LIBRARY__ + #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 34) || (__GLIBC__ > 2) + Lucky user + #endif + #endif _ACEOF -if ac_fn_c_try_compile "$LINENO" +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP_TRADITIONAL "Lucky user" >/dev/null 2>&1 then : - gl_cv_host_cpu_c_abi_32bit=no -else $as_nop - gl_cv_host_cpu_c_abi_32bit=yes + gl_pthread_in_glibc=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - ;; +rm -rf conftest* - ia64* ) - # On ia64 on HP-UX, the C compiler may be generating 64-bit code or - # 32-bit code. In the latter case, it defines _ILP32. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + ;; + esac + echo "$as_me:9387: gl_pthread_in_glibc=$gl_pthread_in_glibc" >&5 + + # Test for libpthread by looking for pthread_kill. (Not pthread_self, + # since it is defined as a macro on OSF/1.) + if test $gl_pthread_api = yes && test -z "$LIBPTHREAD"; then + # The program links fine without libpthread. But it may actually + # need to link with libpthread in order to create multiple threads. + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for pthread_kill in -lpthread" >&5 +printf %s "checking for pthread_kill in -lpthread... " >&6; } +if test ${ac_cv_lib_pthread_pthread_kill+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) ac_check_lib_save_LIBS=$LIBS +LIBS="-lpthread $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#ifdef _ILP32 - int ok; - #else - error fail - #endif +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char pthread_kill (void); +int +main (void) +{ +return pthread_kill (); + ; + return 0; +} _ACEOF -if ac_fn_c_try_compile "$LINENO" +if ac_fn_c_try_link "$LINENO" then : - gl_cv_host_cpu_c_abi_32bit=yes -else $as_nop - gl_cv_host_cpu_c_abi_32bit=no + ac_cv_lib_pthread_pthread_kill=yes +else case e in #( + e) ac_cv_lib_pthread_pthread_kill=no ;; +esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - ;; +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_kill" >&5 +printf "%s\n" "$ac_cv_lib_pthread_pthread_kill" >&6; } +if test "x$ac_cv_lib_pthread_pthread_kill" = xyes +then : + if test $gl_pthread_in_glibc = yes; then + LIBPMULTITHREAD= + else + LIBPMULTITHREAD=-lpthread + # On Solaris and HP-UX, most pthread functions exist also in libc. + # Therefore pthread_in_use() needs to actually try to create a + # thread: pthread_create from libc will fail, whereas + # pthread_create will actually create a thread. + # On Solaris 10 or newer, this test is no longer needed, because + # libc contains the fully functional pthread functions. + case "$host_os" in + solaris | solaris2.1-9 | solaris2.1-9.* | hpux*) - mips* ) - # We should also check for (_MIPS_SZPTR == 64), but gcc keeps this - # at 32. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#if defined _MIPS_SZLONG && (_MIPS_SZLONG == 64) - int ok; - #else - error fail - #endif +printf "%s\n" "#define PTHREAD_IN_USE_DETECTION_HARD 1" >>confdefs.h -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - gl_cv_host_cpu_c_abi_32bit=no -else $as_nop - gl_cv_host_cpu_c_abi_32bit=yes -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - ;; + esac + fi - powerpc* ) - # Different ABIs are in use on AIX vs. Mac OS X vs. Linux,*BSD. - # No need to distinguish them here; the caller may distinguish - # them based on the OS. - # On powerpc64 systems, the C compiler may still be generating - # 32-bit code. And on powerpc-ibm-aix systems, the C compiler may - # be generating 64-bit code. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#if defined __powerpc64__ || defined _ARCH_PPC64 - int ok; - #else - error fail - #endif +fi -_ACEOF -if ac_fn_c_try_compile "$LINENO" + elif test $gl_pthread_api != yes; then + # Some library is needed. Try libpthread and libc_r. + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for pthread_kill in -lpthread" >&5 +printf %s "checking for pthread_kill in -lpthread... " >&6; } +if test ${ac_cv_lib_pthread_pthread_kill+y} then : - gl_cv_host_cpu_c_abi_32bit=no -else $as_nop - gl_cv_host_cpu_c_abi_32bit=yes -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - ;; - - rs6000 ) - gl_cv_host_cpu_c_abi_32bit=yes - ;; - - riscv32 | riscv64 ) - # There are 6 ABIs: ilp32, ilp32f, ilp32d, lp64, lp64f, lp64d. - # Size of 'long' and 'void *': - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#if defined __LP64__ - int ok; - #else - error fail - #endif + printf %s "(cached) " >&6 +else case e in #( + e) ac_check_lib_save_LIBS=$LIBS +LIBS="-lpthread $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char pthread_kill (void); +int +main (void) +{ +return pthread_kill (); + ; + return 0; +} _ACEOF -if ac_fn_c_try_compile "$LINENO" +if ac_fn_c_try_link "$LINENO" then : - gl_cv_host_cpu_c_abi_32bit=no -else $as_nop - gl_cv_host_cpu_c_abi_32bit=yes + ac_cv_lib_pthread_pthread_kill=yes +else case e in #( + e) ac_cv_lib_pthread_pthread_kill=no ;; +esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - ;; - - s390* ) - # On s390x, the C compiler may be generating 64-bit (= s390x) code - # or 31-bit (= s390) code. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#if defined __LP64__ || defined __s390x__ - int ok; - #else - error fail - #endif - -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - gl_cv_host_cpu_c_abi_32bit=no -else $as_nop - gl_cv_host_cpu_c_abi_32bit=yes +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS ;; +esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - ;; - - sparc | sparc64 ) - # UltraSPARCs running Linux have `uname -m` = "sparc64", but the - # C compiler still generates 32-bit code. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#if defined __sparcv9 || defined __arch64__ - int ok; - #else - error fail - #endif - -_ACEOF -if ac_fn_c_try_compile "$LINENO" +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_kill" >&5 +printf "%s\n" "$ac_cv_lib_pthread_pthread_kill" >&6; } +if test "x$ac_cv_lib_pthread_pthread_kill" = xyes then : - gl_cv_host_cpu_c_abi_32bit=no -else $as_nop - gl_cv_host_cpu_c_abi_32bit=yes -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - ;; - - *) - gl_cv_host_cpu_c_abi_32bit=no - ;; - esac - fi - + gl_pthread_api=yes + LIBPTHREAD=-lpthread + LIBPMULTITHREAD=-lpthread fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gl_cv_host_cpu_c_abi_32bit" >&5 -printf "%s\n" "$gl_cv_host_cpu_c_abi_32bit" >&6; } - HOST_CPU_C_ABI_32BIT="$gl_cv_host_cpu_c_abi_32bit" - - - - - - case "$host_os" in - solaris*) - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for 64-bit host" >&5 -printf %s "checking for 64-bit host... " >&6; } -if test ${gl_cv_solaris_64bit+y} + if test $gl_pthread_api != yes; then + # For FreeBSD 4. + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for pthread_kill in -lc_r" >&5 +printf %s "checking for pthread_kill in -lc_r... " >&6; } +if test ${ac_cv_lib_c_r_pthread_kill+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) ac_check_lib_save_LIBS=$LIBS +LIBS="-lc_r $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#ifdef _LP64 - int ok; - #else - error fail - #endif - -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - gl_cv_solaris_64bit=yes -else $as_nop - gl_cv_solaris_64bit=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gl_cv_solaris_64bit" >&5 -printf "%s\n" "$gl_cv_solaris_64bit" >&6; };; - esac - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for the common suffixes of directories in the library search path" >&5 -printf %s "checking for the common suffixes of directories in the library search path... " >&6; } -if test ${acl_cv_libdirstems+y} -then : - printf %s "(cached) " >&6 -else $as_nop - acl_libdirstem=lib - acl_libdirstem2= - case "$host_os" in - solaris*) - if test $gl_cv_solaris_64bit = yes; then - acl_libdirstem=lib/64 - case "$host_cpu" in - sparc*) acl_libdirstem2=lib/sparcv9 ;; - i*86 | x86_64) acl_libdirstem2=lib/amd64 ;; - esac - fi - ;; - *) - if test "$HOST_CPU_C_ABI_32BIT" != yes; then - searchpath=`(if test -f /usr/bin/gcc \ - && LC_ALL=C /usr/bin/gcc -print-search-dirs >/dev/null 2>/dev/null; then \ - LC_ALL=C /usr/bin/gcc -print-search-dirs; \ - else \ - LC_ALL=C $CC -print-search-dirs; \ - fi) 2>/dev/null \ - | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'` - if test -n "$searchpath"; then - acl_save_IFS="${IFS= }"; IFS=":" - for searchdir in $searchpath; do - if test -d "$searchdir"; then - case "$searchdir" in - */lib64/ | */lib64 ) acl_libdirstem=lib64 ;; - */../ | */.. ) - # Better ignore directories of this form. They are misleading. - ;; - *) searchdir=`cd "$searchdir" && pwd` - case "$searchdir" in - */lib64 ) acl_libdirstem=lib64 ;; - esac ;; - esac - fi - done - IFS="$acl_save_IFS" - fi - fi - ;; - esac - test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem" - acl_cv_libdirstems="$acl_libdirstem,$acl_libdirstem2" -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $acl_cv_libdirstems" >&5 -printf "%s\n" "$acl_cv_libdirstems" >&6; } - # Decompose acl_cv_libdirstems into acl_libdirstem and acl_libdirstem2. - acl_libdirstem=`echo "$acl_cv_libdirstems" | sed -e 's/,.*//'` - acl_libdirstem2=`echo "$acl_cv_libdirstems" | sed -e '/,/s/.*,//'` - - - - gl_threads_api=none - LIBTHREAD= - LTLIBTHREAD= - LIBMULTITHREAD= - LTLIBMULTITHREAD= - if test "$gl_use_threads" != no; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether imported symbols can be declared weak" >&5 -printf %s "checking whether imported symbols can be declared weak... " >&6; } -if test ${gl_cv_have_weak+y} -then : - printf %s "(cached) " >&6 -else $as_nop - gl_cv_have_weak=no - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -extern void xyzzy (); -#pragma weak xyzzy +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char pthread_kill (void); int main (void) { -xyzzy(); +return pthread_kill (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : - gl_cv_have_weak=maybe + ac_cv_lib_c_r_pthread_kill=yes +else case e in #( + e) ac_cv_lib_c_r_pthread_kill=no ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext - if test $gl_cv_have_weak = maybe; then - if test "$cross_compiling" = yes -then : - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __ELF__ - Extensible Linking Format - #endif - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "Extensible Linking Format" >/dev/null 2>&1 +LIBS=$ac_check_lib_save_LIBS ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_c_r_pthread_kill" >&5 +printf "%s\n" "$ac_cv_lib_c_r_pthread_kill" >&6; } +if test "x$ac_cv_lib_c_r_pthread_kill" = xyes then : - gl_cv_have_weak="guessing yes" -else $as_nop - gl_cv_have_weak="guessing no" + gl_pthread_api=yes + LIBPTHREAD=-lc_r + LIBPMULTITHREAD=-lc_r fi -rm -rf conftest* + fi + fi + echo "$as_me:9565: LIBPMULTITHREAD=$LIBPMULTITHREAD" >&5 + fi + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether POSIX threads API is available" >&5 +printf %s "checking whether POSIX threads API is available... " >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gl_pthread_api" >&5 +printf "%s\n" "$gl_pthread_api" >&6; } -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#pragma weak fputs -int main () -{ - return (fputs == NULL); -} -_ACEOF -if ac_fn_c_try_run "$LINENO" -then : - gl_cv_have_weak=yes -else $as_nop - gl_cv_have_weak=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi + if test $gl_pthread_api = yes; then - fi - case " $LDFLAGS " in - *" -static "*) gl_cv_have_weak=no ;; - esac +printf "%s\n" "#define HAVE_PTHREAD_API 1" >>confdefs.h -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gl_cv_have_weak" >&5 -printf "%s\n" "$gl_cv_have_weak" >&6; } - if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then - # On OSF/1, the compiler needs the flag -pthread or -D_REENTRANT so that - # it groks . It's added above, in gl_THREADLIB_EARLY_BODY. - ac_fn_c_check_header_compile "$LINENO" "pthread.h" "ac_cv_header_pthread_h" "$ac_includes_default" -if test "x$ac_cv_header_pthread_h" = xyes -then : - gl_have_pthread_h=yes -else $as_nop - gl_have_pthread_h=no -fi - - if test "$gl_have_pthread_h" = yes; then - # Other possible tests: - # -lpthreads (FSU threads, PCthreads) - # -lgthreads - gl_have_pthread= - # Test whether both pthread_mutex_lock and pthread_mutexattr_init exist - # in libc. IRIX 6.5 has the first one in both libc and libpthread, but - # the second one only in libpthread, and lock.c needs it. - # - # If -pthread works, prefer it to -lpthread, since Ubuntu 14.04 - # needs -pthread for some reason. See: - # https://lists.gnu.org/r/bug-gnulib/2014-09/msg00023.html - save_LIBS=$LIBS - for gl_pthread in '' '-pthread'; do - LIBS="$LIBS $gl_pthread" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - pthread_mutex_t m; - pthread_mutexattr_t ma; + fi + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include int main (void) { -pthread_mutex_lock (&m); - pthread_mutexattr_init (&ma); +sched_yield (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : - gl_have_pthread=yes - LIBTHREAD=$gl_pthread LTLIBTHREAD=$gl_pthread - LIBMULTITHREAD=$gl_pthread LTLIBMULTITHREAD=$gl_pthread -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext - LIBS=$save_LIBS - test -n "$gl_have_pthread" && break - done - - # Test for libpthread by looking for pthread_kill. (Not pthread_self, - # since it is defined as a macro on OSF/1.) - if test -n "$gl_have_pthread" && test -z "$LIBTHREAD"; then - # The program links fine without libpthread. But it may actually - # need to link with libpthread in order to create multiple threads. - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for pthread_kill in -lpthread" >&5 -printf %s "checking for pthread_kill in -lpthread... " >&6; } -if test ${ac_cv_lib_pthread_pthread_kill+y} + LIB_SCHED_YIELD= + +else case e in #( + e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for sched_yield in -lrt" >&5 +printf %s "checking for sched_yield in -lrt... " >&6; } +if test ${ac_cv_lib_rt_sched_yield+y} then : printf %s "(cached) " >&6 -else $as_nop - ac_check_lib_save_LIBS=$LIBS -LIBS="-lpthread $LIBS" +else case e in #( + e) ac_check_lib_save_LIBS=$LIBS +LIBS="-lrt $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -char pthread_kill (); + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char sched_yield (void); int main (void) { -return pthread_kill (); +return sched_yield (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : - ac_cv_lib_pthread_pthread_kill=yes -else $as_nop - ac_cv_lib_pthread_pthread_kill=no + ac_cv_lib_rt_sched_yield=yes +else case e in #( + e) ac_cv_lib_rt_sched_yield=no ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS +LIBS=$ac_check_lib_save_LIBS ;; +esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_kill" >&5 -printf "%s\n" "$ac_cv_lib_pthread_pthread_kill" >&6; } -if test "x$ac_cv_lib_pthread_pthread_kill" = xyes +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_rt_sched_yield" >&5 +printf "%s\n" "$ac_cv_lib_rt_sched_yield" >&6; } +if test "x$ac_cv_lib_rt_sched_yield" = xyes then : - LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread - # On Solaris and HP-UX, most pthread functions exist also in libc. - # Therefore pthread_in_use() needs to actually try to create a - # thread: pthread_create from libc will fail, whereas - # pthread_create will actually create a thread. - # On Solaris 10 or newer, this test is no longer needed, because - # libc contains the fully functional pthread functions. - case "$host_os" in - solaris | solaris2.1-9 | solaris2.1-9.* | hpux*) - -printf "%s\n" "#define PTHREAD_IN_USE_DETECTION_HARD 1" >>confdefs.h - - esac - -fi - - elif test -z "$gl_have_pthread"; then - # Some library is needed. Try libpthread and libc_r. - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for pthread_kill in -lpthread" >&5 -printf %s "checking for pthread_kill in -lpthread... " >&6; } -if test ${ac_cv_lib_pthread_pthread_kill+y} + LIB_SCHED_YIELD=-lrt +else case e in #( + e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for sched_yield in -lposix4" >&5 +printf %s "checking for sched_yield in -lposix4... " >&6; } +if test ${ac_cv_lib_posix4_sched_yield+y} then : printf %s "(cached) " >&6 -else $as_nop - ac_check_lib_save_LIBS=$LIBS -LIBS="-lpthread $LIBS" +else case e in #( + e) ac_check_lib_save_LIBS=$LIBS +LIBS="-lposix4 $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -char pthread_kill (); + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char sched_yield (void); int main (void) { -return pthread_kill (); +return sched_yield (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : - ac_cv_lib_pthread_pthread_kill=yes -else $as_nop - ac_cv_lib_pthread_pthread_kill=no + ac_cv_lib_posix4_sched_yield=yes +else case e in #( + e) ac_cv_lib_posix4_sched_yield=no ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS +LIBS=$ac_check_lib_save_LIBS ;; +esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_kill" >&5 -printf "%s\n" "$ac_cv_lib_pthread_pthread_kill" >&6; } -if test "x$ac_cv_lib_pthread_pthread_kill" = xyes +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_posix4_sched_yield" >&5 +printf "%s\n" "$ac_cv_lib_posix4_sched_yield" >&6; } +if test "x$ac_cv_lib_posix4_sched_yield" = xyes then : - gl_have_pthread=yes - LIBTHREAD=-lpthread LTLIBTHREAD=-lpthread - LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread + LIB_SCHED_YIELD=-lposix4 +fi + ;; +esac fi - if test -z "$gl_have_pthread"; then - # For FreeBSD 4. - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for pthread_kill in -lc_r" >&5 + ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + + + gl_pthreadlib_body_done=done + fi + + LIBTHREAD=$LIBPTHREAD LTLIBTHREAD=$LIBPTHREAD + LIBMULTITHREAD=$LIBPMULTITHREAD LTLIBMULTITHREAD=$LIBPMULTITHREAD + if test $gl_pthread_api = yes; then + if test "$gl_use_threads" = isoc+posix && test "$gl_have_isoc_threads" = yes; then + gl_threads_api='isoc+posix' + +printf "%s\n" "#define USE_ISOC_AND_POSIX_THREADS 1" >>confdefs.h + + LIBTHREAD= LTLIBTHREAD= + else + gl_threads_api=posix + +printf "%s\n" "#define USE_POSIX_THREADS 1" >>confdefs.h + + if test -z "$LIBMULTITHREAD" && test -z "$LTLIBMULTITHREAD"; then + +printf "%s\n" "#define USE_POSIX_THREADS_FROM_LIBC 1" >>confdefs.h + + else + if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then + +printf "%s\n" "#define USE_POSIX_THREADS_WEAK 1" >>confdefs.h + + LIBTHREAD= LTLIBTHREAD= + else + case "$host_os" in + freebsd* | dragonfly* | midnightbsd*) + if test "x$LIBTHREAD" != "x$LIBMULTITHREAD"; then + +printf "%s\n" "#define PTHREAD_IN_USE_DETECTION_HARD 1" >>confdefs.h + + fi + ;; + esac + fi + fi + fi + fi + fi + if test $gl_threads_api = none; then + if test "$gl_use_threads" = isoc && test "$gl_have_isoc_threads" = yes; then + + + + if test -z "$gl_stdthreadlib_body_done"; then + + + case "$host_os" in + mingw*) + LIBSTDTHREAD= + ;; + *) + + + if test -z "$gl_pthreadlib_body_done"; then + gl_pthread_api=no + LIBPTHREAD= + LIBPMULTITHREAD= + # On OSF/1, the compiler needs the flag -pthread or -D_REENTRANT so that + # it groks . It's added above, in gl_ANYTHREADLIB_EARLY. + ac_fn_c_check_header_compile "$LINENO" "pthread.h" "ac_cv_header_pthread_h" "$ac_includes_default" +if test "x$ac_cv_header_pthread_h" = xyes +then : + gl_have_pthread_h=yes +else case e in #( + e) gl_have_pthread_h=no ;; +esac +fi + + if test "$gl_have_pthread_h" = yes; then + # Other possible tests: + # -lpthreads (FSU threads, PCthreads) + # -lgthreads + # Test whether both pthread_mutex_lock and pthread_mutexattr_init exist + # in libc. IRIX 6.5 has the first one in both libc and libpthread, but + # the second one only in libpthread, and lock.c needs it. + # + # If -pthread works, prefer it to -lpthread, since Ubuntu 14.04 + # needs -pthread for some reason. See: + # https://lists.gnu.org/r/bug-gnulib/2014-09/msg00023.html + save_LIBS=$LIBS + for gl_pthread in '' '-pthread'; do + LIBS="$LIBS $gl_pthread" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + pthread_mutex_t m; + pthread_mutexattr_t ma; + +int +main (void) +{ +pthread_mutex_lock (&m); + pthread_mutexattr_init (&ma); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + gl_pthread_api=yes + LIBPTHREAD=$gl_pthread + LIBPMULTITHREAD=$gl_pthread +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + LIBS=$save_LIBS + test $gl_pthread_api = yes && break + done + echo "$as_me:9812: gl_pthread_api=$gl_pthread_api" >&5 + echo "$as_me:9813: LIBPTHREAD=$LIBPTHREAD" >&5 + + gl_pthread_in_glibc=no + # On Linux with glibc >= 2.34, libc contains the fully functional + # pthread functions. + case "$host_os" in + linux*) + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + #ifdef __GNU_LIBRARY__ + #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 34) || (__GLIBC__ > 2) + Lucky user + #endif + #endif + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP_TRADITIONAL "Lucky user" >/dev/null 2>&1 +then : + gl_pthread_in_glibc=yes +fi +rm -rf conftest* + + ;; + esac + echo "$as_me:9839: gl_pthread_in_glibc=$gl_pthread_in_glibc" >&5 + + # Test for libpthread by looking for pthread_kill. (Not pthread_self, + # since it is defined as a macro on OSF/1.) + if test $gl_pthread_api = yes && test -z "$LIBPTHREAD"; then + # The program links fine without libpthread. But it may actually + # need to link with libpthread in order to create multiple threads. + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for pthread_kill in -lpthread" >&5 +printf %s "checking for pthread_kill in -lpthread... " >&6; } +if test ${ac_cv_lib_pthread_pthread_kill+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) ac_check_lib_save_LIBS=$LIBS +LIBS="-lpthread $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char pthread_kill (void); +int +main (void) +{ +return pthread_kill (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_lib_pthread_pthread_kill=yes +else case e in #( + e) ac_cv_lib_pthread_pthread_kill=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_kill" >&5 +printf "%s\n" "$ac_cv_lib_pthread_pthread_kill" >&6; } +if test "x$ac_cv_lib_pthread_pthread_kill" = xyes +then : + if test $gl_pthread_in_glibc = yes; then + LIBPMULTITHREAD= + else + LIBPMULTITHREAD=-lpthread + # On Solaris and HP-UX, most pthread functions exist also in libc. + # Therefore pthread_in_use() needs to actually try to create a + # thread: pthread_create from libc will fail, whereas + # pthread_create will actually create a thread. + # On Solaris 10 or newer, this test is no longer needed, because + # libc contains the fully functional pthread functions. + case "$host_os" in + solaris | solaris2.1-9 | solaris2.1-9.* | hpux*) + +printf "%s\n" "#define PTHREAD_IN_USE_DETECTION_HARD 1" >>confdefs.h + + esac + fi + +fi + + elif test $gl_pthread_api != yes; then + # Some library is needed. Try libpthread and libc_r. + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for pthread_kill in -lpthread" >&5 +printf %s "checking for pthread_kill in -lpthread... " >&6; } +if test ${ac_cv_lib_pthread_pthread_kill+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) ac_check_lib_save_LIBS=$LIBS +LIBS="-lpthread $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char pthread_kill (void); +int +main (void) +{ +return pthread_kill (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_lib_pthread_pthread_kill=yes +else case e in #( + e) ac_cv_lib_pthread_pthread_kill=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_kill" >&5 +printf "%s\n" "$ac_cv_lib_pthread_pthread_kill" >&6; } +if test "x$ac_cv_lib_pthread_pthread_kill" = xyes +then : + gl_pthread_api=yes + LIBPTHREAD=-lpthread + LIBPMULTITHREAD=-lpthread +fi + + if test $gl_pthread_api != yes; then + # For FreeBSD 4. + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for pthread_kill in -lc_r" >&5 printf %s "checking for pthread_kill in -lc_r... " >&6; } if test ${ac_cv_lib_c_r_pthread_kill+y} then : printf %s "(cached) " >&6 -else $as_nop - ac_check_lib_save_LIBS=$LIBS +else case e in #( + e) ac_check_lib_save_LIBS=$LIBS LIBS="-lc_r $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -char pthread_kill (); + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char pthread_kill (void); int main (void) { @@ -9613,957 +9994,1269 @@ _ACEOF if ac_fn_c_try_link "$LINENO" then : ac_cv_lib_c_r_pthread_kill=yes -else $as_nop - ac_cv_lib_c_r_pthread_kill=no +else case e in #( + e) ac_cv_lib_c_r_pthread_kill=no ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS +LIBS=$ac_check_lib_save_LIBS ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_c_r_pthread_kill" >&5 printf "%s\n" "$ac_cv_lib_c_r_pthread_kill" >&6; } if test "x$ac_cv_lib_c_r_pthread_kill" = xyes then : - gl_have_pthread=yes - LIBTHREAD=-lc_r LTLIBTHREAD=-lc_r - LIBMULTITHREAD=-lc_r LTLIBMULTITHREAD=-lc_r + gl_pthread_api=yes + LIBPTHREAD=-lc_r + LIBPMULTITHREAD=-lc_r fi - fi fi - if test -n "$gl_have_pthread"; then - gl_threads_api=posix + fi + echo "$as_me:10017: LIBPMULTITHREAD=$LIBPMULTITHREAD" >&5 + fi + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether POSIX threads API is available" >&5 +printf %s "checking whether POSIX threads API is available... " >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gl_pthread_api" >&5 +printf "%s\n" "$gl_pthread_api" >&6; } -printf "%s\n" "#define USE_POSIX_THREADS 1" >>confdefs.h - if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then - if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then + if test $gl_pthread_api = yes; then -printf "%s\n" "#define USE_POSIX_THREADS_WEAK 1" >>confdefs.h +printf "%s\n" "#define HAVE_PTHREAD_API 1" >>confdefs.h - LIBTHREAD= - LTLIBTHREAD= - fi - fi - fi - fi fi - if test -z "$gl_have_pthread"; then - if test "$gl_use_threads" = yes || test "$gl_use_threads" = solaris; then - gl_have_solaristhread= - gl_save_LIBS="$LIBS" - LIBS="$LIBS -lthread" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ +#include +int +main (void) +{ +sched_yield (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + LIB_SCHED_YIELD= -#include -#include +else case e in #( + e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for sched_yield in -lrt" >&5 +printf %s "checking for sched_yield in -lrt... " >&6; } +if test ${ac_cv_lib_rt_sched_yield+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) ac_check_lib_save_LIBS=$LIBS +LIBS="-lrt $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char sched_yield (void); int main (void) { -thr_self(); +return sched_yield (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : - gl_have_solaristhread=yes + ac_cv_lib_rt_sched_yield=yes +else case e in #( + e) ac_cv_lib_rt_sched_yield=no ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext - LIBS="$gl_save_LIBS" - if test -n "$gl_have_solaristhread"; then - gl_threads_api=solaris - LIBTHREAD=-lthread - LTLIBTHREAD=-lthread - LIBMULTITHREAD="$LIBTHREAD" - LTLIBMULTITHREAD="$LTLIBTHREAD" - -printf "%s\n" "#define USE_SOLARIS_THREADS 1" >>confdefs.h - - if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then +LIBS=$ac_check_lib_save_LIBS ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_rt_sched_yield" >&5 +printf "%s\n" "$ac_cv_lib_rt_sched_yield" >&6; } +if test "x$ac_cv_lib_rt_sched_yield" = xyes +then : + LIB_SCHED_YIELD=-lrt +else case e in #( + e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for sched_yield in -lposix4" >&5 +printf %s "checking for sched_yield in -lposix4... " >&6; } +if test ${ac_cv_lib_posix4_sched_yield+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) ac_check_lib_save_LIBS=$LIBS +LIBS="-lposix4 $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ -printf "%s\n" "#define USE_SOLARIS_THREADS_WEAK 1" >>confdefs.h +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char sched_yield (void); +int +main (void) +{ +return sched_yield (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_lib_posix4_sched_yield=yes +else case e in #( + e) ac_cv_lib_posix4_sched_yield=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_posix4_sched_yield" >&5 +printf "%s\n" "$ac_cv_lib_posix4_sched_yield" >&6; } +if test "x$ac_cv_lib_posix4_sched_yield" = xyes +then : + LIB_SCHED_YIELD=-lposix4 +fi + ;; +esac +fi - LIBTHREAD= - LTLIBTHREAD= - fi - fi - fi - fi - if test "$gl_use_threads" = pth; then - gl_save_CPPFLAGS="$CPPFLAGS" + ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + gl_pthreadlib_body_done=done + fi + if test $ac_cv_header_threads_h = yes; then + ac_fn_c_check_func "$LINENO" "thrd_create" "ac_cv_func_thrd_create" +if test "x$ac_cv_func_thrd_create" = xyes +then : + printf "%s\n" "#define HAVE_THRD_CREATE 1" >>confdefs.h +fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to link with libpth" >&5 -printf %s "checking how to link with libpth... " >&6; } -if test ${ac_cv_libpth_libs+y} + if test $ac_cv_func_thrd_create = yes; then + LIBSTDTHREAD= + else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for thrd_create in -lstdthreads" >&5 +printf %s "checking for thrd_create in -lstdthreads... " >&6; } +if test ${ac_cv_lib_stdthreads_thrd_create+y} then : printf %s "(cached) " >&6 -else $as_nop - - - +else case e in #( + e) ac_check_lib_save_LIBS=$LIBS +LIBS="-lstdthreads $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char thrd_create (void); +int +main (void) +{ +return thrd_create (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_lib_stdthreads_thrd_create=yes +else case e in #( + e) ac_cv_lib_stdthreads_thrd_create=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_stdthreads_thrd_create" >&5 +printf "%s\n" "$ac_cv_lib_stdthreads_thrd_create" >&6; } +if test "x$ac_cv_lib_stdthreads_thrd_create" = xyes +then : + LIBSTDTHREAD='-lstdthreads -lpthread' +else case e in #( + e) + LIBSTDTHREAD="$LIBPMULTITHREAD" + ;; +esac +fi - use_additional=yes + fi + else + LIBSTDTHREAD="$LIBPMULTITHREAD $LIB_SCHED_YIELD" + fi + ;; + esac - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - eval additional_includedir=\"$includedir\" - eval additional_libdir=\"$libdir\" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether ISO C threads API is available" >&5 +printf %s "checking whether ISO C threads API is available... " >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_threads_h" >&5 +printf "%s\n" "$ac_cv_header_threads_h" >&6; } + gl_stdthreadlib_body_done=done + fi - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" + LIBTHREAD=$LIBSTDTHREAD LTLIBTHREAD=$LIBSTDTHREAD + LIBMULTITHREAD=$LIBSTDTHREAD LTLIBMULTITHREAD=$LIBSTDTHREAD + gl_threads_api=isoc +printf "%s\n" "#define USE_ISOC_THREADS 1" >>confdefs.h -# Check whether --with-libpth-prefix was given. -if test ${with_libpth_prefix+y} -then : - withval=$with_libpth_prefix; - if test "X$withval" = "Xno"; then - use_additional=no - else - if test "X$withval" = "X"; then + fi + fi + if test $gl_threads_api = none; then + case "$gl_use_threads" in + yes | windows | win32) # The 'win32' is for backward compatibility. + if { case "$host_os" in + mingw*) true;; + *) false;; + esac + }; then + gl_threads_api=windows - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" +printf "%s\n" "#define USE_WINDOWS_THREADS 1" >>confdefs.h - eval additional_includedir=\"$includedir\" - eval additional_libdir=\"$libdir\" + fi + ;; + esac + fi + fi + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for multithread API to use" >&5 +printf %s "checking for multithread API to use... " >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gl_threads_api" >&5 +printf "%s\n" "$gl_threads_api" >&6; } - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" - else - additional_includedir="$withval/include" - additional_libdir="$withval/$acl_libdirstem" - if test "$acl_libdirstem2" != "$acl_libdirstem" \ - && test ! -d "$withval/$acl_libdirstem"; then - additional_libdir="$withval/$acl_libdirstem2" - fi - fi - fi -fi - LIBPTH= - LTLIBPTH= - INCPTH= - LIBPTH_PREFIX= - HAVE_LIBPTH= - rpathdirs= - ltrpathdirs= - names_already_handled= - names_next_round='pth ' - while test -n "$names_next_round"; do - names_this_round="$names_next_round" - names_next_round= - for name in $names_this_round; do - already_handled= - for n in $names_already_handled; do - if test "$n" = "$name"; then - already_handled=yes - break - fi - done - if test -z "$already_handled"; then - names_already_handled="$names_already_handled $name" - uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./+-|ABCDEFGHIJKLMNOPQRSTUVWXYZ____|'` - eval value=\"\$HAVE_LIB$uppername\" - if test -n "$value"; then - if test "$value" = yes; then - eval value=\"\$LIB$uppername\" - test -z "$value" || LIBPTH="${LIBPTH}${LIBPTH:+ }$value" - eval value=\"\$LTLIB$uppername\" - test -z "$value" || LTLIBPTH="${LTLIBPTH}${LTLIBPTH:+ }$value" - else - : - fi - else - found_dir= - found_la= - found_so= - found_a= - eval libname=\"$acl_libname_spec\" # typically: libname=lib$name - if test -n "$acl_shlibext"; then - shrext=".$acl_shlibext" # typically: shrext=.so - else - shrext= - fi - if test $use_additional = yes; then - dir="$additional_libdir" - if test -n "$acl_shlibext"; then - if test -f "$dir/$libname$shrext"; then - found_dir="$dir" - found_so="$dir/$libname$shrext" - else - if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then - ver=`(cd "$dir" && \ - for f in "$libname$shrext".*; do echo "$f"; done \ - | sed -e "s,^$libname$shrext\\\\.,," \ - | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ - | sed 1q ) 2>/dev/null` - if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then - found_dir="$dir" - found_so="$dir/$libname$shrext.$ver" - fi - else - eval library_names=\"$acl_library_names_spec\" - for f in $library_names; do - if test -f "$dir/$f"; then - found_dir="$dir" - found_so="$dir/$f" - break - fi - done - fi - fi - fi - if test "X$found_dir" = "X"; then - if test -f "$dir/$libname.$acl_libext"; then - found_dir="$dir" - found_a="$dir/$libname.$acl_libext" - fi - fi - if test "X$found_dir" != "X"; then - if test -f "$dir/$libname.la"; then - found_la="$dir/$libname.la" - fi - fi - fi - if test "X$found_dir" = "X"; then - for x in $LDFLAGS $LTLIBPTH; do - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - eval x=\"$x\" - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" - case "$x" in - -L*) - dir=`echo "X$x" | sed -e 's/^X-L//'` - if test -n "$acl_shlibext"; then - if test -f "$dir/$libname$shrext"; then - found_dir="$dir" - found_so="$dir/$libname$shrext" - else - if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then - ver=`(cd "$dir" && \ - for f in "$libname$shrext".*; do echo "$f"; done \ - | sed -e "s,^$libname$shrext\\\\.,," \ - | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ - | sed 1q ) 2>/dev/null` - if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then - found_dir="$dir" - found_so="$dir/$libname$shrext.$ver" - fi - else - eval library_names=\"$acl_library_names_spec\" - for f in $library_names; do - if test -f "$dir/$f"; then - found_dir="$dir" - found_so="$dir/$f" - break - fi - done - fi - fi - fi - if test "X$found_dir" = "X"; then - if test -f "$dir/$libname.$acl_libext"; then - found_dir="$dir" - found_a="$dir/$libname.$acl_libext" - fi - fi - if test "X$found_dir" != "X"; then - if test -f "$dir/$libname.la"; then - found_la="$dir/$libname.la" - fi - fi - ;; - esac - if test "X$found_dir" != "X"; then - break - fi - done - fi - if test "X$found_dir" != "X"; then - LTLIBPTH="${LTLIBPTH}${LTLIBPTH:+ }-L$found_dir -l$name" - if test "X$found_so" != "X"; then - if test "$enable_rpath" = no \ - || test "X$found_dir" = "X/usr/$acl_libdirstem" \ - || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then - LIBPTH="${LIBPTH}${LIBPTH:+ }$found_so" - else - haveit= - for x in $ltrpathdirs; do - if test "X$x" = "X$found_dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - ltrpathdirs="$ltrpathdirs $found_dir" - fi - if test "$acl_hardcode_direct" = yes; then - LIBPTH="${LIBPTH}${LIBPTH:+ }$found_so" - else - if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then - LIBPTH="${LIBPTH}${LIBPTH:+ }$found_so" - haveit= - for x in $rpathdirs; do - if test "X$x" = "X$found_dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - rpathdirs="$rpathdirs $found_dir" - fi - else - haveit= - for x in $LDFLAGS $LIBPTH; do - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - eval x=\"$x\" - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" - if test "X$x" = "X-L$found_dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - LIBPTH="${LIBPTH}${LIBPTH:+ }-L$found_dir" - fi - if test "$acl_hardcode_minus_L" != no; then - LIBPTH="${LIBPTH}${LIBPTH:+ }$found_so" - else - LIBPTH="${LIBPTH}${LIBPTH:+ }-l$name" - fi - fi - fi - fi - else - if test "X$found_a" != "X"; then - LIBPTH="${LIBPTH}${LIBPTH:+ }$found_a" - else - LIBPTH="${LIBPTH}${LIBPTH:+ }-L$found_dir -l$name" - fi - fi - additional_includedir= - case "$found_dir" in - */$acl_libdirstem | */$acl_libdirstem/) - basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'` - if test "$name" = 'pth'; then - LIBPTH_PREFIX="$basedir" - fi - additional_includedir="$basedir/include" - ;; - */$acl_libdirstem2 | */$acl_libdirstem2/) - basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'` - if test "$name" = 'pth'; then - LIBPTH_PREFIX="$basedir" - fi - additional_includedir="$basedir/include" - ;; - esac - if test "X$additional_includedir" != "X"; then - if test "X$additional_includedir" != "X/usr/include"; then - haveit= - if test "X$additional_includedir" = "X/usr/local/include"; then - if test -n "$GCC"; then - case $host_os in - linux* | gnu* | k*bsd*-gnu) haveit=yes;; - esac - fi - fi - if test -z "$haveit"; then - for x in $CPPFLAGS $INCPTH; do - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - eval x=\"$x\" - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" - if test "X$x" = "X-I$additional_includedir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - if test -d "$additional_includedir"; then - INCPTH="${INCPTH}${INCPTH:+ }-I$additional_includedir" - fi - fi - fi - fi - fi - if test -n "$found_la"; then - save_libdir="$libdir" - case "$found_la" in - */* | *\\*) . "$found_la" ;; - *) . "./$found_la" ;; - esac - libdir="$save_libdir" - for dep in $dependency_libs; do - case "$dep" in - -L*) - additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` - if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \ - && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then - haveit= - if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \ - || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then - if test -n "$GCC"; then - case $host_os in - linux* | gnu* | k*bsd*-gnu) haveit=yes;; - esac - fi - fi - if test -z "$haveit"; then - haveit= - for x in $LDFLAGS $LIBPTH; do - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - eval x=\"$x\" - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" + if test "$gl_threads_api" = posix; then + # OSF/1 4.0 and Mac OS X 10.1 lack the pthread_rwlock_t type and the + # pthread_rwlock_* functions. + has_rwlock=false + ac_fn_c_check_type "$LINENO" "pthread_rwlock_t" "ac_cv_type_pthread_rwlock_t" "#include +" +if test "x$ac_cv_type_pthread_rwlock_t" = xyes +then : + has_rwlock=true + +printf "%s\n" "#define HAVE_PTHREAD_RWLOCK 1" >>confdefs.h + +fi + + if $has_rwlock; then + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether pthread_rwlock_rdlock prefers a writer to a reader" >&5 +printf %s "checking whether pthread_rwlock_rdlock prefers a writer to a reader... " >&6; } +if test ${gl_cv_pthread_rwlock_rdlock_prefer_writer+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) save_LIBS="$LIBS" + LIBS="$LIBS $LIBMULTITHREAD" + if test "$cross_compiling" = yes +then : + case "$host_os" in + # Guess no on glibc systems. + *-gnu* | gnu*) gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing no" ;; + # Guess no on musl systems. + *-musl*) gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing no" ;; + # Guess no on bionic systems. + *-android*) gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing no" ;; + # Guess yes on native Windows with the mingw-w64 winpthreads library. + # Guess no on native Windows with the gnulib windows-rwlock module. + mingw*) if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then + gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing yes" + else + gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing no" + fi + ;; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_pthread_rwlock_rdlock_prefer_writer="$gl_cross_guess_normal" ;; + esac + +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#include +#include + +#define SUCCEED() exit (0) +#define FAILURE() exit (1) +#define UNEXPECTED(n) (exit (10 + (n))) - if test "X$x" = "X-L$additional_libdir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - if test -d "$additional_libdir"; then - LIBPTH="${LIBPTH}${LIBPTH:+ }-L$additional_libdir" - fi - fi - haveit= - for x in $LDFLAGS $LTLIBPTH; do +/* The main thread creates the waiting writer and the requesting reader threads + in the default way; this guarantees that they have the same priority. + We can reuse the main thread as first reader thread. */ - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - eval x=\"$x\" - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" +static pthread_rwlock_t lock; +static pthread_t reader1; +static pthread_t writer; +static pthread_t reader2; +static pthread_t timer; +/* Used to pass control from writer to reader2 and from reader2 to timer, + as in a relay race. + Passing control from one running thread to another running thread + is most likely faster than to create the second thread. */ +static pthread_mutex_t baton; - if test "X$x" = "X-L$additional_libdir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - if test -d "$additional_libdir"; then - LTLIBPTH="${LTLIBPTH}${LTLIBPTH:+ }-L$additional_libdir" - fi - fi - fi - fi - ;; - -R*) - dir=`echo "X$dep" | sed -e 's/^X-R//'` - if test "$enable_rpath" != no; then - haveit= - for x in $rpathdirs; do - if test "X$x" = "X$dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - rpathdirs="$rpathdirs $dir" - fi - haveit= - for x in $ltrpathdirs; do - if test "X$x" = "X$dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - ltrpathdirs="$ltrpathdirs $dir" - fi - fi - ;; - -l*) - names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` - ;; - *.la) - names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` - ;; - *) - LIBPTH="${LIBPTH}${LIBPTH:+ }$dep" - LTLIBPTH="${LTLIBPTH}${LTLIBPTH:+ }$dep" - ;; - esac - done - fi - else - LIBPTH="${LIBPTH}${LIBPTH:+ }-l$name" - LTLIBPTH="${LTLIBPTH}${LTLIBPTH:+ }-l$name" - fi - fi - fi - done - done - if test "X$rpathdirs" != "X"; then - if test -n "$acl_hardcode_libdir_separator"; then - alldirs= - for found_dir in $rpathdirs; do - alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir" - done - acl_save_libdir="$libdir" - libdir="$alldirs" - eval flag=\"$acl_hardcode_libdir_flag_spec\" - libdir="$acl_save_libdir" - LIBPTH="${LIBPTH}${LIBPTH:+ }$flag" - else - for found_dir in $rpathdirs; do - acl_save_libdir="$libdir" - libdir="$found_dir" - eval flag=\"$acl_hardcode_libdir_flag_spec\" - libdir="$acl_save_libdir" - LIBPTH="${LIBPTH}${LIBPTH:+ }$flag" - done - fi - fi - if test "X$ltrpathdirs" != "X"; then - for found_dir in $ltrpathdirs; do - LTLIBPTH="${LTLIBPTH}${LTLIBPTH:+ }-R$found_dir" - done - fi +static void * +timer_func (void *ignored) +{ + /* Step 13 (can be before or after step 12): + The timer thread takes the baton, then waits a moment to make sure + it can tell whether the second reader thread is blocked at step 12. */ + if (pthread_mutex_lock (&baton)) + UNEXPECTED (13); + usleep (100000); + /* By the time we get here, it's clear that the second reader thread is + blocked at step 12. This is the desired behaviour. */ + SUCCEED (); +} + +static void * +reader2_func (void *ignored) +{ + int err; + /* Step 8 (can be before or after step 7): + The second reader thread takes the baton, then waits a moment to make sure + the writer thread has reached step 7. */ + if (pthread_mutex_lock (&baton)) + UNEXPECTED (8); + usleep (100000); + /* Step 9: The second reader thread requests the lock. */ + err = pthread_rwlock_tryrdlock (&lock); + if (err == 0) + FAILURE (); + else if (err != EBUSY) + UNEXPECTED (9); + /* Step 10: Launch a timer, to test whether the next call blocks. */ + if (pthread_create (&timer, NULL, timer_func, NULL)) + UNEXPECTED (10); + /* Step 11: Release the baton. */ + if (pthread_mutex_unlock (&baton)) + UNEXPECTED (11); + /* Step 12: The second reader thread requests the lock. */ + err = pthread_rwlock_rdlock (&lock); + if (err == 0) + FAILURE (); + else + UNEXPECTED (12); +} +static void * +writer_func (void *ignored) +{ + /* Step 4: Take the baton, so that the second reader thread does not go ahead + too early. */ + if (pthread_mutex_lock (&baton)) + UNEXPECTED (4); + /* Step 5: Create the second reader thread. */ + if (pthread_create (&reader2, NULL, reader2_func, NULL)) + UNEXPECTED (5); + /* Step 6: Release the baton. */ + if (pthread_mutex_unlock (&baton)) + UNEXPECTED (6); + /* Step 7: The writer thread requests the lock. */ + if (pthread_rwlock_wrlock (&lock)) + UNEXPECTED (7); + return NULL; +} +int +main () +{ + reader1 = pthread_self (); + /* Step 1: The main thread initializes the lock and the baton. */ + if (pthread_rwlock_init (&lock, NULL)) + UNEXPECTED (1); + if (pthread_mutex_init (&baton, NULL)) + UNEXPECTED (1); + /* Step 2: The main thread acquires the lock as a reader. */ + if (pthread_rwlock_rdlock (&lock)) + UNEXPECTED (2); + /* Step 3: Create the writer thread. */ + if (pthread_create (&writer, NULL, writer_func, NULL)) + UNEXPECTED (3); + /* Job done. Go to sleep. */ + for (;;) + { + sleep (1); + } +} - ac_cv_libpth_libs="$LIBPTH" - ac_cv_libpth_ltlibs="$LTLIBPTH" - ac_cv_libpth_cppflags="$INCPTH" - ac_cv_libpth_prefix="$LIBPTH_PREFIX" +_ACEOF +if ac_fn_c_try_run "$LINENO" +then : + gl_cv_pthread_rwlock_rdlock_prefer_writer=yes +else case e in #( + e) gl_cv_pthread_rwlock_rdlock_prefer_writer=no ;; +esac +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac +fi + LIBS="$save_LIBS" + ;; +esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_libpth_libs" >&5 -printf "%s\n" "$ac_cv_libpth_libs" >&6; } - LIBPTH="$ac_cv_libpth_libs" - LTLIBPTH="$ac_cv_libpth_ltlibs" - INCPTH="$ac_cv_libpth_cppflags" - LIBPTH_PREFIX="$ac_cv_libpth_prefix" +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gl_cv_pthread_rwlock_rdlock_prefer_writer" >&5 +printf "%s\n" "$gl_cv_pthread_rwlock_rdlock_prefer_writer" >&6; } + case "$gl_cv_pthread_rwlock_rdlock_prefer_writer" in + *yes) - for element in $INCPTH; do - haveit= - for x in $CPPFLAGS; do +printf "%s\n" "#define HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER 1" >>confdefs.h - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - eval x=\"$x\" - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" + ;; + esac - if test "X$x" = "X$element"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element" fi - done + # glibc defines PTHREAD_MUTEX_RECURSIVE as enum, not as a macro. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #include +int +main (void) +{ +#if __FreeBSD__ == 4 +error "No, in FreeBSD 4.0 recursive mutexes actually don't work." +#elif (defined __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ \ + && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1070) +error "No, in Mac OS X < 10.7 recursive mutexes actually don't work." +#else +int x = (int)PTHREAD_MUTEX_RECURSIVE; +return !x; +#endif + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : +printf "%s\n" "#define HAVE_PTHREAD_MUTEX_RECURSIVE 1" >>confdefs.h - HAVE_LIBPTH=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + fi + : +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC options needed to detect all undeclared functions" >&5 +printf %s "checking for $CC options needed to detect all undeclared functions... " >&6; } +if test ${ac_cv_c_undeclared_builtin_options+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) ac_save_CFLAGS=$CFLAGS + ac_cv_c_undeclared_builtin_options='cannot detect' + for ac_arg in '' -fno-builtin; do + CFLAGS="$ac_save_CFLAGS $ac_arg" + # This test program should *not* compile successfully. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int +main (void) +{ +(void) strchr; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : - gl_have_pth= - gl_save_LIBS="$LIBS" - LIBS="$LIBS $LIBPTH" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) # This test program should compile successfully. + # No library function is consistently available on + # freestanding implementations, so test against a dummy + # declaration. Include always-available headers on the + # off chance that they somehow elicit warnings. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include +#include +#include +#include +#include +extern void ac_decl (int, char *); + int main (void) { -pth_self(); +(void) ac_decl (0, (char *) 0); + (void) ac_decl; + ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" +if ac_fn_c_try_compile "$LINENO" then : - gl_have_pth=yes + if test x"$ac_arg" = x +then : + ac_cv_c_undeclared_builtin_options='none needed' +else case e in #( + e) ac_cv_c_undeclared_builtin_options=$ac_arg ;; +esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext - LIBS="$gl_save_LIBS" - if test -n "$gl_have_pth"; then - gl_threads_api=pth - LIBTHREAD="$LIBPTH" - LTLIBTHREAD="$LTLIBPTH" - LIBMULTITHREAD="$LIBTHREAD" - LTLIBMULTITHREAD="$LTLIBTHREAD" + break +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + done + CFLAGS=$ac_save_CFLAGS + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_undeclared_builtin_options" >&5 +printf "%s\n" "$ac_cv_c_undeclared_builtin_options" >&6; } + case $ac_cv_c_undeclared_builtin_options in #( + 'cannot detect') : + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "cannot make $CC report undeclared builtins +See 'config.log' for more details" "$LINENO" 5; } ;; #( + 'none needed') : + ac_c_undeclared_builtin_options='' ;; #( + *) : + ac_c_undeclared_builtin_options=$ac_cv_c_undeclared_builtin_options ;; +esac -printf "%s\n" "#define USE_PTH_THREADS 1" >>confdefs.h - if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then - if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then + if test "X$prefix" = "XNONE"; then + acl_final_prefix="$ac_default_prefix" + else + acl_final_prefix="$prefix" + fi + if test "X$exec_prefix" = "XNONE"; then + acl_final_exec_prefix='${prefix}' + else + acl_final_exec_prefix="$exec_prefix" + fi + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + eval acl_final_exec_prefix=\"$acl_final_exec_prefix\" + prefix="$acl_save_prefix" -printf "%s\n" "#define USE_PTH_THREADS_WEAK 1" >>confdefs.h - LIBTHREAD= - LTLIBTHREAD= - fi - fi - else - CPPFLAGS="$gl_save_CPPFLAGS" - fi - fi - if test -z "$gl_have_pthread"; then - case "$gl_use_threads" in - yes | windows | win32) # The 'win32' is for backward compatibility. - if { case "$host_os" in - mingw*) true;; - *) false;; - esac - }; then - gl_threads_api=windows -printf "%s\n" "#define USE_WINDOWS_THREADS 1" >>confdefs.h +# Check whether --with-gnu-ld was given. +if test ${with_gnu_ld+y} +then : + withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes +else case e in #( + e) with_gnu_ld=no ;; +esac +fi - fi +# Prepare PATH_SEPARATOR. +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which + # contains only /bin. Note that ksh looks also at the FPATH variable, + # so we have to set that as well for the test. + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ + && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ + || PATH_SEPARATOR=';' + } +fi + +if test -n "$LD"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ld" >&5 +printf %s "checking for ld... " >&6; } +elif test "$GCC" = yes; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 +printf %s "checking for ld used by $CC... " >&6; } +elif test "$with_gnu_ld" = yes; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 +printf %s "checking for GNU ld... " >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 +printf %s "checking for non-GNU ld... " >&6; } +fi +if test -n "$LD"; then + # Let the user override the test with a path. + : +else + if test ${acl_cv_path_LD+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) + acl_cv_path_LD= # Final result of this test + ac_prog=ld # Program to search in $PATH + if test "$GCC" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return which upsets mingw + acl_output=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + acl_output=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $acl_output in + # Accept absolute paths. + [\\/]* | ?:[\\/]*) + re_direlt='/[^/][^/]*/\.\./' + # Canonicalize the pathname of ld + acl_output=`echo "$acl_output" | sed 's%\\\\%/%g'` + while echo "$acl_output" | grep "$re_direlt" > /dev/null 2>&1; do + acl_output=`echo $acl_output | sed "s%$re_direlt%/%"` + done + # Got the pathname. No search in PATH is needed. + acl_cv_path_LD="$acl_output" + ac_prog= + ;; + "") + # If it fails, then pretend we aren't using GCC. + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown ;; esac fi - fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for multithread API to use" >&5 -printf %s "checking for multithread API to use... " >&6; } - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gl_threads_api" >&5 -printf "%s\n" "$gl_threads_api" >&6; } - + if test -n "$ac_prog"; then + # Search for $ac_prog in $PATH. + acl_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS="$acl_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + acl_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some variants of GNU ld only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$acl_cv_path_LD" -v 2>&1 conftest.$ac_ext +/* end confdefs.h. */ +#if defined __powerpc64__ || defined __LP64__ + int ok; + #else + error fail + #endif +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + # The compiler produces 64-bit code. Add option '-b64' so that the + # linker groks 64-bit object files. + case "$acl_cv_path_LD " in + *" -b64 "*) ;; + *) acl_cv_path_LD="$acl_cv_path_LD -b64" ;; + esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; + sparc64-*-netbsd*) + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#if defined __sparcv9 || defined __arch64__ + int ok; + #else + error fail + #endif +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : +else case e in #( + e) # The compiler produces 32-bit code. Add option '-m elf32_sparc' + # so that the linker groks 32-bit object files. + case "$acl_cv_path_LD " in + *" -m elf32_sparc "*) ;; + *) acl_cv_path_LD="$acl_cv_path_LD -m elf32_sparc" ;; + esac + ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; + esac + ;; +esac +fi + LD="$acl_cv_path_LD" +fi +if test -n "$LD"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $LD" >&5 +printf "%s\n" "$LD" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 +printf %s "checking if the linker ($LD) is GNU ld... " >&6; } +if test ${acl_cv_prog_gnu_ld+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) # I'd rather use --version here, but apparently some GNU lds only accept -v. +case `$LD -v 2>&1 &5 +printf "%s\n" "$acl_cv_prog_gnu_ld" >&6; } +with_gnu_ld=$acl_cv_prog_gnu_ld - if test "$gl_threads_api" = posix; then - # OSF/1 4.0 and Mac OS X 10.1 lack the pthread_rwlock_t type and the - # pthread_rwlock_* functions. - has_rwlock=false - ac_fn_c_check_type "$LINENO" "pthread_rwlock_t" "ac_cv_type_pthread_rwlock_t" "#include -" -if test "x$ac_cv_type_pthread_rwlock_t" = xyes + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5 +printf %s "checking for shared library run path origin... " >&6; } +if test ${acl_cv_rpath+y} then : - has_rwlock=true - -printf "%s\n" "#define HAVE_PTHREAD_RWLOCK 1" >>confdefs.h - + printf %s "(cached) " >&6 +else case e in #( + e) + CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \ + ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh + . ./conftest.sh + rm -f ./conftest.sh + acl_cv_rpath=done + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $acl_cv_rpath" >&5 +printf "%s\n" "$acl_cv_rpath" >&6; } + wl="$acl_cv_wl" + acl_libext="$acl_cv_libext" + acl_shlibext="$acl_cv_shlibext" + acl_libname_spec="$acl_cv_libname_spec" + acl_library_names_spec="$acl_cv_library_names_spec" + acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" + acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" + acl_hardcode_direct="$acl_cv_hardcode_direct" + acl_hardcode_minus_L="$acl_cv_hardcode_minus_L" + # Check whether --enable-rpath was given. +if test ${enable_rpath+y} +then : + enableval=$enable_rpath; : +else case e in #( + e) enable_rpath=yes ;; +esac fi - if $has_rwlock; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether pthread_rwlock_rdlock prefers a writer to a reader" >&5 -printf %s "checking whether pthread_rwlock_rdlock prefers a writer to a reader... " >&6; } -if test ${gl_cv_pthread_rwlock_rdlock_prefer_writer+y} + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking 32-bit host C ABI" >&5 +printf %s "checking 32-bit host C ABI... " >&6; } +if test ${gl_cv_host_cpu_c_abi_32bit+y} then : printf %s "(cached) " >&6 -else $as_nop - save_LIBS="$LIBS" - LIBS="$LIBS $LIBMULTITHREAD" - if test "$cross_compiling" = yes -then : - gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing yes" -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ +else case e in #( + e) if test -n "$gl_cv_host_cpu_c_abi"; then + case "$gl_cv_host_cpu_c_abi" in + i386 | x86_64-x32 | arm | armhf | arm64-ilp32 | hppa | ia64-ilp32 | mips | mipsn32 | powerpc | riscv*-ilp32* | s390 | sparc) + gl_cv_host_cpu_c_abi_32bit=yes ;; + x86_64 | alpha | arm64 | hppa64 | ia64 | mips64 | powerpc64 | powerpc64-elfv2 | riscv*-lp64* | s390x | sparc64 ) + gl_cv_host_cpu_c_abi_32bit=no ;; + *) + gl_cv_host_cpu_c_abi_32bit=unknown ;; + esac + else + case "$host_cpu" in -#include -#include -#include -#include + # CPUs that only support a 32-bit ABI. + arc \ + | bfin \ + | cris* \ + | csky \ + | epiphany \ + | ft32 \ + | h8300 \ + | m68k \ + | microblaze | microblazeel \ + | nds32 | nds32le | nds32be \ + | nios2 | nios2eb | nios2el \ + | or1k* \ + | or32 \ + | sh | sh1234 | sh1234elb \ + | tic6x \ + | xtensa* ) + gl_cv_host_cpu_c_abi_32bit=yes + ;; -#define SUCCEED() exit (0) -#define FAILURE() exit (1) -#define UNEXPECTED(n) (exit (10 + (n))) + # CPUs that only support a 64-bit ABI. + alpha | alphaev[4-8] | alphaev56 | alphapca5[67] | alphaev6[78] \ + | mmix ) + gl_cv_host_cpu_c_abi_32bit=no + ;; -/* The main thread creates the waiting writer and the requesting reader threads - in the default way; this guarantees that they have the same priority. - We can reuse the main thread as first reader thread. */ + i[34567]86 ) + gl_cv_host_cpu_c_abi_32bit=yes + ;; -static pthread_rwlock_t lock; -static pthread_t reader1; -static pthread_t writer; -static pthread_t reader2; -static pthread_t timer; -/* Used to pass control from writer to reader2 and from reader2 to timer, - as in a relay race. - Passing control from one running thread to another running thread - is most likely faster than to create the second thread. */ -static pthread_mutex_t baton; + x86_64 ) + # On x86_64 systems, the C compiler may be generating code in one of + # these ABIs: + # - 64-bit instruction set, 64-bit pointers, 64-bit 'long': x86_64. + # - 64-bit instruction set, 64-bit pointers, 32-bit 'long': x86_64 + # with native Windows (mingw, MSVC). + # - 64-bit instruction set, 32-bit pointers, 32-bit 'long': x86_64-x32. + # - 32-bit instruction set, 32-bit pointers, 32-bit 'long': i386. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#if (defined __x86_64__ || defined __amd64__ \ + || defined _M_X64 || defined _M_AMD64) \ + && !(defined __ILP32__ || defined _ILP32) + int ok; + #else + error fail + #endif -static void * -timer_func (void *ignored) -{ - /* Step 13 (can be before or after step 12): - The timer thread takes the baton, then waits a moment to make sure - it can tell whether the second reader thread is blocked at step 12. */ - if (pthread_mutex_lock (&baton)) - UNEXPECTED (13); - usleep (100000); - /* By the time we get here, it's clear that the second reader thread is - blocked at step 12. This is the desired behaviour. */ - SUCCEED (); -} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + gl_cv_host_cpu_c_abi_32bit=no +else case e in #( + e) gl_cv_host_cpu_c_abi_32bit=yes ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; -static void * -reader2_func (void *ignored) -{ - int err; + arm* | aarch64 ) + # Assume arm with EABI. + # On arm64 systems, the C compiler may be generating code in one of + # these ABIs: + # - aarch64 instruction set, 64-bit pointers, 64-bit 'long': arm64. + # - aarch64 instruction set, 32-bit pointers, 32-bit 'long': arm64-ilp32. + # - 32-bit instruction set, 32-bit pointers, 32-bit 'long': arm or armhf. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#if defined __aarch64__ && !(defined __ILP32__ || defined _ILP32) + int ok; + #else + error fail + #endif - /* Step 8 (can be before or after step 7): - The second reader thread takes the baton, then waits a moment to make sure - the writer thread has reached step 7. */ - if (pthread_mutex_lock (&baton)) - UNEXPECTED (8); - usleep (100000); - /* Step 9: The second reader thread requests the lock. */ - err = pthread_rwlock_tryrdlock (&lock); - if (err == 0) - FAILURE (); - else if (err != EBUSY) - UNEXPECTED (9); - /* Step 10: Launch a timer, to test whether the next call blocks. */ - if (pthread_create (&timer, NULL, timer_func, NULL)) - UNEXPECTED (10); - /* Step 11: Release the baton. */ - if (pthread_mutex_unlock (&baton)) - UNEXPECTED (11); - /* Step 12: The second reader thread requests the lock. */ - err = pthread_rwlock_rdlock (&lock); - if (err == 0) - FAILURE (); - else - UNEXPECTED (12); -} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + gl_cv_host_cpu_c_abi_32bit=no +else case e in #( + e) gl_cv_host_cpu_c_abi_32bit=yes ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; -static void * -writer_func (void *ignored) -{ - /* Step 4: Take the baton, so that the second reader thread does not go ahead - too early. */ - if (pthread_mutex_lock (&baton)) - UNEXPECTED (4); - /* Step 5: Create the second reader thread. */ - if (pthread_create (&reader2, NULL, reader2_func, NULL)) - UNEXPECTED (5); - /* Step 6: Release the baton. */ - if (pthread_mutex_unlock (&baton)) - UNEXPECTED (6); - /* Step 7: The writer thread requests the lock. */ - if (pthread_rwlock_wrlock (&lock)) - UNEXPECTED (7); - return NULL; -} + hppa1.0 | hppa1.1 | hppa2.0* | hppa64 ) + # On hppa, the C compiler may be generating 32-bit code or 64-bit + # code. In the latter case, it defines _LP64 and __LP64__. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __LP64__ + int ok; + #else + error fail + #endif -int -main () -{ - reader1 = pthread_self (); +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + gl_cv_host_cpu_c_abi_32bit=no +else case e in #( + e) gl_cv_host_cpu_c_abi_32bit=yes ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; - /* Step 1: The main thread initializes the lock and the baton. */ - if (pthread_rwlock_init (&lock, NULL)) - UNEXPECTED (1); - if (pthread_mutex_init (&baton, NULL)) - UNEXPECTED (1); - /* Step 2: The main thread acquires the lock as a reader. */ - if (pthread_rwlock_rdlock (&lock)) - UNEXPECTED (2); - /* Step 3: Create the writer thread. */ - if (pthread_create (&writer, NULL, writer_func, NULL)) - UNEXPECTED (3); - /* Job done. Go to sleep. */ - for (;;) - { - sleep (1); - } -} + ia64* ) + # On ia64 on HP-UX, the C compiler may be generating 64-bit code or + # 32-bit code. In the latter case, it defines _ILP32. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef _ILP32 + int ok; + #else + error fail + #endif + +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + gl_cv_host_cpu_c_abi_32bit=yes +else case e in #( + e) gl_cv_host_cpu_c_abi_32bit=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; + + mips* ) + # We should also check for (_MIPS_SZPTR == 64), but gcc keeps this + # at 32. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#if defined _MIPS_SZLONG && (_MIPS_SZLONG == 64) + int ok; + #else + error fail + #endif _ACEOF -if ac_fn_c_try_run "$LINENO" +if ac_fn_c_try_compile "$LINENO" then : - gl_cv_pthread_rwlock_rdlock_prefer_writer=yes -else $as_nop - gl_cv_pthread_rwlock_rdlock_prefer_writer=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext + gl_cv_host_cpu_c_abi_32bit=no +else case e in #( + e) gl_cv_host_cpu_c_abi_32bit=yes ;; +esac fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; - LIBS="$save_LIBS" + powerpc* ) + # Different ABIs are in use on AIX vs. Mac OS X vs. Linux,*BSD. + # No need to distinguish them here; the caller may distinguish + # them based on the OS. + # On powerpc64 systems, the C compiler may still be generating + # 32-bit code. And on powerpc-ibm-aix systems, the C compiler may + # be generating 64-bit code. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#if defined __powerpc64__ || defined __LP64__ + int ok; + #else + error fail + #endif +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + gl_cv_host_cpu_c_abi_32bit=no +else case e in #( + e) gl_cv_host_cpu_c_abi_32bit=yes ;; +esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gl_cv_pthread_rwlock_rdlock_prefer_writer" >&5 -printf "%s\n" "$gl_cv_pthread_rwlock_rdlock_prefer_writer" >&6; } - case "$gl_cv_pthread_rwlock_rdlock_prefer_writer" in - *yes) - -printf "%s\n" "#define HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER 1" >>confdefs.h +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; - ;; - esac + rs6000 ) + gl_cv_host_cpu_c_abi_32bit=yes + ;; - fi - # glibc defines PTHREAD_MUTEX_RECURSIVE as enum, not as a macro. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + riscv32 | riscv64 ) + # There are 6 ABIs: ilp32, ilp32f, ilp32d, lp64, lp64f, lp64d. + # Size of 'long' and 'void *': + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ +#if defined __LP64__ + int ok; + #else + error fail + #endif - #include -int -main (void) -{ - -#if __FreeBSD__ == 4 -error "No, in FreeBSD 4.0 recursive mutexes actually don't work." -#elif (defined __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ \ - && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1070) -error "No, in Mac OS X < 10.7 recursive mutexes actually don't work." -#else -int x = (int)PTHREAD_MUTEX_RECURSIVE; -return !x; -#endif - - ; - return 0; -} _ACEOF if ac_fn_c_try_compile "$LINENO" then : - -printf "%s\n" "#define HAVE_PTHREAD_MUTEX_RECURSIVE 1" >>confdefs.h - + gl_cv_host_cpu_c_abi_32bit=no +else case e in #( + e) gl_cv_host_cpu_c_abi_32bit=yes ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - fi - : + ;; -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC options needed to detect all undeclared functions" >&5 -printf %s "checking for $CC options needed to detect all undeclared functions... " >&6; } -if test ${ac_cv_c_undeclared_builtin_options+y} -then : - printf %s "(cached) " >&6 -else $as_nop - ac_save_CFLAGS=$CFLAGS - ac_cv_c_undeclared_builtin_options='cannot detect' - for ac_arg in '' -fno-builtin; do - CFLAGS="$ac_save_CFLAGS $ac_arg" - # This test program should *not* compile successfully. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + s390* ) + # On s390x, the C compiler may be generating 64-bit (= s390x) code + # or 31-bit (= s390) code. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ +#if defined __LP64__ || defined __s390x__ + int ok; + #else + error fail + #endif -int -main (void) -{ -(void) strchr; - ; - return 0; -} _ACEOF if ac_fn_c_try_compile "$LINENO" then : + gl_cv_host_cpu_c_abi_32bit=no +else case e in #( + e) gl_cv_host_cpu_c_abi_32bit=yes ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; -else $as_nop - # This test program should compile successfully. - # No library function is consistently available on - # freestanding implementations, so test against a dummy - # declaration. Include always-available headers on the - # off chance that they somehow elicit warnings. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + sparc | sparc64 ) + # UltraSPARCs running Linux have `uname -m` = "sparc64", but the + # C compiler still generates 32-bit code. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include -#include -#include -#include -extern void ac_decl (int, char *); - -int -main (void) -{ -(void) ac_decl (0, (char *) 0); - (void) ac_decl; +#if defined __sparcv9 || defined __arch64__ + int ok; + #else + error fail + #endif - ; - return 0; -} _ACEOF if ac_fn_c_try_compile "$LINENO" then : - if test x"$ac_arg" = x -then : - ac_cv_c_undeclared_builtin_options='none needed' -else $as_nop - ac_cv_c_undeclared_builtin_options=$ac_arg -fi - break + gl_cv_host_cpu_c_abi_32bit=no +else case e in #( + e) gl_cv_host_cpu_c_abi_32bit=yes ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; + + *) + gl_cv_host_cpu_c_abi_32bit=unknown + ;; + esac + fi + ;; +esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - done - CFLAGS=$ac_save_CFLAGS +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gl_cv_host_cpu_c_abi_32bit" >&5 +printf "%s\n" "$gl_cv_host_cpu_c_abi_32bit" >&6; } + + HOST_CPU_C_ABI_32BIT="$gl_cv_host_cpu_c_abi_32bit" + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ELF binary format" >&5 +printf %s "checking for ELF binary format... " >&6; } +if test ${gl_cv_elf+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#if defined __ELF__ || (defined __linux__ && defined __EDG__) + Extensible Linking Format + #endif + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP_TRADITIONAL "Extensible Linking Format" >/dev/null 2>&1 +then : + gl_cv_elf=yes +else case e in #( + e) gl_cv_elf=no ;; +esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_undeclared_builtin_options" >&5 -printf "%s\n" "$ac_cv_c_undeclared_builtin_options" >&6; } - case $ac_cv_c_undeclared_builtin_options in #( - 'cannot detect') : - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot make $CC report undeclared builtins -See \`config.log' for more details" "$LINENO" 5; } ;; #( - 'none needed') : - ac_c_undeclared_builtin_options='' ;; #( - *) : - ac_c_undeclared_builtin_options=$ac_cv_c_undeclared_builtin_options ;; +rm -rf conftest* + + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gl_cv_elf" >&5 +printf "%s\n" "$gl_cv_elf" >&6; } + if test $gl_cv_elf = yes; then + # Extract the ELF class of a file (5th byte) in decimal. + # Cf. https://en.wikipedia.org/wiki/Executable_and_Linkable_Format#File_header + if od -A x < /dev/null >/dev/null 2>/dev/null; then + # Use POSIX od. + func_elfclass () + { + od -A n -t d1 -j 4 -N 1 + } + else + # Use BSD hexdump. + func_elfclass () + { + dd bs=1 count=1 skip=4 2>/dev/null | hexdump -e '1/1 "%3d "' + echo + } + fi + # Use 'expr', not 'test', to compare the values of func_elfclass, because on + # Solaris 11 OpenIndiana and Solaris 11 OmniOS, the result is 001 or 002, + # not 1 or 2. + case $HOST_CPU_C_ABI_32BIT in + yes) + # 32-bit ABI. + acl_is_expected_elfclass () + { + expr "`func_elfclass | sed -e 's/[ ]//g'`" = 1 > /dev/null + } + ;; + no) + # 64-bit ABI. + acl_is_expected_elfclass () + { + expr "`func_elfclass | sed -e 's/[ ]//g'`" = 2 > /dev/null + } + ;; + *) + # Unknown. + acl_is_expected_elfclass () + { + : + } + ;; + esac + else + acl_is_expected_elfclass () + { + : + } + fi + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for the common suffixes of directories in the library search path" >&5 +printf %s "checking for the common suffixes of directories in the library search path... " >&6; } +if test ${acl_cv_libdirstems+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) acl_libdirstem=lib + acl_libdirstem2= + acl_libdirstem3= + case "$host_os" in + solaris*) + if test $HOST_CPU_C_ABI_32BIT = no; then + acl_libdirstem2=lib/64 + case "$host_cpu" in + sparc*) acl_libdirstem3=lib/sparcv9 ;; + i*86 | x86_64) acl_libdirstem3=lib/amd64 ;; + esac + fi + ;; + *) + searchpath=`(LC_ALL=C $CC $CPPFLAGS $CFLAGS -print-search-dirs) 2>/dev/null \ + | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'` + if test $HOST_CPU_C_ABI_32BIT != no; then + # 32-bit or unknown ABI. + if test -d /usr/lib32; then + acl_libdirstem2=lib32 + fi + fi + if test $HOST_CPU_C_ABI_32BIT != yes; then + # 64-bit or unknown ABI. + if test -d /usr/lib64; then + acl_libdirstem3=lib64 + fi + fi + if test -n "$searchpath"; then + acl_save_IFS="${IFS= }"; IFS=":" + for searchdir in $searchpath; do + if test -d "$searchdir"; then + case "$searchdir" in + */lib32/ | */lib32 ) acl_libdirstem2=lib32 ;; + */lib64/ | */lib64 ) acl_libdirstem3=lib64 ;; + */../ | */.. ) + # Better ignore directories of this form. They are misleading. + ;; + *) searchdir=`cd "$searchdir" && pwd` + case "$searchdir" in + */lib32 ) acl_libdirstem2=lib32 ;; + */lib64 ) acl_libdirstem3=lib64 ;; + esac ;; + esac + fi + done + IFS="$acl_save_IFS" + if test $HOST_CPU_C_ABI_32BIT = yes; then + # 32-bit ABI. + acl_libdirstem3= + fi + if test $HOST_CPU_C_ABI_32BIT = no; then + # 64-bit ABI. + acl_libdirstem2= + fi + fi + ;; + esac + test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem" + test -n "$acl_libdirstem3" || acl_libdirstem3="$acl_libdirstem" + acl_cv_libdirstems="$acl_libdirstem,$acl_libdirstem2,$acl_libdirstem3" + ;; esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $acl_cv_libdirstems" >&5 +printf "%s\n" "$acl_cv_libdirstems" >&6; } + acl_libdirstem=`echo "$acl_cv_libdirstems" | sed -e 's/,.*//'` + acl_libdirstem2=`echo "$acl_cv_libdirstems" | sed -e 's/^[^,]*,//' -e 's/,.*//'` + acl_libdirstem3=`echo "$acl_cv_libdirstems" | sed -e 's/^[^,]*,[^,]*,//' -e 's/,.*//'` @@ -10584,6 +11277,8 @@ esac eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" + eval additional_libdir2=\"$exec_prefix/$acl_libdirstem2\" + eval additional_libdir3=\"$exec_prefix/$acl_libdirstem3\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" @@ -10605,6 +11300,8 @@ then : eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" + eval additional_libdir2=\"$exec_prefix/$acl_libdirstem2\" + eval additional_libdir3=\"$exec_prefix/$acl_libdirstem3\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" @@ -10612,15 +11309,19 @@ then : else additional_includedir="$withval/include" additional_libdir="$withval/$acl_libdirstem" - if test "$acl_libdirstem2" != "$acl_libdirstem" \ - && test ! -d "$withval/$acl_libdirstem"; then - additional_libdir="$withval/$acl_libdirstem2" - fi + additional_libdir2="$withval/$acl_libdirstem2" + additional_libdir3="$withval/$acl_libdirstem3" fi fi fi + if test "X$additional_libdir2" = "X$additional_libdir"; then + additional_libdir2= + fi + if test "X$additional_libdir3" = "X$additional_libdir"; then + additional_libdir3= + fi LIBICONV= LTLIBICONV= INCICONV= @@ -10666,45 +11367,51 @@ fi shrext= fi if test $use_additional = yes; then - dir="$additional_libdir" - if test -n "$acl_shlibext"; then - if test -f "$dir/$libname$shrext"; then - found_dir="$dir" - found_so="$dir/$libname$shrext" - else - if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then - ver=`(cd "$dir" && \ - for f in "$libname$shrext".*; do echo "$f"; done \ - | sed -e "s,^$libname$shrext\\\\.,," \ - | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ - | sed 1q ) 2>/dev/null` - if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then - found_dir="$dir" - found_so="$dir/$libname$shrext.$ver" + for additional_libdir_variable in additional_libdir additional_libdir2 additional_libdir3; do + if test "X$found_dir" = "X"; then + eval dir=\$$additional_libdir_variable + if test -n "$dir"; then + if test -n "$acl_shlibext"; then + if test -f "$dir/$libname$shrext" && acl_is_expected_elfclass < "$dir/$libname$shrext"; then + found_dir="$dir" + found_so="$dir/$libname$shrext" + else + if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then + ver=`(cd "$dir" && \ + for f in "$libname$shrext".*; do echo "$f"; done \ + | sed -e "s,^$libname$shrext\\\\.,," \ + | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ + | sed 1q ) 2>/dev/null` + if test -n "$ver" && test -f "$dir/$libname$shrext.$ver" && acl_is_expected_elfclass < "$dir/$libname$shrext.$ver"; then + found_dir="$dir" + found_so="$dir/$libname$shrext.$ver" + fi + else + eval library_names=\"$acl_library_names_spec\" + for f in $library_names; do + if test -f "$dir/$f" && acl_is_expected_elfclass < "$dir/$f"; then + found_dir="$dir" + found_so="$dir/$f" + break + fi + done + fi + fi fi - else - eval library_names=\"$acl_library_names_spec\" - for f in $library_names; do - if test -f "$dir/$f"; then + if test "X$found_dir" = "X"; then + if test -f "$dir/$libname.$acl_libext" && ${AR-ar} -p "$dir/$libname.$acl_libext" | acl_is_expected_elfclass; then found_dir="$dir" - found_so="$dir/$f" - break + found_a="$dir/$libname.$acl_libext" fi - done + fi + if test "X$found_dir" != "X"; then + if test -f "$dir/$libname.la"; then + found_la="$dir/$libname.la" + fi + fi fi fi - fi - if test "X$found_dir" = "X"; then - if test -f "$dir/$libname.$acl_libext"; then - found_dir="$dir" - found_a="$dir/$libname.$acl_libext" - fi - fi - if test "X$found_dir" != "X"; then - if test -f "$dir/$libname.la"; then - found_la="$dir/$libname.la" - fi - fi + done fi if test "X$found_dir" = "X"; then for x in $LDFLAGS $LTLIBICONV; do @@ -10721,7 +11428,7 @@ fi -L*) dir=`echo "X$x" | sed -e 's/^X-L//'` if test -n "$acl_shlibext"; then - if test -f "$dir/$libname$shrext"; then + if test -f "$dir/$libname$shrext" && acl_is_expected_elfclass < "$dir/$libname$shrext"; then found_dir="$dir" found_so="$dir/$libname$shrext" else @@ -10731,14 +11438,14 @@ fi | sed -e "s,^$libname$shrext\\\\.,," \ | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ | sed 1q ) 2>/dev/null` - if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then + if test -n "$ver" && test -f "$dir/$libname$shrext.$ver" && acl_is_expected_elfclass < "$dir/$libname$shrext.$ver"; then found_dir="$dir" found_so="$dir/$libname$shrext.$ver" fi else eval library_names=\"$acl_library_names_spec\" for f in $library_names; do - if test -f "$dir/$f"; then + if test -f "$dir/$f" && acl_is_expected_elfclass < "$dir/$f"; then found_dir="$dir" found_so="$dir/$f" break @@ -10748,7 +11455,7 @@ fi fi fi if test "X$found_dir" = "X"; then - if test -f "$dir/$libname.$acl_libext"; then + if test -f "$dir/$libname.$acl_libext" && ${AR-ar} -p "$dir/$libname.$acl_libext" | acl_is_expected_elfclass; then found_dir="$dir" found_a="$dir/$libname.$acl_libext" fi @@ -10770,7 +11477,8 @@ fi if test "X$found_so" != "X"; then if test "$enable_rpath" = no \ || test "X$found_dir" = "X/usr/$acl_libdirstem" \ - || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then + || test "X$found_dir" = "X/usr/$acl_libdirstem2" \ + || test "X$found_dir" = "X/usr/$acl_libdirstem3"; then LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" else haveit= @@ -10849,6 +11557,13 @@ fi fi additional_includedir="$basedir/include" ;; + */$acl_libdirstem3 | */$acl_libdirstem3/) + basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem3/"'*$,,'` + if test "$name" = 'iconv'; then + LIBICONV_PREFIX="$basedir" + fi + additional_includedir="$basedir/include" + ;; esac if test "X$additional_includedir" != "X"; then if test "X$additional_includedir" != "X/usr/include"; then @@ -10894,12 +11609,14 @@ fi for dep in $dependency_libs; do case "$dep" in -L*) - additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` - if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \ - && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then + dependency_libdir=`echo "X$dep" | sed -e 's/^X-L//'` + if test "X$dependency_libdir" != "X/usr/$acl_libdirstem" \ + && test "X$dependency_libdir" != "X/usr/$acl_libdirstem2" \ + && test "X$dependency_libdir" != "X/usr/$acl_libdirstem3"; then haveit= - if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \ - || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then + if test "X$dependency_libdir" = "X/usr/local/$acl_libdirstem" \ + || test "X$dependency_libdir" = "X/usr/local/$acl_libdirstem2" \ + || test "X$dependency_libdir" = "X/usr/local/$acl_libdirstem3"; then if test -n "$GCC"; then case $host_os in linux* | gnu* | k*bsd*-gnu) haveit=yes;; @@ -10918,14 +11635,14 @@ fi exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" - if test "X$x" = "X-L$additional_libdir"; then + if test "X$x" = "X-L$dependency_libdir"; then haveit=yes break fi done if test -z "$haveit"; then - if test -d "$additional_libdir"; then - LIBICONV="${LIBICONV}${LIBICONV:+ }-L$additional_libdir" + if test -d "$dependency_libdir"; then + LIBICONV="${LIBICONV}${LIBICONV:+ }-L$dependency_libdir" fi fi haveit= @@ -10939,14 +11656,14 @@ fi exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" - if test "X$x" = "X-L$additional_libdir"; then + if test "X$x" = "X-L$dependency_libdir"; then haveit=yes break fi done if test -z "$haveit"; then - if test -d "$additional_libdir"; then - LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-L$additional_libdir" + if test -d "$dependency_libdir"; then + LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-L$dependency_libdir" fi fi fi @@ -10978,7 +11695,14 @@ fi fi ;; -l*) - names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` + dep=`echo "X$dep" | sed -e 's/^X-l//'` + if test "X$dep" != Xc \ + || case $host_os in + linux* | gnu* | k*bsd*-gnu) false ;; + *) true ;; + esac; then + names_next_round="$names_next_round $dep" + fi ;; *.la) names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` @@ -11065,8 +11789,8 @@ printf %s "checking for iconv... " >&6; } if test ${am_cv_func_iconv+y} then : printf %s "(cached) " >&6 -else $as_nop - +else case e in #( + e) am_cv_func_iconv="no, consider installing GNU libiconv" am_cv_lib_iconv=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -11119,7 +11843,8 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext LIBS="$am_save_LIBS" fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_func_iconv" >&5 printf "%s\n" "$am_cv_func_iconv" >&6; } @@ -11129,8 +11854,8 @@ printf %s "checking for working iconv... " >&6; } if test ${am_cv_func_iconv_works+y} then : printf %s "(cached) " >&6 -else $as_nop - +else case e in #( + e) am_save_LIBS="$LIBS" if test $am_cv_lib_iconv = yes; then LIBS="$LIBS $LIBICONV" @@ -11143,8 +11868,8 @@ then : aix* | hpux*) am_cv_func_iconv_works="guessing no" ;; *) am_cv_func_iconv_works="guessing yes" ;; esac -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -11158,8 +11883,9 @@ int main (void) { int result = 0; - /* Test against AIX 5.1 bug: Failures are not distinguishable from successful - returns. */ + /* Test against AIX 5.1...7.2 bug: Failures are not distinguishable from + successful returns. This is even documented in + */ { iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8"); if (cd_utf8_to_88591 != (iconv_t)(-1)) @@ -11272,13 +11998,15 @@ then : am_cv_func_iconv_works=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi test "$am_cv_func_iconv_works" = no || break done LIBS="$am_save_LIBS" - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_func_iconv_works" >&5 printf "%s\n" "$am_cv_func_iconv_works" >&6; } @@ -11308,14 +12036,13 @@ printf "%s\n" "$LIBICONV" >&6; } if test "$am_cv_func_iconv" = yes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for iconv declaration" >&5 -printf %s "checking for iconv declaration... " >&6; } - if test ${am_cv_proto_iconv+y} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether iconv is compatible with its POSIX signature" >&5 +printf %s "checking whether iconv is compatible with its POSIX signature... " >&6; } +if test ${gl_cv_iconv_nonconst+y} then : printf %s "(cached) " >&6 -else $as_nop - - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -11324,11 +12051,7 @@ extern #ifdef __cplusplus "C" #endif -#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft); -#else -size_t iconv(); -#endif int main (void) @@ -11340,24 +12063,27 @@ main (void) _ACEOF if ac_fn_c_try_compile "$LINENO" then : - am_cv_proto_iconv_arg1="" -else $as_nop - am_cv_proto_iconv_arg1="const" + gl_cv_iconv_nonconst=yes +else case e in #( + e) gl_cv_iconv_nonconst=no ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);" + ;; +esac fi - - am_cv_proto_iconv=`echo "$am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'` - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: - $am_cv_proto_iconv" >&5 -printf "%s\n" " - $am_cv_proto_iconv" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gl_cv_iconv_nonconst" >&5 +printf "%s\n" "$gl_cv_iconv_nonconst" >&6; } else - am_cv_proto_iconv_arg1="" + gl_cv_iconv_nonconst=yes + fi + if test $gl_cv_iconv_nonconst = yes; then + iconv_arg1="" + else + iconv_arg1="const" fi -printf "%s\n" "#define ICONV_CONST $am_cv_proto_iconv_arg1" >>confdefs.h +printf "%s\n" "#define ICONV_CONST $iconv_arg1" >>confdefs.h @@ -11384,23 +12110,11 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext - ac_fn_c_check_header_compile "$LINENO" "argz.h" "ac_cv_header_argz_h" "$ac_includes_default" -if test "x$ac_cv_header_argz_h" = xyes -then : - printf "%s\n" "#define HAVE_ARGZ_H 1" >>confdefs.h - -fi -ac_fn_c_check_header_compile "$LINENO" "inttypes.h" "ac_cv_header_inttypes_h" "$ac_includes_default" + ac_fn_c_check_header_compile "$LINENO" "inttypes.h" "ac_cv_header_inttypes_h" "$ac_includes_default" if test "x$ac_cv_header_inttypes_h" = xyes then : printf "%s\n" "#define HAVE_INTTYPES_H 1" >>confdefs.h -fi -ac_fn_c_check_header_compile "$LINENO" "limits.h" "ac_cv_header_limits_h" "$ac_includes_default" -if test "x$ac_cv_header_limits_h" = xyes -then : - printf "%s\n" "#define HAVE_LIMITS_H 1" >>confdefs.h - fi ac_fn_c_check_header_compile "$LINENO" "unistd.h" "ac_cv_header_unistd_h" "$ac_includes_default" if test "x$ac_cv_header_unistd_h" = xyes @@ -11468,42 +12182,12 @@ if test "x$ac_cv_func_strcasecmp" = xyes then : printf "%s\n" "#define HAVE_STRCASECMP 1" >>confdefs.h -fi -ac_fn_c_check_func "$LINENO" "strdup" "ac_cv_func_strdup" -if test "x$ac_cv_func_strdup" = xyes -then : - printf "%s\n" "#define HAVE_STRDUP 1" >>confdefs.h - -fi -ac_fn_c_check_func "$LINENO" "strtoul" "ac_cv_func_strtoul" -if test "x$ac_cv_func_strtoul" = xyes -then : - printf "%s\n" "#define HAVE_STRTOUL 1" >>confdefs.h - fi ac_fn_c_check_func "$LINENO" "tsearch" "ac_cv_func_tsearch" if test "x$ac_cv_func_tsearch" = xyes then : printf "%s\n" "#define HAVE_TSEARCH 1" >>confdefs.h -fi -ac_fn_c_check_func "$LINENO" "argz_count" "ac_cv_func_argz_count" -if test "x$ac_cv_func_argz_count" = xyes -then : - printf "%s\n" "#define HAVE_ARGZ_COUNT 1" >>confdefs.h - -fi -ac_fn_c_check_func "$LINENO" "argz_stringify" "ac_cv_func_argz_stringify" -if test "x$ac_cv_func_argz_stringify" = xyes -then : - printf "%s\n" "#define HAVE_ARGZ_STRINGIFY 1" >>confdefs.h - -fi -ac_fn_c_check_func "$LINENO" "argz_next" "ac_cv_func_argz_next" -if test "x$ac_cv_func_argz_next" = xyes -then : - printf "%s\n" "#define HAVE_ARGZ_NEXT 1" >>confdefs.h - fi ac_fn_c_check_func "$LINENO" "__fsetlocking" "ac_cv_func___fsetlocking" if test "x$ac_cv_func___fsetlocking" = xyes @@ -11513,21 +12197,14 @@ then : fi - ac_fn_c_check_func "$LINENO" "localeconv" "ac_cv_func_localeconv" -if test "x$ac_cv_func_localeconv" = xyes -then : - printf "%s\n" "#define HAVE_LOCALECONV 1" >>confdefs.h - -fi - - ac_fn_check_decl "$LINENO" "feof_unlocked" "ac_cv_have_decl_feof_unlocked" "#include " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_feof_unlocked" = xyes then : ac_have_decl=1 -else $as_nop - ac_have_decl=0 +else case e in #( + e) ac_have_decl=0 ;; +esac fi printf "%s\n" "#define HAVE_DECL_FEOF_UNLOCKED $ac_have_decl" >>confdefs.h ac_fn_check_decl "$LINENO" "fgets_unlocked" "ac_cv_have_decl_fgets_unlocked" "#include @@ -11535,15 +12212,25 @@ ac_fn_check_decl "$LINENO" "fgets_unlocked" "ac_cv_have_decl_fgets_unlocked" "#i if test "x$ac_cv_have_decl_fgets_unlocked" = xyes then : ac_have_decl=1 -else $as_nop - ac_have_decl=0 +else case e in #( + e) ac_have_decl=0 ;; +esac fi printf "%s\n" "#define HAVE_DECL_FGETS_UNLOCKED $ac_have_decl" >>confdefs.h - for ac_prog in bison + ac_fn_c_check_func "$LINENO" "localeconv" "ac_cv_func_localeconv" +if test "x$ac_cv_func_localeconv" = xyes +then : + printf "%s\n" "#define HAVE_LOCALECONV 1" >>confdefs.h + +fi + + + + for ac_prog in bison do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 @@ -11552,8 +12239,8 @@ printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_INTLBISON+y} then : printf %s "(cached) " >&6 -else $as_nop - if test -n "$INTLBISON"; then +else case e in #( + e) if test -n "$INTLBISON"; then ac_cv_prog_INTLBISON="$INTLBISON" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -11575,7 +12262,8 @@ done done IFS=$as_save_IFS -fi +fi ;; +esac fi INTLBISON=$ac_cv_prog_INTLBISON if test -n "$INTLBISON"; then @@ -11593,15 +12281,23 @@ done if test -z "$INTLBISON"; then ac_verc_fail=yes else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking version of bison" >&5 -printf %s "checking version of bison... " >&6; } + cat >conftest.y <<_ACEOF +%require "3.0" +%% +exp: +_ACEOF + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for bison 3.0 or newer" >&5 +printf %s "checking for bison 3.0 or newer... " >&6; } ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'` - case $ac_prog_version in - '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;; - 2.[7-9]* | [3-9].*) - ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;; - *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;; - esac + : ${ac_prog_version:='v. ?.??'} + if $INTLBISON conftest.y -o conftest.c 2>/dev/null; then + ac_prog_version="$ac_prog_version, ok" + ac_verc_fail=no + else + ac_prog_version="$ac_prog_version, bad" + ac_verc_fail=yes + fi + rm -f conftest.y conftest.c { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_prog_version" >&5 printf "%s\n" "$ac_prog_version" >&6; } fi @@ -11611,13 +12307,16 @@ printf "%s\n" "$ac_prog_version" >&6; } + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for long long int" >&5 printf %s "checking for long long int... " >&6; } if test ${ac_cv_type_long_long_int+y} then : printf %s "(cached) " >&6 -else $as_nop - ac_cv_type_long_long_int=yes +else case e in #( + e) ac_cv_type_long_long_int=yes case $ac_prog_cc_stdc in no | c89) ;; *) @@ -11626,12 +12325,12 @@ else $as_nop if test "$cross_compiling" = yes then : : -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifndef LLONG_MAX - # define HALF \ + # define HALF \\ (1LL << (sizeof (long long int) * CHAR_BIT - 2)) # define LLONG_MAX (HALF - 1 + HALF) #endif @@ -11656,15 +12355,18 @@ _ACEOF if ac_fn_c_try_run "$LINENO" then : -else $as_nop - ac_cv_type_long_long_int=no +else case e in #( + e) ac_cv_type_long_long_int=no ;; +esac fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi fi;; - esac + esac ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_long_long_int" >&5 printf "%s\n" "$ac_cv_type_long_long_int" >&6; } @@ -11680,8 +12382,8 @@ printf %s "checking for wchar_t... " >&6; } if test ${gt_cv_c_wchar_t+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include wchar_t foo = (wchar_t)'\0'; @@ -11696,10 +12398,12 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : gt_cv_c_wchar_t=yes -else $as_nop - gt_cv_c_wchar_t=no +else case e in #( + e) gt_cv_c_wchar_t=no ;; +esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gt_cv_c_wchar_t" >&5 printf "%s\n" "$gt_cv_c_wchar_t" >&6; } @@ -11715,17 +12419,9 @@ printf %s "checking for wint_t... " >&6; } if test ${gt_cv_c_wint_t+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -/* Tru64 with Desktop Toolkit C has a bug: must be included before - . - BSD/OS 4.0.1 has a bug: , and must be included - before . */ -#include -#include -#include #include wint_t foo = (wchar_t)'\0'; int @@ -11739,10 +12435,12 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : gt_cv_c_wint_t=yes -else $as_nop - gt_cv_c_wint_t=no +else case e in #( + e) gt_cv_c_wint_t=no ;; +esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gt_cv_c_wint_t" >&5 printf "%s\n" "$gt_cv_c_wint_t" >&6; } @@ -11751,24 +12449,14 @@ printf "%s\n" "$gt_cv_c_wint_t" >&6; } printf "%s\n" "#define HAVE_WINT_T 1" >>confdefs.h - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether wint_t is too small" >&5 -printf %s "checking whether wint_t is too small... " >&6; } -if test ${gl_cv_type_wint_t_too_small+y} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether wint_t is large enough" >&5 +printf %s "checking whether wint_t is large enough... " >&6; } +if test ${gl_cv_type_wint_t_large_enough+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -/* Tru64 with Desktop Toolkit C has a bug: must be included before - . - BSD/OS 4.0.1 has a bug: , and must be - included before . */ -#if !(defined __GLIBC__ && !defined __UCLIBC__) -# include -# include -# include -#endif #include int verify[sizeof (wint_t) < sizeof (int) ? -1 : 1]; @@ -11782,21 +12470,23 @@ main (void) _ACEOF if ac_fn_c_try_compile "$LINENO" then : - gl_cv_type_wint_t_too_small=no -else $as_nop - gl_cv_type_wint_t_too_small=yes + gl_cv_type_wint_t_large_enough=yes +else case e in #( + e) gl_cv_type_wint_t_large_enough=no ;; +esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gl_cv_type_wint_t_too_small" >&5 -printf "%s\n" "$gl_cv_type_wint_t_too_small" >&6; } - if test $gl_cv_type_wint_t_too_small = yes; then - GNULIB_OVERRIDES_WINT_T=1 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gl_cv_type_wint_t_large_enough" >&5 +printf "%s\n" "$gl_cv_type_wint_t_large_enough" >&6; } + if test $gl_cv_type_wint_t_large_enough = no; then + GNULIBHEADERS_OVERRIDE_WINT_T=1 else - GNULIB_OVERRIDES_WINT_T=0 + GNULIBHEADERS_OVERRIDE_WINT_T=0 fi else - GNULIB_OVERRIDES_WINT_T=0 + GNULIBHEADERS_OVERRIDE_WINT_T=0 fi @@ -11808,8 +12498,8 @@ printf %s "checking for intmax_t... " >&6; } if test ${gt_cv_c_intmax_t+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -11833,10 +12523,12 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : gt_cv_c_intmax_t=yes -else $as_nop - gt_cv_c_intmax_t=no +else case e in #( + e) gt_cv_c_intmax_t=no ;; +esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gt_cv_c_intmax_t" >&5 printf "%s\n" "$gt_cv_c_intmax_t" >&6; } @@ -11853,8 +12545,8 @@ printf %s "checking whether printf() supports POSIX/XSI format strings... " >&6; if test ${gt_cv_func_printf_posix+y} then : printf %s "(cached) " >&6 -else $as_nop - +else case e in #( + e) if test "$cross_compiling" = yes then : @@ -11867,17 +12559,18 @@ then : _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "notposix" >/dev/null 2>&1 + $EGREP_TRADITIONAL "notposix" >/dev/null 2>&1 then : gt_cv_func_printf_posix="guessing no" -else $as_nop - gt_cv_func_printf_posix="guessing yes" +else case e in #( + e) gt_cv_func_printf_posix="guessing yes" ;; +esac fi rm -rf conftest* -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -11895,14 +12588,17 @@ _ACEOF if ac_fn_c_try_run "$LINENO" then : gt_cv_func_printf_posix=yes -else $as_nop - gt_cv_func_printf_posix=no +else case e in #( + e) gt_cv_func_printf_posix=no ;; +esac fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gt_cv_func_printf_posix" >&5 printf "%s\n" "$gt_cv_func_printf_posix" >&6; } @@ -11915,45 +12611,6 @@ printf "%s\n" "#define HAVE_POSIX_PRINTF 1" >>confdefs.h esac - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C Library >= 2.1 or uClibc" >&5 -printf %s "checking whether we are using the GNU C Library >= 2.1 or uClibc... " >&6; } -if test ${ac_cv_gnu_library_2_1+y} -then : - printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#ifdef __GNU_LIBRARY__ - #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2) - Lucky GNU user - #endif -#endif -#ifdef __UCLIBC__ - Lucky user -#endif - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "Lucky" >/dev/null 2>&1 -then : - ac_cv_gnu_library_2_1=yes -else $as_nop - ac_cv_gnu_library_2_1=no -fi -rm -rf conftest* - - - -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_gnu_library_2_1" >&5 -printf "%s\n" "$ac_cv_gnu_library_2_1" >&6; } - - GLIBC21="$ac_cv_gnu_library_2_1" - - - ac_fn_c_check_header_compile "$LINENO" "stdint.h" "ac_cv_header_stdint_h" "$ac_includes_default" if test "x$ac_cv_header_stdint_h" = xyes then : @@ -11966,9 +12623,9 @@ printf %s "checking for SIZE_MAX... " >&6; } if test ${gl_cv_size_max+y} then : printf %s "(cached) " >&6 -else $as_nop - - gl_cv_size_max= +else case e in #( + e) + gl_cv_size_max=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -11982,26 +12639,28 @@ Found it _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "Found it" >/dev/null 2>&1 + $EGREP_TRADITIONAL "Found it" >/dev/null 2>&1 then : gl_cv_size_max=yes fi rm -rf conftest* - if test -z "$gl_cv_size_max"; then + if test $gl_cv_size_max != yes; then if ac_fn_c_compute_int "$LINENO" "sizeof (size_t) * CHAR_BIT - 1" "size_t_bits_minus_1" "#include #include " then : -else $as_nop - size_t_bits_minus_1= +else case e in #( + e) size_t_bits_minus_1= ;; +esac fi if ac_fn_c_compute_int "$LINENO" "sizeof (size_t) <= sizeof (unsigned int)" "fits_in_uint" "#include " then : -else $as_nop - fits_in_uint= +else case e in #( + e) fits_in_uint= ;; +esac fi if test -n "$size_t_bits_minus_1" && test -n "$fits_in_uint"; then @@ -12035,7 +12694,8 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext gl_cv_size_max='((size_t)~(size_t)0)' fi fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gl_cv_size_max" >&5 printf "%s\n" "$gl_cv_size_max" >&6; } @@ -12067,8 +12727,8 @@ printf %s "checking for working fcntl.h... " >&6; } if test ${gl_cv_header_working_fcntl_h+y} then : printf %s "(cached) " >&6 -else $as_nop - if test "$cross_compiling" = yes +else case e in #( + e) if test "$cross_compiling" = yes then : case "$host_os" in # Guess 'no' on native Windows. @@ -12076,8 +12736,8 @@ then : *) gl_cv_header_working_fcntl_h=cross-compiling ;; esac -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include @@ -12089,6 +12749,7 @@ else $as_nop # defined sleep(n) _sleep ((n) * 1000) #endif #include + GL_MDA_DEFINES #ifndef O_NOATIME #define O_NOATIME 0 #endif @@ -12175,19 +12836,22 @@ _ACEOF if ac_fn_c_try_run "$LINENO" then : gl_cv_header_working_fcntl_h=yes -else $as_nop - case $? in #( +else case e in #( + e) case $? in #( 4) gl_cv_header_working_fcntl_h='no (bad O_NOFOLLOW)';; #( 64) gl_cv_header_working_fcntl_h='no (bad O_NOATIME)';; #( 68) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #( *) gl_cv_header_working_fcntl_h='no';; - esac + esac ;; +esac fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_working_fcntl_h" >&5 printf "%s\n" "$gl_cv_header_working_fcntl_h" >&6; } @@ -12209,6 +12873,16 @@ printf "%s\n" "#define HAVE_WORKING_O_NOFOLLOW $ac_val" >>confdefs.h + HAVE_NEWLOCALE=1; + HAVE_DUPLOCALE=1; + HAVE_FREELOCALE=1; + REPLACE_LOCALECONV=0; + REPLACE_SETLOCALE=0; + REPLACE_NEWLOCALE=0; + REPLACE_DUPLOCALE=0; + REPLACE_FREELOCALE=0; + REPLACE_STRUCT_LCONV=0; + LOCALENAME_ENHANCE_LOCALE_FUNCS=0; @@ -12220,30 +12894,34 @@ printf "%s\n" "#define HAVE_WORKING_O_NOFOLLOW $ac_val" >>confdefs.h - if test $ac_cv_func_uselocale = yes; then + + + + if test $ac_cv_func_uselocale = yes; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether uselocale works" >&5 printf %s "checking whether uselocale works... " >&6; } if test ${gt_cv_func_uselocale_works+y} then : printf %s "(cached) " >&6 -else $as_nop - if test "$cross_compiling" = yes +else case e in #( + e) if test "$cross_compiling" = yes then : - # Guess no on AIX, yes otherwise. + # Guess no on AIX and z/OS, yes otherwise. case "$host_os" in - aix*) gt_cv_func_uselocale_works="guessing no" ;; - *) gt_cv_func_uselocale_works="guessing yes" ;; + aix* | openedition*) gt_cv_func_uselocale_works="guessing no" ;; + *) gt_cv_func_uselocale_works="guessing yes" ;; esac -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #if HAVE_XLOCALE_H # include #endif +locale_t loc1; int main () { uselocale (NULL); @@ -12254,14 +12932,17 @@ _ACEOF if ac_fn_c_try_run "$LINENO" then : gt_cv_func_uselocale_works=yes -else $as_nop - gt_cv_func_uselocale_works=no +else case e in #( + e) gt_cv_func_uselocale_works=no ;; +esac fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gt_cv_func_uselocale_works" >&5 printf "%s\n" "$gt_cv_func_uselocale_works" >&6; } @@ -12270,9 +12951,13 @@ printf "%s\n" "$gt_cv_func_uselocale_works" >&6; } fi case "$gt_cv_func_uselocale_works" in *yes) + gt_working_uselocale=yes printf "%s\n" "#define HAVE_WORKING_USELOCALE 1" >>confdefs.h + ;; + *) + gt_working_uselocale=no ;; esac @@ -12285,16 +12970,16 @@ printf %s "checking for fake locale system (OpenBSD)... " >&6; } if test ${gt_cv_locale_fake+y} then : printf %s "(cached) " >&6 -else $as_nop - if test "$cross_compiling" = yes +else case e in #( + e) if test "$cross_compiling" = yes then : case "$host_os" in openbsd*) gt_cv_locale_fake="guessing yes" ;; *) gt_cv_locale_fake="guessing no" ;; esac -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -12314,14 +12999,17 @@ _ACEOF if ac_fn_c_try_run "$LINENO" then : gt_cv_locale_fake=yes -else $as_nop - gt_cv_locale_fake=no +else case e in #( + e) gt_cv_locale_fake=no ;; +esac fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gt_cv_locale_fake" >&5 printf "%s\n" "$gt_cv_locale_fake" >&6; } @@ -12330,9 +13018,13 @@ printf "%s\n" "$gt_cv_locale_fake" >&6; } esac case "$gt_cv_locale_fake" in *yes) + gt_fake_locales=yes printf "%s\n" "#define HAVE_FAKE_LOCALES 1" >>confdefs.h + ;; + *) + gt_fake_locales=no ;; esac @@ -12343,8 +13035,8 @@ printf %s "checking for Solaris 11.4 locale system... " >&6; } if test ${gt_cv_locale_solaris114+y} then : printf %s "(cached) " >&6 -else $as_nop - case "$host_os" in +else case e in #( + e) case "$host_os" in solaris*) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -12364,14 +13056,16 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : gt_cv_locale_solaris114=yes -else $as_nop - gt_cv_locale_solaris114=no +else case e in #( + e) gt_cv_locale_solaris114=no ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; *) gt_cv_locale_solaris114=no ;; esac - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gt_cv_locale_solaris114" >&5 printf "%s\n" "$gt_cv_locale_solaris114" >&6; } @@ -12396,12 +13090,33 @@ fi ;; esac - gt_nameless_locales=no - if false; then - gt_nameless_locales=yes + gt_nameless_locales=no + case "$host_os" in + aix*) + gt_nameless_locales=yes printf "%s\n" "#define HAVE_NAMELESS_LOCALES 1" >>confdefs.h + ;; + esac + + if test $gt_working_uselocale = yes && test $gt_fake_locales = no; then + gt_good_uselocale=yes + +printf "%s\n" "#define HAVE_GOOD_USELOCALE 1" >>confdefs.h + + else + gt_good_uselocale=no + fi + + if test $gt_good_uselocale = yes && test $gt_nameless_locales = yes; then + gt_localename_enhances_locale_funcs=yes + LOCALENAME_ENHANCE_LOCALE_FUNCS=1 + +printf "%s\n" "#define LOCALENAME_ENHANCE_LOCALE_FUNCS 1" >>confdefs.h + + else + gt_localename_enhances_locale_funcs=no fi @@ -12410,8 +13125,8 @@ printf %s "checking for CFPreferencesCopyAppValue... " >&6; } if test ${gt_cv_func_CFPreferencesCopyAppValue+y} then : printf %s "(cached) " >&6 -else $as_nop - gt_save_LIBS="$LIBS" +else case e in #( + e) gt_save_LIBS="$LIBS" LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -12427,12 +13142,14 @@ _ACEOF if ac_fn_c_try_link "$LINENO" then : gt_cv_func_CFPreferencesCopyAppValue=yes -else $as_nop - gt_cv_func_CFPreferencesCopyAppValue=no +else case e in #( + e) gt_cv_func_CFPreferencesCopyAppValue=no ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext - LIBS="$gt_save_LIBS" + LIBS="$gt_save_LIBS" ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gt_cv_func_CFPreferencesCopyAppValue" >&5 printf "%s\n" "$gt_cv_func_CFPreferencesCopyAppValue" >&6; } @@ -12441,49 +13158,13 @@ printf "%s\n" "$gt_cv_func_CFPreferencesCopyAppValue" >&6; } printf "%s\n" "#define HAVE_CFPREFERENCESCOPYAPPVALUE 1" >>confdefs.h fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for CFLocaleCopyCurrent" >&5 -printf %s "checking for CFLocaleCopyCurrent... " >&6; } -if test ${gt_cv_func_CFLocaleCopyCurrent+y} -then : - printf %s "(cached) " >&6 -else $as_nop - gt_save_LIBS="$LIBS" - LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main (void) -{ -CFLocaleCopyCurrent(); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO" -then : - gt_cv_func_CFLocaleCopyCurrent=yes -else $as_nop - gt_cv_func_CFLocaleCopyCurrent=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext - LIBS="$gt_save_LIBS" -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gt_cv_func_CFLocaleCopyCurrent" >&5 -printf "%s\n" "$gt_cv_func_CFLocaleCopyCurrent" >&6; } - if test $gt_cv_func_CFLocaleCopyCurrent = yes; then - -printf "%s\n" "#define HAVE_CFLOCALECOPYCURRENT 1" >>confdefs.h - - fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for CFLocaleCopyPreferredLanguages" >&5 + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for CFLocaleCopyPreferredLanguages" >&5 printf %s "checking for CFLocaleCopyPreferredLanguages... " >&6; } if test ${gt_cv_func_CFLocaleCopyPreferredLanguages+y} then : printf %s "(cached) " >&6 -else $as_nop - gt_save_LIBS="$LIBS" +else case e in #( + e) gt_save_LIBS="$LIBS" LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -12499,12 +13180,14 @@ _ACEOF if ac_fn_c_try_link "$LINENO" then : gt_cv_func_CFLocaleCopyPreferredLanguages=yes -else $as_nop - gt_cv_func_CFLocaleCopyPreferredLanguages=no +else case e in #( + e) gt_cv_func_CFLocaleCopyPreferredLanguages=no ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext - LIBS="$gt_save_LIBS" + LIBS="$gt_save_LIBS" ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gt_cv_func_CFLocaleCopyPreferredLanguages" >&5 printf "%s\n" "$gt_cv_func_CFLocaleCopyPreferredLanguages" >&6; } @@ -12515,7 +13198,6 @@ printf "%s\n" "#define HAVE_CFLOCALECOPYPREFERREDLANGUAGES 1" >>confdefs.h fi INTL_MACOSX_LIBS= if test $gt_cv_func_CFPreferencesCopyAppValue = yes \ - || test $gt_cv_func_CFLocaleCopyCurrent = yes \ || test $gt_cv_func_CFLocaleCopyPreferredLanguages = yes; then INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation" fi @@ -12527,26 +13209,31 @@ printf "%s\n" "#define HAVE_CFLOCALECOPYPREFERREDLANGUAGES 1" >>confdefs.h - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for flexible array members" >&5 -printf %s "checking for flexible array members... " >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for flexible array member" >&5 +printf %s "checking for flexible array member... " >&6; } if test ${ac_cv_c_flexmember+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include - #include - #include - struct s { int n; double d[]; }; + #include + #include + struct m { struct m *next, **list; char name[]; }; + struct s { struct s *p; struct m *m; int n; double d[]; }; int main (void) { int m = getchar (); - struct s *p = (struct s *) malloc (offsetof (struct s, d) - + m * sizeof (double)); - p->d[0] = 0.0; - return p->d != (double *) NULL; + size_t nbytes = offsetof (struct s, d) + m * sizeof (double); + nbytes += sizeof (struct s) - 1; + nbytes -= nbytes % sizeof (struct s); + struct s *p = malloc (nbytes); + p->p = p; + p->m = NULL; + p->d[0] = 0.0; + return p->d != (double *) NULL; ; return 0; } @@ -12554,10 +13241,12 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_cv_c_flexmember=yes -else $as_nop - ac_cv_c_flexmember=no +else case e in #( + e) ac_cv_c_flexmember=no ;; +esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_flexmember" >&5 printf "%s\n" "$ac_cv_c_flexmember" >&6; } @@ -12577,6 +13266,9 @@ printf "%s\n" "#define FLEXIBLE_ARRAY_MEMBER /**/" >>confdefs.h + + + if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. set dummy ${ac_tool_prefix}ar; ac_word=$2 @@ -12585,8 +13277,8 @@ printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_AR+y} then : printf %s "(cached) " >&6 -else $as_nop - if test -n "$AR"; then +else case e in #( + e) if test -n "$AR"; then ac_cv_prog_AR="$AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -12608,7 +13300,8 @@ done done IFS=$as_save_IFS -fi +fi ;; +esac fi AR=$ac_cv_prog_AR if test -n "$AR"; then @@ -12630,8 +13323,8 @@ printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_AR+y} then : printf %s "(cached) " >&6 -else $as_nop - if test -n "$ac_ct_AR"; then +else case e in #( + e) if test -n "$ac_ct_AR"; then ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -12653,7 +13346,8 @@ done done IFS=$as_save_IFS -fi +fi ;; +esac fi ac_ct_AR=$ac_cv_prog_ac_ct_AR if test -n "$ac_ct_AR"; then @@ -12697,11 +13391,12 @@ fi if test "x$ac_cv_type_ptrdiff_t" = xyes then : -else $as_nop - +else case e in #( + e) printf "%s\n" "#define ptrdiff_t long" >>confdefs.h - + ;; +esac fi ac_fn_c_check_header_compile "$LINENO" "features.h" "ac_cv_header_features_h" "$ac_includes_default" @@ -12735,10 +13430,10 @@ then : printf "%s\n" "#define HAVE_ASPRINTF 1" >>confdefs.h fi -ac_fn_c_check_func "$LINENO" "fwprintf" "ac_cv_func_fwprintf" -if test "x$ac_cv_func_fwprintf" = xyes +ac_fn_c_check_func "$LINENO" "wprintf" "ac_cv_func_wprintf" +if test "x$ac_cv_func_wprintf" = xyes then : - printf "%s\n" "#define HAVE_FWPRINTF 1" >>confdefs.h + printf "%s\n" "#define HAVE_WPRINTF 1" >>confdefs.h fi ac_fn_c_check_func "$LINENO" "newlocale" "ac_cv_func_newlocale" @@ -12758,12 +13453,6 @@ if test "x$ac_cv_func_setenv" = xyes then : printf "%s\n" "#define HAVE_SETENV 1" >>confdefs.h -fi -ac_fn_c_check_func "$LINENO" "setlocale" "ac_cv_func_setlocale" -if test "x$ac_cv_func_setlocale" = xyes -then : - printf "%s\n" "#define HAVE_SETLOCALE 1" >>confdefs.h - fi ac_fn_c_check_func "$LINENO" "snprintf" "ac_cv_func_snprintf" if test "x$ac_cv_func_snprintf" = xyes @@ -12814,8 +13503,9 @@ fi if test "x$ac_cv_have_decl__snprintf" = xyes then : ac_have_decl=1 -else $as_nop - ac_have_decl=0 +else case e in #( + e) ac_have_decl=0 ;; +esac fi printf "%s\n" "#define HAVE_DECL__SNPRINTF $ac_have_decl" >>confdefs.h ac_fn_check_decl "$LINENO" "_snwprintf" "ac_cv_have_decl__snwprintf" "#include @@ -12823,8 +13513,9 @@ ac_fn_check_decl "$LINENO" "_snwprintf" "ac_cv_have_decl__snwprintf" "#include < if test "x$ac_cv_have_decl__snwprintf" = xyes then : ac_have_decl=1 -else $as_nop - ac_have_decl=0 +else case e in #( + e) ac_have_decl=0 ;; +esac fi printf "%s\n" "#define HAVE_DECL__SNWPRINTF $ac_have_decl" >>confdefs.h @@ -12834,15 +13525,16 @@ printf "%s\n" "#define HAVE_DECL__SNWPRINTF $ac_have_decl" >>confdefs.h if test "x$ac_cv_have_decl_getc_unlocked" = xyes then : ac_have_decl=1 -else $as_nop - ac_have_decl=0 +else case e in #( + e) ac_have_decl=0 ;; +esac fi printf "%s\n" "#define HAVE_DECL_GETC_UNLOCKED $ac_have_decl" >>confdefs.h case $gt_cv_func_printf_posix in *yes) HAVE_POSIX_PRINTF=1 ;; - *) HAVE_POSIX_PRINTF=0 ;; + *) HAVE_POSIX_PRINTF=0 ;; esac if test "$ac_cv_func_asprintf" = yes; then @@ -12876,8 +13568,8 @@ printf %s "checking for nl_langinfo and CODESET... " >&6; } if test ${am_cv_langinfo_codeset+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int @@ -12891,16 +13583,20 @@ _ACEOF if ac_fn_c_try_link "$LINENO" then : am_cv_langinfo_codeset=yes -else $as_nop - am_cv_langinfo_codeset=no +else case e in #( + e) am_cv_langinfo_codeset=no ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_langinfo_codeset" >&5 printf "%s\n" "$am_cv_langinfo_codeset" >&6; } if test $am_cv_langinfo_codeset = yes; then + printf "%s\n" "#define HAVE_NL_LANGINFO 1" >>confdefs.h + printf "%s\n" "#define HAVE_LANGINFO_CODESET 1" >>confdefs.h @@ -12912,8 +13608,8 @@ printf %s "checking for LC_MESSAGES... " >&6; } if test ${gt_cv_val_LC_MESSAGES+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int @@ -12927,11 +13623,13 @@ _ACEOF if ac_fn_c_try_link "$LINENO" then : gt_cv_val_LC_MESSAGES=yes -else $as_nop - gt_cv_val_LC_MESSAGES=no +else case e in #( + e) gt_cv_val_LC_MESSAGES=no ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext + conftest$ac_exeext conftest.$ac_ext ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gt_cv_val_LC_MESSAGES" >&5 printf "%s\n" "$gt_cv_val_LC_MESSAGES" >&6; } @@ -12942,10 +13640,10 @@ printf "%s\n" "#define HAVE_LC_MESSAGES 1" >>confdefs.h fi - if test $gt_nameless_locales = yes; then - HAVE_NAMELESS_LOCALES=1 + if test $gt_localename_enhances_locale_funcs = yes; then + ENHANCE_LOCALE_FUNCS=1 else - HAVE_NAMELESS_LOCALES=0 + ENHANCE_LOCALE_FUNCS=0 fi @@ -12975,8 +13673,8 @@ printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_WINDRES+y} then : printf %s "(cached) " >&6 -else $as_nop - if test -n "$WINDRES"; then +else case e in #( + e) if test -n "$WINDRES"; then ac_cv_prog_WINDRES="$WINDRES" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -12998,7 +13696,8 @@ done done IFS=$as_save_IFS -fi +fi ;; +esac fi WINDRES=$ac_cv_prog_WINDRES if test -n "$WINDRES"; then @@ -13020,8 +13719,8 @@ printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_WINDRES+y} then : printf %s "(cached) " >&6 -else $as_nop - if test -n "$ac_ct_WINDRES"; then +else case e in #( + e) if test -n "$ac_ct_WINDRES"; then ac_cv_prog_ac_ct_WINDRES="$ac_ct_WINDRES" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -13043,7 +13742,8 @@ done done IFS=$as_save_IFS -fi +fi ;; +esac fi ac_ct_WINDRES=$ac_cv_prog_ac_ct_WINDRES if test -n "$ac_ct_WINDRES"; then @@ -13100,8 +13800,8 @@ printf %s "checking for CFPreferencesCopyAppValue... " >&6; } if test ${gt_cv_func_CFPreferencesCopyAppValue+y} then : printf %s "(cached) " >&6 -else $as_nop - gt_save_LIBS="$LIBS" +else case e in #( + e) gt_save_LIBS="$LIBS" LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -13117,12 +13817,14 @@ _ACEOF if ac_fn_c_try_link "$LINENO" then : gt_cv_func_CFPreferencesCopyAppValue=yes -else $as_nop - gt_cv_func_CFPreferencesCopyAppValue=no +else case e in #( + e) gt_cv_func_CFPreferencesCopyAppValue=no ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext - LIBS="$gt_save_LIBS" + LIBS="$gt_save_LIBS" ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gt_cv_func_CFPreferencesCopyAppValue" >&5 printf "%s\n" "$gt_cv_func_CFPreferencesCopyAppValue" >&6; } @@ -13131,49 +13833,13 @@ printf "%s\n" "$gt_cv_func_CFPreferencesCopyAppValue" >&6; } printf "%s\n" "#define HAVE_CFPREFERENCESCOPYAPPVALUE 1" >>confdefs.h fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for CFLocaleCopyCurrent" >&5 -printf %s "checking for CFLocaleCopyCurrent... " >&6; } -if test ${gt_cv_func_CFLocaleCopyCurrent+y} -then : - printf %s "(cached) " >&6 -else $as_nop - gt_save_LIBS="$LIBS" - LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main (void) -{ -CFLocaleCopyCurrent(); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO" -then : - gt_cv_func_CFLocaleCopyCurrent=yes -else $as_nop - gt_cv_func_CFLocaleCopyCurrent=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext - LIBS="$gt_save_LIBS" -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gt_cv_func_CFLocaleCopyCurrent" >&5 -printf "%s\n" "$gt_cv_func_CFLocaleCopyCurrent" >&6; } - if test $gt_cv_func_CFLocaleCopyCurrent = yes; then - -printf "%s\n" "#define HAVE_CFLOCALECOPYCURRENT 1" >>confdefs.h - - fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for CFLocaleCopyPreferredLanguages" >&5 + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for CFLocaleCopyPreferredLanguages" >&5 printf %s "checking for CFLocaleCopyPreferredLanguages... " >&6; } if test ${gt_cv_func_CFLocaleCopyPreferredLanguages+y} then : printf %s "(cached) " >&6 -else $as_nop - gt_save_LIBS="$LIBS" +else case e in #( + e) gt_save_LIBS="$LIBS" LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -13189,12 +13855,14 @@ _ACEOF if ac_fn_c_try_link "$LINENO" then : gt_cv_func_CFLocaleCopyPreferredLanguages=yes -else $as_nop - gt_cv_func_CFLocaleCopyPreferredLanguages=no +else case e in #( + e) gt_cv_func_CFLocaleCopyPreferredLanguages=no ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext - LIBS="$gt_save_LIBS" + LIBS="$gt_save_LIBS" ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gt_cv_func_CFLocaleCopyPreferredLanguages" >&5 printf "%s\n" "$gt_cv_func_CFLocaleCopyPreferredLanguages" >&6; } @@ -13205,7 +13873,6 @@ printf "%s\n" "#define HAVE_CFLOCALECOPYPREFERREDLANGUAGES 1" >>confdefs.h fi INTL_MACOSX_LIBS= if test $gt_cv_func_CFPreferencesCopyAppValue = yes \ - || test $gt_cv_func_CFLocaleCopyCurrent = yes \ || test $gt_cv_func_CFLocaleCopyPreferredLanguages = yes; then INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation" fi @@ -13240,8 +13907,9 @@ printf %s "checking whether included gettext is requested... " >&6; } if test ${with_included_gettext+y} then : withval=$with_included_gettext; nls_cv_force_use_gnu_gettext=$withval -else $as_nop - nls_cv_force_use_gnu_gettext=no +else case e in #( + e) nls_cv_force_use_gnu_gettext=no ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $nls_cv_force_use_gnu_gettext" >&5 @@ -13272,8 +13940,8 @@ printf %s "checking for GNU gettext in libc... " >&6; } if eval test \${$gt_func_gnugettext_libc+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -13300,11 +13968,13 @@ _ACEOF if ac_fn_c_try_link "$LINENO" then : eval "$gt_func_gnugettext_libc=yes" -else $as_nop - eval "$gt_func_gnugettext_libc=no" +else case e in #( + e) eval "$gt_func_gnugettext_libc=no" ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext + conftest$ac_exeext conftest.$ac_ext ;; +esac fi eval ac_res=\$$gt_func_gnugettext_libc { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 @@ -13327,6 +13997,8 @@ printf "%s\n" "$ac_res" >&6; } eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" + eval additional_libdir2=\"$exec_prefix/$acl_libdirstem2\" + eval additional_libdir3=\"$exec_prefix/$acl_libdirstem3\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" @@ -13348,6 +14020,8 @@ then : eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" + eval additional_libdir2=\"$exec_prefix/$acl_libdirstem2\" + eval additional_libdir3=\"$exec_prefix/$acl_libdirstem3\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" @@ -13355,15 +14029,19 @@ then : else additional_includedir="$withval/include" additional_libdir="$withval/$acl_libdirstem" - if test "$acl_libdirstem2" != "$acl_libdirstem" \ - && test ! -d "$withval/$acl_libdirstem"; then - additional_libdir="$withval/$acl_libdirstem2" - fi + additional_libdir2="$withval/$acl_libdirstem2" + additional_libdir3="$withval/$acl_libdirstem3" fi fi fi + if test "X$additional_libdir2" = "X$additional_libdir"; then + additional_libdir2= + fi + if test "X$additional_libdir3" = "X$additional_libdir"; then + additional_libdir3= + fi LIBINTL= LTLIBINTL= INCINTL= @@ -13409,45 +14087,51 @@ fi shrext= fi if test $use_additional = yes; then - dir="$additional_libdir" - if test -n "$acl_shlibext"; then - if test -f "$dir/$libname$shrext"; then - found_dir="$dir" - found_so="$dir/$libname$shrext" - else - if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then - ver=`(cd "$dir" && \ - for f in "$libname$shrext".*; do echo "$f"; done \ - | sed -e "s,^$libname$shrext\\\\.,," \ - | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ - | sed 1q ) 2>/dev/null` - if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then - found_dir="$dir" - found_so="$dir/$libname$shrext.$ver" + for additional_libdir_variable in additional_libdir additional_libdir2 additional_libdir3; do + if test "X$found_dir" = "X"; then + eval dir=\$$additional_libdir_variable + if test -n "$dir"; then + if test -n "$acl_shlibext"; then + if test -f "$dir/$libname$shrext" && acl_is_expected_elfclass < "$dir/$libname$shrext"; then + found_dir="$dir" + found_so="$dir/$libname$shrext" + else + if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then + ver=`(cd "$dir" && \ + for f in "$libname$shrext".*; do echo "$f"; done \ + | sed -e "s,^$libname$shrext\\\\.,," \ + | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ + | sed 1q ) 2>/dev/null` + if test -n "$ver" && test -f "$dir/$libname$shrext.$ver" && acl_is_expected_elfclass < "$dir/$libname$shrext.$ver"; then + found_dir="$dir" + found_so="$dir/$libname$shrext.$ver" + fi + else + eval library_names=\"$acl_library_names_spec\" + for f in $library_names; do + if test -f "$dir/$f" && acl_is_expected_elfclass < "$dir/$f"; then + found_dir="$dir" + found_so="$dir/$f" + break + fi + done + fi + fi fi - else - eval library_names=\"$acl_library_names_spec\" - for f in $library_names; do - if test -f "$dir/$f"; then + if test "X$found_dir" = "X"; then + if test -f "$dir/$libname.$acl_libext" && ${AR-ar} -p "$dir/$libname.$acl_libext" | acl_is_expected_elfclass; then found_dir="$dir" - found_so="$dir/$f" - break + found_a="$dir/$libname.$acl_libext" fi - done + fi + if test "X$found_dir" != "X"; then + if test -f "$dir/$libname.la"; then + found_la="$dir/$libname.la" + fi + fi fi fi - fi - if test "X$found_dir" = "X"; then - if test -f "$dir/$libname.$acl_libext"; then - found_dir="$dir" - found_a="$dir/$libname.$acl_libext" - fi - fi - if test "X$found_dir" != "X"; then - if test -f "$dir/$libname.la"; then - found_la="$dir/$libname.la" - fi - fi + done fi if test "X$found_dir" = "X"; then for x in $LDFLAGS $LTLIBINTL; do @@ -13464,7 +14148,7 @@ fi -L*) dir=`echo "X$x" | sed -e 's/^X-L//'` if test -n "$acl_shlibext"; then - if test -f "$dir/$libname$shrext"; then + if test -f "$dir/$libname$shrext" && acl_is_expected_elfclass < "$dir/$libname$shrext"; then found_dir="$dir" found_so="$dir/$libname$shrext" else @@ -13474,14 +14158,14 @@ fi | sed -e "s,^$libname$shrext\\\\.,," \ | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ | sed 1q ) 2>/dev/null` - if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then + if test -n "$ver" && test -f "$dir/$libname$shrext.$ver" && acl_is_expected_elfclass < "$dir/$libname$shrext.$ver"; then found_dir="$dir" found_so="$dir/$libname$shrext.$ver" fi else eval library_names=\"$acl_library_names_spec\" for f in $library_names; do - if test -f "$dir/$f"; then + if test -f "$dir/$f" && acl_is_expected_elfclass < "$dir/$f"; then found_dir="$dir" found_so="$dir/$f" break @@ -13491,7 +14175,7 @@ fi fi fi if test "X$found_dir" = "X"; then - if test -f "$dir/$libname.$acl_libext"; then + if test -f "$dir/$libname.$acl_libext" && ${AR-ar} -p "$dir/$libname.$acl_libext" | acl_is_expected_elfclass; then found_dir="$dir" found_a="$dir/$libname.$acl_libext" fi @@ -13513,7 +14197,8 @@ fi if test "X$found_so" != "X"; then if test "$enable_rpath" = no \ || test "X$found_dir" = "X/usr/$acl_libdirstem" \ - || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then + || test "X$found_dir" = "X/usr/$acl_libdirstem2" \ + || test "X$found_dir" = "X/usr/$acl_libdirstem3"; then LIBINTL="${LIBINTL}${LIBINTL:+ }$found_so" else haveit= @@ -13592,6 +14277,13 @@ fi fi additional_includedir="$basedir/include" ;; + */$acl_libdirstem3 | */$acl_libdirstem3/) + basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem3/"'*$,,'` + if test "$name" = 'intl'; then + LIBINTL_PREFIX="$basedir" + fi + additional_includedir="$basedir/include" + ;; esac if test "X$additional_includedir" != "X"; then if test "X$additional_includedir" != "X/usr/include"; then @@ -13637,12 +14329,14 @@ fi for dep in $dependency_libs; do case "$dep" in -L*) - additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` - if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \ - && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then + dependency_libdir=`echo "X$dep" | sed -e 's/^X-L//'` + if test "X$dependency_libdir" != "X/usr/$acl_libdirstem" \ + && test "X$dependency_libdir" != "X/usr/$acl_libdirstem2" \ + && test "X$dependency_libdir" != "X/usr/$acl_libdirstem3"; then haveit= - if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \ - || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then + if test "X$dependency_libdir" = "X/usr/local/$acl_libdirstem" \ + || test "X$dependency_libdir" = "X/usr/local/$acl_libdirstem2" \ + || test "X$dependency_libdir" = "X/usr/local/$acl_libdirstem3"; then if test -n "$GCC"; then case $host_os in linux* | gnu* | k*bsd*-gnu) haveit=yes;; @@ -13661,14 +14355,14 @@ fi exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" - if test "X$x" = "X-L$additional_libdir"; then + if test "X$x" = "X-L$dependency_libdir"; then haveit=yes break fi done if test -z "$haveit"; then - if test -d "$additional_libdir"; then - LIBINTL="${LIBINTL}${LIBINTL:+ }-L$additional_libdir" + if test -d "$dependency_libdir"; then + LIBINTL="${LIBINTL}${LIBINTL:+ }-L$dependency_libdir" fi fi haveit= @@ -13682,14 +14376,14 @@ fi exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" - if test "X$x" = "X-L$additional_libdir"; then + if test "X$x" = "X-L$dependency_libdir"; then haveit=yes break fi done if test -z "$haveit"; then - if test -d "$additional_libdir"; then - LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }-L$additional_libdir" + if test -d "$dependency_libdir"; then + LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }-L$dependency_libdir" fi fi fi @@ -13721,7 +14415,14 @@ fi fi ;; -l*) - names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` + dep=`echo "X$dep" | sed -e 's/^X-l//'` + if test "X$dep" != Xc \ + || case $host_os in + linux* | gnu* | k*bsd*-gnu) false ;; + *) true ;; + esac; then + names_next_round="$names_next_round $dep" + fi ;; *.la) names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` @@ -13777,8 +14478,8 @@ printf %s "checking for GNU gettext in libintl... " >&6; } if eval test \${$gt_func_gnugettext_libintl+y} then : printf %s "(cached) " >&6 -else $as_nop - gt_save_CPPFLAGS="$CPPFLAGS" +else case e in #( + e) gt_save_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $INCINTL" gt_save_LIBS="$LIBS" LIBS="$LIBS $LIBINTL" @@ -13813,8 +14514,9 @@ _ACEOF if ac_fn_c_try_link "$LINENO" then : eval "$gt_func_gnugettext_libintl=yes" -else $as_nop - eval "$gt_func_gnugettext_libintl=no" +else case e in #( + e) eval "$gt_func_gnugettext_libintl=no" ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext @@ -13859,7 +14561,8 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi CPPFLAGS="$gt_save_CPPFLAGS" - LIBS="$gt_save_LIBS" + LIBS="$gt_save_LIBS" ;; +esac fi eval ac_res=\$$gt_func_gnugettext_libintl { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 @@ -13886,8 +14589,10 @@ printf "%s\n" "$ac_res" >&6; } if test "$nls_cv_use_gnu_gettext" = "yes"; then BUILD_INCLUDED_LIBINTL=yes USE_INCLUDED_LIBINTL=yes +# LIBINTL="m4_if([lib/intl],[],\${top_builddir}/intl,[lib/intl])/libintl.la $LIBICONV $LIBTHREAD" + # we don't build with libtool LIBINTL="lib/intl/libintl.a $LIBICONV $LIBTHREAD" - LTLIBINTL="lib/intl/libintl.a $LTLIBICONV $LTLIBTHREAD" + LTLIBINTL="lib/intl/libintl.la $LTLIBICONV $LTLIBTHREAD" LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'` fi @@ -13981,33 +14686,10 @@ printf "%s\n" "#define HAVE_DCGETTEXT 1" >>confdefs.h fi - if test "$PACKAGE" = gettext-runtime || test "$PACKAGE" = gettext-tools; then - BUILD_INCLUDED_LIBINTL=yes - fi - - - - - - nls_cv_header_intl= - nls_cv_header_libgt= - - DATADIRNAME=share - + BUILD_INCLUDED_LIBINTL=yes - INSTOBJEXT=.mo - GENCAT=gencat - - - INTLOBJS= - if test "$USE_INCLUDED_LIBINTL" = yes; then - INTLOBJS="\$(GETTOBJS)" - fi - - - INTL_LIBTOOL_SUFFIX_PREFIX= @@ -14021,14 +14703,14 @@ printf "%s\n" "#define HAVE_DCGETTEXT 1" >>confdefs.h ac_header_dirent=no for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do - as_ac_Header=`printf "%s\n" "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh` + as_ac_Header=`printf "%s\n" "ac_cv_header_dirent_$ac_hdr" | sed "$as_sed_sh"` { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_hdr that defines DIR" >&5 printf %s "checking for $ac_hdr that defines DIR... " >&6; } if eval test \${$as_ac_Header+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include <$ac_hdr> @@ -14045,10 +14727,12 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : eval "$as_ac_Header=yes" -else $as_nop - eval "$as_ac_Header=no" +else case e in #( + e) eval "$as_ac_Header=no" ;; +esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi eval ac_res=\$$as_ac_Header { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 @@ -14056,7 +14740,7 @@ printf "%s\n" "$ac_res" >&6; } if eval test \"x\$"$as_ac_Header"\" = x"yes" then : cat >>confdefs.h <<_ACEOF -#define `printf "%s\n" "HAVE_$ac_hdr" | $as_tr_cpp` 1 +#define `printf "%s\n" "HAVE_$ac_hdr" | sed "$as_sed_cpp"` 1 _ACEOF ac_header_dirent=$ac_hdr; break @@ -14070,15 +14754,21 @@ printf %s "checking for library containing opendir... " >&6; } if test ${ac_cv_search_opendir+y} then : printf %s "(cached) " >&6 -else $as_nop - ac_func_search_save_LIBS=$LIBS +else case e in #( + e) ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -char opendir (); + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char opendir (void); int main (void) { @@ -14109,11 +14799,13 @@ done if test ${ac_cv_search_opendir+y} then : -else $as_nop - ac_cv_search_opendir=no +else case e in #( + e) ac_cv_search_opendir=no ;; +esac fi rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS +LIBS=$ac_func_search_save_LIBS ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_opendir" >&5 printf "%s\n" "$ac_cv_search_opendir" >&6; } @@ -14130,15 +14822,21 @@ printf %s "checking for library containing opendir... " >&6; } if test ${ac_cv_search_opendir+y} then : printf %s "(cached) " >&6 -else $as_nop - ac_func_search_save_LIBS=$LIBS +else case e in #( + e) ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -char opendir (); + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char opendir (void); int main (void) { @@ -14169,11 +14867,13 @@ done if test ${ac_cv_search_opendir+y} then : -else $as_nop - ac_cv_search_opendir=no +else case e in #( + e) ac_cv_search_opendir=no ;; +esac fi rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS +LIBS=$ac_func_search_save_LIBS ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_opendir" >&5 printf "%s\n" "$ac_cv_search_opendir" >&6; } @@ -14228,12 +14928,6 @@ if test "x$ac_cv_header_stdlib_h" = xyes then : printf "%s\n" "#define HAVE_STDLIB_H 1" >>confdefs.h -fi -ac_fn_c_check_header_compile "$LINENO" "stdarg.h" "ac_cv_header_stdarg_h" "$ac_includes_default" -if test "x$ac_cv_header_stdarg_h" = xyes -then : - printf "%s\n" "#define HAVE_STDARG_H 1" >>confdefs.h - fi ac_fn_c_check_header_compile "$LINENO" "varargs.h" "ac_cv_header_varargs_h" "$ac_includes_default" if test "x$ac_cv_header_varargs_h" = xyes @@ -14288,12 +14982,6 @@ if test "x$ac_cv_header_dlfcn_h" = xyes then : printf "%s\n" "#define HAVE_DLFCN_H 1" >>confdefs.h -fi -ac_fn_c_check_header_compile "$LINENO" "stdbool.h" "ac_cv_header_stdbool_h" "$ac_includes_default" -if test "x$ac_cv_header_stdbool_h" = xyes -then : - printf "%s\n" "#define HAVE_STDBOOL_H 1" >>confdefs.h - fi ac_fn_c_check_header_compile "$LINENO" "stddef.h" "ac_cv_header_stddef_h" "$ac_includes_default" if test "x$ac_cv_header_stddef_h" = xyes @@ -14330,6 +15018,12 @@ if test "x$ac_cv_header_strings_h" = xyes then : printf "%s\n" "#define HAVE_STRINGS_H 1" >>confdefs.h +fi +ac_fn_c_check_header_compile "$LINENO" "stdckdint.h" "ac_cv_header_stdckdint_h" "$ac_includes_default" +if test "x$ac_cv_header_stdckdint_h" = xyes +then : + printf "%s\n" "#define HAVE_STDCKDINT_H 1" >>confdefs.h + fi ac_fn_c_check_header_compile "$LINENO" "regex.h" "ac_cv_header_regex_h" "$ac_includes_default" if test "x$ac_cv_header_regex_h" = xyes @@ -14481,8 +15175,8 @@ printf %s "checking for working alloca.h... " >&6; } if test ${ac_cv_working_alloca_h+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int @@ -14497,11 +15191,13 @@ _ACEOF if ac_fn_c_try_link "$LINENO" then : ac_cv_working_alloca_h=yes -else $as_nop - ac_cv_working_alloca_h=no +else case e in #( + e) ac_cv_working_alloca_h=no ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext + conftest$ac_exeext conftest.$ac_ext ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_working_alloca_h" >&5 printf "%s\n" "$ac_cv_working_alloca_h" >&6; } @@ -14516,10 +15212,10 @@ printf %s "checking for alloca... " >&6; } if test ${ac_cv_func_alloca_works+y} then : printf %s "(cached) " >&6 -else $as_nop - if test $ac_cv_working_alloca_h = yes; then - ac_cv_func_alloca_works=yes -else +else case e in #( + e) ac_cv_func_alloca_works=$ac_cv_working_alloca_h +if test "$ac_cv_func_alloca_works" != yes +then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -14550,15 +15246,14 @@ _ACEOF if ac_fn_c_try_link "$LINENO" then : ac_cv_func_alloca_works=yes -else $as_nop - ac_cv_func_alloca_works=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext +fi ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_alloca_works" >&5 printf "%s\n" "$ac_cv_func_alloca_works" >&6; } -fi if test $ac_cv_func_alloca_works = yes; then @@ -14580,12 +15275,12 @@ printf %s "checking stack direction for C alloca... " >&6; } if test ${ac_cv_c_stack_direction+y} then : printf %s "(cached) " >&6 -else $as_nop - if test "$cross_compiling" = yes +else case e in #( + e) if test "$cross_compiling" = yes then : ac_cv_c_stack_direction=0 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int @@ -14608,13 +15303,16 @@ _ACEOF if ac_fn_c_try_run "$LINENO" then : ac_cv_c_stack_direction=1 -else $as_nop - ac_cv_c_stack_direction=-1 +else case e in #( + e) ac_cv_c_stack_direction=-1 ;; +esac fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_stack_direction" >&5 printf "%s\n" "$ac_cv_c_stack_direction" >&6; } @@ -14623,36 +15321,26 @@ printf "%s\n" "#define STACK_DIRECTION $ac_cv_c_stack_direction" >>confdefs.h fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for uid_t in sys/types.h" >&5 -printf %s "checking for uid_t in sys/types.h... " >&6; } -if test ${ac_cv_type_uid_t+y} -then : - printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "uid_t" >/dev/null 2>&1 +ac_fn_c_check_type "$LINENO" "uid_t" "ac_cv_type_uid_t" "$ac_includes_default" +if test "x$ac_cv_type_uid_t" = xyes then : - ac_cv_type_uid_t=yes -else $as_nop - ac_cv_type_uid_t=no -fi -rm -rf conftest* - -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_uid_t" >&5 -printf "%s\n" "$ac_cv_type_uid_t" >&6; } -if test $ac_cv_type_uid_t = no; then +else case e in #( + e) printf "%s\n" "#define uid_t int" >>confdefs.h + ;; +esac +fi +ac_fn_c_check_type "$LINENO" "gid_t" "ac_cv_type_gid_t" "$ac_includes_default" +if test "x$ac_cv_type_gid_t" = xyes +then : +else case e in #( + e) printf "%s\n" "#define gid_t int" >>confdefs.h - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for working chown" >&5 @@ -14660,8 +15348,8 @@ printf %s "checking for working chown... " >&6; } if test ${ac_cv_func_chown_works+y} then : printf %s "(cached) " >&6 -else $as_nop - if test "$cross_compiling" = yes +else case e in #( + e) if test "$cross_compiling" = yes then : case "$host_os" in # (( # Guess yes on glibc systems. @@ -14669,8 +15357,8 @@ then : # If we don't know, assume the worst. *) ac_cv_func_chown_works=no ;; esac -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default #include @@ -14698,15 +15386,18 @@ _ACEOF if ac_fn_c_try_run "$LINENO" then : ac_cv_func_chown_works=yes -else $as_nop - ac_cv_func_chown_works=no +else case e in #( + e) ac_cv_func_chown_works=no ;; +esac fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi rm -f conftest.chown - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_chown_works" >&5 printf "%s\n" "$ac_cv_func_chown_works" >&6; } @@ -14721,8 +15412,8 @@ printf %s "checking whether getpgrp requires zero arguments... " >&6; } if test ${ac_cv_func_getpgrp_void+y} then : printf %s "(cached) " >&6 -else $as_nop - # Use it with a single arg. +else case e in #( + e) # Use it with a single arg. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default @@ -14737,11 +15428,13 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_cv_func_getpgrp_void=no -else $as_nop - ac_cv_func_getpgrp_void=yes +else case e in #( + e) ac_cv_func_getpgrp_void=yes ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_getpgrp_void" >&5 printf "%s\n" "$ac_cv_func_getpgrp_void" >&6; } @@ -14769,8 +15462,8 @@ printf %s "checking for working strcoll... " >&6; } if test ${ac_cv_func_strcoll_works+y} then : printf %s "(cached) " >&6 -else $as_nop - if test "$cross_compiling" = yes +else case e in #( + e) if test "$cross_compiling" = yes then : case "$host_os" in # (( # Guess yes on glibc systems. @@ -14778,8 +15471,8 @@ then : # If we don't know, assume the worst. *) ac_cv_func_strcoll_works=no ;; esac -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int @@ -14795,13 +15488,16 @@ _ACEOF if ac_fn_c_try_run "$LINENO" then : ac_cv_func_strcoll_works=yes -else $as_nop - ac_cv_func_strcoll_works=no +else case e in #( + e) ac_cv_func_strcoll_works=no ;; +esac fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_strcoll_works" >&5 printf "%s\n" "$ac_cv_func_strcoll_works" >&6; } @@ -14832,7 +15528,7 @@ printf %s "checking for declaration of vprintf in stdio.h... " >&6; } _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "[int[ ]*vprintf[^a-zA-Z0-9]]" >/dev/null 2>&1 + $EGREP_TRADITIONAL "[int[ ]*vprintf[^a-zA-Z0-9]]" >/dev/null 2>&1 then : ac_cv_func_vprintf=yes fi @@ -14875,9 +15571,10 @@ if test "x$ac_cv_func_mkfifo" = xyes then : printf "%s\n" "#define HAVE_MKFIFO 1" >>confdefs.h -else $as_nop - printf "%s\n" "#define MKFIFO_MISSING 1" >>confdefs.h - +else case e in #( + e) printf "%s\n" "#define MKFIFO_MISSING 1" >>confdefs.h + ;; +esac fi @@ -14976,6 +15673,12 @@ if test "x$ac_cv_func_lstat" = xyes then : printf "%s\n" "#define HAVE_LSTAT 1" >>confdefs.h +fi +ac_fn_c_check_func "$LINENO" "nanosleep" "ac_cv_func_nanosleep" +if test "x$ac_cv_func_nanosleep" = xyes +then : + printf "%s\n" "#define HAVE_NANOSLEEP 1" >>confdefs.h + fi ac_fn_c_check_func "$LINENO" "pselect" "ac_cv_func_pselect" if test "x$ac_cv_func_pselect" = xyes @@ -15006,6 +15709,12 @@ if test "x$ac_cv_func_setitimer" = xyes then : printf "%s\n" "#define HAVE_SETITIMER 1" >>confdefs.h +fi +ac_fn_c_check_func "$LINENO" "statfs" "ac_cv_func_statfs" +if test "x$ac_cv_func_statfs" = xyes +then : + printf "%s\n" "#define HAVE_STATFS 1" >>confdefs.h + fi ac_fn_c_check_func "$LINENO" "tcgetpgrp" "ac_cv_func_tcgetpgrp" if test "x$ac_cv_func_tcgetpgrp" = xyes @@ -15037,13 +15746,14 @@ if test "x$ac_cv_func_rename" = xyes then : printf "%s\n" "#define HAVE_RENAME 1" >>confdefs.h -else $as_nop - case " $LIBOBJS " in +else case e in #( + e) case " $LIBOBJS " in *" rename.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS rename.$ac_objext" ;; esac - + ;; +esac fi @@ -15058,6 +15768,12 @@ if test "x$ac_cv_func_bzero" = xyes then : printf "%s\n" "#define HAVE_BZERO 1" >>confdefs.h +fi +ac_fn_c_check_func "$LINENO" "clock_gettime" "ac_cv_func_clock_gettime" +if test "x$ac_cv_func_clock_gettime" = xyes +then : + printf "%s\n" "#define HAVE_CLOCK_GETTIME 1" >>confdefs.h + fi ac_fn_c_check_func "$LINENO" "confstr" "ac_cv_func_confstr" if test "x$ac_cv_func_confstr" = xyes @@ -15208,6 +15924,18 @@ if test "x$ac_cv_func_tcgetattr" = xyes then : printf "%s\n" "#define HAVE_TCGETATTR 1" >>confdefs.h +fi +ac_fn_c_check_func "$LINENO" "tcgetwinsize" "ac_cv_func_tcgetwinsize" +if test "x$ac_cv_func_tcgetwinsize" = xyes +then : + printf "%s\n" "#define HAVE_TCGETWINSIZE 1" >>confdefs.h + +fi +ac_fn_c_check_func "$LINENO" "tcsetwinsize" "ac_cv_func_tcsetwinsize" +if test "x$ac_cv_func_tcsetwinsize" = xyes +then : + printf "%s\n" "#define HAVE_TCSETWINSIZE 1" >>confdefs.h + fi ac_fn_c_check_func "$LINENO" "times" "ac_cv_func_times" if test "x$ac_cv_func_times" = xyes @@ -15324,32 +16052,61 @@ then : fi +ac_fn_c_check_func "$LINENO" "strlcat" "ac_cv_func_strlcat" +if test "x$ac_cv_func_strlcat" = xyes +then : + printf "%s\n" "#define HAVE_STRLCAT 1" >>confdefs.h + +fi + + +ac_fn_c_check_func "$LINENO" "memfd_create" "ac_cv_func_memfd_create" +if test "x$ac_cv_func_memfd_create" = xyes +then : + printf "%s\n" "#define HAVE_MEMFD_CREATE 1" >>confdefs.h + +fi +ac_fn_c_check_func "$LINENO" "shm_open" "ac_cv_func_shm_open" +if test "x$ac_cv_func_shm_open" = xyes +then : + printf "%s\n" "#define HAVE_SHM_OPEN 1" >>confdefs.h + +fi +ac_fn_c_check_func "$LINENO" "shm_mkstemp" "ac_cv_func_shm_mkstemp" +if test "x$ac_cv_func_shm_mkstemp" = xyes +then : + printf "%s\n" "#define HAVE_SHM_MKSTEMP 1" >>confdefs.h + +fi + ac_fn_c_check_func "$LINENO" "getcwd" "ac_cv_func_getcwd" if test "x$ac_cv_func_getcwd" = xyes then : printf "%s\n" "#define HAVE_GETCWD 1" >>confdefs.h -else $as_nop - case " $LIBOBJS " in +else case e in #( + e) case " $LIBOBJS " in *" getcwd.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS getcwd.$ac_objext" ;; esac - + ;; +esac fi ac_fn_c_check_func "$LINENO" "memset" "ac_cv_func_memset" if test "x$ac_cv_func_memset" = xyes then : printf "%s\n" "#define HAVE_MEMSET 1" >>confdefs.h -else $as_nop - case " $LIBOBJS " in +else case e in #( + e) case " $LIBOBJS " in *" memset.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS memset.$ac_objext" ;; esac - + ;; +esac fi ac_fn_c_check_func "$LINENO" "strcasecmp" "ac_cv_func_strcasecmp" @@ -15357,91 +16114,98 @@ if test "x$ac_cv_func_strcasecmp" = xyes then : printf "%s\n" "#define HAVE_STRCASECMP 1" >>confdefs.h -else $as_nop - case " $LIBOBJS " in +else case e in #( + e) case " $LIBOBJS " in *" strcasecmp.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS strcasecmp.$ac_objext" ;; esac - + ;; +esac fi ac_fn_c_check_func "$LINENO" "strcasestr" "ac_cv_func_strcasestr" if test "x$ac_cv_func_strcasestr" = xyes then : printf "%s\n" "#define HAVE_STRCASESTR 1" >>confdefs.h -else $as_nop - case " $LIBOBJS " in +else case e in #( + e) case " $LIBOBJS " in *" strcasestr.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS strcasestr.$ac_objext" ;; esac - + ;; +esac fi ac_fn_c_check_func "$LINENO" "strerror" "ac_cv_func_strerror" if test "x$ac_cv_func_strerror" = xyes then : printf "%s\n" "#define HAVE_STRERROR 1" >>confdefs.h -else $as_nop - case " $LIBOBJS " in +else case e in #( + e) case " $LIBOBJS " in *" strerror.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS strerror.$ac_objext" ;; esac - + ;; +esac fi ac_fn_c_check_func "$LINENO" "strftime" "ac_cv_func_strftime" if test "x$ac_cv_func_strftime" = xyes then : printf "%s\n" "#define HAVE_STRFTIME 1" >>confdefs.h -else $as_nop - case " $LIBOBJS " in +else case e in #( + e) case " $LIBOBJS " in *" strftime.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS strftime.$ac_objext" ;; esac - + ;; +esac fi ac_fn_c_check_func "$LINENO" "strnlen" "ac_cv_func_strnlen" if test "x$ac_cv_func_strnlen" = xyes then : printf "%s\n" "#define HAVE_STRNLEN 1" >>confdefs.h -else $as_nop - case " $LIBOBJS " in +else case e in #( + e) case " $LIBOBJS " in *" strnlen.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS strnlen.$ac_objext" ;; esac - + ;; +esac fi ac_fn_c_check_func "$LINENO" "strpbrk" "ac_cv_func_strpbrk" if test "x$ac_cv_func_strpbrk" = xyes then : printf "%s\n" "#define HAVE_STRPBRK 1" >>confdefs.h -else $as_nop - case " $LIBOBJS " in +else case e in #( + e) case " $LIBOBJS " in *" strpbrk.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS strpbrk.$ac_objext" ;; esac - + ;; +esac fi ac_fn_c_check_func "$LINENO" "strstr" "ac_cv_func_strstr" if test "x$ac_cv_func_strstr" = xyes then : printf "%s\n" "#define HAVE_STRSTR 1" >>confdefs.h -else $as_nop - case " $LIBOBJS " in +else case e in #( + e) case " $LIBOBJS " in *" strstr.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS strstr.$ac_objext" ;; esac - + ;; +esac fi ac_fn_c_check_func "$LINENO" "strtod" "ac_cv_func_strtod" @@ -15449,78 +16213,84 @@ if test "x$ac_cv_func_strtod" = xyes then : printf "%s\n" "#define HAVE_STRTOD 1" >>confdefs.h -else $as_nop - case " $LIBOBJS " in +else case e in #( + e) case " $LIBOBJS " in *" strtod.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS strtod.$ac_objext" ;; esac - + ;; +esac fi ac_fn_c_check_func "$LINENO" "strtol" "ac_cv_func_strtol" if test "x$ac_cv_func_strtol" = xyes then : printf "%s\n" "#define HAVE_STRTOL 1" >>confdefs.h -else $as_nop - case " $LIBOBJS " in +else case e in #( + e) case " $LIBOBJS " in *" strtol.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS strtol.$ac_objext" ;; esac - + ;; +esac fi ac_fn_c_check_func "$LINENO" "strtoul" "ac_cv_func_strtoul" if test "x$ac_cv_func_strtoul" = xyes then : printf "%s\n" "#define HAVE_STRTOUL 1" >>confdefs.h -else $as_nop - case " $LIBOBJS " in +else case e in #( + e) case " $LIBOBJS " in *" strtoul.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS strtoul.$ac_objext" ;; esac - + ;; +esac fi ac_fn_c_check_func "$LINENO" "strtoll" "ac_cv_func_strtoll" if test "x$ac_cv_func_strtoll" = xyes then : printf "%s\n" "#define HAVE_STRTOLL 1" >>confdefs.h -else $as_nop - case " $LIBOBJS " in +else case e in #( + e) case " $LIBOBJS " in *" strtoll.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS strtoll.$ac_objext" ;; esac - + ;; +esac fi ac_fn_c_check_func "$LINENO" "strtoull" "ac_cv_func_strtoull" if test "x$ac_cv_func_strtoull" = xyes then : printf "%s\n" "#define HAVE_STRTOULL 1" >>confdefs.h -else $as_nop - case " $LIBOBJS " in +else case e in #( + e) case " $LIBOBJS " in *" strtoull.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS strtoull.$ac_objext" ;; esac - + ;; +esac fi ac_fn_c_check_func "$LINENO" "strtoumax" "ac_cv_func_strtoumax" if test "x$ac_cv_func_strtoumax" = xyes then : printf "%s\n" "#define HAVE_STRTOUMAX 1" >>confdefs.h -else $as_nop - case " $LIBOBJS " in +else case e in #( + e) case " $LIBOBJS " in *" strtoumax.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS strtoumax.$ac_objext" ;; esac - + ;; +esac fi ac_fn_c_check_func "$LINENO" "dprintf" "ac_cv_func_dprintf" @@ -15528,27 +16298,14 @@ if test "x$ac_cv_func_dprintf" = xyes then : printf "%s\n" "#define HAVE_DPRINTF 1" >>confdefs.h -else $as_nop - case " $LIBOBJS " in +else case e in #( + e) case " $LIBOBJS " in *" dprintf.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS dprintf.$ac_objext" ;; esac - -fi - -ac_fn_c_check_func "$LINENO" "strchrnul" "ac_cv_func_strchrnul" -if test "x$ac_cv_func_strchrnul" = xyes -then : - printf "%s\n" "#define HAVE_STRCHRNUL 1" >>confdefs.h - -else $as_nop - case " $LIBOBJS " in - *" strchrnul.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS strchrnul.$ac_objext" ;; esac - fi ac_fn_c_check_func "$LINENO" "strdup" "ac_cv_func_strdup" @@ -15556,13 +16313,44 @@ if test "x$ac_cv_func_strdup" = xyes then : printf "%s\n" "#define HAVE_STRDUP 1" >>confdefs.h -else $as_nop - case " $LIBOBJS " in +else case e in #( + e) case " $LIBOBJS " in *" strdup.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS strdup.$ac_objext" ;; esac + ;; +esac +fi + +ac_fn_c_check_func "$LINENO" "strlcpy" "ac_cv_func_strlcpy" +if test "x$ac_cv_func_strlcpy" = xyes +then : + printf "%s\n" "#define HAVE_STRLCPY 1" >>confdefs.h + +else case e in #( + e) case " $LIBOBJS " in + *" strlcpy.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS strlcpy.$ac_objext" + ;; +esac + ;; +esac +fi + +ac_fn_c_check_func "$LINENO" "reallocarray" "ac_cv_func_reallocarray" +if test "x$ac_cv_func_reallocarray" = xyes +then : + printf "%s\n" "#define HAVE_REALLOCARRAY 1" >>confdefs.h +else case e in #( + e) case " $LIBOBJS " in + *" reallocarray.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS reallocarray.$ac_objext" + ;; +esac + ;; +esac fi @@ -15578,8 +16366,9 @@ ac_fn_check_decl "$LINENO" "AUDIT_USER_TTY" "ac_cv_have_decl_AUDIT_USER_TTY" "#i if test "x$ac_cv_have_decl_AUDIT_USER_TTY" = xyes then : ac_have_decl=1 -else $as_nop - ac_have_decl=0 +else case e in #( + e) ac_have_decl=0 ;; +esac fi printf "%s\n" "#define HAVE_DECL_AUDIT_USER_TTY $ac_have_decl" >>confdefs.h @@ -15588,8 +16377,9 @@ ac_fn_check_decl "$LINENO" "confstr" "ac_cv_have_decl_confstr" "$ac_includes_def if test "x$ac_cv_have_decl_confstr" = xyes then : ac_have_decl=1 -else $as_nop - ac_have_decl=0 +else case e in #( + e) ac_have_decl=0 ;; +esac fi printf "%s\n" "#define HAVE_DECL_CONFSTR $ac_have_decl" >>confdefs.h @@ -15597,17 +16387,29 @@ ac_fn_check_decl "$LINENO" "printf" "ac_cv_have_decl_printf" "$ac_includes_defau if test "x$ac_cv_have_decl_printf" = xyes then : ac_have_decl=1 -else $as_nop - ac_have_decl=0 +else case e in #( + e) ac_have_decl=0 ;; +esac fi printf "%s\n" "#define HAVE_DECL_PRINTF $ac_have_decl" >>confdefs.h +ac_fn_check_decl "$LINENO" "brk" "ac_cv_have_decl_brk" "$ac_includes_default" "$ac_c_undeclared_builtin_options" "CFLAGS" +if test "x$ac_cv_have_decl_brk" = xyes +then : + ac_have_decl=1 +else case e in #( + e) ac_have_decl=0 ;; +esac +fi +printf "%s\n" "#define HAVE_DECL_BRK $ac_have_decl" >>confdefs.h + ac_fn_check_decl "$LINENO" "sbrk" "ac_cv_have_decl_sbrk" "$ac_includes_default" "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_sbrk" = xyes then : ac_have_decl=1 -else $as_nop - ac_have_decl=0 +else case e in #( + e) ac_have_decl=0 ;; +esac fi printf "%s\n" "#define HAVE_DECL_SBRK $ac_have_decl" >>confdefs.h @@ -15615,8 +16417,9 @@ ac_fn_check_decl "$LINENO" "setregid" "ac_cv_have_decl_setregid" "$ac_includes_d if test "x$ac_cv_have_decl_setregid" = xyes then : ac_have_decl=1 -else $as_nop - ac_have_decl=0 +else case e in #( + e) ac_have_decl=0 ;; +esac fi printf "%s\n" "#define HAVE_DECL_SETREGID $ac_have_decl" >>confdefs.h @@ -15624,8 +16427,9 @@ ac_fn_check_decl "$LINENO" "strcpy" "ac_cv_have_decl_strcpy" "$ac_includes_defau if test "x$ac_cv_have_decl_strcpy" = xyes then : ac_have_decl=1 -else $as_nop - ac_have_decl=0 +else case e in #( + e) ac_have_decl=0 ;; +esac fi printf "%s\n" "#define HAVE_DECL_STRCPY $ac_have_decl" >>confdefs.h @@ -15633,8 +16437,9 @@ ac_fn_check_decl "$LINENO" "strsignal" "ac_cv_have_decl_strsignal" "$ac_includes if test "x$ac_cv_have_decl_strsignal" = xyes then : ac_have_decl=1 -else $as_nop - ac_have_decl=0 +else case e in #( + e) ac_have_decl=0 ;; +esac fi printf "%s\n" "#define HAVE_DECL_STRSIGNAL $ac_have_decl" >>confdefs.h @@ -15657,8 +16462,9 @@ ac_fn_check_decl "$LINENO" "strtold" "ac_cv_have_decl_strtold" "$ac_includes_def if test "x$ac_cv_have_decl_strtold" = xyes then : ac_have_decl=1 -else $as_nop - ac_have_decl=0 +else case e in #( + e) ac_have_decl=0 ;; +esac fi printf "%s\n" "#define HAVE_DECL_STRTOLD $ac_have_decl" >>confdefs.h if test $ac_have_decl = 1 @@ -15669,8 +16475,8 @@ printf %s "checking for broken strtold... " >&6; } if test ${bash_cv_strtold_broken+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int @@ -15685,12 +16491,14 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : bash_cv_strtold_broken=no -else $as_nop - bash_cv_strtold_broken=yes +else case e in #( + e) bash_cv_strtold_broken=yes ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_strtold_broken" >&5 @@ -15707,8 +16515,9 @@ ac_fn_check_decl "$LINENO" "strtol" "ac_cv_have_decl_strtol" "$ac_includes_defau if test "x$ac_cv_have_decl_strtol" = xyes then : ac_have_decl=1 -else $as_nop - ac_have_decl=0 +else case e in #( + e) ac_have_decl=0 ;; +esac fi printf "%s\n" "#define HAVE_DECL_STRTOL $ac_have_decl" >>confdefs.h @@ -15716,8 +16525,9 @@ ac_fn_check_decl "$LINENO" "strtoll" "ac_cv_have_decl_strtoll" "$ac_includes_def if test "x$ac_cv_have_decl_strtoll" = xyes then : ac_have_decl=1 -else $as_nop - ac_have_decl=0 +else case e in #( + e) ac_have_decl=0 ;; +esac fi printf "%s\n" "#define HAVE_DECL_STRTOLL $ac_have_decl" >>confdefs.h @@ -15725,8 +16535,9 @@ ac_fn_check_decl "$LINENO" "strtoul" "ac_cv_have_decl_strtoul" "$ac_includes_def if test "x$ac_cv_have_decl_strtoul" = xyes then : ac_have_decl=1 -else $as_nop - ac_have_decl=0 +else case e in #( + e) ac_have_decl=0 ;; +esac fi printf "%s\n" "#define HAVE_DECL_STRTOUL $ac_have_decl" >>confdefs.h @@ -15734,8 +16545,9 @@ ac_fn_check_decl "$LINENO" "strtoull" "ac_cv_have_decl_strtoull" "$ac_includes_d if test "x$ac_cv_have_decl_strtoull" = xyes then : ac_have_decl=1 -else $as_nop - ac_have_decl=0 +else case e in #( + e) ac_have_decl=0 ;; +esac fi printf "%s\n" "#define HAVE_DECL_STRTOULL $ac_have_decl" >>confdefs.h @@ -15743,8 +16555,9 @@ ac_fn_check_decl "$LINENO" "strtoumax" "ac_cv_have_decl_strtoumax" "$ac_includes if test "x$ac_cv_have_decl_strtoumax" = xyes then : ac_have_decl=1 -else $as_nop - ac_have_decl=0 +else case e in #( + e) ac_have_decl=0 ;; +esac fi printf "%s\n" "#define HAVE_DECL_STRTOUMAX $ac_have_decl" >>confdefs.h @@ -15758,12 +16571,12 @@ printf %s "checking for working mktime... " >&6; } if test ${ac_cv_func_working_mktime+y} then : printf %s "(cached) " >&6 -else $as_nop - if test "$cross_compiling" = yes +else case e in #( + e) if test "$cross_compiling" = yes then : ac_cv_func_working_mktime=no -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Test program from Paul Eggert and Tony Leneis. */ #include @@ -15798,7 +16611,7 @@ static const char *tz_strings[] = { /* Return 0 if mktime fails to convert a date in the spring-forward gap. Based on a problem report from Andreas Jaeger. */ static int -spring_forward_gap () +spring_forward_gap (void) { /* glibc (up to about 1998-10-07) failed this test. */ struct tm tm; @@ -15835,7 +16648,7 @@ mktime_test (time_t now) } static int -irix_6_4_bug () +irix_6_4_bug (void) { /* Based on code from Ariel Faigon. */ struct tm tm; @@ -15877,7 +16690,7 @@ bigtime_test (int j) } static int -year_2050_test () +year_2050_test (void) { /* The correct answer for 2050-02-01 00:00:00 in Pacific time, ignoring leap seconds. */ @@ -15954,13 +16767,16 @@ _ACEOF if ac_fn_c_try_run "$LINENO" then : ac_cv_func_working_mktime=yes -else $as_nop - ac_cv_func_working_mktime=no +else case e in #( + e) ac_cv_func_working_mktime=no ;; +esac fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_working_mktime" >&5 printf "%s\n" "$ac_cv_func_working_mktime" >&6; } @@ -16007,6 +16823,8 @@ then : fi +printf "%s\n" "#define HAVE_MALLOC 1" >>confdefs.h + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for working mmap" >&5 @@ -16014,8 +16832,8 @@ printf %s "checking for working mmap... " >&6; } if test ${ac_cv_func_mmap_fixed_mapped+y} then : printf %s "(cached) " >&6 -else $as_nop - if test "$cross_compiling" = yes +else case e in #( + e) if test "$cross_compiling" = yes then : case "$host_os" in # (( # Guess yes on platforms where we know the result. @@ -16023,8 +16841,8 @@ then : # If we don't know, assume the worst. *) ac_cv_func_mmap_fixed_mapped=no ;; esac -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default /* malloc might have been renamed as rpl_malloc. */ @@ -16045,21 +16863,21 @@ $ac_includes_default VM page cache was not coherent with the file system buffer cache like early versions of FreeBSD and possibly contemporary NetBSD.) For shared mappings, we should conversely verify that changes get - propagated back to all the places they're supposed to be. - - Grep wants private fixed already mapped. - The main things grep needs to know about mmap are: - * does it exist and is it safe to write into the mmap'd area - * how to use it (BSD variants) */ + propagated back to all the places they're supposed to be. */ #include #include -/* This mess was copied from the GNU getpagesize.h. */ -#ifndef HAVE_GETPAGESIZE +#ifndef getpagesize +/* Prefer sysconf to the legacy getpagesize function, as getpagesize has + been removed from POSIX and is limited to page sizes that fit in 'int'. */ # ifdef _SC_PAGESIZE -# define getpagesize() sysconf(_SC_PAGESIZE) -# else /* no _SC_PAGESIZE */ +# define getpagesize() sysconf (_SC_PAGESIZE) +# elif defined _SC_PAGE_SIZE +# define getpagesize() sysconf (_SC_PAGE_SIZE) +# elif HAVE_GETPAGESIZE +int getpagesize (); +# else # ifdef HAVE_SYS_PARAM_H # include # ifdef EXEC_PAGESIZE @@ -16083,16 +16901,15 @@ $ac_includes_default # else /* no HAVE_SYS_PARAM_H */ # define getpagesize() 8192 /* punt totally */ # endif /* no HAVE_SYS_PARAM_H */ -# endif /* no _SC_PAGESIZE */ - -#endif /* no HAVE_GETPAGESIZE */ +# endif +#endif int main (void) { char *data, *data2, *data3; const char *cdata2; - int i, pagesize; + long i, pagesize; int fd, fd2; pagesize = getpagesize (); @@ -16126,8 +16943,7 @@ main (void) if (*(data2 + i)) return 7; close (fd2); - if (munmap (data2, pagesize)) - return 8; + /* 'return 8;' not currently used. */ /* Next, try to mmap the file at a fixed address which already has something else allocated at it. If we can, also make sure that @@ -16164,13 +16980,16 @@ _ACEOF if ac_fn_c_try_run "$LINENO" then : ac_cv_func_mmap_fixed_mapped=yes -else $as_nop - ac_cv_func_mmap_fixed_mapped=no +else case e in #( + e) ac_cv_func_mmap_fixed_mapped=no ;; +esac fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_mmap_fixed_mapped" >&5 printf "%s\n" "$ac_cv_func_mmap_fixed_mapped" >&6; } @@ -16204,6 +17023,12 @@ if test "x$ac_cv_func_dcgettext" = xyes then : printf "%s\n" "#define HAVE_DCGETTEXT 1" >>confdefs.h +fi +ac_fn_c_check_func "$LINENO" "locale_charset" "ac_cv_func_locale_charset" +if test "x$ac_cv_func_locale_charset" = xyes +then : + printf "%s\n" "#define HAVE_LOCALE_CHARSET 1" >>confdefs.h + fi ac_fn_c_check_func "$LINENO" "mempcpy" "ac_cv_func_mempcpy" if test "x$ac_cv_func_mempcpy" = xyes @@ -16242,6 +17067,9 @@ if test "x$USE_INCLUDED_LIBINTL" = "xyes"; then INTL_DEP='${INTL_LIBDIR}/libintl.a' INTL_INC='-I${INTL_LIBSRC} -I${INTL_BUILDDIR}' LIBINTL_H='${INTL_BUILDDIR}/libintl.h' + + printf "%s\n" "#define HAVE_LOCALE_CHARSET 1" >>confdefs.h + fi @@ -16289,7 +17117,7 @@ fi ac_fn_c_check_func "$LINENO" "mbscasecmp" "ac_cv_func_mbscasecmp" if test "x$ac_cv_func_mbscasecmp" = xyes then : - printf "%s\n" "#define HAVE_MBSCMP 1" >>confdefs.h + printf "%s\n" "#define HAVE_MBSCASECMP 1" >>confdefs.h fi @@ -16300,6 +17128,13 @@ then : fi +ac_fn_c_check_func "$LINENO" "mbsncmp" "ac_cv_func_mbsncmp" +if test "x$ac_cv_func_mbsncmp" = xyes +then : + printf "%s\n" "#define HAVE_MBSNCMP 1" >>confdefs.h + +fi + ac_fn_c_check_func "$LINENO" "mbsnrtowcs" "ac_cv_func_mbsnrtowcs" if test "x$ac_cv_func_mbsnrtowcs" = xyes then : @@ -16320,13 +17155,14 @@ if test "x$ac_cv_func_mbschr" = xyes then : printf "%s\n" "#define HAVE_MBSCHR 1" >>confdefs.h -else $as_nop - case " $LIBOBJS " in +else case e in #( + e) case " $LIBOBJS " in *" mbschr.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS mbschr.$ac_objext" ;; esac - + ;; +esac fi @@ -16365,19 +17201,27 @@ then : fi +ac_fn_c_check_func "$LINENO" "wcsnrtombs" "ac_cv_func_wcsnrtombs" +if test "x$ac_cv_func_wcsnrtombs" = xyes +then : + printf "%s\n" "#define HAVE_WCSNRTOMBS 1" >>confdefs.h + +fi + ac_fn_c_check_func "$LINENO" "wcswidth" "ac_cv_func_wcswidth" if test "x$ac_cv_func_wcswidth" = xyes then : printf "%s\n" "#define HAVE_WCSWIDTH 1" >>confdefs.h -else $as_nop - case " $LIBOBJS " in +else case e in #( + e) case " $LIBOBJS " in *" wcswidth.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS wcswidth.$ac_objext" ;; esac - + ;; +esac fi @@ -16387,8 +17231,8 @@ printf %s "checking whether mbrtowc and mbstate_t are properly declared... " >&6 if test ${ac_cv_func_mbrtowc+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int @@ -16406,11 +17250,13 @@ _ACEOF if ac_fn_c_try_link "$LINENO" then : ac_cv_func_mbrtowc=yes -else $as_nop - ac_cv_func_mbrtowc=no +else case e in #( + e) ac_cv_func_mbrtowc=no ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext + conftest$ac_exeext conftest.$ac_ext ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_mbrtowc" >&5 printf "%s\n" "$ac_cv_func_mbrtowc" >&6; } @@ -16464,8 +17310,8 @@ printf %s "checking for wchar_t in wchar.h... " >&6; } if test ${bash_cv_type_wchar_t+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -16483,11 +17329,13 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : bash_cv_type_wchar_t=yes -else $as_nop - bash_cv_type_wchar_t=no - +else case e in #( + e) bash_cv_type_wchar_t=no + ;; +esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_type_wchar_t" >&5 printf "%s\n" "$bash_cv_type_wchar_t" >&6; } @@ -16502,8 +17350,8 @@ printf %s "checking for wctype_t in wctype.h... " >&6; } if test ${bash_cv_type_wctype_t+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -16521,11 +17369,13 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : bash_cv_type_wctype_t=yes -else $as_nop - bash_cv_type_wctype_t=no - +else case e in #( + e) bash_cv_type_wctype_t=no + ;; +esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_type_wctype_t" >&5 printf "%s\n" "$bash_cv_type_wctype_t" >&6; } @@ -16540,8 +17390,8 @@ printf %s "checking for wint_t in wctype.h... " >&6; } if test ${bash_cv_type_wint_t+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -16559,11 +17409,13 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : bash_cv_type_wint_t=yes -else $as_nop - bash_cv_type_wint_t=no - +else case e in #( + e) bash_cv_type_wint_t=no + ;; +esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_type_wint_t" >&5 printf "%s\n" "$bash_cv_type_wint_t" >&6; } @@ -16578,13 +17430,13 @@ printf %s "checking for wcwidth broken with unicode combining characters... " >& if test ${bash_cv_wcwidth_broken+y} then : printf %s "(cached) " >&6 -else $as_nop - if test "$cross_compiling" = yes +else case e in #( + e) if test "$cross_compiling" = yes then : bash_cv_wcwidth_broken=no -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -16595,14 +17447,15 @@ else $as_nop #include int -main(c, v) -int c; -char **v; +main(int c, char **v) { int w; setlocale(LC_ALL, "en_US.UTF-8"); w = wcwidth (0x0301); + if (w != 0) + exit (0); + w = wcwidth (0x200b); exit (w == 0); /* exit 0 if wcwidth broken */ } @@ -16610,13 +17463,16 @@ _ACEOF if ac_fn_c_try_run "$LINENO" then : bash_cv_wcwidth_broken=yes -else $as_nop - bash_cv_wcwidth_broken=no +else case e in #( + e) bash_cv_wcwidth_broken=no ;; +esac fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_wcwidth_broken" >&5 printf "%s\n" "$bash_cv_wcwidth_broken" >&6; } @@ -16641,28 +17497,30 @@ fi # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects -# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# declarations like 'int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking size of wchar_t" >&5 printf %s "checking size of wchar_t... " >&6; } if test ${ac_cv_sizeof_wchar_t+y} then : printf %s "(cached) " >&6 -else $as_nop - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (wchar_t))" "ac_cv_sizeof_wchar_t" "$ac_includes_default" +else case e in #( + e) if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (wchar_t))" "ac_cv_sizeof_wchar_t" "$ac_includes_default" then : -else $as_nop - if test "$ac_cv_type_wchar_t" = yes; then - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +else case e in #( + e) if test "$ac_cv_type_wchar_t" = yes; then + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (wchar_t) -See \`config.log' for more details" "$LINENO" 5; } +See 'config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_wchar_t=0 - fi + fi ;; +esac fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_wchar_t" >&5 printf "%s\n" "$ac_cv_sizeof_wchar_t" >&6; } @@ -16681,16 +17539,22 @@ printf %s "checking for dlopen in -ldl... " >&6; } if test ${ac_cv_lib_dl_dlopen+y} then : printf %s "(cached) " >&6 -else $as_nop - ac_check_lib_save_LIBS=$LIBS +else case e in #( + e) ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -char dlopen (); + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char dlopen (void); int main (void) { @@ -16702,12 +17566,14 @@ _ACEOF if ac_fn_c_try_link "$LINENO" then : ac_cv_lib_dl_dlopen=yes -else $as_nop - ac_cv_lib_dl_dlopen=no +else case e in #( + e) ac_cv_lib_dl_dlopen=no ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS +LIBS=$ac_check_lib_save_LIBS ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 printf "%s\n" "$ac_cv_lib_dl_dlopen" >&6; } @@ -16747,8 +17613,8 @@ printf %s "checking for inet_aton... " >&6; } if test ${bash_cv_func_inet_aton+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -16766,11 +17632,13 @@ _ACEOF if ac_fn_c_try_link "$LINENO" then : bash_cv_func_inet_aton=yes -else $as_nop - bash_cv_func_inet_aton=no +else case e in #( + e) bash_cv_func_inet_aton=no ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext + conftest$ac_exeext conftest.$ac_ext ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_func_inet_aton" >&5 printf "%s\n" "$bash_cv_func_inet_aton" >&6; } @@ -16794,16 +17662,22 @@ printf %s "checking for getpwent in -lsun... " >&6; } if test ${ac_cv_lib_sun_getpwent+y} then : printf %s "(cached) " >&6 -else $as_nop - ac_check_lib_save_LIBS=$LIBS +else case e in #( + e) ac_check_lib_save_LIBS=$LIBS LIBS="-lsun $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -char getpwent (); + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char getpwent (void); int main (void) { @@ -16815,12 +17689,14 @@ _ACEOF if ac_fn_c_try_link "$LINENO" then : ac_cv_lib_sun_getpwent=yes -else $as_nop - ac_cv_lib_sun_getpwent=no +else case e in #( + e) ac_cv_lib_sun_getpwent=no ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS +LIBS=$ac_check_lib_save_LIBS ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_sun_getpwent" >&5 printf "%s\n" "$ac_cv_lib_sun_getpwent" >&6; } @@ -16846,22 +17722,28 @@ fi if test ${bash_cv_have_socklib+y} then : printf %s "(cached) " >&6 -else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for getpeername in -lsocket" >&5 +else case e in #( + e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for getpeername in -lsocket" >&5 printf %s "checking for getpeername in -lsocket... " >&6; } if test ${ac_cv_lib_socket_getpeername+y} then : printf %s "(cached) " >&6 -else $as_nop - ac_check_lib_save_LIBS=$LIBS +else case e in #( + e) ac_check_lib_save_LIBS=$LIBS LIBS="-lsocket -lnsl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -char getpeername (); + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char getpeername (void); int main (void) { @@ -16873,22 +17755,26 @@ _ACEOF if ac_fn_c_try_link "$LINENO" then : ac_cv_lib_socket_getpeername=yes -else $as_nop - ac_cv_lib_socket_getpeername=no +else case e in #( + e) ac_cv_lib_socket_getpeername=no ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS +LIBS=$ac_check_lib_save_LIBS ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_getpeername" >&5 printf "%s\n" "$ac_cv_lib_socket_getpeername" >&6; } if test "x$ac_cv_lib_socket_getpeername" = xyes then : bash_cv_have_socklib=yes -else $as_nop - bash_cv_have_socklib=no +else case e in #( + e) bash_cv_have_socklib=no ;; +esac fi - + ;; +esac fi if test "X$_bash_needmsg" = Xyes; then @@ -16908,22 +17794,28 @@ printf %s "checking for libnsl... " >&6; } if test ${bash_cv_have_libnsl+y} then : printf %s "(cached) " >&6 -else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for t_open in -lnsl" >&5 +else case e in #( + e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for t_open in -lnsl" >&5 printf %s "checking for t_open in -lnsl... " >&6; } if test ${ac_cv_lib_nsl_t_open+y} then : printf %s "(cached) " >&6 -else $as_nop - ac_check_lib_save_LIBS=$LIBS +else case e in #( + e) ac_check_lib_save_LIBS=$LIBS LIBS="-lnsl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -char t_open (); + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char t_open (void); int main (void) { @@ -16935,22 +17827,26 @@ _ACEOF if ac_fn_c_try_link "$LINENO" then : ac_cv_lib_nsl_t_open=yes -else $as_nop - ac_cv_lib_nsl_t_open=no +else case e in #( + e) ac_cv_lib_nsl_t_open=no ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS +LIBS=$ac_check_lib_save_LIBS ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_t_open" >&5 printf "%s\n" "$ac_cv_lib_nsl_t_open" >&6; } if test "x$ac_cv_lib_nsl_t_open" = xyes then : bash_cv_have_libnsl=yes -else $as_nop - bash_cv_have_libnsl=no +else case e in #( + e) bash_cv_have_libnsl=no ;; +esac fi - + ;; +esac fi if test "X$_bash_needmsg" = Xyes; then @@ -16981,8 +17877,8 @@ fi if test ${bash_cv_have_gethostbyname+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -17001,12 +17897,14 @@ _ACEOF if ac_fn_c_try_link "$LINENO" then : bash_cv_have_gethostbyname=yes -else $as_nop - bash_cv_have_gethostbyname=no - +else case e in #( + e) bash_cv_have_gethostbyname=no + ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext + conftest$ac_exeext conftest.$ac_ext ;; +esac fi if test "X$_bash_needmsg" = Xyes; then @@ -17027,67 +17925,118 @@ printf %s "checking type of array argument to getgroups... " >&6; } if test ${ac_cv_type_getgroups+y} then : printf %s "(cached) " >&6 -else $as_nop - if test "$cross_compiling" = yes +else case e in #( + e) # If AC_TYPE_UID_T says there isn't any gid_t typedef, then we can skip +# everything below. +if test $ac_cv_type_gid_t = no then : - ac_cv_type_getgroups=cross -else $as_nop + ac_cv_type_getgroups=int +else case e in #( + e) # Test programs below rely on strict type checking of extern declarations: + # 'extern int getgroups(int, int *); extern int getgroups(int, pid_t *);' + # is valid in C89 if and only if pid_t is a typedef for int. Unlike + # anything involving either an assignment or a function call, compilers + # tend to make this kind of type mismatch a hard error, not just an + # "incompatible pointer types" warning. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -/* Thanks to Mike Rendell for this test. */ $ac_includes_default -#define NGID 256 -#undef MAX -#define MAX(x, y) ((x) > (y) ? (x) : (y)) - +extern int getgroups(int, gid_t *); int main (void) { - gid_t gidset[NGID]; - int i, n; - union { gid_t gval; long int lval; } val; - - val.lval = -1; - for (i = 0; i < NGID; i++) - gidset[i] = val.gval; - n = getgroups (sizeof (gidset) / MAX (sizeof (int), sizeof (gid_t)) - 1, - gidset); - /* Exit non-zero if getgroups seems to require an array of ints. This - happens when gid_t is short int but getgroups modifies an array - of ints. */ - return n > 0 && gidset[n] != val.gval; +return !(getgroups(0, 0) >= 0); + ; + return 0; } _ACEOF -if ac_fn_c_try_run "$LINENO" +if ac_fn_c_try_compile "$LINENO" then : - ac_cv_type_getgroups=gid_t -else $as_nop - ac_cv_type_getgroups=int + ac_getgroups_gidarray=yes +else case e in #( + e) ac_getgroups_gidarray=no ;; +esac fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default +extern int getgroups(int, int *); +int +main (void) +{ +return !(getgroups(0, 0) >= 0); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_getgroups_intarray=yes +else case e in #( + e) ac_getgroups_intarray=no ;; +esac fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext -if test $ac_cv_type_getgroups = cross; then - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + case int:$ac_getgroups_intarray,gid:$ac_getgroups_gidarray in #( + int:yes,gid:no) : + ac_cv_type_getgroups=int ;; #( + int:no,gid:yes) : + ac_cv_type_getgroups=gid_t ;; #( + int:yes,gid:yes) : + + # Both programs compiled - this means *either* that getgroups + # was declared with no prototype, in which case we should use int, + # or that it was declared prototyped but gid_t is a typedef for int, + # in which case we should use gid_t. Distinguish the two cases + # by testing if the compiler catches a blatantly incorrect function + # signature for getgroups. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include - +$ac_includes_default +extern int getgroups(int, float); +int +main (void) +{ +return !(getgroups(0, 0) >= 0); + ; + return 0; +} _ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "getgroups.*int.*gid_t" >/dev/null 2>&1 +if ac_fn_c_try_compile "$LINENO" then : - ac_cv_type_getgroups=gid_t -else $as_nop - ac_cv_type_getgroups=int + + # Compiler did not catch incorrect argument list; + # getgroups is unprototyped. + ac_cv_type_getgroups=int + +else case e in #( + e) + # Compiler caught incorrect argument list; + # gid_t is a typedef for int. + ac_cv_type_getgroups=gid_t + ;; +esac fi -rm -rf conftest* +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; #( + *) : + # Both programs failed to compile - this probably means getgroups + # wasn't declared at all. Use 'int', as this is probably a very + # old system where the type _would have been_ int. + ac_cv_type_getgroups=int + ;; +esac + ;; +esac fi + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_getgroups" >&5 printf "%s\n" "$ac_cv_type_getgroups" >&6; } - printf "%s\n" "#define GETGROUPS_T $ac_cv_type_getgroups" >>confdefs.h @@ -17095,52 +18044,44 @@ ac_fn_c_check_type "$LINENO" "off_t" "ac_cv_type_off_t" "$ac_includes_default" if test "x$ac_cv_type_off_t" = xyes then : -else $as_nop - +else case e in #( + e) printf "%s\n" "#define off_t long int" >>confdefs.h - + ;; +esac fi ac_fn_c_check_type "$LINENO" "mode_t" "ac_cv_type_mode_t" "$ac_includes_default" if test "x$ac_cv_type_mode_t" = xyes then : -else $as_nop - +else case e in #( + e) printf "%s\n" "#define mode_t int" >>confdefs.h - + ;; +esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for uid_t in sys/types.h" >&5 -printf %s "checking for uid_t in sys/types.h... " >&6; } -if test ${ac_cv_type_uid_t+y} -then : - printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "uid_t" >/dev/null 2>&1 +ac_fn_c_check_type "$LINENO" "uid_t" "ac_cv_type_uid_t" "$ac_includes_default" +if test "x$ac_cv_type_uid_t" = xyes then : - ac_cv_type_uid_t=yes -else $as_nop - ac_cv_type_uid_t=no -fi -rm -rf conftest* - -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_uid_t" >&5 -printf "%s\n" "$ac_cv_type_uid_t" >&6; } -if test $ac_cv_type_uid_t = no; then +else case e in #( + e) printf "%s\n" "#define uid_t int" >>confdefs.h + ;; +esac +fi +ac_fn_c_check_type "$LINENO" "gid_t" "ac_cv_type_gid_t" "$ac_includes_default" +if test "x$ac_cv_type_gid_t" = xyes +then : +else case e in #( + e) printf "%s\n" "#define gid_t int" >>confdefs.h - + ;; +esac fi @@ -17149,8 +18090,8 @@ fi if test "x$ac_cv_type_pid_t" = xyes then : -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if defined _WIN64 && !defined __CYGWIN__ @@ -17169,14 +18110,16 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_pid_type='int' -else $as_nop - ac_pid_type='__int64' +else case e in #( + e) ac_pid_type='__int64' ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext printf "%s\n" "#define pid_t $ac_pid_type" >>confdefs.h - + ;; +esac fi @@ -17184,21 +18127,59 @@ ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" if test "x$ac_cv_type_size_t" = xyes then : -else $as_nop - +else case e in #( + e) printf "%s\n" "#define size_t unsigned int" >>confdefs.h + ;; +esac +fi + + + ac_fn_c_check_type "$LINENO" "intptr_t" "ac_cv_type_intptr_t" "$ac_includes_default" +if test "x$ac_cv_type_intptr_t" = xyes +then : + +printf "%s\n" "#define HAVE_INTPTR_T 1" >>confdefs.h + +else case e in #( + e) for ac_type in 'int' 'long int' 'long long int'; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default +int +main (void) +{ +static int test_array [1 - 2 * !(sizeof (void *) <= sizeof ($ac_type))]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : +printf "%s\n" "#define intptr_t $ac_type" >>confdefs.h + + ac_type= +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + test -z "$ac_type" && break + done ;; +esac fi + ac_fn_c_check_type "$LINENO" "uintptr_t" "ac_cv_type_uintptr_t" "$ac_includes_default" if test "x$ac_cv_type_uintptr_t" = xyes then : printf "%s\n" "#define HAVE_UINTPTR_T 1" >>confdefs.h -else $as_nop - for ac_type in 'unsigned int' 'unsigned long int' \ +else case e in #( + e) for ac_type in 'unsigned int' 'unsigned long int' \ 'unsigned long long int'; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -17223,7 +18204,8 @@ printf "%s\n" "#define uintptr_t $ac_type" >>confdefs.h fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext test -z "$ac_type" && break - done + done ;; +esac fi @@ -17232,20 +18214,22 @@ ac_fn_c_check_type "$LINENO" "ssize_t" "ac_cv_type_ssize_t" "$ac_includes_defaul if test "x$ac_cv_type_ssize_t" = xyes then : -else $as_nop - +else case e in #( + e) printf "%s\n" "#define ssize_t int" >>confdefs.h - + ;; +esac fi ac_fn_c_check_type "$LINENO" "time_t" "ac_cv_type_time_t" "$ac_includes_default" if test "x$ac_cv_type_time_t" = xyes then : -else $as_nop - +else case e in #( + e) printf "%s\n" "#define time_t long" >>confdefs.h - + ;; +esac fi @@ -17256,8 +18240,8 @@ printf %s "checking for long long int... " >&6; } if test ${ac_cv_type_long_long_int+y} then : printf %s "(cached) " >&6 -else $as_nop - ac_cv_type_long_long_int=yes +else case e in #( + e) ac_cv_type_long_long_int=yes case $ac_prog_cc_stdc in no | c89) ;; *) @@ -17266,12 +18250,12 @@ else $as_nop if test "$cross_compiling" = yes then : : -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifndef LLONG_MAX - # define HALF \ + # define HALF \\ (1LL << (sizeof (long long int) * CHAR_BIT - 2)) # define LLONG_MAX (HALF - 1 + HALF) #endif @@ -17296,15 +18280,18 @@ _ACEOF if ac_fn_c_try_run "$LINENO" then : -else $as_nop - ac_cv_type_long_long_int=no +else case e in #( + e) ac_cv_type_long_long_int=no ;; +esac fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi fi;; - esac + esac ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_long_long_int" >&5 printf "%s\n" "$ac_cv_type_long_long_int" >&6; } @@ -17320,8 +18307,8 @@ printf %s "checking for unsigned long long int... " >&6; } if test ${ac_cv_type_unsigned_long_long_int+y} then : printf %s "(cached) " >&6 -else $as_nop - ac_cv_type_unsigned_long_long_int=yes +else case e in #( + e) ac_cv_type_unsigned_long_long_int=yes case $ac_prog_cc_stdc in no | c89) ;; *) @@ -17360,12 +18347,14 @@ _ACEOF if ac_fn_c_try_link "$LINENO" then : -else $as_nop - ac_cv_type_unsigned_long_long_int=no +else case e in #( + e) ac_cv_type_unsigned_long_long_int=no ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext;; - esac + esac ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_unsigned_long_long_int" >&5 printf "%s\n" "$ac_cv_type_unsigned_long_long_int" >&6; } @@ -17381,8 +18370,8 @@ printf %s "checking for sig_atomic_t in signal.h... " >&6; } if test ${ac_cv_have_sig_atomic_t+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int @@ -17396,11 +18385,13 @@ _ACEOF if ac_fn_c_try_link "$LINENO" then : ac_cv_have_sig_atomic_t=yes -else $as_nop - ac_cv_have_sig_atomic_t=no +else case e in #( + e) ac_cv_have_sig_atomic_t=no ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext + conftest$ac_exeext conftest.$ac_ext ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_have_sig_atomic_t" >&5 printf "%s\n" "$ac_cv_have_sig_atomic_t" >&6; } @@ -17413,8 +18404,8 @@ printf %s "checking for sig_atomic_t... " >&6; } if test ${bash_cv_type_sig_atomic_t+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #if HAVE_STDLIB_H @@ -17433,14 +18424,16 @@ else $as_nop _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "sig_atomic_t" >/dev/null 2>&1 + $EGREP_TRADITIONAL "sig_atomic_t" >/dev/null 2>&1 then : bash_cv_type_sig_atomic_t=yes -else $as_nop - bash_cv_type_sig_atomic_t=no +else case e in #( + e) bash_cv_type_sig_atomic_t=no ;; +esac fi rm -rf conftest* - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_type_sig_atomic_t" >&5 @@ -17456,28 +18449,30 @@ fi # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects -# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# declarations like 'int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking size of char" >&5 printf %s "checking size of char... " >&6; } if test ${ac_cv_sizeof_char+y} then : printf %s "(cached) " >&6 -else $as_nop - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (char))" "ac_cv_sizeof_char" "$ac_includes_default" +else case e in #( + e) if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (char))" "ac_cv_sizeof_char" "$ac_includes_default" then : -else $as_nop - if test "$ac_cv_type_char" = yes; then - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +else case e in #( + e) if test "$ac_cv_type_char" = yes; then + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (char) -See \`config.log' for more details" "$LINENO" 5; } +See 'config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_char=0 - fi + fi ;; +esac fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_char" >&5 printf "%s\n" "$ac_cv_sizeof_char" >&6; } @@ -17489,28 +18484,30 @@ printf "%s\n" "#define SIZEOF_CHAR $ac_cv_sizeof_char" >>confdefs.h # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects -# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# declarations like 'int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking size of short" >&5 printf %s "checking size of short... " >&6; } if test ${ac_cv_sizeof_short+y} then : printf %s "(cached) " >&6 -else $as_nop - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (short))" "ac_cv_sizeof_short" "$ac_includes_default" +else case e in #( + e) if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (short))" "ac_cv_sizeof_short" "$ac_includes_default" then : -else $as_nop - if test "$ac_cv_type_short" = yes; then - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +else case e in #( + e) if test "$ac_cv_type_short" = yes; then + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (short) -See \`config.log' for more details" "$LINENO" 5; } +See 'config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_short=0 - fi + fi ;; +esac fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_short" >&5 printf "%s\n" "$ac_cv_sizeof_short" >&6; } @@ -17522,28 +18519,30 @@ printf "%s\n" "#define SIZEOF_SHORT $ac_cv_sizeof_short" >>confdefs.h # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects -# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# declarations like 'int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking size of int" >&5 printf %s "checking size of int... " >&6; } if test ${ac_cv_sizeof_int+y} then : printf %s "(cached) " >&6 -else $as_nop - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (int))" "ac_cv_sizeof_int" "$ac_includes_default" +else case e in #( + e) if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (int))" "ac_cv_sizeof_int" "$ac_includes_default" then : -else $as_nop - if test "$ac_cv_type_int" = yes; then - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +else case e in #( + e) if test "$ac_cv_type_int" = yes; then + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (int) -See \`config.log' for more details" "$LINENO" 5; } +See 'config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_int=0 - fi + fi ;; +esac fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_int" >&5 printf "%s\n" "$ac_cv_sizeof_int" >&6; } @@ -17555,28 +18554,30 @@ printf "%s\n" "#define SIZEOF_INT $ac_cv_sizeof_int" >>confdefs.h # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects -# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# declarations like 'int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking size of long" >&5 printf %s "checking size of long... " >&6; } if test ${ac_cv_sizeof_long+y} then : printf %s "(cached) " >&6 -else $as_nop - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long))" "ac_cv_sizeof_long" "$ac_includes_default" +else case e in #( + e) if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long))" "ac_cv_sizeof_long" "$ac_includes_default" then : -else $as_nop - if test "$ac_cv_type_long" = yes; then - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +else case e in #( + e) if test "$ac_cv_type_long" = yes; then + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (long) -See \`config.log' for more details" "$LINENO" 5; } +See 'config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_long=0 - fi + fi ;; +esac fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long" >&5 printf "%s\n" "$ac_cv_sizeof_long" >&6; } @@ -17588,28 +18589,30 @@ printf "%s\n" "#define SIZEOF_LONG $ac_cv_sizeof_long" >>confdefs.h # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects -# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# declarations like 'int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking size of char *" >&5 printf %s "checking size of char *... " >&6; } if test ${ac_cv_sizeof_char_p+y} then : printf %s "(cached) " >&6 -else $as_nop - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (char *))" "ac_cv_sizeof_char_p" "$ac_includes_default" +else case e in #( + e) if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (char *))" "ac_cv_sizeof_char_p" "$ac_includes_default" then : -else $as_nop - if test "$ac_cv_type_char_p" = yes; then - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +else case e in #( + e) if test "$ac_cv_type_char_p" = yes; then + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (char *) -See \`config.log' for more details" "$LINENO" 5; } +See 'config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_char_p=0 - fi + fi ;; +esac fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_char_p" >&5 printf "%s\n" "$ac_cv_sizeof_char_p" >&6; } @@ -17621,28 +18624,30 @@ printf "%s\n" "#define SIZEOF_CHAR_P $ac_cv_sizeof_char_p" >>confdefs.h # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects -# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# declarations like 'int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking size of size_t" >&5 printf %s "checking size of size_t... " >&6; } if test ${ac_cv_sizeof_size_t+y} then : printf %s "(cached) " >&6 -else $as_nop - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (size_t))" "ac_cv_sizeof_size_t" "$ac_includes_default" +else case e in #( + e) if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (size_t))" "ac_cv_sizeof_size_t" "$ac_includes_default" then : -else $as_nop - if test "$ac_cv_type_size_t" = yes; then - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +else case e in #( + e) if test "$ac_cv_type_size_t" = yes; then + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (size_t) -See \`config.log' for more details" "$LINENO" 5; } +See 'config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_size_t=0 - fi + fi ;; +esac fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_size_t" >&5 printf "%s\n" "$ac_cv_sizeof_size_t" >&6; } @@ -17654,28 +18659,30 @@ printf "%s\n" "#define SIZEOF_SIZE_T $ac_cv_sizeof_size_t" >>confdefs.h # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects -# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# declarations like 'int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking size of double" >&5 printf %s "checking size of double... " >&6; } if test ${ac_cv_sizeof_double+y} then : printf %s "(cached) " >&6 -else $as_nop - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (double))" "ac_cv_sizeof_double" "$ac_includes_default" +else case e in #( + e) if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (double))" "ac_cv_sizeof_double" "$ac_includes_default" then : -else $as_nop - if test "$ac_cv_type_double" = yes; then - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +else case e in #( + e) if test "$ac_cv_type_double" = yes; then + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (double) -See \`config.log' for more details" "$LINENO" 5; } +See 'config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_double=0 - fi + fi ;; +esac fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_double" >&5 printf "%s\n" "$ac_cv_sizeof_double" >&6; } @@ -17687,28 +18694,30 @@ printf "%s\n" "#define SIZEOF_DOUBLE $ac_cv_sizeof_double" >>confdefs.h # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects -# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# declarations like 'int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking size of long long" >&5 printf %s "checking size of long long... " >&6; } if test ${ac_cv_sizeof_long_long+y} then : printf %s "(cached) " >&6 -else $as_nop - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long long))" "ac_cv_sizeof_long_long" "$ac_includes_default" +else case e in #( + e) if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long long))" "ac_cv_sizeof_long_long" "$ac_includes_default" then : -else $as_nop - if test "$ac_cv_type_long_long" = yes; then - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +else case e in #( + e) if test "$ac_cv_type_long_long" = yes; then + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (long long) -See \`config.log' for more details" "$LINENO" 5; } +See 'config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_long_long=0 - fi + fi ;; +esac fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long_long" >&5 printf "%s\n" "$ac_cv_sizeof_long_long" >&6; } @@ -17719,37 +18728,17 @@ printf "%s\n" "#define SIZEOF_LONG_LONG $ac_cv_sizeof_long_long" >>confdefs.h -ac_fn_c_check_type "$LINENO" "u_int" "ac_cv_type_u_int" "$ac_includes_default" -if test "x$ac_cv_type_u_int" = xyes -then : - -else $as_nop - -printf "%s\n" "#define u_int unsigned int" >>confdefs.h - -fi - -ac_fn_c_check_type "$LINENO" "u_long" "ac_cv_type_u_long" "$ac_includes_default" -if test "x$ac_cv_type_u_long" = xyes -then : - -else $as_nop - -printf "%s\n" "#define u_long unsigned long" >>confdefs.h - -fi - - if test "$ac_cv_sizeof_short" = 2; then ac_fn_c_check_type "$LINENO" "bits16_t" "ac_cv_type_bits16_t" "$ac_includes_default" if test "x$ac_cv_type_bits16_t" = xyes then : -else $as_nop - +else case e in #( + e) printf "%s\n" "#define bits16_t short" >>confdefs.h - + ;; +esac fi elif test "$ac_cv_sizeof_char" = 2; then @@ -17757,10 +18746,11 @@ elif test "$ac_cv_sizeof_char" = 2; then if test "x$ac_cv_type_bits16_t" = xyes then : -else $as_nop - +else case e in #( + e) printf "%s\n" "#define bits16_t char" >>confdefs.h - + ;; +esac fi else @@ -17768,10 +18758,11 @@ else if test "x$ac_cv_type_bits16_t" = xyes then : -else $as_nop - +else case e in #( + e) printf "%s\n" "#define bits16_t short" >>confdefs.h - + ;; +esac fi fi @@ -17782,10 +18773,11 @@ if test "$ac_cv_sizeof_short" = 2; then if test "x$ac_cv_type_u_bits16_t" = xyes then : -else $as_nop - +else case e in #( + e) printf "%s\n" "#define u_bits16_t unsigned short" >>confdefs.h - + ;; +esac fi elif test "$ac_cv_sizeof_char" = 2; then @@ -17793,10 +18785,11 @@ elif test "$ac_cv_sizeof_char" = 2; then if test "x$ac_cv_type_u_bits16_t" = xyes then : -else $as_nop - +else case e in #( + e) printf "%s\n" "#define u_bits16_t unsigned char" >>confdefs.h - + ;; +esac fi else @@ -17804,10 +18797,11 @@ else if test "x$ac_cv_type_u_bits16_t" = xyes then : -else $as_nop - +else case e in #( + e) printf "%s\n" "#define u_bits16_t unsigned short" >>confdefs.h - + ;; +esac fi fi @@ -17818,10 +18812,11 @@ if test "$ac_cv_sizeof_int" = 4; then if test "x$ac_cv_type_bits32_t" = xyes then : -else $as_nop - +else case e in #( + e) printf "%s\n" "#define bits32_t int" >>confdefs.h - + ;; +esac fi elif test "$ac_cv_sizeof_long" = 4; then @@ -17829,10 +18824,11 @@ elif test "$ac_cv_sizeof_long" = 4; then if test "x$ac_cv_type_bits32_t" = xyes then : -else $as_nop - +else case e in #( + e) printf "%s\n" "#define bits32_t long" >>confdefs.h - + ;; +esac fi else @@ -17840,10 +18836,11 @@ else if test "x$ac_cv_type_bits32_t" = xyes then : -else $as_nop - +else case e in #( + e) printf "%s\n" "#define bits32_t int" >>confdefs.h - + ;; +esac fi fi @@ -17854,10 +18851,11 @@ if test "$ac_cv_sizeof_int" = 4; then if test "x$ac_cv_type_u_bits32_t" = xyes then : -else $as_nop - +else case e in #( + e) printf "%s\n" "#define u_bits32_t unsigned int" >>confdefs.h - + ;; +esac fi elif test "$ac_cv_sizeof_long" = 4; then @@ -17865,10 +18863,11 @@ elif test "$ac_cv_sizeof_long" = 4; then if test "x$ac_cv_type_u_bits32_t" = xyes then : -else $as_nop - +else case e in #( + e) printf "%s\n" "#define u_bits32_t unsigned long" >>confdefs.h - + ;; +esac fi else @@ -17876,10 +18875,11 @@ else if test "x$ac_cv_type_u_bits32_t" = xyes then : -else $as_nop - +else case e in #( + e) printf "%s\n" "#define u_bits32_t unsigned int" >>confdefs.h - + ;; +esac fi fi @@ -17890,10 +18890,11 @@ if test "$ac_cv_sizeof_char_p" = 8; then if test "x$ac_cv_type_bits64_t" = xyes then : -else $as_nop - +else case e in #( + e) printf "%s\n" "#define bits64_t char *" >>confdefs.h - + ;; +esac fi elif test "$ac_cv_sizeof_double" = 8; then @@ -17901,10 +18902,11 @@ elif test "$ac_cv_sizeof_double" = 8; then if test "x$ac_cv_type_bits64_t" = xyes then : -else $as_nop - +else case e in #( + e) printf "%s\n" "#define bits64_t double" >>confdefs.h - + ;; +esac fi elif test -n "$ac_cv_type_long_long" && test "$ac_cv_sizeof_long_long" = 8; then @@ -17912,10 +18914,11 @@ elif test -n "$ac_cv_type_long_long" && test "$ac_cv_sizeof_long_long" = 8; then if test "x$ac_cv_type_bits64_t" = xyes then : -else $as_nop - +else case e in #( + e) printf "%s\n" "#define bits64_t long long" >>confdefs.h - + ;; +esac fi elif test "$ac_cv_sizeof_long" = 8; then @@ -17923,10 +18926,11 @@ elif test "$ac_cv_sizeof_long" = 8; then if test "x$ac_cv_type_bits64_t" = xyes then : -else $as_nop - +else case e in #( + e) printf "%s\n" "#define bits64_t long" >>confdefs.h - + ;; +esac fi else @@ -17934,10 +18938,11 @@ else if test "x$ac_cv_type_bits64_t" = xyes then : -else $as_nop - +else case e in #( + e) printf "%s\n" "#define bits64_t double" >>confdefs.h - + ;; +esac fi fi @@ -17949,10 +18954,11 @@ if test "$ac_cv_sizeof_int" = "$ac_cv_sizeof_char_p"; then if test "x$ac_cv_type_ptrdiff_t" = xyes then : -else $as_nop - +else case e in #( + e) printf "%s\n" "#define ptrdiff_t int" >>confdefs.h - + ;; +esac fi elif test "$ac_cv_sizeof_long" = "$ac_cv_sizeof_char_p"; then @@ -17960,10 +18966,11 @@ elif test "$ac_cv_sizeof_long" = "$ac_cv_sizeof_char_p"; then if test "x$ac_cv_type_ptrdiff_t" = xyes then : -else $as_nop - +else case e in #( + e) printf "%s\n" "#define ptrdiff_t long" >>confdefs.h - + ;; +esac fi elif test "$ac_cv_type_long_long" = yes && test "$ac_cv_sizeof_long_long" = "$ac_cv_sizeof_char_p"; then @@ -17971,10 +18978,11 @@ elif test "$ac_cv_type_long_long" = yes && test "$ac_cv_sizeof_long_long" = "$ac if test "x$ac_cv_type_ptrdiff_t" = xyes then : -else $as_nop - +else case e in #( + e) printf "%s\n" "#define ptrdiff_t long long" >>confdefs.h - + ;; +esac fi else @@ -17982,10 +18990,11 @@ else if test "x$ac_cv_type_ptrdiff_t" = xyes then : -else $as_nop - +else case e in #( + e) printf "%s\n" "#define ptrdiff_t int" >>confdefs.h - + ;; +esac fi fi @@ -17996,8 +19005,8 @@ printf %s "checking whether stat file-mode macros are broken... " >&6; } if test ${ac_cv_header_stat_broken+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include @@ -18022,10 +19031,12 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_cv_header_stat_broken=no -else $as_nop - ac_cv_header_stat_broken=yes +else case e in #( + e) ac_cv_header_stat_broken=yes ;; +esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stat_broken" >&5 printf "%s\n" "$ac_cv_header_stat_broken" >&6; } @@ -18041,8 +19052,8 @@ printf %s "checking whether #! works in shell scripts... " >&6; } if test ${ac_cv_sys_interpreter+y} then : printf %s "(cached) " >&6 -else $as_nop - echo '#! /bin/cat +else case e in #( + e) echo '#! /bin/cat exit 69 ' >conftest chmod u+x conftest @@ -18052,7 +19063,8 @@ if test $? -ne 69; then else ac_cv_sys_interpreter=no fi -rm -f conftest +rm -f conftest ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_interpreter" >&5 printf "%s\n" "$ac_cv_sys_interpreter" >&6; } @@ -18069,8 +19081,8 @@ printf %s "checking for lstat... " >&6; } if test ${bash_cv_func_lstat+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -18087,11 +19099,13 @@ _ACEOF if ac_fn_c_try_link "$LINENO" then : bash_cv_func_lstat=yes -else $as_nop - bash_cv_func_lstat=no +else case e in #( + e) bash_cv_func_lstat=no ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext + conftest$ac_exeext conftest.$ac_ext ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_func_lstat" >&5 printf "%s\n" "$bash_cv_func_lstat" >&6; } @@ -18102,25 +19116,84 @@ fi fi + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether strchrnul works" >&5 +printf %s "checking whether strchrnul works... " >&6; } +if test ${bash_cv_func_strchrnul_works+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) if test "$cross_compiling" = yes +then : + bash_cv_func_strchrnul_works=no + +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include + +int +main (void) +{ +const char *buf = "abc"; + return strchrnul (buf, 'd') != buf + 3; + + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO" +then : + bash_cv_func_strchrnul_works=yes +else case e in #( + e) bash_cv_func_strchrnul_works=no ;; +esac +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac +fi + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_func_strchrnul_works" >&5 +printf "%s\n" "$bash_cv_func_strchrnul_works" >&6; } + +if test "$bash_cv_func_strchrnul_works" = "no"; then +case " $LIBOBJS " in + *" strchrnul.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS strchrnul.$ac_objext" + ;; +esac + +fi + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if dup2 fails to clear the close-on-exec flag" >&5 printf %s "checking if dup2 fails to clear the close-on-exec flag... " >&6; } if test ${bash_cv_dup2_broken+y} then : printf %s "(cached) " >&6 -else $as_nop - if test "$cross_compiling" = yes +else case e in #( + e) if test "$cross_compiling" = yes then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cannot check dup2 if cross compiling -- defaulting to no" >&5 printf "%s\n" "$as_me: WARNING: cannot check dup2 if cross compiling -- defaulting to no" >&2;} bash_cv_dup2_broken=no -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include +#ifdef HAVE_UNISTD_H +# include +#endif /* HAVE_UNISTD_H */ int main() { @@ -18140,13 +19213,16 @@ _ACEOF if ac_fn_c_try_run "$LINENO" then : bash_cv_dup2_broken=yes -else $as_nop - bash_cv_dup2_broken=no +else case e in #( + e) bash_cv_dup2_broken=no ;; +esac fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_dup2_broken" >&5 @@ -18162,15 +19238,15 @@ printf %s "checking whether pgrps need synchronization... " >&6; } if test ${bash_cv_pgrp_pipe+y} then : printf %s "(cached) " >&6 -else $as_nop - if test "$cross_compiling" = yes +else case e in #( + e) if test "$cross_compiling" = yes then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cannot check pgrp synchronization if cross compiling -- defaulting to no" >&5 printf "%s\n" "$as_me: WARNING: cannot check pgrp synchronization if cross compiling -- defaulting to no" >&2;} bash_cv_pgrp_pipe=no -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_UNISTD_H @@ -18230,13 +19306,16 @@ _ACEOF if ac_fn_c_try_run "$LINENO" then : bash_cv_pgrp_pipe=no -else $as_nop - bash_cv_pgrp_pipe=yes +else case e in #( + e) bash_cv_pgrp_pipe=yes ;; +esac fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_pgrp_pipe" >&5 @@ -18251,13 +19330,13 @@ printf %s "checking for type of signal functions... " >&6; } if test ${bash_cv_signal_vintage+y} then : printf %s "(cached) " >&6 -else $as_nop - +else case e in #( + e) if test ${bash_cv_posix_signals+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -18279,12 +19358,14 @@ _ACEOF if ac_fn_c_try_link "$LINENO" then : bash_cv_posix_signals=yes -else $as_nop - bash_cv_posix_signals=no - +else case e in #( + e) bash_cv_posix_signals=no + ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext + conftest$ac_exeext conftest.$ac_ext ;; +esac fi @@ -18294,8 +19375,8 @@ else if test ${bash_cv_bsd_signals+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -18314,12 +19395,14 @@ _ACEOF if ac_fn_c_try_link "$LINENO" then : bash_cv_bsd_signals=yes -else $as_nop - bash_cv_bsd_signals=no - +else case e in #( + e) bash_cv_bsd_signals=no + ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext + conftest$ac_exeext conftest.$ac_ext ;; +esac fi @@ -18329,8 +19412,8 @@ fi if test ${bash_cv_sysv_signals+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -18351,12 +19434,14 @@ _ACEOF if ac_fn_c_try_link "$LINENO" then : bash_cv_sysv_signals=yes -else $as_nop - bash_cv_sysv_signals=no - +else case e in #( + e) bash_cv_sysv_signals=no + ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext + conftest$ac_exeext conftest.$ac_ext ;; +esac fi @@ -18367,7 +19452,8 @@ fi fi fi fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_signal_vintage" >&5 @@ -18389,8 +19475,8 @@ printf %s "checking for sys_errlist and sys_nerr... " >&6; } if test ${bash_cv_sys_errlist+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -18410,12 +19496,14 @@ _ACEOF if ac_fn_c_try_link "$LINENO" then : bash_cv_sys_errlist=yes -else $as_nop - bash_cv_sys_errlist=no - +else case e in #( + e) bash_cv_sys_errlist=no + ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext + conftest$ac_exeext conftest.$ac_ext ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_sys_errlist" >&5 @@ -18435,8 +19523,9 @@ ac_fn_check_decl "$LINENO" "sys_siglist" "ac_cv_have_decl_sys_siglist" "#include if test "x$ac_cv_have_decl_sys_siglist" = xyes then : ac_have_decl=1 -else $as_nop - ac_have_decl=0 +else case e in #( + e) ac_have_decl=0 ;; +esac fi printf "%s\n" "#define HAVE_DECL_SYS_SIGLIST $ac_have_decl" >>confdefs.h @@ -18447,15 +19536,15 @@ printf %s "checking for sys_siglist in system C library... " >&6; } if test ${bash_cv_sys_siglist+y} then : printf %s "(cached) " >&6 -else $as_nop - if test "$cross_compiling" = yes +else case e in #( + e) if test "$cross_compiling" = yes then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cannot check for sys_siglist if cross compiling -- defaulting to no" >&5 printf "%s\n" "$as_me: WARNING: cannot check for sys_siglist if cross compiling -- defaulting to no" >&2;} bash_cv_sys_siglist=no -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -18478,13 +19567,16 @@ _ACEOF if ac_fn_c_try_run "$LINENO" then : bash_cv_sys_siglist=yes -else $as_nop - bash_cv_sys_siglist=no +else case e in #( + e) bash_cv_sys_siglist=no ;; +esac fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_sys_siglist" >&5 @@ -18499,8 +19591,8 @@ printf %s "checking for _sys_siglist in signal.h or unistd.h... " >&6; } if test ${bash_cv_decl_under_sys_siglist+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -18519,10 +19611,12 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : bash_cv_decl_under_sys_siglist=yes -else $as_nop - bash_cv_decl_under_sys_siglist=no +else case e in #( + e) bash_cv_decl_under_sys_siglist=no ;; +esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_decl_under_sys_siglist" >&5 printf "%s\n" "$bash_cv_decl_under_sys_siglist" >&6; } @@ -18537,15 +19631,15 @@ printf %s "checking for _sys_siglist in system C library... " >&6; } if test ${bash_cv_under_sys_siglist+y} then : printf %s "(cached) " >&6 -else $as_nop - if test "$cross_compiling" = yes +else case e in #( + e) if test "$cross_compiling" = yes then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cannot check for _sys_siglist if cross compiling -- defaulting to no" >&5 printf "%s\n" "$as_me: WARNING: cannot check for _sys_siglist if cross compiling -- defaulting to no" >&2;} bash_cv_under_sys_siglist=no -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -18568,13 +19662,16 @@ _ACEOF if ac_fn_c_try_run "$LINENO" then : bash_cv_under_sys_siglist=yes -else $as_nop - bash_cv_under_sys_siglist=no +else case e in #( + e) bash_cv_under_sys_siglist=no ;; +esac fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_under_sys_siglist" >&5 @@ -18592,8 +19689,8 @@ printf %s "checking for clock_t... " >&6; } if test ${bash_cv_type_clock_t+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #if HAVE_STDLIB_H @@ -18612,14 +19709,16 @@ else $as_nop _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "clock_t" >/dev/null 2>&1 + $EGREP_TRADITIONAL "clock_t" >/dev/null 2>&1 then : bash_cv_type_clock_t=yes -else $as_nop - bash_cv_type_clock_t=no +else case e in #( + e) bash_cv_type_clock_t=no ;; +esac fi rm -rf conftest* - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_type_clock_t" >&5 @@ -18637,8 +19736,8 @@ printf %s "checking for sigset_t... " >&6; } if test ${bash_cv_type_sigset_t+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #if HAVE_STDLIB_H @@ -18657,14 +19756,16 @@ else $as_nop _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "sigset_t" >/dev/null 2>&1 + $EGREP_TRADITIONAL "sigset_t" >/dev/null 2>&1 then : bash_cv_type_sigset_t=yes -else $as_nop - bash_cv_type_sigset_t=no +else case e in #( + e) bash_cv_type_sigset_t=no ;; +esac fi rm -rf conftest* - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_type_sigset_t" >&5 @@ -18683,8 +19784,8 @@ printf %s "checking for socklen_t... " >&6; } if test ${bash_cv_type_socklen_t+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #if HAVE_STDLIB_H @@ -18703,14 +19804,16 @@ else $as_nop _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "socklen_t" >/dev/null 2>&1 + $EGREP_TRADITIONAL "socklen_t" >/dev/null 2>&1 then : bash_cv_type_socklen_t=yes -else $as_nop - bash_cv_type_socklen_t=no +else case e in #( + e) bash_cv_type_socklen_t=no ;; +esac fi rm -rf conftest* - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_type_socklen_t" >&5 @@ -18738,8 +19841,8 @@ printf %s "checking for type of struct rlimit fields... " >&6; } if test ${bash_cv_type_rlimit+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -18756,22 +19859,22 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : bash_cv_type_rlimit=rlim_t -else $as_nop - +else case e in #( + e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for size of struct rlimit fields" >&5 printf %s "checking for size of struct rlimit fields... " >&6; } if test ${bash_cv_sizeof_rlim_cur+y} then : printf %s "(cached) " >&6 -else $as_nop - if test "$cross_compiling" = yes +else case e in #( + e) if test "$cross_compiling" = yes then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cannot check size of rlimit fields if cross compiling -- defaulting to long" >&5 printf "%s\n" "$as_me: WARNING: cannot check size of rlimit fields if cross compiling -- defaulting to long" >&2;} bash_cv_sizeof_rlim_cur=$ac_cv_sizeof_long -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_SYS_TIME_H @@ -18779,6 +19882,7 @@ else $as_nop #endif #include #include +int main() { struct rlimit r; @@ -18789,13 +19893,16 @@ _ACEOF if ac_fn_c_try_run "$LINENO" then : bash_cv_sizeof_rlim_cur=$? -else $as_nop - bash_cv_sizeof_rlim_cur=$? +else case e in #( + e) bash_cv_sizeof_rlim_cur=$? ;; +esac fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_sizeof_rlim_cur" >&5 @@ -18806,15 +19913,15 @@ printf %s "checking for size of quad_t... " >&6; } if test ${bash_cv_sizeof_quad_t+y} then : printf %s "(cached) " >&6 -else $as_nop - if test "$cross_compiling" = yes +else case e in #( + e) if test "$cross_compiling" = yes then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cannot check size of quad_t if cross compiling -- defaulting to 0" >&5 printf "%s\n" "$as_me: WARNING: cannot check size of quad_t if cross compiling -- defaulting to 0" >&2;} bash_cv_sizeof_quad_t=0 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -18826,6 +19933,7 @@ else $as_nop #include #endif +int main() { #if HAVE_QUAD_T @@ -18840,13 +19948,16 @@ _ACEOF if ac_fn_c_try_run "$LINENO" then : bash_cv_sizeof_quad_t=$? -else $as_nop - bash_cv_sizeof_quad_t=$? +else case e in #( + e) bash_cv_sizeof_quad_t=$? ;; +esac fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_sizeof_quad_t" >&5 @@ -18864,9 +19975,11 @@ else bash_cv_type_rlimit='unsigned long' fi - + ;; +esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_type_rlimit" >&5 @@ -18883,13 +19996,14 @@ then : printf "%s\n" "#define HAVE_INTMAX_T 1" >>confdefs.h -else $as_nop - test $ac_cv_type_long_long_int = yes \ +else case e in #( + e) test $ac_cv_type_long_long_int = yes \ && ac_type='long long int' \ || ac_type='long int' printf "%s\n" "#define intmax_t $ac_type" >>confdefs.h - + ;; +esac fi @@ -18901,41 +20015,44 @@ then : printf "%s\n" "#define HAVE_UINTMAX_T 1" >>confdefs.h -else $as_nop - test $ac_cv_type_unsigned_long_long_int = yes \ +else case e in #( + e) test $ac_cv_type_unsigned_long_long_int = yes \ && ac_type='unsigned long long int' \ || ac_type='unsigned long int' printf "%s\n" "#define uintmax_t $ac_type" >>confdefs.h - + ;; +esac fi # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects -# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# declarations like 'int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking size of intmax_t" >&5 printf %s "checking size of intmax_t... " >&6; } if test ${ac_cv_sizeof_intmax_t+y} then : printf %s "(cached) " >&6 -else $as_nop - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (intmax_t))" "ac_cv_sizeof_intmax_t" "$ac_includes_default" +else case e in #( + e) if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (intmax_t))" "ac_cv_sizeof_intmax_t" "$ac_includes_default" then : -else $as_nop - if test "$ac_cv_type_intmax_t" = yes; then - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +else case e in #( + e) if test "$ac_cv_type_intmax_t" = yes; then + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (intmax_t) -See \`config.log' for more details" "$LINENO" 5; } +See 'config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_intmax_t=0 - fi + fi ;; +esac fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_intmax_t" >&5 printf "%s\n" "$ac_cv_sizeof_intmax_t" >&6; } @@ -18973,13 +20090,6 @@ fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for struct dirent.d_ino" >&5 -printf %s "checking for struct dirent.d_ino... " >&6; } -if test ${bash_cv_dirent_has_d_ino+y} -then : - printf %s "(cached) " >&6 -else $as_nop - ac_fn_c_check_member "$LINENO" "struct dirent" "d_ino" "ac_cv_member_struct_dirent_d_ino" " #include @@ -19008,28 +20118,10 @@ then : printf "%s\n" "#define HAVE_STRUCT_DIRENT_D_INO 1" >>confdefs.h -bash_cv_dirent_has_d_ino=yes -else $as_nop - bash_cv_dirent_has_d_ino=no -fi - - -fi - -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_dirent_has_d_ino" >&5 -printf "%s\n" "$bash_cv_dirent_has_d_ino" >&6; } -if test $bash_cv_dirent_has_d_ino = yes; then -printf "%s\n" "#define HAVE_STRUCT_DIRENT_D_INO 1" >>confdefs.h fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for struct dirent.d_fileno" >&5 -printf %s "checking for struct dirent.d_fileno... " >&6; } -if test ${bash_cv_dirent_has_d_fileno+y} -then : - printf %s "(cached) " >&6 -else $as_nop ac_fn_c_check_member "$LINENO" "struct dirent" "d_fileno" "ac_cv_member_struct_dirent_d_fileno" " @@ -19059,28 +20151,10 @@ then : printf "%s\n" "#define HAVE_STRUCT_DIRENT_D_FILENO 1" >>confdefs.h -bash_cv_dirent_has_d_fileno=yes -else $as_nop - bash_cv_dirent_has_d_fileno=no -fi - - -fi - -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_dirent_has_d_fileno" >&5 -printf "%s\n" "$bash_cv_dirent_has_d_fileno" >&6; } -if test $bash_cv_dirent_has_d_fileno = yes; then -printf "%s\n" "#define HAVE_STRUCT_DIRENT_D_FILENO 1" >>confdefs.h fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for struct dirent.d_namlen" >&5 -printf %s "checking for struct dirent.d_namlen... " >&6; } -if test ${bash_cv_dirent_has_d_namlen+y} -then : - printf %s "(cached) " >&6 -else $as_nop ac_fn_c_check_member "$LINENO" "struct dirent" "d_namlen" "ac_cv_member_struct_dirent_d_namlen" " @@ -19110,33 +20184,64 @@ then : printf "%s\n" "#define HAVE_STRUCT_DIRENT_D_NAMLEN 1" >>confdefs.h -bash_cv_dirent_has_d_namlen=yes -else $as_nop - bash_cv_dirent_has_d_namlen=no + fi -fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for d_type member in directory struct" >&5 +printf %s "checking for d_type member in directory struct... " >&6; } +if test ${gl_cv_struct_dirent_d_type+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_dirent_has_d_namlen" >&5 -printf "%s\n" "$bash_cv_dirent_has_d_namlen" >&6; } -if test $bash_cv_dirent_has_d_namlen = yes; then -printf "%s\n" "#define HAVE_STRUCT_DIRENT_D_NAMLEN 1" >>confdefs.h +#include +#include + +int +main (void) +{ +struct dirent dp; dp.d_type = 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + gl_cv_struct_dirent_d_type=yes +else case e in #( + e) gl_cv_struct_dirent_d_type=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + ;; +esac fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gl_cv_struct_dirent_d_type" >&5 +printf "%s\n" "$gl_cv_struct_dirent_d_type" >&6; } + if test $gl_cv_struct_dirent_d_type = yes; then + +printf "%s\n" "#define HAVE_STRUCT_DIRENT_D_TYPE 1" >>confdefs.h + + fi + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for struct winsize in sys/ioctl.h and termios.h" >&5 printf %s "checking for struct winsize in sys/ioctl.h and termios.h... " >&6; } if test ${bash_cv_struct_winsize_header+y} then : printf %s "(cached) " >&6 -else $as_nop - +else case e in #( + e) if test ${bash_cv_struct_winsize_ioctl+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -19156,19 +20261,21 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : bash_cv_struct_winsize_ioctl=yes -else $as_nop - bash_cv_struct_winsize_ioctl=no +else case e in #( + e) bash_cv_struct_winsize_ioctl=no ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - + ;; +esac fi if test ${bash_cv_struct_winsize_termios+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -19188,11 +20295,13 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : bash_cv_struct_winsize_termios=yes -else $as_nop - bash_cv_struct_winsize_termios=no +else case e in #( + e) bash_cv_struct_winsize_termios=no ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - + ;; +esac fi @@ -19204,7 +20313,8 @@ elif test $bash_cv_struct_winsize_termios = yes; then else bash_cv_struct_winsize_header=other fi - + ;; +esac fi if test $bash_cv_struct_winsize_header = ioctl_h; then @@ -19227,8 +20337,8 @@ printf %s "checking for struct timeval in sys/time.h and time.h... " >&6; } if test ${bash_cv_struct_timeval+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if HAVE_SYS_TIME_H #include @@ -19247,11 +20357,13 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : bash_cv_struct_timeval=yes -else $as_nop - bash_cv_struct_timeval=no +else case e in #( + e) bash_cv_struct_timeval=no ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_struct_timeval" >&5 @@ -19275,8 +20387,8 @@ printf %s "checking whether struct tm is in sys/time.h or time.h... " >&6; } if test ${ac_cv_struct_tm+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include @@ -19294,10 +20406,12 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_cv_struct_tm=time.h -else $as_nop - ac_cv_struct_tm=sys/time.h +else case e in #( + e) ac_cv_struct_tm=sys/time.h ;; +esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_struct_tm" >&5 printf "%s\n" "$ac_cv_struct_tm" >&6; } @@ -19329,8 +20443,9 @@ else if test "x$ac_cv_have_decl_tzname" = xyes then : ac_have_decl=1 -else $as_nop - ac_have_decl=0 +else case e in #( + e) ac_have_decl=0 ;; +esac fi printf "%s\n" "#define HAVE_DECL_TZNAME $ac_have_decl" >>confdefs.h @@ -19339,8 +20454,8 @@ printf %s "checking for tzname... " >&6; } if test ${ac_cv_var_tzname+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #if !HAVE_DECL_TZNAME @@ -19358,11 +20473,13 @@ _ACEOF if ac_fn_c_try_link "$LINENO" then : ac_cv_var_tzname=yes -else $as_nop - ac_cv_var_tzname=no +else case e in #( + e) ac_cv_var_tzname=no ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext + conftest$ac_exeext conftest.$ac_ext ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_var_tzname" >&5 printf "%s\n" "$ac_cv_var_tzname" >&6; } @@ -19378,36 +20495,39 @@ printf %s "checking for struct timezone in sys/time.h and time.h... " >&6; } if test ${bash_cv_struct_timezone+y} then : printf %s "(cached) " >&6 -else $as_nop - +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "struct timezone" >/dev/null 2>&1 + $EGREP_TRADITIONAL "struct timezone" >/dev/null 2>&1 then : bash_cv_struct_timezone=yes -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "struct timezone" >/dev/null 2>&1 + $EGREP_TRADITIONAL "struct timezone" >/dev/null 2>&1 then : bash_cv_struct_timezone=yes -else $as_nop - bash_cv_struct_timezone=no +else case e in #( + e) bash_cv_struct_timezone=no ;; +esac fi rm -rf conftest* - + ;; +esac fi rm -rf conftest* - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_struct_timezone" >&5 @@ -19423,15 +20543,15 @@ printf %s "checking for offset of exit status in return status from wait... " >& if test ${bash_cv_wexitstatus_offset+y} then : printf %s "(cached) " >&6 -else $as_nop - if test "$cross_compiling" = yes +else case e in #( + e) if test "$cross_compiling" = yes then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cannot check WEXITSTATUS offset if cross compiling -- defaulting to 0" >&5 printf "%s\n" "$as_me: WARNING: cannot check WEXITSTATUS offset if cross compiling -- defaulting to 0" >&2;} bash_cv_wexitstatus_offset=0 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -19440,9 +20560,7 @@ else $as_nop #include int -main(c, v) - int c; - char **v; +main(int c, char **v) { pid_t pid, p; int s, i, n; @@ -19472,13 +20590,16 @@ _ACEOF if ac_fn_c_try_run "$LINENO" then : bash_cv_wexitstatus_offset=0 -else $as_nop - bash_cv_wexitstatus_offset=$? +else case e in #( + e) bash_cv_wexitstatus_offset=$? ;; +esac fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi - + ;; +esac fi if test "$bash_cv_wexitstatus_offset" -gt 32 ; then @@ -19500,8 +20621,8 @@ printf %s "checking for struct timespec in ... " >&6; } if test ${bash_cv_sys_struct_timespec_in_time_h+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -19516,10 +20637,12 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : bash_cv_sys_struct_timespec_in_time_h=yes -else $as_nop - bash_cv_sys_struct_timespec_in_time_h=no +else case e in #( + e) bash_cv_sys_struct_timespec_in_time_h=no ;; +esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_sys_struct_timespec_in_time_h" >&5 printf "%s\n" "$bash_cv_sys_struct_timespec_in_time_h" >&6; } @@ -19540,8 +20663,8 @@ printf %s "checking for struct timespec in ... " >&6; } if test ${bash_cv_sys_struct_timespec_in_sys_time_h+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -19556,10 +20679,12 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : bash_cv_sys_struct_timespec_in_sys_time_h=yes -else $as_nop - bash_cv_sys_struct_timespec_in_sys_time_h=no +else case e in #( + e) bash_cv_sys_struct_timespec_in_sys_time_h=no ;; +esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_sys_struct_timespec_in_sys_time_h" >&5 printf "%s\n" "$bash_cv_sys_struct_timespec_in_sys_time_h" >&6; } @@ -19575,8 +20700,8 @@ printf %s "checking for struct timespec in ... " >&6; } if test ${bash_cv_sys_struct_timespec_in_pthread_h+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -19591,10 +20716,12 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : bash_cv_sys_struct_timespec_in_pthread_h=yes -else $as_nop - bash_cv_sys_struct_timespec_in_pthread_h=no +else case e in #( + e) bash_cv_sys_struct_timespec_in_pthread_h=no ;; +esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_sys_struct_timespec_in_pthread_h" >&5 printf "%s\n" "$bash_cv_sys_struct_timespec_in_pthread_h" >&6; } @@ -19629,8 +20756,8 @@ printf %s "checking whether struct stat.st_atim is of type struct timespec... " if test ${ac_cv_typeof_struct_stat_st_atim_is_struct_timespec+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -19655,10 +20782,12 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_cv_typeof_struct_stat_st_atim_is_struct_timespec=yes -else $as_nop - ac_cv_typeof_struct_stat_st_atim_is_struct_timespec=no +else case e in #( + e) ac_cv_typeof_struct_stat_st_atim_is_struct_timespec=no ;; +esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_typeof_struct_stat_st_atim_is_struct_timespec" >&5 printf "%s\n" "$ac_cv_typeof_struct_stat_st_atim_is_struct_timespec" >&6; } @@ -19667,8 +20796,8 @@ printf "%s\n" "$ac_cv_typeof_struct_stat_st_atim_is_struct_timespec" >&6; } printf "%s\n" "#define TYPEOF_STRUCT_STAT_ST_ATIM_IS_STRUCT_TIMESPEC 1" >>confdefs.h fi -else $as_nop - ac_fn_c_check_member "$LINENO" "struct stat" "st_atimespec.tv_nsec" "ac_cv_member_struct_stat_st_atimespec_tv_nsec" "#include +else case e in #( + e) ac_fn_c_check_member "$LINENO" "struct stat" "st_atimespec.tv_nsec" "ac_cv_member_struct_stat_st_atimespec_tv_nsec" "#include #include " if test "x$ac_cv_member_struct_stat_st_atimespec_tv_nsec" = xyes @@ -19677,8 +20806,8 @@ then : printf "%s\n" "#define HAVE_STRUCT_STAT_ST_ATIMESPEC_TV_NSEC 1" >>confdefs.h -else $as_nop - ac_fn_c_check_member "$LINENO" "struct stat" "st_atimensec" "ac_cv_member_struct_stat_st_atimensec" "#include +else case e in #( + e) ac_fn_c_check_member "$LINENO" "struct stat" "st_atimensec" "ac_cv_member_struct_stat_st_atimensec" "#include #include " if test "x$ac_cv_member_struct_stat_st_atimensec" = xyes @@ -19687,8 +20816,8 @@ then : printf "%s\n" "#define HAVE_STRUCT_STAT_ST_ATIMENSEC 1" >>confdefs.h -else $as_nop - ac_fn_c_check_member "$LINENO" "struct stat" "st_atim.st__tim.tv_nsec" "ac_cv_member_struct_stat_st_atim_st__tim_tv_nsec" "#include +else case e in #( + e) ac_fn_c_check_member "$LINENO" "struct stat" "st_atim.st__tim.tv_nsec" "ac_cv_member_struct_stat_st_atim_st__tim_tv_nsec" "#include #include " if test "x$ac_cv_member_struct_stat_st_atim_st__tim_tv_nsec" = xyes @@ -19698,11 +20827,14 @@ printf "%s\n" "#define HAVE_STRUCT_STAT_ST_ATIM_ST__TIM_TV_NSEC 1" >>confdefs.h fi - + ;; +esac fi - + ;; +esac fi - + ;; +esac fi @@ -19713,8 +20845,8 @@ printf %s "checking for sbrk... " >&6; } if test ${ac_cv_func_sbrk+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int @@ -19728,11 +20860,13 @@ _ACEOF if ac_fn_c_try_link "$LINENO" then : ac_cv_func_sbrk=yes -else $as_nop - ac_cv_func_sbrk=no +else case e in #( + e) ac_cv_func_sbrk=no ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext + conftest$ac_exeext conftest.$ac_ext ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_sbrk" >&5 @@ -19743,15 +20877,15 @@ printf %s "checking for working sbrk... " >&6; } if test ${bash_cv_func_sbrk+y} then : printf %s "(cached) " >&6 -else $as_nop - if test "$cross_compiling" = yes +else case e in #( + e) if test "$cross_compiling" = yes then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cannot check working sbrk if cross-compiling" >&5 printf "%s\n" "$as_me: WARNING: cannot check working sbrk if cross-compiling" >&2;} bash_cv_func_sbrk=yes -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -19770,13 +20904,16 @@ _ACEOF if ac_fn_c_try_run "$LINENO" then : bash_cv_func_sbrk=yes -else $as_nop - bash_cv_func_sbrk=no +else case e in #( + e) bash_cv_func_sbrk=no ;; +esac fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_func_sbrk" >&5 printf "%s\n" "$bash_cv_func_sbrk" >&6; } @@ -19791,13 +20928,101 @@ printf "%s\n" "#define HAVE_SBRK 1" >>confdefs.h fi + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for brk" >&5 +printf %s "checking for brk... " >&6; } + if test ${ac_cv_func_brk+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main (void) +{ + void *x = brk (0); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_func_brk=yes +else case e in #( + e) ac_cv_func_brk=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext ;; +esac +fi + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_brk" >&5 +printf "%s\n" "$ac_cv_func_brk" >&6; } + if test X$ac_cv_func_brk = Xyes; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for working brk" >&5 +printf %s "checking for working brk... " >&6; } +if test ${bash_cv_func_brk+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) if test "$cross_compiling" = yes +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cannot check working brk if cross-compiling" >&5 +printf "%s\n" "$as_me: WARNING: cannot check working brk if cross-compiling" >&2;} + bash_cv_func_brk=yes + +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include + +int +main(int c, char **v) +{ + void *x; + + x = brk (0); + exit ((x == (void *)-1) ? 1 : 0); +} + +_ACEOF +if ac_fn_c_try_run "$LINENO" +then : + bash_cv_func_brk=yes +else case e in #( + e) bash_cv_func_brk=no ;; +esac +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac +fi + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_func_brk" >&5 +printf "%s\n" "$bash_cv_func_brk" >&6; } + if test $bash_cv_func_brk = no; then + ac_cv_func_brk=no + fi + fi + if test $ac_cv_func_brk = yes; then + +printf "%s\n" "#define HAVE_BRK 1" >>confdefs.h + + fi + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for the existence of strsignal" >&5 printf %s "checking for the existence of strsignal... " >&6; } if test ${bash_cv_have_strsignal+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include @@ -19813,11 +21038,13 @@ _ACEOF if ac_fn_c_try_link "$LINENO" then : bash_cv_have_strsignal=yes -else $as_nop - bash_cv_have_strsignal=no +else case e in #( + e) bash_cv_have_strsignal=no ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext + conftest$ac_exeext conftest.$ac_ext ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_have_strsignal" >&5 @@ -19832,15 +21059,15 @@ printf %s "checking if opendir() opens non-directories... " >&6; } if test ${bash_cv_opendir_not_robust+y} then : printf %s "(cached) " >&6 -else $as_nop - if test "$cross_compiling" = yes +else case e in #( + e) if test "$cross_compiling" = yes then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cannot check opendir if cross compiling -- defaulting to no" >&5 printf "%s\n" "$as_me: WARNING: cannot check opendir if cross compiling -- defaulting to no" >&2;} bash_cv_opendir_not_robust=no -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -19891,13 +21118,16 @@ _ACEOF if ac_fn_c_try_run "$LINENO" then : bash_cv_opendir_not_robust=yes -else $as_nop - bash_cv_opendir_not_robust=no +else case e in #( + e) bash_cv_opendir_not_robust=no ;; +esac fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_opendir_not_robust" >&5 @@ -19912,15 +21142,15 @@ printf %s "checking whether ulimit can substitute for getdtablesize... " >&6; } if test ${bash_cv_ulimit_maxfds+y} then : printf %s "(cached) " >&6 -else $as_nop - if test "$cross_compiling" = yes +else case e in #( + e) if test "$cross_compiling" = yes then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cannot check ulimit if cross compiling -- defaulting to no" >&5 printf "%s\n" "$as_me: WARNING: cannot check ulimit if cross compiling -- defaulting to no" >&2;} bash_cv_ulimit_maxfds=no -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -19938,13 +21168,16 @@ _ACEOF if ac_fn_c_try_run "$LINENO" then : bash_cv_ulimit_maxfds=yes -else $as_nop - bash_cv_ulimit_maxfds=no +else case e in #( + e) bash_cv_ulimit_maxfds=no ;; +esac fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_ulimit_maxfds" >&5 @@ -19964,8 +21197,9 @@ fi if test "x$ac_cv_have_decl_fpurge" = xyes then : ac_have_decl=1 -else $as_nop - ac_have_decl=0 +else case e in #( + e) ac_have_decl=0 ;; +esac fi printf "%s\n" "#define HAVE_DECL_FPURGE $ac_have_decl" >>confdefs.h @@ -19975,33 +21209,23 @@ printf %s "checking to see if getenv can be redefined... " >&6; } if test ${bash_cv_getenv_redef+y} then : printf %s "(cached) " >&6 -else $as_nop - if test "$cross_compiling" = yes +else case e in #( + e) if test "$cross_compiling" = yes then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cannot check getenv redefinition if cross compiling -- defaulting to yes" >&5 printf "%s\n" "$as_me: WARNING: cannot check getenv redefinition if cross compiling -- defaulting to yes" >&2;} bash_cv_getenv_redef=yes -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_UNISTD_H # include #endif #include -#ifndef __STDC__ -# ifndef const -# define const -# endif -#endif char * -getenv (name) -#if defined (__linux__) || defined (__bsdi__) || defined (convex) - const char *name; -#else - char const *name; -#endif /* !__linux__ && !__bsdi__ && !convex */ +getenv (const char *name) { return "42"; } @@ -20023,13 +21247,16 @@ _ACEOF if ac_fn_c_try_run "$LINENO" then : bash_cv_getenv_redef=yes -else $as_nop - bash_cv_getenv_redef=no +else case e in #( + e) bash_cv_getenv_redef=no ;; +esac fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_getenv_redef" >&5 @@ -20045,15 +21272,15 @@ printf %s "checking if getcwd() will dynamically allocate memory with 0 size... if test ${bash_cv_getcwd_malloc+y} then : printf %s "(cached) " >&6 -else $as_nop - if test "$cross_compiling" = yes +else case e in #( + e) if test "$cross_compiling" = yes then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cannot check whether getcwd allocates memory when cross-compiling -- defaulting to no" >&5 printf "%s\n" "$as_me: WARNING: cannot check whether getcwd allocates memory when cross-compiling -- defaulting to no" >&2;} bash_cv_getcwd_malloc=no -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -20074,13 +21301,16 @@ _ACEOF if ac_fn_c_try_run "$LINENO" then : bash_cv_getcwd_malloc=yes -else $as_nop - bash_cv_getcwd_malloc=no +else case e in #( + e) bash_cv_getcwd_malloc=no ;; +esac fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_getcwd_malloc" >&5 @@ -20097,14 +21327,16 @@ esac fi fi +printf "%s\n" "#define HAVE_GETCWD 1" >>confdefs.h + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for presence of POSIX-style sigsetjmp/siglongjmp" >&5 printf %s "checking for presence of POSIX-style sigsetjmp/siglongjmp... " >&6; } if test ${bash_cv_func_sigsetjmp+y} then : printf %s "(cached) " >&6 -else $as_nop - if test "$cross_compiling" = yes +else case e in #( + e) if test "$cross_compiling" = yes then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cannot check for sigsetjmp/siglongjmp if cross-compiling -- defaulting to $bash_cv_posix_signals" >&5 printf "%s\n" "$as_me: WARNING: cannot check for sigsetjmp/siglongjmp if cross-compiling -- defaulting to $bash_cv_posix_signals" >&2;} @@ -20114,8 +21346,8 @@ printf "%s\n" "$as_me: WARNING: cannot check for sigsetjmp/siglongjmp if cross-c bash_cv_func_sigsetjmp=missing fi -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_UNISTD_H @@ -20171,13 +21403,16 @@ _ACEOF if ac_fn_c_try_run "$LINENO" then : bash_cv_func_sigsetjmp=present -else $as_nop - bash_cv_func_sigsetjmp=missing +else case e in #( + e) bash_cv_func_sigsetjmp=missing ;; +esac fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_func_sigsetjmp" >&5 @@ -20192,15 +21427,15 @@ printf %s "checking whether or not strcoll and strcmp differ... " >&6; } if test ${bash_cv_func_strcoll_broken+y} then : printf %s "(cached) " >&6 -else $as_nop - if test "$cross_compiling" = yes +else case e in #( + e) if test "$cross_compiling" = yes then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cannot check strcoll if cross compiling -- defaulting to no" >&5 printf "%s\n" "$as_me: WARNING: cannot check strcoll if cross compiling -- defaulting to no" >&2;} bash_cv_func_strcoll_broken=no -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -20211,9 +21446,7 @@ else $as_nop #include int -main(c, v) -int c; -char *v[]; +main(int c, char **v) { int r1, r2; char *deflocale, *defcoll; @@ -20245,13 +21478,16 @@ _ACEOF if ac_fn_c_try_run "$LINENO" then : bash_cv_func_strcoll_broken=yes -else $as_nop - bash_cv_func_strcoll_broken=no +else case e in #( + e) bash_cv_func_strcoll_broken=no ;; +esac fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_func_strcoll_broken" >&5 @@ -20270,15 +21506,15 @@ printf %s "checking for standard-conformant snprintf... " >&6; } if test ${bash_cv_func_snprintf+y} then : printf %s "(cached) " >&6 -else $as_nop - if test "$cross_compiling" = yes +else case e in #( + e) if test "$cross_compiling" = yes then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cannot check standard snprintf if cross-compiling" >&5 printf "%s\n" "$as_me: WARNING: cannot check standard snprintf if cross-compiling" >&2;} bash_cv_func_snprintf=yes -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -20296,13 +21532,16 @@ _ACEOF if ac_fn_c_try_run "$LINENO" then : bash_cv_func_snprintf=yes -else $as_nop - bash_cv_func_snprintf=no +else case e in #( + e) bash_cv_func_snprintf=no ;; +esac fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_func_snprintf" >&5 printf "%s\n" "$bash_cv_func_snprintf" >&6; } @@ -20325,42 +21564,28 @@ printf %s "checking for standard-conformant vsnprintf... " >&6; } if test ${bash_cv_func_vsnprintf+y} then : printf %s "(cached) " >&6 -else $as_nop - if test "$cross_compiling" = yes +else case e in #( + e) if test "$cross_compiling" = yes then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cannot check standard vsnprintf if cross-compiling" >&5 printf "%s\n" "$as_me: WARNING: cannot check standard vsnprintf if cross-compiling" >&2;} bash_cv_func_vsnprintf=yes -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#if HAVE_STDARG_H #include -#else -#include -#endif #include #include static int -#if HAVE_STDARG_H foo(const char *fmt, ...) -#else -foo(format, va_alist) - const char *format; - va_dcl -#endif { va_list args; int n; -#if HAVE_STDARG_H va_start(args, fmt); -#else - va_start(args); -#endif n = vsnprintf(0, 0, fmt, args); va_end (args); return n; @@ -20378,13 +21603,16 @@ _ACEOF if ac_fn_c_try_run "$LINENO" then : bash_cv_func_vsnprintf=yes -else $as_nop - bash_cv_func_vsnprintf=no +else case e in #( + e) bash_cv_func_vsnprintf=no ;; +esac fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_func_vsnprintf" >&5 printf "%s\n" "$bash_cv_func_vsnprintf" >&6; } @@ -20394,76 +21622,197 @@ printf "%s\n" "$bash_cv_func_vsnprintf" >&6; } fi if test $ac_cv_func_vsnprintf = no; then -printf "%s\n" "#define HAVE_VSNPRINTF 0" >>confdefs.h +printf "%s\n" "#define HAVE_VSNPRINTF 0" >>confdefs.h + + fi + + + + ac_fn_c_check_func "$LINENO" "strtoimax" "ac_cv_func_strtoimax" +if test "x$ac_cv_func_strtoimax" = xyes +then : + printf "%s\n" "#define HAVE_STRTOIMAX 1" >>confdefs.h + +fi + + ac_fn_check_decl "$LINENO" "strtoimax" "ac_cv_have_decl_strtoimax" "$ac_includes_default" "$ac_c_undeclared_builtin_options" "CFLAGS" +if test "x$ac_cv_have_decl_strtoimax" = xyes +then : + ac_have_decl=1 +else case e in #( + e) ac_have_decl=0 ;; +esac +fi +printf "%s\n" "#define HAVE_DECL_STRTOIMAX $ac_have_decl" >>confdefs.h + + + if test "$ac_cv_func_strtoimax" != "yes" ; then + case " $LIBOBJS " in + *" strtoimax.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS strtoimax.$ac_objext" + ;; +esac + + fi + +ac_fn_check_decl "$LINENO" "clearerr_unlocked" "ac_cv_have_decl_clearerr_unlocked" "$ac_includes_default" "$ac_c_undeclared_builtin_options" "CFLAGS" +if test "x$ac_cv_have_decl_clearerr_unlocked" = xyes +then : + ac_have_decl=1 +else case e in #( + e) ac_have_decl=0 ;; +esac +fi +printf "%s\n" "#define HAVE_DECL_CLEARERR_UNLOCKED $ac_have_decl" >>confdefs.h + +ac_fn_check_decl "$LINENO" "feof_unlocked" "ac_cv_have_decl_feof_unlocked" "$ac_includes_default" "$ac_c_undeclared_builtin_options" "CFLAGS" +if test "x$ac_cv_have_decl_feof_unlocked" = xyes +then : + ac_have_decl=1 +else case e in #( + e) ac_have_decl=0 ;; +esac +fi +printf "%s\n" "#define HAVE_DECL_FEOF_UNLOCKED $ac_have_decl" >>confdefs.h + +ac_fn_check_decl "$LINENO" "ferror_unlocked" "ac_cv_have_decl_ferror_unlocked" "$ac_includes_default" "$ac_c_undeclared_builtin_options" "CFLAGS" +if test "x$ac_cv_have_decl_ferror_unlocked" = xyes +then : + ac_have_decl=1 +else case e in #( + e) ac_have_decl=0 ;; +esac +fi +printf "%s\n" "#define HAVE_DECL_FERROR_UNLOCKED $ac_have_decl" >>confdefs.h + +ac_fn_check_decl "$LINENO" "fflush_unlocked" "ac_cv_have_decl_fflush_unlocked" "$ac_includes_default" "$ac_c_undeclared_builtin_options" "CFLAGS" +if test "x$ac_cv_have_decl_fflush_unlocked" = xyes +then : + ac_have_decl=1 +else case e in #( + e) ac_have_decl=0 ;; +esac +fi +printf "%s\n" "#define HAVE_DECL_FFLUSH_UNLOCKED $ac_have_decl" >>confdefs.h + +ac_fn_check_decl "$LINENO" "fgets_unlocked" "ac_cv_have_decl_fgets_unlocked" "$ac_includes_default" "$ac_c_undeclared_builtin_options" "CFLAGS" +if test "x$ac_cv_have_decl_fgets_unlocked" = xyes +then : + ac_have_decl=1 +else case e in #( + e) ac_have_decl=0 ;; +esac +fi +printf "%s\n" "#define HAVE_DECL_FGETS_UNLOCKED $ac_have_decl" >>confdefs.h + +ac_fn_check_decl "$LINENO" "fputc_unlocked" "ac_cv_have_decl_fputc_unlocked" "$ac_includes_default" "$ac_c_undeclared_builtin_options" "CFLAGS" +if test "x$ac_cv_have_decl_fputc_unlocked" = xyes +then : + ac_have_decl=1 +else case e in #( + e) ac_have_decl=0 ;; +esac +fi +printf "%s\n" "#define HAVE_DECL_FPUTC_UNLOCKED $ac_have_decl" >>confdefs.h + +ac_fn_check_decl "$LINENO" "fputs_unlocked" "ac_cv_have_decl_fputs_unlocked" "$ac_includes_default" "$ac_c_undeclared_builtin_options" "CFLAGS" +if test "x$ac_cv_have_decl_fputs_unlocked" = xyes +then : + ac_have_decl=1 +else case e in #( + e) ac_have_decl=0 ;; +esac +fi +printf "%s\n" "#define HAVE_DECL_FPUTS_UNLOCKED $ac_have_decl" >>confdefs.h + +ac_fn_check_decl "$LINENO" "fread_unlocked" "ac_cv_have_decl_fread_unlocked" "$ac_includes_default" "$ac_c_undeclared_builtin_options" "CFLAGS" +if test "x$ac_cv_have_decl_fread_unlocked" = xyes +then : + ac_have_decl=1 +else case e in #( + e) ac_have_decl=0 ;; +esac +fi +printf "%s\n" "#define HAVE_DECL_FREAD_UNLOCKED $ac_have_decl" >>confdefs.h + +ac_fn_check_decl "$LINENO" "fwrite_unlocked" "ac_cv_have_decl_fwrite_unlocked" "$ac_includes_default" "$ac_c_undeclared_builtin_options" "CFLAGS" +if test "x$ac_cv_have_decl_fwrite_unlocked" = xyes +then : + ac_have_decl=1 +else case e in #( + e) ac_have_decl=0 ;; +esac +fi +printf "%s\n" "#define HAVE_DECL_FWRITE_UNLOCKED $ac_have_decl" >>confdefs.h + +ac_fn_check_decl "$LINENO" "getc_unlocked" "ac_cv_have_decl_getc_unlocked" "$ac_includes_default" "$ac_c_undeclared_builtin_options" "CFLAGS" +if test "x$ac_cv_have_decl_getc_unlocked" = xyes +then : + ac_have_decl=1 +else case e in #( + e) ac_have_decl=0 ;; +esac +fi +printf "%s\n" "#define HAVE_DECL_GETC_UNLOCKED $ac_have_decl" >>confdefs.h + +ac_fn_check_decl "$LINENO" "getchar_unlocked" "ac_cv_have_decl_getchar_unlocked" "$ac_includes_default" "$ac_c_undeclared_builtin_options" "CFLAGS" +if test "x$ac_cv_have_decl_getchar_unlocked" = xyes +then : + ac_have_decl=1 +else case e in #( + e) ac_have_decl=0 ;; +esac +fi +printf "%s\n" "#define HAVE_DECL_GETCHAR_UNLOCKED $ac_have_decl" >>confdefs.h + +ac_fn_check_decl "$LINENO" "putc_unlocked" "ac_cv_have_decl_putc_unlocked" "$ac_includes_default" "$ac_c_undeclared_builtin_options" "CFLAGS" +if test "x$ac_cv_have_decl_putc_unlocked" = xyes +then : + ac_have_decl=1 +else case e in #( + e) ac_have_decl=0 ;; +esac +fi +printf "%s\n" "#define HAVE_DECL_PUTC_UNLOCKED $ac_have_decl" >>confdefs.h + +ac_fn_check_decl "$LINENO" "putchar_unlocked" "ac_cv_have_decl_putchar_unlocked" "$ac_includes_default" "$ac_c_undeclared_builtin_options" "CFLAGS" +if test "x$ac_cv_have_decl_putchar_unlocked" = xyes +then : + ac_have_decl=1 +else case e in #( + e) ac_have_decl=0 ;; +esac +fi +printf "%s\n" "#define HAVE_DECL_PUTCHAR_UNLOCKED $ac_have_decl" >>confdefs.h + + - fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for usable strtoimax" >&5 -printf %s "checking for usable strtoimax... " >&6; } -if test ${bash_cv_func_strtoimax+y} -then : - printf %s "(cached) " >&6 -else $as_nop - HAVE_STRTOIMAX=0 HAVE_DECL_STRTOIMAX=0 - ac_fn_c_check_func "$LINENO" "strtoimax" "ac_cv_func_strtoimax" -if test "x$ac_cv_func_strtoimax" = xyes -then : - printf "%s\n" "#define HAVE_STRTOIMAX 1" >>confdefs.h -fi - ac_fn_check_decl "$LINENO" "strtoimax" "ac_cv_have_decl_strtoimax" "$ac_includes_default" "$ac_c_undeclared_builtin_options" "CFLAGS" -if test "x$ac_cv_have_decl_strtoimax" = xyes -then : - ac_have_decl=1 -else $as_nop - ac_have_decl=0 -fi -printf "%s\n" "#define HAVE_DECL_STRTOIMAX $ac_have_decl" >>confdefs.h - if test "$ac_cv_func_strtoimax" = "yes" ; then - HAVE_STRTOIMAX=1 - fi - if test "$ac_cv_have_decl_strtoimax" = "yes" ; then - HAVE_DECL_STRTOIMAX=1 - fi - if test "$HAVE_STRTOIMAX" = 0 || test "$HAVE_DECL_STRTOIMAX" = 0 ; then - bash_cv_func_strtoimax=no REPLACE_STRTOIMAX=1 - else - bash_cv_func_strtoimax=yes - fi -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_func_strtoimax" >&5 -printf "%s\n" "$bash_cv_func_strtoimax" >&6; } -if test $bash_cv_func_strtoimax = no; then -case " $LIBOBJS " in - *" strtoimax.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS strtoimax.$ac_objext" - ;; -esac -fi -if test "$ac_cv_func_putenv" = "yes"; then +if test "$ac_cv_func_putenv" = "yes"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for standard-conformant putenv declaration" >&5 printf %s "checking for standard-conformant putenv declaration... " >&6; } if test ${bash_cv_std_putenv+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if HAVE_STDLIB_H @@ -20472,16 +21821,7 @@ else $as_nop #if HAVE_STDDEF_H #include #endif -#ifndef __STDC__ -# ifndef const -# define const -# endif -#endif -#ifdef PROTOTYPES extern int putenv (char *); -#else -extern int putenv (); -#endif int main (void) @@ -20494,12 +21834,14 @@ _ACEOF if ac_fn_c_try_link "$LINENO" then : bash_cv_std_putenv=yes -else $as_nop - bash_cv_std_putenv=no - +else case e in #( + e) bash_cv_std_putenv=no + ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext + conftest$ac_exeext conftest.$ac_ext ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_std_putenv" >&5 printf "%s\n" "$bash_cv_std_putenv" >&6; } @@ -20514,14 +21856,13 @@ printf "%s\n" "#define HAVE_STD_PUTENV 1" >>confdefs.h fi if test "$ac_cv_func_unsetenv" = "yes"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for standard-conformant unsetenv declaration" >&5 printf %s "checking for standard-conformant unsetenv declaration... " >&6; } if test ${bash_cv_std_unsetenv+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if HAVE_STDLIB_H @@ -20530,16 +21871,7 @@ else $as_nop #if HAVE_STDDEF_H #include #endif -#ifndef __STDC__ -# ifndef const -# define const -# endif -#endif -#ifdef PROTOTYPES extern int unsetenv (const char *); -#else -extern int unsetenv (); -#endif int main (void) @@ -20552,12 +21884,14 @@ _ACEOF if ac_fn_c_try_link "$LINENO" then : bash_cv_std_unsetenv=yes -else $as_nop - bash_cv_std_unsetenv=no - +else case e in #( + e) bash_cv_std_unsetenv=no + ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext + conftest$ac_exeext conftest.$ac_ext ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_std_unsetenv" >&5 printf "%s\n" "$bash_cv_std_unsetenv" >&6; } @@ -20576,15 +21910,15 @@ printf %s "checking for printf floating point output in hex notation... " >&6; } if test ${bash_cv_printf_a_format+y} then : printf %s "(cached) " >&6 -else $as_nop - if test "$cross_compiling" = yes +else case e in #( + e) if test "$cross_compiling" = yes then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cannot check printf if cross compiling -- defaulting to no" >&5 printf "%s\n" "$as_me: WARNING: cannot check printf if cross compiling -- defaulting to no" >&2;} bash_cv_printf_a_format=no -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -20605,13 +21939,16 @@ _ACEOF if ac_fn_c_try_run "$LINENO" then : bash_cv_printf_a_format=yes -else $as_nop - bash_cv_printf_a_format=no +else case e in #( + e) bash_cv_printf_a_format=no ;; +esac fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_printf_a_format" >&5 @@ -20627,15 +21964,15 @@ printf %s "checking whether fnmatch can be used to check bracket equivalence cla if test ${bash_cv_fnmatch_equiv_fallback+y} then : printf %s "(cached) " >&6 -else $as_nop - if test "$cross_compiling" = yes +else case e in #( + e) if test "$cross_compiling" = yes then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cannot check fnmatch if cross compiling -- defaulting to no" >&5 printf "%s\n" "$as_me: WARNING: cannot check fnmatch if cross compiling -- defaulting to no" >&2;} bash_cv_fnmatch_equiv_fallback=no -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -20662,13 +21999,16 @@ _ACEOF if ac_fn_c_try_run "$LINENO" then : bash_cv_fnmatch_equiv_fallback=yes -else $as_nop - bash_cv_fnmatch_equiv_fallback=no +else case e in #( + e) bash_cv_fnmatch_equiv_fallback=no ;; +esac fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_fnmatch_equiv_fallback" >&5 @@ -20689,15 +22029,15 @@ printf %s "checking if signal handlers must be reinstalled when invoked... " >&6 if test ${bash_cv_must_reinstall_sighandlers+y} then : printf %s "(cached) " >&6 -else $as_nop - if test "$cross_compiling" = yes +else case e in #( + e) if test "$cross_compiling" = yes then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cannot check signal handling if cross compiling -- defaulting to no" >&5 printf "%s\n" "$as_me: WARNING: cannot check signal handling if cross compiling -- defaulting to no" >&2;} bash_cv_must_reinstall_sighandlers=no -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -20706,15 +22046,13 @@ else $as_nop #endif #include -typedef void sigfunc(); +typedef void sigfunc(int); volatile int nsigint; #ifdef HAVE_POSIX_SIGNALS sigfunc * -set_signal_handler(sig, handler) - int sig; - sigfunc *handler; +set_signal_handler(int sig, sigfunc *handler) { struct sigaction act, oact; act.sa_handler = handler; @@ -20729,8 +22067,7 @@ set_signal_handler(sig, handler) #endif void -sigint(s) -int s; +sigint(int s) { nsigint++; } @@ -20749,13 +22086,16 @@ _ACEOF if ac_fn_c_try_run "$LINENO" then : bash_cv_must_reinstall_sighandlers=no -else $as_nop - bash_cv_must_reinstall_sighandlers=yes +else case e in #( + e) bash_cv_must_reinstall_sighandlers=yes ;; +esac fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_must_reinstall_sighandlers" >&5 @@ -20771,8 +22111,8 @@ printf %s "checking for presence of necessary job control definitions... " >&6; if test ${bash_cv_job_control_missing+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -20827,11 +22167,13 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : bash_cv_job_control_missing=present -else $as_nop - bash_cv_job_control_missing=missing - +else case e in #( + e) bash_cv_job_control_missing=missing + ;; +esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_job_control_missing" >&5 @@ -20846,15 +22188,15 @@ printf %s "checking for presence of named pipes... " >&6; } if test ${bash_cv_sys_named_pipes+y} then : printf %s "(cached) " >&6 -else $as_nop - if test "$cross_compiling" = yes +else case e in #( + e) if test "$cross_compiling" = yes then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cannot check for named pipes if cross-compiling -- defaulting to missing" >&5 printf "%s\n" "$as_me: WARNING: cannot check for named pipes if cross-compiling -- defaulting to missing" >&2;} bash_cv_sys_named_pipes=missing -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -20902,13 +22244,16 @@ _ACEOF if ac_fn_c_try_run "$LINENO" then : bash_cv_sys_named_pipes=present -else $as_nop - bash_cv_sys_named_pipes=missing +else case e in #( + e) bash_cv_sys_named_pipes=missing ;; +esac fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_sys_named_pipes" >&5 @@ -20924,25 +22269,23 @@ printf %s "checking whether termios.h defines TIOCGWINSZ... " >&6; } if test ${ac_cv_sys_tiocgwinsz_in_termios_h+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include +$ac_includes_default #include -#ifdef TIOCGWINSZ - yes -#endif +const int tiocgwinsz = TIOCGWINSZ; _ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "yes" >/dev/null 2>&1 +if ac_fn_c_try_compile "$LINENO" then : ac_cv_sys_tiocgwinsz_in_termios_h=yes -else $as_nop - ac_cv_sys_tiocgwinsz_in_termios_h=no +else case e in #( + e) ac_cv_sys_tiocgwinsz_in_termios_h=no ;; +esac fi -rm -rf conftest* - +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_tiocgwinsz_in_termios_h" >&5 printf "%s\n" "$ac_cv_sys_tiocgwinsz_in_termios_h" >&6; } @@ -20953,25 +22296,23 @@ printf %s "checking whether sys/ioctl.h defines TIOCGWINSZ... " >&6; } if test ${ac_cv_sys_tiocgwinsz_in_sys_ioctl_h+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include +$ac_includes_default #include -#ifdef TIOCGWINSZ - yes -#endif +const int tiocgwinsz = TIOCGWINSZ; _ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "yes" >/dev/null 2>&1 +if ac_fn_c_try_compile "$LINENO" then : ac_cv_sys_tiocgwinsz_in_sys_ioctl_h=yes -else $as_nop - ac_cv_sys_tiocgwinsz_in_sys_ioctl_h=no +else case e in #( + e) ac_cv_sys_tiocgwinsz_in_sys_ioctl_h=no ;; +esac fi -rm -rf conftest* - +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_tiocgwinsz_in_sys_ioctl_h" >&5 printf "%s\n" "$ac_cv_sys_tiocgwinsz_in_sys_ioctl_h" >&6; } @@ -20988,8 +22329,8 @@ printf %s "checking for TIOCSTAT in sys/ioctl.h... " >&6; } if test ${bash_cv_tiocstat_in_ioctl+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -21005,11 +22346,13 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : bash_cv_tiocstat_in_ioctl=yes -else $as_nop - bash_cv_tiocstat_in_ioctl=no - +else case e in #( + e) bash_cv_tiocstat_in_ioctl=no + ;; +esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_tiocstat_in_ioctl" >&5 @@ -21024,8 +22367,8 @@ printf %s "checking for FIONREAD in sys/ioctl.h... " >&6; } if test ${bash_cv_fionread_in_ioctl+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -21041,11 +22384,13 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : bash_cv_fionread_in_ioctl=yes -else $as_nop - bash_cv_fionread_in_ioctl=no - +else case e in #( + e) bash_cv_fionread_in_ioctl=no + ;; +esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_fionread_in_ioctl" >&5 @@ -21062,15 +22407,15 @@ printf %s "checking whether WCONTINUED flag to waitpid is unavailable or availab if test ${bash_cv_wcontinued_broken+y} then : printf %s "(cached) " >&6 -else $as_nop - if test "$cross_compiling" = yes +else case e in #( + e) if test "$cross_compiling" = yes then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cannot check WCONTINUED if cross compiling -- defaulting to no" >&5 printf "%s\n" "$as_me: WARNING: cannot check WCONTINUED if cross compiling -- defaulting to no" >&2;} bash_cv_wcontinued_broken=no -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -21098,13 +22443,16 @@ _ACEOF if ac_fn_c_try_run "$LINENO" then : bash_cv_wcontinued_broken=no -else $as_nop - bash_cv_wcontinued_broken=yes +else case e in #( + e) bash_cv_wcontinued_broken=yes ;; +esac fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_wcontinued_broken" >&5 @@ -21120,8 +22468,8 @@ printf %s "checking for speed_t in sys/types.h... " >&6; } if test ${bash_cv_speed_t_in_sys_types+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int @@ -21135,10 +22483,12 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : bash_cv_speed_t_in_sys_types=yes -else $as_nop - bash_cv_speed_t_in_sys_types=no +else case e in #( + e) bash_cv_speed_t_in_sys_types=no ;; +esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_speed_t_in_sys_types" >&5 @@ -21153,8 +22503,8 @@ printf %s "checking whether getpw functions are declared in pwd.h... " >&6; } if test ${bash_cv_getpw_declared+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -21165,14 +22515,16 @@ else $as_nop _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "getpwuid" >/dev/null 2>&1 + $EGREP_TRADITIONAL "getpwuid" >/dev/null 2>&1 then : bash_cv_getpw_declared=yes -else $as_nop - bash_cv_getpw_declared=no +else case e in #( + e) bash_cv_getpw_declared=no ;; +esac fi rm -rf conftest* - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_getpw_declared" >&5 @@ -21187,15 +22539,15 @@ printf %s "checking for unusable real-time signals due to large values... " >&6; if test ${bash_cv_unusable_rtsigs+y} then : printf %s "(cached) " >&6 -else $as_nop - if test "$cross_compiling" = yes +else case e in #( + e) if test "$cross_compiling" = yes then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cannot check real-time signals if cross compiling -- defaulting to yes" >&5 printf "%s\n" "$as_me: WARNING: cannot check real-time signals if cross compiling -- defaulting to yes" >&2;} bash_cv_unusable_rtsigs=yes -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -21223,13 +22575,16 @@ _ACEOF if ac_fn_c_try_run "$LINENO" then : bash_cv_unusable_rtsigs=yes -else $as_nop - bash_cv_unusable_rtsigs=no +else case e in #( + e) bash_cv_unusable_rtsigs=no ;; +esac fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_unusable_rtsigs" >&5 @@ -21257,12 +22612,12 @@ printf %s "checking whether $host_os needs _KERNEL for RLIMIT defines... " >&6; if test ${bash_cv_kernel_rlimit+y} then : printf %s "(cached) " >&6 -else $as_nop - if test ${bash_cv_rlimit+y} +else case e in #( + e) if test ${bash_cv_rlimit+y} then : printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -21282,11 +22637,13 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : bash_cv_rlimit=yes -else $as_nop - bash_cv_rlimit=no - +else case e in #( + e) bash_cv_rlimit=no + ;; +esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi @@ -21313,12 +22670,14 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : bash_cv_kernel_rlimit=yes -else $as_nop - bash_cv_kernel_rlimit=no +else case e in #( + e) bash_cv_kernel_rlimit=no ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_kernel_rlimit" >&5 @@ -21345,27 +22704,33 @@ fi if test ${bash_cv_termcap_lib+y} then : printf %s "(cached) " >&6 -else $as_nop - ac_fn_c_check_func "$LINENO" "tgetent" "ac_cv_func_tgetent" +else case e in #( + e) ac_fn_c_check_func "$LINENO" "tgetent" "ac_cv_func_tgetent" if test "x$ac_cv_func_tgetent" = xyes then : bash_cv_termcap_lib=libc -else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for tgetent in -ltermcap" >&5 +else case e in #( + e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for tgetent in -ltermcap" >&5 printf %s "checking for tgetent in -ltermcap... " >&6; } if test ${ac_cv_lib_termcap_tgetent+y} then : printf %s "(cached) " >&6 -else $as_nop - ac_check_lib_save_LIBS=$LIBS +else case e in #( + e) ac_check_lib_save_LIBS=$LIBS LIBS="-ltermcap $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -char tgetent (); + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char tgetent (void); int main (void) { @@ -21377,34 +22742,42 @@ _ACEOF if ac_fn_c_try_link "$LINENO" then : ac_cv_lib_termcap_tgetent=yes -else $as_nop - ac_cv_lib_termcap_tgetent=no +else case e in #( + e) ac_cv_lib_termcap_tgetent=no ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS +LIBS=$ac_check_lib_save_LIBS ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_termcap_tgetent" >&5 printf "%s\n" "$ac_cv_lib_termcap_tgetent" >&6; } if test "x$ac_cv_lib_termcap_tgetent" = xyes then : bash_cv_termcap_lib=libtermcap -else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for tgetent in -ltinfo" >&5 +else case e in #( + e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for tgetent in -ltinfo" >&5 printf %s "checking for tgetent in -ltinfo... " >&6; } if test ${ac_cv_lib_tinfo_tgetent+y} then : printf %s "(cached) " >&6 -else $as_nop - ac_check_lib_save_LIBS=$LIBS +else case e in #( + e) ac_check_lib_save_LIBS=$LIBS LIBS="-ltinfo $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -char tgetent (); + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char tgetent (void); int main (void) { @@ -21416,34 +22789,42 @@ _ACEOF if ac_fn_c_try_link "$LINENO" then : ac_cv_lib_tinfo_tgetent=yes -else $as_nop - ac_cv_lib_tinfo_tgetent=no +else case e in #( + e) ac_cv_lib_tinfo_tgetent=no ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS +LIBS=$ac_check_lib_save_LIBS ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_tinfo_tgetent" >&5 printf "%s\n" "$ac_cv_lib_tinfo_tgetent" >&6; } if test "x$ac_cv_lib_tinfo_tgetent" = xyes then : bash_cv_termcap_lib=libtinfo -else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for tgetent in -lcurses" >&5 +else case e in #( + e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for tgetent in -lcurses" >&5 printf %s "checking for tgetent in -lcurses... " >&6; } if test ${ac_cv_lib_curses_tgetent+y} then : printf %s "(cached) " >&6 -else $as_nop - ac_check_lib_save_LIBS=$LIBS +else case e in #( + e) ac_check_lib_save_LIBS=$LIBS LIBS="-lcurses $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -char tgetent (); + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char tgetent (void); int main (void) { @@ -21455,34 +22836,42 @@ _ACEOF if ac_fn_c_try_link "$LINENO" then : ac_cv_lib_curses_tgetent=yes -else $as_nop - ac_cv_lib_curses_tgetent=no +else case e in #( + e) ac_cv_lib_curses_tgetent=no ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS +LIBS=$ac_check_lib_save_LIBS ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_tgetent" >&5 printf "%s\n" "$ac_cv_lib_curses_tgetent" >&6; } if test "x$ac_cv_lib_curses_tgetent" = xyes then : bash_cv_termcap_lib=libcurses -else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for tgetent in -lncurses" >&5 -printf %s "checking for tgetent in -lncurses... " >&6; } -if test ${ac_cv_lib_ncurses_tgetent+y} +else case e in #( + e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for tgetent in -lncursesw" >&5 +printf %s "checking for tgetent in -lncursesw... " >&6; } +if test ${ac_cv_lib_ncursesw_tgetent+y} then : printf %s "(cached) " >&6 -else $as_nop - ac_check_lib_save_LIBS=$LIBS -LIBS="-lncurses $LIBS" +else case e in #( + e) ac_check_lib_save_LIBS=$LIBS +LIBS="-lncursesw $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -char tgetent (); + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char tgetent (void); int main (void) { @@ -21493,35 +22882,43 @@ return tgetent (); _ACEOF if ac_fn_c_try_link "$LINENO" then : - ac_cv_lib_ncurses_tgetent=yes -else $as_nop - ac_cv_lib_ncurses_tgetent=no + ac_cv_lib_ncursesw_tgetent=yes +else case e in #( + e) ac_cv_lib_ncursesw_tgetent=no ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS +LIBS=$ac_check_lib_save_LIBS ;; +esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ncurses_tgetent" >&5 -printf "%s\n" "$ac_cv_lib_ncurses_tgetent" >&6; } -if test "x$ac_cv_lib_ncurses_tgetent" = xyes +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ncursesw_tgetent" >&5 +printf "%s\n" "$ac_cv_lib_ncursesw_tgetent" >&6; } +if test "x$ac_cv_lib_ncursesw_tgetent" = xyes then : - bash_cv_termcap_lib=libncurses -else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for tgetent in -lncursesw" >&5 -printf %s "checking for tgetent in -lncursesw... " >&6; } -if test ${ac_cv_lib_ncursesw_tgetent+y} + bash_cv_termcap_lib=libncursesw +else case e in #( + e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for tgetent in -lncurses" >&5 +printf %s "checking for tgetent in -lncurses... " >&6; } +if test ${ac_cv_lib_ncurses_tgetent+y} then : printf %s "(cached) " >&6 -else $as_nop - ac_check_lib_save_LIBS=$LIBS -LIBS="-lncursesw $LIBS" +else case e in #( + e) ac_check_lib_save_LIBS=$LIBS +LIBS="-lncurses $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -char tgetent (); + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char tgetent (void); int main (void) { @@ -21532,33 +22929,42 @@ return tgetent (); _ACEOF if ac_fn_c_try_link "$LINENO" then : - ac_cv_lib_ncursesw_tgetent=yes -else $as_nop - ac_cv_lib_ncursesw_tgetent=no + ac_cv_lib_ncurses_tgetent=yes +else case e in #( + e) ac_cv_lib_ncurses_tgetent=no ;; +esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS +LIBS=$ac_check_lib_save_LIBS ;; +esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ncursesw_tgetent" >&5 -printf "%s\n" "$ac_cv_lib_ncursesw_tgetent" >&6; } -if test "x$ac_cv_lib_ncursesw_tgetent" = xyes +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ncurses_tgetent" >&5 +printf "%s\n" "$ac_cv_lib_ncurses_tgetent" >&6; } +if test "x$ac_cv_lib_ncurses_tgetent" = xyes then : - bash_cv_termcap_lib=libncursesw -else $as_nop - bash_cv_termcap_lib=gnutermcap + bash_cv_termcap_lib=libncurses +else case e in #( + e) bash_cv_termcap_lib=gnutermcap ;; +esac fi - + ;; +esac fi - + ;; +esac fi - + ;; +esac fi - + ;; +esac fi - + ;; +esac fi - + ;; +esac fi if test "X$_bash_needmsg" = "Xyes"; then @@ -21577,9 +22983,15 @@ TERMCAP_DEP= elif test $bash_cv_termcap_lib = libtinfo; then TERMCAP_LIB=-ltinfo TERMCAP_DEP= +elif test $bash_cv_termcap_lib = libncursesw; then +TERMCAP_LIB=-lncursesw +TERMCAP_DEP= elif test $bash_cv_termcap_lib = libncurses; then TERMCAP_LIB=-lncurses TERMCAP_DEP= +elif test $bash_cv_termcap_lib = libcurses; then +TERMCAP_LIB=-lcurses +TERMCAP_DEP= elif test $bash_cv_termcap_lib = libc; then TERMCAP_LIB= TERMCAP_DEP= @@ -21598,15 +23010,17 @@ printf %s "checking whether /dev/fd is available... " >&6; } if test ${bash_cv_dev_fd+y} then : printf %s "(cached) " >&6 -else $as_nop - bash_cv_dev_fd="" -if test -d /dev/fd && (exec test -r /dev/fd/0 < /dev/null) ; then +else case e in #( + e) bash_cv_dev_fd="" +if test -d /dev/fd && (exec test -r /dev/fd/0 < /dev/null) ; then # check for systems like FreeBSD 5 that only provide /dev/fd/[012] if (exec test -r /dev/fd/3 3&5 @@ -21630,6 +23045,11 @@ elif test $bash_cv_dev_fd = "whacky"; then printf "%s\n" "#define DEV_FD_PREFIX \"/proc/self/fd/\"" >>confdefs.h +elif test $bash_cv_dev_fd = "nodir"; then + printf "%s\n" "#define HAVE_DEV_FD 1" >>confdefs.h + + printf "%s\n" "#define DEV_FD_PREFIX \"/dev/fd\"" >>confdefs.h + fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether /dev/stdin stdout stderr are available" >&5 @@ -21637,13 +23057,14 @@ printf %s "checking whether /dev/stdin stdout stderr are available... " >&6; } if test ${bash_cv_dev_stdin+y} then : printf %s "(cached) " >&6 -else $as_nop - if (exec test -r /dev/stdin < /dev/null) ; then +else case e in #( + e) if (exec test -r /dev/stdin < /dev/null) ; then bash_cv_dev_stdin=present else bash_cv_dev_stdin=absent fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_dev_stdin" >&5 @@ -21658,8 +23079,8 @@ printf %s "checking for default mail directory... " >&6; } if test ${bash_cv_mail_dir+y} then : printf %s "(cached) " >&6 -else $as_nop - if test -d /var/mail; then +else case e in #( + e) if test -d /var/mail; then bash_cv_mail_dir=/var/mail elif test -d /var/spool/mail; then bash_cv_mail_dir=/var/spool/mail @@ -21670,7 +23091,8 @@ else $as_nop else bash_cv_mail_dir=unknown fi - + ;; +esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_mail_dir" >&5 @@ -21733,7 +23155,7 @@ freebsd*|midnightbsd*) LOCAL_CFLAGS='-DHEREDOC_PIPESIZE=4096' ;; *qnx[67]*) LOCAL_LIBS="-lncurses" ;; *qnx*) LOCAL_CFLAGS="-Dqnx -F -3s" LOCAL_LDFLAGS="-3s" LOCAL_LIBS="-lunix -lncurses" ;; powerux*) LOCAL_LIBS="-lgen" ;; -cygwin*) LOCAL_CFLAGS=-DRECYCLES_PIDS ;; +cygwin*|msys*) LOCAL_CFLAGS=-DRECYCLES_PIDS ;; opennt*|interix*) LOCAL_CFLAGS="-DNO_MAIN_ENV_ARG -DBROKEN_DIRENT_D_INO -D_POSIX_SOURCE -D_ALL_SOURCE -DRECYCLES_PIDS" ;; *openstep*) LOCAL_CFLAGS="-D__APPLE_CC__" ;; esac @@ -21751,7 +23173,9 @@ freebsd[3-9]*) if test -x /usr/bin/objformat && test "`/usr/bin/objformat`" = "elf" ; then LOCAL_LDFLAGS=-rdynamic # allow dynamic loading fi ;; -freebsdelf*) LOCAL_LDFLAGS=-rdynamic ;; # allow dynamic loading +freebsd*) LOCAL_LDFLAGS=-rdynamic ;; # allow dynamic loading +openbsd*) LOCAL_LDFLAGS=-rdynamic ;; # allow dynamic loading +netbsd*) LOCAL_LDFLAGS=-rdynamic ;; # allow dynamic loading dragonfly*) LOCAL_LDFLAGS=-rdynamic ;; # allow dynamic loading midnightbsd*) LOCAL_LDFLAGS=-rdynamic ;; # allow dynamic loading esac @@ -21869,6 +23293,18 @@ ac_config_files="$ac_config_files Makefile builtins/Makefile lib/readline/Makefi ac_config_commands="$ac_config_commands stamp-h" +if test "$ac_cv_header_stdckdint_h" = yes; then + rm -f stdckdint.h + STDCKDINT_H= +elif cmp ${srcdir}/include/stdckdint.in.h stdckdint.h 2>/dev/null; then + : + STDCKDINT_H='${BUILD_DIR}/stdckdint.h' +else + cp ${srcdir}/include/stdckdint.in.h stdckdint.h + STDCKDINT_H='${BUILD_DIR}/stdckdint.h' +fi + + cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure @@ -21879,8 +23315,8 @@ cat >confcache <<\_ACEOF # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # -# `ac_cv_env_foo' variables (set or unset) will be overridden when -# loading this file, other *unset* `ac_cv_foo' will be assigned the +# 'ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* 'ac_cv_foo' will be assigned the # following values. _ACEOF @@ -21910,14 +23346,14 @@ printf "%s\n" "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) - # `set' does not quote correctly, so add quotes: double-quote + # 'set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) - # `set' quotes correctly as required by POSIX, so do not add quotes. + # 'set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | @@ -21978,6 +23414,12 @@ LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs +# Check whether --enable-year2038 was given. +if test ${enable_year2038+y} +then : + enableval=$enable_year2038; +fi + : "${CONFIG_STATUS=./config.status}" @@ -22008,7 +23450,6 @@ cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh -as_nop=: if test ${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1 then : emulate sh @@ -22017,12 +23458,13 @@ then : # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST -else $as_nop - case `(set -o) 2>/dev/null` in #( +else case e in #( + e) case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; +esac ;; esac fi @@ -22094,7 +23536,7 @@ IFS=$as_save_IFS ;; esac -# We did not find ourselves, most probably we were run as `sh COMMAND' +# We did not find ourselves, most probably we were run as 'sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 @@ -22123,7 +23565,6 @@ as_fn_error () } # as_fn_error - # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. @@ -22163,11 +23604,12 @@ then : { eval $1+=\$2 }' -else $as_nop - as_fn_append () +else case e in #( + e) as_fn_append () { eval $1=\$$1\$2 - } + } ;; +esac fi # as_fn_append # as_fn_arith ARG... @@ -22181,11 +23623,12 @@ then : { as_val=$(( $* )) }' -else $as_nop - as_fn_arith () +else case e in #( + e) as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` - } + } ;; +esac fi # as_fn_arith @@ -22268,9 +23711,9 @@ if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -pR'. + # 1) On MSYS, both 'ln -s file dir' and 'ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; 'ln -s' creates a wrapper executable. + # In both cases, we have to default to 'cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then @@ -22351,10 +23794,12 @@ as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. -as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" +as_sed_cpp="y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g" +as_tr_cpp="eval sed '$as_sed_cpp'" # deprecated # Sed expression to map a string onto a valid variable name. -as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" +as_sed_sh="y%*+%pp%;s%[^_$as_cr_alnum]%_%g" +as_tr_sh="eval sed '$as_sed_sh'" # deprecated exec 6>&1 @@ -22369,8 +23814,8 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by bash $as_me 5.2-release, which was -generated by GNU Autoconf 2.71. Invocation command line was +This file was extended by bash $as_me 5.3-release, which was +generated by GNU Autoconf 2.72. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -22402,7 +23847,7 @@ _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ -\`$as_me' instantiates files and other configuration actions +'$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. @@ -22437,11 +23882,11 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config='$ac_cs_config_escaped' ac_cs_version="\\ -bash config.status 5.2-release -configured by $0, generated by GNU Autoconf 2.71, +bash config.status 5.3-release +configured by $0, generated by GNU Autoconf 2.72, with options \\"\$ac_cs_config\\" -Copyright (C) 2021 Free Software Foundation, Inc. +Copyright (C) 2023 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." @@ -22502,8 +23947,8 @@ do ac_need_defaults=false;; --he | --h) # Conflict between --help and --header - as_fn_error $? "ambiguous option: \`$1' -Try \`$0 --help' for more information.";; + as_fn_error $? "ambiguous option: '$1' +Try '$0 --help' for more information.";; --help | --hel | -h ) printf "%s\n" "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ @@ -22511,8 +23956,8 @@ Try \`$0 --help' for more information.";; ac_cs_silent=: ;; # This is an error. - -*) as_fn_error $? "unrecognized option: \`$1' -Try \`$0 --help' for more information." ;; + -*) as_fn_error $? "unrecognized option: '$1' +Try '$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; @@ -22571,6 +24016,7 @@ for ac_config_target in $ac_config_targets do case $ac_config_target in "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; + "buildconf.h") CONFIG_HEADERS="$CONFIG_HEADERS buildconf.h" ;; "po-directories") CONFIG_COMMANDS="$CONFIG_COMMANDS po-directories" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "builtins/Makefile") CONFIG_FILES="$CONFIG_FILES builtins/Makefile" ;; @@ -22592,7 +24038,7 @@ do "support/bashbug.sh") CONFIG_FILES="$CONFIG_FILES support/bashbug.sh" ;; "stamp-h") CONFIG_COMMANDS="$CONFIG_COMMANDS stamp-h" ;; - *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; + *) as_fn_error $? "invalid argument: '$ac_config_target'" "$LINENO" 5;; esac done @@ -22612,7 +24058,7 @@ fi # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: -# after its creation but before its name has been assigned to `$tmp'. +# after its creation but before its name has been assigned to '$tmp'. $debug || { tmp= ac_tmp= @@ -22636,7 +24082,7 @@ ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. -# This happens for instance with `./config.status config.h'. +# This happens for instance with './config.status config.h'. if test -n "$CONFIG_FILES"; then @@ -22794,13 +24240,13 @@ fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. -# This happens for instance with `./config.status Makefile'. +# This happens for instance with './config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF -# Transform confdefs.h into an awk script `defines.awk', embedded as +# Transform confdefs.h into an awk script 'defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. @@ -22910,7 +24356,7 @@ do esac case $ac_mode$ac_tag in :[FHL]*:*);; - :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; + :L* | :C*:*) as_fn_error $? "invalid tag '$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac @@ -22932,19 +24378,19 @@ do -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, - # because $ac_f cannot contain `:'. + # because $ac_f cannot contain ':'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || - as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; + as_fn_error 1 "cannot find input file: '$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`printf "%s\n" "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done - # Let's still pretend it is `configure' which instantiates (i.e., don't + # Let's still pretend it is 'configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` @@ -23077,7 +24523,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 esac _ACEOF -# Neutralize VPATH when `$srcdir' = `.'. +# Neutralize VPATH when '$srcdir' = '.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 @@ -23108,9 +24554,9 @@ test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable 'datarootdir' which seems to be undefined. Please make sure it is defined" >&5 -printf "%s\n" "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +printf "%s\n" "$as_me: WARNING: $ac_file contains a reference to the variable 'datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" @@ -23235,7 +24681,9 @@ printf "%s\n" "$as_me: executing $ac_file commands" >&6;} # presentlang can be used as a fallback for messages # which are not translated in the desiredlang catalog). case "$desiredlang" in - "$presentlang"*) useit=yes;; + "$presentlang" | "$presentlang"_* | "$presentlang".* | "$presentlang"@*) + useit=yes + ;; esac done if test $useit = yes; then diff --git a/configure.ac b/configure.ac index 52d4029a5..5a76267e0 100644 --- a/configure.ac +++ b/configure.ac @@ -1,11 +1,11 @@ dnl -dnl Configure script for bash-5.2 +dnl Configure script for bash-5.3 dnl -dnl report bugs to chet@po.cwru.edu +dnl report bugs to chet.ramey@case.edu dnl dnl Process this file with autoconf to produce a configure script. -# Copyright (C) 1987-2022 Free Software Foundation, Inc. +# Copyright (C) 1987-2025 Free Software Foundation, Inc. # # This program is free software: you can redistribute it and/or modify @@ -21,9 +21,9 @@ dnl Process this file with autoconf to produce a configure script. # You should have received a copy of the GNU General Public License # along with this program. If not, see . -AC_REVISION([for Bash 5.2, version 5.046])dnl +AC_REVISION([for Bash 5.3, version 5.080])dnl -define(bashvers, 5.2) +define(bashvers, 5.3) define(relstatus, release) AC_INIT([bash], bashvers-relstatus, [bug-bash@gnu.org]) @@ -32,9 +32,9 @@ dnl make sure we are using a recent autoconf version AC_PREREQ(2.69) AC_CONFIG_SRCDIR(shell.h) -dnl where to find install.sh, config.sub, and config.guess +dnl where to find install-sh, config.sub, and config.guess AC_CONFIG_AUX_DIR(./support) -AC_CONFIG_HEADERS(config.h) +AC_CONFIG_HEADERS(config.h buildconf.h) dnl checks for version info BASHVERS=bashvers @@ -76,7 +76,7 @@ m68k-sysv) opt_bash_malloc=no ;; # fixes file descriptor leak in closedir # These need additional investigation sparc-linux*) opt_bash_malloc=no ;; # sparc running linux; requires ELF *-aix*) opt_bash_malloc=no ;; # AIX machines -*-cygwin*) opt_bash_malloc=no ;; # Cygnus's CYGWIN environment +*-cygwin*|msys*) opt_bash_malloc=no ;; # Cygnus's CYGWIN environment # These lack a working sbrk(2) aarch64-freebsd*) opt_bash_malloc=no ;; riscv*-freebsd*) opt_bash_malloc=no ;; @@ -92,6 +92,8 @@ riscv*-freebsd*) opt_bash_malloc=no ;; *-nsk*) opt_bash_malloc=no ;; # HP NonStop *-haiku*) opt_bash_malloc=no ;; # Haiku OS *-genode*) opt_bash_malloc=no ;; # Genode has no sbrk +i370-openedition*) opt_bash_malloc=no LOCAL_LIBS=-lzoslib LIBS_FOR_BUILD=-lzoslib ;; # IBM z/OS machines +i370-*) opt_bash_malloc=no ;; # generic (?) IBM 370 machines esac # memory scrambling on free() @@ -184,6 +186,7 @@ opt_function_import=yes opt_dev_fd_stat_broken=no opt_alt_array_impl=no opt_translatable_strings=yes +opt_bash_source_fullpath_default=no dnl modified by alternate array implementation option ARRAY_O=array.o @@ -209,6 +212,7 @@ if test $opt_minimal_config = yes; then opt_casemod_attrs=no opt_casemod_expansions=no opt_extglob_default=no opt_translatable_strings=no opt_globascii_default=yes + opt_bash_source_fullpath_default=no fi AC_ARG_ENABLE(alias, AS_HELP_STRING([--enable-alias], [enable shell aliases]), opt_alias=$enableval) @@ -216,6 +220,7 @@ AC_ARG_ENABLE(alt-array-implementation, AS_HELP_STRING([--enable-alt-array-imple AC_ARG_ENABLE(arith-for-command, AS_HELP_STRING([--enable-arith-for-command], [enable arithmetic for command]), opt_arith_for_command=$enableval) AC_ARG_ENABLE(array-variables, AS_HELP_STRING([--enable-array-variables], [include shell array variables]), opt_array_variables=$enableval) AC_ARG_ENABLE(bang-history, AS_HELP_STRING([--enable-bang-history], [turn on csh-style history substitution]), opt_bang_history=$enableval) +AC_ARG_ENABLE(bash-source-fullpath-default, AS_HELP_STRING([--enable-bash-source-fullpath-default], [enable the bash_source_fullpath option by default]), opt_bash_source_fullpath_default=$enableval) AC_ARG_ENABLE(brace-expansion, AS_HELP_STRING([--enable-brace-expansion], [include brace expansion]), opt_brace_expansion=$enableval) AC_ARG_ENABLE(casemod-attributes, AS_HELP_STRING([--enable-casemod-attributes], [include case-modifying variable attributes]), opt_casemod_attrs=$enableval) AC_ARG_ENABLE(casemod-expansions, AS_HELP_STRING([--enable-casemod-expansions], [include case-modifying word expansions]), opt_casemod_expansions=$enableval) @@ -369,6 +374,11 @@ fi if test $opt_translatable_strings = yes; then AC_DEFINE(TRANSLATABLE_STRINGS) fi +if test $opt_bash_source_fullpath_default = yes; then +AC_DEFINE(BASH_SOURCE_FULLPATH_DEFAULT, 1) +else +AC_DEFINE(BASH_SOURCE_FULLPATH_DEFAULT, 0) +fi if test $opt_memscramble = yes; then AC_DEFINE(MEMSCRAMBLE) @@ -458,27 +468,30 @@ dnl Set SIGNAMES_H based on whether or not we're cross-compiling. CROSS_COMPILE= if test "x$cross_compiling" = "xyes"; then - case "${host}" in - *-cygwin*) - cross_cache=${srcdir}/cross-build/cygwin32.cache - ;; - *-mingw*) - cross_cache=${srcdir}/cross-build/cygwin32.cache - ;; - i[[3456]]86-*-beos*) - cross_cache=${srcdir}/cross-build/x86-beos.cache - ;; - *-qnx*) - cross_cache=${srcdir}/cross-build/qnx.cache - ;; - *) echo "configure: cross-compiling for $host is not supported" >&2 - ;; - esac - if test -n "${cross_cache}" && test -r "${cross_cache}"; then - echo "loading cross-build cache file ${cross_cache}" - . ${cross_cache} - fi - unset cross_cache +# case "${host}" in +# *-cygwin*) +# cross_cache=${srcdir}/cross-build/cygwin32.cache +# ;; +# *-msys*) +# cross_cache=${srcdir}/cross-build/msys32.cache +# ;; +# *-mingw*) +# cross_cache=${srcdir}/cross-build/cygwin32.cache +# ;; +# i[[3456]]86-*-beos*) +# cross_cache=${srcdir}/cross-build/x86-beos.cache +# ;; +# *-qnx*) +# cross_cache=${srcdir}/cross-build/qnx.cache +# ;; +# *) echo "configure: cross-compiling for $host is not supported" >&2 +# ;; +# esac +# if test -n "${cross_cache}" && test -r "${cross_cache}"; then +# echo "loading cross-build cache file ${cross_cache}" +# . ${cross_cache} +# fi +# unset cross_cache SIGNAMES_O='signames.o' CROSS_COMPILE='-DCROSS_COMPILING' AC_SUBST(CROSS_COMPILE) @@ -513,7 +526,8 @@ if test "$opt_static_link" = yes; then if test "$GCC" = "yes"; then STATIC_LD="-static" case "$host_os" in - solaris2*|linux*) ;; + solaris2*) ;; + linux*) test "$opt_profiling" = "no" && LDFLAGS="$LDFLAGS -static" ;; *) LDFLAGS="$LDFLAGS -static" ;; # XXX experimental esac fi @@ -533,11 +547,9 @@ if test "X$cross_compiling" = "Xno"; then # CFLAGS set above to default value if not passed in environment if test -n "$want_auto_cflags" ; then CFLAGS_FOR_BUILD="${CFLAGS}" - BASE_CFLAGS_FOR_BUILD="${CFLAGS}" else # passed in environment CFLAGS_FOR_BUILD=${CFLAGS-'$(CFLAGS)'} - BASE_CFLAGS_FOR_BUILD=${CFLAGS-'$(CFLAGS)'} fi LIBS_FOR_BUILD=${LIBS_FOR_BUILD-'$(LIBS)'} else @@ -545,7 +557,6 @@ else CPPFLAGS_FOR_BUILD=${CPPFLAGS_FOR_BUILD-""} LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD-""} CFLAGS_FOR_BUILD=${CFLAGS_FOR_BUILD="-g"} - BASE_CFLAGS_FOR_BUILD=${BASE_CFLAGS_FOR_BUILD="-g"} LIBS_FOR_BUILD=${LIBS_FOR_BUILD-""} fi @@ -556,13 +567,13 @@ AC_SUBST(STATIC_LD) AC_SUBST(CC_FOR_BUILD) AC_SUBST(CFLAGS_FOR_BUILD) -AC_SUBST(BASE_CFLAGS_FOR_BUILD) AC_SUBST(STYLE_CFLAGS) AC_SUBST(CPPFLAGS_FOR_BUILD) AC_SUBST(LDFLAGS_FOR_BUILD) AC_SUBST(LIBS_FOR_BUILD) -AC_PROG_GCC_TRADITIONAL +dnl This macro is obsolete +dnl AC_PROG_GCC_TRADITIONAL dnl BEGIN READLINE and HISTORY LIBRARY SECTION dnl prepare to allow bash to be linked against an already-installed readline @@ -602,11 +613,13 @@ if test $opt_readline = yes; then # section for OS versions that don't allow unresolved symbols # to be compiled into dynamic libraries. case "$host_os" in - cygwin*) TILDE_LIB= ;; + cygwin*|msys*) TILDE_LIB= ;; esac else RL_LIBDIR='$(dot)/$(LIBSUBDIR)/readline' READLINE_DEP='$(READLINE_LIBRARY)' + # for dependencies + RL_INCLUDEDIR='$(RL_LIBDIR)' # section for OS versions that ship an older/broken version of # readline as a standard dynamic library and don't allow a # static version specified as -llibname to override the @@ -619,6 +632,7 @@ if test $opt_readline = yes; then else RL_LIBDIR='$(dot)/$(LIBSUBDIR)/readline' READLINE_LIB= READLINE_DEP= + RL_INCLUDEDIR= fi if test $opt_history = yes || test $opt_bang_history = yes; then if test $opt_history = yes; then @@ -642,6 +656,8 @@ if test $opt_history = yes || test $opt_bang_history = yes; then else HIST_LIBDIR='$(dot)/$(LIBSUBDIR)/readline' HISTORY_DEP='$(HISTORY_LIBRARY)' + # for dependencies + HIST_INCLUDEDIR='$(HIST_LIBDIR)' # section for OS versions that ship an older version of # readline as a standard dynamic library and don't allow a # static version specified as -llibname to override the @@ -654,6 +670,7 @@ if test $opt_history = yes || test $opt_bang_history = yes; then else HIST_LIBDIR='$(dot)/$(LIBSUBDIR)/readline' HISTORY_LIB= HISTORY_DEP= + HIST_INCLUDEDIR= fi AC_SUBST(READLINE_LIB) AC_SUBST(READLINE_DEP) @@ -663,6 +680,7 @@ AC_SUBST(RL_INCLUDE) AC_SUBST(HISTORY_LIB) AC_SUBST(HISTORY_DEP) AC_SUBST(HIST_LIBDIR) +AC_SUBST(HIST_INCLUDEDIR) AC_SUBST(TILDE_LIB) dnl END READLINE and HISTORY LIBRARY SECTION @@ -677,6 +695,9 @@ AC_PROG_RANLIB AC_PROG_YACC AC_PROG_MAKE_SET +AM_PROG_INSTALL_SH +AM_PROG_INSTALL_STRIP + case "$ac_cv_prog_YACC" in *bison*) ;; *) AC_MSG_WARN([bison not available; needed to process parse.y]) ;; @@ -714,16 +735,18 @@ m4_include([m4/stat-time.m4]) m4_include([m4/timespec.m4]) m4_include([m4/strtoimax.m4]) +m4_include([m4/unlocked-io.m4]) dnl include files for gettext m4_include([m4/codeset.m4]) m4_include([m4/extern-inline.m4]) + +m4_include([m4/bison.m4]) m4_include([m4/fcntl-o.m4]) +m4_include([m4/flexmember.m4]) m4_include([m4/gettext.m4]) m4_include([m4/glibc2.m4]) -m4_include([m4/glibc21.m4]) -m4_include([m4/host-cpu-c-abi.m4]) m4_include([m4/iconv.m4]) m4_include([m4/intdiv0.m4]) m4_include([m4/intl.m4]) @@ -737,6 +760,7 @@ m4_include([m4/lcmessage.m4]) m4_include([m4/lib-ld.m4]) m4_include([m4/lib-link.m4]) m4_include([m4/lib-prefix.m4]) +m4_include([m4/locale_h.m4]) m4_include([m4/lock.m4]) m4_include([m4/nls.m4]) m4_include([m4/po.m4]) @@ -753,19 +777,27 @@ m4_include([m4/wchar_t.m4]) m4_include([m4/wint_t.m4]) m4_include([m4/xsize.m4]) +m4_include([m4/glibc21.m4]) +m4_include([m4/host-cpu-c-abi.m4]) + +m4_include([m4/c-bool.m4]) +m4_include([m4/d-type.m4]) + dnl C compiler characteristics AC_C_CONST AC_C_INLINE AC_C_BIGENDIAN AC_C_STRINGIZE AC_TYPE_LONG_DOUBLE -AC_C_PROTOTYPES AC_C_CHAR_UNSIGNED AC_C_VOLATILE AC_C_RESTRICT +gl_C_BOOL + dnl initialize GNU gettext -BASH_GNU_GETTEXT([no-libtool], [need-ngettext], [lib/intl]) +dnl the use-libtool is a lie, we just use the standard Unix tools +BASH_GNU_GETTEXT([use-libtool], [need-ngettext], [lib/intl]) dnl header files AC_HEADER_DIRENT @@ -773,9 +805,10 @@ AC_HEADER_MAJOR BASH_HEADER_INTTYPES -AC_CHECK_HEADERS(unistd.h stdlib.h stdarg.h varargs.h limits.h string.h \ +AC_CHECK_HEADERS(unistd.h stdlib.h varargs.h limits.h string.h \ memory.h locale.h termcap.h termio.h termios.h dlfcn.h \ - stdbool.h stddef.h stdint.h netdb.h pwd.h grp.h strings.h \ + stddef.h stdint.h netdb.h pwd.h grp.h strings.h \ + stdckdint.h \ regex.h syslog.h ulimit.h) AC_CHECK_HEADERS(sys/pte.h sys/stream.h sys/select.h sys/file.h sys/ioctl.h \ sys/mman.h sys/param.h sys/random.h sys/socket.h sys/stat.h \ @@ -842,35 +875,43 @@ AC_CHECK_FUNC(mkfifo, AC_DEFINE(HAVE_MKFIFO), AC_DEFINE(MKFIFO_MISSING)) dnl checks for system calls AC_CHECK_FUNCS(dup2 eaccess fcntl getdtablesize getentropy getgroups \ gethostname getpagesize getpeername getrandom getrlimit \ - getrusage gettimeofday kill killpg lstat pselect readlink \ - select setdtablesize setitimer tcgetpgrp uname ulimit waitpid) + getrusage gettimeofday kill killpg lstat nanosleep \ + pselect readlink \ + select setdtablesize setitimer statfs \ + tcgetpgrp uname ulimit waitpid) AC_REPLACE_FUNCS(rename) dnl checks for c library functions -AC_CHECK_FUNCS(bcopy bzero confstr faccessat fnmatch \ +AC_CHECK_FUNCS(bcopy bzero clock_gettime confstr faccessat fnmatch \ getaddrinfo gethostbyname getservbyname getservent inet_aton \ imaxdiv memmove pathconf putenv raise random regcomp regexec \ setenv setlinebuf setlocale setvbuf siginterrupt strchr \ - sysconf syslog tcgetattr times ttyname tzset unsetenv) + sysconf syslog tcgetattr tcgetwinsize tcsetwinsize \ + times ttyname tzset unsetenv) AC_CHECK_FUNCS(vasprintf asprintf) AC_CHECK_FUNCS(isascii isblank isgraph isprint isspace isxdigit) AC_CHECK_FUNCS(getpwent getpwnam getpwuid) AC_CHECK_FUNCS(mkstemp mkdtemp) AC_CHECK_FUNCS(arc4random) +AC_CHECK_FUNCS(strlcat) + +AC_CHECK_FUNCS(memfd_create shm_open shm_mkstemp) AC_REPLACE_FUNCS(getcwd memset) AC_REPLACE_FUNCS(strcasecmp strcasestr strerror strftime strnlen strpbrk strstr) AC_REPLACE_FUNCS(strtod strtol strtoul strtoll strtoull strtoumax) AC_REPLACE_FUNCS(dprintf) -AC_REPLACE_FUNCS(strchrnul) AC_REPLACE_FUNCS(strdup) +AC_REPLACE_FUNCS(strlcpy) +AC_REPLACE_FUNCS(reallocarray) AC_CHECK_HEADERS(libaudit.h) AC_CHECK_DECLS([AUDIT_USER_TTY],,, [[#include ]]) AC_CHECK_DECLS([confstr]) AC_CHECK_DECLS([printf]) +AC_CHECK_DECLS([brk]) AC_CHECK_DECLS([sbrk]) AC_CHECK_DECLS([setregid]) AC_CHECK_DECLS([strcpy]) @@ -912,8 +953,10 @@ dnl AC_CHECK_HEADERS([argz.h errno.h fcntl.h malloc.h stdio_ext.h]) dnl AC_FUNC_MALLOC +AC_DEFINE([HAVE_MALLOC]) AC_FUNC_MMAP -AC_CHECK_FUNCS([__argz_count __argz_next __argz_stringify dcgettext mempcpy \ +AC_CHECK_FUNCS([__argz_count __argz_next __argz_stringify dcgettext \ + locale_charset mempcpy \ munmap mremap stpcpy strcspn]) INTL_DEP= INTL_INC= LIBINTL_H= @@ -921,6 +964,8 @@ if test "x$USE_INCLUDED_LIBINTL" = "xyes"; then INTL_DEP='${INTL_LIBDIR}/libintl.a' INTL_INC='-I${INTL_LIBSRC} -I${INTL_BUILDDIR}' LIBINTL_H='${INTL_BUILDDIR}/libintl.h' + + AC_DEFINE([HAVE_LOCALE_CHARSET], 1) fi AC_SUBST(INTL_DEP) AC_SUBST(INTL_INC) @@ -965,6 +1010,7 @@ AC_TYPE_MODE_T AC_TYPE_UID_T AC_TYPE_PID_T AC_TYPE_SIZE_T +AC_TYPE_INTPTR_T AC_TYPE_UINTPTR_T AC_CHECK_TYPE(ssize_t, int) @@ -984,9 +1030,6 @@ AC_CHECK_SIZEOF(size_t, 4) AC_CHECK_SIZEOF(double, 8) AC_CHECK_SIZEOF([long long], 8) -AC_CHECK_TYPE(u_int, [unsigned int]) -AC_CHECK_TYPE(u_long, [unsigned long]) - BASH_TYPE_BITS16_T BASH_TYPE_U_BITS16_T BASH_TYPE_BITS32_T @@ -1009,6 +1052,8 @@ if test "$ac_cv_func_lstat" = "no"; then BASH_FUNC_LSTAT fi +BASH_FUNC_STRCHRNUL + dnl behavior of system calls and library functions BASH_FUNC_DUP2_CLOEXEC_CHECK BASH_SYS_PGRP_SYNC @@ -1040,6 +1085,7 @@ BASH_STRUCT_TERMIO_LDISC BASH_STRUCT_DIRENT_D_INO BASH_STRUCT_DIRENT_D_FILENO BASH_STRUCT_DIRENT_D_NAMLEN +gl_CHECK_TYPE_STRUCT_DIRENT_D_TYPE BASH_STRUCT_WINSIZE BASH_STRUCT_TIMEVAL AC_CHECK_MEMBERS([struct stat.st_blocks]) @@ -1054,6 +1100,7 @@ BASH_STAT_TIME dnl checks for system calls BASH_FUNC_SBRK +BASH_FUNC_BRK dnl presence and behavior of C library functions BASH_FUNC_STRSIGNAL @@ -1064,12 +1111,15 @@ BASH_FUNC_GETENV if test "$ac_cv_func_getcwd" = "yes"; then BASH_FUNC_GETCWD fi +dnl either way this is correct +AC_DEFINE([HAVE_GETCWD]) BASH_FUNC_POSIX_SETJMP BASH_FUNC_STRCOLL BASH_FUNC_SNPRINTF BASH_FUNC_VSNPRINTF BASH_FUNC_STRTOIMAX +BASH_FUNC_UNLOCKED_IO dnl If putenv or unsetenv is not present, set the right define so the dnl prototype and declaration in lib/sh/getenv.c will be standard-conformant @@ -1180,7 +1230,7 @@ freebsd*|midnightbsd*) LOCAL_CFLAGS='-DHEREDOC_PIPESIZE=4096' ;; *qnx[[67]]*) LOCAL_LIBS="-lncurses" ;; *qnx*) LOCAL_CFLAGS="-Dqnx -F -3s" LOCAL_LDFLAGS="-3s" LOCAL_LIBS="-lunix -lncurses" ;; powerux*) LOCAL_LIBS="-lgen" ;; -cygwin*) LOCAL_CFLAGS=-DRECYCLES_PIDS ;; +cygwin*|msys*) LOCAL_CFLAGS=-DRECYCLES_PIDS ;; opennt*|interix*) LOCAL_CFLAGS="-DNO_MAIN_ENV_ARG -DBROKEN_DIRENT_D_INO -D_POSIX_SOURCE -D_ALL_SOURCE -DRECYCLES_PIDS" ;; *openstep*) LOCAL_CFLAGS="-D__APPLE_CC__" ;; esac @@ -1200,7 +1250,9 @@ freebsd[[3-9]]*) if test -x /usr/bin/objformat && test "`/usr/bin/objformat`" = "elf" ; then LOCAL_LDFLAGS=-rdynamic # allow dynamic loading fi ;; -freebsdelf*) LOCAL_LDFLAGS=-rdynamic ;; # allow dynamic loading +freebsd*) LOCAL_LDFLAGS=-rdynamic ;; # allow dynamic loading +openbsd*) LOCAL_LDFLAGS=-rdynamic ;; # allow dynamic loading +netbsd*) LOCAL_LDFLAGS=-rdynamic ;; # allow dynamic loading dragonfly*) LOCAL_LDFLAGS=-rdynamic ;; # allow dynamic loading midnightbsd*) LOCAL_LDFLAGS=-rdynamic ;; # allow dynamic loading esac @@ -1323,4 +1375,16 @@ AC_CONFIG_FILES([Makefile builtins/Makefile lib/readline/Makefile \ dnl Makefile uses this timestamp file to record whether config.h is up to date. AC_CONFIG_COMMANDS([stamp-h], [echo timestamp > stamp-h]) +if test "$ac_cv_header_stdckdint_h" = yes; then + rm -f stdckdint.h + STDCKDINT_H= +elif cmp ${srcdir}/include/stdckdint.in.h stdckdint.h 2>/dev/null; then + : + STDCKDINT_H='${BUILD_DIR}/stdckdint.h' +else + cp ${srcdir}/include/stdckdint.in.h stdckdint.h + STDCKDINT_H='${BUILD_DIR}/stdckdint.h' +fi +AC_SUBST(STDCKDINT_H) + AC_OUTPUT diff --git a/copy_cmd.c b/copy_cmd.c index 758ff238a..6426c016f 100644 --- a/copy_cmd.c +++ b/copy_cmd.c @@ -2,7 +2,7 @@ primarily for making function definitions, but I'm not sure that anyone else will need it. */ -/* Copyright (C) 1987-2020 Free Software Foundation, Inc. +/* Copyright (C) 1987-2020,2022 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -32,29 +32,28 @@ #include "shell.h" -static PATTERN_LIST *copy_case_clause PARAMS((PATTERN_LIST *)); -static PATTERN_LIST *copy_case_clauses PARAMS((PATTERN_LIST *)); -static FOR_COM *copy_for_command PARAMS((FOR_COM *)); +static PATTERN_LIST *copy_case_clause (PATTERN_LIST *); +static PATTERN_LIST *copy_case_clauses (PATTERN_LIST *); +static FOR_COM *copy_for_command (FOR_COM *); #if defined (ARITH_FOR_COMMAND) -static ARITH_FOR_COM *copy_arith_for_command PARAMS((ARITH_FOR_COM *)); +static ARITH_FOR_COM *copy_arith_for_command (ARITH_FOR_COM *); #endif -static GROUP_COM *copy_group_command PARAMS((GROUP_COM *)); -static SUBSHELL_COM *copy_subshell_command PARAMS((SUBSHELL_COM *)); -static COPROC_COM *copy_coproc_command PARAMS((COPROC_COM *)); -static CASE_COM *copy_case_command PARAMS((CASE_COM *)); -static WHILE_COM *copy_while_command PARAMS((WHILE_COM *)); -static IF_COM *copy_if_command PARAMS((IF_COM *)); +static GROUP_COM *copy_group_command (GROUP_COM *); +static SUBSHELL_COM *copy_subshell_command (SUBSHELL_COM *); +static COPROC_COM *copy_coproc_command (COPROC_COM *); +static CASE_COM *copy_case_command (CASE_COM *); +static WHILE_COM *copy_while_command (WHILE_COM *); +static IF_COM *copy_if_command (IF_COM *); #if defined (DPAREN_ARITHMETIC) -static ARITH_COM *copy_arith_command PARAMS((ARITH_COM *)); +static ARITH_COM *copy_arith_command (ARITH_COM *); #endif #if defined (COND_COMMAND) -static COND_COM *copy_cond_command PARAMS((COND_COM *)); +static COND_COM *copy_cond_command (COND_COM *); #endif -static SIMPLE_COM *copy_simple_command PARAMS((SIMPLE_COM *)); +static SIMPLE_COM *copy_simple_command (SIMPLE_COM *); WORD_DESC * -copy_word (w) - WORD_DESC *w; +copy_word (WORD_DESC *w) { WORD_DESC *new_word; @@ -66,8 +65,7 @@ copy_word (w) /* Copy the chain of words in LIST. Return a pointer to the new chain. */ WORD_LIST * -copy_word_list (list) - WORD_LIST *list; +copy_word_list (WORD_LIST *list) { WORD_LIST *new_list, *tl; @@ -86,8 +84,7 @@ copy_word_list (list) } static PATTERN_LIST * -copy_case_clause (clause) - PATTERN_LIST *clause; +copy_case_clause (PATTERN_LIST *clause) { PATTERN_LIST *new_clause; @@ -99,8 +96,7 @@ copy_case_clause (clause) } static PATTERN_LIST * -copy_case_clauses (clauses) - PATTERN_LIST *clauses; +copy_case_clauses (PATTERN_LIST *clauses) { PATTERN_LIST *new_list, *new_clause; @@ -115,17 +111,12 @@ copy_case_clauses (clauses) /* Copy a single redirect. */ REDIRECT * -copy_redirect (redirect) - REDIRECT *redirect; +copy_redirect (REDIRECT *redirect) { REDIRECT *new_redirect; new_redirect = (REDIRECT *)xmalloc (sizeof (REDIRECT)); -#if 0 - FASTCOPY ((char *)redirect, (char *)new_redirect, (sizeof (REDIRECT))); -#else *new_redirect = *redirect; /* let the compiler do the fast structure copy */ -#endif if (redirect->rflags & REDIR_VARASSIGN) new_redirect->redirector.filename = copy_word (redirect->redirector.filename); @@ -162,8 +153,7 @@ copy_redirect (redirect) } REDIRECT * -copy_redirects (list) - REDIRECT *list; +copy_redirects (REDIRECT *list) { REDIRECT *new_list, *temp; @@ -177,8 +167,7 @@ copy_redirects (list) } static FOR_COM * -copy_for_command (com) - FOR_COM *com; +copy_for_command (FOR_COM *com) { FOR_COM *new_for; @@ -193,8 +182,7 @@ copy_for_command (com) #if defined (ARITH_FOR_COMMAND) static ARITH_FOR_COM * -copy_arith_for_command (com) - ARITH_FOR_COM *com; +copy_arith_for_command (ARITH_FOR_COM *com) { ARITH_FOR_COM *new_arith_for; @@ -210,8 +198,7 @@ copy_arith_for_command (com) #endif /* ARITH_FOR_COMMAND */ static GROUP_COM * -copy_group_command (com) - GROUP_COM *com; +copy_group_command (GROUP_COM *com) { GROUP_COM *new_group; @@ -221,8 +208,7 @@ copy_group_command (com) } static SUBSHELL_COM * -copy_subshell_command (com) - SUBSHELL_COM *com; +copy_subshell_command (SUBSHELL_COM *com) { SUBSHELL_COM *new_subshell; @@ -234,8 +220,7 @@ copy_subshell_command (com) } static COPROC_COM * -copy_coproc_command (com) - COPROC_COM *com; +copy_coproc_command (COPROC_COM *com) { COPROC_COM *new_coproc; @@ -247,8 +232,7 @@ copy_coproc_command (com) } static CASE_COM * -copy_case_command (com) - CASE_COM *com; +copy_case_command (CASE_COM *com) { CASE_COM *new_case; @@ -261,8 +245,7 @@ copy_case_command (com) } static WHILE_COM * -copy_while_command (com) - WHILE_COM *com; +copy_while_command (WHILE_COM *com) { WHILE_COM *new_while; @@ -274,8 +257,7 @@ copy_while_command (com) } static IF_COM * -copy_if_command (com) - IF_COM *com; +copy_if_command (IF_COM *com) { IF_COM *new_if; @@ -289,8 +271,7 @@ copy_if_command (com) #if defined (DPAREN_ARITHMETIC) static ARITH_COM * -copy_arith_command (com) - ARITH_COM *com; +copy_arith_command (ARITH_COM *com) { ARITH_COM *new_arith; @@ -305,8 +286,7 @@ copy_arith_command (com) #if defined (COND_COMMAND) static COND_COM * -copy_cond_command (com) - COND_COM *com; +copy_cond_command (COND_COM *com) { COND_COM *new_cond; @@ -323,8 +303,7 @@ copy_cond_command (com) #endif static SIMPLE_COM * -copy_simple_command (com) - SIMPLE_COM *com; +copy_simple_command (SIMPLE_COM *com) { SIMPLE_COM *new_simple; @@ -337,8 +316,7 @@ copy_simple_command (com) } FUNCTION_DEF * -copy_function_def_contents (old, new_def) - FUNCTION_DEF *old, *new_def; +copy_function_def_contents (FUNCTION_DEF *old, FUNCTION_DEF *new_def) { new_def->name = copy_word (old->name); new_def->command = old->command ? copy_command (old->command) : old->command; @@ -349,8 +327,7 @@ copy_function_def_contents (old, new_def) } FUNCTION_DEF * -copy_function_def (com) - FUNCTION_DEF *com; +copy_function_def (FUNCTION_DEF *com) { FUNCTION_DEF *new_def; @@ -363,8 +340,7 @@ copy_function_def (com) copy. Don't you forget to dispose_command () on this pointer later! */ COMMAND * -copy_command (command) - COMMAND *command; +copy_command (COMMAND *command) { COMMAND *new_command; diff --git a/cross-build/msys32.cache b/cross-build/msys32.cache new file mode 100644 index 000000000..7d9f257de --- /dev/null +++ b/cross-build/msys32.cache @@ -0,0 +1,251 @@ +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overriden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +ac_cv_build=${ac_cv_build='i686-pc-msys'} +ac_cv_build_alias=${ac_cv_build_alias='i686-pc-msys'} +ac_cv_c_bigendian=${ac_cv_c_bigendian='no'} +ac_cv_c_char_unsigned=${ac_cv_c_char_unsigned='no'} +ac_cv_c_compiler_gnu=${ac_cv_c_compiler_gnu='yes'} +ac_cv_c_const=${ac_cv_c_const='yes'} +ac_cv_c_inline=${ac_cv_c_inline='inline'} +ac_cv_c_long_double=${ac_cv_c_long_double='yes'} +ac_cv_c_stringize=${ac_cv_c_stringize='yes'} +ac_cv_decl_sys_siglist=${ac_cv_decl_sys_siglist='no'} +ac_cv_exeext=${ac_cv_exeext='.exe'} +ac_cv_func___setostype=${ac_cv_func___setostype='no'} +ac_cv_func__doprnt=${ac_cv_func__doprnt='no'} +ac_cv_func_alloca_works=${ac_cv_func_alloca_works='yes'} +ac_cv_func_asprintf=${ac_cv_func_asprintf='no'} +ac_cv_func_bcopy=${ac_cv_func_bcopy='yes'} +ac_cv_func_bindtextdomain=${ac_cv_func_bindtextdomain='no'} +ac_cv_func_bzero=${ac_cv_func_bzero='yes'} +ac_cv_func_confstr=${ac_cv_func_confstr='no'} +ac_cv_func_dlclose=${ac_cv_func_dlclose='yes'} +ac_cv_func_dlopen=${ac_cv_func_dlopen='yes'} +ac_cv_func_dlsym=${ac_cv_func_dlsym='yes'} +ac_cv_func_dup2=${ac_cv_func_dup2='yes'} +ac_cv_func_fnmatch=${ac_cv_func_fnmatch='no'} +ac_cv_func_getaddrinfo=${ac_cv_func_getaddrinfo='no'} +ac_cv_func_getcwd=${ac_cv_func_getcwd='yes'} +ac_cv_func_getdtablesize=${ac_cv_func_getdtablesize='yes'} +ac_cv_func_getgroups=${ac_cv_func_getgroups='yes'} +ac_cv_func_gethostbyname=${ac_cv_func_gethostbyname='yes'} +ac_cv_func_gethostname=${ac_cv_func_gethostname='yes'} +ac_cv_func_getpagesize=${ac_cv_func_getpagesize='yes'} +ac_cv_func_getpeername=${ac_cv_func_getpeername='yes'} +ac_cv_func_getpgrp_void=${ac_cv_func_getpgrp_void='yes'} +ac_cv_func_getrlimit=${ac_cv_func_getrlimit='yes'} +ac_cv_func_getrusage=${ac_cv_func_getrusage='yes'} +ac_cv_func_getservbyname=${ac_cv_func_getservbyname='yes'} +ac_cv_func_gettext=${ac_cv_func_gettext='no'} +ac_cv_func_gettimeofday=${ac_cv_func_gettimeofday='yes'} +ac_cv_func_inet_aton=${ac_cv_func_inet_aton='yes'} +ac_cv_func_isascii=${ac_cv_func_isascii='yes'} +ac_cv_func_isblank=${ac_cv_func_isblank='no'} +ac_cv_func_isgraph=${ac_cv_func_isgraph='yes'} +ac_cv_func_isprint=${ac_cv_func_isprint='yes'} +ac_cv_func_isspace=${ac_cv_func_isspace='yes'} +ac_cv_func_isxdigit=${ac_cv_func_isxdigit='yes'} +ac_cv_func_killpg=${ac_cv_func_killpg='yes'} +ac_cv_func_lstat=${ac_cv_func_lstat='yes'} +ac_cv_func_memmove=${ac_cv_func_memmove='yes'} +ac_cv_func_mkfifo=${ac_cv_func_mkfifo='yes'} +ac_cv_func_pathconf=${ac_cv_func_pathconf='yes'} +ac_cv_func_putenv=${ac_cv_func_putenv='yes'} +ac_cv_func_readlink=${ac_cv_func_readlink='yes'} +ac_cv_func_rename=${ac_cv_func_rename='yes'} +ac_cv_func_sbrk=${ac_cv_func_sbrk='yes'} +ac_cv_func_select=${ac_cv_func_select='yes'} +ac_cv_func_setdtablesize=${ac_cv_func_setdtablesize='yes'} +ac_cv_func_setenv=${ac_cv_func_setenv='yes'} +ac_cv_func_setlinebuf=${ac_cv_func_setlinebuf='no'} +ac_cv_func_setlocale=${ac_cv_func_setlocale='yes'} +ac_cv_func_setvbuf=${ac_cv_func_setvbuf='yes'} +ac_cv_func_setvbuf_reversed=${ac_cv_func_setvbuf_reversed='no'} +ac_cv_func_siginterrupt=${ac_cv_func_siginterrupt='no'} +ac_cv_func_snprintf=${ac_cv_func_snprintf='yes'} +ac_cv_func_strcasecmp=${ac_cv_func_strcasecmp='yes'} +ac_cv_func_strchr=${ac_cv_func_strchr='yes'} +ac_cv_func_strcoll_works=${ac_cv_func_strcoll_works='yes'} +ac_cv_func_strerror=${ac_cv_func_strerror='yes'} +ac_cv_func_strpbrk=${ac_cv_func_strpbrk='yes'} +ac_cv_func_strtod=${ac_cv_func_strtod='yes'} +ac_cv_func_strtoimax=${ac_cv_func_strtoimax='no'} +ac_cv_func_strtol=${ac_cv_func_strtol='yes'} +ac_cv_func_strtoll=${ac_cv_func_strtoll='no'} +ac_cv_func_strtoul=${ac_cv_func_strtoul='yes'} +ac_cv_func_strtoull=${ac_cv_func_strtoull='no'} +ac_cv_func_strtoumax=${ac_cv_func_strtoumax='no'} +ac_cv_func_sysconf=${ac_cv_func_sysconf='yes'} +ac_cv_func_tcgetattr=${ac_cv_func_tcgetattr='yes'} +ac_cv_func_tcgetpgrp=${ac_cv_func_tcgetpgrp='yes'} +ac_cv_func_textdomain=${ac_cv_func_textdomain='no'} +ac_cv_func_times=${ac_cv_func_times='yes'} +ac_cv_func_ttyname=${ac_cv_func_ttyname='yes'} +ac_cv_func_tzset=${ac_cv_func_tzset='yes'} +ac_cv_func_ulimit=${ac_cv_func_ulimit='no'} +ac_cv_func_uname=${ac_cv_func_uname='yes'} +ac_cv_func_vasprintf=${ac_cv_func_vasprintf='no'} +ac_cv_func_vprintf=${ac_cv_func_vprintf='yes'} +ac_cv_func_vsnprintf=${ac_cv_func_vsnprintf='yes'} +ac_cv_func_wait3=${ac_cv_func_wait3='yes'} +ac_cv_func_waitpid=${ac_cv_func_waitpid='yes'} +ac_cv_have_decl_confstr=${ac_cv_have_decl_confstr='no'} +ac_cv_have_decl_printf=${ac_cv_have_decl_printf='yes'} +ac_cv_have_decl_sbrk=${ac_cv_have_decl_sbrk='yes'} +ac_cv_have_decl_strsignal=${ac_cv_have_decl_strsignal='yes'} +ac_cv_have_decl_strtold=${ac_cv_have_decl_strtold='no'} +ac_cv_header_arpa_inet_h=${ac_cv_header_arpa_inet_h='yes'} +ac_cv_header_dirent_dirent_h=${ac_cv_header_dirent_dirent_h='yes'} +ac_cv_header_dlfcn_h=${ac_cv_header_dlfcn_h='yes'} +ac_cv_header_grp_h=${ac_cv_header_grp_h='yes'} +ac_cv_header_inttypes_h=${ac_cv_header_inttypes_h='no'} +ac_cv_header_libintl_h=${ac_cv_header_libintl_h='yes'} +ac_cv_header_limits_h=${ac_cv_header_limits_h='yes'} +ac_cv_header_locale_h=${ac_cv_header_locale_h='yes'} +ac_cv_header_memory_h=${ac_cv_header_memory_h='yes'} +ac_cv_header_minix_config_h=${ac_cv_header_minix_config_h='no'} +ac_cv_header_netdb_h=${ac_cv_header_netdb_h='yes'} +ac_cv_header_netinet_in_h=${ac_cv_header_netinet_in_h='yes'} +ac_cv_header_stat_broken=${ac_cv_header_stat_broken='no'} +ac_cv_header_stdarg_h=${ac_cv_header_stdarg_h='yes'} +ac_cv_header_stdc=${ac_cv_header_stdc='yes'} +ac_cv_header_stddef_h=${ac_cv_header_stddef_h='yes'} +ac_cv_header_stdint_h=${ac_cv_header_stdint_h='no'} +ac_cv_header_stdlib_h=${ac_cv_header_stdlib_h='yes'} +ac_cv_header_string_h=${ac_cv_header_string_h='yes'} +ac_cv_header_strings_h=${ac_cv_header_strings_h='yes'} +ac_cv_header_sys_file_h=${ac_cv_header_sys_file_h='yes'} +ac_cv_header_sys_param_h=${ac_cv_header_sys_param_h='yes'} +ac_cv_header_sys_pte_h=${ac_cv_header_sys_pte_h='no'} +ac_cv_header_sys_ptem_h=${ac_cv_header_sys_ptem_h='no'} +ac_cv_header_sys_resource_h=${ac_cv_header_sys_resource_h='yes'} +ac_cv_header_sys_select_h=${ac_cv_header_sys_select_h='yes'} +ac_cv_header_sys_socket_h=${ac_cv_header_sys_socket_h='yes'} +ac_cv_header_sys_stat_h=${ac_cv_header_sys_stat_h='yes'} +ac_cv_header_sys_stream_h=${ac_cv_header_sys_stream_h='no'} +ac_cv_header_sys_time_h=${ac_cv_header_sys_time_h='yes'} +ac_cv_header_sys_times_h=${ac_cv_header_sys_times_h='yes'} +ac_cv_header_sys_types_h=${ac_cv_header_sys_types_h='yes'} +ac_cv_header_sys_wait_h=${ac_cv_header_sys_wait_h='yes'} +ac_cv_header_termcap_h=${ac_cv_header_termcap_h='yes'} +ac_cv_header_termio_h=${ac_cv_header_termio_h='yes'} +ac_cv_header_termios_h=${ac_cv_header_termios_h='yes'} +ac_cv_header_time=${ac_cv_header_time='yes'} +ac_cv_header_unistd_h=${ac_cv_header_unistd_h='yes'} +ac_cv_header_varargs_h=${ac_cv_header_varargs_h='yes'} +ac_cv_host=${ac_cv_host='i686-pc-msys'} +ac_cv_host_alias=${ac_cv_host_alias='i686-pc-msys'} +ac_cv_lib_dir_opendir=${ac_cv_lib_dir_opendir='no'} +ac_cv_lib_dl_dlopen=${ac_cv_lib_dl_dlopen='no'} +ac_cv_lib_intl_bindtextdomain=${ac_cv_lib_intl_bindtextdomain='yes'} +ac_cv_lib_termcap_tgetent=${ac_cv_lib_termcap_tgetent='yes'} +ac_cv_member_struct_stat_st_blocks=${ac_cv_member_struct_stat_st_blocks='yes'} +ac_cv_member_struct_termio_c_line=${ac_cv_member_struct_termio_c_line='yes'} +ac_cv_member_struct_termios_c_line=${ac_cv_member_struct_termios_c_line='yes'} +ac_cv_objext=${ac_cv_objext='o'} +ac_cv_path_install=${ac_cv_path_install='/usr/bin/install -c'} +ac_cv_prog_AR=${ac_cv_prog_AR='ar'} +ac_cv_prog_CPP=${ac_cv_prog_CPP='gcc -E'} +ac_cv_prog_YACC=${ac_cv_prog_YACC='bison -y'} +ac_cv_prog_ac_ct_CC=${ac_cv_prog_ac_ct_CC='gcc'} +ac_cv_prog_ac_ct_RANLIB=${ac_cv_prog_ac_ct_RANLIB='ranlib'} +ac_cv_prog_cc_g=${ac_cv_prog_cc_g='yes'} +ac_cv_prog_cc_stdc=${ac_cv_prog_cc_stdc=''} +ac_cv_prog_gcc_traditional=${ac_cv_prog_gcc_traditional='no'} +ac_cv_prog_make_make_set=${ac_cv_prog_make_make_set='yes'} +ac_cv_sizeof_char=${ac_cv_sizeof_char='1'} +ac_cv_sizeof_char_p=${ac_cv_sizeof_char_p='4'} +ac_cv_sizeof_double=${ac_cv_sizeof_double='8'} +ac_cv_sizeof_int=${ac_cv_sizeof_int='4'} +ac_cv_sizeof_long=${ac_cv_sizeof_long='4'} +ac_cv_sizeof_long_long=${ac_cv_sizeof_long_long='8'} +ac_cv_sizeof_short=${ac_cv_sizeof_short='2'} +ac_cv_sys_file_offset_bits=${ac_cv_sys_file_offset_bits='no'} +ac_cv_sys_interpreter=${ac_cv_sys_interpreter='yes'} +ac_cv_sys_large_files=${ac_cv_sys_large_files='no'} +ac_cv_sys_largefile_CC=${ac_cv_sys_largefile_CC='no'} +ac_cv_sys_posix_termios=${ac_cv_sys_posix_termios='yes'} +ac_cv_sys_tiocgwinsz_in_termios_h=${ac_cv_sys_tiocgwinsz_in_termios_h='yes'} +ac_cv_type_bits16_t=${ac_cv_type_bits16_t='no'} +ac_cv_type_bits32_t=${ac_cv_type_bits32_t='no'} +ac_cv_type_bits64_t=${ac_cv_type_bits64_t='no'} +ac_cv_type_char=${ac_cv_type_char='yes'} +ac_cv_type_char_p=${ac_cv_type_char_p='yes'} +ac_cv_type_double=${ac_cv_type_double='yes'} +ac_cv_type_getgroups=${ac_cv_type_getgroups='gid_t'} +ac_cv_type_int=${ac_cv_type_int='yes'} +ac_cv_type_long=${ac_cv_type_long='yes'} +ac_cv_type_long_long=${ac_cv_type_long_long='yes'} +ac_cv_type_mode_t=${ac_cv_type_mode_t='yes'} +ac_cv_type_off_t=${ac_cv_type_off_t='yes'} +ac_cv_type_pid_t=${ac_cv_type_pid_t='yes'} +ac_cv_type_ptrdiff_t=${ac_cv_type_ptrdiff_t='yes'} +ac_cv_type_short=${ac_cv_type_short='yes'} +ac_cv_type_signal=${ac_cv_type_signal='void'} +ac_cv_type_size_t=${ac_cv_type_size_t='yes'} +ac_cv_type_ssize_t=${ac_cv_type_ssize_t='yes'} +ac_cv_type_time_t=${ac_cv_type_time_t='yes'} +ac_cv_type_u_bits16_t=${ac_cv_type_u_bits16_t='no'} +ac_cv_type_u_bits32_t=${ac_cv_type_u_bits32_t='no'} +ac_cv_type_u_int=${ac_cv_type_u_int='yes'} +ac_cv_type_u_long=${ac_cv_type_u_long='yes'} +ac_cv_type_uid_t=${ac_cv_type_uid_t='yes'} +ac_cv_working_alloca_h=${ac_cv_working_alloca_h='no'} + +bash_cv_decl_strtoimax=${bash_cv_decl_strtoimax='no'} +bash_cv_decl_strtol=${bash_cv_decl_strtol='yes'} +bash_cv_decl_strtoll=${bash_cv_decl_strtoll='no'} +bash_cv_decl_strtoul=${bash_cv_decl_strtoul='yes'} +bash_cv_decl_strtoull=${bash_cv_decl_strtoull='no'} +bash_cv_decl_strtoumax=${bash_cv_decl_strtoumax='no'} +bash_cv_decl_under_sys_siglist=${bash_cv_decl_under_sys_siglist='no'} +bash_cv_dev_fd=${bash_cv_dev_fd='absent'} +bash_cv_dev_stdin=${bash_cv_dev_stdin='absent'} +bash_cv_dirent_has_d_fileno=${bash_cv_dirent_has_d_fileno='no'} +bash_cv_dirent_has_dino=${bash_cv_dirent_has_dino='yes'} +bash_cv_dup2_broken=${bash_cv_dup2_broken='no'} +bash_cv_fionread_in_ioctl=${bash_cv_fionread_in_ioctl='no'} +bash_cv_func_sigsetjmp=${bash_cv_func_sigsetjmp='present'} +bash_cv_func_strcoll_broken=${bash_cv_func_strcoll_broken='no'} +bash_cv_getenv_redef=${bash_cv_getenv_redef='yes'} +bash_cv_getpw_declared=${bash_cv_getpw_declared='yes'} +bash_cv_have_strsignal=${bash_cv_have_strsignal='yes'} +bash_cv_job_control_missing=${bash_cv_job_control_missing='present'} +bash_cv_mail_dir=${bash_cv_mail_dir='unknown'} +bash_cv_must_reinstall_sighandlers=${bash_cv_must_reinstall_sighandlers='no'} +bash_cv_opendir_not_robust=${bash_cv_opendir_not_robust='no'} +bash_cv_pgrp_pipe=${bash_cv_pgrp_pipe='no'} +bash_cv_printf_a_format=${bash_cv_printf_a_format='no'} +bash_cv_signal_vintage=${bash_cv_signal_vintage='posix'} +bash_cv_speed_t_in_sys_types=${bash_cv_speed_t_in_sys_types='no'} +bash_cv_struct_timeval=${bash_cv_struct_timeval='yes'} +bash_cv_struct_winsize_header=${bash_cv_struct_winsize_header='termios_h'} +bash_cv_sys_errlist=${bash_cv_sys_errlist='no'} +bash_cv_sys_named_pipes=${bash_cv_sys_named_pipes='present'} +bash_cv_sys_siglist=${bash_cv_sys_siglist='no'} +bash_cv_termcap_lib=${bash_cv_termcap_lib='libtermcap'} +bash_cv_tiocstat_in_ioctl=${bash_cv_tiocstat_in_ioctl='no'} +bash_cv_type_clock_t=${bash_cv_type_clock_t='yes'} +bash_cv_type_intmax_t=${bash_cv_type_intmax_t='no'} +bash_cv_type_long_long=${bash_cv_type_long_long='long long'} +bash_cv_type_quad_t=${bash_cv_type_quad_t='no'} +bash_cv_type_rlimit=${bash_cv_type_rlimit='rlim_t'} +bash_cv_type_sigset_t=${bash_cv_type_sigset_t='yes'} +bash_cv_type_socklen_t=${bash_cv_type_socklen_t='no'} +bash_cv_type_uintmax_t=${bash_cv_type_uintmax_t='no'} +bash_cv_type_unsigned_long_long=${bash_cv_type_unsigned_long_long='unsigned long long'} +bash_cv_ulimit_maxfds=${bash_cv_ulimit_maxfds='no'} +bash_cv_under_sys_siglist=${bash_cv_under_sys_siglist='no'} +bash_cv_unusable_rtsigs=${bash_cv_unusable_rtsigs='no'} +bash_cv_void_sighandler=${bash_cv_void_sighandler='yes'} diff --git a/dispose_cmd.c b/dispose_cmd.c index c624605b5..d2821fed7 100644 --- a/dispose_cmd.c +++ b/dispose_cmd.c @@ -1,6 +1,6 @@ /* dispose_command.c -- dispose of a COMMAND structure. */ -/* Copyright (C) 1987-2009 Free Software Foundation, Inc. +/* Copyright (C) 1987-2009,2022,2023 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -33,8 +33,7 @@ extern sh_obj_cache_t wdcache, wlcache; /* Dispose of the command structure passed. */ void -dispose_command (command) - COMMAND *command; +dispose_command (COMMAND *command) { if (command == 0) return; @@ -205,11 +204,16 @@ dispose_command (command) free (command); } +void +uw_dispose_command (void *command) +{ + dispose_command (command); +} + #if defined (COND_COMMAND) /* How to free a node in a conditional command. */ void -dispose_cond_node (cond) - COND_COM *cond; +dispose_cond_node (COND_COM *cond) { if (cond) { @@ -225,8 +229,7 @@ dispose_cond_node (cond) #endif /* COND_COMMAND */ void -dispose_function_def_contents (c) - FUNCTION_DEF *c; +dispose_function_def_contents (FUNCTION_DEF *c) { dispose_word (c->name); dispose_command (c->command); @@ -234,8 +237,7 @@ dispose_function_def_contents (c) } void -dispose_function_def (c) - FUNCTION_DEF *c; +dispose_function_def (FUNCTION_DEF *c) { dispose_function_def_contents (c); free (c); @@ -243,8 +245,7 @@ dispose_function_def (c) /* How to free a WORD_DESC. */ void -dispose_word (w) - WORD_DESC *w; +dispose_word (WORD_DESC *w) { FREE (w->word); ocache_free (wdcache, WORD_DESC, w); @@ -252,8 +253,7 @@ dispose_word (w) /* Free a WORD_DESC, but not the word contained within. */ void -dispose_word_desc (w) - WORD_DESC *w; +dispose_word_desc (WORD_DESC *w) { w->word = 0; ocache_free (wdcache, WORD_DESC, w); @@ -261,8 +261,7 @@ dispose_word_desc (w) /* How to get rid of a linked list of words. A WORD_LIST. */ void -dispose_words (list) - WORD_LIST *list; +dispose_words (WORD_LIST *list) { WORD_LIST *t; @@ -279,12 +278,17 @@ dispose_words (list) } } +void +uw_dispose_words (void *list) +{ + dispose_words (list); +} + #ifdef INCLUDE_UNUSED /* How to dispose of an array of pointers to char. This is identical to free_array in stringlib.c. */ void -dispose_word_array (array) - char **array; +dispose_word_array (char **array) { register int count; @@ -300,8 +304,7 @@ dispose_word_array (array) /* How to dispose of an list of redirections. A REDIRECT. */ void -dispose_redirects (list) - REDIRECT *list; +dispose_redirects (REDIRECT *list) { register REDIRECT *t; diff --git a/dispose_cmd.h b/dispose_cmd.h index 6095d44a4..5ac900aa5 100644 --- a/dispose_cmd.h +++ b/dispose_cmd.h @@ -1,6 +1,6 @@ /* dispose_cmd.h -- Functions appearing in dispose_cmd.c. */ -/* Copyright (C) 1993-2020 Free Software Foundation, Inc. +/* Copyright (C) 1993-2023 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -23,18 +23,21 @@ #include "stdc.h" -extern void dispose_command PARAMS((COMMAND *)); -extern void dispose_word_desc PARAMS((WORD_DESC *)); -extern void dispose_word PARAMS((WORD_DESC *)); -extern void dispose_words PARAMS((WORD_LIST *)); -extern void dispose_word_array PARAMS((char **)); -extern void dispose_redirects PARAMS((REDIRECT *)); +extern void dispose_command (COMMAND *); +extern void dispose_word_desc (WORD_DESC *); +extern void dispose_word (WORD_DESC *); +extern void dispose_words (WORD_LIST *); +extern void dispose_word_array (char **); +extern void dispose_redirects (REDIRECT *); #if defined (COND_COMMAND) -extern void dispose_cond_node PARAMS((COND_COM *)); +extern void dispose_cond_node (COND_COM *); #endif -extern void dispose_function_def_contents PARAMS((FUNCTION_DEF *)); -extern void dispose_function_def PARAMS((FUNCTION_DEF *)); +extern void dispose_function_def_contents (FUNCTION_DEF *); +extern void dispose_function_def (FUNCTION_DEF *); + +extern void uw_dispose_command (void *); +extern void uw_dispose_words (void *); #endif /* !_DISPOSE_CMD_H_ */ diff --git a/doc/Makefile.in b/doc/Makefile.in index 8bf775e14..b8ac13fc3 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -1,6 +1,6 @@ # This Makefile is for the Bash/documentation directory -*- text -*-. # -# Copyright (C) 2003-2015 Free Software Foundation, Inc. +# Copyright (C) 2003-2024 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -65,10 +65,6 @@ SUPPORT_SRCDIR = $(topdir)/support # bad style RL_LIBDIR = $(topdir)/lib/readline -# unused -TEXINDEX = texindex -TEX = tex - MAKEINFO = makeinfo TEXI2DVI = ${SUPPORT_SRCDIR}/texi2dvi TEXI2HTML = ${SUPPORT_SRCDIR}/texi2html @@ -109,6 +105,10 @@ BASHREF_FILES = $(srcdir)/bashref.texi $(srcdir)/fdl.texi $(srcdir)/version.texi $(RM) $@ -${GROFF} -I${srcdir} -man $< > $@ +.1.pdf: + $(RM) $@ + -${GROFF} -I${srcdir} -man -T pdf $< > $@ + .1.0: $(RM) $@ -${NROFF} -I${srcdir} -man $< > $@ @@ -153,16 +153,18 @@ BASHREF_FILES = $(srcdir)/bashref.texi $(srcdir)/fdl.texi $(srcdir)/version.texi # $(RM) $@ # -${TEXI2PDF} $< -all: ps info dvi text html $(MAN2HTML) +all: info dvi text html pdf $(MAN2HTML) nodvi: ps info text html -everything: all pdf +everything: all ps -PSFILES = bash.ps bashbug.ps article.ps builtins.ps rbash.ps -DVIFILES = bashref.dvi bashref.ps +CREATED_PS = bash.ps bashref.ps +PSFILES = ${CREATED_PS} article.ps +DVIFILES = bashref.dvi INFOFILES = bashref.info bash.info MAN0FILES = bash.0 bashbug.0 builtins.0 rbash.0 HTMLFILES = bashref.html bash.html -PDFFILES = bash.pdf bashref.pdf article.pdf rose94.pdf +CREATED_PDF = bash.pdf bashref.pdf builtins.pdf rbash.pdf +PDFFILES = ${CREATED_PDF} article.pdf rose94.pdf ps: ${PSFILES} dvi: ${DVIFILES} @@ -187,6 +189,7 @@ bashref.pdf: $(BASHREF_FILES) $(HSUSER) $(RLUSER) # can also use: # $(TEXI2HTML) -menu -monolithic -I $(TEXINPUTDIR) $(srcdir)/bashref.texi bashref.html: $(BASHREF_FILES) $(HSUSER) $(RLUSER) + $(RM) $@ $(MAKEINFO) --html --no-split -I$(TEXINPUTDIR) $(srcdir)/bashref.texi bash.info: $(BASHREF_FILES) $(HSUSER) $(RLUSER) @@ -207,38 +210,47 @@ article.ps: article.ms bashref.ps: bashref.dvi -article.pdf: article.ps -#bashref.pdf: bashref.dvi # experimental bashref.pdf: bashref.texi -bash.pdf: bash.ps +bash.pdf: bash.1 + +builtins.pdf: builtins.1 bash.1 + $(RM) $@ + -${GROFF} -I${srcdir} -man -T pdf builtins.1 > $@ + +article.pdf: article.ps rose94.pdf: rose94.ps OTHER_DOCS = $(srcdir)/FAQ $(srcdir)/INTRO OTHER_INSTALLED_DOCS = FAQ INTRO $(MAN2HTML): ${topdir}/support/man2html.c - -( cd ${BUILD_DIR}/support ; ${MAKE} ${MFLAGS} man2html) + -( cd ${BUILD_DIR}/support ; ${MAKE} ${BASH_MAKEFLAGS} man2html) -clean: +.PHONY: clean maintainer-clean distclean mostlyclean maybe-clean + +mostlyclean: $(RM) *.aux *.bak *.cp *.fn *.ky *.log *.pg *.toc *.tp *.vr *.cps \ *.pgs *.bt *.bts *.rw *.rws *.fns *.kys *.tps *.vrs *.o ${RM} core *.core -mostlyclean: clean - $(RM) Makefile +clean: mostlyclean distclean: clean maybe-clean $(RM) Makefile maintainer-clean: clean - ${RM} ${PSFILES} ${DVIFILES} ${INFOFILES} ${MAN0FILES} ${HTMLFILES} + ${RM} ${DVIFILES} ${INFOFILES} ${MAN0FILES} ${HTMLFILES} + ${RM} ${CREATED_PS} ${CREATED_PDF} ${RM} ${CREATED_FAQ} $(RM) Makefile +# I'd like to use realpath here, but it's not universal maybe-clean: - -if test "X$(topdir)" != "X$(BUILD_DIR)"; then \ - $(RM) ${PSFILES} ${DVIFILES} ${INFOFILES} ${MAN0FILES} ${HTMLFILES}; \ + -TD=$$(cd $(topdir) && pwd -P) ; \ + BD=$$(cd $(BUILD_DIR) && pwd -P) ; \ + if test "X$$TD" != "X$$BD"; then \ + $(RM) ${CREATED_PS} ${DVIFILES} ${INFOFILES} ${MAN0FILES} ${HTMLFILES} ${CREATED_PDF}; \ fi installdirs: @@ -282,12 +294,22 @@ install-html: html $(INSTALL_DATA) $(srcdir)/bashref.html $(DESTDIR)$(htmldir) ; \ fi +install-dvi: +install-pdf: +install-ps: + +uninstall-html: + -if test -n "$(htmldir)" ; then \ + $(RM) $(DESTDIR)$(htmldir)/bash.html ; \ + $(RM) $(DESTDIR)$(htmldir)/bashref.html ; \ + fi + uninstall: -$(RM) $(DESTDIR)$(man1dir)/bash${man1ext} $(DESTDIR)$(man1dir)/bashbug${man1ext} -$(RM) $(DESTDIR)$(man1dir)/bash_builtins${man1ext} $(RM) $(DESTDIR)$(infodir)/bash.info # run install-info if it is present to update the info directory - if $(SHELL) -c 'install-info --version' >/dev/null 2>&1; then \ + -if $(SHELL) -c 'install-info --version' >/dev/null 2>&1; then \ install-info --delete --dir-file=$(DESTDIR)$(infodir)/dir $(DESTDIR)$(infodir)/bash.info; \ else true; fi -( cd $(DESTDIR)$(docdir) && $(RM) $(OTHER_INSTALLED_DOCS) ) diff --git a/doc/bash.0 b/doc/bash.0 index 1580b77aa..e01a1afee 100644 --- a/doc/bash.0 +++ b/doc/bash.0 @@ -1,6 +1,4 @@ -BASH(1) General Commands Manual BASH(1) - - +_B_A_S_H(1) General Commands Manual _B_A_S_H(1) NNAAMMEE bash - GNU Bourne-Again SHell @@ -9,16 +7,23 @@ SSYYNNOOPPSSIISS bbaasshh [options] [command_string | file] CCOOPPYYRRIIGGHHTT - Bash is Copyright (C) 1989-2022 by the Free Software Foundation, Inc. + Bash is Copyright (C) 1989-2025 by the Free Software Foundation, Inc. DDEESSCCRRIIPPTTIIOONN - BBaasshh is an sshh-compatible command language interpreter that executes - commands read from the standard input or from a file. BBaasshh also incor- - porates useful features from the _K_o_r_n and _C shells (kksshh and ccsshh). - - BBaasshh is intended to be a conformant implementation of the Shell and - Utilities portion of the IEEE POSIX specification (IEEE Standard - 1003.1). BBaasshh can be configured to be POSIX-conformant by default. + BBaasshh is a command language interpreter that executes commands read from + the standard input, from a string, or from a file. It is a reimplemen- + tation and extension of the Bourne shell, the historical Unix command + language interpreter. BBaasshh also incorporates useful features from the + _K_o_r_n and _C shells (kksshh and ccsshh). + + POSIX is the name for a family of computing standards based on Unix. + BBaasshh is intended to be a conformant implementation of the Shell and + Utilities portion of the IEEE POSIX specification (IEEE Standard + 1003.1). BBaasshh POSIX mode (hereafter referred to as _p_o_s_i_x _m_o_d_e) changes + the shell's behavior where its default operation differs from the stan- + dard to strictly conform to the standard. See SSEEEE AALLSSOO below for a + reference to a document that details how posix mode affects bbaasshh's be- + havior. BBaasshh can be configured to be POSIX-conformant by default. OOPPTTIIOONNSS All of the single-character shell options documented in the description @@ -28,36 +33,44 @@ OOPPTTIIOONNSS --cc If the --cc option is present, then commands are read from the first non-option argument _c_o_m_m_a_n_d___s_t_r_i_n_g. If there are argu- - ments after the _c_o_m_m_a_n_d___s_t_r_i_n_g, the first argument is as- - signed to $$00 and any remaining arguments are assigned to the + ments after the _c_o_m_m_a_n_d___s_t_r_i_n_g, the first argument is as- + signed to $$00 and any remaining arguments are assigned to the positional parameters. The assignment to $$00 sets the name of the shell, which is used in warning and error messages. + --ii If the --ii option is present, the shell is _i_n_t_e_r_a_c_t_i_v_e. + --ll Make bbaasshh act as if it had been invoked as a login shell (see IINNVVOOCCAATTIIOONN below). - --rr If the --rr option is present, the shell becomes _r_e_s_t_r_i_c_t_e_d + + --rr If the --rr option is present, the shell becomes _r_e_s_t_r_i_c_t_e_d (see RREESSTTRRIICCTTEEDD SSHHEELLLL below). - --ss If the --ss option is present, or if no arguments remain after - option processing, then commands are read from the standard + + --ss If the --ss option is present, or if no arguments remain after + option processing, the shell reads commands from the standard input. This option allows the positional parameters to be set when invoking an interactive shell or when reading input through a pipe. - --DD A list of all double-quoted strings preceded by $$ is printed - on the standard output. These are the strings that are sub- - ject to language translation when the current locale is not CC - or PPOOSSIIXX. This implies the --nn option; no commands will be - executed. + + --DD Print a list of all double-quoted strings preceded by $$ on + the standard output. These are the strings that are subject + to language translation when the current locale is not CC or + PPOOSSIIXX. This implies the --nn option; no commands will be exe- + cuted. + [[--++]]OO [[_s_h_o_p_t___o_p_t_i_o_n]] _s_h_o_p_t___o_p_t_i_o_n is one of the shell options accepted by the sshhoopptt builtin (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). If _s_h_o_p_t___o_p_t_i_o_n is present, --OO sets the value of that option; ++OO - unsets it. If _s_h_o_p_t___o_p_t_i_o_n is not supplied, the names and - values of the shell options accepted by sshhoopptt are printed on - the standard output. If the invocation option is ++OO, the + unsets it. If _s_h_o_p_t___o_p_t_i_o_n is not supplied, bbaasshh prints the + names and values of the shell options accepted by sshhoopptt on + the standard output. If the invocation option is ++OO, the output is displayed in a format that may be reused as input. - ---- A ---- signals the end of options and disables further option - processing. Any arguments after the ---- are treated as file- - names and arguments. An argument of -- is equivalent to ----. + + ---- A ---- signals the end of options and disables further option + processing. Any arguments after the ---- are treated as a + shell script filename (see below) and arguments passed to + that script. An argument of -- is equivalent to ----. BBaasshh also interprets a number of multi-character options. These op- tions must appear on the command line before the single-character op- @@ -65,15 +78,19 @@ OOPPTTIIOONNSS ----ddeebbuuggggeerr Arrange for the debugger profile to be executed before the shell - starts. Turns on extended debugging mode (see the description + starts. Turns on extended debugging mode (see the description of the eexxttddeebbuugg option to the sshhoopptt builtin below). + ----dduummpp--ppoo--ssttrriinnggss - Equivalent to --DD, but the output is in the GNU _g_e_t_t_e_x_t ppoo (por- - table object) file format. + Equivalent to --DD, but the output is in the GNU _g_e_t_t_e_x_t "po" + (portable object) file format. + ----dduummpp--ssttrriinnggss Equivalent to --DD. - ----hheellpp Display a usage message on standard output and exit success- + + ----hheellpp Display a usage message on standard output and exit success- fully. + ----iinniitt--ffiillee _f_i_l_e ----rrccffiillee _f_i_l_e Execute commands from _f_i_l_e instead of the standard personal ini- @@ -99,10 +116,8 @@ OOPPTTIIOONNSS fault if the shell is invoked as sshh. ----ppoossiixx - Change the behavior of bbaasshh where the default operation differs - from the POSIX standard to match the standard (_p_o_s_i_x _m_o_d_e). See - SSEEEE AALLSSOO below for a reference to a document that details how - posix mode affects bash's behavior. + Enable posix mode; change the behavior of bbaasshh where the default + operation differs from the POSIX standard to match the standard. ----rreessttrriicctteedd The shell becomes restricted (see RREESSTTRRIICCTTEEDD SSHHEELLLL below). @@ -116,26 +131,26 @@ OOPPTTIIOONNSS AARRGGUUMMEENNTTSS If arguments remain after option processing, and neither the --cc nor the - --ss option has been supplied, the first argument is assumed to be the - name of a file containing shell commands. If bbaasshh is invoked in this - fashion, $$00 is set to the name of the file, and the positional parame- - ters are set to the remaining arguments. BBaasshh reads and executes com- - mands from this file, then exits. BBaasshh's exit status is the exit sta- - tus of the last command executed in the script. If no commands are ex- - ecuted, the exit status is 0. An attempt is first made to open the - file in the current directory, and, if no file is found, then the shell - searches the directories in PPAATTHH for the script. + --ss option has been supplied, the first argument is treated as the name + of a file containing shell commands (a _s_h_e_l_l _s_c_r_i_p_t). When bbaasshh is in- + voked in this fashion, $$00 is set to the name of the file, and the posi- + tional parameters are set to the remaining arguments. BBaasshh reads and + executes commands from this file, then exits. BBaasshh's exit status is + the exit status of the last command executed in the script. If no com- + mands are executed, the exit status is 0. BBaasshh first attempts to open + the file in the current directory, and, if no file is found, searches + the directories in PPAATTHH for the script. IINNVVOOCCAATTIIOONN A _l_o_g_i_n _s_h_e_l_l is one whose first character of argument zero is a --, or one started with the ----llooggiinn option. - An _i_n_t_e_r_a_c_t_i_v_e shell is one started without non-option arguments (un- - less --ss is specified) and without the --cc option, whose standard input - and error are both connected to terminals (as determined by _i_s_a_t_t_y(3)), - or one started with the --ii option. PPSS11 is set and $$-- includes ii if - bbaasshh is interactive, allowing a shell script or a startup file to test - this state. + An _i_n_t_e_r_a_c_t_i_v_e _s_h_e_l_l is one started without non-option arguments (un- + less --ss is specified) and without the --cc option, and whose standard in- + put and standard error are both connected to terminals (as determined + by _i_s_a_t_t_y(3)), or one started with the --ii option. BBaasshh sets PPSS11 and $$-- + includes ii if the shell is interactive, so a shell script or a startup + file can test this state. The following paragraphs describe how bbaasshh executes its startup files. If any of the files exist but cannot be read, bbaasshh reports an error. @@ -146,8 +161,8 @@ IINNVVOOCCAATTIIOONN active shell with the ----llooggiinn option, it first reads and executes com- mands from the file _/_e_t_c_/_p_r_o_f_i_l_e, if that file exists. After reading that file, it looks for _~_/_._b_a_s_h___p_r_o_f_i_l_e, _~_/_._b_a_s_h___l_o_g_i_n, and _~_/_._p_r_o_f_i_l_e, - in that order, and reads and executes commands from the first one that - exists and is readable. The ----nnoopprrooffiillee option may be used when the + in that order, and reads and executes commands from the first one that + exists and is readable. The ----nnoopprrooffiillee option may be used when the shell is started to inhibit this behavior. When an interactive login shell exits, or a non-interactive login shell @@ -155,18 +170,19 @@ IINNVVOOCCAATTIIOONN from the file _~_/_._b_a_s_h___l_o_g_o_u_t, if it exists. When an interactive shell that is not a login shell is started, bbaasshh - reads and executes commands from _~_/_._b_a_s_h_r_c, if that file exists. This - may be inhibited by using the ----nnoorrcc option. The ----rrccffiillee _f_i_l_e option - will force bbaasshh to read and execute commands from _f_i_l_e instead of - _~_/_._b_a_s_h_r_c. - - When bbaasshh is started non-interactively, to run a shell script, for ex- - ample, it looks for the variable BBAASSHH__EENNVV in the environment, expands - its value if it appears there, and uses the expanded value as the name - of a file to read and execute. BBaasshh behaves as if the following com- + reads and executes commands from _~_/_._b_a_s_h_r_c, if that file exists. The + ----nnoorrcc option inhibits this behavior. The ----rrccffiillee _f_i_l_e option causes + bbaasshh to use _f_i_l_e instead of _~_/_._b_a_s_h_r_c. + + When bbaasshh is started non-interactively, to run a shell script, for ex- + ample, it looks for the variable BBAASSHH__EENNVV in the environment, expands + its value if it appears there, and uses the expanded value as the name + of a file to read and execute. BBaasshh behaves as if the following com- mand were executed: + if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi - but the value of the PPAATTHH variable is not used to search for the file- + + but does not use the value of the PPAATTHH variable to search for the file- name. If bbaasshh is invoked with the name sshh, it tries to mimic the startup be- @@ -174,44 +190,50 @@ IINNVVOOCCAATTIIOONN forming to the POSIX standard as well. When invoked as an interactive login shell, or a non-interactive shell with the ----llooggiinn option, it first attempts to read and execute commands from _/_e_t_c_/_p_r_o_f_i_l_e and - _~_/_._p_r_o_f_i_l_e, in that order. The ----nnoopprrooffiillee option may be used to in- - hibit this behavior. When invoked as an interactive shell with the - name sshh, bbaasshh looks for the variable EENNVV, expands its value if it is - defined, and uses the expanded value as the name of a file to read and - execute. Since a shell invoked as sshh does not attempt to read and exe- - cute commands from any other startup files, the ----rrccffiillee option has no - effect. A non-interactive shell invoked with the name sshh does not at- - tempt to read any other startup files. When invoked as sshh, bbaasshh enters - _p_o_s_i_x mode after the startup files are read. - - When bbaasshh is started in _p_o_s_i_x mode, as with the ----ppoossiixx command line + _~_/_._p_r_o_f_i_l_e, in that order. The ----nnoopprrooffiillee option inhibits this behav- + ior. When invoked as an interactive shell with the name sshh, bbaasshh looks + for the variable EENNVV, expands its value if it is defined, and uses the + expanded value as the name of a file to read and execute. Since a + shell invoked as sshh does not attempt to read and execute commands from + any other startup files, the ----rrccffiillee option has no effect. A non-in- + teractive shell invoked with the name sshh does not attempt to read any + other startup files. + + When invoked as sshh, bbaasshh enters posix mode after reading the startup + files. + + When bbaasshh is started in posix mode, as with the ----ppoossiixx command line option, it follows the POSIX standard for startup files. In this mode, - interactive shells expand the EENNVV variable and commands are read and - executed from the file whose name is the expanded value. No other - startup files are read. + interactive shells expand the EENNVV variable and read and execute com- + mands from the file whose name is the expanded value. No other startup + files are read. BBaasshh attempts to determine when it is being run with its standard input - connected to a network connection, as when executed by the historical - remote shell daemon, usually _r_s_h_d, or the secure shell daemon _s_s_h_d. If - bbaasshh determines it is being run non-interactively in this fashion, it - reads and executes commands from _~_/_._b_a_s_h_r_c, if that file exists and is - readable. It will not do this if invoked as sshh. The ----nnoorrcc option may - be used to inhibit this behavior, and the ----rrccffiillee option may be used - to force another file to be read, but neither _r_s_h_d nor _s_s_h_d generally - invoke the shell with those options or allow them to be specified. + connected to a network connection, as when executed by the historical + and rarely-seen remote shell daemon, usually _r_s_h_d, or the secure shell + daemon _s_s_h_d. If bbaasshh determines it is being run non-interactively in + this fashion, it reads and executes commands from _~_/_._b_a_s_h_r_c, if that + file exists and is readable. BBaasshh does not read this file if invoked + as sshh. The ----nnoorrcc option inhibits this behavior, and the ----rrccffiillee op- + tion makes bbaasshh use a different file instead of _~_/_._b_a_s_h_r_c, but neither + _r_s_h_d nor _s_s_h_d generally invoke the shell with those options or allow + them to be specified. If the shell is started with the effective user (group) id not equal to the real user (group) id, and the --pp option is not supplied, no startup files are read, shell functions are not inherited from the environment, - the SSHHEELLLLOOPPTTSS, BBAASSHHOOPPTTSS, CCDDPPAATTHH, and GGLLOOBBIIGGNNOORREE variables, if they ap- - pear in the environment, are ignored, and the effective user id is set - to the real user id. If the --pp option is supplied at invocation, the + the SSHHEELLLLOOPPTTSS, BBAASSHHOOPPTTSS, CCDDPPAATTHH, and GGLLOOBBIIGGNNOORREE variables, if they ap- + pear in the environment, are ignored, and the effective user id is set + to the real user id. If the --pp option is supplied at invocation, the startup behavior is the same, but the effective user id is not reset. DDEEFFIINNIITTIIOONNSS - The following definitions are used throughout the rest of this docu- + The following definitions are used throughout the rest of this docu- ment. bbllaannkk A space or tab. + wwhhiitteessppaaccee + A character belonging to the ssppaaccee character class in the cur- + rent locale, or for which _i_s_s_p_a_c_e(3) returns true. wwoorrdd A sequence of characters considered as a single unit by the shell. Also known as a ttookkeenn. nnaammee A _w_o_r_d consisting only of alphanumeric characters and under- @@ -229,20 +251,20 @@ DDEEFFIINNIITTIIOONNSS RREESSEERRVVEEDD WWOORRDDSS _R_e_s_e_r_v_e_d _w_o_r_d_s are words that have a special meaning to the shell. The following words are recognized as reserved when unquoted and either the - first word of a command (see SSHHEELLLL GGRRAAMMMMAARR below), the third word of a - ccaassee or sseelleecctt command (only iinn is valid), or the third word of a ffoorr + first word of a command (see SSHHEELLLL GGRRAAMMMMAARR below), the third word of a + ccaassee or sseelleecctt command (only iinn is valid), or the third word of a ffoorr command (only iinn and ddoo are valid): - !! ccaassee ccoopprroocc ddoo ddoonnee eelliiff eellssee eessaacc ffii ffoorr ffuunnccttiioonn iiff iinn sseelleecctt + !! ccaassee ccoopprroocc ddoo ddoonnee eelliiff eellssee eessaacc ffii ffoorr ffuunnccttiioonn iiff iinn sseelleecctt tthheenn uunnttiill wwhhiillee {{ }} ttiimmee [[[[ ]]]] SSHHEELLLL GGRRAAMMMMAARR - This section describes the syntax of the various forms of shell com- + This section describes the syntax of the various forms of shell com- mands. SSiimmppllee CCoommmmaannddss - A _s_i_m_p_l_e _c_o_m_m_a_n_d is a sequence of optional variable assignments fol- - lowed by bbllaannkk-separated words and redirections, and terminated by a + A _s_i_m_p_l_e _c_o_m_m_a_n_d is a sequence of optional variable assignments fol- + lowed by bbllaannkk-separated words and redirections, and terminated by a _c_o_n_t_r_o_l _o_p_e_r_a_t_o_r. The first word specifies the command to be executed, and is passed as argument zero. The remaining words are passed as ar- guments to the invoked command. @@ -257,43 +279,43 @@ SSHHEELLLL GGRRAAMMMMAARR [ttiimmee [--pp]] [ ! ] _c_o_m_m_a_n_d_1 [ [|||||&&] _c_o_m_m_a_n_d_2 ... ] The standard output of _c_o_m_m_a_n_d_1 is connected via a pipe to the standard - input of _c_o_m_m_a_n_d_2. This connection is performed before any redirec- - tions specified by the _c_o_m_m_a_n_d_1(see RREEDDIIRREECCTTIIOONN below). If ||&& is used, - _c_o_m_m_a_n_d_1's standard error, in addition to its standard output, is con- - nected to _c_o_m_m_a_n_d_2's standard input through the pipe; it is shorthand - for 22>>&&11 ||. This implicit redirection of the standard error to the - standard output is performed after any redirections specified by _c_o_m_- - _m_a_n_d_1. + input of _c_o_m_m_a_n_d_2. This connection is performed before any redirec- + tions specified by the _c_o_m_m_a_n_d_1(see RREEDDIIRREECCTTIIOONN below). If ||&& is the + pipeline operator, _c_o_m_m_a_n_d_1's standard error, in addition to its stan- + dard output, is connected to _c_o_m_m_a_n_d_2's standard input through the + pipe; it is shorthand for 22>>&&11 ||. This implicit redirection of the + standard error to the standard output is performed after any redirec- + tions specified by _c_o_m_m_a_n_d_1. The return status of a pipeline is the exit status of the last command, unless the ppiippeeffaaiill option is enabled. If ppiippeeffaaiill is enabled, the pipeline's return status is the value of the last (rightmost) command to exit with a non-zero status, or zero if all commands exit success- fully. If the reserved word !! precedes a pipeline, the exit status of - that pipeline is the logical negation of the exit status as described - above. The shell waits for all commands in the pipeline to terminate - before returning a value. - - If the ttiimmee reserved word precedes a pipeline, the elapsed as well as - user and system time consumed by its execution are reported when the - pipeline terminates. The --pp option changes the output format to that - specified by POSIX. When the shell is in _p_o_s_i_x _m_o_d_e, it does not rec- - ognize ttiimmee as a reserved word if the next token begins with a `-'. - The TTIIMMEEFFOORRMMAATT variable may be set to a format string that specifies - how the timing information should be displayed; see the description of - TTIIMMEEFFOORRMMAATT under SShheellll VVaarriiaabblleess below. - - When the shell is in _p_o_s_i_x _m_o_d_e, ttiimmee may be followed by a newline. In - this case, the shell displays the total user and system time consumed - by the shell and its children. The TTIIMMEEFFOORRMMAATT variable may be used to - specify the format of the time information. + that pipeline is the logical negation of the exit status as described + above. If a pipeline is executed synchronously, the shell waits for + all commands in the pipeline to terminate before returning a value. + + If the ttiimmee reserved word precedes a pipeline, the shell reports the + elapsed as well as user and system time consumed by its execution when + the pipeline terminates. The --pp option changes the output format to + that specified by POSIX. When the shell is in posix mode, it does not + recognize ttiimmee as a reserved word if the next token begins with a "-". + The value of the TTIIMMEEFFOORRMMAATT variable is a format string that specifies + how the timing information should be displayed; see the description of + TTIIMMEEFFOORRMMAATT below under SShheellll VVaarriiaabblleess. + + When the shell is in posix mode, ttiimmee may appear by itself as the only + word in a simple command. In this case, the shell displays the total + user and system time consumed by the shell and its children. The TTIIMMEE-- + FFOORRMMAATT variable specifies the format of the time information. Each command in a multi-command pipeline, where pipes are created, is executed in a _s_u_b_s_h_e_l_l, which is a separate process. See CCOOMMMMAANNDD EEXXEE-- CCUUTTIIOONN EENNVVIIRROONNMMEENNTT for a description of subshells and a subshell envi- ronment. If the llaassttppiippee option is enabled using the sshhoopptt builtin - (see the description of sshhoopptt below), the last element of a pipeline - may be run by the shell process when job control is not active. + (see the description of sshhoopptt below), and job control is not active, + the last element of a pipeline may be run by the shell process. LLiissttss A _l_i_s_t is a sequence of one or more pipelines separated by one of the @@ -311,119 +333,124 @@ SSHHEELLLL GGRRAAMMMMAARR wait for the command to finish, and the return status is 0. These are referred to as _a_s_y_n_c_h_r_o_n_o_u_s commands. Commands separated by a ;; are executed sequentially; the shell waits for each command to terminate in - turn. The return status is the exit status of the last command exe- + turn. The return status is the exit status of the last command exe- cuted. - AND and OR lists are sequences of one or more pipelines separated by - the &&&& and |||| control operators, respectively. AND and OR lists are + AND and OR lists are sequences of one or more pipelines separated by + the &&&& and |||| control operators, respectively. AND and OR lists are executed with left associativity. An AND list has the form _c_o_m_m_a_n_d_1 &&&& _c_o_m_m_a_n_d_2 - _c_o_m_m_a_n_d_2 is executed if, and only if, _c_o_m_m_a_n_d_1 returns an exit status + _c_o_m_m_a_n_d_2 is executed if, and only if, _c_o_m_m_a_n_d_1 returns an exit status of zero (success). An OR list has the form _c_o_m_m_a_n_d_1 |||| _c_o_m_m_a_n_d_2 - _c_o_m_m_a_n_d_2 is executed if, and only if, _c_o_m_m_a_n_d_1 returns a non-zero exit - status. The return status of AND and OR lists is the exit status of + _c_o_m_m_a_n_d_2 is executed if, and only if, _c_o_m_m_a_n_d_1 returns a non-zero exit + status. The return status of AND and OR lists is the exit status of the last command executed in the list. CCoommppoouunndd CCoommmmaannddss - A _c_o_m_p_o_u_n_d _c_o_m_m_a_n_d is one of the following. In most cases a _l_i_s_t in a - command's description may be separated from the rest of the command by - one or more newlines, and may be followed by a newline in place of a + A _c_o_m_p_o_u_n_d _c_o_m_m_a_n_d is one of the following. In most cases a _l_i_s_t in a + command's description may be separated from the rest of the command by + one or more newlines, and may be followed by a newline in place of a semicolon. - (_l_i_s_t) _l_i_s_t is executed in a subshell (see CCOOMMMMAANNDD EEXXEECCUUTTIIOONN EENNVVIIRROONN-- - MMEENNTT below for a description of a subshell environment). Vari- - able assignments and builtin commands that affect the shell's + (_l_i_s_t) _l_i_s_t is executed in a subshell (see CCOOMMMMAANNDD EEXXEECCUUTTIIOONN EENNVVIIRROONN-- + MMEENNTT below for a description of a subshell environment). Vari- + able assignments and builtin commands that affect the shell's environment do not remain in effect after the command completes. The return status is the exit status of _l_i_s_t. { _l_i_s_t; } - _l_i_s_t is simply executed in the current shell environment. _l_i_s_t - must be terminated with a newline or semicolon. This is known - as a _g_r_o_u_p _c_o_m_m_a_n_d. The return status is the exit status of - _l_i_s_t. Note that unlike the metacharacters (( and )), {{ and }} are - _r_e_s_e_r_v_e_d _w_o_r_d_s and must occur where a reserved word is permitted + _l_i_s_t is executed in the current shell environment. _l_i_s_t must be + terminated with a newline or semicolon. This is known as a + _g_r_o_u_p _c_o_m_m_a_n_d. The return status is the exit status of _l_i_s_t. + + Note that unlike the metacharacters (( and )), {{ and }} are _r_e_- + _s_e_r_v_e_d _w_o_r_d_s and must occur where a reserved word is permitted to be recognized. Since they do not cause a word break, they must be separated from _l_i_s_t by whitespace or another shell metacharacter. ((_e_x_p_r_e_s_s_i_o_n)) - The _e_x_p_r_e_s_s_i_o_n is evaluated according to the rules described be- - low under AARRIITTHHMMEETTIICC EEVVAALLUUAATTIIOONN. If the value of the expression - is non-zero, the return status is 0; otherwise the return status - is 1. The _e_x_p_r_e_s_s_i_o_n undergoes the same expansions as if it - were within double quotes, but double quote characters in _e_x_- - _p_r_e_s_s_i_o_n are not treated specially and are removed. + The arithmetic _e_x_p_r_e_s_s_i_o_n is evaluated according to the rules + described below under AARRIITTHHMMEETTIICC EEVVAALLUUAATTIIOONN. If the value of + the expression is non-zero, the return status is 0; otherwise + the return status is 1. The _e_x_p_r_e_s_s_i_o_n undergoes the same ex- + pansions as if it were within double quotes, but unescaped dou- + ble quote characters in _e_x_p_r_e_s_s_i_o_n are not treated specially and + are removed. Since this can potentially result in empty + strings, this command treats those as expressions that evaluate + to 0. [[[[ _e_x_p_r_e_s_s_i_o_n ]]]] - Return a status of 0 or 1 depending on the evaluation of the - conditional expression _e_x_p_r_e_s_s_i_o_n. Expressions are composed of - the primaries described below under CCOONNDDIITTIIOONNAALL EEXXPPRREESSSSIIOONNSS. - The words between the [[[[ and ]]]] do not undergo word splitting - and pathname expansion. The shell performs tilde expansion, pa- - rameter and variable expansion, arithmetic expansion, command - substitution, process substitution, and quote removal on those - words (the expansions that would occur if the words were en- - closed in double quotes). Conditional operators such as --ff must - be unquoted to be recognized as primaries. - - When used with [[[[, the << and >> operators sort lexicographically + Evaluate the conditional expression _e_x_p_r_e_s_s_i_o_n and return a sta- + tus of zero (true) or non-zero (false). Expressions are com- + posed of the primaries described below under CCOONNDDIITTIIOONNAALL EEXXPPRREESS-- + SSIIOONNSS. The words between the [[[[ and ]]]] do not undergo word + splitting and pathname expansion. The shell performs tilde ex- + pansion, parameter and variable expansion, arithmetic expansion, + command substitution, process substitution, and quote removal on + those words. Conditional operators such as --ff must be unquoted + to be recognized as primaries. + + When used with [[[[, the << and >> operators sort lexicographically using the current locale. - When the ==== and !!== operators are used, the string to the right + When the ==== and !!== operators are used, the string to the right of the operator is considered a pattern and matched according to the rules described below under PPaatttteerrnn MMaattcchhiinngg, as if the eexxtt-- gglloobb shell option were enabled. The == operator is equivalent to ====. If the nnooccaasseemmaattcchh shell option is enabled, the match is performed without regard to the case of alphabetic characters. The return value is 0 if the string matches (====) or does not - match (!!==) the pattern, and 1 otherwise. Any part of the pat- - tern may be quoted to force the quoted portion to be matched as - a string. + match (!!==) the pattern, and 1 otherwise. If any part of the + pattern is quoted, the quoted portion is matched as a string: + every character in the quoted portion matches itself, instead of + having any special pattern matching meaning. An additional binary operator, ==~~, is available, with the same precedence as ==== and !!==. When it is used, the string to the right of the operator is considered a POSIX extended regular ex- - pression and matched accordingly (using the POSIX _r_e_g_c_o_m_p and - _r_e_g_e_x_e_c interfaces usually described in _r_e_g_e_x(3)). The return - value is 0 if the string matches the pattern, and 1 otherwise. + pression and matched accordingly (using the POSIX _r_e_g_c_o_m_p and + _r_e_g_e_x_e_c interfaces usually described in _r_e_g_e_x(3)). The return + value is 0 if the string matches the pattern, and 1 otherwise. If the regular expression is syntactically incorrect, the condi- tional expression's return value is 2. If the nnooccaasseemmaattcchh shell - option is enabled, the match is performed without regard to the - case of alphabetic characters. If any part of the pattern is - quoted, the quoted portion is matched literally. This means ev- - ery character in the quoted portion matches itself, instead of - having any special pattern matching meaning. If the pattern is - stored in a shell variable, quoting the variable expansion - forces the entire pattern to be matched literally. Treat - bracket expressions in regular expressions carefully, since nor- - mal quoting and pattern characters lose their meanings between - brackets. - - The pattern will match if it matches any part of the string. - Anchor the pattern using the ^^ and $$ regular expression opera- - tors to force it to match the entire string. The array variable - BBAASSHH__RREEMMAATTCCHH records which parts of the string matched the pat- - tern. The element of BBAASSHH__RREEMMAATTCCHH with index 0 contains the - portion of the string matching the entire regular expression. - Substrings matched by parenthesized subexpressions within the - regular expression are saved in the remaining BBAASSHH__RREEMMAATTCCHH in- - dices. The element of BBAASSHH__RREEMMAATTCCHH with index _n is the portion - of the string matching the _nth parenthesized subexpression. - Bash sets BBAASSHH__RREEMMAATTCCHH in the global scope; declaring it as a - local variable will lead to unexpected results. + option is enabled, the match is performed without regard to the + case of alphabetic characters. + + If any part of the pattern is quoted, the quoted portion is + matched literally, as above. If the pattern is stored in a + shell variable, quoting the variable expansion forces the entire + pattern to be matched literally. Treat bracket expressions in + regular expressions carefully, since normal quoting and pattern + characters lose their meanings between brackets. + + The match succeeds if the pattern matches any part of the + string. Anchor the pattern using the ^^ and $$ regular expression + operators to force it to match the entire string. + + The array variable BBAASSHH__RREEMMAATTCCHH records which parts of the + string matched the pattern. The element of BBAASSHH__RREEMMAATTCCHH with + index 0 contains the portion of the string matching the entire + regular expression. Substrings matched by parenthesized subex- + pressions within the regular expression are saved in the remain- + ing BBAASSHH__RREEMMAATTCCHH indices. The element of BBAASSHH__RREEMMAATTCCHH with in- + dex _n is the portion of the string matching the _nth parenthe- + sized subexpression. BBaasshh sets BBAASSHH__RREEMMAATTCCHH in the global + scope; declaring it as a local variable will lead to unexpected + results. - Expressions may be combined using the following operators, + Expressions may be combined using the following operators, listed in decreasing order of precedence: (( _e_x_p_r_e_s_s_i_o_n )) - Returns the value of _e_x_p_r_e_s_s_i_o_n. This may be used to + Returns the value of _e_x_p_r_e_s_s_i_o_n. This may be used to override the normal precedence of operators. !! _e_x_p_r_e_s_s_i_o_n True if _e_x_p_r_e_s_s_i_o_n is false. @@ -436,69 +463,79 @@ SSHHEELLLL GGRRAAMMMMAARR of _e_x_p_r_e_s_s_i_o_n_1 is sufficient to determine the return value of the entire conditional expression. - ffoorr _n_a_m_e [ [ iinn [ _w_o_r_d _._._. ] ] ; ] ddoo _l_i_s_t ; ddoonnee - The list of words following iinn is expanded, generating a list of - items. The variable _n_a_m_e is set to each element of this list in - turn, and _l_i_s_t is executed each time. If the iinn _w_o_r_d is omit- - ted, the ffoorr command executes _l_i_s_t once for each positional pa- - rameter that is set (see PPAARRAAMMEETTEERRSS below). The return status - is the exit status of the last command that executes. If the - expansion of the items following iinn results in an empty list, no - commands are executed, and the return status is 0. - - ffoorr (( _e_x_p_r_1 ; _e_x_p_r_2 ; _e_x_p_r_3 )) ; ddoo _l_i_s_t ; ddoonnee - First, the arithmetic expression _e_x_p_r_1 is evaluated according to - the rules described below under AARRIITTHHMMEETTIICC EEVVAALLUUAATTIIOONN. The - arithmetic expression _e_x_p_r_2 is then evaluated repeatedly until - it evaluates to zero. Each time _e_x_p_r_2 evaluates to a non-zero - value, _l_i_s_t is executed and the arithmetic expression _e_x_p_r_3 is - evaluated. If any expression is omitted, it behaves as if it - evaluates to 1. The return value is the exit status of the last - command in _l_i_s_t that is executed, or false if any of the expres- - sions is invalid. + ffoorr _n_a_m_e [ [ iinn _w_o_r_d _._._. ] ; ] ddoo _l_i_s_t ; ddoonnee + First, expand The list of words following iinn, generating a list + of items. Then, the variable _n_a_m_e is set to each element of + this list in turn, and _l_i_s_t is executed each time. If the iinn + _w_o_r_d is omitted, the ffoorr command executes _l_i_s_t once for each po- + sitional parameter that is set (see PPAARRAAMMEETTEERRSS below). The re- + turn status is the exit status of the last command that exe- + cutes. If the expansion of the items following iinn results in an + empty list, no commands are executed, and the return status is + 0. + + ffoorr (( _e_x_p_r_1 ; _e_x_p_r_2 ; _e_x_p_r_3 )) [;] ddoo _l_i_s_t ; ddoonnee + First, evaluate the arithmetic expression _e_x_p_r_1 according to the + rules described below under AARRIITTHHMMEETTIICC EEVVAALLUUAATTIIOONN. Then, re- + peatedly evaluate the arithmetic expression _e_x_p_r_2 until it eval- + uates to zero. Each time _e_x_p_r_2 evaluates to a non-zero value, + execute _l_i_s_t and evaluate the arithmetic expression _e_x_p_r_3. If + any expression is omitted, it behaves as if it evaluates to 1. + The return value is the exit status of the last command in _l_i_s_t + that is executed, or non-zero if any of the expressions is in- + valid. + + Use the bbrreeaakk and ccoonnttiinnuuee builtins (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS + below) to control loop execution. sseelleecctt _n_a_m_e [ iinn _w_o_r_d ] ; ddoo _l_i_s_t ; ddoonnee - The list of words following iinn is expanded, generating a list of - items, and the set of expanded words is printed on the standard - error, each preceded by a number. If the iinn _w_o_r_d is omitted, - the positional parameters are printed (see PPAARRAAMMEETTEERRSS below). - sseelleecctt then displays the PPSS33 prompt and reads a line from the - standard input. If the line consists of a number corresponding - to one of the displayed words, then the value of _n_a_m_e is set to - that word. If the line is empty, the words and prompt are dis- - played again. If EOF is read, the sseelleecctt command completes and - returns 1. Any other value read causes _n_a_m_e to be set to null. - The line read is saved in the variable RREEPPLLYY. The _l_i_s_t is exe- - cuted after each selection until a bbrreeaakk command is executed. - The exit status of sseelleecctt is the exit status of the last command - executed in _l_i_s_t, or zero if no commands were executed. + First, expand the list of words following iinn, generating a list + of items, and print the set of expanded words the standard er- + ror, each preceded by a number. If the iinn _w_o_r_d is omitted, + print the positional parameters (see PPAARRAAMMEETTEERRSS below). sseelleecctt + then displays the PPSS33 prompt and reads a line from the standard + input. If the line consists of a number corresponding to one of + the displayed words, then sseelleecctt sets the value of _n_a_m_e to that + word. If the line is empty, sseelleecctt displays the words and + prompt again. If EOF is read, sseelleecctt completes and returns 1. + Any other value sets _n_a_m_e to null. The line read is saved in + the variable RREEPPLLYY. The _l_i_s_t is executed after each selection + until a bbrreeaakk command is executed. The exit status of sseelleecctt is + the exit status of the last command executed in _l_i_s_t, or zero if + no commands were executed. ccaassee _w_o_r_d iinn [ [(] _p_a_t_t_e_r_n [ || _p_a_t_t_e_r_n ] ... ) _l_i_s_t ;; ] ... eessaacc A ccaassee command first expands _w_o_r_d, and tries to match it against - each _p_a_t_t_e_r_n in turn, using the matching rules described under - PPaatttteerrnn MMaattcchhiinngg below. The _w_o_r_d is expanded using tilde expan- - sion, parameter and variable expansion, arithmetic expansion, - command substitution, process substitution and quote removal. - Each _p_a_t_t_e_r_n examined is expanded using tilde expansion, parame- - ter and variable expansion, arithmetic expansion, command sub- - stitution, process substitution, and quote removal. If the nnoo-- - ccaasseemmaattcchh shell option is enabled, the match is performed with- - out regard to the case of alphabetic characters. When a match - is found, the corresponding _l_i_s_t is executed. If the ;;;; opera- - tor is used, no subsequent matches are attempted after the first - pattern match. Using ;;&& in place of ;;;; causes execution to con- - tinue with the _l_i_s_t associated with the next set of patterns. - Using ;;;;&& in place of ;;;; causes the shell to test the next pat- - tern list in the statement, if any, and execute any associated - _l_i_s_t on a successful match, continuing the case statement execu- - tion as if the pattern list had not matched. The exit status is - zero if no pattern matches. Otherwise, it is the exit status of - the last command executed in _l_i_s_t. + each _p_a_t_t_e_r_n in turn, proceeding from first to last, using the + matching rules described under PPaatttteerrnn MMaattcchhiinngg below. A pat- + tern list is a set of one or more patterns separated by , and + the ) operator terminates the pattern list. The _w_o_r_d is ex- + panded using tilde expansion, parameter and variable expansion, + arithmetic expansion, command substitution, process substitution + and quote removal. Each _p_a_t_t_e_r_n examined is expanded using + tilde expansion, parameter and variable expansion, arithmetic + expansion, command substitution, process substitution, and quote + removal. If the nnooccaasseemmaattcchh shell option is enabled, the match + is performed without regard to the case of alphabetic charac- + ters. A _c_l_a_u_s_e is a pattern list and an associated _l_i_s_t. + + When a match is found, ccaassee executes the corresponding _l_i_s_t. If + the ;;;; operator terminates the case clause, the ccaassee command + completes after the first match. Using ;;&& in place of ;;;; causes + execution to continue with the _l_i_s_t associated with the next + pattern list. Using ;;;;&& in place of ;;;; causes the shell to test + the next pattern list in the statement, if any, and execute any + associated _l_i_s_t if the match succeeds, continuing the case + statement execution as if the pattern list had not matched. The + exit status is zero if no pattern matches. + + Otherwise, it is the exit status of the last command executed in + the last _l_i_s_t executed. iiff _l_i_s_t; tthheenn _l_i_s_t; [ eelliiff _l_i_s_t; tthheenn _l_i_s_t; ] ... [ eellssee _l_i_s_t; ] ffii - The iiff _l_i_s_t is executed. If its exit status is zero, the tthheenn - _l_i_s_t is executed. Otherwise, each eelliiff _l_i_s_t is executed in - turn, and if its exit status is zero, the corresponding tthheenn + The iiff _l_i_s_t is executed. If its exit status is zero, the tthheenn + _l_i_s_t is executed. Otherwise, each eelliiff _l_i_s_t is executed in + turn, and if its exit status is zero, the corresponding tthheenn _l_i_s_t is executed and the command completes. Otherwise, the eellssee _l_i_s_t is executed, if present. The exit status is the exit sta- tus of the last command executed, or zero if no condition tested @@ -506,7 +543,7 @@ SSHHEELLLL GGRRAAMMMMAARR wwhhiillee _l_i_s_t_-_1; ddoo _l_i_s_t_-_2; ddoonnee uunnttiill _l_i_s_t_-_1; ddoo _l_i_s_t_-_2; ddoonnee - The wwhhiillee command continuously executes the list _l_i_s_t_-_2 as long + The wwhhiillee command continuously executes the list _l_i_s_t_-_2 as long as the last command in the list _l_i_s_t_-_1 returns an exit status of zero. The uunnttiill command is identical to the wwhhiillee command, ex- cept that the test is negated: _l_i_s_t_-_2 is executed as long as the @@ -532,9 +569,9 @@ SSHHEELLLL GGRRAAMMMMAARR ccoopprroocc _N_A_M_E { _c_o_m_m_a_n_d [_r_e_d_i_r_e_c_t_i_o_n_s]; } - This form is recommended because simple commands result in the copro- - cess always being named CCOOPPRROOCC, and it is simpler to use and more com- - plete than the other compound commands. + This form is preferred because simple commands result in the coprocess + always being named CCOOPPRROOCC, and it is simpler to use and more complete + than the other compound commands. If _c_o_m_m_a_n_d is a compound command, _N_A_M_E is optional. The word following ccoopprroocc determines whether that word is interpreted as a variable name: @@ -551,22 +588,22 @@ SSHHEELLLL GGRRAAMMMMAARR file descriptor in the executing shell, and that file descriptor is as- signed to _N_A_M_E[1]. This pipe is established before any redirections specified by the command (see RREEDDIIRREECCTTIIOONN below). The file descriptors - can be utilized as arguments to shell commands and redirections using - standard word expansions. Other than those created to execute command - and process substitutions, the file descriptors are not available in + can be utilized as arguments to shell commands and redirections using + standard word expansions. Other than those created to execute command + and process substitutions, the file descriptors are not available in subshells. - The process ID of the shell spawned to execute the coprocess is avail- - able as the value of the variable _N_A_M_E_PID. The wwaaiitt builtin command - may be used to wait for the coprocess to terminate. + The process ID of the shell spawned to execute the coprocess is avail- + able as the value of the variable _N_A_M_E_PID. The wwaaiitt builtin may be + used to wait for the coprocess to terminate. - Since the coprocess is created as an asynchronous command, the ccoopprroocc - command always returns success. The return status of a coprocess is + Since the coprocess is created as an asynchronous command, the ccoopprroocc + command always returns success. The return status of a coprocess is the exit status of _c_o_m_m_a_n_d. SShheellll FFuunnccttiioonn DDeeffiinniittiioonnss - A shell function is an object that is called like a simple command and - executes a compound command with a new set of positional parameters. + A shell function is an object that is called like a simple command and + executes a compound command with a new set of positional parameters. Shell functions are declared as follows: _f_n_a_m_e () _c_o_m_p_o_u_n_d_-_c_o_m_m_a_n_d [_r_e_d_i_r_e_c_t_i_o_n] @@ -579,26 +616,30 @@ SSHHEELLLL GGRRAAMMMMAARR may be any command listed under CCoommppoouunndd CCoommmmaannddss above. If the ffuunnccttiioonn reserved word is used, but the parentheses are not sup- plied, the braces are recommended. _c_o_m_p_o_u_n_d_-_c_o_m_m_a_n_d is executed - whenever _f_n_a_m_e is specified as the name of a simple command. - When in _p_o_s_i_x _m_o_d_e, _f_n_a_m_e must be a valid shell _n_a_m_e and may not + whenever _f_n_a_m_e is specified as the name of a simple command. + When in posix mode, _f_n_a_m_e must be a valid shell _n_a_m_e and may not be the name of one of the POSIX _s_p_e_c_i_a_l _b_u_i_l_t_i_n_s. In default mode, a function name can be any unquoted shell word that does - not contain $$. Any redirections (see RREEDDIIRREECCTTIIOONN below) speci- - fied when a function is defined are performed when the function - is executed. The exit status of a function definition is zero - unless a syntax error occurs or a readonly function with the - same name already exists. When executed, the exit status of a - function is the exit status of the last command executed in the - body. (See FFUUNNCCTTIIOONNSS below.) + not contain $$. + + Any redirections (see RREEDDIIRREECCTTIIOONN below) specified when a function is + defined are performed when the function is executed. + + The exit status of a function definition is zero unless a syntax error + occurs or a readonly function with the same name already exists. When + executed, the exit status of a function is the exit status of the last + command executed in the body. (See FFUUNNCCTTIIOONNSS below.) CCOOMMMMEENNTTSS In a non-interactive shell, or an interactive shell in which the iinntteerr-- - aaccttiivvee__ccoommmmeennttss option to the sshhoopptt builtin is enabled (see SSHHEELLLL - BBUUIILLTTIINN CCOOMMMMAANNDDSS below), a word beginning with ## causes that word and - all remaining characters on that line to be ignored. An interactive - shell without the iinntteerraaccttiivvee__ccoommmmeennttss option enabled does not allow - comments. The iinntteerraaccttiivvee__ccoommmmeennttss option is on by default in interac- - tive shells. + aaccttiivvee__ccoommmmeennttss option to the sshhoopptt builtin is enabled (see SSHHEELLLL + BBUUIILLTTIINN CCOOMMMMAANNDDSS below), a word beginning with ## introduces a comment. + A word begins at the beginning of a line, after unquoted whitespace, or + after an operator. The comment causes that word and all remaining + characters on that line to be ignored. An interactive shell without + the iinntteerraaccttiivvee__ccoommmmeennttss option enabled does not allow comments. The + iinntteerraaccttiivvee__ccoommmmeennttss option is enabled by default in interactive + shells. QQUUOOTTIINNGG _Q_u_o_t_i_n_g is used to remove the special meaning of certain characters or @@ -606,45 +647,49 @@ QQUUOOTTIINNGG for special characters, to prevent reserved words from being recognized as such, and to prevent parameter expansion. - Each of the _m_e_t_a_c_h_a_r_a_c_t_e_r_s listed above under DDEEFFIINNIITTIIOONNSS has special + Each of the _m_e_t_a_c_h_a_r_a_c_t_e_r_s listed above under DDEEFFIINNIITTIIOONNSS has special meaning to the shell and must be quoted if it is to represent itself. - When the command history expansion facilities are being used (see HHIISS-- + When the command history expansion facilities are being used (see HHIISS-- TTOORRYY EEXXPPAANNSSIIOONN below), the _h_i_s_t_o_r_y _e_x_p_a_n_s_i_o_n character, usually !!, must be quoted to prevent history expansion. - There are three quoting mechanisms: the _e_s_c_a_p_e _c_h_a_r_a_c_t_e_r, single - quotes, and double quotes. + There are four quoting mechanisms: the _e_s_c_a_p_e _c_h_a_r_a_c_t_e_r, single quotes, + double quotes, and dollar-single quotes. - A non-quoted backslash (\\) is the _e_s_c_a_p_e _c_h_a_r_a_c_t_e_r. It preserves the - literal value of the next character that follows, with the exception of - . If a \\ pair appears, and the backslash is not it- - self quoted, the \\ is treated as a line continuation (that is, - it is removed from the input stream and effectively ignored). + A non-quoted backslash (\\) is the _e_s_c_a_p_e _c_h_a_r_a_c_t_e_r. It preserves the + literal value of the next character that follows, removing any special + meaning it has, with the exception of . If a \\ pair + appears, and the backslash is not itself quoted, the \\ is + treated as a line continuation (that is, it is removed from the input + stream and effectively ignored). Enclosing characters in single quotes preserves the literal value of each character within the quotes. A single quote may not occur between single quotes, even when preceded by a backslash. - Enclosing characters in double quotes preserves the literal value of - all characters within the quotes, with the exception of $$, ``, \\, and, - when history expansion is enabled, !!. When the shell is in _p_o_s_i_x _m_o_d_e, + Enclosing characters in double quotes preserves the literal value of + all characters within the quotes, with the exception of $$, ``, \\, and, + when history expansion is enabled, !!. When the shell is in posix mode, the !! has no special meaning within double quotes, even when history expansion is enabled. The characters $$ and `` retain their special meaning within double quotes. The backslash retains its special mean- ing only when followed by one of the following characters: $$, ``, "", \\, - or <>. A double quote may be quoted within double quotes by - preceding it with a backslash. If enabled, history expansion will be - performed unless an !! appearing in double quotes is escaped using a - backslash. The backslash preceding the !! is not removed. + or <>. Backslashes preceding characters without a special mean- + ing are left unmodified. + + A double quote may be quoted within double quotes by preceding it with + a backslash. If enabled, history expansion will be performed unless an + !! appearing in double quotes is escaped using a backslash. The back- + slash preceding the !! is not removed. - The special parameters ** and @@ have special meaning when in double + The special parameters ** and @@ have special meaning when in double quotes (see PPAARRAAMMEETTEERRSS below). - Character sequences of the form $$'_s_t_r_i_n_g' are treated as a special - variant of single quotes. The sequence expands to _s_t_r_i_n_g, with back- - slash-escaped characters in _s_t_r_i_n_g replaced as specified by the ANSI C - standard. Backslash escape sequences, if present, are decoded as fol- + Character sequences of the form $$'_s_t_r_i_n_g' are treated as a special + variant of single quotes. The sequence expands to _s_t_r_i_n_g, with back- + slash-escaped characters in _s_t_r_i_n_g replaced as specified by the ANSI C + standard. Backslash escape sequences, if present, are decoded as fol- lows: \\aa alert (bell) \\bb backspace @@ -659,72 +704,76 @@ QQUUOOTTIINNGG \\'' single quote \\"" double quote \\?? question mark - \\_n_n_n the eight-bit character whose value is the octal value - _n_n_n (one to three octal digits) - \\xx_H_H the eight-bit character whose value is the hexadecimal - value _H_H (one or two hex digits) - \\uu_H_H_H_H the Unicode (ISO/IEC 10646) character whose value is the - hexadecimal value _H_H_H_H (one to four hex digits) + \\_n_n_n The eight-bit character whose value is the octal value + _n_n_n (one to three octal digits). + \\xx_H_H The eight-bit character whose value is the hexadecimal + value _H_H (one or two hex digits). + \\uu_H_H_H_H The Unicode (ISO/IEC 10646) character whose value is the + hexadecimal value _H_H_H_H (one to four hex digits). \\UU_H_H_H_H_H_H_H_H - the Unicode (ISO/IEC 10646) character whose value is the - hexadecimal value _H_H_H_H_H_H_H_H (one to eight hex digits) - \\cc_x a control-_x character + The Unicode (ISO/IEC 10646) character whose value is the + hexadecimal value _H_H_H_H_H_H_H_H (one to eight hex digits). + \\cc_x A control-_x character. - The expanded result is single-quoted, as if the dollar sign had not + The expanded result is single-quoted, as if the dollar sign had not been present. - A double-quoted string preceded by a dollar sign ($$"_s_t_r_i_n_g") will cause - the string to be translated according to the current locale. The _g_e_t_- - _t_e_x_t infrastructure performs the lookup and translation, using the - LLCC__MMEESSSSAAGGEESS, TTEEXXTTDDOOMMAAIINNDDIIRR, and TTEEXXTTDDOOMMAAIINN shell variables. If the - current locale is CC or PPOOSSIIXX, if there are no translations available, - or if the string is not translated, the dollar sign is ignored. This - is a form of double quoting, so the string remains double-quoted by de- - fault, whether or not it is translated and replaced. If the nnooeexx-- - ppaanndd__ttrraannssllaattiioonn option is enabled using the sshhoopptt builtin, translated - strings are single-quoted instead of double-quoted. See the descrip- - tion of sshhoopptt below under SSHHEELLLLBUILTINCCOOMMMMAANNDDSS. + TTrraannssllaattiinngg SSttrriinnggss + A double-quoted string preceded by a dollar sign ($$"_s_t_r_i_n_g") causes the + string to be translated according to the current locale. The _g_e_t_t_e_x_t + infrastructure performs the lookup and translation, using the LLCC__MMEESS-- + SSAAGGEESS, TTEEXXTTDDOOMMAAIINNDDIIRR, and TTEEXXTTDDOOMMAAIINN shell variables. If the current + locale is CC or PPOOSSIIXX, if there are no translations available, or if the + string is not translated, the dollar sign is ignored, and the string is + treated as double-quoted as described above. This is a form of double + quoting, so the string remains double-quoted by default, whether or not + it is translated and replaced. If the nnooeexxppaanndd__ttrraannssllaattiioonn option is + enabled using the sshhoopptt builtin, translated strings are single-quoted + instead of double-quoted. See the description of sshhoopptt below under + SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS. PPAARRAAMMEETTEERRSS A _p_a_r_a_m_e_t_e_r is an entity that stores values. It can be a _n_a_m_e, a num- - ber, or one of the special characters listed below under SSppeecciiaall PPaarraamm-- - eetteerrss. A _v_a_r_i_a_b_l_e is a parameter denoted by a _n_a_m_e. A variable has a - _v_a_l_u_e and zero or more _a_t_t_r_i_b_u_t_e_s. Attributes are assigned using the - ddeeccllaarree builtin command (see ddeeccllaarree below in SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS). + ber, or one of the special characters listed below under SSppeecciiaall PPaarraa-- + mmeetteerrss. A _v_a_r_i_a_b_l_e is a parameter denoted by a _n_a_m_e. A variable has a + _v_a_l_u_e and zero or more _a_t_t_r_i_b_u_t_e_s. Attributes are assigned using the + ddeeccllaarree builtin command (see ddeeccllaarree below in SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS). + The eexxppoorrtt and rreeaaddoonnllyy builtins assign specific attributes. A parameter is set if it has been assigned a value. The null string is - a valid value. Once a variable is set, it may be unset only by using + a valid value. Once a variable is set, it may be unset only by using the uunnsseett builtin command (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). - A _v_a_r_i_a_b_l_e may be assigned to by a statement of the form + A _v_a_r_i_a_b_l_e is assigned to using a statement of the form _n_a_m_e=[_v_a_l_u_e] - If _v_a_l_u_e is not given, the variable is assigned the null string. All - _v_a_l_u_e_s undergo tilde expansion, parameter and variable expansion, com- - mand substitution, arithmetic expansion, and quote removal (see EEXXPPAANN-- + If _v_a_l_u_e is not given, the variable is assigned the null string. All + _v_a_l_u_e_s undergo tilde expansion, parameter and variable expansion, com- + mand substitution, arithmetic expansion, and quote removal (see EEXXPPAANN-- SSIIOONN below). If the variable has its iinntteeggeerr attribute set, then _v_a_l_u_e - is evaluated as an arithmetic expression even if the $((...)) expansion + is evaluated as an arithmetic expression even if the $$((((...)))) expansion is not used (see AArriitthhmmeettiicc EExxppaannssiioonn below). Word splitting and path- name expansion are not performed. Assignment statements may also ap- pear as arguments to the aalliiaass, ddeeccllaarree, ttyyppeesseett, eexxppoorrtt, rreeaaddoonnllyy, and - llooccaall builtin commands (_d_e_c_l_a_r_a_t_i_o_n commands). When in _p_o_s_i_x _m_o_d_e, - these builtins may appear in a command after one or more instances of + llooccaall builtin commands (_d_e_c_l_a_r_a_t_i_o_n commands). When in posix mode, + these builtins may appear in a command after one or more instances of the ccoommmmaanndd builtin and retain these assignment statement properties. - In the context where an assignment statement is assigning a value to a - shell variable or array index, the += operator can be used to append to - or add to the variable's previous value. This includes arguments to - builtin commands such as ddeeccllaarree that accept assignment statements - (_d_e_c_l_a_r_a_t_i_o_n commands). When += is applied to a variable for which the - iinntteeggeerr attribute has been set, _v_a_l_u_e is evaluated as an arithmetic ex- - pression and added to the variable's current value, which is also eval- - uated. When += is applied to an array variable using compound assign- - ment (see AArrrraayyss below), the variable's value is not unset (as it is - when using =), and new values are appended to the array beginning at - one greater than the array's maximum index (for indexed arrays) or - added as additional key-value pairs in an associative array. When ap- - plied to a string-valued variable, _v_a_l_u_e is expanded and appended to + In the context where an assignment statement is assigning a value to a + shell variable or array index, the "+=" operator appends to or adds to + the variable's previous value. This includes arguments to _d_e_c_l_a_r_a_t_i_o_n + commands such as ddeeccllaarree that accept assignment statements. When "+=" + is applied to a variable for which the iinntteeggeerr attribute has been set, + the variable's current value and _v_a_l_u_e are each evaluated as arithmetic + expressions, and the sum of the results is assigned as the variable's + value. The current value is usually an integer constant, but may be an + expression. When "+=" is applied to an array variable using compound + assignment (see AArrrraayyss below), the variable's value is not unset (as it + is when using "="), and new values are appended to the array beginning + at one greater than the array's maximum index (for indexed arrays) or + added as additional key-value pairs in an associative array. When ap- + plied to a string-valued variable, _v_a_l_u_e is expanded and appended to the variable's value. A variable can be assigned the _n_a_m_e_r_e_f attribute using the --nn option to @@ -736,25 +785,31 @@ PPAARRAAMMEETTEERRSS itself), the operation is actually performed on the variable specified by the nameref variable's value. A nameref is commonly used within shell functions to refer to a variable whose name is passed as an argu- - ment to the function. For instance, if a variable name is passed to a + ment to the function. For instance, if a variable name is passed to a shell function as its first argument, running + declare -n ref=$1 - inside the function creates a nameref variable rreeff whose value is the - variable name passed as the first argument. References and assignments - to rreeff, and changes to its attributes, are treated as references, as- - signments, and attribute modifications to the variable whose name was - passed as $$11. If the control variable in a ffoorr loop has the nameref - attribute, the list of words can be a list of shell variables, and a - name reference will be established for each word in the list, in turn, - when the loop is executed. Array variables cannot be given the nnaammeerreeff - attribute. However, nameref variables can reference array variables - and subscripted array variables. Namerefs can be unset using the --nn - option to the uunnsseett builtin. Otherwise, if uunnsseett is executed with the - name of a nameref variable as an argument, the variable referenced by - the nameref variable will be unset. + + inside the function creates a local nameref variable rreeff whose value is + the variable name passed as the first argument. References and assign- + ments to rreeff, and changes to its attributes, are treated as references, + assignments, and attribute modifications to the variable whose name was + passed as $$11. If the control variable in a ffoorr loop has the nameref + attribute, the list of words can be a list of shell variables, and a + name reference is established for each word in the list, in turn, when + the loop is executed. Array variables cannot be given the nnaammeerreeff at- + tribute. However, nameref variables can reference array variables and + subscripted array variables. Namerefs can be unset using the --nn option + to the uunnsseett builtin. Otherwise, if uunnsseett is executed with the name of + a nameref variable as an argument, the variable referenced by the + nameref variable is unset. + + When the shell starts, it reads its environment and creates a shell + variable from each environment variable that has a valid name, as de- + scribed below (see EENNVVIIRROONNMMEENNTT). PPoossiittiioonnaall PPaarraammeetteerrss - A _p_o_s_i_t_i_o_n_a_l _p_a_r_a_m_e_t_e_r is a parameter denoted by one or more digits, + A _p_o_s_i_t_i_o_n_a_l _p_a_r_a_m_e_t_e_r is a parameter denoted by one or more digits, other than the single digit 0. Positional parameters are assigned from the shell's arguments when it is invoked, and may be reassigned using the sseett builtin command. Positional parameters may not be assigned to @@ -762,91 +817,100 @@ PPAARRAAMMEETTEERRSS replaced when a shell function is executed (see FFUUNNCCTTIIOONNSS below). When a positional parameter consisting of more than a single digit is - expanded, it must be enclosed in braces (see EEXXPPAANNSSIIOONN below). + expanded, it must be enclosed in braces (see EEXXPPAANNSSIIOONN below). Without + braces, a digit following $ can only refer to one of the first nine po- + sitional parameters ($$11--$$99) or the special parameter $$00 (see the next + section). SSppeecciiaall PPaarraammeetteerrss - The shell treats several parameters specially. These parameters may - only be referenced; assignment to them is not allowed. - ** Expands to the positional parameters, starting from one. When - the expansion is not within double quotes, each positional pa- - rameter expands to a separate word. In contexts where it is - performed, those words are subject to further word splitting and - pathname expansion. When the expansion occurs within double - quotes, it expands to a single word with the value of each pa- - rameter separated by the first character of the IIFFSS special - variable. That is, "$$**" is equivalent to "$$11_c$$22_c......", where _c - is the first character of the value of the IIFFSS variable. If IIFFSS - is unset, the parameters are separated by spaces. If IIFFSS is + The shell treats several parameters specially. These parameters may + only be referenced; assignment to them is not allowed. Special parame- + ters are denoted by one of the following characters. + + ** ($$**) Expands to the positional parameters, starting from one. + When the expansion is not within double quotes, each positional + parameter expands to a separate word. In contexts where word + expansions are performed, those words are subject to further + word splitting and pathname expansion. When the expansion oc- + curs within double quotes, it expands to a single word with the + value of each parameter separated by the first character of the + IIFFSS variable. That is, ""$$**"" is equivalent to ""$$11_c$$22_c......"", where + _c is the first character of the value of the IIFFSS variable. If + IIFFSS is unset, the parameters are separated by spaces. If IIFFSS is null, the parameters are joined without intervening separators. - @@ Expands to the positional parameters, starting from one. In - contexts where word splitting is performed, this expands each + @@ ($$@@) Expands to the positional parameters, starting from one. + In contexts where word splitting is performed, this expands each positional parameter to a separate word; if not within double quotes, these words are subject to word splitting. In contexts - where word splitting is not performed, this expands to a single - word with each positional parameter separated by a space. When - the expansion occurs within double quotes, each parameter ex- - pands to a separate word. That is, "$$@@" is equivalent to "$$11" - "$$22" ... If the double-quoted expansion occurs within a word, - the expansion of the first parameter is joined with the begin- - ning part of the original word, and the expansion of the last - parameter is joined with the last part of the original word. - When there are no positional parameters, "$$@@" and $$@@ expand to - nothing (i.e., they are removed). - ## Expands to the number of positional parameters in decimal. - ?? Expands to the exit status of the most recently executed fore- - ground pipeline. - -- Expands to the current option flags as specified upon invoca- - tion, by the sseett builtin command, or those set by the shell it- - self (such as the --ii option). - $$ Expands to the process ID of the shell. In a subshell, it ex- - pands to the process ID of the current shell, not the subshell. - !! Expands to the process ID of the job most recently placed into - the background, whether executed as an asynchronous command or - using the bbgg builtin (see JJOOBB CCOONNTTRROOLL below). - 00 Expands to the name of the shell or shell script. This is set - at shell initialization. If bbaasshh is invoked with a file of com- - mands, $$00 is set to the name of that file. If bbaasshh is started - with the --cc option, then $$00 is set to the first argument after - the string to be executed, if one is present. Otherwise, it is - set to the filename used to invoke bbaasshh, as given by argument - zero. + where word splitting is not performed, such as the value portion + of an assignment statement, this expands to a single word with + each positional parameter separated by a space. When the expan- + sion occurs within double quotes, and word splitting is per- + formed, each parameter expands to a separate word. That is, + ""$$@@"" is equivalent to ""$$11"" ""$$22"" ...... If the double-quoted expan- + sion occurs within a word, the expansion of the first parameter + is joined with the expansion of the beginning part of the origi- + nal word, and the expansion of the last parameter is joined with + the expansion of the last part of the original word. When there + are no positional parameters, ""$$@@"" and $$@@ expand to nothing + (i.e., they are removed). + ## ($$##) Expands to the number of positional parameters in decimal. + ?? ($$??) Expands to the exit status of the most recently executed + command. + -- ($$--) Expands to the current option flags as specified upon invo- + cation, by the sseett builtin command, or those set by the shell + itself (such as the --ii option). + $$ ($$$$) Expands to the process ID of the shell. In a subshell, it + expands to the process ID of the parent shell, not the subshell. + !! ($$!!)Expands to the process ID of the job most recently placed + into the background, whether executed as an asynchronous command + or using the bbgg builtin (see JJOOBB CCOONNTTRROOLL below). + 00 ($$00) Expands to the name of the shell or shell script. This is + set at shell initialization. If bbaasshh is invoked with a file of + commands, $$00 is set to the name of that file. If bbaasshh is + started with the --cc option, then $$00 is set to the first argument + after the string to be executed, if one is present. Otherwise, + it is set to the filename used to invoke bbaasshh, as given by argu- + ment zero. SShheellll VVaarriiaabblleess - The following variables are set by the shell: - - __ At shell startup, set to the pathname used to invoke the shell - or shell script being executed as passed in the environment or - argument list. Subsequently, expands to the last argument to - the previous simple command executed in the foreground, after - expansion. Also set to the full pathname used to invoke each - command executed and placed in the environment exported to that - command. When checking mail, this parameter holds the name of - the mail file currently being checked. + The shell sets following variables: + + __ ($$__, an underscore) This has a number of meanings depending on + context. At shell startup, __ is set to the pathname used to in- + voke the shell or shell script being executed as passed in the + environment or argument list. Subsequently, it expands to the + last argument to the previous simple command executed in the + foreground, after expansion. It is also set to the full path- + name used to invoke each command executed and placed in the en- + vironment exported to that command. When checking mail, $$__ ex- + pands to the name of the mail file currently being checked. BBAASSHH Expands to the full filename used to invoke this instance of bbaasshh. BBAASSHHOOPPTTSS A colon-separated list of enabled shell options. Each word in the list is a valid argument for the --ss option to the sshhoopptt builtin command (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). The options - appearing in BBAASSHHOOPPTTSS are those reported as _o_n by sshhoopptt. If - this variable is in the environment when bbaasshh starts up, each - shell option in the list will be enabled before reading any - startup files. This variable is read-only. + appearing in BBAASSHHOOPPTTSS are those reported as _o_n by sshhoopptt. If + this variable is in the environment when bbaasshh starts up, the + shell enables each option in the list before reading any startup + files. If this variable is exported, child shells will enable + each option in the list. This variable is read-only. BBAASSHHPPIIDD - Expands to the process ID of the current bbaasshh process. This - differs from $$$$ under certain circumstances, such as subshells - that do not require bbaasshh to be re-initialized. Assignments to - BBAASSHHPPIIDD have no effect. If BBAASSHHPPIIDD is unset, it loses its spe- + Expands to the process ID of the current bbaasshh process. This + differs from $$$$ under certain circumstances, such as subshells + that do not require bbaasshh to be re-initialized. Assignments to + BBAASSHHPPIIDD have no effect. If BBAASSHHPPIIDD is unset, it loses its spe- cial properties, even if it is subsequently reset. BBAASSHH__AALLIIAASSEESS - An associative array variable whose members correspond to the - internal list of aliases as maintained by the aalliiaass builtin. - Elements added to this array appear in the alias list; however, - unsetting array elements currently does not cause aliases to be - removed from the alias list. If BBAASSHH__AALLIIAASSEESS is unset, it loses - its special properties, even if it is subsequently reset. + An associative array variable whose members correspond to the + internal list of aliases as maintained by the aalliiaass builtin. + Elements added to this array appear in the alias list; however, + unsetting array elements currently does not remove aliases from + the alias list. If BBAASSHH__AALLIIAASSEESS is unset, it loses its special + properties, even if it is subsequently reset. BBAASSHH__AARRGGCC - An array variable whose values are the number of parameters in + An array variable whose values are the number of parameters in each frame of the current bbaasshh execution call stack. The number of parameters to the current subroutine (shell function or script executed with .. or ssoouurrccee) is at the top of the stack. @@ -855,39 +919,41 @@ PPAARRAAMMEETTEERRSS extended debugging mode (see the description of the eexxttddeebbuugg op- tion to the sshhoopptt builtin below). Setting eexxttddeebbuugg after the shell has started to execute a script, or referencing this vari- - able when eexxttddeebbuugg is not set, may result in inconsistent val- - ues. + able when eexxttddeebbuugg is not set, may result in inconsistent val- + ues. Assignments to BBAASSHH__AARRGGCC have no effect, and it may not be + unset. BBAASSHH__AARRGGVV - An array variable containing all of the parameters in the cur- + An array variable containing all of the parameters in the cur- rent bbaasshh execution call stack. The final parameter of the last subroutine call is at the top of the stack; the first parameter of the initial call is at the bottom. When a subroutine is exe- - cuted, the parameters supplied are pushed onto BBAASSHH__AARRGGVV. The - shell sets BBAASSHH__AARRGGVV only when in extended debugging mode (see - the description of the eexxttddeebbuugg option to the sshhoopptt builtin be- - low). Setting eexxttddeebbuugg after the shell has started to execute a - script, or referencing this variable when eexxttddeebbuugg is not set, - may result in inconsistent values. + cuted, the shell pushes the supplied parameters onto BBAASSHH__AARRGGVV. + The shell sets BBAASSHH__AARRGGVV only when in extended debugging mode + (see the description of the eexxttddeebbuugg option to the sshhoopptt builtin + below). Setting eexxttddeebbuugg after the shell has started to execute + a script, or referencing this variable when eexxttddeebbuugg is not set, + may result in inconsistent values. Assignments to BBAASSHH__AARRGGVV + have no effect, and it may not be unset. BBAASSHH__AARRGGVV00 - When referenced, this variable expands to the name of the shell + When referenced, this variable expands to the name of the shell or shell script (identical to $$00; see the description of special - parameter 0 above). Assignment to BBAASSHH__AARRGGVV00 causes the value - assigned to also be assigned to $$00. If BBAASSHH__AARRGGVV00 is unset, it - loses its special properties, even if it is subsequently reset. + parameter 0 above). Assigning a value to BBAASSHH__AARRGGVV00 sets $$00 to + the same value. If BBAASSHH__AARRGGVV00 is unset, it loses its special + properties, even if it is subsequently reset. BBAASSHH__CCMMDDSS An associative array variable whose members correspond to the internal hash table of commands as maintained by the hhaasshh - builtin. Elements added to this array appear in the hash table; - however, unsetting array elements currently does not cause com- - mand names to be removed from the hash table. If BBAASSHH__CCMMDDSS is - unset, it loses its special properties, even if it is subse- - quently reset. + builtin. Adding elements to this array makes them appear in the + hash table; however, unsetting array elements currently does not + remove command names from the hash table. If BBAASSHH__CCMMDDSS is un- + set, it loses its special properties, even if it is subsequently + reset. BBAASSHH__CCOOMMMMAANNDD - The command currently being executed or about to be executed, - unless the shell is executing a command as the result of a trap, - in which case it is the command executing at the time of the - trap. If BBAASSHH__CCOOMMMMAANNDD is unset, it loses its special proper- - ties, even if it is subsequently reset. + Expands to the command currently being executed or about to be + executed, unless the shell is executing a command as the result + of a trap, in which case it is the command executing at the time + of the trap. If BBAASSHH__CCOOMMMMAANNDD is unset, it loses its special + properties, even if it is subsequently reset. BBAASSHH__EEXXEECCUUTTIIOONN__SSTTRRIINNGG The command argument to the --cc invocation option. BBAASSHH__LLIINNEENNOO @@ -896,11 +962,17 @@ PPAARRAAMMEETTEERRSS $${{BBAASSHH__LLIINNEENNOO[[_$_i]]}} is the line number in the source file ($${{BBAASSHH__SSOOUURRCCEE[[_$_i_+_1]]}}) where $${{FFUUNNCCNNAAMMEE[[_$_i]]}} was called (or $${{BBAASSHH__LLIINNEENNOO[[_$_i_-_1]]}} if referenced within another shell func- - tion). Use LLIINNEENNOO to obtain the current line number. + tion). Use LLIINNEENNOO to obtain the current line number. Assign- + ments to BBAASSHH__LLIINNEENNOO have no effect, and it may not be unset. BBAASSHH__LLOOAADDAABBLLEESS__PPAATTHH - A colon-separated list of directories in which the shell looks - for dynamically loadable builtins specified by the eennaabbllee com- - mand. + A colon-separated list of directories in which the eennaabbllee com- + mand looks for dynamically loadable builtins. + BBAASSHH__MMOONNOOSSEECCOONNDDSS + Each time this variable is referenced, it expands to the value + returned by the system's monotonic clock, if one is available. + If there is no monotonic clock, this is equivalent to EEPPOOCCHHSSEECC-- + OONNDDSS. If BBAASSHH__MMOONNOOSSEECCOONNDDSS is unset, it loses its special prop- + erties, even if it is subsequently reset. BBAASSHH__RREEMMAATTCCHH An array variable whose members are assigned by the ==~~ binary operator to the [[[[ conditional command. The element with index @@ -908,57 +980,65 @@ PPAARRAAMMEETTEERRSS pression. The element with index _n is the portion of the string matching the _nth parenthesized subexpression. BBAASSHH__SSOOUURRCCEE - An array variable whose members are the source filenames where - the corresponding shell function names in the FFUUNNCCNNAAMMEE array + An array variable whose members are the source filenames where + the corresponding shell function names in the FFUUNNCCNNAAMMEE array variable are defined. The shell function $${{FFUUNNCCNNAAMMEE[[_$_i]]}} is de- fined in the file $${{BBAASSHH__SSOOUURRCCEE[[_$_i]]}} and called from - $${{BBAASSHH__SSOOUURRCCEE[[_$_i_+_1]]}}. + $${{BBAASSHH__SSOOUURRCCEE[[_$_i_+_1]]}}. Assignments to BBAASSHH__SSOOUURRCCEE have no ef- + fect, and it may not be unset. BBAASSHH__SSUUBBSSHHEELLLL - Incremented by one within each subshell or subshell environment - when the shell begins executing in that environment. The ini- - tial value is 0. If BBAASSHH__SSUUBBSSHHEELLLL is unset, it loses its spe- + Incremented by one within each subshell or subshell environment + when the shell begins executing in that environment. The ini- + tial value is 0. If BBAASSHH__SSUUBBSSHHEELLLL is unset, it loses its spe- cial properties, even if it is subsequently reset. + BBAASSHH__TTRRAAPPSSIIGG + Set to the signal number corresponding to the trap action being + executed during its execution. See the description of ttrraapp un- + der SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below for information about signal + numbers and trap execution. BBAASSHH__VVEERRSSIINNFFOO A readonly array variable whose members hold version information - for this instance of bbaasshh. The values assigned to the array + for this instance of bbaasshh. The values assigned to the array members are as follows: BBAASSHH__VVEERRSSIINNFFOO[[0]] The major version number (the _r_e_l_e_a_s_e). BBAASSHH__VVEERRSSIINNFFOO[[1]] The minor version number (the _v_e_r_s_i_o_n). BBAASSHH__VVEERRSSIINNFFOO[[2]] The patch level. BBAASSHH__VVEERRSSIINNFFOO[[3]] The build version. - BBAASSHH__VVEERRSSIINNFFOO[[4]] The release status (e.g., _b_e_t_a_1). + BBAASSHH__VVEERRSSIINNFFOO[[4]] The release status (e.g., _b_e_t_a). BBAASSHH__VVEERRSSIINNFFOO[[5]] The value of MMAACCHHTTYYPPEE. BBAASSHH__VVEERRSSIIOONN - Expands to a string describing the version of this instance of - bbaasshh. + Expands to a string describing the version of this instance of + bbaasshh (e.g., 5.2.37(3)-release). CCOOMMPP__CCWWOORRDD - An index into $${{CCOOMMPP__WWOORRDDSS}} of the word containing the current + An index into $${{CCOOMMPP__WWOORRDDSS}} of the word containing the current cursor position. This variable is available only in shell func- tions invoked by the programmable completion facilities (see PPrrooggrraammmmaabbllee CCoommpplleettiioonn below). CCOOMMPP__KKEEYY The key (or final key of a key sequence) used to invoke the cur- - rent completion function. + rent completion function. This variable is available only in + shell functions and external commands invoked by the programma- + ble completion facilities (see PPrrooggrraammmmaabbllee CCoommpplleettiioonn below). CCOOMMPP__LLIINNEE - The current command line. This variable is available only in - shell functions and external commands invoked by the program- - mable completion facilities (see PPrrooggrraammmmaabbllee CCoommpplleettiioonn below). + The current command line. This variable is available only in + shell functions and external commands invoked by the programma- + ble completion facilities (see PPrrooggrraammmmaabbllee CCoommpplleettiioonn below). CCOOMMPP__PPOOIINNTT - The index of the current cursor position relative to the begin- - ning of the current command. If the current cursor position is + The index of the current cursor position relative to the begin- + ning of the current command. If the current cursor position is at the end of the current command, the value of this variable is equal to $${{##CCOOMMPP__LLIINNEE}}. This variable is available only in - shell functions and external commands invoked by the program- - mable completion facilities (see PPrrooggrraammmmaabbllee CCoommpplleettiioonn below). + shell functions and external commands invoked by the programma- + ble completion facilities (see PPrrooggrraammmmaabbllee CCoommpplleettiioonn below). CCOOMMPP__TTYYPPEE - Set to an integer value corresponding to the type of completion - attempted that caused a completion function to be called: _T_A_B, + Set to an integer value corresponding to the type of attempted + completion that caused a completion function to be called: _T_A_B, for normal completion, _?, for listing completions after succes- sive tabs, _!, for listing alternatives on partial word comple- tion, _@, to list completions if the word is not unmodified, or _%, for menu completion. This variable is available only in - shell functions and external commands invoked by the program- - mable completion facilities (see PPrrooggrraammmmaabbllee CCoommpplleettiioonn below). + shell functions and external commands invoked by the programma- + ble completion facilities (see PPrrooggrraammmmaabbllee CCoommpplleettiioonn below). CCOOMMPP__WWOORRDDBBRREEAAKKSS The set of characters that the rreeaaddlliinnee library treats as word separators when performing word completion. If CCOOMMPP__WWOORRDDBBRREEAAKKSS @@ -976,63 +1056,63 @@ PPAARRAAMMEETTEERRSS (see CCoopprroocceesssseess above). DDIIRRSSTTAACCKK An array variable (see AArrrraayyss below) containing the current con- - tents of the directory stack. Directories appear in the stack - in the order they are displayed by the ddiirrss builtin. Assigning + tents of the directory stack. Directories appear in the stack + in the order they are displayed by the ddiirrss builtin. Assigning to members of this array variable may be used to modify directo- ries already in the stack, but the ppuusshhdd and ppooppdd builtins must - be used to add and remove directories. Assignment to this vari- - able will not change the current directory. If DDIIRRSSTTAACCKK is un- + be used to add and remove directories. Assigning to this vari- + able does not change the current directory. If DDIIRRSSTTAACCKK is un- set, it loses its special properties, even if it is subsequently reset. EEPPOOCCHHRREEAALLTTIIMMEE Each time this parameter is referenced, it expands to the number - of seconds since the Unix Epoch (see _t_i_m_e(3)) as a floating + of seconds since the Unix Epoch (see _t_i_m_e(3)) as a floating- point value with micro-second granularity. Assignments to EEPPOOCCHHRREEAALLTTIIMMEE are ignored. If EEPPOOCCHHRREEAALLTTIIMMEE is unset, it loses its special properties, even if it is subsequently reset. EEPPOOCCHHSSEECCOONNDDSS Each time this parameter is referenced, it expands to the number - of seconds since the Unix Epoch (see _t_i_m_e(3)). Assignments to - EEPPOOCCHHSSEECCOONNDDSS are ignored. If EEPPOOCCHHSSEECCOONNDDSS is unset, it loses + of seconds since the Unix Epoch (see _t_i_m_e(3)). Assignments to + EEPPOOCCHHSSEECCOONNDDSS are ignored. If EEPPOOCCHHSSEECCOONNDDSS is unset, it loses its special properties, even if it is subsequently reset. - EEUUIIDD Expands to the effective user ID of the current user, initial- + EEUUIIDD Expands to the effective user ID of the current user, initial- ized at shell startup. This variable is readonly. FFUUNNCCNNAAMMEE - An array variable containing the names of all shell functions + An array variable containing the names of all shell functions currently in the execution call stack. The element with index 0 is the name of any currently-executing shell function. The bot- - tom-most element (the one with the highest index) is "main". - This variable exists only when a shell function is executing. - Assignments to FFUUNNCCNNAAMMEE have no effect. If FFUUNNCCNNAAMMEE is unset, - it loses its special properties, even if it is subsequently re- + tom-most element (the one with the highest index) is "main". + This variable exists only when a shell function is executing. + Assignments to FFUUNNCCNNAAMMEE have no effect. If FFUUNNCCNNAAMMEE is unset, + it loses its special properties, even if it is subsequently re- set. - This variable can be used with BBAASSHH__LLIINNEENNOO and BBAASSHH__SSOOUURRCCEE. - Each element of FFUUNNCCNNAAMMEE has corresponding elements in + This variable can be used with BBAASSHH__LLIINNEENNOO and BBAASSHH__SSOOUURRCCEE. + Each element of FFUUNNCCNNAAMMEE has corresponding elements in BBAASSHH__LLIINNEENNOO and BBAASSHH__SSOOUURRCCEE to describe the call stack. For in- stance, $${{FFUUNNCCNNAAMMEE[[_$_i]]}} was called from the file $${{BBAASSHH__SSOOUURRCCEE[[_$_i_+_1]]}} at line number $${{BBAASSHH__LLIINNEENNOO[[_$_i]]}}. The ccaalllleerr builtin displays the current call stack using this infor- mation. - GGRROOUUPPSS An array variable containing the list of groups of which the + GGRROOUUPPSS An array variable containing the list of groups of which the current user is a member. Assignments to GGRROOUUPPSS have no effect. If GGRROOUUPPSS is unset, it loses its special properties, even if it is subsequently reset. HHIISSTTCCMMDD The history number, or index in the history list, of the current - command. Assignments to HHIISSTTCCMMDD are ignored. If HHIISSTTCCMMDD is un- - set, it loses its special properties, even if it is subsequently - reset. + command. Assignments to HHIISSTTCCMMDD have no effect. If HHIISSTTCCMMDD is + unset, it loses its special properties, even if it is subse- + quently reset. HHOOSSTTNNAAMMEE Automatically set to the name of the current host. HHOOSSTTTTYYPPEE - Automatically set to a string that uniquely describes the type - of machine on which bbaasshh is executing. The default is system- + Automatically set to a string that uniquely describes the type + of machine on which bbaasshh is executing. The default is system- dependent. - LLIINNEENNOO Each time this parameter is referenced, the shell substitutes a - decimal number representing the current sequential line number - (starting with 1) within a script or function. When not in a - script or function, the value substituted is not guaranteed to + LLIINNEENNOO Each time this parameter is referenced, the shell substitutes a + decimal number representing the current sequential line number + (starting with 1) within a script or function. When not in a + script or function, the value substituted is not guaranteed to be meaningful. If LLIINNEENNOO is unset, it loses its special proper- ties, even if it is subsequently reset. MMAACCHHTTYYPPEE @@ -1052,18 +1132,24 @@ PPAARRAAMMEETTEERRSS dent. PPIIPPEESSTTAATTUUSS An array variable (see AArrrraayyss below) containing a list of exit - status values from the processes in the most-recently-executed - foreground pipeline (which may contain only a single command). - PPPPIIDD The process ID of the shell's parent. This variable is read- + status values from the commands in the most-recently-executed + foreground pipeline, which may consist of only a simple command + (see SSHHEELLLL GGRRAAMMMMAARR above). BBaasshh sets PPIIPPEESSTTAATTUUSS after executing + multi-element pipelines, timed and negated pipelines, simple + commands, subshells created with the ( operator, the [[[[ and (((( + compound commands, and after error conditions that result in the + shell aborting command execution. + PPPPIIDD The process ID of the shell's parent. This variable is read- only. PPWWDD The current working directory as set by the ccdd command. - RRAANNDDOOMM Each time this parameter is referenced, it expands to a random - integer between 0 and 32767. Assigning a value to RRAANNDDOOMM ini- - tializes (seeds) the sequence of random numbers. If RRAANNDDOOMM is - unset, it loses its special properties, even if it is subse- - quently reset. + RRAANNDDOOMM Each time this parameter is referenced, it expands to a random + integer between 0 and 32767. Assigning a value to RRAANNDDOOMM ini- + tializes (seeds) the sequence of random numbers. Seeding the + random number generator with the same constant value produces + the same sequence of values. If RRAANNDDOOMM is unset, it loses its + special properties, even if it is subsequently reset. RREEAADDLLIINNEE__AARRGGUUMMEENNTT - Any numeric argument given to a readline command that was de- + Any numeric argument given to a rreeaaddlliinnee command that was de- fined using "bind -x" (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below) when it was invoked. RREEAADDLLIINNEE__LLIINNEE @@ -1071,13 +1157,13 @@ PPAARRAAMMEETTEERRSS (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). RREEAADDLLIINNEE__MMAARRKK The position of the mark (saved insertion point) in the rreeaaddlliinnee - line buffer, for use with "bind -x" (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS + line buffer, for use with "bind -x" (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). The characters between the insertion point and the mark are often called the _r_e_g_i_o_n. RREEAADDLLIINNEE__PPOOIINNTT The position of the insertion point in the rreeaaddlliinnee line buffer, for use with "bind -x" (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). - RREEPPLLYY Set to the line of input read by the rreeaadd builtin command when + RREEPPLLYY Set to the line of input read by the rreeaadd builtin command when no arguments are supplied. SSEECCOONNDDSS Each time this parameter is referenced, it expands to the number @@ -1085,70 +1171,74 @@ PPAARRAAMMEETTEERRSS SSEECCOONNDDSS, the value returned upon subsequent references is the number of seconds since the assignment plus the value assigned. The number of seconds at shell invocation and the current time - are always determined by querying the system clock. If SSEECCOONNDDSS - is unset, it loses its special properties, even if it is subse- - quently reset. + are always determined by querying the system clock at one-second + resolution. If SSEECCOONNDDSS is unset, it loses its special proper- + ties, even if it is subsequently reset. SSHHEELLLLOOPPTTSS - A colon-separated list of enabled shell options. Each word in - the list is a valid argument for the --oo option to the sseett + A colon-separated list of enabled shell options. Each word in + the list is a valid argument for the --oo option to the sseett builtin command (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). The options appearing in SSHHEELLLLOOPPTTSS are those reported as _o_n by sseett --oo. If - this variable is in the environment when bbaasshh starts up, each - shell option in the list will be enabled before reading any - startup files. This variable is read-only. + this variable is in the environment when bbaasshh starts up, the + shell enables each option in the list before reading any startup + files. If this variable is exported, child shells will enable + each option in the list. This variable is read-only. SSHHLLVVLL Incremented by one each time an instance of bbaasshh is started. SSRRAANNDDOOMM - This variable expands to a 32-bit pseudo-random number each time - it is referenced. The random number generator is not linear on - systems that support /dev/urandom or _a_r_c_4_r_a_n_d_o_m, so each re- - turned number has no relationship to the numbers preceding it. + Each time it is referenced, this variable expands to a 32-bit + pseudo-random number. The random number generator is not linear + on systems that support _/_d_e_v_/_u_r_a_n_d_o_m or _a_r_c_4_r_a_n_d_o_m(3), so each + returned number has no relationship to the numbers preceding it. The random number generator cannot be seeded, so assignments to this variable have no effect. If SSRRAANNDDOOMM is unset, it loses its special properties, even if it is subsequently reset. UUIIDD Expands to the user ID of the current user, initialized at shell startup. This variable is readonly. - The following variables are used by the shell. In some cases, bbaasshh as- - signs a default value to a variable; these cases are noted below. + The shell uses the following variables. In some cases, bbaasshh assigns a + default value to a variable; these cases are noted below. BBAASSHH__CCOOMMPPAATT The value is used to set the shell's compatibility level. See SSHHEELLLL CCOOMMPPAATTIIBBIILLIITTYY MMOODDEE below for a description of the various compatibility levels and their effects. The value may be a dec- - imal number (e.g., 4.2) or an integer (e.g., 42) corresponding - to the desired compatibility level. If BBAASSHH__CCOOMMPPAATT is unset or - set to the empty string, the compatibility level is set to the - default for the current version. If BBAASSHH__CCOOMMPPAATT is set to a - value that is not one of the valid compatibility levels, the - shell prints an error message and sets the compatibility level - to the default for the current version. The valid values corre- - spond to the compatibility levels described below under SSHHEELLLL - CCOOMMPPAATTIIBBIILLIITTYY MMOODDEE. For example, 4.2 and 42 are valid values - that correspond to the ccoommppaatt4422 sshhoopptt option and set the compat- - ibility level to 42. The current version is also a valid value. + imal number (e.g., 4.2) or an integer (e.g., 42) corresponding + to the desired compatibility level. If BBAASSHH__CCOOMMPPAATT is unset or + set to the empty string, the compatibility level is set to the + default for the current version. If BBAASSHH__CCOOMMPPAATT is set to a + value that is not one of the valid compatibility levels, the + shell prints an error message and sets the compatibility level + to the default for the current version. A subset of the valid + values correspond to the compatibility levels described below + under SSHHEELLLL CCOOMMPPAATTIIBBIILLIITTYY MMOODDEE. For example, 4.2 and 42 are + valid values that correspond to the ccoommppaatt4422 sshhoopptt option and + set the compatibility level to 42. The current version is also + a valid value. BBAASSHH__EENNVV If this parameter is set when bbaasshh is executing a shell script, - its value is interpreted as a filename containing commands to - initialize the shell, as in _~_/_._b_a_s_h_r_c. The value of BBAASSHH__EENNVV is - subjected to parameter expansion, command substitution, and - arithmetic expansion before being interpreted as a filename. - PPAATTHH is not used to search for the resultant filename. + its expanded value is interpreted as a filename containing com- + mands to initialize the shell before it reads and executes com- + mands from the script. The value of BBAASSHH__EENNVV is subjected to + parameter expansion, command substitution, and arithmetic expan- + sion before being interpreted as a filename. PPAATTHH is not used + to search for the resultant filename. BBAASSHH__XXTTRRAACCEEFFDD If set to an integer corresponding to a valid file descriptor, - bbaasshh will write the trace output generated when _s_e_t _-_x is en- - abled to that file descriptor. The file descriptor is closed - when BBAASSHH__XXTTRRAACCEEFFDD is unset or assigned a new value. Unsetting - BBAASSHH__XXTTRRAACCEEFFDD or assigning it the empty string causes the trace - output to be sent to the standard error. Note that setting - BBAASSHH__XXTTRRAACCEEFFDD to 2 (the standard error file descriptor) and then - unsetting it will result in the standard error being closed. - CCDDPPAATTHH The search path for the ccdd command. This is a colon-separated - list of directories in which the shell looks for destination di- - rectories specified by the ccdd command. A sample value is + bbaasshh writes the trace output generated when "set -x" is enabled + to that file descriptor, instead of the standard error. The + file descriptor is closed when BBAASSHH__XXTTRRAACCEEFFDD is unset or as- + signed a new value. Unsetting BBAASSHH__XXTTRRAACCEEFFDD or assigning it the + empty string causes the trace output to be sent to the standard + error. Note that setting BBAASSHH__XXTTRRAACCEEFFDD to 2 (the standard error + file descriptor) and then unsetting it will result in the stan- + dard error being closed. + CCDDPPAATTHH The search path for the ccdd command. This is a colon-separated + list of directories where the shell looks for directories speci- + fied as arguments to the ccdd command. A sample value is ".:~:/usr". CCHHIILLDD__MMAAXX Set the number of exited child status values for the shell to - remember. Bash will not allow this value to be decreased below + remember. BBaasshh will not allow this value to be decreased below a POSIX-mandated minimum, and there is a maximum value (cur- rently 8192) that this may not exceed. The minimum value is system-dependent. @@ -1159,85 +1249,138 @@ PPAARRAAMMEETTEERRSS receipt of a SSIIGGWWIINNCCHH. CCOOMMPPRREEPPLLYY An array variable from which bbaasshh reads the possible completions - generated by a shell function invoked by the programmable com- - pletion facility (see PPrrooggrraammmmaabbllee CCoommpplleettiioonn below). Each ar- + generated by a shell function invoked by the programmable com- + pletion facility (see PPrrooggrraammmmaabbllee CCoommpplleettiioonn below). Each ar- ray element contains one possible completion. - EEMMAACCSS If bbaasshh finds this variable in the environment when the shell - starts with value "t", it assumes that the shell is running in + EEMMAACCSS If bbaasshh finds this variable in the environment when the shell + starts with value "t", it assumes that the shell is running in an Emacs shell buffer and disables line editing. - EENNVV Expanded and executed similarly to BBAASSHH__EENNVV (see IINNVVOOCCAATTIIOONN - above) when an interactive shell is invoked in _p_o_s_i_x _m_o_d_e. + EENNVV Expanded and executed similarly to BBAASSHH__EENNVV (see IINNVVOOCCAATTIIOONN + above) when an interactive shell is invoked in posix mode. EEXXEECCIIGGNNOORREE - A colon-separated list of shell patterns (see PPaatttteerrnn MMaattcchhiinngg) - defining the list of filenames to be ignored by command search - using PPAATTHH. Files whose full pathnames match one of these pat- - terns are not considered executable files for the purposes of + A colon-separated list of shell patterns (see PPaatttteerrnn MMaattcchhiinngg) + defining the set of filenames to be ignored by command search + using PPAATTHH. Files whose full pathnames match one of these pat- + terns are not considered executable files for the purposes of completion and command execution via PPAATTHH lookup. This does not affect the behavior of the [[, tteesstt, and [[[[ commands. Full path- - names in the command hash table are not subject to EEXXEECCIIGGNNOORREE. - Use this variable to ignore shared library files that have the - executable bit set, but are not executable files. The pattern + names in the command hash table are not subject to EEXXEECCIIGGNNOORREE. + Use this variable to ignore shared library files that have the + executable bit set, but are not executable files. The pattern matching honors the setting of the eexxttgglloobb shell option. FFCCEEDDIITT The default editor for the ffcc builtin command. FFIIGGNNOORREE - A colon-separated list of suffixes to ignore when performing + A colon-separated list of suffixes to ignore when performing filename completion (see RREEAADDLLIINNEE below). A filename whose suf- fix matches one of the entries in FFIIGGNNOORREE is excluded from the list of matched filenames. A sample value is ".o:~". FFUUNNCCNNEESSTT If set to a numeric value greater than 0, defines a maximum function nesting level. Function invocations that exceed this - nesting level will cause the current command to abort. + nesting level cause the current command to abort. GGLLOOBBIIGGNNOORREE A colon-separated list of patterns defining the set of file names to be ignored by pathname expansion. If a file name matched by a pathname expansion pattern also matches one of the - patterns in GGLLOOBBIIGGNNOORREE, it is removed from the list of matches. + patterns in GGLLOOBBIIGGNNOORREE, it is removed from the list of matches. + The pattern matching honors the setting of the eexxttgglloobb shell op- + tion. + GGLLOOBBSSOORRTT + Controls how the results of pathname expansion are sorted. The + value of this variable specifies the sort criteria and sort or- + der for the results of pathname expansion. If this variable is + unset or set to the null string, pathname expansion uses the + historical behavior of sorting by name, in ascending lexico- + graphic order as determined by the LLCC__CCOOLLLLAATTEE shell variable. + + If set, a valid value begins with an optional _+, which is ig- + nored, or _-, which reverses the sort order from ascending to de- + scending, followed by a sort specifier. The valid sort speci- + fiers are _n_a_m_e, _n_u_m_e_r_i_c, _s_i_z_e, _m_t_i_m_e, _a_t_i_m_e, _c_t_i_m_e, and _b_l_o_c_k_s, + which sort the files on name, names in numeric rather than lexi- + cographic order, file size, modification time, access time, in- + ode change time, and number of blocks, respectively. If any of + the non-name keys compare as equal (e.g., if two files are the + same size), sorting uses the name as a secondary sort key. + + For example, a value of _-_m_t_i_m_e sorts the results in descending + order by modification time (newest first). + + The _n_u_m_e_r_i_c specifier treats names consisting solely of digits + as numbers and sorts them using their numeric value (so "2" + sorts before "10", for example). When using _n_u_m_e_r_i_c, names con- + taining non-digits sort after all the all-digit names and are + sorted by name using the traditional behavior. + + A sort specifier of _n_o_s_o_r_t disables sorting completely; bbaasshh re- + turns the results in the order they are read from the file sys- + tem, ignoring any leading _-. + + If the sort specifier is missing, it defaults to _n_a_m_e, so a + value of _+ is equivalent to the null string, and a value of _- + sorts by name in descending order. Any invalid value restores + the historical sorting behavior. HHIISSTTCCOONNTTRROOLL A colon-separated list of values controlling how commands are - saved on the history list. If the list of values includes _i_g_- - _n_o_r_e_s_p_a_c_e, lines which begin with a ssppaaccee character are not + saved on the history list. If the list of values includes + _i_g_n_o_r_e_s_p_a_c_e, lines which begin with a ssppaaccee character are not saved in the history list. A value of _i_g_n_o_r_e_d_u_p_s causes lines - matching the previous history entry to not be saved. A value of + matching the previous history entry not to be saved. A value of _i_g_n_o_r_e_b_o_t_h is shorthand for _i_g_n_o_r_e_s_p_a_c_e and _i_g_n_o_r_e_d_u_p_s. A value of _e_r_a_s_e_d_u_p_s causes all previous lines matching the current line - to be removed from the history list before that line is saved. - Any value not in the above list is ignored. If HHIISSTTCCOONNTTRROOLL is - unset, or does not include a valid value, all lines read by the - shell parser are saved on the history list, subject to the value - of HHIISSTTIIGGNNOORREE. The second and subsequent lines of a multi-line - compound command are not tested, and are added to the history - regardless of the value of HHIISSTTCCOONNTTRROOLL. + to be removed from the history list before that line is saved. + Any value not in the above list is ignored. If HHIISSTTCCOONNTTRROOLL is + unset, or does not include a valid value, bbaasshh saves all lines + read by the shell parser on the history list, subject to the + value of HHIISSTTIIGGNNOORREE. If the first line of a multi-line compound + command was saved, the second and subsequent lines are not + tested, and are added to the history regardless of the value of + HHIISSTTCCOONNTTRROOLL. If the first line was not saved, the second and + subsequent lines of the command are not saved either. HHIISSTTFFIILLEE The name of the file in which command history is saved (see HHIISS-- - TTOORRYY below). The default value is _~_/_._b_a_s_h___h_i_s_t_o_r_y. If unset, - the command history is not saved when a shell exits. + TTOORRYY below). BBaasshh assigns a default value of _~_/_._b_a_s_h___h_i_s_t_o_r_y. + If HHIISSTTFFIILLEE is unset or null, the shell does not save the com- + mand history when it exits. HHIISSTTFFIILLEESSIIZZEE The maximum number of lines contained in the history file. When - this variable is assigned a value, the history file is trun- - cated, if necessary, to contain no more than that number of - lines by removing the oldest entries. The history file is also - truncated to this size after writing it when a shell exits. If - the value is 0, the history file is truncated to zero size. - Non-numeric values and numeric values less than zero inhibit - truncation. The shell sets the default value to the value of - HHIISSTTSSIIZZEE after reading any startup files. + this variable is assigned a value, the history file is trun- + cated, if necessary, to contain no more than the number of his- + tory entries that total no more than that number of lines by re- + moving the oldest entries. If the history list contains multi- + line entries, the history file may contain more lines than this + maximum to avoid leaving partial history entries. The history + file is also truncated to this size after writing it when a + shell exits or by the hhiissttoorryy builtin. If the value is 0, the + history file is truncated to zero size. Non-numeric values and + numeric values less than zero inhibit truncation. The shell + sets the default value to the value of HHIISSTTSSIIZZEE after reading + any startup files. HHIISSTTIIGGNNOORREE A colon-separated list of patterns used to decide which command - lines should be saved on the history list. Each pattern is an- - chored at the beginning of the line and must match the complete - line (no implicit `**' is appended). Each pattern is tested + lines should be saved on the history list. If a command line + matches one of the patterns in the value of HHIISSTTIIGGNNOORREE, it is + not saved on the history list. Each pattern is anchored at the + beginning of the line and must match the complete line (bbaasshh + does not implicitly append a "**"). Each pattern is tested against the line after the checks specified by HHIISSTTCCOONNTTRROOLL are applied. In addition to the normal shell pattern matching char- - acters, `&&' matches the previous history line. `&&' may be es- - caped using a backslash; the backslash is removed before at- - tempting a match. The second and subsequent lines of a multi- - line compound command are not tested, and are added to the his- - tory regardless of the value of HHIISSTTIIGGNNOORREE. The pattern match- - ing honors the setting of the eexxttgglloobb shell option. + acters, "&&" matches the previous history line. A backslash es- + capes the "&&"; the backslash is removed before attempting a + match. If the first line of a multi-line compound command was + saved, the second and subsequent lines are not tested, and are + added to the history regardless of the value of HHIISSTTIIGGNNOORREE. If + the first line was not saved, the second and subsequent lines of + the command are not saved either. The pattern matching honors + the setting of the eexxttgglloobb shell option. + HHIISSTTIIGGNNOORREE subsumes some of the function of HHIISSTTCCOONNTTRROOLL. A pat- + tern of "&" is identical to "ignoredups", and a pattern of "[ + ]*" is identical to "ignorespace". Combining these two pat- + terns, separating them with a colon, provides the functionality + of "ignoreboth". HHIISSTTSSIIZZEE - The number of commands to remember in the command history (see - HHIISSTTOORRYY below). If the value is 0, commands are not saved in + The number of commands to remember in the command history (see + HHIISSTTOORRYY below). If the value is 0, commands are not saved in the history list. Numeric values less than zero result in every command being saved on the history list (there is no limit). The shell sets the default value to 500 after reading any @@ -1245,16 +1388,16 @@ PPAARRAAMMEETTEERRSS HHIISSTTTTIIMMEEFFOORRMMAATT If this variable is set and not null, its value is used as a format string for _s_t_r_f_t_i_m_e(3) to print the time stamp associated - with each history entry displayed by the hhiissttoorryy builtin. If - this variable is set, time stamps are written to the history - file so they may be preserved across shell sessions. This uses - the history comment character to distinguish timestamps from - other history lines. + with each history entry displayed by the hhiissttoorryy builtin. If + this variable is set, the shell writes time stamps to the his- + tory file so they may be preserved across shell sessions. This + uses the history comment character to distinguish timestamps + from other history lines. HHOOMMEE The home directory of the current user; the default argument for the ccdd builtin command. The value of this variable is also used when performing tilde expansion. HHOOSSTTFFIILLEE - Contains the name of a file in the same format as _/_e_t_c_/_h_o_s_t_s + Contains the name of a file in the same format as _/_e_t_c_/_h_o_s_t_s that should be read when the shell needs to complete a hostname. The list of possible hostname completions may be changed while the shell is running; the next time hostname completion is at- @@ -1262,19 +1405,19 @@ PPAARRAAMMEETTEERRSS the new file to the existing list. If HHOOSSTTFFIILLEE is set, but has no value, or does not name a readable file, bbaasshh attempts to read _/_e_t_c_/_h_o_s_t_s to obtain the list of possible hostname comple- - tions. When HHOOSSTTFFIILLEE is unset, the hostname list is cleared. + tions. When HHOOSSTTFFIILLEE is unset, bbaasshh clears the hostname list. IIFFSS The _I_n_t_e_r_n_a_l _F_i_e_l_d _S_e_p_a_r_a_t_o_r that is used for word splitting af- - ter expansion and to split lines into words with the rreeaadd - builtin command. The default value is ``''. + ter expansion and to split lines into words with the rreeaadd + builtin command. Word splitting is described below under EEXXPPAANN-- + SSIIOONN. The default value is "". IIGGNNOORREEEEOOFF Controls the action of an interactive shell on receipt of an EEOOFF character as the sole input. If set, the value is the number of consecutive EEOOFF characters which must be typed as the first characters on an input line before bbaasshh exits. If the variable - exists but does not have a numeric value, or has no value, the - default value is 10. If it does not exist, EEOOFF signifies the - end of input to the shell. + is set but does not have a numeric value, or the value is null, + the default value is 10. If it is unset, EEOOFF signifies the end + of input to the shell. IINNPPUUTTRRCC The filename for the rreeaaddlliinnee startup file, overriding the de- fault of _~_/_._i_n_p_u_t_r_c (see RREEAADDLLIINNEE below). @@ -1309,54 +1452,52 @@ PPAARRAAMMEETTEERRSS length for printing selection lists. Automatically set if the cchheecckkwwiinnssiizzee option is enabled or in an interactive shell upon receipt of a SSIIGGWWIINNCCHH. - MMAAIILL If this parameter is set to a file or directory name and the - MMAAIILLPPAATTHH variable is not set, bbaasshh informs the user of the ar- - rival of mail in the specified file or Maildir-format directory. + MMAAIILL If the value is set to a file or directory name and the MMAAIILLPPAATTHH + variable is not set, bbaasshh informs the user of the arrival of + mail in the specified file or Maildir-format directory. MMAAIILLCCHHEECCKK - Specifies how often (in seconds) bbaasshh checks for mail. The de- - fault is 60 seconds. When it is time to check for mail, the - shell does so before displaying the primary prompt. If this - variable is unset, or set to a value that is not a number + Specifies how often (in seconds) bbaasshh checks for mail. The de- + fault is 60 seconds. When it is time to check for mail, the + shell does so before displaying the primary prompt. If this + variable is unset, or set to a value that is not a number greater than or equal to zero, the shell disables mail checking. MMAAIILLPPAATTHH A colon-separated list of filenames to be checked for mail. The message to be printed when mail arrives in a particular file may - be specified by separating the filename from the message with a - `?'. When used in the text of the message, $$__ expands to the - name of the current mailfile. Example: - MMAAIILLPPAATTHH='/var/mail/bfox?"You have mail":~/shell-mail?"$_ has - mail!"' + be specified by separating the filename from the message with a + "?". When used in the text of the message, $$__ expands to the + name of the current mailfile. For example: + MMAAIILLPPAATTHH='/var/mail/bfox?"You have mail":~/shell-mail?"$_ has mail!"' BBaasshh can be configured to supply a default value for this vari- able (there is no value by default), but the location of the user mail files that it uses is system dependent (e.g., /var/mail/$$UUSSEERR). OOPPTTEERRRR If set to the value 1, bbaasshh displays error messages generated by - the ggeettooppttss builtin command (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). - OOPPTTEERRRR is initialized to 1 each time the shell is invoked or a + the ggeettooppttss builtin command (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). + OOPPTTEERRRR is initialized to 1 each time the shell is invoked or a shell script is executed. - PPAATTHH The search path for commands. It is a colon-separated list of - directories in which the shell looks for commands (see CCOOMMMMAANNDD - EEXXEECCUUTTIIOONN below). A zero-length (null) directory name in the + PPAATTHH The search path for commands. It is a colon-separated list of + directories in which the shell looks for commands (see CCOOMMMMAANNDD + EEXXEECCUUTTIIOONN below). A zero-length (null) directory name in the value of PPAATTHH indicates the current directory. A null directory name may appear as two adjacent colons, or as an initial or trailing colon. The default path is system-dependent, and is set by the administrator who installs bbaasshh. A common value is - ``/usr/local/bin:/usr/lo- - cal/sbin:/usr/bin:/usr/sbin:/bin:/sbin''. + /usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin PPOOSSIIXXLLYY__CCOORRRREECCTT If this variable is in the environment when bbaasshh starts, the - shell enters _p_o_s_i_x _m_o_d_e before reading the startup files, as if + shell enters posix mode before reading the startup files, as if the ----ppoossiixx invocation option had been supplied. If it is set - while the shell is running, bbaasshh enables _p_o_s_i_x _m_o_d_e, as if the - command _s_e_t _-_o _p_o_s_i_x had been executed. When the shell enters - _p_o_s_i_x _m_o_d_e, it sets this variable if it was not already set. + while the shell is running, bbaasshh enables posix mode, as if the + command "set -o posix" had been executed. When the shell enters + posix mode, it sets this variable if it was not already set. PPRROOMMPPTT__CCOOMMMMAANNDD - If this variable is set, and is an array, the value of each set - element is executed as a command prior to issuing each primary - prompt. If this is set but not an array variable, its value is + If this variable is set, and is an array, the value of each set + element is executed as a command prior to issuing each primary + prompt. If this is set but not an array variable, its value is used as a command to execute instead. PPRROOMMPPTT__DDIIRRTTRRIIMM - If set to a number greater than zero, the value is used as the + If set to a number greater than zero, the value is used as the number of trailing directory components to retain when expanding the \\ww and \\WW prompt string escapes (see PPRROOMMPPTTIINNGG below). Characters removed are replaced with an ellipsis. @@ -1365,16 +1506,16 @@ PPAARRAAMMEETTEERRSS before the command is executed. PPSS11 The value of this parameter is expanded (see PPRROOMMPPTTIINNGG below) and used as the primary prompt string. The default value is - ``\\ss--\\vv\\$$ ''. + "\s-\v\$ ". PPSS22 The value of this parameter is expanded as with PPSS11 and used as - the secondary prompt string. The default is ``>> ''. + the secondary prompt string. The default is "> ". PPSS33 The value of this parameter is used as the prompt for the sseelleecctt command (see SSHHEELLLL GGRRAAMMMMAARR above). - PPSS44 The value of this parameter is expanded as with PPSS11 and the + PPSS44 The value of this parameter is expanded as with PPSS11 and the value is printed before each command bbaasshh displays during an ex- ecution trace. The first character of the expanded value of PPSS44 is replicated multiple times, as necessary, to indicate multiple - levels of indirection. The default is ``++ ''. + levels of indirection. The default is "+ ". SSHHEELLLL This variable expands to the full pathname to the shell. If it is not set when the shell starts, bbaasshh assigns to it the full pathname of the current user's login shell. @@ -1384,7 +1525,7 @@ PPAARRAAMMEETTEERRSS ttiimmee reserved word should be displayed. The %% character intro- duces an escape sequence that is expanded to a time value or other information. The escape sequences and their meanings are - as follows; the braces denote optional portions. + as follows; the brackets denote optional portions. %%%% A literal %%. %%[[_p]][[ll]]RR The elapsed time in seconds. %%[[_p]][[ll]]UU The number of CPU seconds spent in user mode. @@ -1393,10 +1534,10 @@ PPAARRAAMMEETTEERRSS The optional _p is a digit specifying the _p_r_e_c_i_s_i_o_n, the number of fractional digits after a decimal point. A value of 0 causes - no decimal point or fraction to be output. At most three places - after the decimal point may be specified; values of _p greater - than 3 are changed to 3. If _p is not specified, the value 3 is - used. + no decimal point or fraction to be output. ttiimmee prints at most + six digits after the decimal point; values of _p greater than 6 + are changed to 6. If _p is not specified, ttiimmee prints three dig- + its after the decimal point. The optional ll specifies a longer format, including minutes, of the form _M_Mm_S_S._F_Fs. The value of _p determines whether or not @@ -1404,223 +1545,255 @@ PPAARRAAMMEETTEERRSS If this variable is not set, bbaasshh acts as if it had the value $$''\\nnrreeaall\\tt%%33llRR\\nnuusseerr\\tt%%33llUU\\nnssyyss\\tt%%33llSS''. If the value is null, - no timing information is displayed. A trailing newline is added - when the format string is displayed. - TTMMOOUUTT If set to a value greater than zero, TTMMOOUUTT is treated as the de- - fault timeout for the rreeaadd builtin. The sseelleecctt command termi- - nates if input does not arrive after TTMMOOUUTT seconds when input is - coming from a terminal. In an interactive shell, the value is - interpreted as the number of seconds to wait for a line of input - after issuing the primary prompt. BBaasshh terminates after waiting + bbaasshh does not display any timing information. A trailing new- + line is added when the format string is displayed. + TTMMOOUUTT If set to a value greater than zero, the rreeaadd builtin uses the + value as its default timeout. The sseelleecctt command terminates if + input does not arrive after TTMMOOUUTT seconds when input is coming + from a terminal. In an interactive shell, the value is inter- + preted as the number of seconds to wait for a line of input af- + ter issuing the primary prompt. BBaasshh terminates after waiting for that number of seconds if a complete line of input does not arrive. TTMMPPDDIIRR If set, bbaasshh uses its value as the name of a directory in which bbaasshh creates temporary files for the shell's use. aauuttoo__rreessuummee This variable controls how the shell interacts with the user and - job control. If this variable is set, single word simple com- - mands without redirections are treated as candidates for resump- - tion of an existing stopped job. There is no ambiguity allowed; - if there is more than one job beginning with the string typed, - the job most recently accessed is selected. The _n_a_m_e of a - stopped job, in this context, is the command line used to start - it. If set to the value _e_x_a_c_t, the string supplied must match - the name of a stopped job exactly; if set to _s_u_b_s_t_r_i_n_g, the - string supplied needs to match a substring of the name of a - stopped job. The _s_u_b_s_t_r_i_n_g value provides functionality analo- - gous to the %%?? job identifier (see JJOOBB CCOONNTTRROOLL below). If set - to any other value, the supplied string must be a prefix of a - stopped job's name; this provides functionality analogous to the - %%_s_t_r_i_n_g job identifier. + job control. If this variable is set, simple commands consist- + ing of only a single word, without redirections, are treated as + candidates for resumption of an existing stopped job. There is + no ambiguity allowed; if there is more than one job beginning + with or containing the word, this selects the most recently ac- + cessed job. The _n_a_m_e of a stopped job, in this context, is the + command line used to start it, as displayed by jjoobbss. If set to + the value _e_x_a_c_t, the word must match the name of a stopped job + exactly; if set to _s_u_b_s_t_r_i_n_g, the word needs to match a sub- + string of the name of a stopped job. The _s_u_b_s_t_r_i_n_g value pro- + vides functionality analogous to the %%?? job identifier (see JJOOBB + CCOONNTTRROOLL below). If set to any other value (e.g., _p_r_e_f_i_x), the + word must be a prefix of a stopped job's name; this provides + functionality analogous to the %%_s_t_r_i_n_g job identifier. hhiissttcchhaarrss - The two or three characters which control history expansion and - tokenization (see HHIISSTTOORRYY EEXXPPAANNSSIIOONN below). The first character - is the _h_i_s_t_o_r_y _e_x_p_a_n_s_i_o_n character, the character which signals - the start of a history expansion, normally `!!'. The second - character is the _q_u_i_c_k _s_u_b_s_t_i_t_u_t_i_o_n character, which is used as - shorthand for re-running the previous command entered, substi- - tuting one string for another in the command. The default is - `^^'. The optional third character is the character which indi- - cates that the remainder of the line is a comment when found as - the first character of a word, normally `##'. The history com- - ment character causes history substitution to be skipped for the - remaining words on the line. It does not necessarily cause the - shell parser to treat the rest of the line as a comment. + The two or three characters which control history expansion, + quick substitution, and tokenization (see HHIISSTTOORRYY EEXXPPAANNSSIIOONN be- + low). The first character is the _h_i_s_t_o_r_y _e_x_p_a_n_s_i_o_n character, + the character which begins a history expansion, normally "!!". + The second character is the _q_u_i_c_k _s_u_b_s_t_i_t_u_t_i_o_n character, nor- + mally "^^". When it appears as the first character on the line, + history substitution repeats the previous command, replacing one + string with another. The optional third character is the _h_i_s_- + _t_o_r_y _c_o_m_m_e_n_t character, normally "##", which indicates that the + remainder of the line is a comment when it appears as the first + character of a word. The history comment character disables + history substitution for the remaining words on the line. It + does not necessarily cause the shell parser to treat the rest of + the line as a comment. AArrrraayyss - BBaasshh provides one-dimensional indexed and associative array variables. - Any variable may be used as an indexed array; the ddeeccllaarree builtin will - explicitly declare an array. There is no maximum limit on the size of - an array, nor any requirement that members be indexed or assigned con- - tiguously. Indexed arrays are referenced using integers (including - arithmetic expressions) and are zero-based; associative arrays are ref- - erenced using arbitrary strings. Unless otherwise noted, indexed array - indices must be non-negative integers. - - An indexed array is created automatically if any variable is assigned - to using the syntax _n_a_m_e[_s_u_b_s_c_r_i_p_t]=_v_a_l_u_e. The _s_u_b_s_c_r_i_p_t is treated as - an arithmetic expression that must evaluate to a number. To explicitly - declare an indexed array, use ddeeccllaarree --aa _n_a_m_e (see SSHHEELLLL BBUUIILLTTIINN CCOOMM-- - MMAANNDDSS below). ddeeccllaarree --aa _n_a_m_e[[_s_u_b_s_c_r_i_p_t]] is also accepted; the _s_u_b_- - _s_c_r_i_p_t is ignored. - - Associative arrays are created using ddeeccllaarree --AA _n_a_m_e. + BBaasshh provides one-dimensional indexed and associative array variables. + Any variable may be used as an indexed array; the ddeeccllaarree builtin ex- + plicitly declares an array. There is no maximum limit on the size of + an array, nor any requirement that members be indexed or assigned con- + tiguously. Indexed arrays are referenced using arithmetic expressions + that must expand to an integer (see AARRIITTHHMMEETTIICC EEVVAALLUUAATTIIOONN below) and + are zero-based; associative arrays are referenced using arbitrary + strings. Unless otherwise noted, indexed array indices must be non- + negative integers. + + The shell performs parameter and variable expansion, arithmetic expan- + sion, command substitution, and quote removal on indexed array sub- + scripts. Since this can potentially result in empty strings, subscript + indexing treats those as expressions that evaluate to 0. + + The shell performs tilde expansion, parameter and variable expansion, + arithmetic expansion, command substitution, and quote removal on asso- + ciative array subscripts. Empty strings cannot be used as associative + array keys. + + BBaasshh automatically creates an indexed array if any variable is assigned + to using the syntax + _n_a_m_e[_s_u_b_s_c_r_i_p_t]=_v_a_l_u_e . + The _s_u_b_s_c_r_i_p_t is treated as an arithmetic expression that must evaluate + to a number greater than or equal to zero. To explicitly declare an + indexed array, use + ddeeccllaarree --aa _n_a_m_e + (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). + ddeeccllaarree --aa _n_a_m_e[_s_u_b_s_c_r_i_p_t] + is also accepted; the _s_u_b_s_c_r_i_p_t is ignored. + + Associative arrays are created using + ddeeccllaarree --AA _n_a_m_e + . Attributes may be specified for an array variable using the ddeeccllaarree and rreeaaddoonnllyy builtins. Each attribute applies to all members of an array. - Arrays are assigned to using compound assignments of the form - _n_a_m_e=((value_1 ... value_n)), where each _v_a_l_u_e may be of the form [_s_u_b_- - _s_c_r_i_p_t]=_s_t_r_i_n_g. Indexed array assignments do not require anything but - _s_t_r_i_n_g. Each _v_a_l_u_e in the list is expanded using all the shell expan- - sions described below under EEXXPPAANNSSIIOONN. When assigning to indexed ar- - rays, if the optional brackets and subscript are supplied, that index - is assigned to; otherwise the index of the element assigned is the last - index assigned to by the statement plus one. Indexing starts at zero. + Arrays are assigned using compound assignments of the form _n_a_m_e=((value_1 + ... value_n)), where each _v_a_l_u_e may be of the form [_s_u_b_s_c_r_i_p_t]=_s_t_r_i_n_g. + Indexed array assignments do not require anything but _s_t_r_i_n_g. Each + _v_a_l_u_e in the list is expanded using the shell expansions described be- + low under EEXXPPAANNSSIIOONN, but _v_a_l_u_es that are valid variable assignments in- + cluding the brackets and subscript do not undergo brace expansion and + word splitting, as with individual variable assignments. + + When assigning to indexed arrays, if the optional brackets and sub- + script are supplied, that index is assigned to; otherwise the index of + the element assigned is the last index assigned to by the statement + plus one. Indexing starts at zero. When assigning to an associative array, the words in a compound assign- - ment may be either assignment statements, for which the subscript is - required, or a list of words that is interpreted as a sequence of al- - ternating keys and values: _n_a_m_e=(( _k_e_y_1 _v_a_l_u_e_1 _k_e_y_2 _v_a_l_u_e_2 ...)). These - are treated identically to _n_a_m_e=(( [_k_e_y_1]=_v_a_l_u_e_1 [_k_e_y_2]=_v_a_l_u_e_2 ...)). - The first word in the list determines how the remaining words are in- - terpreted; all assignments in a list must be of the same type. When - using key/value pairs, the keys may not be missing or empty; a final + ment may be either assignment statements, for which the subscript is + required, or a list of words that is interpreted as a sequence of al- + ternating keys and values: _n_a_m_e=(( _k_e_y_1 _v_a_l_u_e_1 _k_e_y_2 _v_a_l_u_e_2 ...)). These + are treated identically to _n_a_m_e=(( [_k_e_y_1]=_v_a_l_u_e_1 [_k_e_y_2]=_v_a_l_u_e_2 ...)). + The first word in the list determines how the remaining words are in- + terpreted; all assignments in a list must be of the same type. When + using key/value pairs, the keys may not be missing or empty; a final missing value is treated like the empty string. - This syntax is also accepted by the ddeeccllaarree builtin. Individual array - elements may be assigned to using the _n_a_m_e[_s_u_b_s_c_r_i_p_t]=_v_a_l_u_e syntax in- - troduced above. When assigning to an indexed array, if _n_a_m_e is sub- - scripted by a negative number, that number is interpreted as relative - to one greater than the maximum index of _n_a_m_e, so negative indices - count back from the end of the array, and an index of -1 references the - last element. - - The += operator will append to an array variable when assigning using - the compound assignment syntax; see PPAARRAAMMEETTEERRSS above. - - Any element of an array may be referenced using ${_n_a_m_e[_s_u_b_s_c_r_i_p_t]}. - The braces are required to avoid conflicts with pathname expansion. If - _s_u_b_s_c_r_i_p_t is @@ or **, the word expands to all members of _n_a_m_e. These - subscripts differ only when the word appears within double quotes. If - the word is double-quoted, ${_n_a_m_e[*]} expands to a single word with the - value of each array member separated by the first character of the IIFFSS - special variable, and ${_n_a_m_e[@]} expands each element of _n_a_m_e to a sep- - arate word. When there are no array members, ${_n_a_m_e[@]} expands to - nothing. If the double-quoted expansion occurs within a word, the ex- - pansion of the first parameter is joined with the beginning part of the - original word, and the expansion of the last parameter is joined with - the last part of the original word. This is analogous to the expansion - of the special parameters ** and @@ (see SSppeecciiaall PPaarraammeetteerrss above). - ${#_n_a_m_e[_s_u_b_s_c_r_i_p_t]} expands to the length of ${_n_a_m_e[_s_u_b_s_c_r_i_p_t]}. If + This syntax is also accepted by the ddeeccllaarree builtin. Individual array + elements may be assigned to using the _n_a_m_e[_s_u_b_s_c_r_i_p_t]=_v_a_l_u_e syntax in- + troduced above. + + When assigning to an indexed array, if _n_a_m_e is subscripted by a nega- + tive number, that number is interpreted as relative to one greater than + the maximum index of _n_a_m_e, so negative indices count back from the end + of the array, and an index of -1 references the last element. + + The "+=" operator appends to an array variable when assigning using the + compound assignment syntax; see PPAARRAAMMEETTEERRSS above. + + An array element is referenced using ${_n_a_m_e[_s_u_b_s_c_r_i_p_t]}. The braces + are required to avoid conflicts with pathname expansion. If _s_u_b_s_c_r_i_p_t + is @@ or **, the word expands to all members of _n_a_m_e, unless noted in the + description of a builtin or word expansion. These subscripts differ + only when the word appears within double quotes. If the word is dou- + ble-quoted, ${_n_a_m_e[*]} expands to a single word with the value of each + array member separated by the first character of the IIFFSS special vari- + able, and ${_n_a_m_e[@]} expands each element of _n_a_m_e to a separate word. + When there are no array members, ${_n_a_m_e[@]} expands to nothing. If the + double-quoted expansion occurs within a word, the expansion of the + first parameter is joined with the beginning part of the expansion of + the original word, and the expansion of the last parameter is joined + with the last part of the expansion of the original word. This is + analogous to the expansion of the special parameters ** and @@ (see SSppee-- + cciiaall PPaarraammeetteerrss above). + + ${#_n_a_m_e[_s_u_b_s_c_r_i_p_t]} expands to the length of ${_n_a_m_e[_s_u_b_s_c_r_i_p_t]}. If _s_u_b_s_c_r_i_p_t is ** or @@, the expansion is the number of elements in the ar- - ray. If the _s_u_b_s_c_r_i_p_t used to reference an element of an indexed array - evaluates to a number less than zero, it is interpreted as relative to - one greater than the maximum index of the array, so negative indices - count back from the end of the array, and an index of -1 references the - last element. + ray. + + If the _s_u_b_s_c_r_i_p_t used to reference an element of an indexed array eval- + uates to a number less than zero, it is interpreted as relative to one + greater than the maximum index of the array, so negative indices count + back from the end of the array, and an index of -1 references the last + element. Referencing an array variable without a subscript is equivalent to ref- erencing the array with a subscript of 0. Any reference to a variable - using a valid subscript is legal, and bbaasshh will create an array if nec- - essary. + using a valid subscript is valid; bbaasshh creates an array if necessary. - An array variable is considered set if a subscript has been assigned a + An array variable is considered set if a subscript has been assigned a value. The null string is a valid value. - It is possible to obtain the keys (indices) of an array as well as the - values. ${!!_n_a_m_e[_@]} and ${!!_n_a_m_e[_*]} expand to the indices assigned in + It is possible to obtain the keys (indices) of an array as well as the + values. ${!!_n_a_m_e[_@]} and ${!!_n_a_m_e[_*]} expand to the indices assigned in array variable _n_a_m_e. The treatment when in double quotes is similar to the expansion of the special parameters _@ and _* within double quotes. - The uunnsseett builtin is used to destroy arrays. uunnsseett _n_a_m_e[_s_u_b_s_c_r_i_p_t] de- - stroys the array element at index _s_u_b_s_c_r_i_p_t, for both indexed and asso- - ciative arrays. Negative subscripts to indexed arrays are interpreted - as described above. Unsetting the last element of an array variable - does not unset the variable. uunnsseett _n_a_m_e, where _n_a_m_e is an array, re- - moves the entire array. uunnsseett _n_a_m_e[_s_u_b_s_c_r_i_p_t], where _s_u_b_s_c_r_i_p_t is ** or - @@, behaves differently depending on whether _n_a_m_e is an indexed or asso- - ciative array. If _n_a_m_e is an associative array, this unsets the ele- - ment with subscript ** or @@. If _n_a_m_e is an indexed array, unset removes - all of the elements but does not remove the array itself. + The uunnsseett builtin is used to destroy arrays. uunnsseett _n_a_m_e[_s_u_b_s_c_r_i_p_t] un- + sets the array element at index _s_u_b_s_c_r_i_p_t, for both indexed and asso- + ciative arrays. Negative subscripts to indexed arrays are interpreted + as described above. Unsetting the last element of an array variable + does not unset the variable. uunnsseett _n_a_m_e, where _n_a_m_e is an array, re- + moves the entire array. uunnsseett _n_a_m_e[_s_u_b_s_c_r_i_p_t] behaves differently de- + pending on whether _n_a_m_e is an indexed or associative array when _s_u_b_- + _s_c_r_i_p_t is ** or @@. If _n_a_m_e is an associative array, this unsets the el- + ement with subscript ** or @@. If _n_a_m_e is an indexed array, unset re- + moves all of the elements but does not remove the array itself. When using a variable name with a subscript as an argument to a com- mand, such as with uunnsseett, without using the word expansion syntax de- - scribed above, the argument is subject to pathname expansion. If path- - name expansion is not desired, the argument should be quoted. - - The ddeeccllaarree, llooccaall, and rreeaaddoonnllyy builtins each accept a --aa option to - specify an indexed array and a --AA option to specify an associative ar- - ray. If both options are supplied, --AA takes precedence. The rreeaadd - builtin accepts a --aa option to assign a list of words read from the + scribed above, (e.g., unset a[4]), the argument is subject to pathname + expansion. Quote the argument if pathname expansion is not desired + (e.g., unset 'a[4]'). + + The ddeeccllaarree, llooccaall, and rreeaaddoonnllyy builtins each accept a --aa option to + specify an indexed array and a --AA option to specify an associative ar- + ray. If both options are supplied, --AA takes precedence. The rreeaadd + builtin accepts a --aa option to assign a list of words read from the standard input to an array. The sseett and ddeeccllaarree builtins display array - values in a way that allows them to be reused as assignments. + values in a way that allows them to be reused as assignments. Other + builtins accept array name arguments as well (e.g., mmaappffiillee); see the + descriptions of individual builtins below for details. The shell pro- + vides a number of builtin array variables. EEXXPPAANNSSIIOONN Expansion is performed on the command line after it has been split into - words. There are seven kinds of expansion performed: _b_r_a_c_e _e_x_p_a_n_s_i_o_n, - _t_i_l_d_e _e_x_p_a_n_s_i_o_n, _p_a_r_a_m_e_t_e_r _a_n_d _v_a_r_i_a_b_l_e _e_x_p_a_n_s_i_o_n, _c_o_m_m_a_n_d _s_u_b_s_t_i_t_u_- - _t_i_o_n, _a_r_i_t_h_m_e_t_i_c _e_x_p_a_n_s_i_o_n, _w_o_r_d _s_p_l_i_t_t_i_n_g, and _p_a_t_h_n_a_m_e _e_x_p_a_n_s_i_o_n. + words. The shell performs these expansions: _b_r_a_c_e _e_x_p_a_n_s_i_o_n, _t_i_l_d_e _e_x_- + _p_a_n_s_i_o_n, _p_a_r_a_m_e_t_e_r _a_n_d _v_a_r_i_a_b_l_e _e_x_p_a_n_s_i_o_n, _c_o_m_m_a_n_d _s_u_b_s_t_i_t_u_t_i_o_n, _a_r_i_t_h_- + _m_e_t_i_c _e_x_p_a_n_s_i_o_n, _w_o_r_d _s_p_l_i_t_t_i_n_g, _p_a_t_h_n_a_m_e _e_x_p_a_n_s_i_o_n, and _q_u_o_t_e _r_e_m_o_v_a_l. The order of expansions is: brace expansion; tilde expansion, parameter - and variable expansion, arithmetic expansion, and command substitution - (done in a left-to-right fashion); word splitting; and pathname expan- - sion. + and variable expansion, arithmetic expansion, and command substitution + (done in a left-to-right fashion); word splitting; pathname expansion; + and quote removal. On systems that can support it, there is an additional expansion avail- able: _p_r_o_c_e_s_s _s_u_b_s_t_i_t_u_t_i_o_n. This is performed at the same time as tilde, parameter, variable, and arithmetic expansion and command sub- stitution. - After these expansions are performed, quote characters present in the - original word are removed unless they have been quoted themselves - (_q_u_o_t_e _r_e_m_o_v_a_l). + _Q_u_o_t_e _r_e_m_o_v_a_l is always performed last. It removes quote characters + present in the original word, not ones resulting from one of the other + expansions, unless they have been quoted themselves. Only brace expansion, word splitting, and pathname expansion can in- crease the number of words of the expansion; other expansions expand a single word to a single word. The only exceptions to this are the ex- - pansions of "$$@@" and "$${{_n_a_m_e[[@@]]}}", and, in most cases, $$** and + pansions of ""$$@@"" and ""$${{_n_a_m_e[[@@]]}}"", and, in most cases, $$** and $${{_n_a_m_e[[**]]}} as explained above (see PPAARRAAMMEETTEERRSS). BBrraaccee EExxppaannssiioonn - _B_r_a_c_e _e_x_p_a_n_s_i_o_n is a mechanism by which arbitrary strings may be gener- - ated. This mechanism is similar to _p_a_t_h_n_a_m_e _e_x_p_a_n_s_i_o_n, but the file- - names generated need not exist. Patterns to be brace expanded take the - form of an optional _p_r_e_a_m_b_l_e, followed by either a series of comma-sep- - arated strings or a sequence expression between a pair of braces, fol- - lowed by an optional _p_o_s_t_s_c_r_i_p_t. The preamble is prefixed to each - string contained within the braces, and the postscript is then appended - to each resulting string, expanding left to right. + _B_r_a_c_e _e_x_p_a_n_s_i_o_n is a mechanism to generate arbitrary strings sharing a + common prefix and suffix, either of which can be empty. This mechanism + is similar to _p_a_t_h_n_a_m_e _e_x_p_a_n_s_i_o_n, but the filenames generated need not + exist. Patterns to be brace expanded are formed from an optional _p_r_e_- + _a_m_b_l_e, followed by either a series of comma-separated strings or a se- + quence expression between a pair of braces, followed by an optional + _p_o_s_t_s_c_r_i_p_t. The preamble is prefixed to each string contained within + the braces, and the postscript is then appended to each resulting + string, expanding left to right. Brace expansions may be nested. The results of each expanded string - are not sorted; left to right order is preserved. For example, - a{{d,c,b}}e expands into `ade ace abe'. + are not sorted; brace expansion preserves left to right order. For ex- + ample, a{{d,c,b}}e expands into "ade ace abe". - A sequence expression takes the form {{_x...._y[[...._i_n_c_r]]}}, where _x and _y are - either integers or single letters, and _i_n_c_r, an optional increment, is + A sequence expression takes the form _x...._y[[...._i_n_c_r]], where _x and _y are + either integers or single letters, and _i_n_c_r, an optional increment, is an integer. When integers are supplied, the expression expands to each - number between _x and _y, inclusive. Supplied integers may be prefixed - with _0 to force each term to have the same width. When either _x or _y - begins with a zero, the shell attempts to force all generated terms to - contain the same number of digits, zero-padding where necessary. When - letters are supplied, the expression expands to each character lexico- - graphically between _x and _y, inclusive, using the default C locale. - Note that both _x and _y must be of the same type (integer or letter). - When the increment is supplied, it is used as the difference between - each term. The default increment is 1 or -1 as appropriate. + number between _x and _y, inclusive. If either _x or _y begins with a + zero, each generated term will contain the same number of digits, zero- + padding where necessary. When letters are supplied, the expression ex- + pands to each character lexicographically between _x and _y, inclusive, + using the C locale. Note that both _x and _y must be of the same type + (integer or letter). When the increment is supplied, it is used as the + difference between each term. The default increment is 1 or -1 as ap- + propriate. Brace expansion is performed before any other expansions, and any char- - acters special to other expansions are preserved in the result. It is - strictly textual. BBaasshh does not apply any syntactic interpretation to + acters special to other expansions are preserved in the result. It is + strictly textual. BBaasshh does not apply any syntactic interpretation to the context of the expansion or the text between the braces. - A correctly-formed brace expansion must contain unquoted opening and + A correctly-formed brace expansion must contain unquoted opening and closing braces, and at least one unquoted comma or a valid sequence ex- - pression. Any incorrectly formed brace expansion is left unchanged. A - {{ or ,, may be quoted with a backslash to prevent its being considered - part of a brace expression. To avoid conflicts with parameter expan- - sion, the string $${{ is not considered eligible for brace expansion, and - inhibits brace expansion until the closing }}. + pression. Any incorrectly formed brace expansion is left unchanged. + + A "{" or Q , may be quoted with a backslash to prevent its being con- + sidered part of a brace expression. To avoid conflicts with parameter + expansion, the string "${" is not considered eligible for brace expan- + sion, and inhibits brace expansion until the closing "}". This construct is typically used as shorthand when the common prefix of the strings to be generated is longer than in the above example: @@ -1633,122 +1806,138 @@ EEXXPPAANNSSIIOONN versions of sshh. sshh does not treat opening or closing braces specially when they appear as part of a word, and preserves them in the output. BBaasshh removes braces from words as a consequence of brace expansion. - For example, a word entered to sshh as _f_i_l_e_{_1_,_2_} appears identically in - the output. The same word is output as _f_i_l_e_1 _f_i_l_e_2 after expansion by - bbaasshh. If strict compatibility with sshh is desired, start bbaasshh with the - ++BB option or disable brace expansion with the ++BB option to the sseett com- - mand (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). + For example, a word entered to sshh as "file{1,2}" appears identically in + the output. BBaasshh outputs that word as "file1 file2" after brace expan- + sion. Start bbaasshh with the ++BB option or disable brace expansion with + the ++BB option to the sseett command (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below) for + strict sshh compatibility. TTiillddee EExxppaannssiioonn - If a word begins with an unquoted tilde character (`~~'), all of the - characters preceding the first unquoted slash (or all characters, if - there is no unquoted slash) are considered a _t_i_l_d_e_-_p_r_e_f_i_x. If none of - the characters in the tilde-prefix are quoted, the characters in the - tilde-prefix following the tilde are treated as a possible _l_o_g_i_n _n_a_m_e. - If this login name is the null string, the tilde is replaced with the - value of the shell parameter HHOOMMEE. If HHOOMMEE is unset, the home direc- - tory of the user executing the shell is substituted instead. Other- + If a word begins with an unquoted tilde character ("~~"), all of the + characters preceding the first unquoted slash (or all characters, if + there is no unquoted slash) are considered a _t_i_l_d_e_-_p_r_e_f_i_x. If none of + the characters in the tilde-prefix are quoted, the characters in the + tilde-prefix following the tilde are treated as a possible _l_o_g_i_n _n_a_m_e. + If this login name is the null string, the tilde is replaced with the + value of the shell parameter HHOOMMEE. If HHOOMMEE is unset, the tilde expands + to the home directory of the user executing the shell instead. Other- wise, the tilde-prefix is replaced with the home directory associated with the specified login name. - If the tilde-prefix is a `~+', the value of the shell variable PPWWDD re- - places the tilde-prefix. If the tilde-prefix is a `~-', the value of - the shell variable OOLLDDPPWWDD, if it is set, is substituted. If the char- - acters following the tilde in the tilde-prefix consist of a number _N, - optionally prefixed by a `+' or a `-', the tilde-prefix is replaced + If the tilde-prefix is a "~+", the value of the shell variable PPWWDD re- + places the tilde-prefix. If the tilde-prefix is a "~-", the shell sub- + stitutes the value of the shell variable OOLLDDPPWWDD, if it is set. If the + characters following the tilde in the tilde-prefix consist of a number + _N, optionally prefixed by a "+" or a "-", the tilde-prefix is replaced with the corresponding element from the directory stack, as it would be - displayed by the ddiirrss builtin invoked with the tilde-prefix as an argu- - ment. If the characters following the tilde in the tilde-prefix con- - sist of a number without a leading `+' or `-', `+' is assumed. + displayed by the ddiirrss builtin invoked with the characters following the + tilde in the tilde-prefix as an argument. If the characters following + the tilde in the tilde-prefix consist of a number without a leading "+" + or "-", tilde expansion assumes "+". + + The results of tilde expansion are treated as if they were quoted, so + the replacement is not subject to word splitting and pathname expan- + sion. - If the login name is invalid, or the tilde expansion fails, the word is - unchanged. + If the login name is invalid, or the tilde expansion fails, the tilde- + prefix is unchanged. - Each variable assignment is checked for unquoted tilde-prefixes immedi- - ately following a :: or the first ==. In these cases, tilde expansion is - also performed. Consequently, one may use filenames with tildes in as- - signments to PPAATTHH, MMAAIILLPPAATTHH, and CCDDPPAATTHH, and the shell assigns the ex- + BBaasshh checks each variable assignment for unquoted tilde-prefixes imme- + diately following a :: or the first ==, and performs tilde expansion in + these cases. Consequently, one may use filenames with tildes in as- + signments to PPAATTHH, MMAAIILLPPAATTHH, and CCDDPPAATTHH, and the shell assigns the ex- panded value. - Bash also performs tilde expansion on words satisfying the conditions + BBaasshh also performs tilde expansion on words satisfying the conditions of variable assignments (as described above under PPAARRAAMMEETTEERRSS) when they - appear as arguments to simple commands. Bash does not do this, except - for the _d_e_c_l_a_r_a_t_i_o_n commands listed above, when in _p_o_s_i_x _m_o_d_e. + appear as arguments to simple commands. BBaasshh does not do this, except + for the _d_e_c_l_a_r_a_t_i_o_n commands listed above, when in posix mode. PPaarraammeetteerr EExxppaannssiioonn - The `$$' character introduces parameter expansion, command substitution, - or arithmetic expansion. The parameter name or symbol to be expanded - may be enclosed in braces, which are optional but serve to protect the - variable to be expanded from characters immediately following it which + The "$$" character introduces parameter expansion, command substitution, + or arithmetic expansion. The parameter name or symbol to be expanded + may be enclosed in braces, which are optional but serve to protect the + variable to be expanded from characters immediately following it which could be interpreted as part of the name. - When braces are used, the matching ending brace is the first `}}' not + When braces are used, the matching ending brace is the first "}}" not escaped by a backslash or within a quoted string, and not within an em- bedded arithmetic expansion, command substitution, or parameter expan- sion. + The basic form of parameter expansion is + ${_p_a_r_a_m_e_t_e_r} - The value of _p_a_r_a_m_e_t_e_r is substituted. The braces are required - when _p_a_r_a_m_e_t_e_r is a positional parameter with more than one - digit, or when _p_a_r_a_m_e_t_e_r is followed by a character which is not - to be interpreted as part of its name. The _p_a_r_a_m_e_t_e_r is a shell - parameter as described above PPAARRAAMMEETTEERRSS) or an array reference - (AArrrraayyss). + + which substitutes the value of _p_a_r_a_m_e_t_e_r. The braces are required when + _p_a_r_a_m_e_t_e_r is a positional parameter with more than one digit, or when + _p_a_r_a_m_e_t_e_r is followed by a character which is not to be interpreted as + part of its name. The _p_a_r_a_m_e_t_e_r is a shell parameter as described + above PPAARRAAMMEETTEERRSS) or an array reference (AArrrraayyss). If the first character of _p_a_r_a_m_e_t_e_r is an exclamation point (!!), and _p_a_r_a_m_e_t_e_r is not a _n_a_m_e_r_e_f, it introduces a level of indirection. BBaasshh uses the value formed by expanding the rest of _p_a_r_a_m_e_t_e_r as the new _p_a_- - _r_a_m_e_t_e_r; this is then expanded and that value is used in the rest of - the expansion, rather than the expansion of the original _p_a_r_a_m_e_t_e_r. - This is known as _i_n_d_i_r_e_c_t _e_x_p_a_n_s_i_o_n. The value is subject to tilde ex- - pansion, parameter expansion, command substitution, and arithmetic ex- - pansion. If _p_a_r_a_m_e_t_e_r is a nameref, this expands to the name of the - parameter referenced by _p_a_r_a_m_e_t_e_r instead of performing the complete - indirect expansion. The exceptions to this are the expansions of - ${!!_p_r_e_f_i_x**} and ${!!_n_a_m_e[_@]} described below. The exclamation point - must immediately follow the left brace in order to introduce indirec- - tion. + _r_a_m_e_t_e_r; this new parameter is then expanded and that value is used in + the rest of the expansion, rather than the expansion of the original + _p_a_r_a_m_e_t_e_r. This is known as _i_n_d_i_r_e_c_t _e_x_p_a_n_s_i_o_n. The value is subject + to tilde expansion, parameter expansion, command substitution, and + arithmetic expansion. If _p_a_r_a_m_e_t_e_r is a nameref, this expands to the + name of the parameter referenced by _p_a_r_a_m_e_t_e_r instead of performing the + complete indirect expansion, for compatibility. The exceptions to this + are the expansions of ${!!_p_r_e_f_i_x**} and ${!!_n_a_m_e[_@]} described below. The + exclamation point must immediately follow the left brace in order to + introduce indirection. In each of the cases below, _w_o_r_d is subject to tilde expansion, parame- ter expansion, command substitution, and arithmetic expansion. When not performing substring expansion, using the forms documented be- - low (e.g., ::--), bbaasshh tests for a parameter that is unset or null. - Omitting the colon results in a test only for a parameter that is un- - set. + low (e.g., ::--), bbaasshh tests for a parameter that is unset or null. + Omitting the colon tests only for a parameter that is unset. ${_p_a_r_a_m_e_t_e_r::--_w_o_r_d} UUssee DDeeffaauulltt VVaalluueess. If _p_a_r_a_m_e_t_e_r is unset or null, the expan- sion of _w_o_r_d is substituted. Otherwise, the value of _p_a_r_a_m_e_t_e_r is substituted. + ${_p_a_r_a_m_e_t_e_r::==_w_o_r_d} AAssssiiggnn DDeeffaauulltt VVaalluueess. If _p_a_r_a_m_e_t_e_r is unset or null, the ex- - pansion of _w_o_r_d is assigned to _p_a_r_a_m_e_t_e_r. The value of _p_a_r_a_m_e_- - _t_e_r is then substituted. Positional parameters and special pa- - rameters may not be assigned to in this way. + pansion of _w_o_r_d is assigned to _p_a_r_a_m_e_t_e_r, and the expansion is + the final value of _p_a_r_a_m_e_t_e_r. Positional parameters and special + parameters may not be assigned in this way. + ${_p_a_r_a_m_e_t_e_r::??_w_o_r_d} - DDiissppllaayy EErrrroorr iiff NNuullll oorr UUnnsseett. If _p_a_r_a_m_e_t_e_r is null or unset, - the expansion of _w_o_r_d (or a message to that effect if _w_o_r_d is - not present) is written to the standard error and the shell, if - it is not interactive, exits. Otherwise, the value of _p_a_r_a_m_e_t_e_r - is substituted. + DDiissppllaayy EErrrroorr iiff NNuullll oorr UUnnsseett. If _p_a_r_a_m_e_t_e_r is null or unset, + the shell writes the expansion of _w_o_r_d (or a message to that ef- + fect if _w_o_r_d is not present) to the standard error and, if it is + not interactive, exits with a non-zero status. An interactive + shell does not exit, but does not execute the command associated + with the expansion. Otherwise, the value of _p_a_r_a_m_e_t_e_r is sub- + stituted. + ${_p_a_r_a_m_e_t_e_r::++_w_o_r_d} UUssee AAlltteerrnnaattee VVaalluuee. If _p_a_r_a_m_e_t_e_r is null or unset, nothing is - substituted, otherwise the expansion of _w_o_r_d is substituted. + substituted, otherwise the expansion of _w_o_r_d is substituted. + The value of _p_a_r_a_m_e_t_e_r is not used. + ${_p_a_r_a_m_e_t_e_r::_o_f_f_s_e_t} ${_p_a_r_a_m_e_t_e_r::_o_f_f_s_e_t::_l_e_n_g_t_h} - SSuubbssttrriinngg EExxppaannssiioonn. Expands to up to _l_e_n_g_t_h characters of the - value of _p_a_r_a_m_e_t_e_r starting at the character specified by _o_f_f_- - _s_e_t. If _p_a_r_a_m_e_t_e_r is @@ or **, an indexed array subscripted by @@ - or **, or an associative array name, the results differ as de- - scribed below. If _l_e_n_g_t_h is omitted, expands to the substring - of the value of _p_a_r_a_m_e_t_e_r starting at the character specified by - _o_f_f_s_e_t and extending to the end of the value. _l_e_n_g_t_h and _o_f_f_s_e_t - are arithmetic expressions (see AARRIITTHHMMEETTIICC EEVVAALLUUAATTIIOONN below). + SSuubbssttrriinngg EExxppaannssiioonn. Expands to up to _l_e_n_g_t_h characters of the + value of _p_a_r_a_m_e_t_e_r starting at the character specified by _o_f_f_- + _s_e_t. If _p_a_r_a_m_e_t_e_r is @@ or **, an indexed array subscripted by @@ + or **, or an associative array name, the results differ as de- + scribed below. If ::_l_e_n_g_t_h is omitted (the first form above), + this expands to the substring of the value of _p_a_r_a_m_e_t_e_r starting + at the character specified by _o_f_f_s_e_t and extending to the end of + the value. If _o_f_f_s_e_t is omitted, it is treated as 0. If _l_e_n_g_t_h + is omitted, but the colon after _o_f_f_s_e_t is present, it is treated + as 0. _l_e_n_g_t_h and _o_f_f_s_e_t are arithmetic expressions (see AARRIITTHH-- + MMEETTIICC EEVVAALLUUAATTIIOONN below). If _o_f_f_s_e_t evaluates to a number less than zero, the value is used as an offset in characters from the end of the value of _p_a_- - _r_a_m_e_t_e_r. If _l_e_n_g_t_h evaluates to a number less than zero, it is + _r_a_m_e_t_e_r. If _l_e_n_g_t_h evaluates to a number less than zero, it is interpreted as an offset in characters from the end of the value of _p_a_r_a_m_e_t_e_r rather than a number of characters, and the expan- sion is the characters between _o_f_f_s_e_t and that result. Note @@ -1758,27 +1947,27 @@ EEXXPPAANNSSIIOONN If _p_a_r_a_m_e_t_e_r is @@ or **, the result is _l_e_n_g_t_h positional parame- ters beginning at _o_f_f_s_e_t. A negative _o_f_f_s_e_t is taken relative to one greater than the greatest positional parameter, so an - offset of -1 evaluates to the last positional parameter. It is - an expansion error if _l_e_n_g_t_h evaluates to a number less than - zero. + offset of -1 evaluates to the last positional parameter (or 0 if + there are no positional parameters). It is an expansion error + if _l_e_n_g_t_h evaluates to a number less than zero. If _p_a_r_a_m_e_t_e_r is an indexed array name subscripted by @ or *, the - result is the _l_e_n_g_t_h members of the array beginning with ${_p_a_- - _r_a_m_e_t_e_r[_o_f_f_s_e_t]}. A negative _o_f_f_s_e_t is taken relative to one + result is the _l_e_n_g_t_h members of the array beginning with ${_p_a_r_a_- + _m_e_t_e_r[_o_f_f_s_e_t]}. A negative _o_f_f_s_e_t is taken relative to one greater than the maximum index of the specified array. It is an expansion error if _l_e_n_g_t_h evaluates to a number less than zero. Substring expansion applied to an associative array produces un- defined results. - Substring indexing is zero-based unless the positional parame- - ters are used, in which case the indexing starts at 1 by de- - fault. If _o_f_f_s_e_t is 0, and the positional parameters are used, + Substring indexing is zero-based unless the positional parame- + ters are used, in which case the indexing starts at 1 by de- + fault. If _o_f_f_s_e_t is 0, and the positional parameters are used, $$00 is prefixed to the list. ${!!_p_r_e_f_i_x**} ${!!_p_r_e_f_i_x@@} - NNaammeess mmaattcchhiinngg pprreeffiixx. Expands to the names of variables whose + NNaammeess mmaattcchhiinngg pprreeffiixx. Expands to the names of variables whose names begin with _p_r_e_f_i_x, separated by the first character of the IIFFSS special variable. When _@ is used and the expansion appears within double quotes, each variable name expands to a separate @@ -1793,15 +1982,16 @@ EEXXPPAANNSSIIOONN each key expands to a separate word. ${##_p_a_r_a_m_e_t_e_r} - PPaarraammeetteerr lleennggtthh. The length in characters of the value of _p_a_- - _r_a_m_e_t_e_r is substituted. If _p_a_r_a_m_e_t_e_r is ** or @@, the value sub- - stituted is the number of positional parameters. If _p_a_r_a_m_e_t_e_r - is an array name subscripted by ** or @@, the value substituted is - the number of elements in the array. If _p_a_r_a_m_e_t_e_r is an indexed - array name subscripted by a negative number, that number is in- - terpreted as relative to one greater than the maximum index of - _p_a_r_a_m_e_t_e_r, so negative indices count back from the end of the - array, and an index of -1 references the last element. + PPaarraammeetteerr lleennggtthh. Substitutes the length in characters of the + expanded value of _p_a_r_a_m_e_t_e_r. If _p_a_r_a_m_e_t_e_r is ** or @@, the value + substituted is the number of positional parameters. If _p_a_r_a_m_e_- + _t_e_r is an array name subscripted by ** or @@, the value substi- + tuted is the number of elements in the array. If _p_a_r_a_m_e_t_e_r is + an indexed array name subscripted by a negative number, that + number is interpreted as relative to one greater than the maxi- + mum index of _p_a_r_a_m_e_t_e_r, so negative indices count back from the + end of the array, and an index of -1 references the last ele- + ment. ${_p_a_r_a_m_e_t_e_r##_w_o_r_d} ${_p_a_r_a_m_e_t_e_r####_w_o_r_d} @@ -1811,141 +2001,153 @@ EEXXPPAANNSSIIOONN tteerrnn MMaattcchhiinngg below. If the pattern matches the beginning of the value of _p_a_r_a_m_e_t_e_r, then the result of the expansion is the expanded value of _p_a_r_a_m_e_t_e_r with the shortest matching pattern - (the ``##'' case) or the longest matching pattern (the ``####'' - case) deleted. If _p_a_r_a_m_e_t_e_r is @@ or **, the pattern removal op- - eration is applied to each positional parameter in turn, and the - expansion is the resultant list. If _p_a_r_a_m_e_t_e_r is an array vari- - able subscripted with @@ or **, the pattern removal operation is - applied to each member of the array in turn, and the expansion - is the resultant list. + (the "#" case) or the longest matching pattern (the "##" case) + deleted. If _p_a_r_a_m_e_t_e_r is @@ or **, the pattern removal operation + is applied to each positional parameter in turn, and the expan- + sion is the resultant list. If _p_a_r_a_m_e_t_e_r is an array variable + subscripted with @@ or **, the pattern removal operation is ap- + plied to each member of the array in turn, and the expansion is + the resultant list. ${_p_a_r_a_m_e_t_e_r%%_w_o_r_d} ${_p_a_r_a_m_e_t_e_r%%%%_w_o_r_d} RReemmoovvee mmaattcchhiinngg ssuuffffiixx ppaatttteerrnn. The _w_o_r_d is expanded to produce a pattern just as in pathname expansion, and matched against the expanded value of _p_a_r_a_m_e_t_e_r using the rules described under PPaatt-- - tteerrnn MMaattcchhiinngg below. If the pattern matches a trailing portion - of the expanded value of _p_a_r_a_m_e_t_e_r, then the result of the ex- - pansion is the expanded value of _p_a_r_a_m_e_t_e_r with the shortest - matching pattern (the ``%%'' case) or the longest matching pat- - tern (the ``%%%%'' case) deleted. If _p_a_r_a_m_e_t_e_r is @@ or **, the - pattern removal operation is applied to each positional parame- - ter in turn, and the expansion is the resultant list. If _p_a_r_a_m_- - _e_t_e_r is an array variable subscripted with @@ or **, the pattern - removal operation is applied to each member of the array in - turn, and the expansion is the resultant list. + tteerrnn MMaattcchhiinngg below. If the pattern matches a trailing portion + of the expanded value of _p_a_r_a_m_e_t_e_r, then the result of the ex- + pansion is the expanded value of _p_a_r_a_m_e_t_e_r with the shortest + matching pattern (the "%" case) or the longest matching pattern + (the "%%" case) deleted. If _p_a_r_a_m_e_t_e_r is @@ or **, the pattern + removal operation is applied to each positional parameter in + turn, and the expansion is the resultant list. If _p_a_r_a_m_e_t_e_r is + an array variable subscripted with @@ or **, the pattern removal + operation is applied to each member of the array in turn, and + the expansion is the resultant list. ${_p_a_r_a_m_e_t_e_r//_p_a_t_t_e_r_n//_s_t_r_i_n_g} ${_p_a_r_a_m_e_t_e_r////_p_a_t_t_e_r_n//_s_t_r_i_n_g} ${_p_a_r_a_m_e_t_e_r//##_p_a_t_t_e_r_n//_s_t_r_i_n_g} ${_p_a_r_a_m_e_t_e_r//%%_p_a_t_t_e_r_n//_s_t_r_i_n_g} PPaatttteerrnn ssuubbssttiittuuttiioonn. The _p_a_t_t_e_r_n is expanded to produce a pat- - tern just as in pathname expansion. _P_a_r_a_m_e_t_e_r is expanded and - the longest match of _p_a_t_t_e_r_n against its value is replaced with - _s_t_r_i_n_g. _s_t_r_i_n_g undergoes tilde expansion, parameter and vari- - able expansion, arithmetic expansion, command and process sub- - stitution, and quote removal. The match is performed using the - rules described under PPaatttteerrnn MMaattcchhiinngg below. In the first form - above, only the first match is replaced. If there are two - slashes separating _p_a_r_a_m_e_t_e_r and _p_a_t_t_e_r_n (the second form - above), all matches of _p_a_t_t_e_r_n are replaced with _s_t_r_i_n_g. If - _p_a_t_t_e_r_n is preceded by ## (the third form above), it must match - at the beginning of the expanded value of _p_a_r_a_m_e_t_e_r. If _p_a_t_t_e_r_n - is preceded by %% (the fourth form above), it must match at the - end of the expanded value of _p_a_r_a_m_e_t_e_r. If the expansion of - _s_t_r_i_n_g is null, matches of _p_a_t_t_e_r_n are deleted. If _s_t_r_i_n_g is - null, matches of _p_a_t_t_e_r_n are deleted and the // following _p_a_t_t_e_r_n - may be omitted. - - If the ppaattssuubb__rreeppllaacceemmeenntt shell option is enabled using sshhoopptt, - any unquoted instances of && in _s_t_r_i_n_g are replaced with the + tern and matched against the expanded value of _p_a_r_a_m_e_t_e_r as de- + scribed under PPaatttteerrnn MMaattcchhiinngg below. The longest match of _p_a_t_- + _t_e_r_n in the expanded value is replaced with _s_t_r_i_n_g. _s_t_r_i_n_g un- + dergoes tilde expansion, parameter and variable expansion, + arithmetic expansion, command and process substitution, and + quote removal. + + In the first form above, only the first match is replaced. If + there are two slashes separating _p_a_r_a_m_e_t_e_r and _p_a_t_t_e_r_n (the sec- + ond form above), all matches of _p_a_t_t_e_r_n are replaced with + _s_t_r_i_n_g. If _p_a_t_t_e_r_n is preceded by ## (the third form above), it + must match at the beginning of the expanded value of _p_a_r_a_m_e_t_e_r. + If _p_a_t_t_e_r_n is preceded by %% (the fourth form above), it must + match at the end of the expanded value of _p_a_r_a_m_e_t_e_r. + + If the expansion of _s_t_r_i_n_g is null, matches of _p_a_t_t_e_r_n are + deleted and the // following _p_a_t_t_e_r_n may be omitted. + + If the ppaattssuubb__rreeppllaacceemmeenntt shell option is enabled using sshhoopptt, + any unquoted instances of && in _s_t_r_i_n_g are replaced with the matching portion of _p_a_t_t_e_r_n. Quoting any part of _s_t_r_i_n_g inhibits replacement in the expansion of the quoted portion, including replacement strings stored in - shell variables. Backslash will escape && in _s_t_r_i_n_g; the back- - slash is removed in order to permit a literal && in the replace- - ment string. Backslash can also be used to escape a backslash; - \\\\ results in a literal backslash in the replacement. Users - should take care if _s_t_r_i_n_g is double-quoted to avoid unwanted - interactions between the backslash and double-quoting, since - backslash has special meaning within double quotes. Pattern - substitution performs the check for unquoted && after expanding - _s_t_r_i_n_g; shell programmers should quote any occurrences of && they - want to be taken literally in the replacement and ensure any in- - stances of && they want to be replaced are unquoted. - - If the nnooccaasseemmaattcchh shell option is enabled, the match is per- - formed without regard to the case of alphabetic characters. If - _p_a_r_a_m_e_t_e_r is @@ or **, the substitution operation is applied to - each positional parameter in turn, and the expansion is the re- - sultant list. If _p_a_r_a_m_e_t_e_r is an array variable subscripted - with @@ or **, the substitution operation is applied to each mem- - ber of the array in turn, and the expansion is the resultant + shell variables. Backslash escapes && in _s_t_r_i_n_g; the backslash + is removed in order to permit a literal && in the replacement + string. Backslash can also be used to escape a backslash; \\\\ + results in a literal backslash in the replacement. Users should + take care if _s_t_r_i_n_g is double-quoted to avoid unwanted interac- + tions between the backslash and double-quoting, since backslash + has special meaning within double quotes. Pattern substitution + performs the check for unquoted && after expanding _s_t_r_i_n_g; shell + programmers should quote any occurrences of && they want to be + taken literally in the replacement and ensure any instances of && + they want to be replaced are unquoted. + + Like the pattern removal operators, double quotes surrounding + the replacement string quote the expanded characters, while dou- + ble quotes enclosing the entire parameter substitution do not, + since the expansion is performed in a context that doesn't take + any enclosing double quotes into account. + + If the nnooccaasseemmaattcchh shell option is enabled, the match is per- + formed without regard to the case of alphabetic characters. + + If _p_a_r_a_m_e_t_e_r is @@ or **, the substitution operation is applied to + each positional parameter in turn, and the expansion is the re- + sultant list. If _p_a_r_a_m_e_t_e_r is an array variable subscripted + with @@ or **, the substitution operation is applied to each mem- + ber of the array in turn, and the expansion is the resultant list. ${_p_a_r_a_m_e_t_e_r^^_p_a_t_t_e_r_n} ${_p_a_r_a_m_e_t_e_r^^^^_p_a_t_t_e_r_n} ${_p_a_r_a_m_e_t_e_r,,_p_a_t_t_e_r_n} ${_p_a_r_a_m_e_t_e_r,,,,_p_a_t_t_e_r_n} - CCaassee mmooddiiffiiccaattiioonn. This expansion modifies the case of alpha- - betic characters in _p_a_r_a_m_e_t_e_r. The _p_a_t_t_e_r_n is expanded to pro- - duce a pattern just as in pathname expansion. Each character in - the expanded value of _p_a_r_a_m_e_t_e_r is tested against _p_a_t_t_e_r_n, and, - if it matches the pattern, its case is converted. The pattern - should not attempt to match more than one character. The ^^ op- - erator converts lowercase letters matching _p_a_t_t_e_r_n to uppercase; - the ,, operator converts matching uppercase letters to lowercase. - The ^^^^ and ,,,, expansions convert each matched character in the - expanded value; the ^^ and ,, expansions match and convert only - the first character in the expanded value. If _p_a_t_t_e_r_n is omit- - ted, it is treated like a ??, which matches every character. If - _p_a_r_a_m_e_t_e_r is @@ or **, the case modification operation is applied - to each positional parameter in turn, and the expansion is the - resultant list. If _p_a_r_a_m_e_t_e_r is an array variable subscripted - with @@ or **, the case modification operation is applied to each - member of the array in turn, and the expansion is the resultant - list. + CCaassee mmooddiiffiiccaattiioonn. This expansion modifies the case of alpha- + betic characters in _p_a_r_a_m_e_t_e_r. First, the _p_a_t_t_e_r_n is expanded + to produce a pattern as described below under PPaatttteerrnn MMaattcchhiinngg. + BBaasshh then examines characters in the expanded value of _p_a_r_a_m_e_t_e_r + against _p_a_t_t_e_r_n as described below. If a character matches the + pattern, its case is converted. The pattern should not attempt + to match more than one character. + + Using "^" converts lowercase letters matching _p_a_t_t_e_r_n to upper- + case; "," converts matching uppercase letters to lowercase. The + ^^ and ,, variants examine the first character in the expanded + value and convert its case if it matches _p_a_t_t_e_r_n; the ^^^^ and ,,,, + variants examine all characters in the expanded value and con- + vert each one that matches _p_a_t_t_e_r_n. If _p_a_t_t_e_r_n is omitted, it + is treated like a ??, which matches every character. + + If _p_a_r_a_m_e_t_e_r is @@ or **, the case modification operation is ap- + plied to each positional parameter in turn, and the expansion is + the resultant list. If _p_a_r_a_m_e_t_e_r is an array variable sub- + scripted with @@ or **, the case modification operation is applied + to each member of the array in turn, and the expansion is the + resultant list. ${_p_a_r_a_m_e_t_e_r@@_o_p_e_r_a_t_o_r} PPaarraammeetteerr ttrraannssffoorrmmaattiioonn. The expansion is either a transforma- tion of the value of _p_a_r_a_m_e_t_e_r or information about _p_a_r_a_m_e_t_e_r itself, depending on the value of _o_p_e_r_a_t_o_r. Each _o_p_e_r_a_t_o_r is a single letter: - UU The expansion is a string that is the value of _p_a_r_a_m_e_t_e_r with lowercase alphabetic characters converted to upper- case. uu The expansion is a string that is the value of _p_a_r_a_m_e_t_e_r with the first character converted to uppercase, if it is alphabetic. - LL The expansion is a string that is the value of _p_a_r_a_m_e_t_e_r - with uppercase alphabetic characters converted to lower- + LL The expansion is a string that is the value of _p_a_r_a_m_e_t_e_r + with uppercase alphabetic characters converted to lower- case. - QQ The expansion is a string that is the value of _p_a_r_a_m_e_t_e_r + QQ The expansion is a string that is the value of _p_a_r_a_m_e_t_e_r quoted in a format that can be reused as input. - EE The expansion is a string that is the value of _p_a_r_a_m_e_t_e_r - with backslash escape sequences expanded as with the - $$''......'' quoting mechanism. + EE The expansion is a string that is the value of _p_a_r_a_m_e_t_e_r + with backslash escape sequences expanded as with the + $$''...'' quoting mechanism. PP The expansion is a string that is the result of expanding the value of _p_a_r_a_m_e_t_e_r as if it were a prompt string (see PPRROOMMPPTTIINNGG below). - AA The expansion is a string in the form of an assignment - statement or ddeeccllaarree command that, if evaluated, will - recreate _p_a_r_a_m_e_t_e_r with its attributes and value. - KK Produces a possibly-quoted version of the value of _p_a_r_a_m_- - _e_t_e_r, except that it prints the values of indexed and as- - sociative arrays as a sequence of quoted key-value pairs - (see AArrrraayyss above). - aa The expansion is a string consisting of flag values rep- + AA The expansion is a string in the form of an assignment + statement or ddeeccllaarree command that, if evaluated, recre- + ates _p_a_r_a_m_e_t_e_r with its attributes and value. + KK Produces a possibly-quoted version of the value of _p_a_r_a_- + _m_e_t_e_r, except that it prints the values of indexed and + associative arrays as a sequence of quoted key-value + pairs (see AArrrraayyss above). The keys and values are quoted + in a format that can be reused as input. + aa The expansion is a string consisting of flag values rep- resenting _p_a_r_a_m_e_t_e_r's attributes. - kk Like the K transformation, but expands the keys and val- - ues of indexed and associative arrays to separate words + kk Like the K transformation, but expands the keys and val- + ues of indexed and associative arrays to separate words after word splitting. - If _p_a_r_a_m_e_t_e_r is @@ or **, the operation is applied to each posi- - tional parameter in turn, and the expansion is the resultant - list. If _p_a_r_a_m_e_t_e_r is an array variable subscripted with @@ or + If _p_a_r_a_m_e_t_e_r is @@ or **, the operation is applied to each posi- + tional parameter in turn, and the expansion is the resultant + list. If _p_a_r_a_m_e_t_e_r is an array variable subscripted with @@ or **, the operation is applied to each member of the array in turn, and the expansion is the resultant list. @@ -1954,11 +2156,11 @@ EEXXPPAANNSSIIOONN CCoommmmaanndd SSuubbssttiittuuttiioonn _C_o_m_m_a_n_d _s_u_b_s_t_i_t_u_t_i_o_n allows the output of a command to replace the com- - mand name. There are two forms: + mand itself. There are two standard forms: $$((_c_o_m_m_a_n_d)) - or - ``_c_o_m_m_a_n_d`` + or (deprecated) + ``_c_o_m_m_a_n_d``. BBaasshh performs the expansion by executing _c_o_m_m_a_n_d in a subshell environ- ment and replacing the command substitution with the standard output of @@ -1967,206 +2169,274 @@ EEXXPPAANNSSIIOONN mand substitution $$((ccaatt _f_i_l_e)) can be replaced by the equivalent but faster $$((<< _f_i_l_e)). - When the old-style backquote form of substitution is used, backslash - retains its literal meaning except when followed by $$, ``, or \\. The - first backquote not preceded by a backslash terminates the command sub- - stitution. When using the $(_c_o_m_m_a_n_d) form, all characters between the + With the old-style backquote form of substitution, backslash retains + its literal meaning except when followed by $$, ``, or \\. The first + backquote not preceded by a backslash terminates the command substitu- + tion. When using the $(_c_o_m_m_a_n_d) form, all characters between the parentheses make up the command; none are treated specially. + There is an alternate form of command substitution: + + $${{_c _c_o_m_m_a_n_d;;}} + + which executes _c_o_m_m_a_n_d in the current execution environment and cap- + tures its output, again with trailing newlines removed. + + The character _c following the open brace must be a space, tab, newline, + or ||, and the close brace must be in a position where a reserved word + may appear (i.e., preceded by a command terminator such as semicolon). + BBaasshh allows the close brace to be joined to the remaining characters in + the word without being followed by a shell metacharacter as a reserved + word would usually require. + + Any side effects of _c_o_m_m_a_n_d take effect immediately in the current exe- + cution environment and persist in the current environment after the + command completes (e.g., the eexxiitt builtin exits the shell). + + This type of command substitution superficially resembles executing an + unnamed shell function: local variables are created as when a shell + function is executing, and the rreettuurrnn builtin forces _c_o_m_m_a_n_d to com- + plete; however, the rest of the execution environment, including the + positional parameters, is shared with the caller. + + If the first character following the open brace is a ||, the construct + expands to the value of the RREEPPLLYY shell variable after _c_o_m_m_a_n_d exe- + cutes, without removing any trailing newlines, and the standard output + of _c_o_m_m_a_n_d remains the same as in the calling shell. BBaasshh creates RREE-- + PPLLYY as an initially-unset local variable when _c_o_m_m_a_n_d executes, and re- + stores RREEPPLLYY to the value it had before the command substitution after + _c_o_m_m_a_n_d completes, as with any local variable. + Command substitutions may be nested. To nest when using the backquoted form, escape the inner backquotes with backslashes. - If the substitution appears within double quotes, word splitting and - pathname expansion are not performed on the results. + If the substitution appears within double quotes, bbaasshh does not perform + word splitting and pathname expansion on the results. AArriitthhmmeettiicc EExxppaannssiioonn - Arithmetic expansion allows the evaluation of an arithmetic expression - and the substitution of the result. The format for arithmetic expan- - sion is: + Arithmetic expansion evaluates an arithmetic expression and substitutes + the result. The format for arithmetic expansion is: $$((((_e_x_p_r_e_s_s_i_o_n)))) The _e_x_p_r_e_s_s_i_o_n undergoes the same expansions as if it were within dou- - ble quotes, but double quote characters in _e_x_p_r_e_s_s_i_o_n are not treated - specially and are removed. All tokens in the expression undergo param- - eter and variable expansion, command substitution, and quote removal. - The result is treated as the arithmetic expression to be evaluated. - Arithmetic expansions may be nested. + ble quotes, but unescaped double quote characters in _e_x_p_r_e_s_s_i_o_n are not + treated specially and are removed. All tokens in the expression un- + dergo parameter and variable expansion, command substitution, and quote + removal. The result is treated as the arithmetic expression to be + evaluated. Since the way Bash handles double quotes can potentially + result in empty strings, arithmetic expansion treats those as expres- + sions that evaluate to 0. Arithmetic expansions may be nested. The evaluation is performed according to the rules listed below under AARRIITTHHMMEETTIICC EEVVAALLUUAATTIIOONN. If _e_x_p_r_e_s_s_i_o_n is invalid, bbaasshh prints a message - indicating failure and no substitution occurs. + to standard error indicating failure, does not perform the substitu- + tion, and does not execute the command associated with the expansion. PPrroocceessss SSuubbssttiittuuttiioonn _P_r_o_c_e_s_s _s_u_b_s_t_i_t_u_t_i_o_n allows a process's input or output to be referred to using a filename. It takes the form of <<((_l_i_s_t)) or >>((_l_i_s_t)). The process _l_i_s_t is run asynchronously, and its input or output appears as a filename. This filename is passed as an argument to the current com- - mand as the result of the expansion. If the >>((_l_i_s_t)) form is used, - writing to the file will provide input for _l_i_s_t. If the <<((_l_i_s_t)) form - is used, the file passed as an argument should be read to obtain the - output of _l_i_s_t. Process substitution is supported on systems that sup- - port named pipes (_F_I_F_O_s) or the //ddeevv//ffdd method of naming open files. - - When available, process substitution is performed simultaneously with - parameter and variable expansion, command substitution, and arithmetic + mand as the result of the expansion. + + If the >>((_l_i_s_t)) form is used, writing to the file provides input for + _l_i_s_t. If the <<((_l_i_s_t)) form is used, reading the file obtains the output + of _l_i_s_t. No space may appear between the << or >> and the left parenthe- + sis, otherwise the construct would be interpreted as a redirection. + + Process substitution is supported on systems that support named pipes + (_F_I_F_O_s) or the _/_d_e_v_/_f_d method of naming open files. + + When available, process substitution is performed simultaneously with + parameter and variable expansion, command substitution, and arithmetic expansion. WWoorrdd SSpplliittttiinngg - The shell scans the results of parameter expansion, command substitu- - tion, and arithmetic expansion that did not occur within double quotes - for _w_o_r_d _s_p_l_i_t_t_i_n_g. - - The shell treats each character of IIFFSS as a delimiter, and splits the - results of the other expansions into words using these characters as - field terminators. If IIFFSS is unset, or its value is exactly - <><><>, the default, then sequences of <>, <>, - and <> at the beginning and end of the results of the previous - expansions are ignored, and any sequence of IIFFSS characters not at the - beginning or end serves to delimit words. If IIFFSS has a value other - than the default, then sequences of the whitespace characters ssppaaccee, - ttaabb, and nneewwlliinnee are ignored at the beginning and end of the word, as - long as the whitespace character is in the value of IIFFSS (an IIFFSS white- - space character). Any character in IIFFSS that is not IIFFSS whitespace, - along with any adjacent IIFFSS whitespace characters, delimits a field. A - sequence of IIFFSS whitespace characters is also treated as a delimiter. - If the value of IIFFSS is null, no word splitting occurs. + The shell scans the results of parameter expansion, command substitu- + tion, and arithmetic expansion that did not occur within double quotes + for _w_o_r_d _s_p_l_i_t_t_i_n_g. Words that were not expanded are not split. + + The shell treats each character of IIFFSS as a delimiter, and splits the + results of the other expansions into words using these characters as + field terminators. + + An _I_F_S _w_h_i_t_e_s_p_a_c_e character is whitespace as defined above (see DDeeffiinnii-- + ttiioonnss) that appears in the value of IIFFSS. Space, tab, and newline are + always considered IFS whitespace, even if they don't appear in the lo- + cale's ssppaaccee category. + + If IIFFSS is unset, field splitting acts as if its value were + <><><>, and treats these characters as IFS whitespace. + If the value of IIFFSS is null, no word splitting occurs, but implicit + null arguments (see below) are still removed. + + Word splitting begins by removing sequences of IFS whitespace charac- + ters from the beginning and end of the results of the previous expan- + sions, then splits the remaining words. + + If the value of IIFFSS consists solely of IFS whitespace, any sequence of + IFS whitespace characters delimits a field, so a field consists of + characters that are not unquoted IFS whitespace, and null fields result + only from quoting. + + If IIFFSS contains a non-whitespace character, then any character in the + value of IIFFSS that is not IFS whitespace, along with any adjacent IFS + whitespace characters, delimits a field. This means that adjacent non- + IFS-whitespace delimiters produce a null field. A sequence of IFS + whitespace characters also delimits a field. Explicit null arguments ("""" or '''') are retained and passed to commands as empty strings. Unquoted implicit null arguments, resulting from the - expansion of parameters that have no values, are removed. If a parame- - ter with no value is expanded within double quotes, a null argument re- - sults and is retained and passed to a command as an empty string. When - a quoted null argument appears as part of a word whose expansion is - non-null, the null argument is removed. That is, the word -d'' becomes - -d after word splitting and null argument removal. + expansion of parameters that have no values, are removed. Expanding a + parameter with no value within double quotes produces a null field, + which is retained and passed to a command as an empty string. - Note that if no expansion occurs, no splitting is performed. + When a quoted null argument appears as part of a word whose expansion + is non-null, word splitting removes the null argument portion, leaving + the non-null expansion. That is, the word "-d''" becomes "-d" after + word splitting and null argument removal. PPaatthhnnaammee EExxppaannssiioonn - After word splitting, unless the --ff option has been set, bbaasshh scans - each word for the characters **, ??, and [[. If one of these characters + After word splitting, unless the --ff option has been set, bbaasshh scans + each word for the characters **, ??, and [[. If one of these characters appears, and is not quoted, then the word is regarded as a _p_a_t_t_e_r_n, and - replaced with an alphabetically sorted list of filenames matching the - pattern (see PPaatttteerrnn MMaattcchhiinngg below). If no matching filenames are - found, and the shell option nnuullllgglloobb is not enabled, the word is left - unchanged. If the nnuullllgglloobb option is set, and no matches are found, - the word is removed. If the ffaaiillgglloobb shell option is set, and no - matches are found, an error message is printed and the command is not - executed. If the shell option nnooccaasseegglloobb is enabled, the match is per- - formed without regard to the case of alphabetic characters. When a - pattern is used for pathname expansion, the character ````..'''' at the + replaced with a sorted list of filenames matching the pattern (see PPaatt-- + tteerrnn MMaattcchhiinngg below) subject to the value of the GGLLOOBBSSOORRTT shell vari- + able. + + If no matching filenames are found, and the shell option nnuullllgglloobb is + not enabled, the word is left unchanged. If the nnuullllgglloobb option is + set, and no matches are found, the word is removed. If the ffaaiillgglloobb + shell option is set, and no matches are found, bbaasshh prints an error + message and does not execute the command. If the shell option nnooccaassee-- + gglloobb is enabled, the match is performed without regard to the case of + alphabetic characters. + + When a pattern is used for pathname expansion, the character "." at the start of a name or immediately following a slash must be matched ex- plicitly, unless the shell option ddoottgglloobb is set. In order to match - the filenames ````..'''' and ````....'''', the pattern must begin with ``.'' (for - example, ``.?''), even if ddoottgglloobb is set. If the gglloobbsskkiippddoottss shell - option is enabled, the filenames ````..'''' and ````....'''' are never matched, - even if the pattern begins with a ````..''''. When not matching pathnames, - the ````..'''' character is not treated specially. When matching a path- - name, the slash character must always be matched explicitly by a slash - in the pattern, but in other matching contexts it can be matched by a - special pattern character as described below under PPaatttteerrnn MMaattcchhiinngg. - See the description of sshhoopptt below under SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS for a - description of the nnooccaasseegglloobb, nnuullllgglloobb, gglloobbsskkiippddoottss, ffaaiillgglloobb, and + the filenames _. and _._., the pattern must begin with "." (for example, + ".?"), even if ddoottgglloobb is set. If the gglloobbsskkiippddoottss shell option is en- + abled, the filenames _. and _._. never match, even if the pattern begins + with a ".". When not matching pathnames, the "." character is not + treated specially. + + When matching a pathname, the slash character must always be matched + explicitly by a slash in the pattern, but in other matching contexts it + can be matched by a special pattern character as described below under + PPaatttteerrnn MMaattcchhiinngg. + + See the description of sshhoopptt below under SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS for a + description of the nnooccaasseegglloobb, nnuullllgglloobb, gglloobbsskkiippddoottss, ffaaiillgglloobb, and ddoottgglloobb shell options. - The GGLLOOBBIIGGNNOORREE shell variable may be used to restrict the set of file - names matching a _p_a_t_t_e_r_n. If GGLLOOBBIIGGNNOORREE is set, each matching file - name that also matches one of the patterns in GGLLOOBBIIGGNNOORREE is removed - from the list of matches. If the nnooccaasseegglloobb option is set, the match- - ing against the patterns in GGLLOOBBIIGGNNOORREE is performed without regard to - case. The filenames ````..'''' and ````....'''' are always ignored when GGLLOOBBIIGG-- - NNOORREE is set and not null. However, setting GGLLOOBBIIGGNNOORREE to a non-null - value has the effect of enabling the ddoottgglloobb shell option, so all other - filenames beginning with a ````..'''' will match. To get the old behavior - of ignoring filenames beginning with a ````..'''', make ````..**'''' one of the - patterns in GGLLOOBBIIGGNNOORREE. The ddoottgglloobb option is disabled when GGLLOOBBIIGGNNOORREE - is unset. The pattern matching honors the setting of the eexxttgglloobb shell - option. + The GGLLOOBBIIGGNNOORREE shell variable may be used to restrict the set of file + names matching a _p_a_t_t_e_r_n. If GGLLOOBBIIGGNNOORREE is set, each matching file + name that also matches one of the patterns in GGLLOOBBIIGGNNOORREE is removed + from the list of matches. If the nnooccaasseegglloobb option is set, the match- + ing against the patterns in GGLLOOBBIIGGNNOORREE is performed without regard to + case. The filenames _. and _._. are always ignored when GGLLOOBBIIGGNNOORREE is set + and not null. However, setting GGLLOOBBIIGGNNOORREE to a non-null value has the + effect of enabling the ddoottgglloobb shell option, so all other filenames be- + ginning with a "." match. To get the old behavior of ignoring file- + names beginning with a ".", make ".*" one of the patterns in GGLLOOBBIIGG-- + NNOORREE. The ddoottgglloobb option is disabled when GGLLOOBBIIGGNNOORREE is unset. The + GGLLOOBBIIGGNNOORREE pattern matching honors the setting of the eexxttgglloobb shell op- + tion. + + The value of the GGLLOOBBSSOORRTT shell variable controls how the results of + pathname expansion are sorted, as described above under SShheellll VVaarrii-- + aabblleess. PPaatttteerrnn MMaattcchhiinngg Any character that appears in a pattern, other than the special pattern - characters described below, matches itself. The NUL character may not - occur in a pattern. A backslash escapes the following character; the - escaping backslash is discarded when matching. The special pattern + characters described below, matches itself. The NUL character may not + occur in a pattern. A backslash escapes the following character; the + escaping backslash is discarded when matching. The special pattern characters must be quoted if they are to be matched literally. The special pattern characters have the following meanings: - ** Matches any string, including the null string. When the - gglloobbssttaarr shell option is enabled, and ** is used in a - pathname expansion context, two adjacent **s used as a - single pattern will match all files and zero or more di- - rectories and subdirectories. If followed by a //, two - adjacent **s will match only directories and subdirecto- - ries. + ** Matches any string, including the null string. When the + gglloobbssttaarr shell option is enabled, and ** is used in a + pathname expansion context, two adjacent **s used as a + single pattern match all files and zero or more directo- + ries and subdirectories. If followed by a //, two adja- + cent **s match only directories and subdirectories. ?? Matches any single character. - [[......]] Matches any one of the enclosed characters. A pair of - characters separated by a hyphen denotes a _r_a_n_g_e _e_x_p_r_e_s_- - _s_i_o_n; any character that falls between those two charac- - ters, inclusive, using the current locale's collating se- - quence and character set, is matched. If the first char- - acter following the [[ is a !! or a ^^ then any character - not enclosed is matched. The sorting order of characters - in range expressions, and the characters included in the - range, are determined by the current locale and the val- - ues of the LLCC__CCOOLLLLAATTEE or LLCC__AALLLL shell variables, if set. - To obtain the traditional interpretation of range expres- - sions, where [[aa--dd]] is equivalent to [[aabbccdd]], set value of - the LLCC__AALLLL shell variable to CC, or enable the gglloobbaassccii-- - iirraannggeess shell option. A -- may be matched by including it - as the first or last character in the set. A ]] may be - matched by including it as the first character in the - set. - - Within [[ and ]], _c_h_a_r_a_c_t_e_r _c_l_a_s_s_e_s can be specified using - the syntax [[::_c_l_a_s_s::]], where _c_l_a_s_s is one of the following - classes defined in the POSIX standard: - aallnnuumm aallpphhaa aasscciiii bbllaannkk ccnnttrrll ddiiggiitt ggrraapphh lloowweerr pprriinntt + [[...]] Matches any one of the characters enclosed between the + brackets. This is known as a _b_r_a_c_k_e_t _e_x_p_r_e_s_s_i_o_n and + matches a single character. A pair of characters sepa- + rated by a hyphen denotes a _r_a_n_g_e _e_x_p_r_e_s_s_i_o_n; any charac- + ter that falls between those two characters, inclusive, + using the current locale's collating sequence and charac- + ter set, matches. If the first character following the [[ + is a !! or a ^^ then any character not within the range + matches. To match a --, include it as the first or last + character in the set. To match a ]], include it as the + first character in the set. + + The sorting order of characters in range expressions, and + the characters included in the range, are determined by + the current locale and the values of the LLCC__CCOOLLLLAATTEE or + LLCC__AALLLL shell variables, if set. To obtain the tradi- + tional interpretation of range expressions, where [[aa--dd]] + is equivalent to [[aabbccdd]], set the value of the LLCC__CCOOLLLLAATTEE + or LLCC__AALLLL shell variables to CC, or enable the gglloobbaassccii-- + iirraannggeess shell option. + + Within a bracket expression, _c_h_a_r_a_c_t_e_r _c_l_a_s_s_e_s can be + specified using the syntax [[::_c_l_a_s_s::]], where _c_l_a_s_s is one + of the following classes defined in the POSIX standard: + + aallnnuumm aallpphhaa aasscciiii bbllaannkk ccnnttrrll ddiiggiitt ggrraapphh lloowweerr pprriinntt ppuunncctt ssppaaccee uuppppeerr wwoorrdd xxddiiggiitt + A character class matches any character belonging to that class. The wwoorrdd character class matches letters, digits, and the character _. - Within [[ and ]], an _e_q_u_i_v_a_l_e_n_c_e _c_l_a_s_s can be specified us- - ing the syntax [[==_c==]], which matches all characters with - the same collation weight (as defined by the current lo- - cale) as the character _c. + Within a bracket expression, an _e_q_u_i_v_a_l_e_n_c_e _c_l_a_s_s can be + specified using the syntax [[==_c==]], which matches all char- + acters with the same collation weight (as defined by the + current locale) as the character _c. - Within [[ and ]], the syntax [[.._s_y_m_b_o_l..]] matches the collat- - ing symbol _s_y_m_b_o_l. + Within a bracket expression, the syntax [[.._s_y_m_b_o_l..]] + matches the collating symbol _s_y_m_b_o_l. If the eexxttgglloobb shell option is enabled using the sshhoopptt builtin, the shell recognizes several extended pattern matching operators. In the following description, a _p_a_t_t_e_r_n_-_l_i_s_t is a list of one or more patterns - separated by a ||. Composite patterns may be formed using one or more + separated by a ||. Composite patterns may be formed using one or more of the following sub-patterns: ??((_p_a_t_t_e_r_n_-_l_i_s_t)) - Matches zero or one occurrence of the given patterns + Matches zero or one occurrence of the given patterns. **((_p_a_t_t_e_r_n_-_l_i_s_t)) - Matches zero or more occurrences of the given patterns + Matches zero or more occurrences of the given patterns. ++((_p_a_t_t_e_r_n_-_l_i_s_t)) - Matches one or more occurrences of the given patterns + Matches one or more occurrences of the given patterns. @@((_p_a_t_t_e_r_n_-_l_i_s_t)) - Matches one of the given patterns + Matches one of the given patterns. !!((_p_a_t_t_e_r_n_-_l_i_s_t)) - Matches anything except one of the given patterns + Matches anything except one of the given patterns. - Theeexxttgglloobb option changes the behavior of the parser, since the paren- + The eexxttgglloobb option changes the behavior of the parser, since the paren- theses are normally treated as operators with syntactic meaning. To ensure that extended matching patterns are parsed correctly, make sure that eexxttgglloobb is enabled before parsing constructs containing the pat- terns, including shell functions and command substitutions. When matching filenames, the ddoottgglloobb shell option determines the set of - filenames that are tested: when ddoottgglloobb is enabled, the set of file- - names includes all files beginning with ``.'', but ``.'' and ``..'' - must be matched by a pattern or sub-pattern that begins with a dot; - when it is disabled, the set does not include any filenames beginning - with ``.'' unless the pattern or sub-pattern begins with a ``.''. As - above, ``.'' only has a special meaning when matching filenames. + filenames that are tested: when ddoottgglloobb is enabled, the set of file- + names includes all files beginning with ".", but _. and _._. must be + matched by a pattern or sub-pattern that begins with a dot; when it is + disabled, the set does not include any filenames beginning with "." un- + less the pattern or sub-pattern begins with a ".". If the gglloobbsskkiippddoottss + shell option is enabled, the filenames _. and _._. never appear in the + set. As above, "." only has a special meaning when matching filenames. Complicated extended pattern matching against long strings is slow, es- pecially when the patterns contain alternations and the strings contain @@ -2175,65 +2445,63 @@ EEXXPPAANNSSIIOONN QQuuoottee RReemmoovvaall After the preceding expansions, all unquoted occurrences of the charac- - ters \\, '', and "" that did not result from one of the above expansions + ters \\, '', and "" that did not result from one of the above expansions are removed. RREEDDIIRREECCTTIIOONN - Before a command is executed, its input and output may be _r_e_d_i_r_e_c_t_e_d - using a special notation interpreted by the shell. _R_e_d_i_r_e_c_t_i_o_n allows - commands' file handles to be duplicated, opened, closed, made to refer + Before a command is executed, its input and output may be _r_e_d_i_r_e_c_t_e_d + using a special notation interpreted by the shell. _R_e_d_i_r_e_c_t_i_o_n allows + commands' file handles to be duplicated, opened, closed, made to refer to different files, and can change the files the command reads from and - writes to. Redirection may also be used to modify file handles in the - current shell execution environment. The following redirection opera- - tors may precede or appear anywhere within a _s_i_m_p_l_e _c_o_m_m_a_n_d or may fol- - low a _c_o_m_m_a_n_d. Redirections are processed in the order they appear, - from left to right. + writes to. When used with the eexxeecc builtin, redirections modify file + handles in the current shell execution environment. The following + redirection operators may precede or appear anywhere within a _s_i_m_p_l_e + _c_o_m_m_a_n_d or may follow a _c_o_m_m_a_n_d. Redirections are processed in the or- + der they appear, from left to right. - Each redirection that may be preceded by a file descriptor number may + Each redirection that may be preceded by a file descriptor number may instead be preceded by a word of the form {_v_a_r_n_a_m_e}. In this case, for - each redirection operator except >&- and <&-, the shell will allocate a - file descriptor greater than or equal to 10 and assign it to _v_a_r_n_a_m_e. - If >&- or <&- is preceded by {_v_a_r_n_a_m_e}, the value of _v_a_r_n_a_m_e defines - the file descriptor to close. If {_v_a_r_n_a_m_e} is supplied, the redirect- - ion persists beyond the scope of the command, allowing the shell pro- - grammer to manage the file descriptor's lifetime manually. The - vvaarrrreeddiirr__cclloossee shell option manages this behavior. + each redirection operator except >>&&-- and <<&&--, the shell allocates a + file descriptor greater than or equal to 10 and assigns it to _v_a_r_n_a_m_e. + If {_v_a_r_n_a_m_e} precedes >>&&-- or <<&&--, the value of _v_a_r_n_a_m_e defines the file + descriptor to close. If {_v_a_r_n_a_m_e} is supplied, the redirection per- + sists beyond the scope of the command, which allows the shell program- + mer to manage the file descriptor's lifetime manually without using the + eexxeecc builtin. The vvaarrrreeddiirr__cclloossee shell option manages this behavior. In the following descriptions, if the file descriptor number is omit- - ted, and the first character of the redirection operator is <<, the re- - direction refers to the standard input (file descriptor 0). If the - first character of the redirection operator is >>, the redirection + ted, and the first character of the redirection operator is "<", the + redirection refers to the standard input (file descriptor 0). If the + first character of the redirection operator is ">", the redirection refers to the standard output (file descriptor 1). - The word following the redirection operator in the following descrip- + The _w_o_r_d following the redirection operator in the following descrip- tions, unless otherwise noted, is subjected to brace expansion, tilde expansion, parameter and variable expansion, command substitution, arithmetic expansion, quote removal, pathname expansion, and word splitting. If it expands to more than one word, bbaasshh reports an error. - Note that the order of redirections is significant. For example, the - command + The order of redirections is significant. For example, the command ls >> dirlist 2>>&&1 - directs both standard output and standard error to the file _d_i_r_l_i_s_t, + directs both standard output and standard error to the file _d_i_r_l_i_s_t, while the command ls 2>>&&1 >> dirlist - directs only the standard output to file _d_i_r_l_i_s_t, because the standard - error was duplicated from the standard output before the standard out- - put was redirected to _d_i_r_l_i_s_t. + directs only the standard output to file _d_i_r_l_i_s_t, because the standard + error was directed to the standard output before the standard output + was redirected to _d_i_r_l_i_s_t. BBaasshh handles several filenames specially when they are used in redirec- tions, as described in the following table. If the operating system on - which bbaasshh is running provides these special files, bash will use them; - otherwise it will emulate them internally with the behavior described - below. + which bbaasshh is running provides these special files, bbaasshh uses them; + otherwise it emulates them internally with the behavior described be- + low. //ddeevv//ffdd//_f_d - If _f_d is a valid integer, file descriptor _f_d is dupli- - cated. + If _f_d is a valid integer, duplicate file descriptor _f_d. //ddeevv//ssttddiinn File descriptor 0 is duplicated. //ddeevv//ssttddoouutt @@ -2242,7 +2510,7 @@ RREEDDIIRREECCTTIIOONN File descriptor 2 is duplicated. //ddeevv//ttccpp//_h_o_s_t//_p_o_r_t If _h_o_s_t is a valid hostname or Internet address, and _p_o_r_t - is an integer port number or service name, bbaasshh attempts + is an integer port number or service name, bbaasshh attempts to open the corresponding TCP socket. //ddeevv//uuddpp//_h_o_s_t//_p_o_r_t If _h_o_s_t is a valid hostname or Internet address, and _p_o_r_t @@ -2256,48 +2524,47 @@ RREEDDIIRREECCTTIIOONN nally. RReeddiirreeccttiinngg IInnppuutt - Redirection of input causes the file whose name results from the expan- - sion of _w_o_r_d to be opened for reading on file descriptor _n, or the - standard input (file descriptor 0) if _n is not specified. + Redirecting input opens the file whose name results from the expansion + of _w_o_r_d for reading on file descriptor _n, or the standard input (file + descriptor 0) if _n is not specified. The general format for redirecting input is: [_n]<<_w_o_r_d RReeddiirreeccttiinngg OOuuttppuutt - Redirection of output causes the file whose name results from the ex- - pansion of _w_o_r_d to be opened for writing on file descriptor _n, or the - standard output (file descriptor 1) if _n is not specified. If the file - does not exist it is created; if it does exist it is truncated to zero - size. + Redirecting output opens the file whose name results from the expansion + of _w_o_r_d for writing on file descriptor _n, or the standard output (file + descriptor 1) if _n is not specified. If the file does not exist it is + created; if it does exist it is truncated to zero size. The general format for redirecting output is: [_n]>>_w_o_r_d If the redirection operator is >>, and the nnoocclloobbbbeerr option to the sseett - builtin has been enabled, the redirection will fail if the file whose - name results from the expansion of _w_o_r_d exists and is a regular file. - If the redirection operator is >>||, or the redirection operator is >> and - the nnoocclloobbbbeerr option to the sseett builtin command is not enabled, the re- - direction is attempted even if the file named by _w_o_r_d exists. + builtin command has been enabled, the redirection fails if the file + whose name results from the expansion of _w_o_r_d exists and is a regular + file. If the redirection operator is >>||, or the redirection operator + is >> and the nnoocclloobbbbeerr option to the sseett builtin is not enabled, bbaasshh + attempts the redirection even if the file named by _w_o_r_d exists. AAppppeennddiinngg RReeddiirreecctteedd OOuuttppuutt - Redirection of output in this fashion causes the file whose name re- - sults from the expansion of _w_o_r_d to be opened for appending on file de- - scriptor _n, or the standard output (file descriptor 1) if _n is not - specified. If the file does not exist it is created. + Redirecting output in this fashion opens the file whose name results + from the expansion of _w_o_r_d for appending on file descriptor _n, or the + standard output (file descriptor 1) if _n is not specified. If the file + does not exist it is created. The general format for appending output is: [_n]>>>>_w_o_r_d RReeddiirreeccttiinngg SSttaannddaarrdd OOuuttppuutt aanndd SSttaannddaarrdd EErrrroorr - This construct allows both the standard output (file descriptor 1) and - the standard error output (file descriptor 2) to be redirected to the - file whose name is the expansion of _w_o_r_d. + This construct redirects both the standard output (file descriptor 1) + and the standard error output (file descriptor 2) to the file whose + name is the expansion of _w_o_r_d. - There are two formats for redirecting standard output and standard er- + There are two formats for redirecting standard output and standard er- ror: &&>>_w_o_r_d @@ -2314,9 +2581,9 @@ RREEDDIIRREECCTTIIOONN ssccrriippttoorrss below) for compatibility reasons. AAppppeennddiinngg SSttaannddaarrdd OOuuttppuutt aanndd SSttaannddaarrdd EErrrroorr - This construct allows both the standard output (file descriptor 1) and - the standard error output (file descriptor 2) to be appended to the - file whose name is the expansion of _w_o_r_d. + This construct appends both the standard output (file descriptor 1) and + the standard error output (file descriptor 2) to the file whose name is + the expansion of _w_o_r_d. The format for appending standard output and standard error is: @@ -2330,10 +2597,10 @@ RREEDDIIRREECCTTIIOONN HHeerree DDooccuummeennttss This type of redirection instructs the shell to read input from the - current source until a line containing only _d_e_l_i_m_i_t_e_r (with no trailing - blanks) is seen. All of the lines read up to that point are then used - as the standard input (or file descriptor _n if _n is specified) for a - command. + current source until it reads a line containing only _d_e_l_i_m_i_t_e_r (with no + trailing blanks). All of the lines read up to that point then become + the standard input (or file descriptor _n if _n is specified) for a com- + mand. The format of here-documents is: @@ -2341,28 +2608,37 @@ RREEDDIIRREECCTTIIOONN _h_e_r_e_-_d_o_c_u_m_e_n_t _d_e_l_i_m_i_t_e_r - No parameter and variable expansion, command substitution, arithmetic - expansion, or pathname expansion is performed on _w_o_r_d. If any part of - _w_o_r_d is quoted, the _d_e_l_i_m_i_t_e_r is the result of quote removal on _w_o_r_d, - and the lines in the here-document are not expanded. If _w_o_r_d is un- - quoted, all lines of the here-document are subjected to parameter ex- - pansion, command substitution, and arithmetic expansion, the character - sequence \\<> is ignored, and \\ must be used to quote the charac- - ters \\, $$, and ``. - - If the redirection operator is <<<<--, then all leading tab characters are - stripped from input lines and the line containing _d_e_l_i_m_i_t_e_r. This al- - lows here-documents within shell scripts to be indented in a natural - fashion. + The shell does not perform parameter and variable expansion, command + substitution, arithmetic expansion, or pathname expansion on _w_o_r_d. + + If any part of _w_o_r_d is quoted, the _d_e_l_i_m_i_t_e_r is the result of quote re- + moval on _w_o_r_d, and the lines in the here-document are not expanded. If + _w_o_r_d is unquoted, the _d_e_l_i_m_i_t_e_r is _w_o_r_d itself, and the here-document + text is treated similarly to a double-quoted string: all lines of the + here-document are subjected to parameter expansion, command substitu- + tion, and arithmetic expansion, the character sequence \\<> is + treated literally, and \\ must be used to quote the characters \\, $$, and + ``; however, double quote characters have no special meaning. + + If the redirection operator is <<<<--, then the shell strips all leading + tab characters from input lines and the line containing _d_e_l_i_m_i_t_e_r. + This allows here-documents within shell scripts to be indented in a + natural fashion. + + If the delimiter is not quoted, the \\<> sequence is treated as a + line continuation: the two lines are joined and the backslash-newline + is removed. This happens while reading the here-document, before the + check for the ending delimiter, so joined lines can form the end delim- + iter. HHeerree SSttrriinnggss A variant of here documents, the format is: [_n]<<<<<<_w_o_r_d - The _w_o_r_d undergoes tilde expansion, parameter and variable expansion, - command substitution, arithmetic expansion, and quote removal. Path- - name expansion and word splitting are not performed. The result is + The _w_o_r_d undergoes tilde expansion, parameter and variable expansion, + command substitution, arithmetic expansion, and quote removal. Path- + name expansion and word splitting are not performed. The result is supplied as a single string, with a newline appended, to the command on its standard input (or file descriptor _n if _n is specified). @@ -2372,30 +2648,30 @@ RREEDDIIRREECCTTIIOONN [_n]<<&&_w_o_r_d is used to duplicate input file descriptors. If _w_o_r_d expands to one or - more digits, the file descriptor denoted by _n is made to be a copy of - that file descriptor. If the digits in _w_o_r_d do not specify a file de- - scriptor open for input, a redirection error occurs. If _w_o_r_d evaluates - to --, file descriptor _n is closed. If _n is not specified, the standard - input (file descriptor 0) is used. + more digits, file descriptor _n is made to be a copy of that file de- + scriptor. It is a redirection error if the digits in _w_o_r_d do not spec- + ify a file descriptor open for input. If _w_o_r_d evaluates to --, file de- + scriptor _n is closed. If _n is not specified, this uses the standard + input (file descriptor 0). The operator [_n]>>&&_w_o_r_d - is used similarly to duplicate output file descriptors. If _n is not - specified, the standard output (file descriptor 1) is used. If the - digits in _w_o_r_d do not specify a file descriptor open for output, a re- - direction error occurs. If _w_o_r_d evaluates to --, file descriptor _n is - closed. As a special case, if _n is omitted, and _w_o_r_d does not expand - to one or more digits or --, the standard output and standard error are - redirected as described previously. + is used similarly to duplicate output file descriptors. If _n is not + specified, this uses the standard output (file descriptor 1). It is a + redirection error if the digits in _w_o_r_d do not specify a file descrip- + tor open for output. If _w_o_r_d evaluates to --, file descriptor _n is + closed. As a special case, if _n is omitted, and _w_o_r_d does not expand + to one or more digits or --, this redirects the standard output and + standard error as described previously. MMoovviinngg FFiillee DDeessccrriippttoorrss The redirection operator [_n]<<&&_d_i_g_i_t-- - moves the file descriptor _d_i_g_i_t to file descriptor _n, or the standard + moves the file descriptor _d_i_g_i_t to file descriptor _n, or the standard input (file descriptor 0) if _n is not specified. _d_i_g_i_t is closed after being duplicated to _n. @@ -2411,161 +2687,182 @@ RREEDDIIRREECCTTIIOONN [_n]<<>>_w_o_r_d - causes the file whose name is the expansion of _w_o_r_d to be opened for - both reading and writing on file descriptor _n, or on file descriptor 0 - if _n is not specified. If the file does not exist, it is created. + opens the file whose name is the expansion of _w_o_r_d for both reading and + writing on file descriptor _n, or on file descriptor 0 if _n is not spec- + ified. If the file does not exist, it is created. AALLIIAASSEESS - _A_l_i_a_s_e_s allow a string to be substituted for a word when it is used as - the first word of a simple command. The shell maintains a list of - aliases that may be set and unset with the aalliiaass and uunnaalliiaass builtin - commands (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). The first word of each - simple command, if unquoted, is checked to see if it has an alias. If - so, that word is replaced by the text of the alias. The characters //, - $$, ``, and == and any of the shell _m_e_t_a_c_h_a_r_a_c_t_e_r_s or quoting characters - listed above may not appear in an alias name. The replacement text may - contain any valid shell input, including shell metacharacters. The - first word of the replacement text is tested for aliases, but a word - that is identical to an alias being expanded is not expanded a second - time. This means that one may alias llss to llss --FF, for instance, and - bbaasshh does not try to recursively expand the replacement text. If the - last character of the alias value is a _b_l_a_n_k, then the next command - word following the alias is also checked for alias expansion. + _A_l_i_a_s_e_s allow a string to be substituted for a word that is in a posi- + tion in the input where it can be the first word of a simple command. + Aliases have names and corresponding values that are set and unset us- + ing the aalliiaass and uunnaalliiaass builtin commands (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS + below). + + If the shell reads an unquoted word in the right position, it checks + the word to see if it matches an alias name. If it matches, the shell + replaces the word with the alias value, and reads that value as if it + had been read instead of the word. The shell doesn't look at any char- + acters following the word before attempting alias substitution. + + The characters //, $$, ``, and == and any of the shell _m_e_t_a_c_h_a_r_a_c_t_e_r_s or + quoting characters listed above may not appear in an alias name. The + replacement text may contain any valid shell input, including shell + metacharacters. The first word of the replacement text is tested for + aliases, but a word that is identical to an alias being expanded is not + expanded a second time. This means that one may alias llss to llss --FF, for + instance, and bbaasshh does not try to recursively expand the replacement + text. + + If the last character of the alias value is a _b_l_a_n_k, the shell checks + the next command word following the alias for alias expansion. Aliases are created and listed with the aalliiaass command, and removed with the uunnaalliiaass command. There is no mechanism for using arguments in the replacement text. If - arguments are needed, use a shell function (see FFUUNNCCTTIIOONNSS below). + arguments are needed, use a shell function (see FFUUNNCCTTIIOONNSS below) in- + stead. - Aliases are not expanded when the shell is not interactive, unless the - eexxppaanndd__aalliiaasseess shell option is set using sshhoopptt (see the description of + Aliases are not expanded when the shell is not interactive, unless the + eexxppaanndd__aalliiaasseess shell option is set using sshhoopptt (see the description of sshhoopptt under SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). - The rules concerning the definition and use of aliases are somewhat - confusing. BBaasshh always reads at least one complete line of input, and - all lines that make up a compound command, before executing any of the - commands on that line or the compound command. Aliases are expanded - when a command is read, not when it is executed. Therefore, an alias - definition appearing on the same line as another command does not take - effect until the next line of input is read. The commands following - the alias definition on that line are not affected by the new alias. - This behavior is also an issue when functions are executed. Aliases - are expanded when a function definition is read, not when the function - is executed, because a function definition is itself a command. As a - consequence, aliases defined in a function are not available until af- - ter that function is executed. To be safe, always put alias defini- - tions on a separate line, and do not use aalliiaass in compound commands. - - For almost every purpose, aliases are superseded by shell functions. + The rules concerning the definition and use of aliases are somewhat + confusing. BBaasshh always reads at least one complete line of input, and + all lines that make up a compound command, before executing any of the + commands on that line or the compound command. Aliases are expanded + when a command is read, not when it is executed. Therefore, an alias + definition appearing on the same line as another command does not take + effect until the shell reads the next line of input, and an alias defi- + nition in a compound command does not take effect until the shell + parses and executes the entire compound command. The commands follow- + ing the alias definition on that line, or in the rest of a compound + command, are not affected by the new alias. This behavior is also an + issue when functions are executed. Aliases are expanded when a func- + tion definition is read, not when the function is executed, because a + function definition is itself a command. As a consequence, aliases de- + fined in a function are not available until after that function is exe- + cuted. To be safe, always put alias definitions on a separate line, + and do not use aalliiaass in compound commands. + + For almost every purpose, shell functions are preferable to aliases. FFUUNNCCTTIIOONNSS - A shell function, defined as described above under SSHHEELLLL GGRRAAMMMMAARR, - stores a series of commands for later execution. When the name of a - shell function is used as a simple command name, the list of commands - associated with that function name is executed. Functions are executed - in the context of the current shell; no new process is created to in- - terpret them (contrast this with the execution of a shell script). - When a function is executed, the arguments to the function become the + A shell function, defined as described above under SSHHEELLLL GGRRAAMMMMAARR, + stores a series of commands for later execution. When the name of a + shell function is used as a simple command name, the shell executes the + list of commands associated with that function name. Functions are ex- + ecuted in the context of the calling shell; there is no new process + created to interpret them (contrast this with the execution of a shell + script). + + When a function is executed, the arguments to the function become the positional parameters during its execution. The special parameter ## is - updated to reflect the change. Special parameter 00 is unchanged. The - first element of the FFUUNNCCNNAAMMEE variable is set to the name of the func- - tion while the function is executing. - - All other aspects of the shell execution environment are identical be- - tween a function and its caller with these exceptions: the DDEEBBUUGG and - RREETTUURRNN traps (see the description of the ttrraapp builtin under SSHHEELLLL - BBUUIILLTTIINN CCOOMMMMAANNDDSS below) are not inherited unless the function has been - given the ttrraaccee attribute (see the description of the ddeeccllaarree builtin - below) or the --oo ffuunnccttrraaccee shell option has been enabled with the sseett - builtin (in which case all functions inherit the DDEEBBUUGG and RREETTUURRNN - traps), and the EERRRR trap is not inherited unless the --oo eerrrrttrraaccee shell + updated to reflect the new positional parameters. Special parameter 00 + is unchanged. The first element of the FFUUNNCCNNAAMMEE variable is set to the + name of the function while the function is executing. + + All other aspects of the shell execution environment are identical be- + tween a function and its caller with these exceptions: the DDEEBBUUGG and + RREETTUURRNN traps (see the description of the ttrraapp builtin under SSHHEELLLL + BBUUIILLTTIINN CCOOMMMMAANNDDSS below) are not inherited unless the function has been + given the ttrraaccee attribute (see the description of the ddeeccllaarree builtin + below) or the --oo ffuunnccttrraaccee shell option has been enabled with the sseett + builtin (in which case all functions inherit the DDEEBBUUGG and RREETTUURRNN + traps), and the EERRRR trap is not inherited unless the --oo eerrrrttrraaccee shell option has been enabled. - Variables local to the function may be declared with the llooccaall builtin - command (_l_o_c_a_l _v_a_r_i_a_b_l_e_s). Ordinarily, variables and their values are - shared between the function and its caller. If a variable is declared - llooccaall, the variable's visible scope is restricted to that function and + Variables local to the function are declared with the llooccaall builtin + command (_l_o_c_a_l _v_a_r_i_a_b_l_e_s). Ordinarily, variables and their values are + shared between the function and its caller. If a variable is declared + llooccaall, the variable's visible scope is restricted to that function and its children (including the functions it calls). In the following description, the _c_u_r_r_e_n_t _s_c_o_p_e is a currently- execut- ing function. Previous scopes consist of that function's caller and so - on, back to the "global" scope, where the shell is not executing any - shell function. Consequently, a local variable at the current scope is - a variable declared using the llooccaall or ddeeccllaarree builtins in the function - that is currently executing. - - Local variables "shadow" variables with the same name declared at pre- - vious scopes. For instance, a local variable declared in a function - hides a global variable of the same name: references and assignments - refer to the local variable, leaving the global variable unmodified. - When the function returns, the global variable is once again visible. - - The shell uses _d_y_n_a_m_i_c _s_c_o_p_i_n_g to control a variable's visibility - within functions. With dynamic scoping, visible variables and their - values are a result of the sequence of function calls that caused exe- - cution to reach the current function. The value of a variable that a - function sees depends on its value within its caller, if any, whether - that caller is the "global" scope or another shell function. This is - also the value that a local variable declaration "shadows", and the - value that is restored when the function returns. + on, back to the "global" scope, where the shell is not executing any + shell function. A local variable at the current scope is a variable + declared using the llooccaall or ddeeccllaarree builtins in the function that is + currently executing. + + Local variables "shadow" variables with the same name declared at pre- + vious scopes. For instance, a local variable declared in a function + hides variables with the same name declared at previous scopes, includ- + ing global variables: references and assignments refer to the local + variable, leaving the variables at previous scopes unmodified. When + the function returns, the global variable is once again visible. + + The shell uses _d_y_n_a_m_i_c _s_c_o_p_i_n_g to control a variable's visibility + within functions. With dynamic scoping, visible variables and their + values are a result of the sequence of function calls that caused exe- + cution to reach the current function. The value of a variable that a + function sees depends on its value within its caller, if any, whether + that caller is the global scope or another shell function. This is + also the value that a local variable declaration shadows, and the value + that is restored when the function returns. For example, if a variable _v_a_r is declared as local in function _f_u_n_c_1, and _f_u_n_c_1 calls another function _f_u_n_c_2, references to _v_a_r made from - within _f_u_n_c_2 will resolve to the local variable _v_a_r from _f_u_n_c_1, shadow- - ing any global variable named _v_a_r. + within _f_u_n_c_2 resolve to the local variable _v_a_r from _f_u_n_c_1, shadowing + any global variable named _v_a_r. The uunnsseett builtin also acts using the same dynamic scope: if a variable - is local to the current scope, uunnsseett will unset it; otherwise the unset - will refer to the variable found in any calling scope as described - above. If a variable at the current local scope is unset, it will re- - main so (appearing as unset) until it is reset in that scope or until - the function returns. Once the function returns, any instance of the - variable at a previous scope will become visible. If the unset acts on - a variable at a previous scope, any instance of a variable with that - name that had been shadowed will become visible (see below how the lloo-- - ccaallvvaarr__uunnsseett shell option changes this behavior). - - The FFUUNNCCNNEESSTT variable, if set to a numeric value greater than 0, de- - fines a maximum function nesting level. Function invocations that ex- + is local to the current scope, uunnsseett unsets it; otherwise the unset + will refer to the variable found in any calling scope as described + above. If a variable at the current local scope is unset, it remains + so (appearing as unset) until it is reset in that scope or until the + function returns. Once the function returns, any instance of the vari- + able at a previous scope becomes visible. If the unset acts on a vari- + able at a previous scope, any instance of a variable with that name + that had been shadowed becomes visible (see below how the llooccaallvvaarr__uunn-- + sseett shell option changes this behavior). + + The FFUUNNCCNNEESSTT variable, if set to a numeric value greater than 0, de- + fines a maximum function nesting level. Function invocations that ex- ceed the limit cause the entire command to abort. - If the builtin command rreettuurrnn is executed in a function, the function - completes and execution resumes with the next command after the func- - tion call. Any command associated with the RREETTUURRNN trap is executed be- - fore execution resumes. When a function completes, the values of the - positional parameters and the special parameter ## are restored to the - values they had prior to the function's execution. - - Function names and definitions may be listed with the --ff option to the - ddeeccllaarree or ttyyppeesseett builtin commands. The --FF option to ddeeccllaarree or ttyyppee-- - sseett will list the function names only (and optionally the source file - and line number, if the eexxttddeebbuugg shell option is enabled). Functions - may be exported so that child shell processes (those created when exe- - cuting a separate shell invocation) automatically have them defined - with the --ff option to the eexxppoorrtt builtin. A function definition may be - deleted using the --ff option to the uunnsseett builtin. + If the builtin command rreettuurrnn is executed in a function, the function + completes and execution resumes with the next command after the func- + tion call. If rreettuurrnn is supplied a numeric argument, that is the func- + tion's return status; otherwise the function's return status is the + exit status of the last command executed before the rreettuurrnn. Any com- + mand associated with the RREETTUURRNN trap is executed before execution re- + sumes. When a function completes, the values of the positional parame- + ters and the special parameter ## are restored to the values they had + prior to the function's execution. + + The --ff option to the ddeeccllaarree or ttyyppeesseett builtin commands lists function + names and definitions. The --FF option to ddeeccllaarree or ttyyppeesseett lists the + function names only (and optionally the source file and line number, if + the eexxttddeebbuugg shell option is enabled). Functions may be exported so + that child shell processes (those created when executing a separate + shell invocation) automatically have them defined with the --ff option to + the eexxppoorrtt builtin. The --ff option to the uunnsseett builtin deletes a func- + tion definition. Functions may be recursive. The FFUUNNCCNNEESSTT variable may be used to limit - the depth of the function call stack and restrict the number of func- - tion invocations. By default, no limit is imposed on the number of re- - cursive calls. + the depth of the function call stack and restrict the number of func- + tion invocations. By default, bbaasshh imposes no limit on the number of + recursive calls. AARRIITTHHMMEETTIICC EEVVAALLUUAATTIIOONN - The shell allows arithmetic expressions to be evaluated, under certain - circumstances (see the lleett and ddeeccllaarree builtin commands, the (((( com- - pound command, and AArriitthhmmeettiicc EExxppaannssiioonn). Evaluation is done in fixed- - width integers with no check for overflow, though division by 0 is - trapped and flagged as an error. The operators and their precedence, - associativity, and values are the same as in the C language. The fol- - lowing list of operators is grouped into levels of equal-precedence op- - erators. The levels are listed in order of decreasing precedence. + The shell allows arithmetic expressions to be evaluated, under certain + circumstances (see the lleett and ddeeccllaarree builtin commands, the (((( com- + pound command, the arithmetic ffoorr command, the [[[[ conditional command, + and AArriitthhmmeettiicc EExxppaannssiioonn). + + Evaluation is done in the largest fixed-width integers available, with + no check for overflow, though division by 0 is trapped and flagged as + an error. The operators and their precedence, associativity, and val- + ues are the same as in the C language. The following list of operators + is grouped into levels of equal-precedence operators. The levels are + listed in order of decreasing precedence. _i_d++++ _i_d---- variable post-increment and post-decrement - -- ++ unary minus and plus ++++_i_d ----_i_d variable pre-increment and pre-decrement + -- ++ unary minus and plus !! ~~ logical and bitwise negation **** exponentiation ** // %% multiplication, division, remainder @@ -2586,13 +2883,16 @@ AARRIITTHHMMEETTIICC EEVVAALLUUAATTIIOONN _e_x_p_r_1 ,, _e_x_p_r_2 comma - Shell variables are allowed as operands; parameter expansion is per- + Shell variables are allowed as operands; parameter expansion is per- formed before the expression is evaluated. Within an expression, shell variables may also be referenced by name without using the parameter - expansion syntax. A shell variable that is null or unset evaluates to - 0 when referenced by name without using the parameter expansion syntax. - The value of a variable is evaluated as an arithmetic expression when - it is referenced, or when a variable which has been given the _i_n_t_e_g_e_r + expansion syntax. This means you can use "x", where _x is a shell vari- + able name, in an arithmetic expression, and the shell will evaluate its + value as an expression and use the result. A shell variable that is + null or unset evaluates to 0 when referenced by name in an expression. + + The value of a variable is evaluated as an arithmetic expression when + it is referenced, or when a variable which has been given the _i_n_t_e_g_e_r attribute using ddeeccllaarree --ii is assigned a value. A null value evaluates to 0. A shell variable need not have its _i_n_t_e_g_e_r attribute turned on to be used in an expression. @@ -2604,38 +2904,43 @@ AARRIITTHHMMEETTIICC EEVVAALLUUAATTIIOONN ber between 2 and 64 representing the arithmetic base, and _n is a num- ber in that base. If _b_a_s_e_# is omitted, then base 10 is used. When specifying _n, if a non-digit is required, the digits greater than 9 are - represented by the lowercase letters, the uppercase letters, @, and _, - in that order. If _b_a_s_e is less than or equal to 36, lowercase and up- - percase letters may be used interchangeably to represent numbers be- + represented by the lowercase letters, the uppercase letters, @, and _, + in that order. If _b_a_s_e is less than or equal to 36, lowercase and up- + percase letters may be used interchangeably to represent numbers be- tween 10 and 35. - Operators are evaluated in order of precedence. Sub-expressions in - parentheses are evaluated first and may override the precedence rules - above. + Operators are evaluated in precedence order. Sub-expressions in paren- + theses are evaluated first and may override the precedence rules above. CCOONNDDIITTIIOONNAALL EEXXPPRREESSSSIIOONNSS - Conditional expressions are used by the [[[[ compound command and the - tteesstt and [[ builtin commands to test file attributes and perform string - and arithmetic comparisons. The tteesstt and [[ commands determine their - behavior based on the number of arguments; see the descriptions of + Conditional expressions are used by the [[[[ compound command and the + tteesstt and [[ builtin commands to test file attributes and perform string + and arithmetic comparisons. The tteesstt and [[ commands determine their + behavior based on the number of arguments; see the descriptions of those commands for any other command-specific actions. - Expressions are formed from the following unary or binary primaries. + Expressions are formed from the unary or binary primaries listed below. + Unary expressions are often used to examine the status of a file or + shell variable. Binary operators are used for string, numeric, and + file attribute comparisons. + BBaasshh handles several filenames specially when they are used in expres- sions. If the operating system on which bbaasshh is running provides these - special files, bash will use them; otherwise it will emulate them in- - ternally with this behavior: If any _f_i_l_e argument to one of the pri- - maries is of the form _/_d_e_v_/_f_d_/_n, then file descriptor _n is checked. If - the _f_i_l_e argument to one of the primaries is one of _/_d_e_v_/_s_t_d_i_n, - _/_d_e_v_/_s_t_d_o_u_t, or _/_d_e_v_/_s_t_d_e_r_r, file descriptor 0, 1, or 2, respectively, - is checked. + special files, bash will use them; otherwise it will emulate them in- + ternally with this behavior: If any _f_i_l_e argument to one of the pri- + maries is of the form _/_d_e_v_/_f_d_/_n, then bbaasshh checks file descriptor _n. + If the _f_i_l_e argument to one of the primaries is one of _/_d_e_v_/_s_t_d_i_n, + _/_d_e_v_/_s_t_d_o_u_t, or _/_d_e_v_/_s_t_d_e_r_r, bbaasshh checks file descriptor 0, 1, or 2, + respectively. Unless otherwise specified, primaries that operate on files follow sym- bolic links and operate on the target of the link, rather than the link itself. - When used with [[[[, the << and >> operators sort lexicographically using - the current locale. The tteesstt command sorts using ASCII ordering. + When used with [[[[, or when the shell is in posix mode, the << and >> op- + erators sort lexicographically using the current locale. When the + shell is not in posix mode, the tteesstt command sorts using ASCII order- + ing. --aa _f_i_l_e True if _f_i_l_e exists. @@ -2654,7 +2959,7 @@ CCOONNDDIITTIIOONNAALL EEXXPPRREESSSSIIOONNSS --hh _f_i_l_e True if _f_i_l_e exists and is a symbolic link. --kk _f_i_l_e - True if _f_i_l_e exists and its ``sticky'' bit is set. + True if _f_i_l_e exists and its "sticky" bit is set. --pp _f_i_l_e True if _f_i_l_e exists and is a named pipe (FIFO). --rr _f_i_l_e @@ -2673,30 +2978,25 @@ CCOONNDDIITTIIOONNAALL EEXXPPRREESSSSIIOONNSS --LL _f_i_l_e True if _f_i_l_e exists and is a symbolic link. --NN _f_i_l_e - True if _f_i_l_e exists and has been modified since it was last - read. + True if _f_i_l_e exists and has been modified since it was last ac- + cessed. --OO _f_i_l_e True if _f_i_l_e exists and is owned by the effective user id. --SS _f_i_l_e True if _f_i_l_e exists and is a socket. - _f_i_l_e_1 --eeff _f_i_l_e_2 - True if _f_i_l_e_1 and _f_i_l_e_2 refer to the same device and inode num- - bers. - _f_i_l_e_1 -nntt _f_i_l_e_2 - True if _f_i_l_e_1 is newer (according to modification date) than - _f_i_l_e_2, or if _f_i_l_e_1 exists and _f_i_l_e_2 does not. - _f_i_l_e_1 -oott _f_i_l_e_2 - True if _f_i_l_e_1 is older than _f_i_l_e_2, or if _f_i_l_e_2 exists and _f_i_l_e_1 - does not. --oo _o_p_t_n_a_m_e True if the shell option _o_p_t_n_a_m_e is enabled. See the list of options under the description of the --oo option to the sseett builtin below. --vv _v_a_r_n_a_m_e True if the shell variable _v_a_r_n_a_m_e is set (has been assigned a - value). + value). If _v_a_r_n_a_m_e is an indexed array variable name sub- + scripted by _@ or _*, this returns true if the array has any set + elements. If _v_a_r_n_a_m_e is an associative array variable name sub- + scripted by _@ or _*, this returns true if an element with that + key is set. --RR _v_a_r_n_a_m_e - True if the shell variable _v_a_r_n_a_m_e is set and is a name refer- + True if the shell variable _v_a_r_n_a_m_e is set and is a name refer- ence. --zz _s_t_r_i_n_g True if the length of _s_t_r_i_n_g is zero. @@ -2706,48 +3006,58 @@ CCOONNDDIITTIIOONNAALL EEXXPPRREESSSSIIOONNSS _s_t_r_i_n_g_1 ==== _s_t_r_i_n_g_2 _s_t_r_i_n_g_1 == _s_t_r_i_n_g_2 - True if the strings are equal. == should be used with the tteesstt - command for POSIX conformance. When used with the [[[[ command, + True if the strings are equal. == should be used with the tteesstt + command for POSIX conformance. When used with the [[[[ command, this performs pattern matching as described above (CCoommppoouunndd CCoomm-- mmaannddss). - _s_t_r_i_n_g_1 !!== _s_t_r_i_n_g_2 True if the strings are not equal. - _s_t_r_i_n_g_1 << _s_t_r_i_n_g_2 True if _s_t_r_i_n_g_1 sorts before _s_t_r_i_n_g_2 lexicographically. - _s_t_r_i_n_g_1 >> _s_t_r_i_n_g_2 True if _s_t_r_i_n_g_1 sorts after _s_t_r_i_n_g_2 lexicographically. + _f_i_l_e_1 --eeff _f_i_l_e_2 + True if _f_i_l_e_1 and _f_i_l_e_2 refer to the same device and inode num- + bers. + _f_i_l_e_1 -nntt _f_i_l_e_2 + True if _f_i_l_e_1 is newer (according to modification date) than + _f_i_l_e_2, or if _f_i_l_e_1 exists and _f_i_l_e_2 does not. + _f_i_l_e_1 -oott _f_i_l_e_2 + True if _f_i_l_e_1 is older than _f_i_l_e_2, or if _f_i_l_e_2 exists and _f_i_l_e_1 + does not. + _a_r_g_1 OOPP _a_r_g_2 - OOPP is one of --eeqq, --nnee, --lltt, --llee, --ggtt, or --ggee. These arithmetic - binary operators return true if _a_r_g_1 is equal to, not equal to, - less than, less than or equal to, greater than, or greater than - or equal to _a_r_g_2, respectively. _A_r_g_1 and _a_r_g_2 may be positive - or negative integers. When used with the [[[[ command, _A_r_g_1 and - _A_r_g_2 are evaluated as arithmetic expressions (see AARRIITTHHMMEETTIICC - EEVVAALLUUAATTIIOONN above). + OOPP is one of --eeqq, --nnee, --lltt, --llee, --ggtt, or --ggee. These arithmetic + binary operators return true if _a_r_g_1 is equal to, not equal to, + less than, less than or equal to, greater than, or greater than + or equal to _a_r_g_2, respectively. _a_r_g_1 and _a_r_g_2 may be positive + or negative integers. When used with the [[[[ command, _a_r_g_1 and + _a_r_g_2 are evaluated as arithmetic expressions (see AARRIITTHHMMEETTIICC + EEVVAALLUUAATTIIOONN above). Since the expansions the [[[[ command performs + on _a_r_g_1 and _a_r_g_2 can potentially result in empty strings, arith- + metic expression evaluation treats those as expressions that + evaluate to 0. SSIIMMPPLLEE CCOOMMMMAANNDD EEXXPPAANNSSIIOONN - When a simple command is executed, the shell performs the following ex- - pansions, assignments, and redirections, from left to right, in the + When the shell executes a simple command, it performs the following ex- + pansions, assignments, and redirections, from left to right, in the following order. - 1. The words that the parser has marked as variable assignments - (those preceding the command name) and redirections are saved + 1. The words that the parser has marked as variable assignments + (those preceding the command name) and redirections are saved for later processing. - 2. The words that are not variable assignments or redirections are - expanded. If any words remain after expansion, the first word - is taken to be the name of the command and the remaining words + 2. The words that are not variable assignments or redirections are + expanded. If any words remain after expansion, the first word + is taken to be the name of the command and the remaining words are the arguments. 3. Redirections are performed as described above under RREEDDIIRREECCTTIIOONN. 4. The text after the == in each variable assignment undergoes tilde expansion, parameter expansion, command substitution, arithmetic - expansion, and quote removal before being assigned to the vari- + expansion, and quote removal before being assigned to the vari- able. If no command name results, the variable assignments affect the current @@ -2756,24 +3066,24 @@ SSIIMMPPLLEE CCOOMMMMAANNDD EEXXPPAANNSSIIOONN are performed before redirections. Otherwise, the variables are added to the environment of the executed command and do not affect the cur- rent shell environment. If any of the assignments attempts to assign a - value to a readonly variable, an error occurs, and the command exits + value to a readonly variable, an error occurs, and the command exits with a non-zero status. - If no command name results, redirections are performed, but do not af- - fect the current shell environment. A redirection error causes the + If no command name results, redirections are performed, but do not af- + fect the current shell environment. A redirection error causes the command to exit with a non-zero status. - If there is a command name left after expansion, execution proceeds as - described below. Otherwise, the command exits. If one of the expan- - sions contained a command substitution, the exit status of the command - is the exit status of the last command substitution performed. If - there were no command substitutions, the command exits with a status of - zero. + If there is a command name left after expansion, execution proceeds as + described below. Otherwise, the command exits. If one of the expan- + sions contained a command substitution, the exit status of the command + is the exit status of the last command substitution performed. If + there were no command substitutions, the command exits with a zero sta- + tus. CCOOMMMMAANNDD EEXXEECCUUTTIIOONN After a command has been split into words, if it results in a simple - command and an optional list of arguments, the following actions are - taken. + command and an optional list of arguments, the shell performs the fol- + lowing actions. If the command name contains no slashes, the shell attempts to locate it. If there exists a shell function by that name, that function is @@ -2784,16 +3094,16 @@ CCOOMMMMAANNDD EEXXEECCUUTTIIOONN If the name is neither a shell function nor a builtin, and contains no slashes, bbaasshh searches each element of the PPAATTHH for a directory con- taining an executable file by that name. BBaasshh uses a hash table to re- - member the full pathnames of executable files (see hhaasshh under SSHHEELLLL - BBUUIILLTTIINN CCOOMMMMAANNDDSS below). A full search of the directories in PPAATTHH is - performed only if the command is not found in the hash table. If the - search is unsuccessful, the shell searches for a defined shell function - named ccoommmmaanndd__nnoott__ffoouunndd__hhaannddllee. If that function exists, it is invoked - in a separate execution environment with the original command and the - original command's arguments as its arguments, and the function's exit - status becomes the exit status of that subshell. If that function is - not defined, the shell prints an error message and returns an exit sta- - tus of 127. + member the full pathnames of executable files (see hhaasshh under SSHHEELLLL + BBUUIILLTTIINN CCOOMMMMAANNDDSS below). Bash performs a full search of the directo- + ries in PPAATTHH only if the command is not found in the hash table. If + the search is unsuccessful, the shell searches for a defined shell + function named ccoommmmaanndd__nnoott__ffoouunndd__hhaannddllee. If that function exists, it + is invoked in a separate execution environment with the original com- + mand and the original command's arguments as its arguments, and the + function's exit status becomes the exit status of that subshell. If + that function is not defined, the shell prints an error message and re- + turns an exit status of 127. If the search is successful, or if the command name contains one or more slashes, the shell executes the named program in a separate execu- @@ -2803,88 +3113,92 @@ CCOOMMMMAANNDD EEXXEECCUUTTIIOONN If this execution fails because the file is not in executable format, and the file is not a directory, it is assumed to be a _s_h_e_l_l _s_c_r_i_p_t, a file containing shell commands, and the shell creates a new instance of - itself to execute it. This subshell reinitializes itself, so that the - effect is as if a new shell had been invoked to handle the script, with - the exception that the locations of commands remembered by the parent - (see hhaasshh below under SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS) are retained by the - child. - - If the program is a file beginning with ##!!, the remainder of the first - line specifies an interpreter for the program. The shell executes the + itself to execute it. Bash tries to determine whether the file is a + text file or a binary, and will not execute files it determines to be + binaries. This subshell reinitializes itself, so that the effect is as + if a new shell had been invoked to handle the script, with the excep- + tion that the locations of commands remembered by the parent (see hhaasshh + below under SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS are retained by the child. + + If the program is a file beginning with ##!!, the remainder of the first + line specifies an interpreter for the program. The shell executes the specified interpreter on operating systems that do not handle this exe- cutable format themselves. The arguments to the interpreter consist of - a single optional argument following the interpreter name on the first - line of the program, followed by the name of the program, followed by + a single optional argument following the interpreter name on the first + line of the program, followed by the name of the program, followed by the command arguments, if any. CCOOMMMMAANNDD EEXXEECCUUTTIIOONN EENNVVIIRROONNMMEENNTT - The shell has an _e_x_e_c_u_t_i_o_n _e_n_v_i_r_o_n_m_e_n_t, which consists of the follow- + The shell has an _e_x_e_c_u_t_i_o_n _e_n_v_i_r_o_n_m_e_n_t, which consists of the follow- ing: - +o open files inherited by the shell at invocation, as modified by - redirections supplied to the eexxeecc builtin + +o Open files inherited by the shell at invocation, as modified by + redirections supplied to the eexxeecc builtin. - +o the current working directory as set by ccdd, ppuusshhdd, or ppooppdd, or - inherited by the shell at invocation + +o The current working directory as set by ccdd, ppuusshhdd, or ppooppdd, or + inherited by the shell at invocation. - +o the file creation mode mask as set by uummaasskk or inherited from - the shell's parent + +o The file creation mode mask as set by uummaasskk or inherited from + the shell's parent. - +o current traps set by ttrraapp + +o Current traps set by ttrraapp. - +o shell parameters that are set by variable assignment or with sseett - or inherited from the shell's parent in the environment + +o Shell parameters that are set by variable assignment or with sseett + or inherited from the shell's parent in the environment. - +o shell functions defined during execution or inherited from the - shell's parent in the environment + +o Shell functions defined during execution or inherited from the + shell's parent in the environment. - +o options enabled at invocation (either by default or with com- - mand-line arguments) or by sseett + +o Options enabled at invocation (either by default or with com- + mand-line arguments) or by sseett. - +o options enabled by sshhoopptt + +o Options enabled by sshhoopptt. - +o shell aliases defined with aalliiaass + +o Shell aliases defined with aalliiaass. - +o various process IDs, including those of background jobs, the - value of $$$$, and the value of PPPPIIDD + +o Various process IDs, including those of background jobs, the + value of $$$$, and the value of PPPPIIDD. When a simple command other than a builtin or shell function is to be executed, it is invoked in a separate execution environment that con- sists of the following. Unless otherwise noted, the values are inher- ited from the shell. + +o The shell's open files, plus any modifications and additions + specified by redirections to the command. - +o the shell's open files, plus any modifications and additions - specified by redirections to the command - - +o the current working directory + +o The current working directory. - +o the file creation mode mask + +o The file creation mode mask. - +o shell variables and functions marked for export, along with - variables exported for the command, passed in the environment + +o Shell variables and functions marked for export, along with + variables exported for the command, passed in the environment. - +o traps caught by the shell are reset to the values inherited from - the shell's parent, and traps ignored by the shell are ignored + +o Traps caught by the shell are reset to the values inherited from + the shell's parent, and traps ignored by the shell are ignored. - A command invoked in this separate environment cannot affect the + A command invoked in this separate environment cannot affect the shell's execution environment. A _s_u_b_s_h_e_l_l is a copy of the shell process. - Command substitution, commands grouped with parentheses, and asynchro- + Command substitution, commands grouped with parentheses, and asynchro- nous commands are invoked in a subshell environment that is a duplicate of the shell environment, except that traps caught by the shell are re- - set to the values that the shell inherited from its parent at invoca- - tion. Builtin commands that are invoked as part of a pipeline are also - executed in a subshell environment. Changes made to the subshell envi- - ronment cannot affect the shell's execution environment. - - Subshells spawned to execute command substitutions inherit the value of - the --ee option from the parent shell. When not in _p_o_s_i_x _m_o_d_e, bbaasshh - clears the --ee option in such subshells. - - If a command is followed by a && and job control is not active, the de- + set to the values that the shell inherited from its parent at invoca- + tion. Builtin commands that are invoked as part of a pipeline, except + possibly in the last element depending on the value of the llaassttppiippee + shell option, are also executed in a subshell environment. Changes + made to the subshell environment cannot affect the shell's execution + environment. + + When the shell is in posix mode, subshells spawned to execute command + substitutions inherit the value of the --ee option from their parent + shell. When not in posix mode, bbaasshh clears the --ee option in such sub- + shells. See the description of the iinnhheerriitt__eerrrreexxiitt shell option below + for how to control this behavior when not in posix mode. + + If a command is followed by a && and job control is not active, the de- fault standard input for the command is the empty file _/_d_e_v_/_n_u_l_l. Oth- erwise, the invoked command inherits the file descriptors of the call- ing shell as modified by redirections. @@ -2896,31 +3210,34 @@ EENNVVIIRROONNMMEENNTT The shell provides several ways to manipulate the environment. On in- vocation, the shell scans its own environment and creates a parameter - for each name found, automatically marking it for _e_x_p_o_r_t to child pro- - cesses. Executed commands inherit the environment. The eexxppoorrtt and ddee-- - ccllaarree --xx commands allow parameters and functions to be added to and - deleted from the environment. If the value of a parameter in the envi- - ronment is modified, the new value becomes part of the environment, re- - placing the old. The environment inherited by any executed command - consists of the shell's initial environment, whose values may be modi- - fied in the shell, less any pairs removed by the uunnsseett command, plus - any additions via the eexxppoorrtt and ddeeccllaarree --xx commands. - - The environment for any _s_i_m_p_l_e _c_o_m_m_a_n_d or function may be augmented - temporarily by prefixing it with parameter assignments, as described - above in PPAARRAAMMEETTEERRSS. These assignment statements affect only the envi- - ronment seen by that command. + for each name found, automatically marking it for _e_x_p_o_r_t to child + processes. Executed commands inherit the environment. The eexxppoorrtt, ddee-- + ccllaarree --xx, and uunnsseett commands modify the environment by adding and + deleting parameters and functions. If the value of a parameter in the + environment is modified, the new value automatically becomes part of + the environment, replacing the old. The environment inherited by any + executed command consists of the shell's initial environment, whose + values may be modified in the shell, less any pairs removed by the uunn-- + sseett or eexxppoorrtt --nn commands, plus any additions via the eexxppoorrtt and ddee-- + ccllaarree --xx commands. + + If any parameter assignments, as described above in PPAARRAAMMEETTEERRSS, appear + before a _s_i_m_p_l_e _c_o_m_m_a_n_d, the variable assignments are part of that com- + mand's environment for as long as it executes. These assignment state- + ments affect only the environment seen by that command. If these as- + signments precede a call to a shell function, the variables are local + to the function and exported to that function's children. If the --kk option is set (see the sseett builtin command below), then _a_l_l parameter assignments are placed in the environment for a command, not just those that precede the command name. When bbaasshh invokes an external command, the variable __ is set to the - full filename of the command and passed to that command in its environ- + full pathname of the command and passed to that command in its environ- ment. EEXXIITT SSTTAATTUUSS - The exit status of an executed command is the value returned by the + The exit status of an executed command is the value returned by the _w_a_i_t_p_i_d system call or equivalent function. Exit statuses fall between 0 and 255, though, as explained below, the shell may use values above 125 specially. Exit statuses from shell builtins and compound commands @@ -2928,12 +3245,14 @@ EEXXIITT SSTTAATTUUSS will use special values to indicate specific failure modes. For the shell's purposes, a command which exits with a zero exit status - has succeeded. An exit status of zero indicates success. A non-zero - exit status indicates failure. When a command terminates on a fatal - signal _N, bbaasshh uses the value of 128+_N as the exit status. + has succeeded. So while an exit status of zero indicates success, a + non-zero exit status indicates failure. + + When a command terminates on a fatal signal _N, bbaasshh uses the value of + 128+_N as the exit status. - If a command is not found, the child process created to execute it re- - turns a status of 127. If a command is found but is not executable, + If a command is not found, the child process created to execute it re- + turns a status of 127. If a command is found but is not executable, the return status is 126. If a command fails because of an error during expansion or redirection, @@ -2947,148 +3266,192 @@ EEXXIITT SSTTAATTUUSS The exit status of the last command is available in the special parame- ter $?. - BBaasshh itself returns the exit status of the last command executed, un- - less a syntax error occurs, in which case it exits with a non-zero + BBaasshh itself returns the exit status of the last command executed, un- + less a syntax error occurs, in which case it exits with a non-zero value. See also the eexxiitt builtin command below. SSIIGGNNAALLSS - When bbaasshh is interactive, in the absence of any traps, it ignores - SSIIGGTTEERRMM (so that kkiillll 00 does not kill an interactive shell), and SSIIGGIINNTT - is caught and handled (so that the wwaaiitt builtin is interruptible). In + When bbaasshh is interactive, in the absence of any traps, it ignores + SSIIGGTTEERRMM (so that kkiillll 00 does not kill an interactive shell), and + catches and handles SSIIGGIINNTT (so that the wwaaiitt builtin is interruptible). + When bbaasshh receives SSIIGGIINNTT, it breaks out of any executing loops. In all cases, bbaasshh ignores SSIIGGQQUUIITT. If job control is in effect, bbaasshh ig- nores SSIIGGTTTTIINN, SSIIGGTTTTOOUU, and SSIIGGTTSSTTPP. - Non-builtin commands run by bbaasshh have signal handlers set to the values - inherited by the shell from its parent. When job control is not in ef- - fect, asynchronous commands ignore SSIIGGIINNTT and SSIIGGQQUUIITT in addition to - these inherited handlers. Commands run as a result of command substi- - tution ignore the keyboard-generated job control signals SSIIGGTTTTIINN, SSIIGGTT-- - TTOOUU, and SSIIGGTTSSTTPP. + The ttrraapp builtin modifies the shell's signal handling, as described be- + low. + + Non-builtin commands bbaasshh executes have signal handlers set to the val- + ues inherited by the shell from its parent, unless ttrraapp sets them to be + ignored, in which case the child process will ignore them as well. + When job control is not in effect, asynchronous commands ignore SSIIGGIINNTT + and SSIIGGQQUUIITT in addition to these inherited handlers. Commands run as a + result of command substitution ignore the keyboard-generated job con- + trol signals SSIIGGTTTTIINN, SSIIGGTTTTOOUU, and SSIIGGTTSSTTPP. The shell exits by default upon receipt of a SSIIGGHHUUPP. Before exiting, an interactive shell resends the SSIIGGHHUUPP to all jobs, running or - stopped. Stopped jobs are sent SSIIGGCCOONNTT to ensure that they receive the - SSIIGGHHUUPP. To prevent the shell from sending the signal to a particular - job, it should be removed from the jobs table with the ddiissoowwnn builtin - (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below) or marked to not receive SSIIGGHHUUPP us- - ing ddiissoowwnn --hh. - - If the hhuuppoonneexxiitt shell option has been set with sshhoopptt, bbaasshh sends a + stopped. The shell sends SSIIGGCCOONNTT to stopped jobs to ensure that they + receive the SSIIGGHHUUPP (see JJOOBB CCOONNTTRROOLL below for more information about + running and stopped jobs). To prevent the shell from sending the sig- + nal to a particular job, remove it from the jobs table with the ddiissoowwnn + builtin (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below) or mark it not to receive + SSIIGGHHUUPP using ddiissoowwnn --hh. + + If the hhuuppoonneexxiitt shell option has been set using sshhoopptt, bbaasshh sends a SSIIGGHHUUPP to all jobs when an interactive login shell exits. - If bbaasshh is waiting for a command to complete and receives a signal for - which a trap has been set, the trap will not be executed until the com- - mand completes. When bbaasshh is waiting for an asynchronous command via - the wwaaiitt builtin, the reception of a signal for which a trap has been - set will cause the wwaaiitt builtin to return immediately with an exit sta- - tus greater than 128, immediately after which the trap is executed. + If bbaasshh is waiting for a command to complete and receives a signal for + which a trap has been set, it will not execute the trap until the com- + mand completes. If bbaasshh is waiting for an asynchronous command via the + wwaaiitt builtin, and it receives a signal for which a trap has been set, + the wwaaiitt builtin will return immediately with an exit status greater + than 128, immediately after which the shell executes the trap. When job control is not enabled, and bbaasshh is waiting for a foreground command to complete, the shell receives keyboard-generated signals such - as SSIIGGIINNTT (usually generated by ^^CC) that users commonly intend to send + as SSIIGGIINNTT (usually generated by ^^CC) that users commonly intend to send to that command. This happens because the shell and the command are in - the same process group as the terminal, and ^^CC sends SSIIGGIINNTT to all pro- - cesses in that process group. - - When bbaasshh is running without job control enabled and receives SSIIGGIINNTT - while waiting for a foreground command, it waits until that foreground - command terminates and then decides what to do about the SSIIGGIINNTT: + the same process group as the terminal, and ^^CC sends SSIIGGIINNTT to all + processes in that process group. Since bbaasshh does not enable job con- + trol by default when the shell is not interactive, this scenario is + most common in non-interactive shells. + + When job control is enabled, and bbaasshh is waiting for a foreground com- + mand to complete, the shell does not receive keyboard-generated sig- + nals, because it is not in the same process group as the terminal. + This scenario is most common in interactive shells, where bbaasshh attempts + to enable job control by default. See JJOOBB CCOONNTTRROOLL below for more in- + formation about process groups. + + When job control is not enabled, and bbaasshh receives SSIIGGIINNTT while waiting + for a foreground command, it waits until that foreground command termi- + nates and then decides what to do about the SSIIGGIINNTT: 1. If the command terminates due to the SSIIGGIINNTT, bbaasshh concludes that - the user meant to end the entire script, and acts on the SSIIGGIINNTT - (e.g., by running a SSIIGGIINNTT trap or exiting itself); - - 2. If the command does not terminate due to SSIIGGIINNTT, the program - handled the SSIIGGIINNTT itself and did not treat it as a fatal sig- - nal. In that case, bbaasshh does not treat SSIIGGIINNTT as a fatal sig- - nal, either, instead assuming that the SSIIGGIINNTT was used as part - of the program's normal operation (e.g., emacs uses it to abort + the user meant to send the SSIIGGIINNTT to the shell as well, and acts + on the SSIIGGIINNTT (e.g., by running a SSIIGGIINNTT trap, exiting a non-in- + teractive shell, or returning to the top level to read a new + command). + + 2. If the command does not terminate due to SSIIGGIINNTT, the program + handled the SSIIGGIINNTT itself and did not treat it as a fatal sig- + nal. In that case, bbaasshh does not treat SSIIGGIINNTT as a fatal sig- + nal, either, instead assuming that the SSIIGGIINNTT was used as part + of the program's normal operation (e.g., emacs uses it to abort editing commands) or deliberately discarded. However, bbaasshh will run any trap set on SSIIGGIINNTT, as it does with any other trapped signal it receives while it is waiting for the foreground com- mand to complete, for compatibility. + When job control is enabled, bbaasshh does not receive keyboard-generated + signals such as SSIIGGIINNTT while it is waiting for a foreground command. + An interactive shell does not pay attention to the SSIIGGIINNTT, even if the + foreground command terminates as a result, other than noting its exit + status. If the shell is not interactive, and the foreground command + terminates due to the SSIIGGIINNTT, bbaasshh pretends it received the SSIIGGIINNTT it- + self (scenario 1 above), for compatibility. + JJOOBB CCOONNTTRROOLL _J_o_b _c_o_n_t_r_o_l refers to the ability to selectively stop (_s_u_s_p_e_n_d) the ex- - ecution of processes and continue (_r_e_s_u_m_e) their execution at a later - point. A user typically employs this facility via an interactive in- - terface supplied jointly by the operating system kernel's terminal - driver and bbaasshh. + ecution of processes and continue (_r_e_s_u_m_e) their execution at a later + point. A user typically employs this facility via an interactive in- + terface supplied jointly by the operating system kernel's terminal dri- + ver and bbaasshh. The shell associates a _j_o_b with each pipeline. It keeps a table of - currently executing jobs, which may be listed with the jjoobbss command. - When bbaasshh starts a job asynchronously (in the _b_a_c_k_g_r_o_u_n_d), it prints a - line that looks like: + currently executing jobs, which the jjoobbss command will display. Each + job has a _j_o_b _n_u_m_b_e_r, which jjoobbss displays between brackets. Job num- + bers start at 1. When bbaasshh starts a job asynchronously (in the _b_a_c_k_- + _g_r_o_u_n_d), it prints a line that looks like: [1] 25647 indicating that this job is job number 1 and that the process ID of the last process in the pipeline associated with this job is 25647. All of - the processes in a single pipeline are members of the same job. BBaasshh + the processes in a single pipeline are members of the same job. BBaasshh uses the _j_o_b abstraction as the basis for job control. - To facilitate the implementation of the user interface to job control, - the operating system maintains the notion of a _c_u_r_r_e_n_t _t_e_r_m_i_n_a_l _p_r_o_c_e_s_s - _g_r_o_u_p _I_D. Members of this process group (processes whose process group - ID is equal to the current terminal process group ID) receive keyboard- - generated signals such as SSIIGGIINNTT. These processes are said to be in - the _f_o_r_e_g_r_o_u_n_d. _B_a_c_k_g_r_o_u_n_d processes are those whose process group ID - differs from the terminal's; such processes are immune to keyboard-gen- - erated signals. Only foreground processes are allowed to read from or, - if the user so specifies with stty tostop, write to the terminal. - Background processes which attempt to read from (write to when stty - tostop is in effect) the terminal are sent a SSIIGGTTTTIINN ((SSIIGGTTTTOOUU)) signal - by the kernel's terminal driver, which, unless caught, suspends the - process. + To facilitate the implementation of the user interface to job control, + each process has a _p_r_o_c_e_s_s _g_r_o_u_p _I_D, and the operating system maintains + the notion of a _c_u_r_r_e_n_t _t_e_r_m_i_n_a_l _p_r_o_c_e_s_s _g_r_o_u_p _I_D. This terminal + process group ID is associated with the _c_o_n_t_r_o_l_l_i_n_g _t_e_r_m_i_n_a_l. + + Processes that have the same process group ID are said to be part of + the same _p_r_o_c_e_s_s _g_r_o_u_p. Members of the _f_o_r_e_g_r_o_u_n_d process group + (processes whose process group ID is equal to the current terminal + process group ID) receive keyboard-generated signals such as SSIIGGIINNTT. + Processes in the foreground process group are said to be _f_o_r_e_g_r_o_u_n_d + processes. _B_a_c_k_g_r_o_u_n_d processes are those whose process group ID dif- + fers from the controlling terminal's; such processes are immune to key- + board-generated signals. Only foreground processes are allowed to read + from or, if the user so specifies with "stty tostop", write to the con- + trolling terminal. The system sends a SSIIGGTTTTIINN ((SSIIGGTTTTOOUU)) signal to + background processes which attempt to read from (write to when "tostop" + is in effect) the terminal, which, unless caught, suspends the process. If the operating system on which bbaasshh is running supports job control, bbaasshh contains facilities to use it. Typing the _s_u_s_p_e_n_d character (typ- - ically ^^ZZ, Control-Z) while a process is running causes that process to - be stopped and returns control to bbaasshh. Typing the _d_e_l_a_y_e_d _s_u_s_p_e_n_d - character (typically ^^YY, Control-Y) causes the process to be stopped - when it attempts to read input from the terminal, and control to be re- - turned to bbaasshh. The user may then manipulate the state of this job, - using the bbgg command to continue it in the background, the ffgg command - to continue it in the foreground, or the kkiillll command to kill it. A ^^ZZ - takes effect immediately, and has the additional side effect of causing - pending output and typeahead to be discarded. - - There are a number of ways to refer to a job in the shell. The charac- - ter %% introduces a job specification (_j_o_b_s_p_e_c). Job number _n may be - referred to as %%nn. A job may also be referred to using a prefix of the - name used to start it, or using a substring that appears in its command - line. For example, %%ccee refers to a stopped job whose command name be- - gins with ccee. If a prefix matches more than one job, bbaasshh reports an - error. Using %%??ccee, on the other hand, refers to any job containing the - string ccee in its command line. If the substring matches more than one - job, bbaasshh reports an error. The symbols %%%% and %%++ refer to the shell's - notion of the _c_u_r_r_e_n_t _j_o_b, which is the last job stopped while it was - in the foreground or started in the background. The _p_r_e_v_i_o_u_s _j_o_b may - be referenced using %%--. If there is only a single job, %%++ and %%-- can - both be used to refer to that job. In output pertaining to jobs (e.g., - the output of the jjoobbss command), the current job is always flagged with - a ++, and the previous job with a --. A single % (with no accompanying - job specification) also refers to the current job. - - Simply naming a job can be used to bring it into the foreground: %%11 is - a synonym for ````ffgg %%11'''', bringing job 1 from the background into the - foreground. Similarly, ````%%11 &&'''' resumes job 1 in the background, - equivalent to ````bbgg %%11''''. + ically ^^ZZ, Control-Z) while a process is running stops that process and + returns control to bbaasshh. Typing the _d_e_l_a_y_e_d _s_u_s_p_e_n_d character (typi- + cally ^^YY, Control-Y) causes the process stop when it attempts to read + input from the terminal, and returns control to bbaasshh. The user then + manipulates the state of this job, using the bbgg command to continue it + in the background, the ffgg command to continue it in the foreground, or + the kkiillll command to kill it. The suspend character takes effect imme- + diately, and has the additional side effect of discarding any pending + output and typeahead. To force a background process to stop, or stop a + process that's not associated with the current terminal session, send + it the SSIIGGSSTTOOPP signal using kkiillll. + + There are a number of ways to refer to a job in the shell. The %% char- + acter introduces a job specification (jobspec). + + Job number _n may be referred to as %%nn. A job may also be referred to + using a prefix of the name used to start it, or using a substring that + appears in its command line. For example, %%ccee refers to a job whose + command name begins with ccee. Using %%??ccee, on the other hand, refers to + any job containing the string ccee in its command line. If the prefix or + substring matches more than one job, bbaasshh reports an error. + + The symbols %%%% and %%++ refer to the shell's notion of the _c_u_r_r_e_n_t _j_o_b. + A single % (with no accompanying job specification) also refers to the + current job. %%-- refers to the _p_r_e_v_i_o_u_s _j_o_b. When a job starts in the + background, a job stops while in the foreground, or a job is resumed in + the background, it becomes the current job. The job that was the cur- + rent job becomes the previous job. When the current job terminates, + the previous job becomes the current job. If there is only a single + job, %%++ and %%-- can both be used to refer to that job. In output per- + taining to jobs (e.g., the output of the jjoobbss command), the current job + is always marked with a ++, and the previous job with a --. + + Simply naming a job can be used to bring it into the foreground: %%11 is + a synonym for "fg %1", bringing job 1 from the background into the + foreground. Similarly, "%1 &" resumes job 1 in the background, equiva- + lent to "bg %1". The shell learns immediately whenever a job changes state. Normally, - bbaasshh waits until it is about to print a prompt before reporting changes - in a job's status so as to not interrupt any other output. If the --bb - option to the sseett builtin command is enabled, bbaasshh reports such changes - immediately. Any trap on SSIIGGCCHHLLDD is executed for each child that ex- - its. - - If an attempt to exit bbaasshh is made while jobs are stopped (or, if the + bbaasshh waits until it is about to print a prompt before notifying the + user about changes in a job's status so as to not interrupt any other + output, though it will notify of changes in a job's status after a + foreground command in a list completes, before executing the next com- + mand in the list. If the --bb option to the sseett builtin command is en- + abled, bbaasshh reports status changes immediately. BBaasshh executes any trap + on SSIIGGCCHHLLDD for each child that terminates. + + When a job terminates and bbaasshh notifies the user about it, bbaasshh removes + the job from the table. It will not appear in jjoobbss output, but wwaaiitt + will report its exit status, as long as it's supplied the process ID + associated with the job as an argument. When the table is empty, job + numbers start over at 1. + + If a user attempts to exit bbaasshh while jobs are stopped (or, if the cchheecckkjjoobbss shell option has been enabled using the sshhoopptt builtin, run- ning), the shell prints a warning message, and, if the cchheecckkjjoobbss option - is enabled, lists the jobs and their statuses. The jjoobbss command may - then be used to inspect their status. If a second attempt to exit is - made without an intervening command, the shell does not print another - warning, and any stopped jobs are terminated. + is enabled, lists the jobs and their statuses. The jjoobbss command may + then be used to inspect their status. If the user immediately attempts + to exit again, without an intervening command, bbaasshh does not print an- + other warning, and terminates any stopped jobs. When the shell is waiting for a job or process using the wwaaiitt builtin, and job control is enabled, wwaaiitt will return when the job changes @@ -3098,57 +3461,68 @@ JJOOBB CCOONNTTRROOLL PPRROOMMPPTTIINNGG When executing interactively, bbaasshh displays the primary prompt PPSS11 when it is ready to read a command, and the secondary prompt PPSS22 when it - needs more input to complete a command. BBaasshh displays PPSS00 after it - reads a command but before executing it. BBaasshh displays PPSS44 as de- - scribed above before tracing each command when the --xx option is en- - abled. BBaasshh allows these prompt strings to be customized by inserting - a number of backslash-escaped special characters that are decoded as - follows: - \\aa an ASCII bell character (07) - \\dd the date in "Weekday Month Date" format (e.g., "Tue May - 26") + needs more input to complete a command. + + BBaasshh examines the value of the array variable PPRROOMMPPTT__CCOOMMMMAANNDD just be- + fore printing each primary prompt. If any elements in PPRROOMMPPTT__CCOOMMMMAANNDD + are set and non-null, Bash executes each value, in numeric order, just + as if it had been typed on the command line. BBaasshh displays PPSS00 after + it reads a command but before executing it. + + BBaasshh displays PPSS44 as described above before tracing each command when + the --xx option is enabled. + + BBaasshh allows the prompt strings PPSS00, PPSS11, PPSS22, and PPSS44, to be customized + by inserting a number of backslash-escaped special characters that are + decoded as follows: + + \\aa An ASCII bell character (07). + \\dd The date in "Weekday Month Date" format (e.g., "Tue May + 26"). \\DD{{_f_o_r_m_a_t}} - the _f_o_r_m_a_t is passed to _s_t_r_f_t_i_m_e(3) and the result is in- + The _f_o_r_m_a_t is passed to _s_t_r_f_t_i_m_e(3) and the result is in- serted into the prompt string; an empty _f_o_r_m_a_t results in - a locale-specific time representation. The braces are - required - \\ee an ASCII escape character (033) - \\hh the hostname up to the first `.' - \\HH the hostname - \\jj the number of jobs currently managed by the shell - \\ll the basename of the shell's terminal device name - \\nn newline - \\rr carriage return - \\ss the name of the shell, the basename of $$00 (the portion - following the final slash) - \\tt the current time in 24-hour HH:MM:SS format - \\TT the current time in 12-hour HH:MM:SS format - \\@@ the current time in 12-hour am/pm format - \\AA the current time in 24-hour HH:MM format - \\uu the username of the current user - \\vv the version of bbaasshh (e.g., 2.00) - \\VV the release of bbaasshh, version + patch level (e.g., 2.00.0) - \\ww the value of the PPWWDD shell variable ($$PPWWDD), with $$HHOOMMEE + a locale-specific time representation. The braces are + required. + \\ee An ASCII escape character (033). + \\hh The hostname up to the first ".". + \\HH The hostname. + \\jj The number of jobs currently managed by the shell. + \\ll The basename of the shell's terminal device name (e.g., + "ttys0"). + \\nn A newline. + \\rr A carriage return. + \\ss The name of the shell: the basename of $$00 (the portion + following the final slash). + \\tt The current time in 24-hour HH:MM:SS format. + \\TT The current time in 12-hour HH:MM:SS format. + \\@@ The current time in 12-hour am/pm format. + \\AA The current time in 24-hour HH:MM format. + \\uu The username of the current user. + \\vv The bbaasshh version (e.g., 2.00). + \\VV The bbaasshh release, version + patch level (e.g., 2.00.0) + \\ww The value of the PPWWDD shell variable ($$PPWWDD), with $$HHOOMMEE abbreviated with a tilde (uses the value of the - PPRROOMMPPTT__DDIIRRTTRRIIMM variable) - \\WW the basename of $$PPWWDD, with $$HHOOMMEE abbreviated with a tilde - \\!! the history number of this command - \\## the command number of this command - \\$$ if the effective UID is 0, a ##, otherwise a $$ - \\_n_n_n the character corresponding to the octal number _n_n_n - \\\\ a backslash - \\[[ begin a sequence of non-printing characters, which could - be used to embed a terminal control sequence into the - prompt - \\]] end a sequence of non-printing characters - - The command number and the history number are usually different: the - history number of a command is its position in the history list, which - may include commands restored from the history file (see HHIISSTTOORRYY be- - low), while the command number is the position in the sequence of com- - mands executed during the current shell session. After the string is - decoded, it is expanded via parameter expansion, command substitution, - arithmetic expansion, and quote removal, subject to the value of the + PPRROOMMPPTT__DDIIRRTTRRIIMM variable). + \\WW The basename of $$PPWWDD, with $$HHOOMMEE abbreviated with a + tilde. + \\!! The history number of this command. + \\## The command number of this command. + \\$$ If the effective UID is 0, a ##, otherwise a $$. + \\_n_n_n The character corresponding to the octal number _n_n_n. + \\\\ A backslash. + \\[[ Begin a sequence of non-printing characters, which could + be used to embed a terminal control sequence into the + prompt. + \\]] End a sequence of non-printing characters. + + The command number and the history number are usually different: the + history number of a command is its position in the history list, which + may include commands restored from the history file (see HHIISSTTOORRYY be- + low), while the command number is the position in the sequence of com- + mands executed during the current shell session. After the string is + decoded, it is expanded via parameter expansion, command substitution, + arithmetic expansion, and quote removal, subject to the value of the pprroommppttvvaarrss shell option (see the description of the sshhoopptt command under SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). This can have unwanted side effects if escaped portions of the string appear within command substitution or @@ -3156,73 +3530,104 @@ PPRROOMMPPTTIINNGG RREEAADDLLIINNEE This is the library that handles reading input when using an interac- - tive shell, unless the ----nnooeeddiittiinngg option is given at shell invocation. - Line editing is also used when using the --ee option to the rreeaadd builtin. - By default, the line editing commands are similar to those of Emacs. A - vi-style line editing interface is also available. Line editing can be - enabled at any time using the --oo eemmaaccss or --oo vvii options to the sseett - builtin (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). To turn off line editing - after the shell is running, use the ++oo eemmaaccss or ++oo vvii options to the - sseett builtin. + tive shell, unless the ----nnooeeddiittiinngg option is supplied at shell invoca- + tion. Line editing is also used when using the --ee option to the rreeaadd + builtin. By default, the line editing commands are similar to those of + emacs; a vi-style line editing interface is also available. Line edit- + ing can be enabled at any time using the --oo eemmaaccss or --oo vvii options to + the sseett builtin (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). To turn off line + editing after the shell is running, use the ++oo eemmaaccss or ++oo vvii options + to the sseett builtin. RReeaaddlliinnee NNoottaattiioonn - In this section, the Emacs-style notation is used to denote keystrokes. - Control keys are denoted by C-_k_e_y, e.g., C-n means Control-N. Simi- - larly, _m_e_t_a keys are denoted by M-_k_e_y, so M-x means Meta-X. (On key- - boards without a _m_e_t_a key, M-_x means ESC _x, i.e., press the Escape key - then the _x key. This makes ESC the _m_e_t_a _p_r_e_f_i_x. The combination M-C-_x - means ESC-Control-_x, or press the Escape key then hold the Control key - while pressing the _x key.) - - Readline commands may be given numeric _a_r_g_u_m_e_n_t_s, which normally act as - a repeat count. Sometimes, however, it is the sign of the argument - that is significant. Passing a negative argument to a command that - acts in the forward direction (e.g., kkiillll--lliinnee) causes that command to - act in a backward direction. Commands whose behavior with arguments - deviates from this are noted below. + This section uses Emacs-style editing concepts and uses its notation + for keystrokes. Control keys are denoted by C-_k_e_y, e.g., C-n means + Control-N. Similarly, _m_e_t_a keys are denoted by M-_k_e_y, so M-x means + Meta-X. The Meta key is often labeled "Alt" or "Option". + + On keyboards without a _M_e_t_a key, M-_x means ESC _x, i.e., press and re- + lease the Escape key, then press and release the _x key, in sequence. + This makes ESC the _m_e_t_a _p_r_e_f_i_x. The combination M-C-_x means ESC Con- + trol-_x: press and release the Escape key, then press and hold the Con- + trol key while pressing the _x key, then release both. + + On some keyboards, the Meta key modifier produces characters with the + eighth bit (0200) set. You can use the eennaabbllee--mmeettaa--kkeeyy variable to + control whether or not it does this, if the keyboard allows it. On + many others, the terminal or terminal emulator converts the metafied + key to a key sequence beginning with ESC as described in the preceding + paragraph. + + If your _M_e_t_a key produces a key sequence with the ESC meta prefix, you + can make M-_k_e_y key bindings you specify (see RReeaaddlliinnee KKeeyy BBiinnddiinnggss be- + low) do the same thing by setting the ffoorrccee--mmeettaa--pprreeffiixx variable. + + RReeaaddlliinnee commands may be given numeric _a_r_g_u_m_e_n_t_s, which normally act as + a repeat count. Sometimes, however, it is the sign of the argument + that is significant. Passing a negative argument to a command that + acts in the forward direction (e.g., kkiillll--lliinnee) makes that command act + in a backward direction. Commands whose behavior with arguments devi- + ates from this are noted below. + + The _p_o_i_n_t is the current cursor position, and _m_a_r_k refers to a saved + cursor position. The text between the point and mark is referred to as + the _r_e_g_i_o_n. RReeaaddlliinnee has the concept of an _a_c_t_i_v_e _r_e_g_i_o_n: when the re- + gion is active, rreeaaddlliinnee redisplay highlights the region using the + value of the aaccttiivvee--rreeggiioonn--ssttaarrtt--ccoolloorr variable. The eennaabbllee--aaccttiivvee--rree-- + ggiioonn variable turns this on and off. Several commands set the region + to active; those are noted below. When a command is described as _k_i_l_l_i_n_g text, the text deleted is saved for possible future retrieval (_y_a_n_k_i_n_g). The killed text is saved in a - _k_i_l_l _r_i_n_g. Consecutive kills cause the text to be accumulated into one + _k_i_l_l _r_i_n_g. Consecutive kills accumulate the deleted text into one unit, which can be yanked all at once. Commands which do not kill text separate the chunks of text on the kill ring. RReeaaddlliinnee IInniittiiaalliizzaattiioonn - Readline is customized by putting commands in an initialization file + RReeaaddlliinnee is customized by putting commands in an initialization file (the _i_n_p_u_t_r_c file). The name of this file is taken from the value of - the IINNPPUUTTRRCC variable. If that variable is unset, the default is _~_/_._i_n_- - _p_u_t_r_c. If that file does not exist or cannot be read, the ultimate - default is _/_e_t_c_/_i_n_p_u_t_r_c. When a program which uses the readline li- - brary starts up, the initialization file is read, and the key bindings - and variables are set. There are only a few basic constructs allowed - in the readline initialization file. Blank lines are ignored. Lines - beginning with a ## are comments. Lines beginning with a $$ indicate - conditional constructs. Other lines denote key bindings and variable - settings. - - The default key-bindings may be changed with an _i_n_p_u_t_r_c file. Other - programs that use this library may add their own commands and bindings. + the IINNPPUUTTRRCC shell variable. If that variable is unset, the default is + _~_/_._i_n_p_u_t_r_c. If that file does not exist or cannot be read, rreeaaddlliinnee + looks for _/_e_t_c_/_i_n_p_u_t_r_c. When a program that uses the rreeaaddlliinnee library + starts up, rreeaaddlliinnee reads the initialization file and sets the key + bindings and variables found there, before reading any user input. + + There are only a few basic constructs allowed in the inputrc file. + Blank lines are ignored. Lines beginning with a ## are comments. Lines + beginning with a $$ indicate conditional constructs. Other lines denote + key bindings and variable settings. + + The default key-bindings in this section may be changed using key bind- + ing commands in the _i_n_p_u_t_r_c file. Programs that use the rreeaaddlliinnee li- + brary, including bbaasshh, may add their own commands and bindings. For example, placing M-Control-u: universal-argument or C-Meta-u: universal-argument - into the _i_n_p_u_t_r_c would make M-C-u execute the readline command _u_n_i_v_e_r_- + + into the _i_n_p_u_t_r_c would make M-C-u execute the rreeaaddlliinnee command _u_n_i_v_e_r_- _s_a_l_-_a_r_g_u_m_e_n_t. - The following symbolic character names are recognized: _R_U_B_O_U_T, _D_E_L, - _E_S_C, _L_F_D, _N_E_W_L_I_N_E, _R_E_T, _R_E_T_U_R_N, _S_P_C, _S_P_A_C_E, and _T_A_B. + Key bindings may contain the following symbolic character names: _D_E_L, + _E_S_C, _E_S_C_A_P_E, _L_F_D, _N_E_W_L_I_N_E, _R_E_T, _R_E_T_U_R_N, _R_U_B_O_U_T (a destructive back- + space), _S_P_A_C_E, _S_P_C, and _T_A_B. - In addition to command names, readline allows keys to be bound to a - string that is inserted when the key is pressed (a _m_a_c_r_o). + In addition to command names, rreeaaddlliinnee allows keys to be bound to a + string that is inserted when the key is pressed (a _m_a_c_r_o). The differ- + ence between a macro and a command is that a macro is enclosed in sin- + gle or double quotes. RReeaaddlliinnee KKeeyy BBiinnddiinnggss - The syntax for controlling key bindings in the _i_n_p_u_t_r_c file is simple. - All that is required is the name of the command or the text of a macro - and a key sequence to which it should be bound. The name may be speci- - fied in one of two ways: as a symbolic key name, possibly with _M_e_t_a_- or - _C_o_n_t_r_o_l_- prefixes, or as a key sequence. + The syntax for controlling key bindings in the _i_n_p_u_t_r_c file is simple. + All that is required is the name of the command or the text of a macro + and a key sequence to which it should be bound. The key sequence may + be specified in one of two ways: as a symbolic key name, possibly with + _M_e_t_a_- or _C_o_n_t_r_o_l_- prefixes, or as a key sequence composed of one or + more characters enclosed in double quotes. The key sequence and name + are separated by a colon. There can be no whitespace between the name + and the colon. When using the form kkeeyynnaammee:_f_u_n_c_t_i_o_n_-_n_a_m_e or _m_a_c_r_o, _k_e_y_n_a_m_e is the name of a key spelled out in English. For example: @@ -3231,16 +3636,16 @@ RREEAADDLLIINNEE Meta-Rubout: backward-kill-word Control-o: "> output" - In the above example, _C_-_u is bound to the function uunniivveerrssaall--aarrgguummeenntt, - _M_-_D_E_L is bound to the function bbaacckkwwaarrdd--kkiillll--wwoorrdd, and _C_-_o is bound to - run the macro expressed on the right hand side (that is, to insert the - text ``> output'' into the line). + In the above example, _C_-_u is bound to the function uunniivveerrssaall--aarrgguummeenntt, + _M_-_D_E_L is bound to the function bbaacckkwwaarrdd--kkiillll--wwoorrdd, and _C_-_o is bound to + run the macro expressed on the right hand side (that is, to insert the + text "> output" into the line). - In the second form, ""kkeeyysseeqq"":_f_u_n_c_t_i_o_n_-_n_a_m_e or _m_a_c_r_o, kkeeyysseeqq differs - from kkeeyynnaammee above in that strings denoting an entire key sequence may - be specified by placing the sequence within double quotes. Some GNU - Emacs style key escapes can be used, as in the following example, but - the symbolic character names are not recognized. + In the second form, ""kkeeyysseeqq"":_f_u_n_c_t_i_o_n_-_n_a_m_e or _m_a_c_r_o, kkeeyysseeqq differs + from kkeeyynnaammee above in that strings denoting an entire key sequence may + be specified by placing the sequence within double quotes. Some GNU + Emacs style key escapes can be used, as in the following example, but + none of the symbolic character names are recognized. "\C-u": universal-argument "\C-x\C-r": re-read-init-file @@ -3248,17 +3653,20 @@ RREEAADDLLIINNEE In this example, _C_-_u is again bound to the function uunniivveerrssaall--aarrgguummeenntt. _C_-_x _C_-_r is bound to the function rree--rreeaadd--iinniitt--ffiillee, and _E_S_C _[ _1 _1 _~ is - bound to insert the text ``Function Key 1''. - - The full set of GNU Emacs style escape sequences is - \\CC-- control prefix - \\MM-- meta prefix - \\ee an escape character - \\\\ backslash - \\"" literal " - \\'' literal ' - - In addition to the GNU Emacs style escape sequences, a second set of + bound to insert the text "Function Key 1". + + The full set of GNU Emacs style escape sequences available when speci- + fying key sequences is + \\CC-- A control prefix. + \\MM-- Adding the meta prefix or converting the following char- + acter to a meta character, as described below under + ffoorrccee--mmeettaa--pprreeffiixx. + \\ee An escape character. + \\\\ Backslash. + \\"" Literal ", a double quote. + \\'' Literal ', a single quote. + + In addition to the GNU Emacs style escape sequences, a second set of backslash escapes is available: \\aa alert (bell) \\bb backspace @@ -3268,173 +3676,197 @@ RREEAADDLLIINNEE \\rr carriage return \\tt horizontal tab \\vv vertical tab - \\_n_n_n the eight-bit character whose value is the octal value - _n_n_n (one to three digits) - \\xx_H_H the eight-bit character whose value is the hexadecimal - value _H_H (one or two hex digits) + \\_n_n_n The eight-bit character whose value is the octal value + _n_n_n (one to three digits). + \\xx_H_H The eight-bit character whose value is the hexadecimal + value _H_H (one or two hex digits). When entering the text of a macro, single or double quotes must be used to indicate a macro definition. Unquoted text is assumed to be a func- - tion name. In the macro body, the backslash escapes described above - are expanded. Backslash will quote any other character in the macro - text, including " and '. + tion name. The backslash escapes described above are expanded in the + macro body. Backslash quotes any other character in the macro text, + including " and '. - BBaasshh allows the current readline key bindings to be displayed or modi- - fied with the bbiinndd builtin command. The editing mode may be switched - during interactive use by using the --oo option to the sseett builtin com- - mand (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). + BBaasshh will display or modify the current rreeaaddlliinnee key bindings with the + bbiinndd builtin command. The --oo eemmaaccss or --oo vvii options to the sseett builtin + (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below) change the editing mode during in- + teractive use. RReeaaddlliinnee VVaarriiaabblleess - Readline has variables that can be used to further customize its behav- + RReeaaddlliinnee has variables that can be used to further customize its behav- ior. A variable may be set in the _i_n_p_u_t_r_c file with a statement of the form sseett _v_a_r_i_a_b_l_e_-_n_a_m_e _v_a_l_u_e or using the bbiinndd builtin command (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). - Except where noted, readline variables can take the values OOnn or OOffff + Except where noted, rreeaaddlliinnee variables can take the values OOnn or OOffff (without regard to case). Unrecognized variable names are ignored. - When a variable value is read, empty or null values, "on" (case-insen- - sitive), and "1" are equivalent to OOnn. All other values are equivalent - to OOffff. The variables and their default values are: + When rreeaaddlliinnee reads a variable value, empty or null values, "on" (case- + insensitive), and "1" are equivalent to OOnn. All other values are + equivalent to OOffff. + + The bbiinndd --VV command lists the current rreeaaddlliinnee variable names and val- + ues (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). + + The variables and their default values are: aaccttiivvee--rreeggiioonn--ssttaarrtt--ccoolloorr A string variable that controls the text color and background when displaying the text in the active region (see the descrip- tion of eennaabbllee--aaccttiivvee--rreeggiioonn below). This string must not take up any physical character positions on the display, so it should - consist only of terminal escape sequences. It is output to the - terminal before displaying the text in the active region. This - variable is reset to the default value whenever the terminal - type changes. The default value is the string that puts the - terminal in standout mode, as obtained from the terminal's ter- + consist only of terminal escape sequences. It is output to the + terminal before displaying the text in the active region. This + variable is reset to the default value whenever the terminal + type changes. The default value is the string that puts the + terminal in standout mode, as obtained from the terminal's ter- minfo description. A sample value might be "\e[01;33m". aaccttiivvee--rreeggiioonn--eenndd--ccoolloorr - A string variable that "undoes" the effects of aaccttiivvee--rree-- - ggiioonn--ssttaarrtt--ccoolloorr and restores "normal" terminal display appear- - ance after displaying text in the active region. This string - must not take up any physical character positions on the dis- - play, so it should consist only of terminal escape sequences. - It is output to the terminal after displaying the text in the - active region. This variable is reset to the default value - whenever the terminal type changes. The default value is the - string that restores the terminal from standout mode, as ob- + A string variable that "undoes" the effects of aaccttiivvee--rree-- + ggiioonn--ssttaarrtt--ccoolloorr and restores "normal" terminal display appear- + ance after displaying text in the active region. This string + must not take up any physical character positions on the dis- + play, so it should consist only of terminal escape sequences. + It is output to the terminal after displaying the text in the + active region. This variable is reset to the default value + whenever the terminal type changes. The default value is the + string that restores the terminal from standout mode, as ob- tained from the terminal's terminfo description. A sample value might be "\e[0m". bbeellll--ssttyyllee ((aauuddiibbllee)) - Controls what happens when readline wants to ring the terminal - bell. If set to nnoonnee, readline never rings the bell. If set to - vviissiibbllee, readline uses a visible bell if one is available. If - set to aauuddiibbllee, readline attempts to ring the terminal's bell. + Controls what happens when rreeaaddlliinnee wants to ring the terminal + bell. If set to nnoonnee, rreeaaddlliinnee never rings the bell. If set to + vviissiibbllee, rreeaaddlliinnee uses a visible bell if one is available. If + set to aauuddiibbllee, rreeaaddlliinnee attempts to ring the terminal's bell. bbiinndd--ttttyy--ssppeecciiaall--cchhaarrss ((OOnn)) - If set to OOnn, readline attempts to bind the control characters - treated specially by the kernel's terminal driver to their read- - line equivalents. + If set to OOnn, rreeaaddlliinnee attempts to bind the control characters + that are treated specially by the kernel's terminal driver to + their rreeaaddlliinnee equivalents. These override the default rreeaaddlliinnee + bindings described here. Type "stty -a" at a bbaasshh prompt to see + your current terminal settings, including the special control + characters (usually cccchhaarrss). bblliinnkk--mmaattcchhiinngg--ppaarreenn ((OOffff)) - If set to OOnn, readline attempts to briefly move the cursor to an + If set to OOnn, rreeaaddlliinnee attempts to briefly move the cursor to an opening parenthesis when a closing parenthesis is inserted. ccoolloorreedd--ccoommpplleettiioonn--pprreeffiixx ((OOffff)) - If set to OOnn, when listing completions, readline displays the + If set to OOnn, when listing completions, rreeaaddlliinnee displays the common prefix of the set of possible completions using a differ- ent color. The color definitions are taken from the value of the LLSS__CCOOLLOORRSS environment variable. If there is a color defini- - tion in $$LLSS__CCOOLLOORRSS for the custom suffix "readline-colored-com- - pletion-prefix", readline uses this color for the common prefix + tion in $$LLSS__CCOOLLOORRSS for the custom suffix ".readline-colored-com- + pletion-prefix", rreeaaddlliinnee uses this color for the common prefix instead of its default. ccoolloorreedd--ssttaattss ((OOffff)) - If set to OOnn, readline displays possible completions using dif- + If set to OOnn, rreeaaddlliinnee displays possible completions using dif- ferent colors to indicate their file type. The color defini- tions are taken from the value of the LLSS__CCOOLLOORRSS environment variable. - ccoommmmeenntt--bbeeggiinn ((````##'''')) - The string that is inserted when the readline iinnsseerrtt--ccoommmmeenntt - command is executed. This command is bound to MM--## in emacs mode - and to ## in vi command mode. + ccoommmmeenntt--bbeeggiinn (("##")) + The string that the rreeaaddlliinnee iinnsseerrtt--ccoommmmeenntt command inserts. + This command is bound to MM--## in emacs mode and to ## in vi com- + mand mode. ccoommpplleettiioonn--ddiissppllaayy--wwiiddtthh ((--11)) The number of screen columns used to display possible matches when performing completion. The value is ignored if it is less than 0 or greater than the terminal screen width. A value of 0 - will cause matches to be displayed one per line. The default - value is -1. + causes matches to be displayed one per line. The default value + is -1. ccoommpplleettiioonn--iiggnnoorree--ccaassee ((OOffff)) - If set to OOnn, readline performs filename matching and completion + If set to OOnn, rreeaaddlliinnee performs filename matching and completion in a case-insensitive fashion. ccoommpplleettiioonn--mmaapp--ccaassee ((OOffff)) - If set to OOnn, and ccoommpplleettiioonn--iiggnnoorree--ccaassee is enabled, readline - treats hyphens (_-) and underscores (__) as equivalent when per- + If set to OOnn, and ccoommpplleettiioonn--iiggnnoorree--ccaassee is enabled, rreeaaddlliinnee + treats hyphens (_-) and underscores (__) as equivalent when per- forming case-insensitive filename matching and completion. ccoommpplleettiioonn--pprreeffiixx--ddiissppllaayy--lleennggtthh ((00)) - The length in characters of the common prefix of a list of pos- - sible completions that is displayed without modification. When - set to a value greater than zero, common prefixes longer than - this value are replaced with an ellipsis when displaying possi- - ble completions. + The maximum length in characters of the common prefix of a list + of possible completions that is displayed without modification. + When set to a value greater than zero, rreeaaddlliinnee replaces common + prefixes longer than this value with an ellipsis when displaying + possible completions. If a completion begins with a period, and + eeaaddlliinnee is completing filenames, it uses three underscores in- + stead of an ellipsis. ccoommpplleettiioonn--qquueerryy--iitteemmss ((110000)) - This determines when the user is queried about viewing the num- - ber of possible completions generated by the ppoossssiibbllee--ccoommppllee-- - ttiioonnss command. It may be set to any integer value greater than - or equal to zero. If the number of possible completions is - greater than or equal to the value of this variable, readline - will ask whether or not the user wishes to view them; otherwise - they are simply listed on the terminal. A zero value means - readline should never ask; negative values are treated as zero. + This determines when the user is queried about viewing the num- + ber of possible completions generated by the ppoossssiibbllee--ccoommppllee-- + ttiioonnss command. It may be set to any integer value greater than + or equal to zero. If the number of possible completions is + greater than or equal to the value of this variable, rreeaaddlliinnee + asks whether or not the user wishes to view them; otherwise + rreeaaddlliinnee simply lists them on the terminal. A zero value means + rreeaaddlliinnee should never ask; negative values are treated as zero. ccoonnvveerrtt--mmeettaa ((OOnn)) - If set to OOnn, readline will convert characters with the eighth - bit set to an ASCII key sequence by stripping the eighth bit and - prefixing an escape character (in effect, using escape as the - _m_e_t_a _p_r_e_f_i_x). The default is _O_n, but readline will set it to - _O_f_f if the locale contains eight-bit characters. This variable - is dependent on the LLCC__CCTTYYPPEE locale category, and may change if - the locale is changed. + If set to OOnn, rreeaaddlliinnee converts characters it reads that have + the eighth bit set to an ASCII key sequence by clearing the + eighth bit and prefixing it with an escape character (converting + the character to have the meta prefix). The default is _O_n, but + rreeaaddlliinnee sets it to _O_f_f if the locale contains characters whose + encodings may include bytes with the eighth bit set. This vari- + able is dependent on the LLCC__CCTTYYPPEE locale category, and may + change if the locale changes. This variable also affects key + bindings; see the description of ffoorrccee--mmeettaa--pprreeffiixx below. ddiissaabbllee--ccoommpplleettiioonn ((OOffff)) - If set to OOnn, readline will inhibit word completion. Completion - characters will be inserted into the line as if they had been - mapped to sseellff--iinnsseerrtt. + If set to OOnn, rreeaaddlliinnee inhibits word completion. Completion + characters are inserted into the line as if they had been mapped + to sseellff--iinnsseerrtt. eecchhoo--ccoonnttrrooll--cchhaarraacctteerrss ((OOnn)) When set to OOnn, on operating systems that indicate they support - it, readline echoes a character corresponding to a signal gener- + it, rreeaaddlliinnee echoes a character corresponding to a signal gener- ated from the keyboard. eeddiittiinngg--mmooddee ((eemmaaccss)) - Controls whether readline begins with a set of key bindings sim- - ilar to _E_m_a_c_s or _v_i. eeddiittiinngg--mmooddee can be set to either eemmaaccss or - vvii. + Controls whether rreeaaddlliinnee uses a set of key bindings similar to + _E_m_a_c_s or _v_i. eeddiittiinngg--mmooddee can be set to either eemmaaccss or vvii. eemmaaccss--mmooddee--ssttrriinngg ((@@)) If the _s_h_o_w_-_m_o_d_e_-_i_n_-_p_r_o_m_p_t variable is enabled, this string is displayed immediately before the last line of the primary prompt when emacs editing mode is active. The value is expanded like a - key binding, so the standard set of meta- and control prefixes - and backslash escape sequences is available. Use the \1 and \2 - escapes to begin and end sequences of non-printing characters, - which can be used to embed a terminal control sequence into the - mode string. + key binding, so the standard set of meta- and control- prefixes + and backslash escape sequences is available. The \1 and \2 es- + capes begin and end sequences of non-printing characters, which + can be used to embed a terminal control sequence into the mode + string. eennaabbllee--aaccttiivvee--rreeggiioonn ((OOnn)) - The _p_o_i_n_t is the current cursor position, and _m_a_r_k refers to a - saved cursor position. The text between the point and mark is - referred to as the _r_e_g_i_o_n. When this variable is set to _O_n, - readline allows certain commands to designate the region as _a_c_- - _t_i_v_e. When the region is active, readline highlights the text - in the region using the value of the aaccttiivvee--rreeggiioonn--ssttaarrtt--ccoolloorr, - which defaults to the string that enables the terminal's stand- - out mode. The active region shows the text inserted by brack- - eted-paste and any matching text found by incremental and non- - incremental history searches. + When this variable is set to _O_n, rreeaaddlliinnee allows certain com- + mands to designate the region as _a_c_t_i_v_e. When the region is ac- + tive, rreeaaddlliinnee highlights the text in the region using the value + of the aaccttiivvee--rreeggiioonn--ssttaarrtt--ccoolloorr variable, which defaults to the + string that enables the terminal's standout mode. The active + region shows the text inserted by bracketed-paste and any match- + ing text found by incremental and non-incremental history + searches. eennaabbllee--bbrraacckkeetteedd--ppaassttee ((OOnn)) - When set to OOnn, readline configures the terminal to insert each + When set to OOnn, rreeaaddlliinnee configures the terminal to insert each paste into the editing buffer as a single string of characters, instead of treating each character as if it had been read from - the keyboard. This prevents readline from executing any editing - commands bound to key sequences appearing in the pasted text. + the keyboard. This is called _b_r_a_c_k_e_t_e_d_-_p_a_s_t_e _m_o_d_e; it prevents + rreeaaddlliinnee from executing any editing commands bound to key se- + quences appearing in the pasted text. eennaabbllee--kkeeyyppaadd ((OOffff)) - When set to OOnn, readline will try to enable the application key- - pad when it is called. Some systems need this to enable the ar- - row keys. + When set to OOnn, rreeaaddlliinnee tries to enable the application keypad + when it is called. Some systems need this to enable the arrow + keys. eennaabbllee--mmeettaa--kkeeyy ((OOnn)) - When set to OOnn, readline will try to enable any meta modifier - key the terminal claims to support when it is called. On many - terminals, the meta key is used to send eight-bit characters. + When set to OOnn, rreeaaddlliinnee tries to enable any meta modifier key + the terminal claims to support. On many terminals, the Meta key + is used to send eight-bit characters; this variable checks for + the terminal capability that indicates the terminal can enable + and disable a mode that sets the eighth bit of a character + (0200) if the Meta key is held down when the character is typed + (a meta character). eexxppaanndd--ttiillddee ((OOffff)) - If set to OOnn, tilde expansion is performed when readline at- - tempts word completion. + If set to OOnn, rreeaaddlliinnee performs tilde expansion when it attempts + word completion. + ffoorrccee--mmeettaa--pprreeffiixx ((OOffff)) + If set to OOnn, rreeaaddlliinnee modifies its behavior when binding key + sequences containing \M- or Meta- (see KKeeyy BBiinnddiinnggss above) by + converting a key sequence of the form \M-_C or Meta-_C to the two- + character sequence EESSCC _C (adding the meta prefix). If + ffoorrccee--mmeettaa--pprreeffiixx is set to OOffff (the default), rreeaaddlliinnee uses the + value of the ccoonnvveerrtt--mmeettaa variable to determine whether to per- + form this conversion: if ccoonnvveerrtt--mmeettaa is OOnn, rreeaaddlliinnee performs + the conversion described above; if it is OOffff, rreeaaddlliinnee converts + _C to a meta character by setting the eighth bit (0200). hhiissttoorryy--pprreesseerrvvee--ppooiinntt ((OOffff)) If set to OOnn, the history code attempts to place point at the same location on each history line retrieved with pprreevviioouuss--hhiiss-- @@ -3443,174 +3875,178 @@ RREEAADDLLIINNEE Set the maximum number of history entries saved in the history list. If set to zero, any existing history entries are deleted and no new entries are saved. If set to a value less than zero, - the number of history entries is not limited. By default, the - number of history entries is set to the value of the HHIISSTTSSIIZZEE - shell variable. If an attempt is made to set _h_i_s_t_o_r_y_-_s_i_z_e to a - non-numeric value, the maximum number of history entries will be - set to 500. + the number of history entries is not limited. By default, bbaasshh + sets the maximum number of history entries to the value of the + HHIISSTTSSIIZZEE shell variable. Setting _h_i_s_t_o_r_y_-_s_i_z_e to a non-numeric + value will set the maximum number of history entries to 500. hhoorriizzoonnttaall--ssccrroollll--mmooddee ((OOffff)) - When set to OOnn, makes readline use a single line for display, - scrolling the input horizontally on a single screen line when it - becomes longer than the screen width rather than wrapping to a - new line. This setting is automatically enabled for terminals - of height 1. + Setting this variable to OOnn makes rreeaaddlliinnee use a single line for + display, scrolling the input horizontally on a single screen + line when it becomes longer than the screen width rather than + wrapping to a new line. This setting is automatically enabled + for terminals of height 1. iinnppuutt--mmeettaa ((OOffff)) - If set to OOnn, readline will enable eight-bit input (that is, it - will not strip the eighth bit from the characters it reads), re- - gardless of what the terminal claims it can support. The name - mmeettaa--ffllaagg is a synonym for this variable. The default is _O_f_f, - but readline will set it to _O_n if the locale contains eight-bit - characters. This variable is dependent on the LLCC__CCTTYYPPEE locale - category, and may change if the locale is changed. - iisseeaarrcchh--tteerrmmiinnaattoorrss ((````CC--[[CC--JJ'''')) - The string of characters that should terminate an incremental - search without subsequently executing the character as a com- - mand. If this variable has not been given a value, the charac- - ters _E_S_C and _C_-_J will terminate an incremental search. + If set to OOnn, rreeaaddlliinnee enables eight-bit input (that is, it does + not clear the eighth bit in the characters it reads), regardless + of what the terminal claims it can support. The default is _O_f_f, + but rreeaaddlliinnee sets it to _O_n if the locale contains characters + whose encodings may include bytes with the eighth bit set. This + variable is dependent on the LLCC__CCTTYYPPEE locale category, and its + value may change if the locale changes. The name mmeettaa--ffllaagg is a + synonym for iinnppuutt--mmeettaa. + iisseeaarrcchh--tteerrmmiinnaattoorrss (("CC--[[CC--jj")) + The string of characters that should terminate an incremental + search without subsequently executing the character as a com- + mand. If this variable has not been given a value, the charac- + ters _E_S_C and CC--jj terminate an incremental search. kkeeyymmaapp ((eemmaaccss)) - Set the current readline keymap. The set of valid keymap names - is _e_m_a_c_s_, _e_m_a_c_s_-_s_t_a_n_d_a_r_d_, _e_m_a_c_s_-_m_e_t_a_, _e_m_a_c_s_-_c_t_l_x_, _v_i_, _v_i_-_c_o_m_- - _m_a_n_d, and _v_i_-_i_n_s_e_r_t. _v_i is equivalent to _v_i_-_c_o_m_m_a_n_d; _e_m_a_c_s is - equivalent to _e_m_a_c_s_-_s_t_a_n_d_a_r_d. The default value is _e_m_a_c_s; the + Set the current rreeaaddlliinnee keymap. The set of valid keymap names + is _e_m_a_c_s_, _e_m_a_c_s_-_s_t_a_n_d_a_r_d_, _e_m_a_c_s_-_m_e_t_a_, _e_m_a_c_s_-_c_t_l_x_, _v_i_, _v_i_-_c_o_m_- + _m_a_n_d, and _v_i_-_i_n_s_e_r_t. _v_i is equivalent to _v_i_-_c_o_m_m_a_n_d; _e_m_a_c_s is + equivalent to _e_m_a_c_s_-_s_t_a_n_d_a_r_d. The default value is _e_m_a_c_s; the value of eeddiittiinngg--mmooddee also affects the default keymap. kkeeyysseeqq--ttiimmeeoouutt ((550000)) - Specifies the duration _r_e_a_d_l_i_n_e will wait for a character when - reading an ambiguous key sequence (one that can form a complete + Specifies the duration rreeaaddlliinnee will wait for a character when + reading an ambiguous key sequence (one that can form a complete key sequence using the input read so far, or can take additional - input to complete a longer key sequence). If no input is re- - ceived within the timeout, _r_e_a_d_l_i_n_e will use the shorter but + input to complete a longer key sequence). If rreeaaddlliinnee does not + receive any input within the timeout, it uses the shorter but complete key sequence. The value is specified in milliseconds, - so a value of 1000 means that _r_e_a_d_l_i_n_e will wait one second for + so a value of 1000 means that rreeaaddlliinnee will wait one second for additional input. If this variable is set to a value less than - or equal to zero, or to a non-numeric value, _r_e_a_d_l_i_n_e will wait - until another key is pressed to decide which key sequence to - complete. + or equal to zero, or to a non-numeric value, rreeaaddlliinnee waits un- + til another key is pressed to decide which key sequence to com- + plete. mmaarrkk--ddiirreeccttoorriieess ((OOnn)) If set to OOnn, completed directory names have a slash appended. mmaarrkk--mmooddiiffiieedd--lliinneess ((OOffff)) - If set to OOnn, history lines that have been modified are dis- - played with a preceding asterisk (**). + If set to OOnn, rreeaaddlliinnee displays history lines that have been + modified with a preceding asterisk (**). mmaarrkk--ssyymmlliinnkkeedd--ddiirreeccttoorriieess ((OOffff)) If set to OOnn, completed names which are symbolic links to direc- - tories have a slash appended (subject to the value of mmaarrkk--ddii-- - rreeccttoorriieess). + tories have a slash appended, subject to the value of mmaarrkk--ddii-- + rreeccttoorriieess. mmaattcchh--hhiiddddeenn--ffiilleess ((OOnn)) - This variable, when set to OOnn, causes readline to match files - whose names begin with a `.' (hidden files) when performing - filename completion. If set to OOffff, the leading `.' must be - supplied by the user in the filename to be completed. + This variable, when set to OOnn, forces rreeaaddlliinnee to match files + whose names begin with a "." (hidden files) when performing + filename completion. If set to OOffff, the user must include the + leading "." in the filename to be completed. mmeennuu--ccoommpplleettee--ddiissppllaayy--pprreeffiixx ((OOffff)) - If set to OOnn, menu completion displays the common prefix of the + If set to OOnn, menu completion displays the common prefix of the list of possible completions (which may be empty) before cycling through the list. oouuttppuutt--mmeettaa ((OOffff)) - If set to OOnn, readline will display characters with the eighth - bit set directly rather than as a meta-prefixed escape sequence. - The default is _O_f_f, but readline will set it to _O_n if the locale - contains eight-bit characters. This variable is dependent on - the LLCC__CCTTYYPPEE locale category, and may change if the locale is - changed. + If set to OOnn, rreeaaddlliinnee displays characters with the eighth bit + set directly rather than as a meta-prefixed escape sequence. + The default is _O_f_f, but rreeaaddlliinnee sets it to _O_n if the locale + contains characters whose encodings may include bytes with the + eighth bit set. This variable is dependent on the LLCC__CCTTYYPPEE lo- + cale category, and its value may change if the locale changes. ppaaggee--ccoommpplleettiioonnss ((OOnn)) - If set to OOnn, readline uses an internal _m_o_r_e-like pager to dis- - play a screenful of possible completions at a time. + If set to OOnn, rreeaaddlliinnee uses an internal pager resembling _m_o_r_e(1) + to display a screenful of possible completions at a time. + pprreeffeerr--vviissiibbllee--bbeellll + See bbeellll--ssttyyllee. pprriinntt--ccoommpplleettiioonnss--hhoorriizzoonnttaallllyy ((OOffff)) - If set to OOnn, readline will display completions with matches - sorted horizontally in alphabetical order, rather than down the - screen. + If set to OOnn, rreeaaddlliinnee displays completions with matches sorted + horizontally in alphabetical order, rather than down the screen. rreevveerrtt--aallll--aatt--nneewwlliinnee ((OOffff)) - If set to OOnn, readline will undo all changes to history lines - before returning when aacccceepptt--lliinnee is executed. By default, his- + If set to OOnn, rreeaaddlliinnee will undo all changes to history lines + before returning when executing aacccceepptt--lliinnee. By default, his- tory lines may be modified and retain individual undo lists across calls to rreeaaddlliinnee. + sseeaarrcchh--iiggnnoorree--ccaassee ((OOffff)) + If set to OOnn, rreeaaddlliinnee performs incremental and non-incremental + history list searches in a case-insensitive fashion. sshhooww--aallll--iiff--aammbbiigguuoouuss ((OOffff)) - This alters the default behavior of the completion functions. + This alters the default behavior of the completion functions. If set to OOnn, words which have more than one possible completion cause the matches to be listed immediately instead of ringing the bell. sshhooww--aallll--iiff--uunnmmooddiiffiieedd ((OOffff)) This alters the default behavior of the completion functions in a fashion similar to sshhooww--aallll--iiff--aammbbiigguuoouuss. If set to OOnn, words - which have more than one possible completion without any possi- - ble partial completion (the possible completions don't share a - common prefix) cause the matches to be listed immediately in- + which have more than one possible completion without any possi- + ble partial completion (the possible completions don't share a + common prefix) cause the matches to be listed immediately in- stead of ringing the bell. sshhooww--mmooddee--iinn--pprroommpptt ((OOffff)) - If set to OOnn, add a string to the beginning of the prompt indi- - cating the editing mode: emacs, vi command, or vi insertion. + If set to OOnn, add a string to the beginning of the prompt indi- + cating the editing mode: emacs, vi command, or vi insertion. The mode strings are user-settable (e.g., _e_m_a_c_s_-_m_o_d_e_-_s_t_r_i_n_g). sskkiipp--ccoommpplleetteedd--tteexxtt ((OOffff)) - If set to OOnn, this alters the default completion behavior when - inserting a single match into the line. It's only active when - performing completion in the middle of a word. If enabled, - readline does not insert characters from the completion that - match characters after point in the word being completed, so + If set to OOnn, this alters the default completion behavior when + inserting a single match into the line. It's only active when + performing completion in the middle of a word. If enabled, + rreeaaddlliinnee does not insert characters from the completion that + match characters after point in the word being completed, so portions of the word following the cursor are not duplicated. vvii--ccmmdd--mmooddee--ssttrriinngg ((((ccmmdd)))) - If the _s_h_o_w_-_m_o_d_e_-_i_n_-_p_r_o_m_p_t variable is enabled, this string is + If the _s_h_o_w_-_m_o_d_e_-_i_n_-_p_r_o_m_p_t variable is enabled, this string is displayed immediately before the last line of the primary prompt when vi editing mode is active and in command mode. The value is expanded like a key binding, so the standard set of meta- and - control prefixes and backslash escape sequences is available. - Use the \1 and \2 escapes to begin and end sequences of non- - printing characters, which can be used to embed a terminal con- - trol sequence into the mode string. + control- prefixes and backslash escape sequences is available. + The \1 and \2 escapes begin and end sequences of non-printing + characters, which can be used to embed a terminal control se- + quence into the mode string. vvii--iinnss--mmooddee--ssttrriinngg ((((iinnss)))) - If the _s_h_o_w_-_m_o_d_e_-_i_n_-_p_r_o_m_p_t variable is enabled, this string is + If the _s_h_o_w_-_m_o_d_e_-_i_n_-_p_r_o_m_p_t variable is enabled, this string is displayed immediately before the last line of the primary prompt when vi editing mode is active and in insertion mode. The value is expanded like a key binding, so the standard set of meta- and - control prefixes and backslash escape sequences is available. - Use the \1 and \2 escapes to begin and end sequences of non- - printing characters, which can be used to embed a terminal con- - trol sequence into the mode string. + control- prefixes and backslash escape sequences is available. + The \1 and \2 escapes begin and end sequences of non-printing + characters, which can be used to embed a terminal control se- + quence into the mode string. vviissiibbllee--ssttaattss ((OOffff)) If set to OOnn, a character denoting a file's type as reported by _s_t_a_t(2) is appended to the filename when listing possible com- pletions. RReeaaddlliinnee CCoonnddiittiioonnaall CCoonnssttrruuccttss - Readline implements a facility similar in spirit to the conditional + RReeaaddlliinnee implements a facility similar in spirit to the conditional compilation features of the C preprocessor which allows key bindings and variable settings to be performed as the result of tests. There - are four parser directives used. + are four parser directives available. $$iiff The $$iiff construct allows bindings to be made based on the edit- ing mode, the terminal being used, or the application using - readline. The text of the test, after any comparison operator, - extends to the end of the line; unless otherwise noted, no - characters are required to isolate it. + rreeaaddlliinnee. The text of the test, after any comparison operator, + extends to the end of the line; unless otherwise noted, no char- + acters are required to isolate it. mmooddee The mmooddee== form of the $$iiff directive is used to test - whether readline is in emacs or vi mode. This may be + whether rreeaaddlliinnee is in emacs or vi mode. This may be used in conjunction with the sseett kkeeyymmaapp command, for in- stance, to set bindings in the _e_m_a_c_s_-_s_t_a_n_d_a_r_d and - _e_m_a_c_s_-_c_t_l_x keymaps only if readline is starting out in + _e_m_a_c_s_-_c_t_l_x keymaps only if rreeaaddlliinnee is starting out in emacs mode. tteerrmm The tteerrmm== form may be used to include terminal-specific key bindings, perhaps to bind the key sequences output by the terminal's function keys. The word on the right side of the == is tested against both the full name of the ter- - minal and the portion of the terminal name before the - first --. This allows _s_u_n to match both _s_u_n and _s_u_n_-_c_m_d, - for instance. + minal and the portion of the terminal name before the + first --. This allows _x_t_e_r_m to match both _x_t_e_r_m and + _x_t_e_r_m_-_2_5_6_c_o_l_o_r, for instance. vveerrssiioonn - The vveerrssiioonn test may be used to perform comparisons - against specific readline versions. The vveerrssiioonn expands - to the current readline version. The set of comparison - operators includes ==, (and ====), !!==, <<==, >>==, <<, and >>. - The version number supplied on the right side of the op- - erator consists of a major version number, an optional + The vveerrssiioonn test may be used to perform comparisons + against specific rreeaaddlliinnee versions. The vveerrssiioonn expands + to the current rreeaaddlliinnee version. The set of comparison + operators includes ==, (and ====), !!==, <<==, >>==, <<, and >>. + The version number supplied on the right side of the op- + erator consists of a major version number, an optional decimal point, and an optional minor version (e.g., 77..11). - If the minor version is omitted, it is assumed to be 00. - The operator may be separated from the string vveerrssiioonn and + If the minor version is omitted, it defaults to 00. The + operator may be separated from the string vveerrssiioonn and from the version number argument by whitespace. - aapppplliiccaattiioonn - The aapppplliiccaattiioonn construct is used to include application- - specific settings. Each program using the readline li- - brary sets the _a_p_p_l_i_c_a_t_i_o_n _n_a_m_e, and an initialization + _a_p_p_l_i_c_a_t_i_o_n + The _a_p_p_l_i_c_a_t_i_o_n construct is used to include application- + specific settings. Each program using the rreeaaddlliinnee li- + brary sets the _a_p_p_l_i_c_a_t_i_o_n _n_a_m_e, and an initialization file can test for a particular value. This could be used to bind key sequences to functions useful for a specific program. For instance, the following command adds a key @@ -3624,200 +4060,228 @@ RREEAADDLLIINNEE _v_a_r_i_a_b_l_e The _v_a_r_i_a_b_l_e construct provides simple equality tests for - readline variables and values. The permitted comparison - operators are _=, _=_=, and _!_=. The variable name must be + rreeaaddlliinnee variables and values. The permitted comparison + operators are _=, _=_=, and _!_=. The variable name must be separated from the comparison operator by whitespace; the operator may be separated from the value on the right - hand side by whitespace. Both string and boolean vari- - ables may be tested. Boolean variables must be tested - against the values _o_n and _o_f_f. - - $$eennddiiff This command, as seen in the previous example, terminates an $$iiff - command. + hand side by whitespace. String and boolean variables + may be tested. Boolean variables must be tested against + the values _o_n and _o_f_f. $$eellssee Commands in this branch of the $$iiff directive are executed if the test fails. + $$eennddiiff This command, as seen in the previous example, terminates an $$iiff + command. + $$iinncclluuddee This directive takes a single filename as an argument and reads - commands and bindings from that file. For example, the follow- - ing directive would read _/_e_t_c_/_i_n_p_u_t_r_c: + commands and key bindings from that file. For example, the fol- + lowing directive would read _/_e_t_c_/_i_n_p_u_t_r_c: $$iinncclluuddee _/_e_t_c_/_i_n_p_u_t_r_c SSeeaarrcchhiinngg - Readline provides commands for searching through the command history + RReeaaddlliinnee provides commands for searching through the command history (see HHIISSTTOORRYY below) for lines containing a specified string. There are two search modes: _i_n_c_r_e_m_e_n_t_a_l and _n_o_n_-_i_n_c_r_e_m_e_n_t_a_l. Incremental searches begin before the user has finished typing the - search string. As each character of the search string is typed, read- - line displays the next entry from the history matching the string typed - so far. An incremental search requires only as many characters as - needed to find the desired history entry. The characters present in - the value of the iisseeaarrcchh--tteerrmmiinnaattoorrss variable are used to terminate an - incremental search. If that variable has not been assigned a value the - Escape and Control-J characters will terminate an incremental search. - Control-G will abort an incremental search and restore the original - line. When the search is terminated, the history entry containing the - search string becomes the current line. - - To find other matching entries in the history list, type Control-S or - Control-R as appropriate. This will search backward or forward in the - history for the next entry matching the search string typed so far. - Any other key sequence bound to a readline command will terminate the - search and execute that command. For instance, a _n_e_w_l_i_n_e will termi- - nate the search and accept the line, thereby executing the command from - the history list. - - Readline remembers the last incremental search string. If two Control- - Rs are typed without any intervening characters defining a new search - string, any remembered search string is used. + search string. As each character of the search string is typed, rreeaadd-- + lliinnee displays the next entry from the history matching the string typed + so far. An incremental search requires only as many characters as + needed to find the desired history entry. When using emacs editing + mode, type CC--rr to search backward in the history for a particular + string. Typing CC--ss searches forward through the history. The charac- + ters present in the value of the iisseeaarrcchh--tteerrmmiinnaattoorrss variable are used + to terminate an incremental search. If that variable has not been as- + signed a value, _E_S_C and CC--jj terminate an incremental search. CC--gg + aborts an incremental search and restores the original line. When the + search is terminated, the history entry containing the search string + becomes the current line. + + To find other matching entries in the history list, type CC--rr or CC--ss as + appropriate. This searches backward or forward in the history for the + next entry matching the search string typed so far. Any other key se- + quence bound to a rreeaaddlliinnee command terminates the search and executes + that command. For instance, a newline terminates the search and ac- + cepts the line, thereby executing the command from the history list. A + movement command will terminate the search, make the last line found + the current line, and begin editing. + + RReeaaddlliinnee remembers the last incremental search string. If two CC--rrs are + typed without any intervening characters defining a new search string, + rreeaaddlliinnee uses any remembered search string. Non-incremental searches read the entire search string before starting - to search for matching history lines. The search string may be typed + to search for matching history entries. The search string may be typed by the user or be part of the contents of the current line. RReeaaddlliinnee CCoommmmaanndd NNaammeess - The following is a list of the names of the commands and the default + The following is a list of the names of the commands and the default key sequences to which they are bound. Command names without an accom- - panying key sequence are unbound by default. In the following descrip- - tions, _p_o_i_n_t refers to the current cursor position, and _m_a_r_k refers to - a cursor position saved by the sseett--mmaarrkk command. The text between the - point and mark is referred to as the _r_e_g_i_o_n. + panying key sequence are unbound by default. + + In the following descriptions, _p_o_i_n_t refers to the current cursor posi- + tion, and _m_a_r_k refers to a cursor position saved by the sseett--mmaarrkk com- + mand. The text between the point and mark is referred to as the _r_e_- + _g_i_o_n. RReeaaddlliinnee has the concept of an _a_c_t_i_v_e _r_e_g_i_o_n: when the region is + active, rreeaaddlliinnee redisplay highlights the region using the value of the + aaccttiivvee--rreeggiioonn--ssttaarrtt--ccoolloorr variable. The eennaabbllee--aaccttiivvee--rreeggiioonn rreeaaddlliinnee + variable turns this on and off. Several commands set the region to ac- + tive; those are noted below. CCoommmmaannddss ffoorr MMoovviinngg bbeeggiinnnniinngg--ooff--lliinnee ((CC--aa)) - Move to the start of the current line. + Move to the start of the current line. This may also be bound + to the Home key on some keyboards. eenndd--ooff--lliinnee ((CC--ee)) - Move to the end of the line. + Move to the end of the line. This may also be bound to the End + key on some keyboards. ffoorrwwaarrdd--cchhaarr ((CC--ff)) - Move forward a character. + Move forward a character. This may also be bound to the right + arrow key on some keyboards. bbaacckkwwaarrdd--cchhaarr ((CC--bb)) - Move back a character. + Move back a character. This may also be bound to the left arrow + key on some keyboards. ffoorrwwaarrdd--wwoorrdd ((MM--ff)) Move forward to the end of the next word. Words are composed of alphanumeric characters (letters and digits). bbaacckkwwaarrdd--wwoorrdd ((MM--bb)) Move back to the start of the current or previous word. Words are composed of alphanumeric characters (letters and digits). - sshheellll--ffoorrwwaarrdd--wwoorrdd + sshheellll--ffoorrwwaarrdd--wwoorrdd ((MM--CC--ff)) Move forward to the end of the next word. Words are delimited by non-quoted shell metacharacters. - sshheellll--bbaacckkwwaarrdd--wwoorrdd + sshheellll--bbaacckkwwaarrdd--wwoorrdd ((MM--CC--bb)) Move back to the start of the current or previous word. Words are delimited by non-quoted shell metacharacters. pprreevviioouuss--ssccrreeeenn--lliinnee Attempt to move point to the same physical screen column on the - previous physical screen line. This will not have the desired - effect if the current readline line does not take up more than + previous physical screen line. This will not have the desired + effect if the current rreeaaddlliinnee line does not take up more than one physical line or if point is not greater than the length of the prompt plus the screen width. nneexxtt--ssccrreeeenn--lliinnee Attempt to move point to the same physical screen column on the - next physical screen line. This will not have the desired effect - if the current readline line does not take up more than one - physical line or if the length of the current readline line is + next physical screen line. This will not have the desired ef- + fect if the current rreeaaddlliinnee line does not take up more than one + physical line or if the length of the current rreeaaddlliinnee line is not greater than the length of the prompt plus the screen width. cclleeaarr--ddiissppllaayy ((MM--CC--ll)) - Clear the screen and, if possible, the terminal's scrollback - buffer, then redraw the current line, leaving the current line + Clear the screen and, if possible, the terminal's scrollback + buffer, then redraw the current line, leaving the current line at the top of the screen. cclleeaarr--ssccrreeeenn ((CC--ll)) Clear the screen, then redraw the current line, leaving the cur- - rent line at the top of the screen. With an argument, refresh - the current line without clearing the screen. + rent line at the top of the screen. With a numeric argument, + refresh the current line without clearing the screen. rreeddrraaww--ccuurrrreenntt--lliinnee Refresh the current line. CCoommmmaannddss ffoorr MMaanniippuullaattiinngg tthhee HHiissttoorryy aacccceepptt--lliinnee ((NNeewwlliinnee,, RReettuurrnn)) Accept the line regardless of where the cursor is. If this line - is non-empty, add it to the history list according to the state - of the HHIISSTTCCOONNTTRROOLL variable. If the line is a modified history - line, then restore the history line to its original state. + is non-empty, add it to the history list according to the state + of the HHIISSTTCCOONNTTRROOLL and HHIISSTTIIGGNNOORREE variables. If the line is a + modified history line, restore the history line to its original + state. pprreevviioouuss--hhiissttoorryy ((CC--pp)) Fetch the previous command from the history list, moving back in - the list. + the list. This may also be bound to the up arrow key on some + keyboards. nneexxtt--hhiissttoorryy ((CC--nn)) Fetch the next command from the history list, moving forward in - the list. + the list. This may also be bound to the down arrow key on some + keyboards. bbeeggiinnnniinngg--ooff--hhiissttoorryy ((MM--<<)) Move to the first line in the history. eenndd--ooff--hhiissttoorryy ((MM-->>)) - Move to the end of the input history, i.e., the line currently + Move to the end of the input history, i.e., the line currently being entered. ooppeerraattee--aanndd--ggeett--nneexxtt ((CC--oo)) - Accept the current line for execution and fetch the next line - relative to the current line from the history for editing. A - numeric argument, if supplied, specifies the history entry to - use instead of the current line. + Accept the current line for execution as if a newline had been + entered, and fetch the next line relative to the current line + from the history for editing. A numeric argument, if supplied, + specifies the history entry to use instead of the current line. ffeettcchh--hhiissttoorryy - With a numeric argument, fetch that entry from the history list + With a numeric argument, fetch that entry from the history list and make it the current line. Without an argument, move back to the first entry in the history list. rreevveerrssee--sseeaarrcchh--hhiissttoorryy ((CC--rr)) - Search backward starting at the current line and moving `up' + Search backward starting at the current line and moving "up" through the history as necessary. This is an incremental - search. + search. This command sets the region to the matched text and + activates the region. ffoorrwwaarrdd--sseeaarrcchh--hhiissttoorryy ((CC--ss)) - Search forward starting at the current line and moving `down' - through the history as necessary. This is an incremental - search. + Search forward starting at the current line and moving "down" + through the history as necessary. This is an incremental + search. This command sets the region to the matched text and + activates the region. nnoonn--iinnccrreemmeennttaall--rreevveerrssee--sseeaarrcchh--hhiissttoorryy ((MM--pp)) Search backward through the history starting at the current line - using a non-incremental search for a string supplied by the - user. + using a non-incremental search for a string supplied by the + user. The search string may match anywhere in a history line. nnoonn--iinnccrreemmeennttaall--ffoorrwwaarrdd--sseeaarrcchh--hhiissttoorryy ((MM--nn)) - Search forward through the history using a non-incremental - search for a string supplied by the user. - hhiissttoorryy--sseeaarrcchh--ffoorrwwaarrdd - Search forward through the history for the string of characters - between the start of the current line and the point. This is a - non-incremental search. + Search forward through the history using a non-incremental + search for a string supplied by the user. The search string may + match anywhere in a history line. hhiissttoorryy--sseeaarrcchh--bbaacckkwwaarrdd Search backward through the history for the string of characters - between the start of the current line and the point. This is a - non-incremental search. + between the start of the current line and the point. The search + string must match at the beginning of a history line. This is a + non-incremental search. This may be bound to the Page Up key on + some keyboards. + hhiissttoorryy--sseeaarrcchh--ffoorrwwaarrdd + Search forward through the history for the string of characters + between the start of the current line and the point. The search + string must match at the beginning of a history line. This is a + non-incremental search. This may be bound to the Page Down key + on some keyboards. hhiissttoorryy--ssuubbssttrriinngg--sseeaarrcchh--bbaacckkwwaarrdd Search backward through the history for the string of characters - between the start of the current line and the current cursor po- - sition (the _p_o_i_n_t). The search string may match anywhere in a - history line. This is a non-incremental search. + between the start of the current line and the point. The search + string may match anywhere in a history line. This is a non-in- + cremental search. hhiissttoorryy--ssuubbssttrriinngg--sseeaarrcchh--ffoorrwwaarrdd - Search forward through the history for the string of characters + Search forward through the history for the string of characters between the start of the current line and the point. The search string may match anywhere in a history line. This is a non-in- cremental search. yyaannkk--nntthh--aarrgg ((MM--CC--yy)) Insert the first argument to the previous command (usually the second word on the previous line) at point. With an argument _n, - insert the _nth word from the previous command (the words in the - previous command begin with word 0). A negative argument in- - serts the _nth word from the end of the previous command. Once - the argument _n is computed, the argument is extracted as if the - "!_n" history expansion had been specified. + insert the _nth word from the previous command (the words in the + previous command begin with word 0). A negative argument in- + serts the _nth word from the end of the previous command. Once + the argument _n is computed, this uses the history expansion fa- + cilities to extract the _nth word, as if the "!_n" history expan- + sion had been specified. yyaannkk--llaasstt--aarrgg ((MM--..,, MM--__)) Insert the last argument to the previous command (the last word of the previous history entry). With a numeric argument, behave - exactly like yyaannkk--nntthh--aarrgg. Successive calls to yyaannkk--llaasstt--aarrgg - move back through the history list, inserting the last word (or - the word specified by the argument to the first call) of each + exactly like yyaannkk--nntthh--aarrgg. Successive calls to yyaannkk--llaasstt--aarrgg + move back through the history list, inserting the last word (or + the word specified by the argument to the first call) of each line in turn. Any numeric argument supplied to these successive calls determines the direction to move through the history. A negative argument switches the direction through the history - (back or forward). The history expansion facilities are used to - extract the last word, as if the "!$" history expansion had been - specified. + (back or forward). This uses the history expansion facilities + to extract the last word, as if the "!$" history expansion had + been specified. sshheellll--eexxppaanndd--lliinnee ((MM--CC--ee)) - Expand the line as the shell does. This performs alias and his- - tory expansion as well as all of the shell word expansions. See - HHIISSTTOORRYY EEXXPPAANNSSIIOONN below for a description of history expansion. + Expand the line by performing shell word expansions. This per- + forms alias and history expansion, $$'_s_t_r_i_n_g' and $$"_s_t_r_i_n_g" quot- + ing, tilde expansion, parameter and variable expansion, arith- + metic expansion, command and process substitution, word split- + ting, and quote removal. An explicit argument suppresses com- + mand and process substitution. See HHIISSTTOORRYY EEXXPPAANNSSIIOONN below for + a description of history expansion. hhiissttoorryy--eexxppaanndd--lliinnee ((MM--^^)) - Perform history expansion on the current line. See HHIISSTTOORRYY EEXX-- + Perform history expansion on the current line. See HHIISSTTOORRYY EEXX-- PPAANNSSIIOONN below for a description of history expansion. mmaaggiicc--ssppaaccee - Perform history expansion on the current line and insert a + Perform history expansion on the current line and insert a space. See HHIISSTTOORRYY EEXXPPAANNSSIIOONN below for a description of history expansion. aalliiaass--eexxppaanndd--lliinnee @@ -3834,19 +4298,20 @@ RREEAADDLLIINNEE CCoommmmaannddss ffoorr CChhaannggiinngg TTeexxtt _e_n_d_-_o_f_-_f_i_l_e ((uussuuaallllyy CC--dd)) - The character indicating end-of-file as set, for example, by - ``stty''. If this character is read when there are no charac- - ters on the line, and point is at the beginning of the line, - readline interprets it as the end of input and returns EEOOFF. + The character indicating end-of-file as set, for example, by + _s_t_t_y(1). If this character is read when there are no characters + on the line, and point is at the beginning of the line, rreeaaddlliinnee + interprets it as the end of input and returns EEOOFF. ddeelleettee--cchhaarr ((CC--dd)) Delete the character at point. If this function is bound to the same character as the tty EEOOFF character, as CC--dd commonly is, see - above for the effects. + above for the effects. This may also be bound to the Delete key + on some keyboards. bbaacckkwwaarrdd--ddeelleettee--cchhaarr ((RRuubboouutt)) - Delete the character behind the cursor. When given a numeric + Delete the character behind the cursor. When given a numeric argument, save the deleted text on the kill ring. ffoorrwwaarrdd--bbaacckkwwaarrdd--ddeelleettee--cchhaarr - Delete the character under the cursor, unless the cursor is at + Delete the character under the cursor, unless the cursor is at the end of the line, in which case the character behind the cur- sor is deleted. qquuootteedd--iinnsseerrtt ((CC--qq,, CC--vv)) @@ -3854,17 +4319,33 @@ RREEAADDLLIINNEE to insert characters like CC--qq, for example. ttaabb--iinnsseerrtt ((CC--vv TTAABB)) Insert a tab character. - sseellff--iinnsseerrtt ((aa,, bb,, AA,, 11,, !!,, ......)) + sseellff--iinnsseerrtt ((aa,, bb,, AA,, 11,, !!,, ...)) Insert the character typed. + bbrraacckkeetteedd--ppaassttee--bbeeggiinn + This function is intended to be bound to the "bracketed paste" + escape sequence sent by some terminals, and such a binding is + assigned by default. It allows rreeaaddlliinnee to insert the pasted + text as a single unit without treating each character as if it + had been read from the keyboard. The pasted characters are in- + serted as if each one was bound to sseellff--iinnsseerrtt instead of exe- + cuting any editing commands. + Bracketed paste sets the region to the inserted text and acti- + vates the region. ttrraannssppoossee--cchhaarrss ((CC--tt)) - Drag the character before point forward over the character at - point, moving point forward as well. If point is at the end of - the line, then this transposes the two characters before point. + Drag the character before point forward over the character at + point, moving point forward as well. If point is at the end of + the line, then this transposes the two characters before point. Negative arguments have no effect. ttrraannssppoossee--wwoorrddss ((MM--tt)) - Drag the word before point past the word after point, moving - point over that word as well. If point is at the end of the + Drag the word before point past the word after point, moving + point past that word as well. If point is at the end of the line, this transposes the last two words on the line. + sshheellll--ttrraannssppoossee--wwoorrddss ((MM--CC--tt)) + Drag the word before point past the word after point, moving + point past that word as well. If the insertion point is at the + end of the line, this transposes the last two words on the line. + Word boundaries are the same as sshheellll--ffoorrwwaarrdd--wwoorrdd and + sshheellll--bbaacckkwwaarrdd--wwoorrdd. uuppccaassee--wwoorrdd ((MM--uu)) Uppercase the current (or following) word. With a negative ar- gument, uppercase the previous word, but do not move point. @@ -3875,54 +4356,60 @@ RREEAADDLLIINNEE Capitalize the current (or following) word. With a negative ar- gument, capitalize the previous word, but do not move point. oovveerrwwrriittee--mmooddee - Toggle overwrite mode. With an explicit positive numeric argu- + Toggle overwrite mode. With an explicit positive numeric argu- ment, switches to overwrite mode. With an explicit non-positive numeric argument, switches to insert mode. This command affects - only eemmaaccss mode; vvii mode does overwrite differently. Each call - to _r_e_a_d_l_i_n_e_(_) starts in insert mode. In overwrite mode, charac- - ters bound to sseellff--iinnsseerrtt replace the text at point rather than - pushing the text to the right. Characters bound to bbaacckk-- - wwaarrdd--ddeelleettee--cchhaarr replace the character before point with a - space. By default, this command is unbound. + only eemmaaccss mode; vvii mode does overwrite differently. Each call + to _r_e_a_d_l_i_n_e_(_) starts in insert mode. + In overwrite mode, characters bound to sseellff--iinnsseerrtt replace the + text at point rather than pushing the text to the right. Char- + acters bound to bbaacckkwwaarrdd--ddeelleettee--cchhaarr replace the character be- + fore point with a space. By default, this command is unbound, + but may be bound to the Insert key on some keyboards. KKiilllliinngg aanndd YYaannkkiinngg kkiillll--lliinnee ((CC--kk)) - Kill the text from point to the end of the line. + Kill the text from point to the end of the current line. With a + negative numeric argument, kill backward from the cursor to the + beginning of the line. bbaacckkwwaarrdd--kkiillll--lliinnee ((CC--xx RRuubboouutt)) - Kill backward to the beginning of the line. + Kill backward to the beginning of the current line. With a neg- + ative numeric argument, kill forward from the cursor to the end + of the line. uunniixx--lliinnee--ddiissccaarrdd ((CC--uu)) - Kill backward from point to the beginning of the line. The - killed text is saved on the kill-ring. + Kill backward from point to the beginning of the line, saving + the killed text on the kill-ring. kkiillll--wwhhoollee--lliinnee - Kill all characters on the current line, no matter where point + Kill all characters on the current line, no matter where point is. kkiillll--wwoorrdd ((MM--dd)) - Kill from point to the end of the current word, or if between - words, to the end of the next word. Word boundaries are the + Kill from point to the end of the current word, or if between + words, to the end of the next word. Word boundaries are the same as those used by ffoorrwwaarrdd--wwoorrdd. bbaacckkwwaarrdd--kkiillll--wwoorrdd ((MM--RRuubboouutt)) - Kill the word behind point. Word boundaries are the same as + Kill the word behind point. Word boundaries are the same as those used by bbaacckkwwaarrdd--wwoorrdd. - sshheellll--kkiillll--wwoorrdd - Kill from point to the end of the current word, or if between - words, to the end of the next word. Word boundaries are the + sshheellll--kkiillll--wwoorrdd ((MM--CC--dd)) + Kill from point to the end of the current word, or if between + words, to the end of the next word. Word boundaries are the same as those used by sshheellll--ffoorrwwaarrdd--wwoorrdd. sshheellll--bbaacckkwwaarrdd--kkiillll--wwoorrdd - Kill the word behind point. Word boundaries are the same as + Kill the word behind point. Word boundaries are the same as those used by sshheellll--bbaacckkwwaarrdd--wwoorrdd. uunniixx--wwoorrdd--rruubboouutt ((CC--ww)) - Kill the word behind point, using white space as a word bound- - ary. The killed text is saved on the kill-ring. + Kill the word behind point, using white space as a word bound- + ary, saving the killed text on the kill-ring. uunniixx--ffiilleennaammee--rruubboouutt - Kill the word behind point, using white space and the slash - character as the word boundaries. The killed text is saved on - the kill-ring. + Kill the word behind point, using white space and the slash + character as the word boundaries, saving the killed text on the + kill-ring. ddeelleettee--hhoorriizzoonnttaall--ssppaaccee ((MM--\\)) Delete all spaces and tabs around point. kkiillll--rreeggiioonn Kill the text in the current region. ccooppyy--rreeggiioonn--aass--kkiillll - Copy the text in the region to the kill buffer. + Copy the text in the region to the kill buffer, so it can be + yanked immediately. ccooppyy--bbaacckkwwaarrdd--wwoorrdd Copy the word before point to the kill buffer. The word bound- aries are the same as bbaacckkwwaarrdd--wwoorrdd. @@ -3936,7 +4423,7 @@ RREEAADDLLIINNEE ing yyaannkk or yyaannkk--ppoopp. NNuummeerriicc AArrgguummeennttss - ddiiggiitt--aarrgguummeenntt ((MM--00,, MM--11,, ......,, MM----)) + ddiiggiitt--aarrgguummeenntt ((MM--00,, MM--11,, ...,, MM----)) Add this digit to the argument already accumulating, or start a new argument. M-- starts a negative argument. uunniivveerrssaall--aarrgguummeenntt @@ -3946,83 +4433,126 @@ RREEAADDLLIINNEE lowed by digits, executing uunniivveerrssaall--aarrgguummeenntt again ends the nu- meric argument, but is otherwise ignored. As a special case, if this command is immediately followed by a character that is nei- - ther a digit nor minus sign, the argument count for the next - command is multiplied by four. The argument count is initially - one, so executing this function the first time makes the argu- + ther a digit nor minus sign, the argument count for the next + command is multiplied by four. The argument count is initially + one, so executing this function the first time makes the argu- ment count four, a second time makes the argument count sixteen, and so on. CCoommpplleettiinngg ccoommpplleettee ((TTAABB)) Attempt to perform completion on the text before point. BBaasshh - attempts completion treating the text as a variable (if the text - begins with $$), username (if the text begins with ~~), hostname - (if the text begins with @@), or command (including aliases and - functions) in turn. If none of these produces a match, filename - completion is attempted. + attempts completion by first checking for any programmable com- + pletions for the command word (see PPrrooggrraammmmaabbllee CCoommpplleettiioonn be- + low), otherwise treating the text as a variable (if the text be- + gins with $$), username (if the text begins with ~~), hostname (if + the text begins with @@), or command (including aliases, func- + tions, and builtins) in turn. If none of these produces a + match, it falls back to filename completion. ppoossssiibbllee--ccoommpplleettiioonnss ((MM--??)) - List the possible completions of the text before point. + List the possible completions of the text before point. When + displaying completions, rreeaaddlliinnee sets the number of columns used + for display to the value of ccoommpplleettiioonn--ddiissppllaayy--wwiiddtthh, the value + of the shell variable CCOOLLUUMMNNSS, or the screen width, in that or- + der. iinnsseerrtt--ccoommpplleettiioonnss ((MM--**)) - Insert all completions of the text before point that would have - been generated by ppoossssiibbllee--ccoommpplleettiioonnss. + Insert all completions of the text before point that would have + been generated by ppoossssiibbllee--ccoommpplleettiioonnss, separated by a space. mmeennuu--ccoommpplleettee - Similar to ccoommpplleettee, but replaces the word to be completed with - a single match from the list of possible completions. Repeated - execution of mmeennuu--ccoommpplleettee steps through the list of possible - completions, inserting each match in turn. At the end of the - list of completions, the bell is rung (subject to the setting of - bbeellll--ssttyyllee) and the original text is restored. An argument of _n - moves _n positions forward in the list of matches; a negative ar- - gument may be used to move backward through the list. This com- + Similar to ccoommpplleettee, but replaces the word to be completed with + a single match from the list of possible completions. Repeat- + edly executing mmeennuu--ccoommpplleettee steps through the list of possible + completions, inserting each match in turn. At the end of the + list of completions, mmeennuu--ccoommpplleettee rings the bell (subject to + the setting of bbeellll--ssttyyllee) and restores the original text. An + argument of _n moves _n positions forward in the list of matches; + a negative argument moves backward through the list. This com- mand is intended to be bound to TTAABB, but is unbound by default. mmeennuu--ccoommpplleettee--bbaacckkwwaarrdd - Identical to mmeennuu--ccoommpplleettee, but moves backward through the list - of possible completions, as if mmeennuu--ccoommpplleettee had been given a + Identical to mmeennuu--ccoommpplleettee, but moves backward through the list + of possible completions, as if mmeennuu--ccoommpplleettee had been given a negative argument. This command is unbound by default. + eexxppoorrtt--ccoommpplleettiioonnss + Perform completion on the word before point as described above + and write the list of possible completions to rreeaaddlliinnee's output + stream using the following format, writing information on sepa- + rate lines: + + +o the number of matches _N; + +o the word being completed; + +o _S:_E, where _S and _E are the start and end offsets of the + word in the rreeaaddlliinnee line buffer; then + +o each match, one per line + + If there are no matches, the first line will be "0", and this + command does not print any output after the _S:_E. If there is + only a single match, this prints a single line containing it. + If there is more than one match, this prints the common prefix + of the matches, which may be empty, on the first line after the + _S:_E, then the matches on subsequent lines. In this case, _N will + include the first line with the common prefix. + + The user or application should be able to accommodate the possi- + bility of a blank line. The intent is that the user or applica- + tion reads _N lines after the line containing _S:_E to obtain the + match list. This command is unbound by default. + ddeelleettee--cchhaarr--oorr--lliisstt - Deletes the character under the cursor if not at the beginning - or end of the line (like ddeelleettee--cchhaarr). If at the end of the - line, behaves identically to ppoossssiibbllee--ccoommpplleettiioonnss. This command - is unbound by default. + Deletes the character under the cursor if not at the beginning + or end of the line (like ddeelleettee--cchhaarr). At the end of the line, + it behaves identically to ppoossssiibbllee--ccoommpplleettiioonnss. This command is + unbound by default. + ccoommpplleettee--ffiilleennaammee ((MM--//)) Attempt filename completion on the text before point. + ppoossssiibbllee--ffiilleennaammee--ccoommpplleettiioonnss ((CC--xx //)) List the possible completions of the text before point, treating it as a filename. + ccoommpplleettee--uusseerrnnaammee ((MM--~~)) - Attempt completion on the text before point, treating it as a + Attempt completion on the text before point, treating it as a username. + ppoossssiibbllee--uusseerrnnaammee--ccoommpplleettiioonnss ((CC--xx ~~)) List the possible completions of the text before point, treating it as a username. + ccoommpplleettee--vvaarriiaabbllee ((MM--$$)) Attempt completion on the text before point, treating it as a shell variable. + ppoossssiibbllee--vvaarriiaabbllee--ccoommpplleettiioonnss ((CC--xx $$)) List the possible completions of the text before point, treating it as a shell variable. + ccoommpplleettee--hhoossttnnaammee ((MM--@@)) - Attempt completion on the text before point, treating it as a + Attempt completion on the text before point, treating it as a hostname. + ppoossssiibbllee--hhoossttnnaammee--ccoommpplleettiioonnss ((CC--xx @@)) List the possible completions of the text before point, treating it as a hostname. + ccoommpplleettee--ccoommmmaanndd ((MM--!!)) Attempt completion on the text before point, treating it as a command name. Command completion attempts to match the text against aliases, reserved words, shell functions, shell builtins, and finally executable filenames, in that order. + ppoossssiibbllee--ccoommmmaanndd--ccoommpplleettiioonnss ((CC--xx !!)) List the possible completions of the text before point, treating it as a command name. + ddyynnaammiicc--ccoommpplleettee--hhiissttoorryy ((MM--TTAABB)) - Attempt completion on the text before point, comparing the text - against lines from the history list for possible completion - matches. + Attempt completion on the text before point, comparing the text + against history list entries for possible completion matches. + ddaabbbbrreevv--eexxppaanndd Attempt menu completion on the text before point, comparing the text against lines from the history list for possible completion matches. + ccoommpplleettee--iinnttoo--bbrraacceess ((MM--{{)) Perform filename completion and insert the list of possible com- pletions enclosed within braces so the list is available to the @@ -4036,21 +4566,21 @@ RREEAADDLLIINNEE Stop saving the characters typed into the current keyboard macro and store the definition. ccaallll--llaasstt--kkbbdd--mmaaccrroo ((CC--xx ee)) - Re-execute the last keyboard macro defined, by making the char- + Re-execute the last keyboard macro defined, by making the char- acters in the macro appear as if typed at the keyboard. pprriinntt--llaasstt--kkbbdd--mmaaccrroo (()) - Print the last keyboard macro defined in a format suitable for + Print the last keyboard macro defined in a format suitable for the _i_n_p_u_t_r_c file. MMiisscceellllaanneeoouuss rree--rreeaadd--iinniitt--ffiillee ((CC--xx CC--rr)) - Read in the contents of the _i_n_p_u_t_r_c file, and incorporate any + Read in the contents of the _i_n_p_u_t_r_c file, and incorporate any bindings or variable assignments found there. aabboorrtt ((CC--gg)) - Abort the current editing command and ring the terminal's bell + Abort the current editing command and ring the terminal's bell (subject to the setting of bbeellll--ssttyyllee). - ddoo--lloowweerrccaassee--vveerrssiioonn ((MM--AA,, MM--BB,, MM--_x,, ......)) - If the metafied character _x is uppercase, run the command that + ddoo--lloowweerrccaassee--vveerrssiioonn ((MM--AA,, MM--BB,, MM--_x,, ...)) + If the metafied character _x is uppercase, run the command that is bound to the corresponding metafied lowercase character. The behavior is undefined if _x is already lowercase. pprreeffiixx--mmeettaa ((EESSCC)) @@ -4065,323 +4595,370 @@ RREEAADDLLIINNEE Perform tilde expansion on the current word. sseett--mmaarrkk ((CC--@@,, MM--<>)) Set the mark to the point. If a numeric argument is supplied, - the mark is set to that position. + set the mark to that position. eexxcchhaannggee--ppooiinntt--aanndd--mmaarrkk ((CC--xx CC--xx)) - Swap the point with the mark. The current cursor position is - set to the saved position, and the old cursor position is saved - as the mark. + Swap the point with the mark. Set the current cursor position + to the saved position, then set the mark to the old cursor posi- + tion. cchhaarraacctteerr--sseeaarrcchh ((CC--]])) - A character is read and point is moved to the next occurrence of - that character. A negative argument searches for previous oc- - currences. + Read a character and move point to the next occurrence of that + character. A negative argument searches for previous occur- + rences. cchhaarraacctteerr--sseeaarrcchh--bbaacckkwwaarrdd ((MM--CC--]])) - A character is read and point is moved to the previous occur- - rence of that character. A negative argument searches for sub- - sequent occurrences. + Read a character and move point to the previous occurrence of + that character. A negative argument searches for subsequent oc- + currences. sskkiipp--ccssii--sseeqquueennccee Read enough characters to consume a multi-key sequence such as - those defined for keys like Home and End. Such sequences begin - with a Control Sequence Indicator (CSI), usually ESC-[. If this - sequence is bound to "\[", keys producing such sequences will - have no effect unless explicitly bound to a readline command, - instead of inserting stray characters into the editing buffer. - This is unbound by default, but usually bound to ESC-[. + those defined for keys like Home and End. CSI sequences begin + with a Control Sequence Indicator (CSI), usually _E_S_C _[. If this + sequence is bound to "\e[", keys producing CSI sequences have no + effect unless explicitly bound to a rreeaaddlliinnee command, instead of + inserting stray characters into the editing buffer. This is un- + bound by default, but usually bound to _E_S_C _[. iinnsseerrtt--ccoommmmeenntt ((MM--##)) - Without a numeric argument, the value of the readline ccoomm-- - mmeenntt--bbeeggiinn variable is inserted at the beginning of the current - line. If a numeric argument is supplied, this command acts as a - toggle: if the characters at the beginning of the line do not - match the value of ccoommmmeenntt--bbeeggiinn, the value is inserted, other- - wise the characters in ccoommmmeenntt--bbeeggiinn are deleted from the begin- - ning of the line. In either case, the line is accepted as if a - newline had been typed. The default value of ccoommmmeenntt--bbeeggiinn - causes this command to make the current line a shell comment. - If a numeric argument causes the comment character to be re- - moved, the line will be executed by the shell. + Without a numeric argument, insert the value of the rreeaaddlliinnee + ccoommmmeenntt--bbeeggiinn variable at the beginning of the current line. If + a numeric argument is supplied, this command acts as a toggle: + if the characters at the beginning of the line do not match the + value of ccoommmmeenntt--bbeeggiinn, insert the value; otherwise delete the + characters in ccoommmmeenntt--bbeeggiinn from the beginning of the line. In + either case, the line is accepted as if a newline had been + typed. The default value of ccoommmmeenntt--bbeeggiinn causes this command + to make the current line a shell comment. If a numeric argument + causes the comment character to be removed, the line will be ex- + ecuted by the shell. ssppeellll--ccoorrrreecctt--wwoorrdd ((CC--xx ss)) - Perform spelling correction on the current word, treating it as - a directory or filename, in the same way as the ccddssppeellll shell - option. Word boundaries are the same as those used by + Perform spelling correction on the current word, treating it as + a directory or filename, in the same way as the ccddssppeellll shell + option. Word boundaries are the same as those used by sshheellll--ffoorrwwaarrdd--wwoorrdd. gglloobb--ccoommpplleettee--wwoorrdd ((MM--gg)) - The word before point is treated as a pattern for pathname ex- - pansion, with an asterisk implicitly appended. This pattern is - used to generate a list of matching filenames for possible com- - pletions. + Treat the word before point as a pattern for pathname expansion, + with an asterisk implicitly appended, then use the pattern to + generate a list of matching file names for possible completions. gglloobb--eexxppaanndd--wwoorrdd ((CC--xx **)) - The word before point is treated as a pattern for pathname ex- - pansion, and the list of matching filenames is inserted, replac- - ing the word. If a numeric argument is supplied, an asterisk is - appended before pathname expansion. + Treat the word before point as a pattern for pathname expansion, + and insert the list of matching file names, replacing the word. + If a numeric argument is supplied, append a ** before pathname + expansion. gglloobb--lliisstt--eexxppaannssiioonnss ((CC--xx gg)) - The list of expansions that would have been generated by - gglloobb--eexxppaanndd--wwoorrdd is displayed, and the line is redrawn. If a - numeric argument is supplied, an asterisk is appended before - pathname expansion. + Display the list of expansions that would have been generated by + gglloobb--eexxppaanndd--wwoorrdd and redisplay the line. If a numeric argument + is supplied, append a ** before pathname expansion. dduummpp--ffuunnccttiioonnss - Print all of the functions and their key bindings to the read- - line output stream. If a numeric argument is supplied, the out- - put is formatted in such a way that it can be made part of an + Print all of the functions and their key bindings to the rreeaadd-- + lliinnee output stream. If a numeric argument is supplied, the out- + put is formatted in such a way that it can be made part of an _i_n_p_u_t_r_c file. dduummpp--vvaarriiaabblleess - Print all of the settable readline variables and their values to - the readline output stream. If a numeric argument is supplied, + Print all of the settable rreeaaddlliinnee variables and their values to + the rreeaaddlliinnee output stream. If a numeric argument is supplied, the output is formatted in such a way that it can be made part of an _i_n_p_u_t_r_c file. dduummpp--mmaaccrrooss - Print all of the readline key sequences bound to macros and the - strings they output. If a numeric argument is supplied, the - output is formatted in such a way that it can be made part of an - _i_n_p_u_t_r_c file. + Print all of the rreeaaddlliinnee key sequences bound to macros and the + strings they output to the rreeaaddlliinnee output stream. If a numeric + argument is supplied, the output is formatted in such a way that + it can be made part of an _i_n_p_u_t_r_c file. + eexxeeccuuttee--nnaammeedd--ccoommmmaanndd ((MM--xx)) + Read a bindable rreeaaddlliinnee command name from the input and execute + the function to which it's bound, as if the key sequence to + which it was bound appeared in the input. If this function is + supplied with a numeric argument, it passes that argument to the + function it executes. ddiissppllaayy--sshheellll--vveerrssiioonn ((CC--xx CC--vv)) Display version information about the current instance of bbaasshh. PPrrooggrraammmmaabbllee CCoommpplleettiioonn - When word completion is attempted for an argument to a command for - which a completion specification (a _c_o_m_p_s_p_e_c) has been defined using - the ccoommpplleettee builtin (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below), the program- - mable completion facilities are invoked. - - First, the command name is identified. If the command word is the - empty string (completion attempted at the beginning of an empty line), - any compspec defined with the --EE option to ccoommpplleettee is used. If a - compspec has been defined for that command, the compspec is used to - generate the list of possible completions for the word. If the command - word is a full pathname, a compspec for the full pathname is searched - for first. If no compspec is found for the full pathname, an attempt - is made to find a compspec for the portion following the final slash. - If those searches do not result in a compspec, any compspec defined - with the --DD option to ccoommpplleettee is used as the default. If there is no - default compspec, bbaasshh attempts alias expansion on the command word as + When a user attempts word completion for a command or an argument to a + command for which a completion specification (a _c_o_m_p_s_p_e_c) has been de- + fined using the ccoommpplleettee builtin (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below), + rreeaaddlliinnee invokes the programmable completion facilities. + + First, bbaasshh identifies the command name. If a compspec has been de- + fined for that command, the compspec is used to generate the list of + possible completions for the word. If the command word is the empty + string (completion attempted at the beginning of an empty line), bbaasshh + uses any compspec defined with the --EE option to ccoommpplleettee. The --II op- + tion to ccoommpplleettee indicates that the command word is the first non-as- + signment word on the line, or after a command delimiter such as ;; or ||. + This usually indicates command name completion. + + If the command word is a full pathname, bbaasshh searches for a compspec + for the full pathname first. If there is no compspec for the full + pathname, bbaasshh attempts to find a compspec for the portion following + the final slash. If those searches do not result in a compspec, or if + there is no compspec for the command word, bbaasshh uses any compspec de- + fined with the --DD option to ccoommpplleettee as the default. If there is no + default compspec, bbaasshh performs alias expansion on the command word as a final resort, and attempts to find a compspec for the command word - from any successful expansion. - - Once a compspec has been found, it is used to generate the list of - matching words. If a compspec is not found, the default bbaasshh comple- - tion as described above under CCoommpplleettiinngg is performed. - - First, the actions specified by the compspec are used. Only matches - which are prefixed by the word being completed are returned. When the - --ff or --dd option is used for filename or directory name completion, the - shell variable FFIIGGNNOORREE is used to filter the matches. - - Any completions specified by a pathname expansion pattern to the --GG op- - tion are generated next. The words generated by the pattern need not - match the word being completed. The GGLLOOBBIIGGNNOORREE shell variable is not - used to filter the matches, but the FFIIGGNNOORREE variable is used. - - Next, the string specified as the argument to the --WW option is consid- - ered. The string is first split using the characters in the IIFFSS spe- - cial variable as delimiters. Shell quoting is honored. Each word is - then expanded using brace expansion, tilde expansion, parameter and - variable expansion, command substitution, and arithmetic expansion, as - described above under EEXXPPAANNSSIIOONN. The results are split using the rules - described above under WWoorrdd SSpplliittttiinngg. The results of the expansion are - prefix-matched against the word being completed, and the matching words - become the possible completions. - - After these matches have been generated, any shell function or command - specified with the --FF and --CC options is invoked. When the command or - function is invoked, the CCOOMMPP__LLIINNEE, CCOOMMPP__PPOOIINNTT, CCOOMMPP__KKEEYY, and CCOOMMPP__TTYYPPEE - variables are assigned values as described above under SShheellll VVaarriiaabblleess. - If a shell function is being invoked, the CCOOMMPP__WWOORRDDSS and CCOOMMPP__CCWWOORRDD - variables are also set. When the function or command is invoked, the - first argument ($$11) is the name of the command whose arguments are be- - ing completed, the second argument ($$22) is the word being completed, - and the third argument ($$33) is the word preceding the word being com- - pleted on the current command line. No filtering of the generated com- - pletions against the word being completed is performed; the function or - command has complete freedom in generating the matches. - - Any function specified with --FF is invoked first. The function may use - any of the shell facilities, including the ccoommppggeenn builtin described - below, to generate the matches. It must put the possible completions - in the CCOOMMPPRREEPPLLYY array variable, one per array element. + resulting from any successful expansion. + + If a compspec is not found, bbaasshh performs its default completion as de- + scribed above under CCoommpplleettiinngg. Otherwise, once a compspec has been + found, bbaasshh uses it to generate the list of matching words. + + First, bbaasshh performs the _a_c_t_i_o_n_s specified by the compspec. This only + returns matches which are prefixes of the word being completed. When + the --ff or --dd option is used for filename or directory name completion, + bbaasshh uses the shell variable FFIIGGNNOORREE to filter the matches. + + Next, programmable completion generates matches specified by a pathname + expansion pattern supplied as an argument to the --GG option. The words + generated by the pattern need not match the word being completed. BBaasshh + uses the FFIIGGNNOORREE variable to filter the matches, but does not use the + GGLLOOBBIIGGNNOORREE shell variable. + + Next, completion considers the string specified as the argument to the + --WW option. The string is first split using the characters in the IIFFSS + special variable as delimiters. This honors shell quoting within the + string, in order to provide a mechanism for the words to contain shell + metacharacters or characters in the value of IIFFSS. Each word is then + expanded using brace expansion, tilde expansion, parameter and variable + expansion, command substitution, and arithmetic expansion, as described + above under EEXXPPAANNSSIIOONN. The results are split using the rules described + above under WWoorrdd SSpplliittttiinngg. The results of the expansion are prefix- + matched against the word being completed, and the matching words become + possible completions. + + After these matches have been generated, bbaasshh executes any shell func- + tion or command specified with the --FF and --CC options. When the command + or function is invoked, bbaasshh assigns values to the CCOOMMPP__LLIINNEE, + CCOOMMPP__PPOOIINNTT, CCOOMMPP__KKEEYY, and CCOOMMPP__TTYYPPEE variables as described above under + SShheellll VVaarriiaabblleess. If a shell function is being invoked, bbaasshh also sets + the CCOOMMPP__WWOORRDDSS and CCOOMMPP__CCWWOORRDD variables. When the function or command + is invoked, the first argument ($$11) is the name of the command whose + arguments are being completed, the second argument ($$22) is the word be- + ing completed, and the third argument ($$33) is the word preceding the + word being completed on the current command line. There is no filter- + ing of the generated completions against the word being completed; the + function or command has complete freedom in generating the matches and + they do not need to match a prefix of the word. + + Any function specified with --FF is invoked first. The function may use + any of the shell facilities, including the ccoommppggeenn and ccoommppoopptt builtins + described below, to generate the matches. It must put the possible + completions in the CCOOMMPPRREEPPLLYY array variable, one per array element. Next, any command specified with the --CC option is invoked in an envi- ronment equivalent to command substitution. It should print a list of - completions, one per line, to the standard output. Backslash may be - used to escape a newline, if necessary. - - After all of the possible completions are generated, any filter speci- - fied with the --XX option is applied to the list. The filter is a pat- - tern as used for pathname expansion; a && in the pattern is replaced - with the text of the word being completed. A literal && may be escaped - with a backslash; the backslash is removed before attempting a match. - Any completion that matches the pattern will be removed from the list. - A leading !! negates the pattern; in this case any completion not match- - ing the pattern will be removed. If the nnooccaasseemmaattcchh shell option is - enabled, the match is performed without regard to the case of alpha- - betic characters. - - Finally, any prefix and suffix specified with the --PP and --SS options are - added to each member of the completion list, and the result is returned - to the readline completion code as the list of possible completions. + completions, one per line, to the standard output. Backslash will es- + cape a newline, if necessary. These are added to the set of possible + completions. + + After generating all of the possible completions, bbaasshh applies any fil- + ter specified with the --XX option to the completions in the list. The + filter is a pattern as used for pathname expansion; a && in the pattern + is replaced with the text of the word being completed. A literal && may + be escaped with a backslash; the backslash is removed before attempting + a match. Any completion that matches the pattern is removed from the + list. A leading !! negates the pattern; in this case bbaasshh removes any + completion that does not match the pattern. If the nnooccaasseemmaattcchh shell + option is enabled, bbaasshh performs the match without regard to the case + of alphabetic characters. + + Finally, programmable completion adds any prefix and suffix specified + with the --PP and --SS options, respectively, to each completion, and re- + turns the result to rreeaaddlliinnee as the list of possible completions. If the previously-applied actions do not generate any matches, and the --oo ddiirrnnaammeess option was supplied to ccoommpplleettee when the compspec was de- - fined, directory name completion is attempted. + fined, bbaasshh attempts directory name completion. If the --oo pplluussddiirrss option was supplied to ccoommpplleettee when the compspec - was defined, directory name completion is attempted and any matches are - added to the results of the other actions. + was defined, bbaasshh attempts directory name completion and adds any + matches to the set of possible completions. By default, if a compspec is found, whatever it generates is returned to the completion code as the full set of possible completions. The - default bbaasshh completions are not attempted, and the readline default of - filename completion is disabled. If the --oo bbaasshhddeeffaauulltt option was sup- - plied to ccoommpplleettee when the compspec was defined, the bbaasshh default com- - pletions are attempted if the compspec generates no matches. If the --oo - ddeeffaauulltt option was supplied to ccoommpplleettee when the compspec was defined, - readline's default completion will be performed if the compspec (and, - if attempted, the default bbaasshh completions) generate no matches. - - When a compspec indicates that directory name completion is desired, - the programmable completion functions force readline to append a slash - to completed names which are symbolic links to directories, subject to - the value of the mmaarrkk--ddiirreeccttoorriieess readline variable, regardless of the - setting of the mmaarrkk--ssyymmlliinnkkeedd--ddiirreeccttoorriieess readline variable. + default bbaasshh completions and the rreeaaddlliinnee default of filename comple- + tion are disabled. If the --oo bbaasshhddeeffaauulltt option was supplied to ccoomm-- + pplleettee when the compspec was defined, and the compspec generates no + matches, bbaasshh attempts its default completions. If the compspec and, + if attempted, the default bbaasshh completions generate no matches, and the + --oo ddeeffaauulltt option was supplied to ccoommpplleettee when the compspec was de- + fined, programmable completion performs rreeaaddlliinnee's default completion. + + The options supplied to ccoommpplleettee and ccoommppoopptt can control how rreeaaddlliinnee + treats the completions. For instance, the _-_o _f_u_l_l_q_u_o_t_e option tells + rreeaaddlliinnee to quote the matches as if they were filenames. See the de- + scription of ccoommpplleettee below for details. + + When a compspec indicates that it wants directory name completion, the + programmable completion functions force rreeaaddlliinnee to append a slash to + completed names which are symbolic links to directories, subject to the + value of the mmaarrkk--ddiirreeccttoorriieess rreeaaddlliinnee variable, regardless of the set- + ting of the mmaarrkk--ssyymmlliinnkkeedd--ddiirreeccttoorriieess rreeaaddlliinnee variable. There is some support for dynamically modifying completions. This is most useful when used in combination with a default completion speci- fied with ccoommpplleettee --DD. It's possible for shell functions executed as - completion handlers to indicate that completion should be retried by + completion functions to indicate that completion should be retried by returning an exit status of 124. If a shell function returns 124, and changes the compspec associated with the command on which completion is - being attempted (supplied as the first argument when the function is + being attempted (supplied as the first argument when the function is executed), programmable completion restarts from the beginning, with an - attempt to find a new compspec for that command. This allows a set of - completions to be built dynamically as completion is attempted, rather - than being loaded all at once. + attempt to find a new compspec for that command. This can be used to + build a set of completions dynamically as completion is attempted, + rather than loading them all at once. For instance, assuming that there is a library of compspecs, each kept in a file corresponding to the name of the command, the following de- fault completion function would load completions dynamically: - - _completion_loader() - { - . "/etc/bash_completion.d/$1.sh" >/dev/null 2>&1 && return 124 - } - complete -D -F _completion_loader -o bashdefault -o default - + _completion_loader() + { + . "/etc/bash_completion.d/$1.sh" \ + >/dev/null 2>&1 && return 124 + } + complete -D -F _completion_loader \ + -o bashdefault -o default HHIISSTTOORRYY When the --oo hhiissttoorryy option to the sseett builtin is enabled, the shell provides access to the _c_o_m_m_a_n_d _h_i_s_t_o_r_y, the list of commands previously - typed. The value of the HHIISSTTSSIIZZEE variable is used as the number of - commands to save in a history list. The text of the last HHIISSTTSSIIZZEE com- - mands (default 500) is saved. The shell stores each command in the - history list prior to parameter and variable expansion (see EEXXPPAANNSSIIOONN - above) but after history expansion is performed, subject to the values - of the shell variables HHIISSTTIIGGNNOORREE and HHIISSTTCCOONNTTRROOLL. - - On startup, the history is initialized from the file named by the vari- - able HHIISSTTFFIILLEE (default _~_/_._b_a_s_h___h_i_s_t_o_r_y). The file named by the value - of HHIISSTTFFIILLEE is truncated, if necessary, to contain no more than the - number of lines specified by the value of HHIISSTTFFIILLEESSIIZZEE. If HHIISSTTFFIILLEE-- - SSIIZZEE is unset, or set to null, a non-numeric value, or a numeric value - less than zero, the history file is not truncated. When the history - file is read, lines beginning with the history comment character fol- - lowed immediately by a digit are interpreted as timestamps for the fol- - lowing history line. These timestamps are optionally displayed depend- - ing on the value of the HHIISSTTTTIIMMEEFFOORRMMAATT variable. When a shell with - history enabled exits, the last $$HHIISSTTSSIIZZEE lines are copied from the - history list to $$HHIISSTTFFIILLEE. If the hhiissttaappppeenndd shell option is enabled - (see the description of sshhoopptt under SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below), the - lines are appended to the history file, otherwise the history file is - overwritten. If HHIISSTTFFIILLEE is unset, or if the history file is un- - writable, the history is not saved. If the HHIISSTTTTIIMMEEFFOORRMMAATT variable is - set, time stamps are written to the history file, marked with the his- - tory comment character, so they may be preserved across shell sessions. - This uses the history comment character to distinguish timestamps from - other history lines. After saving the history, the history file is - truncated to contain no more than HHIISSTTFFIILLEESSIIZZEE lines. If HHIISSTTFFIILLEESSIIZZEE - is unset, or set to null, a non-numeric value, or a numeric value less - than zero, the history file is not truncated. - - The builtin command ffcc (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below) may be used - to list or edit and re-execute a portion of the history list. The hhiiss-- - ttoorryy builtin may be used to display or modify the history list and ma- - nipulate the history file. When using command-line editing, search - commands are available in each editing mode that provide access to the - history list. + typed. The value of the HHIISSTTSSIIZZEE variable is used as the number of + commands to save in a history list: the shell saves the text of the + last HHIISSTTSSIIZZEE commands (default 500). The shell stores each command in + the history list prior to parameter and variable expansion (see EEXXPPAANN-- + SSIIOONN above) but after history expansion is performed, subject to the + values of the shell variables HHIISSTTIIGGNNOORREE and HHIISSTTCCOONNTTRROOLL. + + On startup, bbaasshh initializes the history list by reading history en- + tries from the file named by the HHIISSTTFFIILLEE variable (default + _~_/_._b_a_s_h___h_i_s_t_o_r_y). That file is referred to as the _h_i_s_t_o_r_y _f_i_l_e. The + history file is truncated, if necessary, to contain no more than the + number of history entries specified by the value of the HHIISSTTFFIILLEESSIIZZEE + variable. If HHIISSTTFFIILLEESSIIZZEE is unset, or set to null, a non-numeric + value, or a numeric value less than zero, the history file is not trun- + cated. + + When the history file is read, lines beginning with the history comment + character followed immediately by a digit are interpreted as timestamps + for the following history line. These timestamps are optionally dis- + played depending on the value of the HHIISSTTTTIIMMEEFFOORRMMAATT variable. When + present, history timestamps delimit history entries, making multi-line + entries possible. + + When a shell with history enabled exits, bbaasshh copies the last $$HHIISSTTSSIIZZEE + entries from the history list to $$HHIISSTTFFIILLEE. If the hhiissttaappppeenndd shell + option is enabled (see the description of sshhoopptt under SSHHEELLLL BBUUIILLTTIINN + CCOOMMMMAANNDDSS below), bbaasshh appends the entries to the history file, other- + wise it overwrites the history file. If HHIISSTTFFIILLEE is unset or null, or + if the history file is unwritable, the history is not saved. After + saving the history, bbaasshh truncates the history file to contain no more + than HHIISSTTFFIILLEESSIIZZEE lines as described above. + + If the HHIISSTTTTIIMMEEFFOORRMMAATT variable is set, the shell writes the timestamp + information associated with each history entry to the history file, + marked with the history comment character, so timestamps are preserved + across shell sessions. This uses the history comment character to dis- + tinguish timestamps from other history lines. As above, when using + HHIISSTTTTIIMMEEFFOORRMMAATT, the timestamps delimit multi-line history entries. + + The ffcc builtin command (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below) will list or + edit and re-execute a portion of the history list. The hhiissttoorryy builtin + can display or modify the history list and manipulate the history file. + When using command-line editing, search commands are available in each + editing mode that provide access to the history list. The shell allows control over which commands are saved on the history - list. The HHIISSTTCCOONNTTRROOLL and HHIISSTTIIGGNNOORREE variables may be set to cause the - shell to save only a subset of the commands entered. The ccmmddhhiisstt shell - option, if enabled, causes the shell to attempt to save each line of a - multi-line command in the same history entry, adding semicolons where - necessary to preserve syntactic correctness. The lliitthhiisstt shell option - causes the shell to save the command with embedded newlines instead of - semicolons. See the description of the sshhoopptt builtin below under SSHHEELLLL - BBUUIILLTTIINN CCOOMMMMAANNDDSS for information on setting and unsetting shell op- - tions. + list. The HHIISSTTCCOONNTTRROOLL and HHIISSTTIIGGNNOORREE variables are used to save only a + subset of the commands entered. If the ccmmddhhiisstt shell option is en- + abled, the shell attempts to save each line of a multi-line command in + the same history entry, adding semicolons where necessary to preserve + syntactic correctness. The lliitthhiisstt shell option modifies ccmmddhhiisstt by + saving the command with embedded newlines instead of semicolons. See + the description of the sshhoopptt builtin below under SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS + for information on setting and unsetting shell options. HHIISSTTOORRYY EEXXPPAANNSSIIOONN - The shell supports a history expansion feature that is similar to the - history expansion in ccsshh. This section describes what syntax features - are available. This feature is enabled by default for interactive - shells, and can be disabled using the ++HH option to the sseett builtin com- - mand (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). Non-interactive shells do not - perform history expansion by default. + The shell supports a history expansion feature that is similar to the + history expansion in ccsshh. This section describes what syntax features + are available. + + History expansion is enabled by default for interactive shells, and can + be disabled using the ++HH option to the sseett builtin command (see SSHHEELLLL + BBUUIILLTTIINN CCOOMMMMAANNDDSS below). Non-interactive shells do not perform history + expansion by default, but it can be enabled with "set -H". History expansions introduce words from the history list into the input stream, making it easy to repeat commands, insert the arguments to a previous command into the current input line, or fix errors in previous commands quickly. - History expansion is performed immediately after a complete line is - read, before the shell breaks it into words, and is performed on each - line individually without taking quoting on previous lines into ac- - count. It takes place in two parts. The first is to determine which - line from the history list to use during substitution. The second is - to select portions of that line for inclusion into the current one. - The line selected from the history is the _e_v_e_n_t, and the portions of - that line that are acted upon are _w_o_r_d_s. Various _m_o_d_i_f_i_e_r_s are avail- - able to manipulate the selected words. The line is broken into words - in the same fashion as when reading input, so that several _m_e_t_a_c_h_a_r_a_c_- - _t_e_r-separated words surrounded by quotes are considered one word. His- - tory expansions are introduced by the appearance of the history expan- - sion character, which is !! by default. Only backslash (\\) and single - quotes can quote the history expansion character, but the history ex- - pansion character is also treated as quoted if it immediately precedes - the closing double quote in a double-quoted string. - - Several characters inhibit history expansion if found immediately fol- - lowing the history expansion character, even if it is unquoted: space, - tab, newline, carriage return, and ==. If the eexxttgglloobb shell option is - enabled, (( will also inhibit expansion. - - Several shell options settable with the sshhoopptt builtin may be used to - tailor the behavior of history expansion. If the hhiissttvveerriiffyy shell op- - tion is enabled (see the description of the sshhoopptt builtin below), and - rreeaaddlliinnee is being used, history substitutions are not immediately - passed to the shell parser. Instead, the expanded line is reloaded - into the rreeaaddlliinnee editing buffer for further modification. If rreeaaddlliinnee - is being used, and the hhiissttrreeeeddiitt shell option is enabled, a failed - history substitution will be reloaded into the rreeaaddlliinnee editing buffer - for correction. The --pp option to the hhiissttoorryy builtin command may be - used to see what a history expansion will do before using it. The --ss - option to the hhiissttoorryy builtin may be used to add commands to the end of - the history list without actually executing them, so that they are - available for subsequent recall. + History expansion is performed immediately after a complete line is + read, before the shell breaks it into words, and is performed on each + line individually. The shell attempts to inform the history expansion + functions about quoting still in effect from previous lines. + + It takes place in two parts. The first is to determine which history + list entry to use during substitution. The second is to select por- + tions of that entry to include into the current one. + + The entry selected from the history is the _e_v_e_n_t, and the portions of + that entry that are acted upon are _w_o_r_d_s. Various _m_o_d_i_f_i_e_r_s are avail- + able to manipulate the selected words. The entry is split into words + in the same fashion as when reading input, so that several _m_e_t_a_c_h_a_r_a_c_- + _t_e_r-separated words surrounded by quotes are considered one word. The + _e_v_e_n_t _d_e_s_i_g_n_a_t_o_r selects the event, the optional _w_o_r_d _d_e_s_i_g_n_a_t_o_r se- + lects words from the event, and various optional _m_o_d_i_f_i_e_r_s are avail- + able to manipulate the selected words. + + History expansions are introduced by the appearance of the history ex- + pansion character, which is !! by default. History expansions may ap- + pear anywhere in the input, but do not nest. + + Only backslash (\\) and single quotes can quote the history expansion + character, but the history expansion character is also treated as + quoted if it immediately precedes the closing double quote in a double- + quoted string. + + Several characters inhibit history expansion if found immediately fol- + lowing the history expansion character, even if it is unquoted: space, + tab, newline, carriage return, ==, and the other shell metacharacters + defined above. + + There is a special abbreviation for substitution, active when the _q_u_i_c_k + _s_u_b_s_t_i_t_u_t_i_o_n character (described above under hhiissttcchhaarrss) is the first + character on the line. It selects the previous history list entry, us- + ing an event designator equivalent to !!!!, and substitutes one string + for another in that entry. It is described below under EEvveenntt DDeessiiggnnaa-- + ttoorrss. This is the only history expansion that does not begin with the + history expansion character. + + Several shell options settable with the sshhoopptt builtin will modify his- + tory expansion behavior (see the description of the sshhoopptt builtin be- + low).and If the hhiissttvveerriiffyy shell option is enabled, and rreeaaddlliinnee is be- + ing used, history substitutions are not immediately passed to the shell + parser. Instead, the expanded line is reloaded into the rreeaaddlliinnee edit- + ing buffer for further modification. If rreeaaddlliinnee is being used, and + the hhiissttrreeeeddiitt shell option is enabled, a failed history substitution + is reloaded into the rreeaaddlliinnee editing buffer for correction. + + The --pp option to the hhiissttoorryy builtin command shows what a history ex- + pansion will do before using it. The --ss option to the hhiissttoorryy builtin + will add commands to the end of the history list without actually exe- + cuting them, so that they are available for subsequent recall. The shell allows control of the various characters used by the history expansion mechanism (see the description of hhiissttcchhaarrss above under SShheellll - VVaarriiaabblleess). The shell uses the history comment character to mark his- + VVaarriiaabblleess). The shell uses the history comment character to mark his- tory timestamps when writing the history file. EEvveenntt DDeessiiggnnaattoorrss - An event designator is a reference to a command line entry in the his- - tory list. Unless the reference is absolute, events are relative to - the current position in the history list. + An event designator is a reference to an entry in the history list. + The event designator consists of the portion of the word beginning with + the history expansion character and ending with the word designator if + present, or the end of the word. Unless the reference is absolute, + events are relative to the current position in the history list. !! Start a history substitution, except when followed by a bbllaannkk, - newline, carriage return, = or ( (when the eexxttgglloobb shell option - is enabled using the sshhoopptt builtin). - !!_n Refer to command line _n. - !!--_n Refer to the current command minus _n. - !!!! Refer to the previous command. This is a synonym for `!-1'. + newline, carriage return, =, or, when the eexxttgglloobb shell option + is enabled using the sshhoopptt builtin, (. + !!_n Refer to history list entry _n. + !!--_n Refer to the current entry minus _n. + !!!! Refer to the previous entry. This is a synonym for "!-1". !!_s_t_r_i_n_g Refer to the most recent command preceding the current position in the history list starting with _s_t_r_i_n_g. @@ -4389,73 +4966,77 @@ HHIISSTTOORRYY EEXXPPAANNSSIIOONN Refer to the most recent command preceding the current position in the history list containing _s_t_r_i_n_g. The trailing ?? may be omitted if _s_t_r_i_n_g is followed immediately by a newline. If - _s_t_r_i_n_g is missing, the string from the most recent search is - used; it is an error if there is no previous search string. + _s_t_r_i_n_g is missing, this uses the string from the most recent + search; it is an error if there is no previous search string. ^^_s_t_r_i_n_g_1^^_s_t_r_i_n_g_2^^ Quick substitution. Repeat the previous command, replacing - _s_t_r_i_n_g_1 with _s_t_r_i_n_g_2. Equivalent to ``!!:s^_s_t_r_i_n_g_1^_s_t_r_i_n_g_2^'' + _s_t_r_i_n_g_1 with _s_t_r_i_n_g_2. Equivalent to "!!:s^_s_t_r_i_n_g_1^_s_t_r_i_n_g_2^" (see MMooddiiffiieerrss below). !!## The entire command line typed so far. WWoorrdd DDeessiiggnnaattoorrss - Word designators are used to select desired words from the event. A :: - separates the event specification from the word designator. It may be - omitted if the word designator begins with a ^^, $$, **, --, or %%. Words - are numbered from the beginning of the line, with the first word being - denoted by 0 (zero). Words are inserted into the current line sepa- - rated by single spaces. + Word designators are used to select desired words from the event. They + are optional; if the word designator isn't supplied, the history expan- + sion uses the entire event. A :: separates the event specification from + the word designator. It may be omitted if the word designator begins + with a ^^, $$, **, --, or %%. Words are numbered from the beginning of the + line, with the first word being denoted by 0 (zero). Words are in- + serted into the current line separated by single spaces. 00 ((zzeerroo)) The zeroth word. For the shell, this is the command word. _n The _nth word. - ^^ The first argument. That is, word 1. + ^^ The first argument: word 1. $$ The last word. This is usually the last argument, but will ex- pand to the zeroth word if there is only one word in the line. - %% The first word matched by the most recent `?_s_t_r_i_n_g?' search, if - the search string begins with a character that is part of a - word. - _x--_y A range of words; `-_y' abbreviates `0-_y'. - ** All of the words but the zeroth. This is a synonym for `_1_-_$'. - It is not an error to use ** if there is just one word in the - event; the empty string is returned in that case. + %% The first word matched by the most recent "?_s_t_r_i_n_g?" search, if + the search string begins with a character that is part of a + word. By default, searches begin at the end of each line and + proceed to the beginning, so the first word matched is the one + closest to the end of the line. + _x--_y A range of words; "-_y" abbreviates "0-_y". + ** All of the words but the zeroth. This is a synonym for "_1_-_$". + It is not an error to use ** if there is just one word in the + event; it expands to the empty string in that case. xx** Abbreviates _x_-_$. xx-- Abbreviates _x_-_$ like xx**, but omits the last word. If xx is miss- ing, it defaults to 0. If a word designator is supplied without an event specification, the - previous command is used as the event. + previous command is used as the event, equivalent to !!!!. MMooddiiffiieerrss - After the optional word designator, there may appear a sequence of one - or more of the following modifiers, each preceded by a `:'. These mod- - ify, or edit, the word or words selected from the history event. + After the optional word designator, the expansion may include a se- + quence of one or more of the following modifiers, each preceded by a + ":". These modify, or edit, the word or words selected from the his- + tory event. - hh Remove a trailing filename component, leaving only the head. - tt Remove all leading filename components, leaving the tail. + hh Remove a trailing pathname component, leaving only the head. + tt Remove all leading pathname components, leaving the tail. rr Remove a trailing suffix of the form _._x_x_x, leaving the basename. ee Remove all but the trailing suffix. pp Print the new command but do not execute it. qq Quote the substituted words, escaping further substitutions. - xx Quote the substituted words as with qq, but break into words at - bbllaannkkss and newlines. The qq and xx modifiers are mutually exclu- - sive; the last one supplied is used. + xx Quote the substituted words as with qq, but break into words at + bbllaannkkss and newlines. The qq and xx modifiers are mutually exclu- + sive; expansion uses the last one supplied. ss//_o_l_d//_n_e_w// - Substitute _n_e_w for the first occurrence of _o_l_d in the event + Substitute _n_e_w for the first occurrence of _o_l_d in the event line. Any character may be used as the delimiter in place of /. The final delimiter is optional if it is the last character of - the event line. The delimiter may be quoted in _o_l_d and _n_e_w with - a single backslash. If & appears in _n_e_w, it is replaced by _o_l_d. - A single backslash will quote the &. If _o_l_d is null, it is set - to the last _o_l_d substituted, or, if no previous history substi- - tutions took place, the last _s_t_r_i_n_g in a !!??_s_t_r_i_n_g[[??]] search. - If _n_e_w is null, each matching _o_l_d is deleted. + the event line. A single backslash quotes the delimiter in _o_l_d + and _n_e_w. If & appears in _n_e_w, it is replaced with _o_l_d. A sin- + gle backslash quotes the &. If _o_l_d is null, it is set to the + last _o_l_d substituted, or, if no previous history substitutions + took place, the last _s_t_r_i_n_g in a !!??_s_t_r_i_n_g[[??]] search. If _n_e_w is + null, each matching _o_l_d is deleted. && Repeat the previous substitution. gg Cause changes to be applied over the entire event line. This is - used in conjunction with `::ss' (e.g., `::ggss//_o_l_d//_n_e_w//') or `::&&'. - If used with `::ss', any delimiter can be used in place of /, and + used in conjunction with "::ss" (e.g., "::ggss//_o_l_d//_n_e_w//") or "::&&". + If used with "::ss", any delimiter can be used in place of /, and the final delimiter is optional if it is the last character of the event line. An aa may be used as a synonym for gg. - GG Apply the following `ss' or `&&' modifier once to each word in the + GG Apply the following "ss" or "&&" modifier once to each word in the event line. SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS @@ -4468,237 +5049,304 @@ SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS are not specified as accepting options interpret arguments beginning with -- as invalid options and require ---- to prevent this interpreta- tion. + :: [_a_r_g_u_m_e_n_t_s] No effect; the command does nothing beyond expanding _a_r_g_u_m_e_n_t_s and performing any specified redirections. The return status is zero. - .. _f_i_l_e_n_a_m_e [_a_r_g_u_m_e_n_t_s] - ssoouurrccee _f_i_l_e_n_a_m_e [_a_r_g_u_m_e_n_t_s] - Read and execute commands from _f_i_l_e_n_a_m_e in the current shell en- - vironment and return the exit status of the last command exe- - cuted from _f_i_l_e_n_a_m_e. If _f_i_l_e_n_a_m_e does not contain a slash, - filenames in PPAATTHH are used to find the directory containing - _f_i_l_e_n_a_m_e, but _f_i_l_e_n_a_m_e does not need to be executable. The file - searched for in PPAATTHH need not be executable. When bbaasshh is not - in _p_o_s_i_x _m_o_d_e, it searches the current directory if no file is - found in PPAATTHH. If the ssoouurrcceeppaatthh option to the sshhoopptt builtin - command is turned off, the PPAATTHH is not searched. If any _a_r_g_u_- - _m_e_n_t_s are supplied, they become the positional parameters when - _f_i_l_e_n_a_m_e is executed. Otherwise the positional parameters are - unchanged. If the --TT option is enabled, .. inherits any trap on - DDEEBBUUGG; if it is not, any DDEEBBUUGG trap string is saved and restored - around the call to .., and .. unsets the DDEEBBUUGG trap while it exe- - cutes. If --TT is not set, and the sourced file changes the DDEEBBUUGG - trap, the new value is retained when .. completes. The return - status is the status of the last command exited within the - script (0 if no commands are executed), and false if _f_i_l_e_n_a_m_e is - not found or cannot be read. + .. [--pp _p_a_t_h] _f_i_l_e_n_a_m_e [_a_r_g_u_m_e_n_t_s] + ssoouurrccee [--pp _p_a_t_h] _f_i_l_e_n_a_m_e [_a_r_g_u_m_e_n_t_s] + The .. command (ssoouurrccee) reads and execute commands from _f_i_l_e_n_a_m_e + in the current shell environment and returns the exit status of + the last command executed from _f_i_l_e_n_a_m_e. + + If _f_i_l_e_n_a_m_e does not contain a slash, .. searches for it. If the + --pp option is supplied, .. treats _p_a_t_h as a colon-separated list + of directories in which to find _f_i_l_e_n_a_m_e; otherwise, .. uses the + entries in PPAATTHH to find the directory containing _f_i_l_e_n_a_m_e. + _f_i_l_e_n_a_m_e does not need to be executable. When bbaasshh is not in + posix mode, it searches the current directory if _f_i_l_e_n_a_m_e is not + found in PPAATTHH, but does not search the current directory if --pp + is supplied. If the ssoouurrcceeppaatthh option to the sshhoopptt builtin com- + mand is turned off, .. does not search PPAATTHH. + + If any _a_r_g_u_m_e_n_t_s are supplied, they become the positional para- + meters when _f_i_l_e_n_a_m_e is executed. Otherwise the positional pa- + rameters are unchanged. + + If the --TT option is enabled, .. inherits any trap on DDEEBBUUGG; if it + is not, any DDEEBBUUGG trap string is saved and restored around the + call to .., and .. unsets the DDEEBBUUGG trap while it executes. If --TT + is not set, and the sourced file changes the DDEEBBUUGG trap, the new + value persists after .. completes. The return status is the sta- + tus of the last command executed from _f_i_l_e_n_a_m_e (0 if no commands + are executed), and non-zero if _f_i_l_e_n_a_m_e is not found or cannot + be read. aalliiaass [--pp] [_n_a_m_e[=_v_a_l_u_e] ...] - AAlliiaass with no arguments or with the --pp option prints the list of - aliases in the form aalliiaass _n_a_m_e=_v_a_l_u_e on standard output. When - arguments are supplied, an alias is defined for each _n_a_m_e whose - _v_a_l_u_e is given. A trailing space in _v_a_l_u_e causes the next word - to be checked for alias substitution when the alias is expanded. - For each _n_a_m_e in the argument list for which no _v_a_l_u_e is sup- - plied, the name and value of the alias is printed. AAlliiaass re- - turns true unless a _n_a_m_e is given for which no alias has been - defined. + With no arguments or with the --pp option, aalliiaass prints the list + of aliases in the form aalliiaass _n_a_m_e=_v_a_l_u_e on standard output. + When arguments are supplied, define an alias for each _n_a_m_e whose + _v_a_l_u_e is given. A trailing space in _v_a_l_u_e causes the next word + to be checked for alias substitution when the alias is expanded + during command parsing. For each _n_a_m_e in the argument list for + which no _v_a_l_u_e is supplied, print the name and value of the + alias _n_a_m_e. aalliiaass returns true unless a _n_a_m_e is given (without + a corresponding =_v_a_l_u_e) for which no alias has been defined. bbgg [_j_o_b_s_p_e_c ...] - Resume each suspended job _j_o_b_s_p_e_c in the background, as if it - had been started with &&. If _j_o_b_s_p_e_c is not present, the shell's - notion of the _c_u_r_r_e_n_t _j_o_b is used. bbgg _j_o_b_s_p_e_c returns 0 unless + Resume each suspended job _j_o_b_s_p_e_c in the background, as if it + had been started with &&. If _j_o_b_s_p_e_c is not present, the shell + uses its notion of the _c_u_r_r_e_n_t _j_o_b. bbgg _j_o_b_s_p_e_c returns 0 unless run when job control is disabled or, when run with job control enabled, any specified _j_o_b_s_p_e_c was not found or was started without job control. - bbiinndd [--mm _k_e_y_m_a_p] [--llppssvvPPSSVVXX] + bbiinndd [--mm _k_e_y_m_a_p] [--llssvvSSVVXX] bbiinndd [--mm _k_e_y_m_a_p] [--qq _f_u_n_c_t_i_o_n] [--uu _f_u_n_c_t_i_o_n] [--rr _k_e_y_s_e_q] bbiinndd [--mm _k_e_y_m_a_p] --ff _f_i_l_e_n_a_m_e - bbiinndd [--mm _k_e_y_m_a_p] --xx _k_e_y_s_e_q:_s_h_e_l_l_-_c_o_m_m_a_n_d + bbiinndd [--mm _k_e_y_m_a_p] --xx _k_e_y_s_e_q[:] _s_h_e_l_l_-_c_o_m_m_a_n_d bbiinndd [--mm _k_e_y_m_a_p] _k_e_y_s_e_q:_f_u_n_c_t_i_o_n_-_n_a_m_e + bbiinndd [--mm _k_e_y_m_a_p] --pp|--PP [_r_e_a_d_l_i_n_e_-_c_o_m_m_a_n_d] bbiinndd [--mm _k_e_y_m_a_p] _k_e_y_s_e_q:_r_e_a_d_l_i_n_e_-_c_o_m_m_a_n_d bbiinndd _r_e_a_d_l_i_n_e_-_c_o_m_m_a_n_d_-_l_i_n_e Display current rreeaaddlliinnee key and function bindings, bind a key - sequence to a rreeaaddlliinnee function or macro, or set a rreeaaddlliinnee - variable. Each non-option argument is a command as it would ap- - pear in a rreeaaddlliinnee initialization file such as _._i_n_p_u_t_r_c, but - each binding or command must be passed as a separate argument; - e.g., '"\C-x\C-r": re-read-init-file'. Options, if supplied, - have the following meanings: + sequence to a rreeaaddlliinnee function or macro or to a shell command, + or set a rreeaaddlliinnee variable. Each non-option argument is a key + binding or command as it would appear in a rreeaaddlliinnee initializa- + tion file such as _._i_n_p_u_t_r_c, but each binding or command must be + passed as a separate argument; e.g., '"\C-x\C-r": + re-read-init-file'. In the following descriptions, output + available to be re-read is formatted as commands that would ap- + pear in a rreeaaddlliinnee initialization file or that would be supplied + as individual arguments to a bbiinndd command. Options, if sup- + plied, have the following meanings: --mm _k_e_y_m_a_p Use _k_e_y_m_a_p as the keymap to be affected by the subsequent bindings. Acceptable _k_e_y_m_a_p names are _e_m_a_c_s_, _e_m_a_c_s_-_s_t_a_n_- - _d_a_r_d_, _e_m_a_c_s_-_m_e_t_a_, _e_m_a_c_s_-_c_t_l_x_, _v_i_, _v_i_-_m_o_v_e_, _v_i_-_c_o_m_m_a_n_d, - and _v_i_-_i_n_s_e_r_t. _v_i is equivalent to _v_i_-_c_o_m_m_a_n_d (_v_i_-_m_o_v_e - is also a synonym); _e_m_a_c_s is equivalent to _e_m_a_c_s_-_s_t_a_n_- + _d_a_r_d_, _e_m_a_c_s_-_m_e_t_a_, _e_m_a_c_s_-_c_t_l_x_, _v_i_, _v_i_-_m_o_v_e_, _v_i_-_c_o_m_m_a_n_d, + and _v_i_-_i_n_s_e_r_t. _v_i is equivalent to _v_i_-_c_o_m_m_a_n_d (_v_i_-_m_o_v_e + is also a synonym); _e_m_a_c_s is equivalent to _e_m_a_c_s_-_s_t_a_n_- _d_a_r_d. --ll List the names of all rreeaaddlliinnee functions. - --pp Display rreeaaddlliinnee function names and bindings in such a - way that they can be re-read. - --PP List current rreeaaddlliinnee function names and bindings. + --pp Display rreeaaddlliinnee function names and bindings in such a + way that they can be used as an argument to a subsequent + bbiinndd command or in a rreeaaddlliinnee initialization file. If + arguments remain after option processing, bbiinndd treats + them as rreeaaddlliinnee command names and restricts output to + those names. + --PP List current rreeaaddlliinnee function names and bindings. If + arguments remain after option processing, bbiinndd treats + them as rreeaaddlliinnee command names and restricts output to + those names. --ss Display rreeaaddlliinnee key sequences bound to macros and the - strings they output in such a way that they can be re- - read. + strings they output in such a way that they can be used + as an argument to a subsequent bbiinndd command or in a rreeaadd-- + lliinnee initialization file. --SS Display rreeaaddlliinnee key sequences bound to macros and the strings they output. --vv Display rreeaaddlliinnee variable names and values in such a way - that they can be re-read. + that they can be used as an argument to a subsequent bbiinndd + command or in a rreeaaddlliinnee initialization file. --VV List current rreeaaddlliinnee variable names and values. --ff _f_i_l_e_n_a_m_e Read key bindings from _f_i_l_e_n_a_m_e. --qq _f_u_n_c_t_i_o_n - Query about which keys invoke the named _f_u_n_c_t_i_o_n. + Display key sequences that invoke the named rreeaaddlliinnee + _f_u_n_c_t_i_o_n. --uu _f_u_n_c_t_i_o_n - Unbind all keys bound to the named _f_u_n_c_t_i_o_n. + Unbind all key sequences bound to the named rreeaaddlliinnee + _f_u_n_c_t_i_o_n. --rr _k_e_y_s_e_q Remove any current binding for _k_e_y_s_e_q. - --xx _k_e_y_s_e_q::_s_h_e_l_l_-_c_o_m_m_a_n_d + --xx _k_e_y_s_e_q[[:: ]]_s_h_e_l_l_-_c_o_m_m_a_n_d Cause _s_h_e_l_l_-_c_o_m_m_a_n_d to be executed whenever _k_e_y_s_e_q is en- - tered. When _s_h_e_l_l_-_c_o_m_m_a_n_d is executed, the shell sets - the RREEAADDLLIINNEE__LLIINNEE variable to the contents of the rreeaadd-- - lliinnee line buffer and the RREEAADDLLIINNEE__PPOOIINNTT and RREEAADDLLIINNEE__MMAARRKK - variables to the current location of the insertion point - and the saved insertion point (the mark), respectively. - The shell assigns any numeric argument the user supplied - to the RREEAADDLLIINNEE__AARRGGUUMMEENNTT variable. If there was no argu- - ment, that variable is not set. If the executed command - changes the value of any of RREEAADDLLIINNEE__LLIINNEE, RREEAADD-- - LLIINNEE__PPOOIINNTT, or RREEAADDLLIINNEE__MMAARRKK, those new values will be + tered. The separator between _k_e_y_s_e_q and _s_h_e_l_l_-_c_o_m_m_a_n_d is + either whitespace or a colon optionally followed by + whitespace. If the separator is whitespace, _s_h_e_l_l_-_c_o_m_- + _m_a_n_d must be enclosed in double quotes and rreeaaddlliinnee ex- + pands any of its special backslash-escapes in _s_h_e_l_l_-_c_o_m_- + _m_a_n_d before saving it. If the separator is a colon, any + enclosing double quotes are optional, and rreeaaddlliinnee does + not expand the command string before saving it. Since + the entire key binding expression must be a single argu- + ment, it should be enclosed in single quotes. When + _s_h_e_l_l_-_c_o_m_m_a_n_d is executed, the shell sets the RREEAADD-- + LLIINNEE__LLIINNEE variable to the contents of the rreeaaddlliinnee line + buffer and the RREEAADDLLIINNEE__PPOOIINNTT and RREEAADDLLIINNEE__MMAARRKK variables + to the current location of the insertion point and the + saved insertion point (the mark), respectively. The + shell assigns any numeric argument the user supplied to + the RREEAADDLLIINNEE__AARRGGUUMMEENNTT variable. If there was no argu- + ment, that variable is not set. If the executed command + changes the value of any of RREEAADDLLIINNEE__LLIINNEE, RREEAADD-- + LLIINNEE__PPOOIINNTT, or RREEAADDLLIINNEE__MMAARRKK, those new values will be reflected in the editing state. - --XX List all key sequences bound to shell commands and the - associated commands in a format that can be reused as in- - put. + --XX List all key sequences bound to shell commands and the + associated commands in a format that can be reused as an + argument to a subsequent bbiinndd command. - The return value is 0 unless an unrecognized option is given or - an error occurred. + The return value is 0 unless an unrecognized option is supplied + or an error occurred. bbrreeaakk [_n] - Exit from within a ffoorr, wwhhiillee, uunnttiill, or sseelleecctt loop. If _n is - specified, break _n levels. _n must be >= 1. If _n is greater - than the number of enclosing loops, all enclosing loops are ex- - ited. The return value is 0 unless _n is not greater than or - equal to 1. + Exit from within a ffoorr, wwhhiillee, uunnttiill, or sseelleecctt loop. If _n is + specified, bbrreeaakk exits _n enclosing loops. _n must be >= 1. If _n + is greater than the number of enclosing loops, all enclosing + loops are exited. The return value is 0 unless _n is not greater + than or equal to 1. bbuuiillttiinn _s_h_e_l_l_-_b_u_i_l_t_i_n [_a_r_g_u_m_e_n_t_s] - Execute the specified shell builtin, passing it _a_r_g_u_m_e_n_t_s, and - return its exit status. This is useful when defining a function - whose name is the same as a shell builtin, retaining the func- - tionality of the builtin within the function. The ccdd builtin is - commonly redefined this way. The return status is false if - _s_h_e_l_l_-_b_u_i_l_t_i_n is not a shell builtin command. + Execute the specified shell builtin _s_h_e_l_l_-_b_u_i_l_t_i_n, passing it + _a_r_g_u_m_e_n_t_s, and return its exit status. This is useful when + defining a function whose name is the same as a shell builtin, + retaining the functionality of the builtin within the function. + The ccdd builtin is commonly redefined this way. The return sta- + tus is false if _s_h_e_l_l_-_b_u_i_l_t_i_n is not a shell builtin command. ccaalllleerr [_e_x_p_r] Returns the context of any active subroutine call (a shell func- - tion or a script executed with the .. or ssoouurrccee builtins). With- - out _e_x_p_r, ccaalllleerr displays the line number and source filename of - the current subroutine call. If a non-negative integer is sup- - plied as _e_x_p_r, ccaalllleerr displays the line number, subroutine name, - and source file corresponding to that position in the current - execution call stack. This extra information may be used, for - example, to print a stack trace. The current frame is frame 0. + tion or a script executed with the .. or ssoouurrccee builtins). + + Without _e_x_p_r, ccaalllleerr displays the line number and source file- + name of the current subroutine call. If a non-negative integer + is supplied as _e_x_p_r, ccaalllleerr displays the line number, subroutine + name, and source file corresponding to that position in the cur- + rent execution call stack. This extra information may be used, + for example, to print a stack trace. The current frame is frame + 0. + The return value is 0 unless the shell is not executing a sub- routine call or _e_x_p_r does not correspond to a valid position in the call stack. - ccdd [--LL|[--PP [--ee]] [-@]] [_d_i_r] + ccdd [--LL] [--@@] [_d_i_r] + ccdd --PP [--ee] [--@@] [_d_i_r] Change the current directory to _d_i_r. if _d_i_r is not supplied, - the value of the HHOOMMEE shell variable is the default. The vari- - able CCDDPPAATTHH defines the search path for the directory containing - _d_i_r: each directory name in CCDDPPAATTHH is searched for _d_i_r. Alter- - native directory names in CCDDPPAATTHH are separated by a colon (:). - A null directory name in CCDDPPAATTHH is the same as the current di- - rectory, i.e., ``..''. If _d_i_r begins with a slash (/), then CCDD-- - PPAATTHH is not used. The --PP option causes ccdd to use the physical - directory structure by resolving symbolic links while traversing - _d_i_r and before processing instances of _._. in _d_i_r (see also the - --PP option to the sseett builtin command); the --LL option forces sym- - bolic links to be followed by resolving the link after process- - ing instances of _._. in _d_i_r. If _._. appears in _d_i_r, it is pro- - cessed by removing the immediately previous pathname component - from _d_i_r, back to a slash or the beginning of _d_i_r. If the --ee - option is supplied with --PP, and the current working directory - cannot be successfully determined after a successful directory - change, ccdd will return an unsuccessful status. On systems that - support it, the --@@ option presents the extended attributes asso- - ciated with a file as a directory. An argument of -- is con- - verted to $$OOLLDDPPWWDD before the directory change is attempted. If - a non-empty directory name from CCDDPPAATTHH is used, or if -- is the - first argument, and the directory change is successful, the ab- - solute pathname of the new working directory is written to the - standard output. If the directory change is successful, ccdd sets - the value of the PPWWDD environment variable to the new directory - name, and sets the OOLLDDPPWWDD environment variable to the value of - the current working directory before the change. The return - value is true if the directory was successfully changed; false - otherwise. + the value of the HHOOMMEE shell variable is used as _d_i_r. The vari- + able CCDDPPAATTHH exists, and _d_i_r does not begin with a slash (/), ccdd + uses it as a search path: the shell searches each directory name + in CCDDPPAATTHH for _d_i_r. Alternative directory names in CCDDPPAATTHH are + separated by a colon (:). A null directory name in CCDDPPAATTHH is + the same as the current directory, i.e., ".". + + The --PP option causes ccdd to use the physical directory structure + by resolving symbolic links while traversing _d_i_r and before pro- + cessing instances of _._. in _d_i_r (see also the --PP option to the + sseett builtin command). + + The --LL option forces ccdd to follow symbolic links by resolving + the link after processing instances of _._. in _d_i_r. If _._. appears + in _d_i_r, ccdd processes it by removing the immediately previous + pathname component from _d_i_r, back to a slash or the beginning of + _d_i_r, and verifying that the portion of _d_i_r it has processed to + that point is still a valid directory name after removing the + pathname component. If it is not a valid directory name, ccdd re- + turns a non-zero status. If neither --LL nor --PP is supplied, ccdd + behaves as if --LL had been supplied. + + If the --ee option is supplied with --PP, and ccdd cannot successfully + determine the current working directory after a successful di- + rectory change, it returns a non-zero status. + + On systems that support it, the --@@ option presents the extended + attributes associated with a file as a directory. + + An argument of -- is converted to $$OOLLDDPPWWDD before attempting the + directory change. + + If ccdd uses a non-empty directory name from CCDDPPAATTHH, or if -- is + the first argument, and the directory change is successful, ccdd + writes the absolute pathname of the new working directory to the + standard output. + + If the directory change is successful, ccdd sets the value of the + PPWWDD environment variable to the new directory name, and sets the + OOLLDDPPWWDD environment variable to the value of the current working + directory before the change. + + The return value is true if the directory was successfully + changed; false otherwise. ccoommmmaanndd [--ppVVvv] _c_o_m_m_a_n_d [_a_r_g ...] - Run _c_o_m_m_a_n_d with _a_r_g_s suppressing the normal shell function - lookup. Only builtin commands or commands found in the PPAATTHH are - executed. If the --pp option is given, the search for _c_o_m_m_a_n_d is - performed using a default value for PPAATTHH that is guaranteed to - find all of the standard utilities. If either the --VV or --vv op- - tion is supplied, a description of _c_o_m_m_a_n_d is printed. The --vv - option causes a single word indicating the command or filename - used to invoke _c_o_m_m_a_n_d to be displayed; the --VV option produces a - more verbose description. If the --VV or --vv option is supplied, - the exit status is 0 if _c_o_m_m_a_n_d was found, and 1 if not. If - neither option is supplied and an error occurred or _c_o_m_m_a_n_d can- - not be found, the exit status is 127. Otherwise, the exit sta- - tus of the ccoommmmaanndd builtin is the exit status of _c_o_m_m_a_n_d. - - ccoommppggeenn [_o_p_t_i_o_n] [_w_o_r_d] - Generate possible completion matches for _w_o_r_d according to the - _o_p_t_i_o_ns, which may be any option accepted by the ccoommpplleettee - builtin with the exception of --pp and --rr, and write the matches - to the standard output. When using the --FF or --CC options, the - various shell variables set by the programmable completion fa- - cilities, while available, will not have useful values. + The ccoommmmaanndd builtin runs _c_o_m_m_a_n_d with _a_r_g_s suppressing the nor- + mal shell function lookup for _c_o_m_m_a_n_d. Only builtin commands or + commands found in the PPAATTHH named _c_o_m_m_a_n_d are executed. If the + --pp option is supplied, the search for _c_o_m_m_a_n_d is performed using + a default value for PPAATTHH that is guaranteed to find all of the + standard utilities. + + If either the --VV or --vv option is supplied, ccoommmmaanndd prints a de- + scription of _c_o_m_m_a_n_d. The --vv option displays a single word in- + dicating the command or filename used to invoke _c_o_m_m_a_n_d; the --VV + option produces a more verbose description. + + If the --VV or --vv option is supplied, the exit status is zero if + _c_o_m_m_a_n_d was found, and non-zero if not. If neither option is + supplied and an error occurred or _c_o_m_m_a_n_d cannot be found, the + exit status is 127. Otherwise, the exit status of the ccoommmmaanndd + builtin is the exit status of _c_o_m_m_a_n_d. + + ccoommppggeenn [--VV _v_a_r_n_a_m_e] [_o_p_t_i_o_n] [_w_o_r_d] + Generate possible completion matches for _w_o_r_d according to the + _o_p_t_i_o_ns, which may be any option accepted by the ccoommpplleettee + builtin with the exceptions of --pp, --rr, --DD, --EE, and --II, and write + the matches to the standard output. + + If the --VV option is supplied, ccoommppggeenn stores the generated com- + pletions into the indexed array variable _v_a_r_n_a_m_e instead of + writing them to the standard output. + + When using the --FF or --CC options, the various shell variables set + by the programmable completion facilities, while available, will + not have useful values. The matches will be generated in the same way as if the program- mable completion code had generated them directly from a comple- tion specification with the same flags. If _w_o_r_d is specified, - only those completions matching _w_o_r_d will be displayed. + only those completions matching _w_o_r_d will be displayed or + stored. - The return value is true unless an invalid option is supplied, + The return value is true unless an invalid option is supplied, or no matches were generated. - ccoommpplleettee [--aabbccddeeffggjjkkssuuvv] [--oo _c_o_m_p_-_o_p_t_i_o_n] [--DDEEII] [--AA _a_c_t_i_o_n] [--GG _g_l_o_b_- - _p_a_t] [--WW _w_o_r_d_l_i_s_t] - [--FF _f_u_n_c_t_i_o_n] [--CC _c_o_m_m_a_n_d] [--XX _f_i_l_t_e_r_p_a_t] [--PP _p_r_e_f_i_x] [--SS _s_u_f_- - _f_i_x] _n_a_m_e [_n_a_m_e _._._.] + ccoommpplleettee [--aabbccddeeffggjjkkssuuvv] [--oo _c_o_m_p_-_o_p_t_i_o_n] [--DDEEII] [--AA _a_c_t_i_o_n] + [--GG _g_l_o_b_p_a_t] [--WW _w_o_r_d_l_i_s_t] [--FF _f_u_n_c_t_i_o_n] [--CC _c_o_m_m_a_n_d] + [--XX _f_i_l_t_e_r_p_a_t] [--PP _p_r_e_f_i_x] [--SS _s_u_f_f_i_x] _n_a_m_e [_n_a_m_e ...] ccoommpplleettee --pprr [--DDEEII] [_n_a_m_e ...] - Specify how arguments to each _n_a_m_e should be completed. If the - --pp option is supplied, or if no options are supplied, existing - completion specifications are printed in a way that allows them - to be reused as input. The --rr option removes a completion spec- - ification for each _n_a_m_e, or, if no _n_a_m_es are supplied, all com- - pletion specifications. The --DD option indicates that other sup- - plied options and actions should apply to the ``default'' com- - mand completion; that is, completion attempted on a command for - which no completion has previously been defined. The --EE option - indicates that other supplied options and actions should apply - to ``empty'' command completion; that is, completion attempted - on a blank line. The --II option indicates that other supplied - options and actions should apply to completion on the initial - non-assignment word on the line, or after a command delimiter - such as ;; or ||, which is usually command name completion. If - multiple options are supplied, the --DD option takes precedence - over --EE, and both take precedence over --II. If any of --DD, --EE, or - --II are supplied, any other _n_a_m_e arguments are ignored; these - completions only apply to the case specified by the option. - - The process of applying these completion specifications when - word completion is attempted is described above under PPrrooggrraamm-- - mmaabbllee CCoommpplleettiioonn. + Specify how arguments to each _n_a_m_e should be completed. + + If the --pp option is supplied, or if no options or _n_a_m_es are sup- + plied, print existing completion specifications in a way that + allows them to be reused as input. The --rr option removes a com- + pletion specification for each _n_a_m_e, or, if no _n_a_m_es are sup- + plied, all completion specifications. + + The --DD option indicates that other supplied options and actions + should apply to the "default" command completion; that is, com- + pletion attempted on a command for which no completion has pre- + viously been defined. The --EE option indicates that other sup- + plied options and actions should apply to "empty" command com- + pletion; that is, completion attempted on a blank line. The --II + option indicates that other supplied options and actions should + apply to completion on the initial non-assignment word on the + line, or after a command delimiter such as ;; or ||, which is usu- + ally command name completion. If multiple options are supplied, + the --DD option takes precedence over --EE, and both take precedence + over --II. If any of --DD, --EE, or --II are supplied, any other _n_a_m_e + arguments are ignored; these completions only apply to the case + specified by the option. + + The process of applying these completion specifications when at- + tempting word completion is described above under PPrrooggrraammmmaabbllee + CCoommpplleettiioonn. Other options, if specified, have the following meanings. The arguments to the --GG, --WW, and --XX options (and, if necessary, the --PP and --SS options) should be quoted to protect them from expan- sion before the ccoommpplleettee builtin is invoked. + --oo _c_o_m_p_-_o_p_t_i_o_n The _c_o_m_p_-_o_p_t_i_o_n controls several aspects of the comp- spec's behavior beyond the simple generation of comple- @@ -4706,31 +5354,34 @@ SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS bbaasshhddeeffaauulltt Perform the rest of the default bbaasshh completions if the compspec generates no matches. - ddeeffaauulltt Use readline's default filename completion if + ddeeffaauulltt Use rreeaaddlliinnee's default filename completion if the compspec generates no matches. ddiirrnnaammeess - Perform directory name completion if the comp- + Perform directory name completion if the comp- spec generates no matches. ffiilleennaammeess - Tell readline that the compspec generates file- - names, so it can perform any filename-specific - processing (like adding a slash to directory - names, quoting special characters, or suppress- - ing trailing spaces). Intended to be used with - shell functions. - nnooqquuoottee Tell readline not to quote the completed words + Tell rreeaaddlliinnee that the compspec generates file- + names, so it can perform any filename-specific + processing (such as adding a slash to directory + names, quoting special characters, or suppress- + ing trailing spaces). This is intended to be + used with shell functions. + ffuullllqquuoottee + Tell rreeaaddlliinnee to quote all the completed words + even if they are not filenames. + nnooqquuoottee Tell rreeaaddlliinnee not to quote the completed words if they are filenames (quoting filenames is the default). - nnoossoorrtt Tell readline not to sort the list of possible + nnoossoorrtt Tell rreeaaddlliinnee not to sort the list of possible completions alphabetically. - nnoossppaaccee Tell readline not to append a space (the de- + nnoossppaaccee Tell rreeaaddlliinnee not to append a space (the de- fault) to words completed at the end of the line. pplluussddiirrss - After any matches defined by the compspec are - generated, directory name completion is at- - tempted and any matches are added to the results - of the other actions. + After generating any matches defined by the + compspec, attempt directory name completion and + add any matches to the results of the other ac- + tions. --AA _a_c_t_i_o_n The _a_c_t_i_o_n may be one of the following to generate a list of possible completions: @@ -4748,7 +5399,9 @@ SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS eennaabblleedd Names of enabled shell builtins. eexxppoorrtt Names of exported shell variables. May also be specified as --ee. - ffiillee File names. May also be specified as --ff. + ffiillee File and directory names, similar to rreeaaddlliinnee's + filename completion. May also be specified as + --ff. ffuunnccttiioonn Names of shell functions. ggrroouupp Group names. May also be specified as --gg. @@ -4774,109 +5427,119 @@ SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS Names of all shell variables. May also be spec- ified as --vv. --CC _c_o_m_m_a_n_d - _c_o_m_m_a_n_d is executed in a subshell environment, and its - output is used as the possible completions. Arguments + _c_o_m_m_a_n_d is executed in a subshell environment, and its + output is used as the possible completions. Arguments are passed as with the --FF option. --FF _f_u_n_c_t_i_o_n - The shell function _f_u_n_c_t_i_o_n is executed in the current - shell environment. When the function is executed, the + The shell function _f_u_n_c_t_i_o_n is executed in the current + shell environment. When the function is executed, the first argument ($$11) is the name of the command whose ar- guments are being completed, the second argument ($$22) is the word being completed, and the third argument ($$33) is the word preceding the word being completed on the cur- - rent command line. When it finishes, the possible com- - pletions are retrieved from the value of the CCOOMMPPRREEPPLLYY - array variable. + rent command line. When _f_u_n_c_t_i_o_n finishes, programmable + completion retrieves the possible completions from the + value of the CCOOMMPPRREEPPLLYY array variable. --GG _g_l_o_b_p_a_t - The pathname expansion pattern _g_l_o_b_p_a_t is expanded to - generate the possible completions. + Expand the pathname expansion pattern _g_l_o_b_p_a_t to gener- + ate the possible completions. --PP _p_r_e_f_i_x - _p_r_e_f_i_x is added at the beginning of each possible com- - pletion after all other options have been applied. + Add _p_r_e_f_i_x to the beginning of each possible completion + after all other options have been applied. --SS _s_u_f_f_i_x - _s_u_f_f_i_x is appended to each possible completion after all + Append _s_u_f_f_i_x to each possible completion after all other options have been applied. --WW _w_o_r_d_l_i_s_t - The _w_o_r_d_l_i_s_t is split using the characters in the IIFFSS - special variable as delimiters, and each resultant word - is expanded. Shell quoting is honored within _w_o_r_d_l_i_s_t, - in order to provide a mechanism for the words to contain - shell metacharacters or characters in the value of IIFFSS. - The possible completions are the members of the resul- - tant list which match the word being completed. + Split the _w_o_r_d_l_i_s_t using the characters in the IIFFSS spe- + cial variable as delimiters, and expand each resulting + word. Shell quoting is honored within _w_o_r_d_l_i_s_t, in or- + der to provide a mechanism for the words to contain + shell metacharacters or characters in the value of IIFFSS. + The possible completions are the members of the resul- + tant list which match a prefix of the word being com- + pleted. --XX _f_i_l_t_e_r_p_a_t _f_i_l_t_e_r_p_a_t is a pattern as used for pathname expansion. It is applied to the list of possible completions gener- - ated by the preceding options and arguments, and each - completion matching _f_i_l_t_e_r_p_a_t is removed from the list. - A leading !! in _f_i_l_t_e_r_p_a_t negates the pattern; in this + ated by the preceding options and arguments, and each + completion matching _f_i_l_t_e_r_p_a_t is removed from the list. + A leading !! in _f_i_l_t_e_r_p_a_t negates the pattern; in this case, any completion not matching _f_i_l_t_e_r_p_a_t is removed. - The return value is true unless an invalid option is supplied, - an option other than --pp or --rr is supplied without a _n_a_m_e argu- - ment, an attempt is made to remove a completion specification - for a _n_a_m_e for which no specification exists, or an error occurs - adding a completion specification. + The return value is true unless an invalid option is supplied, + an option other than --pp, --rr, --DD, --EE, or --II is supplied without a + _n_a_m_e argument, an attempt is made to remove a completion speci- + fication for a _n_a_m_e for which no specification exists, or an er- + ror occurs adding a completion specification. ccoommppoopptt [--oo _o_p_t_i_o_n] [--DDEEII] [++oo _o_p_t_i_o_n] [_n_a_m_e] - Modify completion options for each _n_a_m_e according to the _o_p_- + Modify completion options for each _n_a_m_e according to the _o_p_- _t_i_o_ns, or for the currently-executing completion if no _n_a_m_es are - supplied. If no _o_p_t_i_o_ns are given, display the completion op- - tions for each _n_a_m_e or the current completion. The possible + supplied. If no _o_p_t_i_o_ns are supplied, display the completion + options for each _n_a_m_e or the current completion. The possible values of _o_p_t_i_o_n are those valid for the ccoommpplleettee builtin de- - scribed above. The --DD option indicates that other supplied op- - tions should apply to the ``default'' command completion; that - is, completion attempted on a command for which no completion - has previously been defined. The --EE option indicates that other - supplied options should apply to ``empty'' command completion; - that is, completion attempted on a blank line. The --II option - indicates that other supplied options should apply to completion - on the initial non-assignment word on the line, or after a com- - mand delimiter such as ;; or ||, which is usually command name - completion. + scribed above. - The return value is true unless an invalid option is supplied, + The --DD option indicates that other supplied options should apply + to the "default" command completion; the --EE option indicates + that other supplied options should apply to "empty" command com- + pletion; and the --II option indicates that other supplied options + should apply to completion on the initial word on the line. + These are determined in the same way as the ccoommpplleettee builtin. + + If multiple options are supplied, the --DD option takes precedence + over --EE, and both take precedence over --II. + + The return value is true unless an invalid option is supplied, an attempt is made to modify the options for a _n_a_m_e for which no completion specification exists, or an output error occurs. ccoonnttiinnuuee [_n] - Resume the next iteration of the enclosing ffoorr, wwhhiillee, uunnttiill, or - sseelleecctt loop. If _n is specified, resume at the _nth enclosing - loop. _n must be >= 1. If _n is greater than the number of en- - closing loops, the last enclosing loop (the ``top-level'' loop) - is resumed. The return value is 0 unless _n is not greater than - or equal to 1. + ccoonnttiinnuuee resumes the next iteration of the enclosing ffoorr, wwhhiillee, + uunnttiill, or sseelleecctt loop. If _n is specified, bbaasshh resumes the _nth + enclosing loop. _n must be >= 1. If _n is greater than the num- + ber of enclosing loops, the shell resumes the last enclosing + loop (the "top-level" loop). The return value is 0 unless _n is + not greater than or equal to 1. ddeeccllaarree [--aaAAffFFggiiIIllnnrrttuuxx] [--pp] [_n_a_m_e[=_v_a_l_u_e] ...] ttyyppeesseett [--aaAAffFFggiiIIllnnrrttuuxx] [--pp] [_n_a_m_e[=_v_a_l_u_e] ...] - Declare variables and/or give them attributes. If no _n_a_m_es are - given then display the values of variables. The --pp option will - display the attributes and values of each _n_a_m_e. When --pp is used - with _n_a_m_e arguments, additional options, other than --ff and --FF, - are ignored. When --pp is supplied without _n_a_m_e arguments, it - will display the attributes and values of all variables having - the attributes specified by the additional options. If no other - options are supplied with --pp, ddeeccllaarree will display the at- - tributes and values of all shell variables. The --ff option will - restrict the display to shell functions. The --FF option inhibits - the display of function definitions; only the function name and - attributes are printed. If the eexxttddeebbuugg shell option is enabled - using sshhoopptt, the source file name and line number where each - _n_a_m_e is defined are displayed as well. The --FF option implies - --ff. The --gg option forces variables to be created or modified at - the global scope, even when ddeeccllaarree is executed in a shell func- - tion. It is ignored in all other cases. The --II option causes - local variables to inherit the attributes (except the _n_a_m_e_r_e_f - attribute) and value of any existing variable with the same _n_a_m_e - at a surrounding scope. If there is no existing variable, the - local variable is initially unset. The following options can be - used to restrict output to variables with the specified attri- - bute or to give variables attributes: - --aa Each _n_a_m_e is an indexed array variable (see AArrrraayyss + Declare variables and/or give them attributes. If no _n_a_m_es are + given then display the values of variables or functions. The --pp + option will display the attributes and values of each _n_a_m_e. + When --pp is used with _n_a_m_e arguments, additional options, other + than --ff and --FF, are ignored. + + When --pp is supplied without _n_a_m_e arguments, ddeeccllaarree will display + the attributes and values of all variables having the attributes + specified by the additional options. If no other options are + supplied with --pp, ddeeccllaarree will display the attributes and values + of all shell variables. The --ff option restricts the display to + shell functions. + + The --FF option inhibits the display of function definitions; only + the function name and attributes are printed. If the eexxttddeebbuugg + shell option is enabled using sshhoopptt, the source file name and + line number where each _n_a_m_e is defined are displayed as well. + The --FF option implies --ff. + + The --gg option forces variables to be created or modified at the + global scope, even when ddeeccllaarree is executed in a shell function. + It is ignored when ddeeccllaarree is not executed in a shell function. + + The --II option causes local variables to inherit the attributes + (except the _n_a_m_e_r_e_f attribute) and value of any existing vari- + able with the same _n_a_m_e at a surrounding scope. If there is no + existing variable, the local variable is initially unset. + + The following options can be used to restrict output to vari- + ables with the specified attribute or to give variables attrib- + utes: + --aa Each _n_a_m_e is an indexed array variable (see AArrrraayyss above). - --AA Each _n_a_m_e is an associative array variable (see AArrrraayyss + --AA Each _n_a_m_e is an associative array variable (see AArrrraayyss above). - --ff Use function names only. + --ff Each _n_a_m_e refers to a shell function. --ii The variable is treated as an integer; arithmetic evalua- tion (see AARRIITTHHMMEETTIICC EEVVAALLUUAATTIIOONN above) is performed when the variable is assigned a value. @@ -4898,35 +5561,40 @@ SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS --uu When the variable is assigned a value, all lower-case characters are converted to upper-case. The lower-case attribute is disabled. - --xx Mark _n_a_m_es for export to subsequent commands via the en- - vironment. - - Using `+' instead of `-' turns off the attribute instead, with - the exceptions that ++aa and ++AA may not be used to destroy array - variables and ++rr will not remove the readonly attribute. When - used in a function, ddeeccllaarree and ttyyppeesseett make each _n_a_m_e local, as - with the llooccaall command, unless the --gg option is supplied. If a - variable name is followed by =_v_a_l_u_e, the value of the variable - is set to _v_a_l_u_e. When using --aa or --AA and the compound assign- - ment syntax to create array variables, additional attributes do - not take effect until subsequent assignments. The return value - is 0 unless an invalid option is encountered, an attempt is made - to define a function using ``-f foo=bar'', an attempt is made to - assign a value to a readonly variable, an attempt is made to as- - sign a value to an array variable without using the compound as- - signment syntax (see AArrrraayyss above), one of the _n_a_m_e_s is not a - valid shell variable name, an attempt is made to turn off read- - only status for a readonly variable, an attempt is made to turn - off array status for an array variable, or an attempt is made to - display a non-existent function with --ff. + --xx Mark each _n_a_m_e for export to subsequent commands via the + environment. + + Using "+" instead of "-" turns off the specified attribute in- + stead, with the exceptions that ++aa and ++AA may not be used to de- + stroy array variables and ++rr will not remove the readonly at- + tribute. + + When used in a function, ddeeccllaarree and ttyyppeesseett make each _n_a_m_e lo- + cal, as with the llooccaall command, unless the --gg option is sup- + plied. If a variable name is followed by =_v_a_l_u_e, the value of + the variable is set to _v_a_l_u_e. When using --aa or --AA and the com- + pound assignment syntax to create array variables, additional + attributes do not take effect until subsequent assignments. + + The return value is 0 unless an invalid option is encountered, + an attempt is made to define a function using "-f foo=bar", an + attempt is made to assign a value to a readonly variable, an at- + tempt is made to assign a value to an array variable without us- + ing the compound assignment syntax (see AArrrraayyss above), one of + the _n_a_m_e_s is not a valid shell variable name, an attempt is made + to turn off readonly status for a readonly variable, an attempt + is made to turn off array status for an array variable, or an + attempt is made to display a non-existent function with --ff. ddiirrss [[--ccllppvv]] [[++_n]] [[--_n]] - Without options, displays the list of currently remembered di- - rectories. The default display is on a single line with direc- - tory names separated by spaces. Directories are added to the - list with the ppuusshhdd command; the ppooppdd command removes entries - from the list. The current directory is always the first direc- - tory in the stack. + Without options, display the list of currently remembered direc- + tories. The default display is on a single line with directory + names separated by spaces. Directories are added to the list + with the ppuusshhdd command; the ppooppdd command removes entries from + the list. The current directory is always the first directory + in the stack. + + Options, if supplied, have the following meanings: --cc Clears the directory stack by deleting all of the en- tries. --ll Produces a listing using full pathnames; the default @@ -4941,32 +5609,40 @@ SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS list shown by ddiirrss when invoked without options, starting with zero. - The return value is 0 unless an invalid option is supplied or _n + The return value is 0 unless an invalid option is supplied or _n indexes beyond the end of the directory stack. - ddiissoowwnn [--aarr] [--hh] [_j_o_b_s_p_e_c ... | _p_i_d ... ] - Without options, remove each _j_o_b_s_p_e_c from the table of active - jobs. If _j_o_b_s_p_e_c is not present, and neither the --aa nor the --rr - option is supplied, the _c_u_r_r_e_n_t _j_o_b is used. If the --hh option - is given, each _j_o_b_s_p_e_c is not removed from the table, but is - marked so that SSIIGGHHUUPP is not sent to the job if the shell re- - ceives a SSIIGGHHUUPP. If no _j_o_b_s_p_e_c is supplied, the --aa option means - to remove or mark all jobs; the --rr option without a _j_o_b_s_p_e_c ar- - gument restricts operation to running jobs. The return value is - 0 unless a _j_o_b_s_p_e_c does not specify a valid job. + ddiissoowwnn [--aarr] [--hh] [_i_d ...] + Without options, remove each _i_d from the table of active jobs. + Each _i_d may be a job specification _j_o_b_s_p_e_c or a process ID _p_i_d; + if _i_d is a _p_i_d, ddiissoowwnn uses the job containing _p_i_d as _j_o_b_s_p_e_c. + + If the --hh option is supplied, ddiissoowwnn does not remove the jobs + corresponding to each _i_d from the jobs table, but rather marks + them so the shell does not send SSIIGGHHUUPP to the job if the shell + receives a SSIIGGHHUUPP. + + If no _i_d is supplied, the --aa option means to remove or mark all + jobs; the --rr option without an _i_d argument removes or marks run- + ning jobs. If no _i_d is supplied, and neither the --aa nor the --rr + option is supplied, ddiissoowwnn removes or marks the current job. + + The return value is 0 unless an _i_d does not specify a valid job. eecchhoo [--nneeEE] [_a_r_g ...] Output the _a_r_gs, separated by spaces, followed by a newline. The return status is 0 unless a write error occurs. If --nn is - specified, the trailing newline is suppressed. If the --ee option - is given, interpretation of the following backslash-escaped - characters is enabled. The --EE option disables the interpreta- - tion of these escape characters, even on systems where they are - interpreted by default. The xxppgg__eecchhoo shell option may be used - to dynamically determine whether or not eecchhoo expands these es- - cape characters by default. eecchhoo does not interpret ---- to mean - the end of options. eecchhoo interprets the following escape se- - quences: + specified, the trailing newline is not printed. + + If the --ee option is given, eecchhoo interprets the following back- + slash-escaped characters. The --EE option disables interpretation + of these escape characters, even on systems where they are in- + terpreted by default. The xxppgg__eecchhoo shell option determines + whether or not eecchhoo interprets any options and expands these es- + cape characters. eecchhoo does not interpret ---- to mean the end of + options. + + eecchhoo interprets the following escape sequences: \\aa alert (bell) \\bb backspace \\cc suppress further output @@ -4978,82 +5654,107 @@ SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS \\tt horizontal tab \\vv vertical tab \\\\ backslash - \\00_n_n_n the eight-bit character whose value is the octal value - _n_n_n (zero to three octal digits) - \\xx_H_H the eight-bit character whose value is the hexadecimal - value _H_H (one or two hex digits) - \\uu_H_H_H_H the Unicode (ISO/IEC 10646) character whose value is the - hexadecimal value _H_H_H_H (one to four hex digits) + \\00_n_n_n The eight-bit character whose value is the octal value + _n_n_n (zero to three octal digits). + \\xx_H_H The eight-bit character whose value is the hexadecimal + value _H_H (one or two hex digits). + \\uu_H_H_H_H The Unicode (ISO/IEC 10646) character whose value is the + hexadecimal value _H_H_H_H (one to four hex digits). \\UU_H_H_H_H_H_H_H_H - the Unicode (ISO/IEC 10646) character whose value is the - hexadecimal value _H_H_H_H_H_H_H_H (one to eight hex digits) + The Unicode (ISO/IEC 10646) character whose value is the + hexadecimal value _H_H_H_H_H_H_H_H (one to eight hex digits). + + eecchhoo writes any unrecognized backslash-escaped characters un- + changed. eennaabbllee [--aa] [--ddnnppss] [--ff _f_i_l_e_n_a_m_e] [_n_a_m_e ...] - Enable and disable builtin shell commands. Disabling a builtin - allows a disk command which has the same name as a shell builtin - to be executed without specifying a full pathname, even though - the shell normally searches for builtins before disk commands. - If --nn is used, each _n_a_m_e is disabled; otherwise, _n_a_m_e_s are en- - abled. For example, to use the tteesstt binary found via the PPAATTHH - instead of the shell builtin version, run ``enable -n test''. + Enable and disable builtin shell commands. Disabling a builtin + allows an executable file which has the same name as a shell + builtin to be executed without specifying a full pathname, even + though the shell normally searches for builtins before files. + + If --nn is supplied, each _n_a_m_e is disabled; otherwise, _n_a_m_es are + enabled. For example, to use the tteesstt binary found using PPAATTHH + instead of the shell builtin version, run "enable -n test". + + If no _n_a_m_e arguments are supplied, or if the --pp option is sup- + plied, print a list of shell builtins. With no other option ar- + guments, the list consists of all enabled shell builtins. If --nn + is supplied, print only disabled builtins. If --aa is supplied, + the list printed includes all builtins, with an indication of + whether or not each is enabled. The --ss option means to restrict + the output to the POSIX _s_p_e_c_i_a_l builtins. + The --ff option means to load the new builtin command _n_a_m_e from shared object _f_i_l_e_n_a_m_e, on systems that support dynamic loading. - Bash will use the value of the BBAASSHH__LLOOAADDAABBLLEESS__PPAATTHH variable as a - colon-separated list of directories in which to search for _f_i_l_e_- - _n_a_m_e. The default is system-dependent. The --dd option will - delete a builtin previously loaded with --ff. If no _n_a_m_e argu- - ments are given, or if the --pp option is supplied, a list of - shell builtins is printed. With no other option arguments, the - list consists of all enabled shell builtins. If --nn is supplied, - only disabled builtins are printed. If --aa is supplied, the list - printed includes all builtins, with an indication of whether or - not each is enabled. If --ss is supplied, the output is re- - stricted to the POSIX _s_p_e_c_i_a_l builtins. If no options are sup- - plied and a _n_a_m_e is not a shell builtin, eennaabbllee will attempt to - load _n_a_m_e from a shared object named _n_a_m_e, as if the command - were ``enable -f _n_a_m_e _n_a_m_e . The return value is 0 unless a - _n_a_m_e is not a shell builtin or there is an error loading a new - builtin from a shared object. + If _f_i_l_e_n_a_m_e does not contain a slash, BBaasshh will use the value of + the BBAASSHH__LLOOAADDAABBLLEESS__PPAATTHH variable as a colon-separated list of + directories in which to search for _f_i_l_e_n_a_m_e. The default for + BBAASSHH__LLOOAADDAABBLLEESS__PPAATTHH is system-dependent, and may include "." to + force a search of the current directory. The --dd option will + delete a builtin previously loaded with --ff. If _-_s is used with + _-_f, the new builtin becomes a POSIX special builtin. + + If no options are supplied and a _n_a_m_e is not a shell builtin, + eennaabbllee will attempt to load _n_a_m_e from a shared object named + _n_a_m_e, as if the command were "enable -f _n_a_m_e _n_a_m_e". + + The return value is 0 unless a _n_a_m_e is not a shell builtin or + there is an error loading a new builtin from a shared object. eevvaall [_a_r_g ...] - The _a_r_gs are read and concatenated together into a single com- - mand. This command is then read and executed by the shell, and - its exit status is returned as the value of eevvaall. If there are - no _a_r_g_s, or only null arguments, eevvaall returns 0. + Concatenate the _a_r_gs together into a single command, separating + them with spaces. BBaasshh then reads and execute this command, and + returns its exit status as the return status of eevvaall. If there + are no _a_r_g_s, or only null arguments, eevvaall returns 0. eexxeecc [--ccll] [--aa _n_a_m_e] [_c_o_m_m_a_n_d [_a_r_g_u_m_e_n_t_s]] - If _c_o_m_m_a_n_d is specified, it replaces the shell. No new process - is created. The _a_r_g_u_m_e_n_t_s become the arguments to _c_o_m_m_a_n_d. If - the --ll option is supplied, the shell places a dash at the begin- - ning of the zeroth argument passed to _c_o_m_m_a_n_d. This is what _l_o_- - _g_i_n(1) does. The --cc option causes _c_o_m_m_a_n_d to be executed with - an empty environment. If --aa is supplied, the shell passes _n_a_m_e - as the zeroth argument to the executed command. If _c_o_m_m_a_n_d can- - not be executed for some reason, a non-interactive shell exits, - unless the eexxeeccffaaiill shell option is enabled. In that case, it - returns failure. An interactive shell returns failure if the - file cannot be executed. A subshell exits unconditionally if - eexxeecc fails. If _c_o_m_m_a_n_d is not specified, any redirections take - effect in the current shell, and the return status is 0. If - there is a redirection error, the return status is 1. + If _c_o_m_m_a_n_d is specified, it replaces the shell without creating + a new process. _c_o_m_m_a_n_d cannot be a shell builtin or function. + The _a_r_g_u_m_e_n_t_s become the arguments to _c_o_m_m_a_n_d. If the --ll option + is supplied, the shell places a dash at the beginning of the ze- + roth argument passed to _c_o_m_m_a_n_d. This is what _l_o_g_i_n(1) does. + The --cc option causes _c_o_m_m_a_n_d to be executed with an empty envi- + ronment. If --aa is supplied, the shell passes _n_a_m_e as the zeroth + argument to the executed command. + + If _c_o_m_m_a_n_d cannot be executed for some reason, a non-interactive + shell exits, unless the eexxeeccffaaiill shell option is enabled. In + that case, it returns a non-zero status. An interactive shell + returns a non-zero status if the file cannot be executed. A + subshell exits unconditionally if eexxeecc fails. + + If _c_o_m_m_a_n_d is not specified, any redirections take effect in the + current shell, and the return status is 0. If there is a redi- + rection error, the return status is 1. eexxiitt [_n] Cause the shell to exit with a status of _n. If _n is omitted, - the exit status is that of the last command executed. A trap on - EEXXIITT is executed before the shell terminates. + the exit status is that of the last command executed. Any trap + on EEXXIITT is executed before the shell terminates. - eexxppoorrtt [--ffnn] [_n_a_m_e[=_w_o_r_d]] ... - eexxppoorrtt --pp + eexxppoorrtt [--ffnn] [_n_a_m_e[=_v_a_l_u_e]] ... + eexxppoorrtt --pp [[--ff]] The supplied _n_a_m_e_s are marked for automatic export to the envi- ronment of subsequently executed commands. If the --ff option is - given, the _n_a_m_e_s refer to functions. If no _n_a_m_e_s are given, or - if the --pp option is supplied, a list of names of all exported - variables is printed. The --nn option causes the export property - to be removed from each _n_a_m_e. If a variable name is followed by - =_w_o_r_d, the value of the variable is set to _w_o_r_d. eexxppoorrtt returns - an exit status of 0 unless an invalid option is encountered, one - of the _n_a_m_e_s is not a valid shell variable name, or --ff is sup- - plied with a _n_a_m_e that is not a function. + given, the _n_a_m_e_s refer to functions. + + The --nn option unexports, or removes the export attribute, from + each _n_a_m_e. If no _n_a_m_e_s are given, or if only the --pp option is + supplied, eexxppoorrtt displays a list of names of all exported vari- + ables on the standard output. Using --pp and --ff together displays + exported functions. The --pp option displays output in a form + that may be reused as input. + + eexxppoorrtt allows the value of a variable to be set when it is ex- + ported or unexported by following the variable name with =_v_a_l_u_e. + This sets the value of the variable to _v_a_l_u_e while modifying the + export attribute. eexxppoorrtt returns an exit status of 0 unless an + invalid option is encountered, one of the _n_a_m_e_s is not a valid + shell variable name, or --ff is supplied with a _n_a_m_e that is not a + function. + + ffaallssee Does nothing; returns a non-zero status. ffcc [--ee _e_n_a_m_e] [--llnnrr] [_f_i_r_s_t] [_l_a_s_t] ffcc --ss [_p_a_t=_r_e_p] [_c_m_d] @@ -5062,67 +5763,75 @@ SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS them. _F_i_r_s_t and _l_a_s_t may be specified as a string (to locate the last command beginning with that string) or as a number (an index into the history list, where a negative number is used as - an offset from the current command number). When listing, a - _f_i_r_s_t or _l_a_s_t of 0 is equivalent to -1 and -0 is equivalent to - the current command (usually the ffcc command); otherwise 0 is - equivalent to -1 and -0 is invalid. If _l_a_s_t is not specified, - it is set to the current command for listing (so that ``fc -l - -10'' prints the last 10 commands) and to _f_i_r_s_t otherwise. If - _f_i_r_s_t is not specified, it is set to the previous command for + an offset from the current command number). + + When listing, a _f_i_r_s_t or _l_a_s_t of 0 is equivalent to -1 and -0 is + equivalent to the current command (usually the ffcc command); oth- + erwise 0 is equivalent to -1 and -0 is invalid. If _l_a_s_t is not + specified, it is set to the current command for listing (so that + "fc -l -10" prints the last 10 commands) and to _f_i_r_s_t otherwise. + If _f_i_r_s_t is not specified, it is set to the previous command for editing and -16 for listing. - The --nn option suppresses the command numbers when listing. The - --rr option reverses the order of the commands. If the --ll option - is given, the commands are listed on standard output. Other- - wise, the editor given by _e_n_a_m_e is invoked on a file containing - those commands. If _e_n_a_m_e is not given, the value of the FFCCEEDDIITT - variable is used, and the value of EEDDIITTOORR if FFCCEEDDIITT is not set. - If neither variable is set, _v_i is used. When editing is com- - plete, the edited commands are echoed and executed. - - In the second form, _c_o_m_m_a_n_d is re-executed after each instance - of _p_a_t is replaced by _r_e_p. _C_o_m_m_a_n_d is interpreted the same as - _f_i_r_s_t above. A useful alias to use with this is ``r="fc -s"'', - so that typing ``r cc'' runs the last command beginning with - ``cc'' and typing ``r'' re-executes the last command. - - If the first form is used, the return value is 0 unless an in- - valid option is encountered or _f_i_r_s_t or _l_a_s_t specify history - lines out of range. If the --ee option is supplied, the return - value is the value of the last command executed or failure if an - error occurs with the temporary file of commands. If the second - form is used, the return status is that of the command re-exe- - cuted, unless _c_m_d does not specify a valid history line, in - which case ffcc returns failure. + If the --ll option is supplied, the commands are listed on the + standard output. The --nn option suppresses the command numbers + when listing. The --rr option reverses the order of the commands. + + Otherwise, ffcc invokes the editor named by _e_n_a_m_e on a file con- + taining those commands. If _e_n_a_m_e is not supplied, ffcc uses the + value of the FFCCEEDDIITT variable, and the value of EEDDIITTOORR if FFCCEEDDIITT + is not set. If neither variable is set, ffcc uses _v_i_. When edit- + ing is complete, ffcc reads the file containing the edited com- + mands and echoes and executes them. + + In the second form, ffcc re-executes _c_o_m_m_a_n_d after replacing each + instance of _p_a_t with _r_e_p. _C_o_m_m_a_n_d is interpreted the same as + _f_i_r_s_t above. + + A useful alias to use with ffcc is "r="fc -s"", so that typing "r + cc" runs the last command beginning with "cc" and typing "r" re- + executes the last command. + + If the first form is used, the return value is zero unless an + invalid option is encountered or _f_i_r_s_t or _l_a_s_t specify history + lines out of range. When editing and re-executing a file of + commands, the return value is the value of the last command exe- + cuted or failure if an error occurs with the temporary file. If + the second form is used, the return status is that of the re-ex- + ecuted command, unless _c_m_d does not specify a valid history en- + try, in which case ffcc returns a non-zero status. ffgg [_j_o_b_s_p_e_c] Resume _j_o_b_s_p_e_c in the foreground, and make it the current job. - If _j_o_b_s_p_e_c is not present, the shell's notion of the _c_u_r_r_e_n_t _j_o_b - is used. The return value is that of the command placed into - the foreground, or failure if run when job control is disabled - or, when run with job control enabled, if _j_o_b_s_p_e_c does not spec- - ify a valid job or _j_o_b_s_p_e_c specifies a job that was started + If _j_o_b_s_p_e_c is not present, ffgg uses the shell's notion of the + _c_u_r_r_e_n_t _j_o_b. The return value is that of the command placed + into the foreground, or failure if run when job control is dis- + abled or, when run with job control enabled, if _j_o_b_s_p_e_c does not + specify a valid job or _j_o_b_s_p_e_c specifies a job that was started without job control. - ggeettooppttss _o_p_t_s_t_r_i_n_g _n_a_m_e [_a_r_g _._._.] - ggeettooppttss is used by shell procedures to parse positional parame- - ters. _o_p_t_s_t_r_i_n_g contains the option characters to be recog- - nized; if a character is followed by a colon, the option is ex- - pected to have an argument, which should be separated from it by - white space. The colon and question mark characters may not be - used as option characters. Each time it is invoked, ggeettooppttss - places the next option in the shell variable _n_a_m_e, initializing - _n_a_m_e if it does not exist, and the index of the next argument to - be processed into the variable OOPPTTIINNDD. OOPPTTIINNDD is initialized to - 1 each time the shell or a shell script is invoked. When an op- - tion requires an argument, ggeettooppttss places that argument into the - variable OOPPTTAARRGG. The shell does not reset OOPPTTIINNDD automatically; - it must be manually reset between multiple calls to ggeettooppttss - within the same shell invocation if a new set of parameters is - to be used. - - When the end of options is encountered, ggeettooppttss exits with a re- - turn value greater than zero. OOPPTTIINNDD is set to the index of the + ggeettooppttss _o_p_t_s_t_r_i_n_g _n_a_m_e [_a_r_g ...] + ggeettooppttss is used by shell scripts and functions to parse posi- + tional parameters and obtain options and their arguments. _o_p_t_- + _s_t_r_i_n_g contains the option characters to be recognized; if a + character is followed by a colon, the option is expected to have + an argument, which should be separated from it by white space. + The colon and question mark characters may not be used as option + characters. + + Each time it is invoked, ggeettooppttss places the next option in the + shell variable _n_a_m_e, initializing _n_a_m_e if it does not exist, and + the index of the next argument to be processed into the variable + OOPPTTIINNDD. OOPPTTIINNDD is initialized to 1 each time the shell or a + shell script is invoked. When an option requires an argument, + ggeettooppttss places that argument into the variable OOPPTTAARRGG. + + The shell does not reset OOPPTTIINNDD automatically; it must be manu- + ally reset between multiple calls to ggeettooppttss within the same + shell invocation to use a new set of parameters. + + When it reaches the end of options, ggeettooppttss exits with a return + value greater than zero. OOPPTTIINNDD is set to the index of the first non-option argument, and _n_a_m_e is set to ?. ggeettooppttss normally parses the positional parameters, but if more @@ -5130,54 +5839,78 @@ SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS stead. ggeettooppttss can report errors in two ways. If the first character - of _o_p_t_s_t_r_i_n_g is a colon, _s_i_l_e_n_t error reporting is used. In - normal operation, diagnostic messages are printed when invalid - options or missing option arguments are encountered. If the - variable OOPPTTEERRRR is set to 0, no error messages will be dis- - played, even if the first character of _o_p_t_s_t_r_i_n_g is not a colon. - - If an invalid option is seen, ggeettooppttss places ? into _n_a_m_e and, if - not silent, prints an error message and unsets OOPPTTAARRGG. If - ggeettooppttss is silent, the option character found is placed in OOPP-- - TTAARRGG and no diagnostic message is printed. + of _o_p_t_s_t_r_i_n_g is a colon, ggeettooppttss uses _s_i_l_e_n_t error reporting. + In normal operation, ggeettooppttss prints diagnostic messages when it + encounters invalid options or missing option arguments. If the + variable OOPPTTEERRRR is set to 0, ggeettooppttss does not display any error + messages, even if the first character of _o_p_t_s_t_r_i_n_g is not a + colon. + + If ggeettooppttss detects an invalid option, it places ? into _n_a_m_e and, + if not silent, prints an error message and unsets OOPPTTAARRGG. If + ggeettooppttss is silent, it assigns the option character found to OOPP-- + TTAARRGG and does not print a diagnostic message. If a required argument is not found, and ggeettooppttss is not silent, - a question mark (??) is placed in _n_a_m_e, OOPPTTAARRGG is unset, and a - diagnostic message is printed. If ggeettooppttss is silent, then a - colon (::) is placed in _n_a_m_e and OOPPTTAARRGG is set to the option + it sets the value of _n_a_m_e to a question mark (??), unsets OOPPTTAARRGG, + and prints a diagnostic message. If ggeettooppttss is silent, it sets + the value of _n_a_m_e to a colon (::) and sets OOPPTTAARRGG to the option character found. - ggeettooppttss returns true if an option, specified or unspecified, is + ggeettooppttss returns true if an option, specified or unspecified, is found. It returns false if the end of options is encountered or an error occurs. hhaasshh [--llrr] [--pp _f_i_l_e_n_a_m_e] [--ddtt] [_n_a_m_e] - Each time hhaasshh is invoked, the full pathname of the command _n_a_m_e - is determined by searching the directories in $$PPAATTHH and remem- - bered. Any previously-remembered pathname is discarded. If the - --pp option is supplied, no path search is performed, and _f_i_l_e_n_a_m_e - is used as the full filename of the command. The --rr option - causes the shell to forget all remembered locations. The --dd op- - tion causes the shell to forget the remembered location of each - _n_a_m_e. If the --tt option is supplied, the full pathname to which - each _n_a_m_e corresponds is printed. If multiple _n_a_m_e arguments - are supplied with --tt, the _n_a_m_e is printed before the hashed full - pathname. The --ll option causes output to be displayed in a for- - mat that may be reused as input. If no arguments are given, or - if only --ll is supplied, information about remembered commands is - printed. The return status is true unless a _n_a_m_e is not found - or an invalid option is supplied. + Each time hhaasshh is invoked, it remembers the full pathname of the + command _n_a_m_e as determined by searching the directories in + $$PPAATTHH. Any previously-remembered pathname associated with _n_a_m_e + is discarded. If the --pp option is supplied, hhaasshh uses _f_i_l_e_n_a_m_e + as the full pathname of the command. + + The --rr option causes the shell to forget all remembered loca- + tions. Assigning to the PPAATTHH variable also clears all hashed + filenames. The --dd option causes the shell to forget the remem- + bered location of each _n_a_m_e. + + If the --tt option is supplied, hhaasshh prints the full pathname cor- + responding to each _n_a_m_e. If multiple _n_a_m_e arguments are sup- + plied with --tt, hhaasshh prints the _n_a_m_e before the corresponding + hashed full pathname. The --ll option displays output in a format + that may be reused as input. + + If no arguments are given, or if only --ll is supplied, hhaasshh + prints information about remembered commands. The --tt, --dd, and + --pp options (the options that act on the _n_a_m_e arguments) are mu- + tually exclusive. Only one will be active. If more than one is + supplied, --tt has higher priority than --pp, and both have higher + priority than --dd. + + The return status is zero unless a _n_a_m_e is not found or an in- + valid option is supplied. hheellpp [--ddmmss] [_p_a_t_t_e_r_n] - Display helpful information about builtin commands. If _p_a_t_t_e_r_n - is specified, hheellpp gives detailed help on all commands matching - _p_a_t_t_e_r_n; otherwise help for all the builtins and shell control - structures is printed. + Display helpful information about builtin commands. If _p_a_t_t_e_r_n + is specified, hheellpp gives detailed help on all commands matching + _p_a_t_t_e_r_n as described below; otherwise it displays a list of all + the builtins and shell compound commands. + + Options, if supplied, have the follow meanings: + --dd Display a short description of each _p_a_t_t_e_r_n --mm Display the description of each _p_a_t_t_e_r_n in a manpage-like format --ss Display only a short usage synopsis for each _p_a_t_t_e_r_n + If _p_a_t_t_e_r_n contains pattern matching characters (see PPaatttteerrnn + MMaattcchhiinngg above) it's treated as a shell pattern and hheellpp prints + the description of each help topic matching _p_a_t_t_e_r_n. + + If not, and _p_a_t_t_e_r_n exactly matches the name of a help topic, + hheellpp prints the description associated with that topic. Other- + wise, hheellpp performs prefix matching and prints the descriptions + of all matching help topics. + The return status is 0 unless no command matches _p_a_t_t_e_r_n. hhiissttoorryy [[_n]] @@ -5185,265 +5918,303 @@ SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS hhiissttoorryy --dd _o_f_f_s_e_t hhiissttoorryy --dd _s_t_a_r_t-_e_n_d hhiissttoorryy --aannrrww [_f_i_l_e_n_a_m_e] - hhiissttoorryy --pp _a_r_g [_a_r_g _._._.] - hhiissttoorryy --ss _a_r_g [_a_r_g _._._.] - With no options, display the command history list with line num- - bers. Lines listed with a ** have been modified. An argument of - _n lists only the last _n lines. If the shell variable HHIISSTTTTIIMMEE-- - FFOORRMMAATT is set and not null, it is used as a format string for - _s_t_r_f_t_i_m_e(3) to display the time stamp associated with each dis- - played history entry. No intervening blank is printed between - the formatted time stamp and the history line. If _f_i_l_e_n_a_m_e is - supplied, it is used as the name of the history file; if not, - the value of HHIISSTTFFIILLEE is used. Options, if supplied, have the - following meanings: - --cc Clear the history list by deleting all the entries. + hhiissttoorryy --pp _a_r_g [_a_r_g ...] + hhiissttoorryy --ss _a_r_g [_a_r_g ...] + With no options, display the command history list with numbers. + Entries prefixed with a ** have been modified. An argument of _n + lists only the last _n entries. If the shell variable HHIISSTTTTIIMMEE-- + FFOORRMMAATT is set and not null, it is used as a format string for + _s_t_r_f_t_i_m_e(3) to display the time stamp associated with each dis- + played history entry. If hhiissttoorryy uses HHIISSTTTTIIMMEEFFOORRMMAATT, it does + not print an intervening space between the formatted time stamp + and the history entry. + + If _f_i_l_e_n_a_m_e is supplied, hhiissttoorryy uses it as the name of the his- + tory file; if not, it uses the value of HHIISSTTFFIILLEE. If _f_i_l_e_n_a_m_e + is not supplied and HHIISSTTFFIILLEE is unset or null, the --aa,, --nn,, --rr,, + and --ww options have no effect. + + Options, if supplied, have the following meanings: + --cc Clear the history list by deleting all the entries. This + can be used with the other options to replace the history + list. --dd _o_f_f_s_e_t - Delete the history entry at position _o_f_f_s_e_t. If _o_f_f_s_e_t + Delete the history entry at position _o_f_f_s_e_t. If _o_f_f_s_e_t is negative, it is interpreted as relative to one greater than the last history position, so negative indices count - back from the end of the history, and an index of -1 + back from the end of the history, and an index of -1 refers to the current hhiissttoorryy --dd command. --dd _s_t_a_r_t-_e_n_d - Delete the range of history entries between positions - _s_t_a_r_t and _e_n_d, inclusive. Positive and negative values + Delete the range of history entries between positions + _s_t_a_r_t and _e_n_d, inclusive. Positive and negative values for _s_t_a_r_t and _e_n_d are interpreted as described above. - --aa Append the ``new'' history lines to the history file. - These are history lines entered since the beginning of + --aa Append the "new" history lines to the history file. + These are history lines entered since the beginning of the current bbaasshh session, but not already appended to the history file. --nn Read the history lines not already read from the history - file into the current history list. These are lines ap- - pended to the history file since the beginning of the - current bbaasshh session. - --rr Read the contents of the history file and append them to - the current history list. + file and add them to the current history list. These are + lines appended to the history file since the beginning of + the current bbaasshh session. + --rr Read the history file and append its contents to the cur- + rent history list. --ww Write the current history list to the history file, over- - writing the history file's contents. + writing the history file. --pp Perform history substitution on the following _a_r_g_s and - display the result on the standard output. Does not - store the results in the history list. Each _a_r_g must be + display the result on the standard output, without stor- + ing the results in the history list. Each _a_r_g must be quoted to disable normal history expansion. --ss Store the _a_r_g_s in the history list as a single entry. The last command in the history list is removed before - the _a_r_g_s are added. - - If the HHIISSTTTTIIMMEEFFOORRMMAATT variable is set, the time stamp informa- - tion associated with each history entry is written to the his- - tory file, marked with the history comment character. When the - history file is read, lines beginning with the history comment - character followed immediately by a digit are interpreted as - timestamps for the following history entry. The return value is - 0 unless an invalid option is encountered, an error occurs while - reading or writing the history file, an invalid _o_f_f_s_e_t or range - is supplied as an argument to --dd, or the history expansion sup- - plied as an argument to --pp fails. + adding the _a_r_g_s. + + If the HHIISSTTTTIIMMEEFFOORRMMAATT variable is set, hhiissttoorryy writes the time + stamp information associated with each history entry to the his- + tory file, marked with the history comment character as de- + scribed above. When the history file is read, lines beginning + with the history comment character followed immediately by a + digit are interpreted as timestamps for the following history + entry. + + The return value is 0 unless an invalid option is encountered, + an error occurs while reading or writing the history file, an + invalid _o_f_f_s_e_t or range is supplied as an argument to --dd, or the + history expansion supplied as an argument to --pp fails. jjoobbss [--llnnpprrss] [ _j_o_b_s_p_e_c ... ] jjoobbss --xx _c_o_m_m_a_n_d [ _a_r_g_s ... ] The first form lists the active jobs. The options have the fol- lowing meanings: --ll List process IDs in addition to the normal information. - --nn Display information only about jobs that have changed + --nn Display information only about jobs that have changed status since the user was last notified of their status. - --pp List only the process ID of the job's process group + --pp List only the process ID of the job's process group leader. --rr Display only running jobs. --ss Display only stopped jobs. - If _j_o_b_s_p_e_c is given, output is restricted to information about - that job. The return status is 0 unless an invalid option is - encountered or an invalid _j_o_b_s_p_e_c is supplied. + If _j_o_b_s_p_e_c is supplied, jjoobbss restricts output to information + about that job. The return status is 0 unless an invalid option + is encountered or an invalid _j_o_b_s_p_e_c is supplied. If the --xx option is supplied, jjoobbss replaces any _j_o_b_s_p_e_c found in _c_o_m_m_a_n_d or _a_r_g_s with the corresponding process group ID, and ex- - ecutes _c_o_m_m_a_n_d passing it _a_r_g_s, returning its exit status. + ecutes _c_o_m_m_a_n_d, passing it _a_r_g_s, returning its exit status. - kkiillll [--ss _s_i_g_s_p_e_c | --nn _s_i_g_n_u_m | --_s_i_g_s_p_e_c] [_p_i_d | _j_o_b_s_p_e_c] ... + kkiillll [--ss _s_i_g_s_p_e_c | --nn _s_i_g_n_u_m | --_s_i_g_s_p_e_c] _i_d [ ... ] kkiillll --ll|--LL [_s_i_g_s_p_e_c | _e_x_i_t___s_t_a_t_u_s] - Send the signal named by _s_i_g_s_p_e_c or _s_i_g_n_u_m to the processes - named by _p_i_d or _j_o_b_s_p_e_c. _s_i_g_s_p_e_c is either a case-insensitive - signal name such as SSIIGGKKIILLLL (with or without the SSIIGG prefix) or - a signal number; _s_i_g_n_u_m is a signal number. If _s_i_g_s_p_e_c is not - present, then SSIIGGTTEERRMM is assumed. An argument of --ll lists the - signal names. If any arguments are supplied when --ll is given, - the names of the signals corresponding to the arguments are - listed, and the return status is 0. The _e_x_i_t___s_t_a_t_u_s argument to - --ll is a number specifying either a signal number or the exit - status of a process terminated by a signal. The --LL option is - equivalent to --ll. kkiillll returns true if at least one signal was - successfully sent, or false if an error occurs or an invalid op- - tion is encountered. + Send the signal specified by _s_i_g_s_p_e_c or _s_i_g_n_u_m to the processes + named by each _i_d. Each _i_d may be a job specification _j_o_b_s_p_e_c or + a process ID _p_i_d. _s_i_g_s_p_e_c is either a case-insensitive signal + name such as SSIIGGKKIILLLL (with or without the SSIIGG prefix) or a sig- + nal number; _s_i_g_n_u_m is a signal number. If _s_i_g_s_p_e_c is not sup- + plied, then kkiillll sends SSIIGGTTEERRMM. + + The --ll option lists the signal names. If any arguments are sup- + plied when --ll is given, kkiillll lists the names of the signals cor- + responding to the arguments, and the return status is 0. The + _e_x_i_t___s_t_a_t_u_s argument to --ll is a number specifying either a sig- + nal number or the exit status of a process terminated by a sig- + nal; if it is supplied, kkiillll prints the name of the signal that + caused the process to terminate. kkiillll assumes that process exit + statuses are greater than 128; anything less than that is a sig- + nal number. The --LL option is equivalent to --ll. + + kkiillll returns true if at least one signal was successfully sent, + or false if an error occurs or an invalid option is encountered. lleett _a_r_g [_a_r_g ...] - Each _a_r_g is an arithmetic expression to be evaluated (see AARRIITTHH-- - MMEETTIICC EEVVAALLUUAATTIIOONN above). If the last _a_r_g evaluates to 0, lleett - returns 1; 0 is returned otherwise. + Each _a_r_g is evaluated as an arithmetic expression (see AARRIITTHH-- + MMEETTIICC EEVVAALLUUAATTIIOONN above). If the last _a_r_g evaluates to 0, lleett + returns 1; otherwise lleett returns 0. llooccaall [_o_p_t_i_o_n] [_n_a_m_e[=_v_a_l_u_e] ... | - ] - For each argument, a local variable named _n_a_m_e is created, and - assigned _v_a_l_u_e. The _o_p_t_i_o_n can be any of the options accepted - by ddeeccllaarree. When llooccaall is used within a function, it causes the + For each argument, create a local variable named _n_a_m_e and assign + it _v_a_l_u_e. The _o_p_t_i_o_n can be any of the options accepted by ddee-- + ccllaarree. When llooccaall is used within a function, it causes the variable _n_a_m_e to have a visible scope restricted to that func- - tion and its children. If _n_a_m_e is -, the set of shell options - is made local to the function in which llooccaall is invoked: shell - options changed using the sseett builtin inside the function are - restored to their original values when the function returns. - The restore is effected as if a series of sseett commands were exe- - cuted to restore the values that were in place before the func- - tion. With no operands, llooccaall writes a list of local variables - to the standard output. It is an error to use llooccaall when not - within a function. The return status is 0 unless llooccaall is used - outside a function, an invalid _n_a_m_e is supplied, or _n_a_m_e is a - readonly variable. - - llooggoouutt Exit a login shell. - - mmaappffiillee [--dd _d_e_l_i_m] [--nn _c_o_u_n_t] [--OO _o_r_i_g_i_n] [--ss _c_o_u_n_t] [--tt] [--uu _f_d] [--CC + tion and its children. It is an error to use llooccaall when not + within a function. + + If _n_a_m_e is -, it makes the set of shell options local to the + function in which llooccaall is invoked: any shell options changed + using the sseett builtin inside the function after the call to lloo-- + ccaall are restored to their original values when the function re- + turns. The restore is performed as if a series of sseett commands + were executed to restore the values that were in place before + the function. + + With no operands, llooccaall writes a list of local variables to the + standard output. + + The return status is 0 unless llooccaall is used outside a function, + an invalid _n_a_m_e is supplied, or _n_a_m_e is a readonly variable. + + llooggoouutt [[_n]] + Exit a login shell, returning a status of _n to the shell's par- + ent. + + mmaappffiillee [--dd _d_e_l_i_m] [--nn _c_o_u_n_t] [--OO _o_r_i_g_i_n] [--ss _c_o_u_n_t] [--tt] [--uu _f_d] [--CC _c_a_l_l_b_a_c_k] [--cc _q_u_a_n_t_u_m] [_a_r_r_a_y] rreeaaddaarrrraayy [--dd _d_e_l_i_m] [--nn _c_o_u_n_t] [--OO _o_r_i_g_i_n] [--ss _c_o_u_n_t] [--tt] [--uu _f_d] [--CC _c_a_l_l_b_a_c_k] [--cc _q_u_a_n_t_u_m] [_a_r_r_a_y] - Read lines from the standard input into the indexed array vari- - able _a_r_r_a_y, or from file descriptor _f_d if the --uu option is sup- - plied. The variable MMAAPPFFIILLEE is the default _a_r_r_a_y. Options, if + Read lines from the standard input, or from file descriptor _f_d + if the --uu option is supplied, into the indexed array variable + _a_r_r_a_y. The variable MMAAPPFFIILLEE is the default _a_r_r_a_y. Options, if supplied, have the following meanings: - --dd The first character of _d_e_l_i_m is used to terminate each - input line, rather than newline. If _d_e_l_i_m is the empty - string, mmaappffiillee will terminate a line when it reads a NUL - character. - --nn Copy at most _c_o_u_n_t lines. If _c_o_u_n_t is 0, all lines are - copied. - --OO Begin assigning to _a_r_r_a_y at index _o_r_i_g_i_n. The default + --dd Use the first character of _d_e_l_i_m to terminate each input + line, rather than newline. If _d_e_l_i_m is the empty string, + mmaappffiillee will terminate a line when it reads a NUL charac- + ter. + --nn Copy at most _c_o_u_n_t lines. If _c_o_u_n_t is 0, copy all lines. + --OO Begin assigning to _a_r_r_a_y at index _o_r_i_g_i_n. The default index is 0. --ss Discard the first _c_o_u_n_t lines read. - --tt Remove a trailing _d_e_l_i_m (default newline) from each line + --tt Remove a trailing _d_e_l_i_m (default newline) from each line read. - --uu Read lines from file descriptor _f_d instead of the stan- + --uu Read lines from file descriptor _f_d instead of the stan- dard input. - --CC Evaluate _c_a_l_l_b_a_c_k each time _q_u_a_n_t_u_m lines are read. The + --CC Evaluate _c_a_l_l_b_a_c_k each time _q_u_a_n_t_u_m lines are read. The --cc option specifies _q_u_a_n_t_u_m. - --cc Specify the number of lines read between each call to + --cc Specify the number of lines read between each call to _c_a_l_l_b_a_c_k. - If --CC is specified without --cc, the default quantum is 5000. + If --CC is specified without --cc, the default quantum is 5000. When _c_a_l_l_b_a_c_k is evaluated, it is supplied the index of the next array element to be assigned and the line to be assigned to that - element as additional arguments. _c_a_l_l_b_a_c_k is evaluated after + element as additional arguments. _c_a_l_l_b_a_c_k is evaluated after the line is read but before the array element is assigned. - If not supplied with an explicit origin, mmaappffiillee will clear _a_r_- + If not supplied with an explicit origin, mmaappffiillee will clear _a_r_- _r_a_y before assigning to it. - mmaappffiillee returns successfully unless an invalid option or option - argument is supplied, _a_r_r_a_y is invalid or unassignable, or if - _a_r_r_a_y is not an indexed array. + mmaappffiillee returns zero unless an invalid option or option argument + is supplied, _a_r_r_a_y is invalid or unassignable, or if _a_r_r_a_y is + not an indexed array. ppooppdd [-nn] [+_n] [-_n] - Removes entries from the directory stack. The elements are num- - bered from 0 starting at the first directory listed by ddiirrss. - With no arguments, ppooppdd removes the top directory from the - stack, and changes to the new top directory. Arguments, if sup- - plied, have the following meanings: - --nn Suppresses the normal change of directory when removing - directories from the stack, so that only the stack is ma- - nipulated. - ++_n Removes the _nth entry counting from the left of the list + Remove entries from the directory stack. The elements are num- + bered from 0 starting at the first directory listed by ddiirrss, so + ppooppdd is equivalent to "popd +0." With no arguments, ppooppdd re- + moves the top directory from the stack, and changes to the new + top directory. Arguments, if supplied, have the following mean- + ings: + --nn Suppress the normal change of directory when removing di- + rectories from the stack, only manipulate the stack. + ++_n Remove the _nth entry counting from the left of the list shown by ddiirrss, starting with zero, from the stack. For - example: ``popd +0'' removes the first directory, ``popd - +1'' the second. - --_n Removes the _nth entry counting from the right of the list - shown by ddiirrss, starting with zero. For example: ``popd - -0'' removes the last directory, ``popd -1'' the next to + example: "popd +0" removes the first directory, "popd +1" + the second. + --_n Remove the _nth entry counting from the right of the list + shown by ddiirrss, starting with zero. For example: "popd + -0" removes the last directory, "popd -1" the next to last. - If the top element of the directory stack is modified, and the - _-_n option was not supplied, ppooppdd uses the ccdd builtin to change + If the top element of the directory stack is modified, and the + _-_n option was not supplied, ppooppdd uses the ccdd builtin to change to the directory at the top of the stack. If the ccdd fails, ppooppdd returns a non-zero value. - Otherwise, ppooppdd returns false if an invalid option is encoun- - tered, the directory stack is empty, or a non-existent directory - stack entry is specified. + Otherwise, ppooppdd returns false if an invalid option is supplied, + the directory stack is empty, or _n specifies a non-existent di- + rectory stack entry. - If the ppooppdd command is successful, bash runs ddiirrss to show the + If the ppooppdd command is successful, bbaasshh runs ddiirrss to show the final contents of the directory stack, and the return status is 0. pprriinnttff [--vv _v_a_r] _f_o_r_m_a_t [_a_r_g_u_m_e_n_t_s] Write the formatted _a_r_g_u_m_e_n_t_s to the standard output under the - control of the _f_o_r_m_a_t. The --vv option causes the output to be - assigned to the variable _v_a_r rather than being printed to the - standard output. - - The _f_o_r_m_a_t is a character string which contains three types of - objects: plain characters, which are simply copied to standard - output, character escape sequences, which are converted and - copied to the standard output, and format specifications, each - of which causes printing of the next successive _a_r_g_u_m_e_n_t. In - addition to the standard _p_r_i_n_t_f(1) format specifications, pprriinnttff - interprets the following extensions: + control of the _f_o_r_m_a_t. The --vv option assigns the output to the + variable _v_a_r rather than printing it to the standard output. + + The _f_o_r_m_a_t is a character string which contains three types of + objects: plain characters, which are simply copied to standard + output, character escape sequences, which are converted and + copied to the standard output, and format specifications, each + of which causes printing of the next successive _a_r_g_u_m_e_n_t. In + addition to the standard _p_r_i_n_t_f(3) format characters ccCCssSS-- + nnddiioouuxxXXeeEEffFFggGGaaAA, pprriinnttff interprets the following additional for- + mat specifiers: %%bb causes pprriinnttff to expand backslash escape sequences in the corresponding _a_r_g_u_m_e_n_t in the same way as eecchhoo --ee. %%qq causes pprriinnttff to output the corresponding _a_r_g_u_m_e_n_t in a - format that can be reused as shell input. - %%QQ like %%qq, but applies any supplied precision to the _a_r_g_u_- + format that can be reused as shell input. %%qq and %%QQ use + the $$'''' quoting style if any characters in the argument + string require it, and backslash quoting otherwise. If + the format string uses the _p_r_i_n_t_f alternate form, these + two formats quote the argument string using single + quotes. + %%QQ like %%qq, but applies any supplied precision to the _a_r_g_u_- _m_e_n_t before quoting it. %%((_d_a_t_e_f_m_t))TT - causes pprriinnttff to output the date-time string resulting - from using _d_a_t_e_f_m_t as a format string for _s_t_r_f_t_i_m_e(3). + causes pprriinnttff to output the date-time string resulting + from using _d_a_t_e_f_m_t as a format string for _s_t_r_f_t_i_m_e(3). The corresponding _a_r_g_u_m_e_n_t is an integer representing the - number of seconds since the epoch. Two special argument - values may be used: -1 represents the current time, and - -2 represents the time the shell was invoked. If no ar- - gument is specified, conversion behaves as if -1 had been - given. This is an exception to the usual pprriinnttff behav- - ior. - - The %b, %q, and %T directives all use the field width and preci- - sion arguments from the format specification and write that many - bytes from (or use that wide a field for) the expanded argument, - which usually contains more characters than the original. - - Arguments to non-string format specifiers are treated as C con- + number of seconds since the epoch. This format specifier + recognizes two special argument values: -1 represents the + current time, and -2 represents the time the shell was + invoked. If no argument is specified, conversion behaves + as if -1 had been supplied. This is an exception to the + usual pprriinnttff behavior. + + The %b, %q, and %T format specifiers all use the field width and + precision arguments from the format specification and write that + many bytes from (or use that wide a field for) the expanded ar- + gument, which usually contains more characters than the origi- + nal. + + The %n format specifier accepts a corresponding argument that is + treated as a shell variable name. + + The %s and %c format specifiers accept an l (long) modifier, + which forces them to convert the argument string to a wide-char- + acter string and apply any supplied field width and precision in + terms of characters, not bytes. The %S and %C format specifiers + are equivalent to %ls and %lc, respectively. + + Arguments to non-string format specifiers are treated as C con- stants, except that a leading plus or minus sign is allowed, and if the leading character is a single or double quote, the value - is the ASCII value of the following character. + is the numeric value of the following character, using the cur- + rent locale. - The _f_o_r_m_a_t is reused as necessary to consume all of the _a_r_g_u_- + The _f_o_r_m_a_t is reused as necessary to consume all of the _a_r_g_u_- _m_e_n_t_s. If the _f_o_r_m_a_t requires more _a_r_g_u_m_e_n_t_s than are supplied, the extra format specifications behave as if a zero value or null string, as appropriate, had been supplied. The return - value is zero on success, non-zero on failure. + value is zero on success, non-zero if an invalid option is sup- + plied or a write or assignment error occurs. ppuusshhdd [--nn] [+_n] [-_n] ppuusshhdd [--nn] [_d_i_r] - Adds a directory to the top of the directory stack, or rotates - the stack, making the new top of the stack the current working - directory. With no arguments, ppuusshhdd exchanges the top two ele- + Add a directory to the top of the directory stack, or rotate the + stack, making the new top of the stack the current working di- + rectory. With no arguments, ppuusshhdd exchanges the top two ele- ments of the directory stack. Arguments, if supplied, have the following meanings: - --nn Suppresses the normal change of directory when rotating - or adding directories to the stack, so that only the - stack is manipulated. - ++_n Rotates the stack so that the _nth directory (counting - from the left of the list shown by ddiirrss, starting with + --nn Suppress the normal change of directory when rotating or + adding directories to the stack, only manipulate the + stack. + ++_n Rotate the stack so that the _nth directory (counting from + the left of the list shown by ddiirrss, starting with zero) + is at the top. + --_n Rotates the stack so that the _nth directory (counting + from the right of the list shown by ddiirrss, starting with zero) is at the top. - --_n Rotates the stack so that the _nth directory (counting - from the right of the list shown by ddiirrss, starting with - zero) is at the top. - _d_i_r Adds _d_i_r to the directory stack at the top + _d_i_r Adds _d_i_r to the directory stack at the top. After the stack has been modified, if the --nn option was not sup- plied, ppuusshhdd uses the ccdd builtin to change to the directory at the top of the stack. If the ccdd fails, ppuusshhdd returns a non-zero value. - Otherwise, if no arguments are supplied, ppuusshhdd returns 0 unless - the directory stack is empty. When rotating the directory - stack, ppuusshhdd returns 0 unless the directory stack is empty or a - non-existent directory stack element is specified. + Otherwise, if no arguments are supplied, ppuusshhdd returns zero un- + less the directory stack is empty. When rotating the directory + stack, ppuusshhdd returns zero unless the directory stack is empty or + _n specifies a non-existent directory stack element. - If the ppuusshhdd command is successful, bash runs ddiirrss to show the + If the ppuusshhdd command is successful, bbaasshh runs ddiirrss to show the final contents of the directory stack. ppwwdd [--LLPP] @@ -5455,182 +6226,205 @@ SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS occurs while reading the name of the current directory or an in- valid option is supplied. - rreeaadd [--eerrss] [--aa _a_n_a_m_e] [--dd _d_e_l_i_m] [--ii _t_e_x_t] [--nn _n_c_h_a_r_s] [--NN _n_c_h_a_r_s] [--pp - _p_r_o_m_p_t] [--tt _t_i_m_e_o_u_t] [--uu _f_d] [_n_a_m_e ...] - One line is read from the standard input, or from the file de- - scriptor _f_d supplied as an argument to the --uu option, split into - words as described above under WWoorrdd SSpplliittttiinngg, and the first - word is assigned to the first _n_a_m_e, the second word to the sec- - ond _n_a_m_e, and so on. If there are more words than names, the - remaining words and their intervening delimiters are assigned to - the last _n_a_m_e. If there are fewer words read from the input - stream than names, the remaining names are assigned empty val- - ues. The characters in IIFFSS are used to split the line into - words using the same rules the shell uses for expansion (de- - scribed above under WWoorrdd SSpplliittttiinngg). The backslash character - (\\) may be used to remove any special meaning for the next char- - acter read and for line continuation. Options, if supplied, - have the following meanings: + rreeaadd [--EEeerrss] [--aa _a_n_a_m_e] [--dd _d_e_l_i_m] [--ii _t_e_x_t] [--nn _n_c_h_a_r_s] [--NN _n_c_h_a_r_s] + [--pp _p_r_o_m_p_t] [--tt _t_i_m_e_o_u_t] [--uu _f_d] [_n_a_m_e ...] + Read one line from the standard input, or from the file descrip- + tor _f_d supplied as an argument to the --uu option, split it into + words as described above under WWoorrdd SSpplliittttiinngg, and assign the + first word to the first _n_a_m_e, the second word to the second + _n_a_m_e, and so on. If there are more words than names, the re- + maining words and their intervening delimiters are assigned to + the last _n_a_m_e. If there are fewer words read from the input + stream than names, the remaining names are assigned empty val- + ues. The characters in the value of the IIFFSS variable are used + to split the line into words using the same rules the shell uses + for expansion (described above under WWoorrdd SSpplliittttiinngg). The back- + slash character (\\) removes any special meaning for the next + character read and is used for line continuation. + + Options, if supplied, have the following meanings: --aa _a_n_a_m_e The words are assigned to sequential indices of the array variable _a_n_a_m_e, starting at 0. _a_n_a_m_e is unset before any new values are assigned. Other _n_a_m_e arguments are ig- nored. --dd _d_e_l_i_m - The first character of _d_e_l_i_m is used to terminate the in- - put line, rather than newline. If _d_e_l_i_m is the empty - string, rreeaadd will terminate a line when it reads a NUL - character. - --ee If the standard input is coming from a terminal, rreeaaddlliinnee - (see RREEAADDLLIINNEE above) is used to obtain the line. Read- - line uses the current (or default, if line editing was - not previously active) editing settings, but uses read- - line's default filename completion. + The first character of _d_e_l_i_m terminates the input line, + rather than newline. If _d_e_l_i_m is the empty string, rreeaadd + will terminate a line when it reads a NUL character. + --ee If the standard input is coming from a terminal, rreeaadd + uses rreeaaddlliinnee (see RREEAADDLLIINNEE above) to obtain the line. + RReeaaddlliinnee uses the current (or default, if line editing + was not previously active) editing settings, but uses + rreeaaddlliinnee's default filename completion. + --EE If the standard input is coming from a terminal, rreeaadd + uses rreeaaddlliinnee (see RREEAADDLLIINNEE above) to obtain the line. + RReeaaddlliinnee uses the current (or default, if line editing + was not previously active) editing settings, but uses + bash's default completion, including programmable comple- + tion. --ii _t_e_x_t - If rreeaaddlliinnee is being used to read the line, _t_e_x_t is - placed into the editing buffer before editing begins. + If rreeaaddlliinnee is being used to read the line, rreeaadd places + _t_e_x_t into the editing buffer before editing begins. --nn _n_c_h_a_r_s - rreeaadd returns after reading _n_c_h_a_r_s characters rather than - waiting for a complete line of input, but honors a delim- - iter if fewer than _n_c_h_a_r_s characters are read before the - delimiter. + rreeaadd returns after reading _n_c_h_a_r_s characters rather than + waiting for a complete line of input, unless it encoun- + ters EOF or rreeaadd times out, but honors a delimiter if it + reads fewer than _n_c_h_a_r_s characters before the delimiter. --NN _n_c_h_a_r_s - rreeaadd returns after reading exactly _n_c_h_a_r_s characters - rather than waiting for a complete line of input, unless - EOF is encountered or rreeaadd times out. Delimiter charac- - ters encountered in the input are not treated specially - and do not cause rreeaadd to return until _n_c_h_a_r_s characters - are read. The result is not split on the characters in - IIFFSS; the intent is that the variable is assigned exactly - the characters read (with the exception of backslash; see - the --rr option below). + rreeaadd returns after reading exactly _n_c_h_a_r_s characters + rather than waiting for a complete line of input, unless + it encounters EOF or rreeaadd times out. Any delimiter char- + acters in the input are not treated specially and do not + cause rreeaadd to return until it has read _n_c_h_a_r_s characters. + The result is not split on the characters in IIFFSS; the in- + tent is that the variable is assigned exactly the charac- + ters read (with the exception of backslash; see the --rr + option below). --pp _p_r_o_m_p_t Display _p_r_o_m_p_t on standard error, without a trailing new- - line, before attempting to read any input. The prompt is - displayed only if input is coming from a terminal. + line, before attempting to read any input, but only if + input is coming from a terminal. --rr Backslash does not act as an escape character. The back- - slash is considered to be part of the line. In particu- - lar, a backslash-newline pair may not then be used as a + slash is considered to be part of the line. In particu- + lar, a backslash-newline pair may not then be used as a line continuation. --ss Silent mode. If input is coming from a terminal, charac- ters are not echoed. --tt _t_i_m_e_o_u_t - Cause rreeaadd to time out and return failure if a complete - line of input (or a specified number of characters) is - not read within _t_i_m_e_o_u_t seconds. _t_i_m_e_o_u_t may be a deci- - mal number with a fractional portion following the deci- - mal point. This option is only effective if rreeaadd is + Cause rreeaadd to time out and return failure if it does not + read a complete line of input (or a specified number of + characters) within _t_i_m_e_o_u_t seconds. _t_i_m_e_o_u_t may be a + decimal number with a fractional portion following the + decimal point. This option is only effective if rreeaadd is reading input from a terminal, pipe, or other special file; it has no effect when reading from regular files. - If rreeaadd times out, rreeaadd saves any partial input read into - the specified variable _n_a_m_e. If _t_i_m_e_o_u_t is 0, rreeaadd re- - turns immediately, without trying to read any data. The - exit status is 0 if input is available on the specified - file descriptor, or the read will return EOF, non-zero - otherwise. The exit status is greater than 128 if the - timeout is exceeded. - --uu _f_d Read input from file descriptor _f_d. - - If no _n_a_m_e_s are supplied, the line read, without the ending de- - limiter but otherwise unmodified, is assigned to the variable - RREEPPLLYY. The exit status is zero, unless end-of-file is encoun- - tered, rreeaadd times out (in which case the status is greater than - 128), a variable assignment error (such as assigning to a read- - only variable) occurs, or an invalid file descriptor is supplied - as the argument to --uu. + If rreeaadd times out, it saves any partial input read into + the specified variable _n_a_m_e, and the exit status is + greater than 128. If _t_i_m_e_o_u_t is 0, rreeaadd returns immedi- + ately, without trying to read any data. In this case, + the exit status is 0 if input is available on the speci- + fied file descriptor, or the read will return EOF, non- + zero otherwise. + --uu _f_d Read input from file descriptor _f_d instead of the stan- + dard input. + + Other than the case where _d_e_l_i_m is the empty string, rreeaadd ig- + nores any NUL characters in the input. + + If no _n_a_m_e_s are supplied, rreeaadd assigns the line read, without + the ending delimiter but otherwise unmodified, to the variable + RREEPPLLYY. + + The exit status is zero, unless end-of-file is encountered, rreeaadd + times out (in which case the status is greater than 128), a + variable assignment error (such as assigning to a readonly vari- + able) occurs, or an invalid file descriptor is supplied as the + argument to --uu. rreeaaddoonnllyy [--aaAAff] [--pp] [_n_a_m_e[=_w_o_r_d] ...] The given _n_a_m_e_s are marked readonly; the values of these _n_a_m_e_s - may not be changed by subsequent assignment. If the --ff option - is supplied, the functions corresponding to the _n_a_m_e_s are so - marked. The --aa option restricts the variables to indexed ar- - rays; the --AA option restricts the variables to associative ar- - rays. If both options are supplied, --AA takes precedence. If no - _n_a_m_e arguments are given, or if the --pp option is supplied, a - list of all readonly names is printed. The other options may be - used to restrict the output to a subset of the set of readonly - names. The --pp option causes output to be displayed in a format - that may be reused as input. If a variable name is followed by - =_w_o_r_d, the value of the variable is set to _w_o_r_d. The return - status is 0 unless an invalid option is encountered, one of the - _n_a_m_e_s is not a valid shell variable name, or --ff is supplied with - a _n_a_m_e that is not a function. + may not be changed by subsequent assignment or unset. If the --ff + option is supplied, each _n_a_m_e refers to a shell function. The + --aa option restricts the variables to indexed arrays; the --AA op- + tion restricts the variables to associative arrays. If both op- + tions are supplied, --AA takes precedence. If no _n_a_m_e arguments + are supplied, or if the --pp option is supplied, print a list of + all readonly names. The other options may be used to restrict + the output to a subset of the set of readonly names. The --pp op- + tion displays output in a format that may be reused as input. + + rreeaaddoonnllyy allows the value of a variable to be set at the same + time the readonly attribute is changed by following the variable + name with =_v_a_l_u_e. This sets the value of the variable is to + _v_a_l_u_e while modifying the readonly attribute. + + The return status is 0 unless an invalid option is encountered, + one of the _n_a_m_e_s is not a valid shell variable name, or --ff is + supplied with a _n_a_m_e that is not a function. rreettuurrnn [_n] - Causes a function to stop executing and return the value speci- - fied by _n to its caller. If _n is omitted, the return status is - that of the last command executed in the function body. If rree-- - ttuurrnn is executed by a trap handler, the last command used to de- - termine the status is the last command executed before the trap - handler. If rreettuurrnn is executed during a DDEEBBUUGG trap, the last - command used to determine the status is the last command exe- - cuted by the trap handler before rreettuurrnn was invoked. If rreettuurrnn - is used outside a function, but during execution of a script by - the .. (ssoouurrccee) command, it causes the shell to stop executing - that script and return either _n or the exit status of the last - command executed within the script as the exit status of the - script. If _n is supplied, the return value is its least signif- - icant 8 bits. The return status is non-zero if rreettuurrnn is sup- - plied a non-numeric argument, or is used outside a function and - not during execution of a script by .. or ssoouurrccee. Any command - associated with the RREETTUURRNN trap is executed before execution re- - sumes after the function or script. + Stop executing a shell function or sourced file and return the + value specified by _n to its caller. If _n is omitted, the return + status is that of the last command executed. If rreettuurrnn is exe- + cuted by a trap handler, the last command used to determine the + status is the last command executed before the trap handler. If + rreettuurrnn is executed during a DDEEBBUUGG trap, the last command used to + determine the status is the last command executed by the trap + handler before rreettuurrnn was invoked. + + When rreettuurrnn is used to terminate execution of a script being ex- + ecuted by the .. (ssoouurrccee) command, it causes the shell to stop + executing that script and return either _n or the exit status of + the last command executed within the script as the exit status + of the script. If _n is supplied, the return value is its least + significant 8 bits. + + Any command associated with the RREETTUURRNN trap is executed before + execution resumes after the function or script. + + The return status is non-zero if rreettuurrnn is supplied a non-nu- + meric argument, or is used outside a function and not during ex- + ecution of a script by .. or ssoouurrccee. sseett [--aabbeeffhhkkmmnnppttuuvvxxBBCCEEHHPPTT] [--oo _o_p_t_i_o_n_-_n_a_m_e] [----] [--] [_a_r_g ...] sseett [++aabbeeffhhkkmmnnppttuuvvxxBBCCEEHHPPTT] [++oo _o_p_t_i_o_n_-_n_a_m_e] [----] [--] [_a_r_g ...] - Without options, display the name and value of each shell vari- - able in a format that can be reused as input for setting or re- + sseett --oo + sseett ++oo Without options, display the name and value of each shell vari- + able in a format that can be reused as input for setting or re- setting the currently-set variables. Read-only variables cannot - be reset. In _p_o_s_i_x _m_o_d_e, only shell variables are listed. The + be reset. In posix mode, only shell variables are listed. The output is sorted according to the current locale. When options are specified, they set or unset shell attributes. Any argu- ments remaining after option processing are treated as values for the positional parameters and are assigned, in order, to $$11, - $$22, ...... $$_n. Options, if specified, have the following mean- + $$22, ..., $$_n. Options, if specified, have the following mean- ings: --aa Each variable or function that is created or modified is given the export attribute and marked for export to the environment of subsequent commands. --bb Report the status of terminated background jobs immedi- - ately, rather than before the next primary prompt. This - is effective only when job control is enabled. + ately, rather than before the next primary prompt or af- + ter a foreground command terminates. This is effective + only when job control is enabled. --ee Exit immediately if a _p_i_p_e_l_i_n_e (which may consist of a single _s_i_m_p_l_e _c_o_m_m_a_n_d), a _l_i_s_t, or a _c_o_m_p_o_u_n_d _c_o_m_m_a_n_d (see SSHHEELLLL GGRRAAMMMMAARR above), exits with a non-zero status. - The shell does not exit if the command that fails is - part of the command list immediately following a wwhhiillee - or uunnttiill keyword, part of the test following the iiff or - eelliiff reserved words, part of any command executed in a - &&&& or |||| list except the command following the final &&&& - or ||||, any command in a pipeline but the last, or if the - command's return value is being inverted with !!. If a - compound command other than a subshell returns a non- - zero status because a command failed while --ee was being - ignored, the shell does not exit. A trap on EERRRR, if - set, is executed before the shell exits. This option + The shell does not exit if the command that fails is + part of the command list immediately following a wwhhiillee + or uunnttiill reserved word, part of the test following the + iiff or eelliiff reserved words, part of any command executed + in a &&&& or |||| list except the command following the fi- + nal &&&& or ||||, any command in a pipeline but the last + (subject to the state of the ppiippeeffaaiill shell option), or + if the command's return value is being inverted with !!. + If a compound command other than a subshell returns a + non-zero status because a command failed while --ee was + being ignored, the shell does not exit. A trap on EERRRR, + if set, is executed before the shell exits. This option applies to the shell environment and each subshell envi- ronment separately (see CCOOMMMMAANNDD EEXXEECCUUTTIIOONN EENNVVIIRROONNMMEENNTT above), and may cause subshells to exit before executing all the commands in the subshell. - If a compound command or shell function executes in a - context where --ee is being ignored, none of the commands - executed within the compound command or function body - will be affected by the --ee setting, even if --ee is set - and a command returns a failure status. If a compound - command or shell function sets --ee while executing in a - context where --ee is ignored, that setting will not have - any effect until the compound command or the command + If a compound command or shell function executes in a + context where --ee is being ignored, none of the commands + executed within the compound command or function body + will be affected by the --ee setting, even if --ee is set + and a command returns a failure status. If a compound + command or shell function sets --ee while executing in a + context where --ee is ignored, that setting will not have + any effect until the compound command or the command containing the function call completes. --ff Disable pathname expansion. - --hh Remember the location of commands as they are looked up + --hh Remember the location of commands as they are looked up for execution. This is enabled by default. - --kk All arguments in the form of assignment statements are - placed in the environment for a command, not just those + --kk All arguments in the form of assignment statements are + placed in the environment for a command, not just those that precede the command name. - --mm Monitor mode. Job control is enabled. This option is - on by default for interactive shells on systems that - support it (see JJOOBB CCOONNTTRROOLL above). All processes run + --mm Monitor mode. Job control is enabled. This option is + on by default for interactive shells on systems that + support it (see JJOOBB CCOONNTTRROOLL above). All processes run in a separate process group. When a background job com- pletes, the shell prints a line containing its exit sta- tus. @@ -5660,9 +6454,9 @@ SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS HHIISSTTOORRYY. This option is on by default in inter- active shells. iiggnnoorreeeeooff - The effect is as if the shell command ``IG- - NOREEOF=10'' had been executed (see SShheellll VVaarrii-- - aabblleess above). + The effect is as if the shell command + "IGNOREEOF=10" had been executed (see SShheellll + VVaarriiaabblleess above). kkeeyywwoorrdd Same as --kk. mmoonniittoorr Same as --mm. nnoocclloobbbbeerr @@ -5681,11 +6475,11 @@ SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS with a non-zero status, or zero if all commands in the pipeline exit successfully. This option is disabled by default. - ppoossiixx Change the behavior of bbaasshh where the default - operation differs from the POSIX standard to - match the standard (_p_o_s_i_x _m_o_d_e). See SSEEEE AALLSSOO - below for a reference to a document that details - how posix mode affects bash's behavior. + ppoossiixx Enable posix mode; change the behavior of bbaasshh + where the default operation differs from the + POSIX standard to match the standard. See SSEEEE + AALLSSOO below for a reference to a document that + details how posix mode affects bash's behavior. pprriivviilleeggeedd Same as --pp. vveerrbboossee Same as --vv. @@ -5693,158 +6487,167 @@ SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS This also affects the editing interface used for rreeaadd --ee. xxttrraaccee Same as --xx. - If --oo is supplied with no _o_p_t_i_o_n_-_n_a_m_e, the values of the - current options are printed. If ++oo is supplied with no - _o_p_t_i_o_n_-_n_a_m_e, a series of sseett commands to recreate the - current option settings is displayed on the standard + If --oo is supplied with no _o_p_t_i_o_n_-_n_a_m_e, sseett prints the + current shell option settings. If ++oo is supplied with + no _o_p_t_i_o_n_-_n_a_m_e, sseett prints a series of sseett commands to + recreate the current option settings on the standard output. - --pp Turn on _p_r_i_v_i_l_e_g_e_d mode. In this mode, the $$EENNVV and - $$BBAASSHH__EENNVV files are not processed, shell functions are - not inherited from the environment, and the SSHHEELLLLOOPPTTSS, - BBAASSHHOOPPTTSS, CCDDPPAATTHH, and GGLLOOBBIIGGNNOORREE variables, if they ap- - pear in the environment, are ignored. If the shell is - started with the effective user (group) id not equal to - the real user (group) id, and the --pp option is not sup- - plied, these actions are taken and the effective user id - is set to the real user id. If the --pp option is sup- - plied at startup, the effective user id is not reset. - Turning this option off causes the effective user and + --pp Turn on _p_r_i_v_i_l_e_g_e_d mode. In this mode, the shell does + not read the $$EENNVV and $$BBAASSHH__EENNVV files, shell functions + are not inherited from the environment, and the SSHHEELL-- + LLOOPPTTSS, BBAASSHHOOPPTTSS, CCDDPPAATTHH, and GGLLOOBBIIGGNNOORREE variables, if + they appear in the environment, are ignored. If the + shell is started with the effective user (group) id not + equal to the real user (group) id, and the --pp option is + not supplied, these actions are taken and the effective + user id is set to the real user id. If the --pp option is + supplied at startup, the effective user id is not reset. + Turning this option off causes the effective user and group ids to be set to the real user and group ids. --rr Enable restricted shell mode. This option cannot be un- set once it has been set. --tt Exit after reading and executing one command. --uu Treat unset variables and parameters other than the spe- - cial parameters "@" and "*", or array variables sub- - scripted with "@" or "*", as an error when performing - parameter expansion. If expansion is attempted on an - unset variable or parameter, the shell prints an error - message, and, if not interactive, exits with a non-zero + cial parameters "@" and "*", or array variables sub- + scripted with "@" or "*", as an error when performing + parameter expansion. If expansion is attempted on an + unset variable or parameter, the shell prints an error + message, and, if not interactive, exits with a non-zero status. --vv Print shell input lines as they are read. - --xx After expanding each _s_i_m_p_l_e _c_o_m_m_a_n_d, ffoorr command, ccaassee + --xx After expanding each _s_i_m_p_l_e _c_o_m_m_a_n_d, ffoorr command, ccaassee command, sseelleecctt command, or arithmetic ffoorr command, dis- play the expanded value of PPSS44, followed by the command - and its expanded arguments or associated word list. - --BB The shell performs brace expansion (see BBrraaccee EExxppaannssiioonn + and its expanded arguments or associated word list, to + the standard error. + --BB The shell performs brace expansion (see BBrraaccee EExxppaannssiioonn above). This is on by default. - --CC If set, bbaasshh does not overwrite an existing file with - the >>, >>&&, and <<>> redirection operators. This may be - overridden when creating output files by using the redi- - rection operator >>|| instead of >>. + --CC If set, bbaasshh does not overwrite an existing file with + the >>, >>&&, and <<>> redirection operators. Using the + redirection operator >>|| instead of >> will override this + and force the creation of an output file. --EE If set, any trap on EERRRR is inherited by shell functions, command substitutions, and commands executed in a sub- shell environment. The EERRRR trap is normally not inher- ited in such cases. --HH Enable !! style history substitution. This option is on by default when the shell is interactive. - --PP If set, the shell does not resolve symbolic links when - executing commands such as ccdd that change the current + --PP If set, the shell does not resolve symbolic links when + executing commands such as ccdd that change the current working directory. It uses the physical directory structure instead. By default, bbaasshh follows the logical chain of directories when performing commands which change the current directory. --TT If set, any traps on DDEEBBUUGG and RREETTUURRNN are inherited by shell functions, command substitutions, and commands ex- - ecuted in a subshell environment. The DDEEBBUUGG and RREETTUURRNN + ecuted in a subshell environment. The DDEEBBUUGG and RREETTUURRNN traps are normally not inherited in such cases. - ---- If no arguments follow this option, then the positional - parameters are unset. Otherwise, the positional parame- - ters are set to the _a_r_gs, even if some of them begin - with a --. - -- Signal the end of options, cause all remaining _a_r_gs to - be assigned to the positional parameters. The --xx and --vv - options are turned off. If there are no _a_r_gs, the posi- - tional parameters remain unchanged. + ---- If no arguments follow this option, unset the positional + parameters. Otherwise, set the positional parameters to + the _a_r_gs, even if some of them begin with a --. + -- Signal the end of options, and assign all remaining _a_r_gs + to the positional parameters. The --xx and --vv options are + turned off. If there are no _a_r_gs, the positional para- + meters remain unchanged. The options are off by default unless otherwise noted. Using + rather than - causes these options to be turned off. The op- tions can also be specified as arguments to an invocation of the - shell. The current set of options may be found in $$--. The re- - turn status is always true unless an invalid option is encoun- + shell. The current set of options may be found in $$--. The re- + turn status is always zero unless an invalid option is encoun- tered. sshhiifftt [_n] - The positional parameters from _n+1 ... are renamed to $$11 ........ - Parameters represented by the numbers $$## down to $$##-_n+1 are un- - set. _n must be a non-negative number less than or equal to $$##. - If _n is 0, no parameters are changed. If _n is not given, it is - assumed to be 1. If _n is greater than $$##, the positional param- - eters are not changed. The return status is greater than zero - if _n is greater than $$## or less than zero; otherwise 0. + Rename positional parameters from _n+1 ... to $$11 ........ Parameters + represented by the numbers $$## down to $$##-_n+1 are unset. _n must + be a non-negative number less than or equal to $$##. If _n is 0, + no parameters are changed. If _n is not given, it is assumed to + be 1. If _n is greater than $$##, the positional parameters are + not changed. The return status is greater than zero if _n is + greater than $$## or less than zero; otherwise 0. sshhoopptt [--ppqqssuu] [--oo] [_o_p_t_n_a_m_e ...] Toggle the values of settings controlling optional shell behav- ior. The settings can be either those listed below, or, if the --oo option is used, those available with the --oo option to the sseett - builtin command. With no options, or with the --pp option, a list - of all settable options is displayed, with an indication of - whether or not each is set; if _o_p_t_n_a_m_e_s are supplied, the output - is restricted to those options. The --pp option causes output to - be displayed in a form that may be reused as input. Other op- - tions have the following meanings: + builtin command. + + With no options, or with the --pp option, display a list of all + settable options, with an indication of whether or not each is + set; if any _o_p_t_n_a_m_e_s are supplied, the output is restricted to + those options. The --pp option displays output in a form that may + be reused as input. + + Other options have the following meanings: --ss Enable (set) each _o_p_t_n_a_m_e. --uu Disable (unset) each _o_p_t_n_a_m_e. - --qq Suppresses normal output (quiet mode); the return status + --qq Suppresses normal output (quiet mode); the return status indicates whether the _o_p_t_n_a_m_e is set or unset. If multi- - ple _o_p_t_n_a_m_e arguments are given with --qq, the return sta- - tus is zero if all _o_p_t_n_a_m_e_s are enabled; non-zero other- - wise. - --oo Restricts the values of _o_p_t_n_a_m_e to be those defined for + ple _o_p_t_n_a_m_e arguments are supplied with --qq, the return + status is zero if all _o_p_t_n_a_m_e_s are enabled; non-zero oth- + erwise. + --oo Restricts the values of _o_p_t_n_a_m_e to be those defined for the --oo option to the sseett builtin. - If either --ss or --uu is used with no _o_p_t_n_a_m_e arguments, sshhoopptt - shows only those options which are set or unset, respectively. - Unless otherwise noted, the sshhoopptt options are disabled (unset) + If either --ss or --uu is used with no _o_p_t_n_a_m_e arguments, sshhoopptt + shows only those options which are set or unset, respectively. + Unless otherwise noted, the sshhoopptt options are disabled (unset) by default. - The return status when listing options is zero if all _o_p_t_n_a_m_e_s - are enabled, non-zero otherwise. When setting or unsetting op- - tions, the return status is zero unless an _o_p_t_n_a_m_e is not a + The return status when listing options is zero if all _o_p_t_n_a_m_e_s + are enabled, non-zero otherwise. When setting or unsetting op- + tions, the return status is zero unless an _o_p_t_n_a_m_e is not a valid shell option. The list of sshhoopptt options is: + aarrrraayy__eexxppaanndd__oonnccee + If set, the shell suppresses multiple evaluation of as- + sociative and indexed array subscripts during arithmetic + expression evaluation, while executing builtins that can + perform variable assignments, and while executing + builtins that perform array dereferencing. aassssoocc__eexxppaanndd__oonnccee - If set, the shell suppresses multiple evaluation of as- - sociative array subscripts during arithmetic expression - evaluation, while executing builtins that can perform - variable assignments, and while executing builtins that - perform array dereferencing. - aauuttooccdd If set, a command name that is the name of a directory - is executed as if it were the argument to the ccdd com- + Deprecated; a synonym for aarrrraayy__eexxppaanndd__oonnccee. + aauuttooccdd If set, a command name that is the name of a directory + is executed as if it were the argument to the ccdd com- mand. This option is only used by interactive shells. + bbaasshh__ssoouurrccee__ffuullllppaatthh + If set, filenames added to the BBAASSHH__SSOOUURRCCEE array vari- + able are converted to full pathnames (see SShheellll VVaarrii-- + aabblleess above). ccddaabbllee__vvaarrss - If set, an argument to the ccdd builtin command that is - not a directory is assumed to be the name of a variable + If set, an argument to the ccdd builtin command that is + not a directory is assumed to be the name of a variable whose value is the directory to change to. - ccddssppeellll If set, minor errors in the spelling of a directory com- - ponent in a ccdd command will be corrected. The errors - checked for are transposed characters, a missing charac- - ter, and one character too many. If a correction is - found, the corrected filename is printed, and the com- - mand proceeds. This option is only used by interactive - shells. + ccddssppeellll If set, the ccdd command attempts to correct minor errors + in the spelling of a directory component. Minor errors + include transposed characters, a missing character, and + one extra character. If ccdd corrects the directory name, + it prints the corrected filename, and the command pro- + ceeds. This option is only used by interactive shells. cchheecckkhhaasshh If set, bbaasshh checks that a command found in the hash ta- ble exists before trying to execute it. If a hashed - command no longer exists, a normal path search is per- - formed. + command no longer exists, bbaasshh performs a normal path + search. cchheecckkjjoobbss If set, bbaasshh lists the status of any stopped and running - jobs before exiting an interactive shell. If any jobs - are running, this causes the exit to be deferred until a - second exit is attempted without an intervening command - (see JJOOBB CCOONNTTRROOLL above). The shell always postpones ex- - iting if any jobs are stopped. + jobs before exiting an interactive shell. If any jobs + are running, bbaasshh defers the exit until a second exit is + attempted without an intervening command (see JJOOBB CCOONN-- + TTRROOLL above). The shell always postpones exiting if any + jobs are stopped. cchheecckkwwiinnssiizzee If set, bbaasshh checks the window size after each external (non-builtin) command and, if necessary, updates the - values of LLIINNEESS and CCOOLLUUMMNNSS. This option is enabled by - default. - ccmmddhhiisstt If set, bbaasshh attempts to save all lines of a multiple- - line command in the same history entry. This allows - easy re-editing of multi-line commands. This option is - enabled by default, but only has an effect if command + values of LLIINNEESS and CCOOLLUUMMNNSS, using the file descriptor + associated with the standard error if it is a terminal. + This option is enabled by default. + ccmmddhhiisstt If set, bbaasshh attempts to save all lines of a multiple- + line command in the same history entry. This allows + easy re-editing of multi-line commands. This option is + enabled by default, but only has an effect if command history is enabled, as described above under HHIISSTTOORRYY. ccoommppaatt3311 ccoommppaatt3322 @@ -5853,13 +6656,11 @@ SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS ccoommppaatt4422 ccoommppaatt4433 ccoommppaatt4444 - ccoommppaatt5500 - These control aspects of the shell's compatibility mode + These control aspects of the shell's compatibility mode (see SSHHEELLLL CCOOMMPPAATTIIBBIILLIITTYY MMOODDEE below). - ccoommpplleettee__ffuullllqquuoottee - If set, bbaasshh quotes all shell metacharacters in file- - names and directory names when performing completion. + If set, bbaasshh quotes all shell metacharacters in file- + names and directory names when performing completion. If not set, bbaasshh removes metacharacters such as the dol- lar sign from the set of characters that will be quoted in completed filenames when these metacharacters appear @@ -5871,285 +6672,241 @@ SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS slashes to quote completed filenames. This variable is set by default, which is the default bash behavior in versions through 4.2. - ddiirreexxppaanndd If set, bbaasshh replaces directory names with the results of word expansion when performing filename completion. - This changes the contents of the readline editing buf- - fer. If not set, bbaasshh attempts to preserve what the + This changes the contents of the rreeaaddlliinnee editing + buffer. If not set, bbaasshh attempts to preserve what the user typed. - ddiirrssppeellll If set, bbaasshh attempts spelling correction on directory names during word completion if the directory name ini- tially supplied does not exist. - - ddoottgglloobb If set, bbaasshh includes filenames beginning with a `.' in - the results of pathname expansion. The filenames ````..'''' - and ````....'''' must always be matched explicitly, even if - ddoottgglloobb is set. - + ddoottgglloobb If set, bbaasshh includes filenames beginning with a "." in + the results of pathname expansion. The filenames _. and + _._. must always be matched explicitly, even if ddoottgglloobb is + set. eexxeeccffaaiill If set, a non-interactive shell will not exit if it can- not execute the file specified as an argument to the - eexxeecc builtin command. An interactive shell does not - exit if eexxeecc fails. - + eexxeecc builtin. An interactive shell does not exit if + eexxeecc fails. eexxppaanndd__aalliiaasseess If set, aliases are expanded as described above under AALLIIAASSEESS. This option is enabled by default for interac- tive shells. - eexxttddeebbuugg - If set at shell invocation, or in a shell startup file, + If set at shell invocation, or in a shell startup file, arrange to execute the debugger profile before the shell starts, identical to the ----ddeebbuuggggeerr option. If set af- ter invocation, behavior intended for use by debuggers is enabled: - 11.. The --FF option to the ddeeccllaarree builtin displays the source file name and line number corresponding to each function name supplied as an argument. - 22.. If the command run by the DDEEBBUUGG trap returns a non-zero value, the next command is skipped and not executed. - 33.. If the command run by the DDEEBBUUGG trap returns a value of 2, and the shell is executing in a sub- routine (a shell function or a shell script exe- cuted by the .. or ssoouurrccee builtins), the shell simulates a call to rreettuurrnn. - 44.. BBAASSHH__AARRGGCC and BBAASSHH__AARRGGVV are updated as described in their descriptions above). - 55.. Function tracing is enabled: command substitu- tion, shell functions, and subshells invoked with (( _c_o_m_m_a_n_d )) inherit the DDEEBBUUGG and RREETTUURRNN traps. - - 66.. Error tracing is enabled: command substitution, - shell functions, and subshells invoked with (( + 66.. Error tracing is enabled: command substitution, + shell functions, and subshells invoked with (( _c_o_m_m_a_n_d )) inherit the EERRRR trap. - - eexxttgglloobb If set, the extended pattern matching features described - above under PPaatthhnnaammee EExxppaannssiioonn are enabled. - + eexxttgglloobb If set, enable the extended pattern matching features + described above under PPaatthhnnaammee EExxppaannssiioonn. eexxttqquuoottee - If set, $$'_s_t_r_i_n_g' and $$"_s_t_r_i_n_g" quoting is performed - within $${{_p_a_r_a_m_e_t_e_r}} expansions enclosed in double + If set, $$'_s_t_r_i_n_g' and $$"_s_t_r_i_n_g" quoting is performed + within $${{_p_a_r_a_m_e_t_e_r}} expansions enclosed in double quotes. This option is enabled by default. - ffaaiillgglloobb - If set, patterns which fail to match filenames during + If set, patterns which fail to match filenames during pathname expansion result in an expansion error. - ffoorrccee__ffiiggnnoorree - If set, the suffixes specified by the FFIIGGNNOORREE shell - variable cause words to be ignored when performing word + If set, the suffixes specified by the FFIIGGNNOORREE shell + variable cause words to be ignored when performing word completion even if the ignored words are the only possi- - ble completions. See SSHHEELLLL VVAARRIIAABBLLEESS above for a de- + ble completions. See SShheellll VVaarriiaabblleess above for a de- scription of FFIIGGNNOORREE. This option is enabled by de- fault. - gglloobbaasscciiiirraannggeess If set, range expressions used in pattern matching bracket expressions (see PPaatttteerrnn MMaattcchhiinngg above) behave as if in the traditional C locale when performing com- - parisons. That is, the current locale's collating se- - quence is not taken into account, so bb will not collate - between AA and BB, and upper-case and lower-case ASCII - characters will collate together. - + parisons. That is, pattern matching does not take the + current locale's collating sequence into account, so bb + will not collate between AA and BB, and upper-case and + lower-case ASCII characters will collate together. gglloobbsskkiippddoottss If set, pathname expansion will never match the file- - names ````..'''' and ````....'''', even if the pattern begins with - a ````..''''. This option is enabled by default. - + names _. and _._., even if the pattern begins with a ".". + This option is enabled by default. gglloobbssttaarr If set, the pattern **** used in a pathname expansion con- - text will match all files and zero or more directories - and subdirectories. If the pattern is followed by a //, + text will match all files and zero or more directories + and subdirectories. If the pattern is followed by a //, only directories and subdirectories match. - ggnnuu__eerrrrffmmtt If set, shell error messages are written in the standard GNU error message format. - hhiissttaappppeenndd If set, the history list is appended to the file named by the value of the HHIISSTTFFIILLEE variable when the shell ex- its, rather than overwriting the file. - hhiissttrreeeeddiitt - If set, and rreeaaddlliinnee is being used, a user is given the - opportunity to re-edit a failed history substitution. - + If set, and rreeaaddlliinnee is being used, the user is given + the opportunity to re-edit a failed history substitu- + tion. hhiissttvveerriiffyy If set, and rreeaaddlliinnee is being used, the results of his- tory substitution are not immediately passed to the shell parser. Instead, the resulting line is loaded into the rreeaaddlliinnee editing buffer, allowing further modi- fication. - hhoossttccoommpplleettee If set, and rreeaaddlliinnee is being used, bbaasshh will attempt to perform hostname completion when a word containing a @@ is being completed (see CCoommpplleettiinngg under RREEAADDLLIINNEE above). This is enabled by default. - hhuuppoonneexxiitt If set, bbaasshh will send SSIIGGHHUUPP to all jobs when an inter- active login shell exits. - iinnhheerriitt__eerrrreexxiitt - If set, command substitution inherits the value of the - eerrrreexxiitt option, instead of unsetting it in the subshell - environment. This option is enabled when _p_o_s_i_x _m_o_d_e is + If set, command substitution inherits the value of the + eerrrreexxiitt option, instead of unsetting it in the subshell + environment. This option is enabled when posix mode is enabled. - iinntteerraaccttiivvee__ccoommmmeennttss - If set, allow a word beginning with ## to cause that word - and all remaining characters on that line to be ignored - in an interactive shell (see CCOOMMMMEENNTTSS above). This op- - tion is enabled by default. - + In an interactive shell, a word beginning with ## causes + that word and all remaining characters on that line to + be ignored, as in a non-interactive shell (see CCOOMMMMEENNTTSS + above). This option is enabled by default. llaassttppiippee - If set, and job control is not active, the shell runs + If set, and job control is not active, the shell runs the last command of a pipeline not executed in the back- ground in the current shell environment. - lliitthhiisstt If set, and the ccmmddhhiisstt option is enabled, multi-line commands are saved to the history with embedded newlines rather than using semicolon separators where possible. - llooccaallvvaarr__iinnhheerriitt If set, local variables inherit the value and attributes of a variable of the same name that exists at a previous scope before any new value is assigned. The nameref at- tribute is not inherited. - llooccaallvvaarr__uunnsseett If set, calling uunnsseett on local variables in previous function scopes marks them so subsequent lookups find - them unset until that function returns. This is identi- - cal to the behavior of unsetting local variables at the + them unset until that function returns. This is identi- + cal to the behavior of unsetting local variables at the current function scope. - llooggiinn__sshheellll - The shell sets this option if it is started as a login - shell (see IINNVVOOCCAATTIIOONN above). The value may not be + The shell sets this option if it is started as a login + shell (see IINNVVOOCCAATTIIOONN above). The value may not be changed. - mmaaiillwwaarrnn - If set, and a file that bbaasshh is checking for mail has - been accessed since the last time it was checked, the - message ``The mail in _m_a_i_l_f_i_l_e has been read'' is dis- - played. - + If set, and a file that bbaasshh is checking for mail has + been accessed since the last time it was checked, bbaasshh + displays the message "The mail in _m_a_i_l_f_i_l_e has been + read". nnoo__eemmppttyy__ccmmdd__ccoommpplleettiioonn - If set, and rreeaaddlliinnee is being used, bbaasshh will not at- - tempt to search the PPAATTHH for possible completions when - completion is attempted on an empty line. - + If set, and rreeaaddlliinnee is being used, bbaasshh does not search + PPAATTHH for possible completions when completion is at- + tempted on an empty line. nnooccaasseegglloobb If set, bbaasshh matches filenames in a case-insensitive fashion when performing pathname expansion (see PPaatthhnnaammee EExxppaannssiioonn above). - nnooccaasseemmaattcchh - If set, bbaasshh matches patterns in a case-insensitive + If set, bbaasshh matches patterns in a case-insensitive fashion when performing matching while executing ccaassee or [[[[ conditional commands, when performing pattern substi- - tution word expansions, or when filtering possible com- + tution word expansions, or when filtering possible com- pletions as part of programmable completion. - nnooeexxppaanndd__ttrraannssllaattiioonn - If set, bbaasshh encloses the translated results of $"..." - quoting in single quotes instead of double quotes. If + If set, bbaasshh encloses the translated results of $$""..."" + quoting in single quotes instead of double quotes. If the string is not translated, this has no effect. - nnuullllgglloobb - If set, bbaasshh allows patterns which match no files (see - PPaatthhnnaammee EExxppaannssiioonn above) to expand to a null string, - rather than themselves. - + If set, pathname expansion patterns which match no files + (see PPaatthhnnaammee EExxppaannssiioonn above) expand to nothing and are + removed, rather than expanding to themselves. ppaattssuubb__rreeppllaacceemmeenntt If set, bbaasshh expands occurrences of && in the replacement string of pattern substitution to the text matched by the pattern, as described under PPaarraammeetteerr EExxppaannssiioonn above. This option is enabled by default. - pprrooggccoommpp - If set, the programmable completion facilities (see PPrroo-- - ggrraammmmaabbllee CCoommpplleettiioonn above) are enabled. This option is - enabled by default. - + If set, enable the programmable completion facilities + (see PPrrooggrraammmmaabbllee CCoommpplleettiioonn above). This option is en- + abled by default. pprrooggccoommpp__aalliiaass - If set, and programmable completion is enabled, bbaasshh - treats a command name that doesn't have any completions - as a possible alias and attempts alias expansion. If it + If set, and programmable completion is enabled, bbaasshh + treats a command name that doesn't have any completions + as a possible alias and attempts alias expansion. If it has an alias, bbaasshh attempts programmable completion us- ing the command word resulting from the expanded alias. - pprroommppttvvaarrss If set, prompt strings undergo parameter expansion, com- - mand substitution, arithmetic expansion, and quote re- - moval after being expanded as described in PPRROOMMPPTTIINNGG + mand substitution, arithmetic expansion, and quote re- + moval after being expanded as described in PPRROOMMPPTTIINNGG above. This option is enabled by default. - rreessttrriicctteedd__sshheellll - The shell sets this option if it is started in re- - stricted mode (see RREESSTTRRIICCTTEEDD SSHHEELLLL below). The value - may not be changed. This is not reset when the startup - files are executed, allowing the startup files to dis- + The shell sets this option if it is started in re- + stricted mode (see RREESSTTRRIICCTTEEDD SSHHEELLLL below). The value + may not be changed. This is not reset when the startup + files are executed, allowing the startup files to dis- cover whether or not a shell is restricted. - sshhiifftt__vveerrbboossee - If set, the sshhiifftt builtin prints an error message when + If set, the sshhiifftt builtin prints an error message when the shift count exceeds the number of positional parame- ters. - ssoouurrcceeppaatthh If set, the .. (ssoouurrccee) builtin uses the value of PPAATTHH to - find the directory containing the file supplied as an - argument. This option is enabled by default. - + find the directory containing the file supplied as an + argument when the --pp option is not supplied. This op- + tion is enabled by default. vvaarrrreeddiirr__cclloossee If set, the shell automatically closes file descriptors - assigned using the _{_v_a_r_n_a_m_e_} redirection syntax (see RREE-- - DDIIRREECCTTIIOONN above) instead of leaving them open when the + assigned using the _{_v_a_r_n_a_m_e_} redirection syntax (see + RREEDDIIRREECCTTIIOONN above) instead of leaving them open when the command completes. - xxppgg__eecchhoo - If set, the eecchhoo builtin expands backslash-escape se- - quences by default. + If set, the eecchhoo builtin expands backslash-escape se- + quences by default. If the ppoossiixx shell option is also + enabled, eecchhoo does not interpret any options. ssuussppeenndd [--ff] Suspend the execution of this shell until it receives a SSIIGGCCOONNTT signal. A login shell, or a shell without job control enabled, - cannot be suspended; the --ff option can be used to override this - and force the suspension. The return status is 0 unless the - shell is a login shell or job control is not enabled and --ff is - not supplied. + cannot be suspended; the --ff option will override this and force + the suspension. The return status is 0 unless the shell is a + login shell or job control is not enabled and --ff is not sup- + plied. tteesstt _e_x_p_r [[ _e_x_p_r ]] Return a status of 0 (true) or 1 (false) depending on the evalu- - ation of the conditional expression _e_x_p_r. Each operator and op- - erand must be a separate argument. Expressions are composed of - the primaries described above under CCOONNDDIITTIIOONNAALL EEXXPPRREESSSSIIOONNSS. - tteesstt does not accept any options, nor does it accept and ignore + ation of the conditional expression _e_x_p_r. Each operator and + operand must be a separate argument. Expressions are composed + of the primaries described above under CCOONNDDIITTIIOONNAALL EEXXPPRREESSSSIIOONNSS. + tteesstt does not accept any options, nor does it accept and ignore an argument of ---- as signifying the end of options. - Expressions may be combined using the following operators, - listed in decreasing order of precedence. The evaluation de- - pends on the number of arguments; see below. Operator prece- - dence is used when there are five or more arguments. + Expressions may be combined using the following operators, + listed in decreasing order of precedence. The evaluation de- + pends on the number of arguments; see below. tteesstt uses operator + precedence when there are five or more arguments. !! _e_x_p_r True if _e_x_p_r is false. (( _e_x_p_r )) Returns the value of _e_x_p_r. This may be used to override - the normal precedence of operators. + normal operator precedence. _e_x_p_r_1 -aa _e_x_p_r_2 True if both _e_x_p_r_1 and _e_x_p_r_2 are true. _e_x_p_r_1 -oo _e_x_p_r_2 @@ -6165,9 +6922,9 @@ SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS null. 2 arguments If the first argument is !!, the expression is true if and - only if the second argument is null. If the first argu- - ment is one of the unary conditional operators listed - above under CCOONNDDIITTIIOONNAALL EEXXPPRREESSSSIIOONNSS, the expression is + only if the second argument is null. If the first argu- + ment is one of the unary conditional operators listed + above under CCOONNDDIITTIIOONNAALL EEXXPPRREESSSSIIOONNSS, the expression is true if the unary test is true. If the first argument is not a valid unary conditional operator, the expression is false. @@ -6188,227 +6945,275 @@ SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS The following conditions are applied in the order listed. If the first argument is !!, the result is the negation of the three-argument expression composed of the remaining - arguments. the two-argument test using the second and - third arguments. If the first argument is exactly (( and - the fourth argument is exactly )), the result is the two- - argument test of the second and third arguments. Other- - wise, the expression is parsed and evaluated according to + arguments. If the first argument is exactly (( and the + fourth argument is exactly )), the result is the two-argu- + ment test of the second and third arguments. Otherwise, + the expression is parsed and evaluated according to precedence using the rules listed above. 5 or more arguments The expression is parsed and evaluated according to precedence using the rules listed above. - When used with tteesstt or [[, the << and >> operators sort lexico- - graphically using ASCII ordering. + When the shell is in posix mode, or if the expression is part of + the [[[[ command, the << and >> operators sort using the current lo- + cale. If the shell is not in posix mode, the tteesstt and [[ com- + mands sort lexicographically using ASCII ordering. + + The historical operator-precedence parsing with 4 or more argu- + ments can lead to ambiguities when it encounters strings that + look like primaries. The POSIX standard has deprecated the --aa + and --oo primaries and enclosing expressions within parentheses. + Scripts should no longer use them. It's much more reliable to + restrict test invocations to a single primary, and to replace + uses of --aa and --oo with the shell's &&&& and |||| list operators. ttiimmeess Print the accumulated user and system times for the shell and for processes run from the shell. The return status is 0. - ttrraapp [--llpp] [[_a_r_g] _s_i_g_s_p_e_c ...] - The command _a_r_g is to be read and executed when the shell re- - ceives signal(s) _s_i_g_s_p_e_c. If _a_r_g is absent (and there is a sin- - gle _s_i_g_s_p_e_c) or --, each specified signal is reset to its origi- - nal disposition (the value it had upon entrance to the shell). - If _a_r_g is the null string the signal specified by each _s_i_g_s_p_e_c - is ignored by the shell and by the commands it invokes. If _a_r_g - is not present and --pp has been supplied, then the trap commands - associated with each _s_i_g_s_p_e_c are displayed. If no arguments are - supplied or if only --pp is given, ttrraapp prints the list of com- - mands associated with each signal. The --ll option causes the - shell to print a list of signal names and their corresponding - numbers. Each _s_i_g_s_p_e_c is either a signal name defined in <_s_i_g_- - _n_a_l_._h>, or a signal number. Signal names are case insensitive - and the SSIIGG prefix is optional. - - If a _s_i_g_s_p_e_c is EEXXIITT (0) the command _a_r_g is executed on exit - from the shell. If a _s_i_g_s_p_e_c is DDEEBBUUGG, the command _a_r_g is exe- - cuted before every _s_i_m_p_l_e _c_o_m_m_a_n_d, _f_o_r command, _c_a_s_e command, - _s_e_l_e_c_t command, every arithmetic _f_o_r command, and before the - first command executes in a shell function (see SSHHEELLLL GGRRAAMMMMAARR - above). Refer to the description of the eexxttddeebbuugg option to the - sshhoopptt builtin for details of its effect on the DDEEBBUUGG trap. If a - _s_i_g_s_p_e_c is RREETTUURRNN, the command _a_r_g is executed each time a shell - function or a script executed with the .. or ssoouurrccee builtins fin- - ishes executing. - - If a _s_i_g_s_p_e_c is EERRRR, the command _a_r_g is executed whenever a - pipeline (which may consist of a single simple command), a list, - or a compound command returns a non-zero exit status, subject to - the following conditions. The EERRRR trap is not executed if the + ttrraapp [--llppPP] [[_a_c_t_i_o_n] _s_i_g_s_p_e_c ...] + The _a_c_t_i_o_n is a command that is read and executed when the shell + receives any of the signals _s_i_g_s_p_e_c. If _a_c_t_i_o_n is absent (and + there is a single _s_i_g_s_p_e_c) or --, each specified _s_i_g_s_p_e_c is reset + to the value it had when the shell was started. If _a_c_t_i_o_n is + the null string the signal specified by each _s_i_g_s_p_e_c is ignored + by the shell and by the commands it invokes. + + If no arguments are supplied, ttrraapp displays the actions associ- + ated with each trapped signal as a set of ttrraapp commands that can + be reused as shell input to restore the current signal disposi- + tions. If --pp is given, and _a_c_t_i_o_n is not present, then ttrraapp + displays the actions associated with each _s_i_g_s_p_e_c or, if none + are supplied, for all trapped signals, as a set of ttrraapp commands + that can be reused as shell input to restore the current signal + dispositions. The --PP option behaves similarly, but displays + only the actions associated with each _s_i_g_s_p_e_c argument. --PP re- + quires at least one _s_i_g_s_p_e_c argument. The --PP or --pp options may + be used in a subshell environment (e.g., command substitution) + and, as long as they are used before ttrraapp is used to change a + signal's handling, will display the state of its parent's traps. + + The --ll option prints a list of signal names and their corre- + sponding numbers. Each _s_i_g_s_p_e_c is either a signal name defined + in <_s_i_g_n_a_l_._h>, or a signal number. Signal names are case insen- + sitive and the SSIIGG prefix is optional. If --ll is supplied with + no _s_i_g_s_p_e_c arguments, it prints a list of valid signal names. + + If a _s_i_g_s_p_e_c is EEXXIITT (0), _a_c_t_i_o_n is executed on exit from the + shell. If a _s_i_g_s_p_e_c is DDEEBBUUGG, _a_c_t_i_o_n is executed before every + _s_i_m_p_l_e _c_o_m_m_a_n_d, _f_o_r command, _c_a_s_e command, _s_e_l_e_c_t command, (( + arithmetic command, [[ conditional command, arithmetic _f_o_r com- + mand, and before the first command executes in a shell function + (see SSHHEELLLL GGRRAAMMMMAARR above). Refer to the description of the + eexxttddeebbuugg shell option (see sshhoopptt above) for details of its ef- + fect on the DDEEBBUUGG trap. If a _s_i_g_s_p_e_c is RREETTUURRNN, _a_c_t_i_o_n is exe- + cuted each time a shell function or a script executed with the .. + or ssoouurrccee builtins finishes executing. + + If a _s_i_g_s_p_e_c is EERRRR, _a_c_t_i_o_n is executed whenever a pipeline + (which may consist of a single simple command), a list, or a + compound command returns a non-zero exit status, subject to the + following conditions. The EERRRR trap is not executed if the failed command is part of the command list immediately following - a wwhhiillee or uunnttiill keyword, part of the test in an _i_f statement, - part of a command executed in a &&&& or |||| list except the command - following the final &&&& or ||||, any command in a pipeline but the - last, or if the command's return value is being inverted using + a wwhhiillee or uunnttiill reserved word, part of the test in an _i_f state- + ment, part of a command executed in a &&&& or |||| list except the + command following the final &&&& or ||||, any command in a pipeline + but the last (subject to the state of the ppiippeeffaaiill shell op- + tion), or if the command's return value is being inverted using !!. These are the same conditions obeyed by the eerrrreexxiitt (--ee) op- tion. - Signals ignored upon entry to the shell cannot be trapped or re- - set. Trapped signals that are not being ignored are reset to - their original values in a subshell or subshell environment when - one is created. The return status is false if any _s_i_g_s_p_e_c is - invalid; otherwise ttrraapp returns true. + When the shell is not interactive, signals ignored upon entry to + the shell cannot be trapped or reset. Interactive shells permit + trapping signals ignored on entry. Trapped signals that are not + being ignored are reset to their original values in a subshell + or subshell environment when one is created. The return status + is false if any _s_i_g_s_p_e_c is invalid; otherwise ttrraapp returns true. + + ttrruuee Does nothing, returns a 0 status. ttyyppee [--aaffttppPP] _n_a_m_e [_n_a_m_e ...] - With no options, indicate how each _n_a_m_e would be interpreted if - used as a command name. If the --tt option is used, ttyyppee prints a - string which is one of _a_l_i_a_s, _k_e_y_w_o_r_d, _f_u_n_c_t_i_o_n, _b_u_i_l_t_i_n, or - _f_i_l_e if _n_a_m_e is an alias, shell reserved word, function, - builtin, or disk file, respectively. If the _n_a_m_e is not found, - then nothing is printed, and an exit status of false is re- - turned. If the --pp option is used, ttyyppee either returns the name - of the disk file that would be executed if _n_a_m_e were specified - as a command name, or nothing if ``type -t name'' would not re- - turn _f_i_l_e. The --PP option forces a PPAATTHH search for each _n_a_m_e, - even if ``type -t name'' would not return _f_i_l_e. If a command is - hashed, --pp and --PP print the hashed value, which is not necessar- - ily the file that appears first in PPAATTHH. If the --aa option is - used, ttyyppee prints all of the places that contain an executable - named _n_a_m_e. This includes aliases and functions, if and only if - the --pp option is not also used. The table of hashed commands is - not consulted when using --aa. The --ff option suppresses shell - function lookup, as with the ccoommmmaanndd builtin. ttyyppee returns true - if all of the arguments are found, false if any are not found. + Indicate how each _n_a_m_e would be interpreted if used as a command + name. + + If the --tt option is used, ttyyppee prints a string which is one of + _a_l_i_a_s, _k_e_y_w_o_r_d, _f_u_n_c_t_i_o_n, _b_u_i_l_t_i_n, or _f_i_l_e if _n_a_m_e is an alias, + shell reserved word, function, builtin, or executable file, re- + spectively. If the _n_a_m_e is not found, ttyyppee prints nothing and + returns a non-zero exit status. + + If the --pp option is used, ttyyppee either returns the pathname of + the executable file that would be found by searching $$PPAATTHH for + _n_a_m_e or nothing if "type -t name" would not return _f_i_l_e. The --PP + option forces a PPAATTHH search for each _n_a_m_e, even if "type -t + name" would not return _f_i_l_e. If _n_a_m_e is present in the table of + hashed commands, --pp and --PP print the hashed value, which is not + necessarily the file that appears first in PPAATTHH. + + If the --aa option is used, ttyyppee prints all of the places that + contain a command named _n_a_m_e. This includes aliases, reserved + words, functions, and builtins, but the path search options (--pp + and --PP) can be supplied to restrict the output to executable + files. ttyyppee does not consult the table of hashed commands when + using --aa with --pp, and only performs a PPAATTHH search for _n_a_m_e. + + The --ff option suppresses shell function lookup, as with the ccoomm-- + mmaanndd builtin. ttyyppee returns true if all of the arguments are + found, false if any are not found. uulliimmiitt [--HHSS] --aa uulliimmiitt [--HHSS] [--bbccddeeffiikkllmmnnppqqrrssttuuvvxxPPRRTT [_l_i_m_i_t]] Provides control over the resources available to the shell and - to processes started by it, on systems that allow such control. - The --HH and --SS options specify that the hard or soft limit is set - for the given resource. A hard limit cannot be increased by a - non-root user once it is set; a soft limit may be increased up - to the value of the hard limit. If neither --HH nor --SS is speci- - fied, both the soft and hard limits are set. The value of _l_i_m_i_t - can be a number in the unit specified for the resource or one of - the special values hhaarrdd, ssoofftt, or uunnlliimmiitteedd, which stand for the - current hard limit, the current soft limit, and no limit, re- - spectively. If _l_i_m_i_t is omitted, the current value of the soft - limit of the resource is printed, unless the --HH option is given. - When more than one resource is specified, the limit name and - unit, if appropriate, are printed before the value. Other op- - tions are interpreted as follows: - --aa All current limits are reported; no limits are set - --bb The maximum socket buffer size - --cc The maximum size of core files created - --dd The maximum size of a process's data segment - --ee The maximum scheduling priority ("nice") - --ff The maximum size of files written by the shell and its - children - --ii The maximum number of pending signals - --kk The maximum number of kqueues that may be allocated - --ll The maximum size that may be locked into memory - --mm The maximum resident set size (many systems do not honor - this limit) + to processes it starts, on systems that allow such control. + + The --HH and --SS options specify whether the hard or soft limit is + set for the given resource. A hard limit cannot be increased by + a non-root user once it is set; a soft limit may be increased up + to the value of the hard limit. If neither --HH nor --SS is speci- + fied, uulliimmiitt sets both the soft and hard limits. + + The value of _l_i_m_i_t can be a number in the unit specified for the + resource or one of the special values hhaarrdd, ssoofftt, or uunnlliimmiitteedd, + which stand for the current hard limit, the current soft limit, + and no limit, respectively. If _l_i_m_i_t is omitted, uulliimmiitt prints + the current value of the soft limit of the resource, unless the + --HH option is given. When more than one resource is specified, + the limit name and unit, if appropriate, are printed before the + value. Other options are interpreted as follows: + --aa Report all current limits; no limits are set. + --bb The maximum socket buffer size. + --cc The maximum size of core files created. + --dd The maximum size of a process's data segment. + --ee The maximum scheduling priority ("nice"). + --ff The maximum size of files written by the shell and its + children. + --ii The maximum number of pending signals. + --kk The maximum number of kqueues that may be allocated. + --ll The maximum size that may be locked into memory. + --mm The maximum resident set size (many systems do not honor + this limit). --nn The maximum number of open file descriptors (most systems - do not allow this value to be set) - --pp The pipe size in 512-byte blocks (this may not be set) - --qq The maximum number of bytes in POSIX message queues - --rr The maximum real-time scheduling priority - --ss The maximum stack size - --tt The maximum amount of cpu time in seconds + do not allow this value to be set). + --pp The pipe size in 512-byte blocks (this may not be set). + --qq The maximum number of bytes in POSIX message queues. + --rr The maximum real-time scheduling priority. + --ss The maximum stack size. + --tt The maximum amount of cpu time in seconds. --uu The maximum number of processes available to a single - user + user. --vv The maximum amount of virtual memory available to the - shell and, on some systems, to its children - --xx The maximum number of file locks - --PP The maximum number of pseudoterminals + shell and, on some systems, to its children. + --xx The maximum number of file locks. + --PP The maximum number of pseudoterminals. --RR The maximum time a real-time process can run before - blocking, in microseconds - --TT The maximum number of threads - - If _l_i_m_i_t is given, and the --aa option is not used, _l_i_m_i_t is the - new value of the specified resource. If no option is given, - then --ff is assumed. Values are in 1024-byte increments, except - for --tt, which is in seconds; --RR, which is in microseconds; --pp, - which is in units of 512-byte blocks; --PP, --TT, --bb, --kk, --nn, and - --uu, which are unscaled values; and, when in posix mode, --cc and - --ff, which are in 512-byte increments. The return status is 0 - unless an invalid option or argument is supplied, or an error - occurs while setting a new limit. + blocking, in microseconds. + --TT The maximum number of threads. + + If _l_i_m_i_t is supplied, and the --aa option is not used, _l_i_m_i_t is + the new value of the specified resource. If no option is sup- + plied, then --ff is assumed. + + Values are in 1024-byte increments, except for --tt, which is in + seconds; --RR, which is in microseconds; --pp, which is in units of + 512-byte blocks; --PP, --TT, --bb, --kk, --nn, and --uu, which are unscaled + values; and, when in posix mode, --cc and --ff, which are in + 512-byte increments. The return status is 0 unless an invalid + option or argument is supplied, or an error occurs while setting + a new limit. uummaasskk [--pp] [--SS] [_m_o_d_e] - The user file-creation mask is set to _m_o_d_e. If _m_o_d_e begins with - a digit, it is interpreted as an octal number; otherwise it is - interpreted as a symbolic mode mask similar to that accepted by - _c_h_m_o_d(1). If _m_o_d_e is omitted, the current value of the mask is - printed. The --SS option causes the mask to be printed in sym- - bolic form; the default output is an octal number. If the --pp - option is supplied, and _m_o_d_e is omitted, the output is in a form - that may be reused as input. The return status is 0 if the mode - was successfully changed or if no _m_o_d_e argument was supplied, - and false otherwise. + Set the user file-creation mask to _m_o_d_e. If _m_o_d_e begins with a + digit, it is interpreted as an octal number; otherwise it is in- + terpreted as a symbolic mode mask similar to that accepted by + _c_h_m_o_d(1). If _m_o_d_e is omitted, uummaasskk prints the current value of + the mask. The --SS option without a _m_o_d_e argument prints the mask + in a symbolic format; the default output is an octal number. If + the --pp option is supplied, and _m_o_d_e is omitted, the output is in + a form that may be reused as input. The return status is zero + if the mode was successfully changed or if no _m_o_d_e argument was + supplied, and non-zero otherwise. uunnaalliiaass [-aa] [_n_a_m_e ...] Remove each _n_a_m_e from the list of defined aliases. If --aa is - supplied, all alias definitions are removed. The return value - is true unless a supplied _n_a_m_e is not a defined alias. + supplied, remove all alias definitions. The return value is + true unless a supplied _n_a_m_e is not a defined alias. uunnsseett [-ffvv] [-nn] [_n_a_m_e ...] For each _n_a_m_e, remove the corresponding variable or function. If the --vv option is given, each _n_a_m_e refers to a shell variable, - and that variable is removed. Read-only variables may not be - unset. If --ff is specified, each _n_a_m_e refers to a shell func- - tion, and the function definition is removed. If the --nn option - is supplied, and _n_a_m_e is a variable with the _n_a_m_e_r_e_f attribute, - _n_a_m_e will be unset rather than the variable it references. --nn - has no effect if the --ff option is supplied. If no options are - supplied, each _n_a_m_e refers to a variable; if there is no vari- - able by that name, a function with that name, if any, is unset. - Each unset variable or function is removed from the environment - passed to subsequent commands. If any of BBAASSHH__AALLIIAASSEESS, - BBAASSHH__AARRGGVV00, BBAASSHH__CCMMDDSS, BBAASSHH__CCOOMMMMAANNDD, BBAASSHH__SSUUBBSSHHEELLLL, BBAASSHHPPIIDD, - CCOOMMPP__WWOORRDDBBRREEAAKKSS, DDIIRRSSTTAACCKK, EEPPOOCCHHRREEAALLTTIIMMEE, EEPPOOCCHHSSEECCOONNDDSS, FFUUNNCC-- - NNAAMMEE, GGRROOUUPPSS, HHIISSTTCCMMDD, LLIINNEENNOO, RRAANNDDOOMM, SSEECCOONNDDSS, or SSRRAANNDDOOMM are - unset, they lose their special properties, even if they are sub- - sequently reset. The exit status is true unless a _n_a_m_e is read- - only or may not be unset. - - wwaaiitt [--ffnn] [--pp _v_a_r_n_a_m_e] [_i_d _._._.] - Wait for each specified child process and return its termination - status. Each _i_d may be a process ID or a job specification; if - a job spec is given, all processes in that job's pipeline are - waited for. If _i_d is not given, wwaaiitt waits for all running - background jobs and the last-executed process substitution, if + and that variable is removed. If --ff is specified, each _n_a_m_e + refers to a shell function, and the function definition is re- + moved. If the --nn option is supplied, and _n_a_m_e is a variable + with the _n_a_m_e_r_e_f attribute, _n_a_m_e will be unset rather than the + variable it references. --nn has no effect if the --ff option is + supplied. Read-only variables and functions may not be unset. + When variables or functions are removed, they are also removed + from the environment passed to subsequent commands. If no op- + tions are supplied, each _n_a_m_e refers to a variable; if there is + no variable by that name, a function with that name, if any, is + unset. Some shell variables may not be unset. If any of + BBAASSHH__AALLIIAASSEESS, BBAASSHH__AARRGGVV00, BBAASSHH__CCMMDDSS, BBAASSHH__CCOOMMMMAANNDD, BBAASSHH__SSUUBB-- + SSHHEELLLL, BBAASSHHPPIIDD, CCOOMMPP__WWOORRDDBBRREEAAKKSS, DDIIRRSSTTAACCKK, EEPPOOCCHHRREEAALLTTIIMMEE, + EEPPOOCCHHSSEECCOONNDDSS, FFUUNNCCNNAAMMEE, GGRROOUUPPSS, HHIISSTTCCMMDD, LLIINNEENNOO, RRAANNDDOOMM, SSEECC-- + OONNDDSS, or SSRRAANNDDOOMM are unset, they lose their special properties, + even if they are subsequently reset. The exit status is true + unless a _n_a_m_e is readonly or may not be unset. + + wwaaiitt [--ffnn] [--pp _v_a_r_n_a_m_e] [_i_d ...] + Wait for each specified child process _i_d and return the termina- + tion status of the last _i_d. Each _i_d may be a process ID _p_i_d or + a job specification _j_o_b_s_p_e_c; if a jobspec is supplied, wwaaiitt + waits for all processes in the job. + + If no options or _i_ds are supplied, wwaaiitt waits for all running + background jobs and the last-executed process substitution, if its process id is the same as $$!!, and the return status is zero. - If the --nn option is supplied, wwaaiitt waits for a single job from - the list of _i_ds or, if no _i_ds are supplied, any job, to complete - and returns its exit status. If none of the supplied arguments - is a child of the shell, or if no arguments are supplied and the - shell has no unwaited-for children, the exit status is 127. If - the --pp option is supplied, the process or job identifier of the - job for which the exit status is returned is assigned to the - variable _v_a_r_n_a_m_e named by the option argument. The variable - will be unset initially, before any assignment. This is useful - only when the --nn option is supplied. Supplying the --ff option, - when job control is enabled, forces wwaaiitt to wait for _i_d to ter- - minate before returning its status, instead of returning when it - changes status. If _i_d specifies a non-existent process or job, - the return status is 127. If wwaaiitt is interrupted by a signal, - the return status will be greater than 128, as described under - SSIIGGNNAALLSS above. Otherwise, the return status is the exit status - of the last process or job waited for. + + If the --nn option is supplied, wwaaiitt waits for any one of the + given _i_ds or, if no _i_ds are supplied, any job or process substi- + tution, to complete and returns its exit status. If none of the + supplied _i_ds is a child of the shell, or if no _i_ds are supplied + and the shell has no unwaited-for children, the exit status is + 127. + + If the --pp option is supplied, wwaaiitt assigns the process or job + identifier of the job for which the exit status is returned to + the variable _v_a_r_n_a_m_e named by the option argument. The vari- + able, which cannot be readonly, will be unset initially, before + any assignment. This is useful only when used with the --nn op- + tion. + + Supplying the --ff option, when job control is enabled, forces + wwaaiitt to wait for each _i_d to terminate before returning its sta- + tus, instead of returning when it changes status. + + If none of the _i_ds specify one of the shell's active child + processes, the return status is 127. If wwaaiitt is interrupted by + a signal, any _v_a_r_n_a_m_e will remain unset, and the return status + will be greater than 128, as described under SSIIGGNNAALLSS above. + Otherwise, the return status is the exit status of the last _i_d. SSHHEELLLL CCOOMMPPAATTIIBBIILLIITTYY MMOODDEE Bash-4.0 introduced the concept of a _s_h_e_l_l _c_o_m_p_a_t_i_b_i_l_i_t_y _l_e_v_e_l, speci- - fied as a set of options to the shopt builtin ( ccoommppaatt3311, ccoommppaatt3322, - ccoommppaatt4400, ccoommppaatt4411, and so on). There is only one current compatibil- - ity level -- each option is mutually exclusive. The compatibility - level is intended to allow users to select behavior from previous ver- - sions that is incompatible with newer versions while they migrate - scripts to use current features and behavior. It's intended to be a - temporary solution. + fied as a set of options to the shopt builtin (ccoommppaatt3311, ccoommppaatt3322, ccoomm-- + ppaatt4400, ccoommppaatt4411, and so on). There is only one current compatibility + level -- each option is mutually exclusive. The compatibility level is + intended to allow users to select behavior from previous versions that + is incompatible with newer versions while they migrate scripts to use + current features and behavior. It's intended to be a temporary solu- + tion. This section does not mention behavior that is standard for a particu- - lar version (e.g., setting ccoommppaatt3322 means that quoting the rhs of the - regexp matching operator quotes special regexp characters in the word, - which is default behavior in bash-3.2 and subsequent versions). - - If a user enables, say, ccoommppaatt3322, it may affect the behavior of other - compatibility levels up to and including the current compatibility - level. The idea is that each compatibility level controls behavior - that changed in that version of bbaasshh, but that behavior may have been - present in earlier versions. For instance, the change to use locale- - based comparisons with the [[[[ command came in bash-4.1, and earlier + lar version (e.g., setting ccoommppaatt3322 means that quoting the right hand + side of the regexp matching operator quotes special regexp characters + in the word, which is default behavior in bash-3.2 and subsequent ver- + sions). + + If a user enables, say, ccoommppaatt3322, it may affect the behavior of other + compatibility levels up to and including the current compatibility + level. The idea is that each compatibility level controls behavior + that changed in that version of bbaasshh, but that behavior may have been + present in earlier versions. For instance, the change to use locale- + based comparisons with the [[[[ command came in bash-4.1, and earlier versions used ASCII-based comparisons, so enabling ccoommppaatt3322 will enable ASCII-based comparisons as well. That granularity may not be suffi- cient for all uses, and as a result users should employ compatibility @@ -6417,103 +7222,97 @@ SSHHEELLLL CCOOMMPPAATTIIBBIILLIITTYY MMOODDEE Bash-4.3 introduced a new shell variable: BBAASSHH__CCOOMMPPAATT. The value as- signed to this variable (a decimal version number like 4.2, or an inte- - ger corresponding to the ccoommppaatt_N_N option, like 42) determines the com- + ger corresponding to the ccoommppaatt_N_N option, like 42) determines the com- patibility level. - Starting with bash-4.4, Bash has begun deprecating older compatibility - levels. Eventually, the options will be removed in favor of BBAASSHH__CCOOMM-- - PPAATT. + Starting with bash-4.4, bbaasshh began deprecating older compatibility lev- + els. Eventually, the options will be removed in favor of BBAASSHH__CCOOMMPPAATT. - Bash-5.0 is the final version for which there will be an individual - shopt option for the previous version. Users should use BBAASSHH__CCOOMMPPAATT on - bash-5.0 and later versions. + Bash-5.0 was the final version for which there was an individual shopt + option for the previous version. BBAASSHH__CCOOMMPPAATT is the only mechanism to + control the compatibility level in versions newer than bash-5.0. - The following table describes the behavior changes controlled by each + The following table describes the behavior changes controlled by each compatibility level setting. The ccoommppaatt_N_N tag is used as shorthand for setting the compatibility level to _N_N using one of the following mecha- - nisms. For versions prior to bash-5.0, the compatibility level may be - set using the corresponding ccoommppaatt_N_N shopt option. For bash-4.3 and - later versions, the BBAASSHH__CCOOMMPPAATT variable is preferred, and it is re- + nisms. For versions prior to bash-5.0, the compatibility level may be + set using the corresponding ccoommppaatt_N_N shopt option. For bash-4.3 and + later versions, the BBAASSHH__CCOOMMPPAATT variable is preferred, and it is re- quired for bash-5.1 and later versions. ccoommppaatt3311 - +o quoting the rhs of the [[[[ command's regexp matching oper- - ator (=~) has no special effect + +o Quoting the rhs of the [[[[ command's regexp matching oper- + ator (=~) has no special effect. ccoommppaatt3322 - +o interrupting a command list such as "a ; b ; c" causes - the execution of the next command in the list (in - bash-4.0 and later versions, the shell acts as if it re- - ceived the interrupt, so interrupting one command in a - list aborts the execution of the entire list) + +o The << and >> operators to the [[[[ command do not consider + the current locale when comparing strings; they use ASCII + ordering. ccoommppaatt4400 - +o the << and >> operators to the [[[[ command do not consider + +o The << and >> operators to the [[[[ command do not consider the current locale when comparing strings; they use ASCII - ordering. Bash versions prior to bash-4.1 use ASCII col- - lation and _s_t_r_c_m_p(3); bash-4.1 and later use the current + ordering. BBaasshh versions prior to bash-4.1 use ASCII col- + lation and _s_t_r_c_m_p(3); bash-4.1 and later use the current locale's collation sequence and _s_t_r_c_o_l_l(3). ccoommppaatt4411 - +o in _p_o_s_i_x mode, ttiimmee may be followed by options and still + +o In posix mode, ttiimmee may be followed by options and still be recognized as a reserved word (this is POSIX interpre- - tation 267) - +o in _p_o_s_i_x mode, the parser requires that an even number of - single quotes occur in the _w_o_r_d portion of a double- - quoted parameter expansion and treats them specially, so - that characters within the single quotes are considered - quoted (this is POSIX interpretation 221) + tation 267). + +o In _p_o_s_i_x mode, the parser requires that an even number of + single quotes occur in the _w_o_r_d portion of a double- + quoted parameter expansion and treats them specially, so + that characters within the single quotes are considered + quoted (this is POSIX interpretation 221). ccoommppaatt4422 - +o the replacement string in double-quoted pattern substitu- + +o The replacement string in double-quoted pattern substitu- tion does not undergo quote removal, as it does in ver- - sions after bash-4.2 - +o in posix mode, single quotes are considered special when + sions after bash-4.2. + +o In posix mode, single quotes are considered special when expanding the _w_o_r_d portion of a double-quoted parameter expansion and can be used to quote a closing brace or other special character (this is part of POSIX interpre- tation 221); in later versions, single quotes are not - special within double-quoted word expansions + special within double-quoted word expansions. ccoommppaatt4433 - +o the shell does not print a warning message if an attempt - is made to use a quoted compound assignment as an argu- - ment to declare (e.g., declare -a foo='(1 2)'). Later - versions warn that this usage is deprecated - +o word expansion errors are considered non-fatal errors - that cause the current command to fail, even in posix - mode (the default behavior is to make them fatal errors - that cause the shell to exit) - +o when executing a shell function, the loop state + +o Word expansion errors are considered non-fatal errors + that cause the current command to fail, even in posix + mode (the default behavior is to make them fatal errors + that cause the shell to exit). + +o When executing a shell function, the loop state (while/until/etc.) is not reset, so bbrreeaakk or ccoonnttiinnuuee in that function will break or continue loops in the calling context. Bash-4.4 and later reset the loop state to pre- - vent this + vent this. ccoommppaatt4444 - +o the shell sets up the values used by BBAASSHH__AARRGGVV and + +o The shell sets up the values used by BBAASSHH__AARRGGVV and BBAASSHH__AARRGGCC so they can expand to the shell's positional - parameters even if extended debugging mode is not enabled - +o a subshell inherits loops from its parent context, so - bbrreeaakk or ccoonnttiinnuuee will cause the subshell to exit. - Bash-5.0 and later reset the loop state to prevent the + parameters even if extended debugging mode is not en- + abled. + +o A subshell inherits loops from its parent context, so + bbrreeaakk or ccoonnttiinnuuee will cause the subshell to exit. + Bash-5.0 and later reset the loop state to prevent the exit - +o variable assignments preceding builtins like eexxppoorrtt and + +o Variable assignments preceding builtins like eexxppoorrtt and rreeaaddoonnllyy that set attributes continue to affect variables with the same name in the calling environment even if the - shell is not in posix mode + shell is not in posix mode. ccoommppaatt5500 - +o Bash-5.1 changed the way $$RRAANNDDOOMM is generated to intro- - duce slightly more randomness. If the shell compatibility - level is set to 50 or lower, it reverts to the method + +o Bash-5.1 changed the way $$RRAANNDDOOMM is generated to intro- + duce slightly more randomness. If the shell compatibil- + ity level is set to 50 or lower, it reverts to the method from bash-5.0 and previous versions, so seeding the ran- dom number generator by assigning a value to RRAANNDDOOMM will - produce the same sequence as in bash-5.0 + produce the same sequence as in bash-5.0. +o If the command hash table is empty, bash versions prior to bash-5.1 printed an informational message to that ef- fect, even when producing output that can be reused as - input. Bash-5.1 suppresses that message when the --ll op- + input. Bash-5.1 suppresses that message when the --ll op- tion is supplied. ccoommppaatt5511 @@ -6521,66 +7320,107 @@ SSHHEELLLL CCOOMMPPAATTIIBBIILLIITTYY MMOODDEE scripts @@ and ** differently depending on whether the ar- ray is indexed or associative, and differently than in previous versions. + +o Arithmetic commands ( ((((...)))) ) and the expressions in an + arithmetic for statement can be expanded more than once. + +o Expressions used as arguments to arithmetic operators in + the [[[[ conditional command can be expanded more than + once. + +o The expressions in substring parameter brace expansion + can be expanded more than once. + +o The expressions in the $$((((...)))) word expansion can be ex- + panded more than once. + +o Arithmetic expressions used as indexed array subscripts + can be expanded more than once. + +o tteesstt --vv, when given an argument of AA[[@@]], where AA is an + existing associative array, will return true if the array + has any set elements. Bash-5.2 will look for and report + on a key named @@. + +o The ${_p_a_r_a_m_e_t_e_r[[::]]==_v_a_l_u_e} word expansion will return + _v_a_l_u_e, before any variable-specific transformations have + been performed (e.g., converting to lowercase). Bash-5.2 + will return the final value assigned to the variable. + +o Parsing command substitutions will behave as if extended + globbing (see the description of the sshhoopptt builtin above) + is enabled, so that parsing a command substitution con- + taining an extglob pattern (say, as part of a shell func- + tion) will not fail. This assumes the intent is to en- + able extglob before the command is executed and word ex- + pansions are performed. It will fail at word expansion + time if extglob hasn't been enabled by the time the com- + mand is executed. + + ccoommppaatt5522 + +o The tteesstt builtin uses its historical algorithm to parse + parenthesized subexpressions when given five or more ar- + guments. + +o If the --pp or --PP option is supplied to the bbiinndd builtin, + bbiinndd treats any arguments remaining after option process- + ing as bindable command names, and displays any key se- + quences bound to those commands, instead of treating the + arguments as key sequences to bind. RREESSTTRRIICCTTEEDD SSHHEELLLL If bbaasshh is started with the name rrbbaasshh, or the --rr option is supplied at - invocation, the shell becomes restricted. A restricted shell is used + invocation, the shell becomes _r_e_s_t_r_i_c_t_e_d. A restricted shell is used to set up an environment more controlled than the standard shell. It behaves identically to bbaasshh with the exception that the following are disallowed or not performed: - +o changing directories with ccdd + +o Changing directories with ccdd. - +o setting or unsetting the values of SSHHEELLLL, PPAATTHH, HHIISSTTFFIILLEE, EENNVV, - or BBAASSHH__EENNVV + +o Setting or unsetting the values of SSHHEELLLL, PPAATTHH, HHIISSTTFFIILLEE, EENNVV, + or BBAASSHH__EENNVV. - +o specifying command names containing // + +o Specifying command names containing //. - +o specifying a filename containing a // as an argument to the .. - builtin command + +o Specifying a filename containing a // as an argument to the .. + builtin command. - +o specifying a filename containing a slash as an argument to the - hhiissttoorryy builtin command + +o Using the --pp option to the .. builtin command to specify a + search path. - +o specifying a filename containing a slash as an argument to the - --pp option to the hhaasshh builtin command + +o Specifying a filename containing a slash as an argument to the + hhiissttoorryy builtin command. - +o importing function definitions from the shell environment at - startup + +o Specifying a filename containing a slash as an argument to the + --pp option to the hhaasshh builtin command. - +o parsing the value of SSHHEELLLLOOPPTTSS from the shell environment at - startup + +o Importing function definitions from the shell environment at + startup. - +o redirecting output using the >, >|, <>, >&, &>, and >> redirect- - ion operators + +o Parsing the values of BBAASSHHOOPPTTSS and SSHHEELLLLOOPPTTSS from the shell en- + vironment at startup. - +o using the eexxeecc builtin command to replace the shell with another - command + +o Redirecting output using the >, >|, <>, >&, &>, and >> redirec- + tion operators. - +o adding or deleting builtin commands with the --ff and --dd options - to the eennaabbllee builtin command + +o Using the eexxeecc builtin command to replace the shell with another + command. - +o using the eennaabbllee builtin command to enable disabled shell - builtins + +o Adding or deleting builtin commands with the --ff and --dd options + to the eennaabbllee builtin command. - +o specifying the --pp option to the ccoommmmaanndd builtin command + +o Using the eennaabbllee builtin command to enable disabled shell + builtins. - +o turning off restricted mode with sseett ++rr or sshhoopptt --uu rree-- + +o Specifying the --pp option to the ccoommmmaanndd builtin command. + + +o Turning off restricted mode with sseett ++rr or sshhoopptt --uu rree-- ssttrriicctteedd__sshheellll. These restrictions are enforced after any startup files are read. When a command that is found to be a shell script is executed (see CCOOMM-- - MMAANNDD EEXXEECCUUTTIIOONN above), rrbbaasshh turns off any restrictions in the shell + MMAANNDD EEXXEECCUUTTIIOONN above), rrbbaasshh turns off any restrictions in the shell spawned to execute the script. SSEEEE AALLSSOO _B_a_s_h _R_e_f_e_r_e_n_c_e _M_a_n_u_a_l, Brian Fox and Chet Ramey _T_h_e _G_n_u _R_e_a_d_l_i_n_e _L_i_b_r_a_r_y, Brian Fox and Chet Ramey _T_h_e _G_n_u _H_i_s_t_o_r_y _L_i_b_r_a_r_y, Brian Fox and Chet Ramey - _P_o_r_t_a_b_l_e _O_p_e_r_a_t_i_n_g _S_y_s_t_e_m _I_n_t_e_r_f_a_c_e _(_P_O_S_I_X_) _P_a_r_t _2_: _S_h_e_l_l _a_n_d _U_t_i_l_i_- + _P_o_r_t_a_b_l_e _O_p_e_r_a_t_i_n_g _S_y_s_t_e_m _I_n_t_e_r_f_a_c_e _(_P_O_S_I_X_) _P_a_r_t _2_: _S_h_e_l_l _a_n_d _U_t_i_l_i_- _t_i_e_s, IEEE -- - http://pubs.opengroup.org/onlinepubs/9699919799/ + http://pubs.opengroup.org/onlinepubs/9799919799/ http://tiswww.case.edu/~chet/bash/POSIX -- a description of posix mode _s_h(1), _k_s_h(1), _c_s_h(1) _e_m_a_c_s(1), _v_i(1) @@ -6612,16 +7452,16 @@ AAUUTTHHOORRSS chet.ramey@case.edu BBUUGG RREEPPOORRTTSS - If you find a bug in bbaasshh,, you should report it. But first, you should - make sure that it really is a bug, and that it appears in the latest - version of bbaasshh. The latest version is always available from + If you find a bug in bbaasshh, you should report it. But first, you should + make sure that it really is a bug, and that it appears in the latest + version of bbaasshh. The latest version is always available from _f_t_p_:_/_/_f_t_p_._g_n_u_._o_r_g_/_p_u_b_/_g_n_u_/_b_a_s_h_/ and _h_t_t_p_:_/_/_g_i_t_._s_a_v_a_n_- _n_a_h_._g_n_u_._o_r_g_/_c_g_i_t_/_b_a_s_h_._g_i_t_/_s_n_a_p_s_h_o_t_/_b_a_s_h_-_m_a_s_t_e_r_._t_a_r_._g_z. - Once you have determined that a bug actually exists, use the _b_a_s_h_b_u_g - command to submit a bug report. If you have a fix, you are encouraged - to mail that as well! Suggestions and `philosophical' bug reports may - be mailed to _b_u_g_-_b_a_s_h_@_g_n_u_._o_r_g or posted to the Usenet newsgroup + Once you have determined that a bug actually exists, use the _b_a_s_h_b_u_g + command to submit a bug report. If you have a fix, you are encouraged + to mail that as well! You may send suggestions and "philosophical" bug + reports to _b_u_g_-_b_a_s_h_@_g_n_u_._o_r_g or post them to the Usenet newsgroup ggnnuu..bbaasshh..bbuugg. ALL bug reports should include: @@ -6629,8 +7469,8 @@ BBUUGG RREEPPOORRTTSS The version number of bbaasshh The hardware and operating system The compiler used to compile - A description of the bug behaviour - A short script or `recipe' which exercises the bug + A description of the bug behavior + A short script or "recipe" which exercises the bug _b_a_s_h_b_u_g inserts the first three items automatically into the template it provides for filing a bug report. @@ -6642,23 +7482,20 @@ BBUUGGSS It's too big and too slow. There are some subtle differences between bbaasshh and traditional versions - of sshh, mostly because of the PPOOSSIIXX specification. + of sshh, mostly because of the POSIX specification. Aliases are confusing in some uses. Shell builtin commands and functions are not stoppable/restartable. - Compound commands and command sequences of the form `a ; b ; c' are not - handled gracefully when process suspension is attempted. When a + Compound commands and command lists of the form "a ; b ; c" are not + handled gracefully when combined with process suspension. When a process is stopped, the shell immediately executes the next command in - the sequence. It suffices to place the sequence of commands between - parentheses to force it into a subshell, which may be stopped as a - unit. + the list or breaks out of any existing loops. It suffices to enclose + the command in parentheses to force it into a subshell, which may be + stopped as a unit, or to start the command in the background and imme- + diately bring it into the foreground. Array variables may not (yet) be exported. - There may be only one active coprocess at a time. - - - -GNU Bash 5.2 2022 September 19 BASH(1) +GNU Bash 5.3 2025 April 7 _B_A_S_H(1) diff --git a/doc/bash.1 b/doc/bash.1 index 55c562208..5af3492f7 100644 --- a/doc/bash.1 +++ b/doc/bash.1 @@ -5,43 +5,63 @@ .\" Case Western Reserve University .\" chet.ramey@case.edu .\" -.\" Last Change: Mon Sep 19 11:13:21 EDT 2022 +.\" Last Change: Mon Apr 7 16:59:13 EDT 2025 .\" -.\" bash_builtins, strip all but Built-Ins section -.if \n(zZ=1 .ig zZ -.if \n(zY=1 .ig zY -.TH BASH 1 "2022 September 19" "GNU Bash 5.2" +.\" For bash_builtins, strip all but "SHELL BUILTIN COMMANDS" section +.\" For rbash, strip all but "RESTRICTED SHELL" section .\" -.\" There's some problem with having a `@' -.\" in a tagged paragraph with the BSD man macros. -.\" It has to do with `@' appearing in the }1 macro. -.\" This is a problem on 4.3 BSD and Ultrix, but Sun -.\" appears to have fixed it. -.\" If you're seeing the characters -.\" `@u-3p' appearing before the lines reading -.\" `possible-hostname-completions -.\" and `complete-hostname' down in READLINE, -.\" then uncomment this redefinition. +.\" Both conditionalize text based on the base page being formatted +.\" using the zZ and zY registers, respectively .\" -.\" .de }1 -.\" .ds ]X \&\\*(]B\\ -.\" .nr )E 0 -.\" .if !"\\$1"" .nr )I \\$1n -.\" .}f -.\" .ll \\n(LLu -.\" .in \\n()Ru+\\n(INu+\\n()Iu -.\" .ti \\n(INu -.\" .ie !\\n()Iu+\\n()Ru-\w\\*(]Xu-3p \{\\*(]X -.\" .br\} -.\" .el \\*(]X\h|\\n()Iu+\\n()Ru\c -.\" .}f -.\" .. +.\" Ensure the registers are initialized to avoid groff warnings. +.nr zZ +0 +.nr zY +0 +.\" Ensure the macros/strings are initialized to avoid groff warnings. +.ds zZ \" empty +.ds zY \" empty +.if \n(zZ=1 .ig zZ +.if \n(zY=1 .ig zY +.TH BASH 1 "2025 April 7" "GNU Bash 5.3" .\" +.ie \n(.g \{\ +.ds ' \(aq +.ds " \(dq +.ds ^ \(ha +.ds ~ \(ti +.\} +.el \{\ +.ds ' ' +.\" \*" is not usable in macro arguments on AT&T troff (DWB, Solaris 10) +.ds " ""\" two adjacent quotes and no space before this comment +.ds ^ ^ +.ds ~ ~ +.\} +. .\" File Name macro. This used to be `.PN', for Path Name, .\" but Sun doesn't seem to like that very much. +.\" \% at the beginning of the string protects the filename from hyphenation. .\" .de FN -\fI\|\\$1\|\fP +\%\fI\|\\$1\|\fP\\$2 +.. +.\" +.\" Quotation macro: generate consistent quoted strings that don't rely +.\" on the presence of the `CW' constant-width font. +.\" +.de Q +.ie \n(.g \(lq\\$1\(rq\\$2 +.el \{\ +. if t ``\\$1''\\$2 +. if n "\\$1"\\$2 +.\} +.. +.\" Q but disallowing hyphenation of the string +.de QN +.ie \n(.g \%\(lq\\$1\(rq\\$2 +.el \{\ +. if t \%``\\$1''\\$2 +. if n \%"\\$1"\\$2 +.\} .. .SH NAME bash \- GNU Bourne-Again SHell @@ -50,30 +70,47 @@ bash \- GNU Bourne-Again SHell [options] [command_string | file] .SH COPYRIGHT -.if n Bash is Copyright (C) 1989-2022 by the Free Software Foundation, Inc. -.if t Bash is Copyright \(co 1989-2022 by the Free Software Foundation, Inc. +.if n Bash is Copyright (C) 1989-2025 by the Free Software Foundation, Inc. +.if t Bash is Copyright \(co 1989-2025 by the Free Software Foundation, Inc. .SH DESCRIPTION .B Bash -is an \fBsh\fR-compatible command language interpreter that -executes commands read from the standard input or from a file. +is a command language interpreter that +executes commands read from the standard input, from a string, +or from a file. +It is a reimplementation and extension of the Bourne shell, +the historical Unix command language interpreter. .B Bash also incorporates useful features from the \fIKorn\fP and \fIC\fP shells (\fBksh\fP and \fBcsh\fP). .PP +.SM POSIX +is the name for a family of computing standards based on Unix. .B Bash is intended to be a conformant implementation of the -Shell and Utilities portion of the IEEE POSIX specification -(IEEE Standard 1003.1). +Shell and Utilities portion of the IEEE +.SM POSIX +specification (IEEE Standard 1003.1). .B Bash -can be configured to be POSIX-conformant by default. +.SM POSIX +mode (hereafter referred to as \fIposix mode\fP) +changes the shell's behavior where its default operation differs +from the standard to strictly conform to the standard. +See +.SM +.B "SEE ALSO" +below for a reference to a document that details how posix mode affects +\fBbash\fP's behavior. +.B Bash +can be configured to be +.SM POSIX\c +-conformant by default. .SH OPTIONS All of the single-character shell options documented in the -description of the \fBset\fR builtin command, including \fB\-o\fP, +description of the \fBset\fP builtin command, including \fB\-o\fP, can be used as options when the shell is invoked. -In addition, \fBbash\fR +In addition, \fBbash\fP interprets the following options when it is invoked: .PP -.PD 0 .TP 10 .B \-c If the @@ -117,14 +154,14 @@ below). If the .B \-s option is present, or if no arguments remain after option -processing, then commands are read from the standard input. +processing, the shell reads commands from the standard input. This option allows the positional parameters to be set when invoking an interactive shell or when reading input through a pipe. .TP .B \-D -A list of all double-quoted strings preceded by \fB$\fP -is printed on the standard output. +Print a list of all double-quoted strings preceded by \fB$\fP +on the standard output. These are the strings that are subject to language translation when the current locale is not \fBC\fP or \fBPOSIX\fP. @@ -134,12 +171,13 @@ This implies the \fB\-n\fP option; no commands will be executed. \fIshopt_option\fP is one of the shell options accepted by the \fBshopt\fP builtin (see .SM -.B SHELL BUILTIN COMMANDS +.B "SHELL BUILTIN COMMANDS" below). If \fIshopt_option\fP is present, \fB\-O\fP sets the value of that option; \fB+O\fP unsets it. -If \fIshopt_option\fP is not supplied, the names and values of the shell -options accepted by \fBshopt\fP are printed on the standard output. +If \fIshopt_option\fP is not supplied, \fBbash\fP prints +the names and values of the shell +options accepted by \fBshopt\fP on the standard output. If the invocation option is \fB+O\fP, the output is displayed in a format that may be reused as input. .TP @@ -149,17 +187,17 @@ A signals the end of options and disables further option processing. Any arguments after the .B \-\- -are treated as filenames and arguments. An argument of +are treated as a shell script filename (see below) +and arguments passed to that script. +An argument of .B \- is equivalent to \fB\-\-\fP. -.PD .PP .B Bash also interprets a number of multi-character options. These options must appear on the command line before the single-character options to be recognized. .PP -.PD 0 .TP .B \-\-debugger Arrange for the debugger profile to be executed before the shell @@ -172,7 +210,8 @@ builtin below). .TP .B \-\-dump\-po\-strings Equivalent to \fB\-D\fP, but the output is in the GNU \fIgettext\fP -\fBpo\fP (portable object) file format. +.Q po +(portable object) file format. .TP .B \-\-dump\-strings Equivalent to \fB\-D\fP. @@ -180,15 +219,15 @@ Equivalent to \fB\-D\fP. .B \-\-help Display a usage message on standard output and exit successfully. .TP -\fB\-\-init\-file\fP \fIfile\fP .PD 0 +\fB\-\-init\-file\fP \fIfile\fP .TP \fB\-\-rcfile\fP \fIfile\fP .PD Execute commands from .I file instead of the standard personal initialization file -.I ~/.bashrc +.FN \*~/.bashrc if the shell is interactive (see .SM .B INVOCATION @@ -206,10 +245,10 @@ library to read command lines when the shell is interactive. Do not read either the system-wide startup file .FN /etc/profile or any of the personal initialization files -.IR ~/.bash_profile , -.IR ~/.bash_login , +.FN \*~/.bash_profile , +.FN \*~/.bash_login , or -.IR ~/.profile . +.FN \*~/.profile . By default, .B bash reads these files when it is invoked as a login shell (see @@ -219,19 +258,17 @@ below). .TP .B \-\-norc Do not read and execute the personal initialization file -.I ~/.bashrc +.FN \*~/.bashrc if the shell is interactive. This option is on by default if the shell is invoked as .BR sh . .TP .B \-\-posix -Change the behavior of \fBbash\fP where the default operation differs -from the POSIX standard to match the standard (\fIposix mode\fP). -See -.SM -.B "SEE ALSO" -below for a reference to a document that details how posix mode affects -bash's behavior. +Enable posix mode; +change the behavior of \fBbash\fP +where the default operation differs from the +.SM POSIX +standard to match the standard. .TP .B \-\-restricted The shell becomes restricted (see @@ -246,15 +283,14 @@ Equivalent to \fB\-v\fP. Show version information for this instance of .B bash on the standard output and exit successfully. -.PD .SH ARGUMENTS If arguments remain after option processing, and neither the .B \-c nor the .B \-s -option has been supplied, the first argument is assumed to -be the name of a file containing shell commands. -If +option has been supplied, the first argument is treated as +the name of a file containing shell commands (a \fIshell script\fP). +When .B bash is invoked in this fashion, .B $0 @@ -265,8 +301,9 @@ reads and executes commands from this file, then exits. \fBBash\fP's exit status is the exit status of the last command executed in the script. If no commands are executed, the exit status is 0. -An attempt is first made to open the file in the current directory, and, -if no file is found, then the shell searches the directories in +.B Bash +first attempts to open the file in the current directory, +and, if no file is found, searches the directories in .SM .B PATH for the script. @@ -277,27 +314,27 @@ or one started with the .B \-\-login option. .PP -An \fIinteractive\fP shell is one started without non-option arguments +An \fIinteractive shell\fP is one started without non-option arguments (unless \fB\-s\fP is specified) and without the .B \-c option, -whose standard input and error are +and whose standard input and standard error are both connected to terminals (as determined by .IR isatty (3)), or one started with the .B \-i option. +.B Bash +sets .SM .B PS1 -is set and +and .B $\- includes .B i -if -.B bash -is interactive, -allowing a shell script or a startup file to test this state. +if the shell is interactive, +so a shell script or a startup file can test this state. .PP The following paragraphs describe how .B bash @@ -316,10 +353,15 @@ When .B bash is invoked as an interactive login shell, or as a non-interactive shell with the \fB\-\-login\fP option, it first reads and -executes commands from the file \fI/etc/profile\fP, if that -file exists. -After reading that file, it looks for \fI~/.bash_profile\fP, -\fI~/.bash_login\fP, and \fI~/.profile\fP, in that order, and reads +executes commands from the file +.FN /etc/profile , +if that file exists. +After reading that file, it looks for +.FN \*~/.bash_profile , +.FN \*~/.bash_login , +and +.FN \*~/.profile , +in that order, and reads and executes commands from the first one that exists and is readable. The .B \-\-noprofile @@ -328,18 +370,22 @@ option may be used when the shell is started to inhibit this behavior. When an interactive login shell exits, or a non-interactive login shell executes the \fBexit\fP builtin command, .B bash -reads and executes commands from the file \fI~/.bash_logout\fP, if it -exists. +reads and executes commands from the file +.FN \*~/.bash_logout , +if it exists. .PP When an interactive shell that is not a login shell is started, .B bash -reads and executes commands from \fI~/.bashrc\fP, if that file exists. -This may be inhibited by using the +reads and executes commands from +.FN \*~/.bashrc , +if that file exists. +The .B \-\-norc -option. -The \fB\-\-rcfile\fP \fIfile\fP option will force +option inhibits this behavior. +The \fB\-\-rcfile\fP \fIfile\fP option causes .B bash -to read and execute commands from \fIfile\fP instead of \fI~/.bashrc\fP. +to use \fIfile\fP instead of +.FN \*~/.bashrc . .PP When .B bash @@ -351,16 +397,17 @@ in the environment, expands its value if it appears there, and uses the expanded value as the name of a file to read and execute. .B Bash behaves as if the following command were executed: -.sp .5 +.PP .RS -.if t \f(CWif [ \-n "$BASH_ENV" ]; then . "$BASH_ENV"; fi\fP -.if n if [ \-n "$BASH_ENV" ]; then . "$BASH_ENV"; fi +.EX +if [ \-n \*"$BASH_ENV\*" ]; then . \*"$BASH_ENV\*"; fi +.EE .RE -.sp .5 -but the value of the +.PP +but does not use the value of the .SM .B PATH -variable is not used to search for the filename. +variable to search for the filename. .PP If .B bash @@ -369,17 +416,19 @@ is invoked with the name it tries to mimic the startup behavior of historical versions of .B sh as closely as possible, -while conforming to the POSIX standard as well. +while conforming to the +.SM POSIX +standard as well. When invoked as an interactive login shell, or a non-interactive -shell with the \fB\-\-login\fP option, it first attempts to -read and execute commands from -.I /etc/profile +shell with the \fB\-\-login\fP option, it first attempts to read +and execute commands from +.FN /etc/profile and -.IR ~/.profile , +.FN \*~/.profile , in that order. The .B \-\-noprofile -option may be used to inhibit this behavior. +option inhibits this behavior. When invoked as an interactive shell with the name .BR sh , .B bash @@ -397,43 +446,46 @@ option has no effect. A non-interactive shell invoked with the name .B sh does not attempt to read any other startup files. +.PP When invoked as .BR sh , .B bash -enters -.I posix -mode after the startup files are read. +enters posix mode after reading the startup files. .PP When .B bash -is started in -.I posix -mode, as with the +is started in posix mode, as with the .B \-\-posix -command line option, it follows the POSIX standard for startup files. +command line option, it follows the +.SM POSIX +standard for startup files. In this mode, interactive shells expand the .SM .B ENV -variable and commands are read and executed from the file +variable and read and execute commands from the file whose name is the expanded value. No other startup files are read. .PP .B Bash attempts to determine when it is being run with its standard input connected to a network connection, as when executed by -the historical remote shell daemon, usually \fIrshd\fP, +the historical and rarely-seen remote shell daemon, usually \fIrshd\fP, or the secure shell daemon \fIsshd\fP. If .B bash determines it is being run non-interactively in this fashion, -it reads and executes commands from \fI~/.bashrc\fP, +it reads and executes commands from +.FN \*~/.bashrc , if that file exists and is readable. -It will not do this if invoked as \fBsh\fP. +.B Bash +does not read this file if invoked as \fBsh\fP. The .B \-\-norc -option may be used to inhibit this behavior, and the +option inhibits this behavior, and the .B \-\-rcfile -option may be used to force another file to be read, but neither +option makes \fBbash\fP use a different file instead of +.FN \*~/.bashrc , +but neither \fIrshd\fP nor \fIsshd\fP generally invoke the shell with those options or allow them to be specified. .PP @@ -461,6 +513,10 @@ document. .B blank A space or tab. .TP +.B whitespace +A character belonging to the \fBspace\fP character class in the +current locale, or for which \fIisspace\fP(3) returns true. +.TP .B word A sequence of characters considered as a single unit by the shell. Also known as a @@ -475,7 +531,8 @@ referred to as an .BR identifier . .TP .B metacharacter -A character that, when unquoted, separates words. One of the following: +A character that, when unquoted, separates words. +One of the following: .br .RS .PP @@ -483,9 +540,9 @@ A character that, when unquoted, separates words. One of the following: .if n \fB| & ; ( ) < > space tab newline\fP .RE .TP -.B control operator -A \fItoken\fP that performs a control function. It is one of the following -symbols: +.B "control operator" +A \fItoken\fP that performs a control function. +It is one of the following symbols: .RS .PP .if t \fB|| & && ; ;; ;& ;;& ( ) | |& \fP @@ -497,7 +554,7 @@ symbols: The following words are recognized as reserved when unquoted and either the first word of a command (see .SM -.B SHELL GRAMMAR +.B "SHELL GRAMMAR" below), the third word of a .B case or @@ -509,7 +566,8 @@ command (only \fBin\fP and \fBdo\fP are valid): .if t .RS .PP .B -.if n ! case coproc do done elif else esac fi for function if in select then until while { } time [[ ]] +.if n ! case coproc do done elif else esac fi for function if in select \ +then until while { } time [[ ]] .if t ! case coproc do done elif else esac fi for function if in select then until while { } time [[ ]] .if t .RE .SH "SHELL GRAMMAR" @@ -517,7 +575,8 @@ This section describes the syntax of the various forms of shell commands. .SS Simple Commands A \fIsimple command\fP is a sequence of optional variable assignments followed by \fBblank\fP-separated words and redirections, and -terminated by a \fIcontrol operator\fP. The first word +terminated by a \fIcontrol operator\fP. +The first word specifies the command to be executed, and is passed as argument zero. The remaining words are passed as arguments to the invoked command. .PP @@ -532,7 +591,7 @@ or \fB|&\fP. The format for a pipeline is: .RS .PP -[\fBtime\fP [\fB\-p\fP]] [ ! ] \fIcommand1\fP [ [\fB|\fP\(bv\fB|&\fP] \fIcommand2\fP ... ] +[\fBtime\fP [\fB\-p\fP]] [ ! ] \fIcommand1\fP [ [\fB|\fP\(bv\fB|&\fP] \fIcommand2\fP .\|.\|.\& ] .RE .PP The standard output of @@ -544,7 +603,8 @@ This connection is performed before any redirections specified by the .SM .B REDIRECTION below). -If \fB|&\fP is used, \fIcommand1\fP's standard error, in addition to its +If \fB|&\fP is the pipeline operator, +\fIcommand1\fP's standard error, in addition to its standard output, is connected to \fIcommand2\fP's standard input through the pipe; it is shorthand for \fB2>&1 |\fP. @@ -560,36 +620,39 @@ If the reserved word .B ! precedes a pipeline, the exit status of that pipeline is the logical negation of the exit status as described above. -The shell waits for all commands in the pipeline to +If a pipeline is executed synchronously, +the shell waits for all commands in the pipeline to terminate before returning a value. .PP If the .B time -reserved word precedes a pipeline, the elapsed as well as user and -system time consumed by its execution are reported when the pipeline -terminates. -The \fB\-p\fP option changes the output format to that specified by POSIX. -When the shell is in \fIposix mode\fP, it does not recognize -\fBtime\fP as a reserved word if the next token begins with a `-'. -The +reserved word precedes a pipeline, the shell reports the +elapsed as well as user and system time consumed by its execution +when the pipeline terminates. +The \fB\-p\fP option changes the output format to that specified by +.SM POSIX\c +\&. +When the shell is in posix mode, it does not recognize +\fBtime\fP as a reserved word if the next token begins with a +.Q \- . +The value of the .SM .B TIMEFORMAT -variable may be set to a format string that specifies how the timing +variable is a format string that specifies how the timing information should be displayed; see the description of .SM .B TIMEFORMAT -under -.B "Shell Variables" -below. +below under +.BR "Shell Variables" . .PP -When the shell is in \fIposix mode\fP, \fBtime\fP -may be followed by a newline. In this case, the shell displays the +When the shell is in posix mode, \fBtime\fP +may appear by itself as the only word in a simple command. +In this case, the shell displays the total user and system time consumed by the shell and its children. The .SM .B TIMEFORMAT -variable may be used to specify the format of -the time information. +variable specifies the format of the time information. .PP Each command in a multi-command pipeline, where pipes are created, @@ -597,12 +660,12 @@ is executed in a \fIsubshell\fP, which is a separate process. See .SM -\fBCOMMAND EXECUTION ENVIRONMENT\fP +.B "COMMAND EXECUTION ENVIRONMENT" for a description of subshells and a subshell environment. If the \fBlastpipe\fP option is enabled using the \fBshopt\fP builtin (see the description of \fBshopt\fP below), -the last element of a pipeline may be run by the shell process -when job control is not active. +and job control is not active, +the last element of a pipeline may be run by the shell process. .SS Lists A \fIlist\fP is a sequence of one or more pipelines separated by one of the operators @@ -640,8 +703,8 @@ These are referred to as \fIasynchronous\fP commands. Commands separated by a .B ; are executed sequentially; the shell waits for each -command to terminate in turn. The return status is the -exit status of the last command executed. +command to terminate in turn. +The return status is the exit status of the last command executed. .PP AND and OR lists are sequences of one or more pipelines separated by the \fB&&\fP and \fB||\fP control operators, respectively. @@ -679,28 +742,28 @@ newline in place of a semicolon. (\fIlist\fP) \fIlist\fP is executed in a subshell (see .SM -\fBCOMMAND EXECUTION ENVIRONMENT\fP +.B "COMMAND EXECUTION ENVIRONMENT" below for a description of a subshell environment). Variable assignments and builtin commands that affect the shell's environment do not remain in effect -after the command completes. The return status is the exit status of -\fIlist\fP. +after the command completes. +The return status is the exit status of \fIlist\fP. .TP { \fIlist\fP; } -\fIlist\fP is simply executed in the current shell environment. +\fIlist\fP is executed in the current shell environment. \fIlist\fP must be terminated with a newline or semicolon. This is known as a \fIgroup command\fP. -The return status is the exit status of -\fIlist\fP. +The return status is the exit status of \fIlist\fP. +.IP Note that unlike the metacharacters \fB(\fP and \fB)\fP, \fB{\fP and \fB}\fP are \fIreserved words\fP and must occur where a reserved -word is permitted to be recognized. Since they do not cause a word -break, they must be separated from \fIlist\fP by whitespace or another -shell metacharacter. +word is permitted to be recognized. +Since they do not cause a word break, they must be separated from +\fIlist\fP by whitespace or another shell metacharacter. .TP ((\fIexpression\fP)) -The \fIexpression\fP is evaluated according to the rules described -below under +The arithmetic \fIexpression\fP is evaluated according to the rules +described below under .SM .BR "ARITHMETIC EVALUATION" . If the value of the expression is non-zero, the return status is 0; @@ -708,12 +771,16 @@ otherwise the return status is 1. The \fIexpression\fP undergoes the same expansions as if it were within double quotes, -but double quote characters in \fIexpression\fP are not treated specially -and are removed. +but unescaped double quote characters +in \fIexpression\fP are not treated +specially and are removed. +Since this can potentially result in empty strings, this command treats +those as expressions that evaluate to 0. .TP \fB[[\fP \fIexpression\fP \fB]]\fP -Return a status of 0 or 1 depending on the evaluation of -the conditional expression \fIexpression\fP. +.PD +Evaluate the conditional expression \fIexpression\fP +and return a status of zero (true) or non-zero (false). Expressions are composed of the primaries described below under .SM .BR "CONDITIONAL EXPRESSIONS" . @@ -721,16 +788,13 @@ The words between the \fB[[\fP and \fB]]\fP do not undergo word splitting and pathname expansion. The shell performs tilde expansion, parameter and variable expansion, arithmetic expansion, command substitution, process -substitution, and quote removal on those words -(the expansions that would occur if the words were enclosed in double quotes). +substitution, and quote removal on those words. Conditional operators such as \fB\-f\fP must be unquoted to be recognized as primaries. -.if t .sp 0.5 -.if n .sp 1 +.IP When used with \fB[[\fP, the \fB<\fP and \fB>\fP operators sort lexicographically using the current locale. -.if t .sp 0.5 -.if n .sp 1 +.IP When the \fB==\fP and \fB!=\fP operators are used, the string to the right of the operator is considered a pattern and matched according to the rules described below under \fBPattern Matching\fP, @@ -742,16 +806,21 @@ shell option is enabled, the match is performed without regard to the case of alphabetic characters. The return value is 0 if the string matches (\fB==\fP) or does not match (\fB!=\fP) the pattern, and 1 otherwise. -Any part of the pattern may be quoted to force the quoted portion -to be matched as a string. -.if t .sp 0.5 -.if n .sp 1 -An additional binary operator, \fB=~\fP, is available, with the same +If any part of the pattern is quoted, the quoted portion is matched +as a string: every character in the quoted portion matches itself, +instead of having any special pattern matching meaning. +.IP +An additional binary operator, \fB=\*~\fP, is available, with the same precedence as \fB==\fP and \fB!=\fP. When it is used, the string to the right of the operator is considered -a POSIX extended regular expression and matched accordingly -(using the POSIX \fIregcomp\fP and \fIregexec\fP interfaces -usually described in \fIregex\fP(3)). +a +.SM POSIX +extended regular expression and matched accordingly +(using the +.SM POSIX +\fIregcomp\fP and \fIregexec\fP interfaces +usually described in +.IR regex (3)). The return value is 0 if the string matches the pattern, and 1 otherwise. If the regular expression is syntactically incorrect, the conditional @@ -760,19 +829,19 @@ If the .B nocasematch shell option is enabled, the match is performed without regard to the case of alphabetic characters. -If any part of the pattern is quoted, the quoted portion is matched literally. -This means every character in the quoted portion matches itself, -instead of having any special pattern matching meaning. +.IP +If any part of the pattern is quoted, the quoted portion is matched literally, +as above. If the pattern is stored in a shell variable, quoting the variable expansion forces the entire pattern to be matched literally. Treat bracket expressions in regular expressions carefully, since normal quoting and pattern characters lose their meanings between brackets. -.if t .sp 0.5 -.if n .sp 1 -The pattern will match if it matches any part of the string. -Anchor the pattern using the \fB^\fP and \fB$\fP regular expression +.IP +The match succeeds if the pattern matches any part of the string. +Anchor the pattern using the \fB\*^\fP and \fB$\fP regular expression operators to force it to match the entire string. +.IP The array variable .SM .B BASH_REMATCH @@ -786,22 +855,21 @@ Substrings matched by parenthesized subexpressions within the regular expression are saved in the remaining .SM .B BASH_REMATCH -indices. The element of +indices. +The element of .SM .B BASH_REMATCH with index \fIn\fP is the portion of the string matching the \fIn\fPth parenthesized subexpression. -Bash sets +\fBBash\fP sets .SM .B BASH_REMATCH in the global scope; declaring it as a local variable will lead to unexpected results. -.if t .sp 0.5 -.if n .sp 1 +.IP Expressions may be combined using the following operators, listed in decreasing order of precedence: -.if t .sp 0.5 -.if n .sp 1 +.IP .RS .PD 0 .TP @@ -835,10 +903,10 @@ operators do not evaluate \fIexpression2\fP if the value of the entire conditional expression. .RE .TP -\fBfor\fP \fIname\fP [ [ \fBin\fP [ \fIword ...\fP ] ] ; ] \fBdo\fP \fIlist\fP ; \fBdone\fP -The list of words following \fBin\fP is expanded, generating a list +\fBfor\fP \fIname\fP [ [ \fBin\fP \fIword .\|.\|.\&\fP ] ; ] \fBdo\fP \fIlist\fP ; \fBdone\fP +First, expand The list of words following \fBin\fP, generating a list of items. -The variable \fIname\fP is set to each element of this list +Then, the variable \fIname\fP is set to each element of this list in turn, and \fIlist\fP is executed each time. If the \fBin\fP \fIword\fP is omitted, the \fBfor\fP command executes \fIlist\fP once for each positional parameter that is set (see @@ -849,24 +917,33 @@ The return status is the exit status of the last command that executes. If the expansion of the items following \fBin\fP results in an empty list, no commands are executed, and the return status is 0. .TP -\fBfor\fP (( \fIexpr1\fP ; \fIexpr2\fP ; \fIexpr3\fP )) ; \fBdo\fP \fIlist\fP ; \fBdone\fP -First, the arithmetic expression \fIexpr1\fP is evaluated according +\fBfor\fP (( \fIexpr1\fP ; \fIexpr2\fP ; \fIexpr3\fP )) [;] \fBdo\fP \fIlist\fP ; \fBdone\fP +First, evaluate the arithmetic expression \fIexpr1\fP according to the rules described below under .SM .BR "ARITHMETIC EVALUATION" . -The arithmetic expression \fIexpr2\fP is then evaluated repeatedly +Then, repeatedly evaluate the arithmetic expression \fIexpr2\fP until it evaluates to zero. -Each time \fIexpr2\fP evaluates to a non-zero value, \fIlist\fP is -executed and the arithmetic expression \fIexpr3\fP is evaluated. +Each time \fIexpr2\fP evaluates to a non-zero value, +execute \fIlist\fP +and evaluate the arithmetic expression \fIexpr3\fP. If any expression is omitted, it behaves as if it evaluates to 1. The return value is the exit status of the last command in \fIlist\fP -that is executed, or false if any of the expressions is invalid. +that is executed, or non-zero if any of the expressions is invalid. +.IP +Use the \fBbreak\fP and \fPcontinue\fP builtins +(see +.SM +.B "SHELL BUILTIN COMMANDS" +below) +to control loop execution. .TP \fBselect\fP \fIname\fP [ \fBin\fP \fIword\fP ] ; \fBdo\fP \fIlist\fP ; \fBdone\fP -The list of words following \fBin\fP is expanded, generating a list -of items, and the set of expanded words is printed on the standard -error, each preceded by a number. If the \fBin\fP -\fIword\fP is omitted, the positional parameters are printed (see +First, expand the list of words following \fBin\fP, +generating a list of items, and print the set of expanded words +the standard error, each preceded by a number. +If the \fBin\fP +\fIword\fP is omitted, print the positional parameters (see .SM .B PARAMETERS below). @@ -876,14 +953,15 @@ then displays the .B PS3 prompt and reads a line from the standard input. If the line consists of a number corresponding to one of -the displayed words, then the value of +the displayed words, then \fBselect\fP sets the value of .I name -is set to that word. -If the line is empty, the words and prompt are displayed again. -If EOF is read, the \fBselect\fP command completes and returns 1. -Any other value read causes +to that word. +If the line is empty, \fBselect\fP displays the words and prompt again. +If EOF is read, \fBselect\fP completes and returns 1. +Any other value sets .I name -to be set to null. The line read is saved in the variable +to null. +The line read is saved in the variable .SM .BR REPLY . The @@ -898,12 +976,17 @@ is the exit status of the last command executed in or zero if no commands were executed. .TP \fBcase\fP \fIword\fP \fBin\fP [ [(] \fIpattern\fP [ \fB|\fP \fIpattern\fP ] \ -... ) \fIlist\fP ;; ] ... \fBesac\fP +.\|.\|.\& ) \fIlist\fP ;; ] .\|.\|.\& \ +\fBesac\fP A \fBcase\fP command first expands \fIword\fP, and tries to match -it against each \fIpattern\fP in turn, using the matching rules +it against each \fIpattern\fP in turn, +proceeding from first to last, +using the matching rules described under -.B Pattern Matching +.B "Pattern Matching" below. +A pattern list is a set of one or more patterns separated by \|, +and the ) operator terminates the pattern list. The \fIword\fP is expanded using tilde expansion, parameter and variable expansion, arithmetic expansion, command substitution, process substitution and quote removal. @@ -914,31 +997,36 @@ If the .B nocasematch shell option is enabled, the match is performed without regard to the case of alphabetic characters. -When a match is found, the corresponding \fIlist\fP is executed. -If the \fB;;\fP operator is used, no subsequent matches are attempted after -the first pattern match. +A \fIclause\fP is a pattern list and an associated \fIlist\fP. +.IP +When a match is found, \fBcase\fP executes the corresponding \fIlist\fP. +If the \fB;;\fP operator terminates the case clause, the \fBcase\fP +command completes after the first match. Using \fB;&\fP in place of \fB;;\fP causes execution to continue with -the \fIlist\fP associated with the next set of patterns. +the \fIlist\fP associated with the next pattern list. Using \fB;;&\fP in place of \fB;;\fP causes the shell to test the next pattern list in the statement, if any, and execute any associated \fIlist\fP -on a successful match, +if the match succeeds, continuing the case statement execution as if the pattern list had not matched. -The exit status is zero if no -pattern matches. Otherwise, it is the exit status of the -last command executed in \fIlist\fP. +The exit status is zero if no pattern matches. +.IP +Otherwise, it is the exit status of the +last command executed in the last \fIlist\fP executed. .TP \fBif\fP \fIlist\fP; \fBthen\fP \fIlist\fP; \ -[ \fBelif\fP \fIlist\fP; \fBthen\fP \fIlist\fP; ] ... \ +[ \fBelif\fP \fIlist\fP; \fBthen\fP \fIlist\fP; ] .\|.\|.\& \ [ \fBelse\fP \fIlist\fP; ] \fBfi\fP The .B if .I list -is executed. If its exit status is zero, the -\fBthen\fP \fIlist\fP is executed. Otherwise, each \fBelif\fP -\fIlist\fP is executed in turn, and if its exit status is zero, -the corresponding \fBthen\fP \fIlist\fP is executed and the -command completes. Otherwise, the \fBelse\fP \fIlist\fP is -executed, if present. The exit status is the exit status of the +is executed. +If its exit status is zero, the +\fBthen\fP \fIlist\fP is executed. +Otherwise, each \fBelif\fP \fIlist\fP is executed in turn, +and if its exit status is zero, the corresponding \fBthen\fP \fIlist\fP +is executed and the command completes. +Otherwise, the \fBelse\fP \fIlist\fP is executed, if present. +The exit status is the exit status of the last command executed, or zero if no condition tested true. .TP \fBwhile\fP \fIlist-1\fP; \fBdo\fP \fIlist-2\fP; \fBdone\fP @@ -948,7 +1036,8 @@ last command executed, or zero if no condition tested true. .PD The \fBwhile\fP command continuously executes the list \fIlist-2\fP as long as the last command in the list \fIlist-1\fP returns -an exit status of zero. The \fBuntil\fP command is identical +an exit status of zero. +The \fBuntil\fP command is identical to the \fBwhile\fP command, except that the test is negated: .I list-2 is executed as long as the last command in @@ -983,7 +1072,7 @@ The recommended form to use for a coprocess is \fBcoproc\fP \fINAME\fP { \fIcommand\fP [\fIredirections\fP]; } .RE .PP -This form is recommended because simple commands result in the coprocess +This form is preferred because simple commands result in the coprocess always being named \fBCOPROC\fP, and it is simpler to use and more complete than the other compound commands. .PP @@ -1019,7 +1108,7 @@ the file descriptors are not available in subshells. The process ID of the shell spawned to execute the coprocess is available as the value of the variable \fINAME\fP_PID. The \fBwait\fP -builtin command may be used to wait for the coprocess to terminate. +builtin may be used to wait for the coprocess to terminate. .PP Since the coprocess is created as an asynchronous command, the \fBcoproc\fP command always returns success. @@ -1046,16 +1135,19 @@ If the \fBfunction\fP reserved word is used, but the parentheses are not supplied, the braces are recommended. \fIcompound\-command\fP is executed whenever \fIfname\fP is specified as the name of a simple command. -When in \fIposix mode\fP, \fIfname\fP must be a valid shell \fIname\fP +When in posix mode, \fIfname\fP must be a valid shell \fIname\fP and may not be the name of one of the -POSIX \fIspecial builtins\fP. +.SM POSIX +\fIspecial builtins\fP. In default mode, a function name can be any unquoted shell word that does not contain \fB$\fP. +.PP Any redirections (see .SM .B REDIRECTION below) specified when a function is defined are performed when the function is executed. +.PP The exit status of a function definition is zero unless a syntax error occurs or a readonly function with the same name already exists. When executed, the exit status of a function is the exit status of the @@ -1073,15 +1165,21 @@ builtin is enabled (see .B "SHELL BUILTIN COMMANDS" below), a word beginning with .B # -causes that word and all remaining characters on that line to -be ignored. An interactive shell without the +introduces a comment. +A word begins at the beginning of a line, after unquoted whitespace, or +after an operator. +The comment causes that word and all remaining characters on that line to +be ignored. +An interactive shell without the .B interactive_comments -option enabled does not allow comments. The +option enabled does not allow comments. +The .B interactive_comments -option is on by default in interactive shells. +option is enabled by default in interactive shells. .SH QUOTING \fIQuoting\fP is used to remove the special meaning of certain -characters or words to the shell. Quoting can be used to +characters or words to the shell. +Quoting can be used to disable special treatment for special characters, to prevent reserved words from being recognized as such, and to prevent parameter expansion. @@ -1095,25 +1193,28 @@ represent itself. When the command history expansion facilities are being used (see .SM -.B HISTORY EXPANSION +.B "HISTORY EXPANSION" below), the \fIhistory expansion\fP character, usually \fB!\fP, must be quoted to prevent history expansion. .PP -There are three quoting mechanisms: the +There are four quoting mechanisms: the .IR "escape character" , -single quotes, and double quotes. +single quotes, double quotes, +and dollar-single quotes. .PP A non-quoted backslash (\fB\e\fP) is the .IR "escape character" . It preserves the literal value of the next character that follows, -with the exception of . If a \fB\e\fP pair -appears, and the backslash is not itself quoted, the \fB\e\fP -is treated as a line continuation (that is, it is removed from the -input stream and effectively ignored). +removing any special meaning it has, +with the exception of . +If a \fB\e\fP pair appears, and the backslash is not itself quoted, +the \fB\e\fP is treated as a line continuation (that is, it is +removed from the input stream and effectively ignored). .PP Enclosing characters in single quotes preserves the literal value -of each character within the quotes. A single quote may not occur +of each character within the quotes. +A single quote may not occur between single quotes, even when preceded by a backslash. .PP Enclosing characters in double quotes preserves the literal value @@ -1123,21 +1224,25 @@ of all characters within the quotes, with the exception of .BR \e , and, when history expansion is enabled, .BR ! . -When the shell is in \fIposix mode\fP, the \fB!\fP has no special meaning +When the shell is in posix mode, +the \fB!\fP has no special meaning within double quotes, even when history expansion is enabled. The characters .B $ and .B \` -retain their special meaning within double quotes. The backslash -retains its special meaning only when followed by one of the following -characters: +retain their special meaning within double quotes. +The backslash retains its special meaning only when followed by one of +the following characters: .BR $ , .BR \` , -\^\fB"\fP\^, +\^\fB\*"\fP\^, .BR \e , or .BR . +Backslashes preceding characters without a +special meaning are left unmodified. +.PP A double quote may be quoted within double quotes by preceding it with a backslash. If enabled, history expansion will be performed unless an @@ -1151,13 +1256,13 @@ The special parameters .B * and .B @ -have special meaning when in double -quotes (see +have special meaning when in double quotes +(see .SM .B PARAMETERS below). .PP -Character sequences of the form \fB$\fP\(aq\fIstring\fP\(aq are treated +Character sequences of the form \fB$\fP\*'\fIstring\fP\*' are treated as a special variant of single quotes. The sequence expands to \fIstring\fP, with backslash-escaped characters in \fIstring\fP replaced as specified by the ANSI C standard. @@ -1194,48 +1299,48 @@ vertical tab .B \e\e backslash .TP -.B \e\(aq +.B \e\*' single quote .TP -.B \e\(dq +.B \e\*" double quote .TP .B \e? question mark .TP .B \e\fInnn\fP -the eight-bit character whose value is the octal value \fInnn\fP -(one to three octal digits) +The eight-bit character whose value is the octal value \fInnn\fP +(one to three octal digits). .TP .B \ex\fIHH\fP -the eight-bit character whose value is the hexadecimal value \fIHH\fP -(one or two hex digits) +The eight-bit character whose value is the hexadecimal value \fIHH\fP +(one or two hex digits). .TP .B \eu\fIHHHH\fP -the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value -\fIHHHH\fP (one to four hex digits) +The Unicode (ISO/IEC 10646) character whose value is the hexadecimal value +\fIHHHH\fP (one to four hex digits). .TP .B \eU\fIHHHHHHHH\fP -the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value -\fIHHHHHHHH\fP (one to eight hex digits) +The Unicode (ISO/IEC 10646) character whose value is the hexadecimal value +\fIHHHHHHHH\fP (one to eight hex digits). .TP .B \ec\fIx\fP -a control-\fIx\fP character +A control-\fIx\fP character. .PD .RE .LP The expanded result is single-quoted, as if the dollar sign had not been present. -.PP -A double-quoted string preceded by a dollar sign (\fB$\fP\(dq\fIstring\fP\(dq) -will cause the string to be translated according to the current locale. +.SS "Translating Strings" +A double-quoted string preceded by a dollar sign (\fB$\fP\*"\fIstring\fP\*") +causes the string to be translated according to the current locale. The \fIgettext\fP infrastructure performs the lookup and translation, using the \fBLC_MESSAGES\fP, \fBTEXTDOMAINDIR\fP, and \fBTEXTDOMAIN\fP shell variables. If the current locale is \fBC\fP or \fBPOSIX\fP, if there are no translations available, -or if the string is not translated, -the dollar sign is ignored. +or if the string is not translated, the dollar sign is ignored, +and the string is treated as double-quoted as described above. This is a form of double quoting, so the string remains double-quoted by default, whether or not it is translated and replaced. If the \fBnoexpand_translation\fP option is enabled @@ -1245,7 +1350,7 @@ See the description of .B shopt below under .SM -.BR SHELL BUILTIN COMMANDS . +.BR "SHELL BUILTIN COMMANDS" . .SH PARAMETERS A .I parameter @@ -1266,19 +1371,20 @@ builtin command (see below in .SM .BR "SHELL BUILTIN COMMANDS" ). +The \fBexport\fP and \fBreadonly\fP builtins assign specific attributes. .PP -A parameter is set if it has been assigned a value. The null string is -a valid value. Once a variable is set, it may be unset only by using -the +A parameter is set if it has been assigned a value. +The null string is a valid value. +Once a variable is set, it may be unset only by using the .B unset builtin command (see .SM -.B SHELL BUILTIN COMMANDS +.B "SHELL BUILTIN COMMANDS" below). .PP A .I variable -may be assigned to by a statement of the form +is assigned to using a statement of the form .RS .PP \fIname\fP=[\fIvalue\fP] @@ -1286,19 +1392,22 @@ may be assigned to by a statement of the form .PP If .I value -is not given, the variable is assigned the null string. All +is not given, the variable is assigned the null string. +All .I values undergo tilde expansion, parameter and variable expansion, command substitution, arithmetic expansion, and quote removal (see .SM .B EXPANSION -below). If the variable has its +below). +If the variable has its .B integer attribute set, then .I value -is evaluated as an arithmetic expression even if the $((...)) expansion is -not used (see +is evaluated as an arithmetic expression even if the +.BR $(( .\|.\|.\& )) +expansion is not used (see .B "Arithmetic Expansion" below). Word splitting and pathname expansion are not performed. @@ -1306,30 +1415,44 @@ Assignment statements may also appear as arguments to the .BR alias , .BR declare , .BR typeset , -.BR export , +.BR \%export , .BR readonly , and .B local builtin commands (\fIdeclaration\fP commands). -When in \fIposix mode\fP, these builtins may appear in a command after +When in posix mode, these builtins may appear in a command after one or more instances of the \fBcommand\fP builtin and retain these assignment statement properties. .PP In the context where an assignment statement is assigning a value -to a shell variable or array index, the += operator can be used to -append to or add to the variable's previous value. -This includes arguments to builtin commands such as \fBdeclare\fP that -accept assignment statements (\fIdeclaration\fP commands). -When += is applied to a variable for which the \fBinteger\fP attribute has been -set, \fIvalue\fP is evaluated as an arithmetic expression and added to the -variable's current value, which is also evaluated. -When += is applied to an array variable using compound assignment (see +to a shell variable or array index, the +.Q += +operator appends to or adds to +the variable's previous value. +This includes arguments to \fIdeclaration\fP commands such as +.B \%declare +that accept assignment statements. +When +.Q += +is applied to a variable for which the +.B \%integer +attribute has been set, +the variable's current value and \fIvalue\fP are each evaluated as +arithmetic expressions, +and the sum of the results is assigned as the variable's value. +The current value is usually an integer constant, but may be an expression. +When +.Q += +is applied to an array variable using compound assignment +(see .B Arrays -below), the -variable's value is not unset (as it is when using =), and new values are -appended to the array beginning at one greater than the array's maximum index -(for indexed arrays) or added as additional key\-value pairs in an -associative array. +below), +the variable's value is not unset +(as it is when using +.Q = ), +and new values are appended to the array +beginning at one greater than the array's maximum index (for indexed arrays) +or added as additional key\-value pairs in an associative array. When applied to a string-valued variable, \fIvalue\fP is expanded and appended to the variable's value. .PP @@ -1347,37 +1470,48 @@ A nameref is commonly used within shell functions to refer to a variable whose name is passed as an argument to the function. For instance, if a variable name is passed to a shell function as its first argument, running -.sp .5 +.PP .RS -.if t \f(CWdeclare -n ref=$1\fP -.if n declare -n ref=$1 +.EX +declare \-n ref=$1 +.EE .RE -.sp .5 -inside the function creates a nameref variable \fBref\fP whose value is -the variable name passed as the first argument. +.PP +inside the function creates a local nameref variable \fBref\fP whose value +is the variable name passed as the first argument. References and assignments to \fBref\fP, and changes to its attributes, are treated as references, assignments, and attribute modifications to the variable whose name was passed as \fB$1\fP. If the control variable in a \fBfor\fP loop has the nameref attribute, the list of words can be a list of shell variables, and a name reference -will be established for each word in the list, in turn, when the loop is +is established for each word in the list, in turn, when the loop is executed. Array variables cannot be given the \fBnameref\fP attribute. However, nameref variables can reference array variables and subscripted array variables. Namerefs can be unset using the \fB\-n\fP option to the \fBunset\fP builtin. Otherwise, if \fBunset\fP is executed with the name of a nameref variable -as an argument, the variable referenced by the nameref variable will be unset. +as an argument, the variable referenced by the nameref variable is unset. +.PP +When the shell starts, it reads its environment and creates a shell +variable from each environment variable that has a valid name, +as described below +(see +.SM +.BR ENVIRONMENT ). .SS Positional Parameters A .I positional parameter is a parameter denoted by one or more -digits, other than the single digit 0. Positional parameters are +digits, other than the single digit 0. +Positional parameters are assigned from the shell's arguments when it is invoked, and may be reassigned using the .B set -builtin command. Positional parameters may not be assigned to -with assignment statements. The positional parameters are +builtin command. +Positional parameters may not be assigned to +with assignment statements. +The positional parameters are temporarily replaced when a shell function is executed (see .SM .B FUNCTIONS @@ -1388,28 +1522,39 @@ digit is expanded, it must be enclosed in braces (see .SM .B EXPANSION below). +Without braces, a digit following $ can only refer to +one of the first nine positional parameters (\fB$1\-$9\fP) or the +special parameter \fB$0\fP (see the next section). .SS Special Parameters -The shell treats several parameters specially. These parameters may -only be referenced; assignment to them is not allowed. -.PD 0 +The shell treats several parameters specially. +These parameters may only be referenced; assignment to them is +not allowed. +Special parameters are denoted by one of the following characters. .TP +.PD 0 .B * -Expands to the positional parameters, starting from one. +(\fB$*\fP) Expands to the positional parameters, starting from one. When the expansion is not within double quotes, each positional parameter expands to a separate word. -In contexts where it is performed, those words +In contexts where word expansions are performed, those words are subject to further word splitting and pathname expansion. -When the expansion occurs within double quotes, it expands to a single word -with the value of each parameter separated by the first character of the +When the expansion occurs within double quotes, it expands to a +single word with the value of each parameter separated by the first +character of the .SM .B IFS -special variable. That is, "\fB$*\fP" is equivalent -to "\fB$1\fP\fIc\fP\fB$2\fP\fIc\fP\fB...\fP", where +variable. +That is, +.B \*"$*\*" +is equivalent to +.BR \*"$1\fIc\fP$2\fIc\fP.\|.\|.\*" , +where .I c is the first character of the value of the .SM .B IFS -variable. If +variable. +If .SM .B IFS is unset, the parameters are separated by spaces. @@ -1419,34 +1564,40 @@ If is null, the parameters are joined without intervening separators. .TP .B @ -Expands to the positional parameters, starting from one. +(\fB$@\fP) Expands to the positional parameters, starting from one. In contexts where word splitting is performed, this expands each positional parameter to a separate word; if not within double quotes, these words are subject to word splitting. In contexts where word splitting is not performed, +such as the value portion of an assignment statement, this expands to a single word with each positional parameter separated by a space. -When the -expansion occurs within double quotes, each parameter expands to a -separate word. That is, "\fB$@\fP" is equivalent to -"\fB$1\fP" "\fB$2\fP" ... +When the expansion occurs within double quotes, +and word splitting is performed, +each parameter expands to a separate word. +That is, +.B \&\*"$@\*" +is equivalent to +.B \&\*"\&$1\&\*"\ \*"$2\*"\ .\|.\|. If the double-quoted expansion occurs within a word, the expansion of -the first parameter is joined with the beginning part of the original -word, and the expansion of the last parameter is joined with the last -part of the original word. -When there are no positional parameters, "\fB$@\fP" and +the first parameter is joined with the expansion of the +beginning part of the original word, +and the expansion of the last parameter is joined with the +expansion of the last part of the original word. +When there are no positional parameters, +.B \&\*"$@\*" +and .B $@ expand to nothing (i.e., they are removed). .TP .B # -Expands to the number of positional parameters in decimal. +(\fB$#\fP) Expands to the number of positional parameters in decimal. .TP .B ? -Expands to the exit status of the most recently executed foreground -pipeline. +(\fB$?\fP) Expands to the exit status of the most recently executed command. .TP .B \- -Expands to the current option flags as specified upon invocation, +(\fB$\-\fP) Expands to the current option flags as specified upon invocation, by the .B set builtin command, or those set by the shell itself @@ -1455,12 +1606,12 @@ builtin command, or those set by the shell itself option). .TP .B $ -Expands to the process ID of the shell. In a subshell, it -expands to the process ID of the current shell, not the -subshell. +(\fB$$\fP) Expands to the process ID of the shell. +In a subshell, it expands to the process ID of the parent shell, +not the subshell. .TP .B ! -Expands to the process ID of the job most recently placed into the +(\fB$!\fP)Expands to the process ID of the job most recently placed into the background, whether executed as an asynchronous command or using the \fBbg\fP builtin (see .SM @@ -1468,37 +1619,37 @@ the \fBbg\fP builtin (see below). .TP .B 0 -Expands to the name of the shell or shell script. This is set at -shell initialization. If -.B bash -is invoked with a file of commands, +(\fB$0\fP) Expands to the name of the shell or shell script. +This is set at shell initialization. +If \fBbash\fP is invoked with a file of commands, .B $0 -is set to the name of that file. If -.B bash -is started with the +is set to the name of that file. +If \fBbash\fP is started with the .B \-c option, then .B $0 is set to the first argument after the string to be -executed, if one is present. Otherwise, it is set -to the filename used to invoke +executed, if one is present. +Otherwise, it is set to the filename used to invoke .BR bash , as given by argument zero. .PD -.SS Shell Variables -The following variables are set by the shell: +.SS "Shell Variables" +The shell sets following variables: .PP .PD 0 .TP .B _ -At shell startup, set to the pathname used to invoke the +(\fB$_\fP, an underscore) +This has a number of meanings depending on context. +At shell startup, \fB_\fP is set to the pathname used to invoke the shell or shell script being executed as passed in the environment or argument list. -Subsequently, expands to the last argument to the previous simple +Subsequently, it expands to the last argument to the previous simple command executed in the foreground, after expansion. -Also set to the full pathname used to invoke each command executed +It is also set to the full pathname used to invoke each command executed and placed in the environment exported to that command. -When checking mail, this parameter holds the name of the mail file +When checking mail, \fB$_\fP expands to the name of the mail file currently being checked. .TP .B BASH @@ -1514,7 +1665,8 @@ option to the builtin command (see .SM .B "SHELL BUILTIN COMMANDS" -below). The options appearing in +below). +The options appearing in .SM .B BASHOPTS are those reported as @@ -1522,8 +1674,10 @@ are those reported as by \fBshopt\fP. If this variable is in the environment when .B bash -starts up, each shell option in the list will be enabled before +starts up, the shell enables each option in the list before reading any startup files. +If this variable is exported, child shells will enable each option +in the list. This variable is read-only. .TP .B BASHPID @@ -1535,6 +1689,7 @@ Assignments to .B BASHPID have no effect. If +.SM .B BASHPID is unset, it loses its special properties, even if it is subsequently reset. @@ -1543,9 +1698,10 @@ subsequently reset. An associative array variable whose members correspond to the internal list of aliases as maintained by the \fBalias\fP builtin. Elements added to this array appear in the alias list; however, -unsetting array elements currently does not cause aliases to be removed +unsetting array elements currently does not remove aliases from the alias list. If +.SM .B BASH_ALIASES is unset, it loses its special properties, even if it is subsequently reset. @@ -1553,9 +1709,8 @@ subsequently reset. .B BASH_ARGC An array variable whose values are the number of parameters in each frame of the current \fBbash\fP execution call stack. -The number of -parameters to the current subroutine (shell function or script executed -with \fB.\fP or \fBsource\fP) is at the top of the stack. +The number of parameters to the current subroutine (shell function or +script executed with \fB.\fP or \fBsource\fP) is at the top of the stack. When a subroutine is executed, the number of parameters passed is pushed onto .SM .BR BASH_ARGC . @@ -1570,13 +1725,17 @@ builtin below). Setting \fBextdebug\fP after the shell has started to execute a script, or referencing this variable when \fBextdebug\fP is not set, may result in inconsistent values. +Assignments to +.SM +.B BASH_ARGC +have no effect, and it may not be unset. .TP .B BASH_ARGV An array variable containing all of the parameters in the current \fBbash\fP -execution call stack. The final parameter of the last subroutine call -is at the top of the stack; the first parameter of the initial call is -at the bottom. When a subroutine is executed, the parameters supplied -are pushed onto +execution call stack. +The final parameter of the last subroutine call is at the top of the stack; +the first parameter of the initial call is at the bottom. +When a subroutine is executed, the shell pushes the supplied parameters onto .SM .BR BASH_ARGV . The shell sets @@ -1591,16 +1750,22 @@ builtin below). Setting \fBextdebug\fP after the shell has started to execute a script, or referencing this variable when \fBextdebug\fP is not set, may result in inconsistent values. +Assignments to +.SM +.B BASH_ARGV +have no effect, and it may not be unset. .TP .B BASH_ARGV0 When referenced, this variable expands to the name of the shell or shell script (identical to .BR $0 ; see the description of special parameter 0 above). -Assignment to +Assigning a value to +.SM .B BASH_ARGV0 -causes the value assigned to also be assigned to \fB$0\fP. +sets \fB$0\fP to the same value. If +.SM .B BASH_ARGV0 is unset, it loses its special properties, even if it is subsequently reset. @@ -1608,19 +1773,21 @@ subsequently reset. .B BASH_CMDS An associative array variable whose members correspond to the internal hash table of commands as maintained by the \fBhash\fP builtin. -Elements added to this array appear in the hash table; however, -unsetting array elements currently does not cause command names to be removed +Adding elements to this array makes them appear in the hash table; however, +unsetting array elements currently does not remove command names from the hash table. If +.SM .B BASH_CMDS is unset, it loses its special properties, even if it is subsequently reset. .TP .B BASH_COMMAND -The command currently being executed or about to be executed, unless the -shell is executing a command as the result of a trap, +Expands to the command currently being executed or about to be executed, +unless the shell is executing a command as the result of a trap, in which case it is the command executing at the time of the trap. If +.SM .B BASH_COMMAND is unset, it loses its special properties, even if it is subsequently reset. @@ -1634,24 +1801,42 @@ where each corresponding member of .SM .B FUNCNAME was invoked. -\fB${BASH_LINENO[\fP\fI$i\fP\fB]}\fP is the line number in the source -file (\fB${BASH_SOURCE[\fP\fI$i+1\fP\fB]}\fP) where -\fB${FUNCNAME[\fP\fI$i\fP\fB]}\fP was called -(or \fB${BASH_LINENO[\fP\fI$i-1\fP\fB]}\fP if referenced within another +\fB${BASH_LINENO[\fP\fI$i\fP\fB]}\fP +is the line number in the source file +(\fB${BASH_SOURCE[\fP\fI$i+1\fP\fB]}\fP) +where +\fB${FUNCNAME[\fP\fI$i\fP\fB]}\fP +was called +(or \fB${BASH_LINENO[\fP\fI$i\-1\fP\fB]}\fP if referenced within another shell function). Use .SM .B LINENO to obtain the current line number. +Assignments to +.SM +.B BASH_LINENO +have no effect, and it may not be unset. .TP .B BASH_LOADABLES_PATH -A colon-separated list of directories in which the shell looks for -dynamically loadable builtins specified by the +A colon-separated list of directories in which the .B enable -command. +command +looks for +dynamically loadable builtins. +.TP +.B BASH_MONOSECONDS +Each time this variable is referenced, it expands to the value returned +by the system's monotonic clock, if one is available. +If there is no monotonic clock, this is equivalent to \fBEPOCHSECONDS\fP. +If +.SM +.B BASH_MONOSECONDS +is unset, it loses its special properties, even if it is +subsequently reset. .TP .B BASH_REMATCH -An array variable whose members are assigned by the \fB=~\fP binary +An array variable whose members are assigned by the \fB=\*~\fP binary operator to the \fB[[\fP conditional command. The element with index 0 is the portion of the string matching the entire regular expression. @@ -1668,22 +1853,35 @@ The shell function \fB${FUNCNAME[\fP\fI$i\fP\fB]}\fP is defined in the file \fB${BASH_SOURCE[\fP\fI$i\fP\fB]}\fP and called from \fB${BASH_SOURCE[\fP\fI$i+1\fP\fB]}\fP. +Assignments to +.SM +.B BASH_SOURCE +have no effect, and it may not be unset. .TP .B BASH_SUBSHELL Incremented by one within each subshell or subshell environment when the shell begins executing in that environment. The initial value is 0. If +.SM .B BASH_SUBSHELL is unset, it loses its special properties, even if it is subsequently reset. .TP +.B BASH_TRAPSIG +Set to the signal number corresponding to the trap action being executed +during its execution. +See the description of \fBtrap\fP under +.SM +.B "SHELL BUILTIN COMMANDS" +below for information about signal numbers and trap execution. +.TP .B BASH_VERSINFO A readonly array variable whose members hold version information for this instance of .BR bash . The values assigned to the array members are as follows: -.sp .5 +.PP .RS .TP 24 .B BASH_VERSINFO[\fR0\fP] @@ -1699,7 +1897,7 @@ The patch level. The build version. .TP .B BASH_VERSINFO[\fR4\fP] -The release status (e.g., \fIbeta1\fP). +The release status (e.g., \fIbeta\fP). .TP .B BASH_VERSINFO[\fR5\fP] The value of @@ -1709,7 +1907,8 @@ The value of .TP .B BASH_VERSION Expands to a string describing the version of this instance of -.BR bash . +.B bash +(e.g., 5.2.37(3)-release). .TP .B COMP_CWORD An index into \fB${COMP_WORDS}\fP of the word containing the current @@ -1721,6 +1920,10 @@ below). .B COMP_KEY The key (or final key of a key sequence) used to invoke the current completion function. +This variable is available only in shell functions and external +commands invoked by the +programmable completion facilities (see \fBProgrammable Completion\fP +below). .TP .B COMP_LINE The current command line. @@ -1740,7 +1943,7 @@ programmable completion facilities (see \fBProgrammable Completion\fP below). .TP .B COMP_TYPE -Set to an integer value corresponding to the type of completion attempted +Set to an integer value corresponding to the type of attempted completion that caused a completion function to be called: \fITAB\fP, for normal completion, \fI?\fP, for listing completions after successive tabs, @@ -1791,7 +1994,7 @@ directories already in the stack, but the and .B popd builtins must be used to add and remove directories. -Assignment to this variable will not change the current directory. +Assigning to this variable does not change the current directory. If .SM .B DIRSTACK @@ -1800,8 +2003,9 @@ subsequently reset. .TP .B EPOCHREALTIME Each time this parameter is referenced, it expands to the number of seconds -since the Unix Epoch (see \fItime\fP\fR(3)\fP) as a floating point value -with micro-second granularity. +since the Unix Epoch (see +.IR time (3)) +as a floating-point value with micro-second granularity. Assignments to .SM .B EPOCHREALTIME @@ -1814,7 +2018,8 @@ subsequently reset. .TP .B EPOCHSECONDS Each time this parameter is referenced, it expands to the number of seconds -since the Unix Epoch (see \fItime\fP\fR(3)\fP). +since the Unix Epoch (see +.IR time (3)). Assignments to .SM .B EPOCHSECONDS @@ -1830,13 +2035,13 @@ Expands to the effective user ID of the current user, initialized at shell startup. This variable is readonly. .TP .B FUNCNAME +.PD An array variable containing the names of all shell functions currently in the execution call stack. The element with index 0 is the name of any currently-executing shell function. The bottom-most element (the one with the highest index) is -.if t \f(CW"main"\fP. -.if n "main". +.Q main . This variable exists only when a shell function is executing. Assignments to .SM @@ -1847,16 +2052,32 @@ If .B FUNCNAME is unset, it loses its special properties, even if it is subsequently reset. -.if t .sp 0.5 -.if n .sp 1 -This variable can be used with \fBBASH_LINENO\fP and \fBBASH_SOURCE\fP. -Each element of \fBFUNCNAME\fP has corresponding elements in -\fBBASH_LINENO\fP and \fBBASH_SOURCE\fP to describe the call stack. -For instance, \fB${FUNCNAME[\fP\fI$i\fP\fB]}\fP was called from the file -\fB${BASH_SOURCE[\fP\fI$i+1\fP\fB]}\fP at line number +.IP +This variable can be used with +.SM +.B BASH_LINENO +and +.SM +.BR BASH_SOURCE . +Each element of +.SM +.B \%FUNCNAME +has corresponding elements in +.SM +.B BASH_LINENO +and +.SM +.B BASH_SOURCE +to describe the call stack. +For instance, +\fB\%${FUNCNAME[\fP\fI$i\fP\fB]}\fP +was called from the file +\fB${BASH_SOURCE[\fP\fI$i+1\fP\fB]}\fP +at line number \fB${BASH_LINENO[\fP\fI$i\fP\fB]}\fP. The \fBcaller\fP builtin displays the current call stack using this information. +.PD 0 .TP .B GROUPS An array variable containing the list of groups of which the current @@ -1877,7 +2098,7 @@ command. Assignments to .SM .B HISTCMD -are ignored. +have no effect. If .SM .B HISTCMD @@ -1897,9 +2118,9 @@ The default is system-dependent. .B LINENO Each time this parameter is referenced, the shell substitutes a decimal number representing the current sequential line number -(starting with 1) within a script or function. When not in a -script or function, the value substituted is not guaranteed to -be meaningful. +(starting with 1) within a script or function. +When not in a script or function, the value substituted is not +guaranteed to be meaningful. If .SM .B LINENO @@ -1927,7 +2148,7 @@ The value of the last option argument processed by the .B getopts builtin command (see .SM -.B SHELL BUILTIN COMMANDS +.B "SHELL BUILTIN COMMANDS" below). .TP .B OPTIND @@ -1935,7 +2156,7 @@ The index of the next argument to be processed by the .B getopts builtin command (see .SM -.B SHELL BUILTIN COMMANDS +.B "SHELL BUILTIN COMMANDS" below). .TP .B OSTYPE @@ -1948,12 +2169,31 @@ The default is system-dependent. .B PIPESTATUS An array variable (see .B Arrays -below) containing a list of exit status values from the processes -in the most-recently-executed foreground pipeline (which may -contain only a single command). +below) containing a list of exit status values from the commands +in the most-recently-executed foreground pipeline, which may +consist of only a simple command +(see +.SM +.B "SHELL GRAMMAR" +above). +\fBBash\fP sets +.SM +.B PIPESTATUS +after executing multi-element pipelines, +timed and negated pipelines, +simple commands, +subshells created with the ( operator, +the +.B [[ +and +.B (( +compound commands, and +after error conditions that result in the +shell aborting command execution. .TP .B PPID -The process ID of the shell's parent. This variable is readonly. +The process ID of the shell's parent. +This variable is readonly. .TP .B PWD The current working directory as set by the @@ -1963,11 +2203,12 @@ command. .B RANDOM Each time this parameter is referenced, it expands to a random integer between 0 and 32767. -Assigning -a value to +Assigning a value to .SM -.BR RANDOM +.B RANDOM initializes (seeds) the sequence of random numbers. +Seeding the random number generator with the same constant value +produces the same sequence of values. If .SM .B RANDOM @@ -1975,9 +2216,10 @@ is unset, it loses its special properties, even if it is subsequently reset. .TP .B READLINE_ARGUMENT -Any numeric argument given to a readline command that was defined using -.if t \f(CWbind -x\fP -.if n "bind -x" +Any numeric argument given to a +.B \%readline +command that was defined using +.Q "bind \-x" (see .SM .B "SHELL BUILTIN COMMANDS" @@ -1988,8 +2230,7 @@ when it was invoked. The contents of the .B readline line buffer, for use with -.if t \f(CWbind -x\fP -.if n "bind -x" +.Q "bind \-x" (see .SM .B "SHELL BUILTIN COMMANDS" @@ -1999,8 +2240,7 @@ below). The position of the mark (saved insertion point) in the .B readline line buffer, for use with -.if t \f(CWbind -x\fP -.if n "bind -x" +.Q "bind \-x" (see .SM .B "SHELL BUILTIN COMMANDS" @@ -2012,8 +2252,7 @@ called the \fIregion\fP. The position of the insertion point in the .B readline line buffer, for use with -.if t \f(CWbind -x\fP -.if n "bind -x" +.Q "bind \-x" (see .SM .B "SHELL BUILTIN COMMANDS" @@ -2034,7 +2273,7 @@ the value returned upon subsequent references is the number of seconds since the assignment plus the value assigned. The number of seconds at shell invocation and the current time are always -determined by querying the system clock. +determined by querying the system clock at one-second resolution. If .SM .B SECONDS @@ -2042,15 +2281,16 @@ is unset, it loses its special properties, even if it is subsequently reset. .TP .B SHELLOPTS -A colon-separated list of enabled shell options. Each word in -the list is a valid argument for the +A colon-separated list of enabled shell options. +Each word in the list is a valid argument for the .B \-o option to the .B set builtin command (see .SM .B "SHELL BUILTIN COMMANDS" -below). The options appearing in +below). +The options appearing in .SM .B SHELLOPTS are those reported as @@ -2058,8 +2298,10 @@ are those reported as by \fBset \-o\fP. If this variable is in the environment when .B bash -starts up, each shell option in the list will be enabled before +starts up, the shell enables each option in the list before reading any startup files. +If this variable is exported, child shells will enable each option +in the list. This variable is read-only. .TP .B SHLVL @@ -2068,9 +2310,14 @@ Incremented by one each time an instance of is started. .TP .B SRANDOM -This variable expands to a 32-bit pseudo-random number each time it is -referenced. The random number generator is not linear on systems that -support \f(CW/dev/urandom\fP or \fIarc4random\fP, so each returned number +Each time it is referenced, this variable expands to a 32-bit pseudo-random +number. +The random number generator is not linear on systems that +support +.FN /dev/urandom +or +.IR arc4random (3), +so each returned number has no relationship to the numbers preceding it. The random number generator cannot be seeded, so assignments to this variable have no effect. @@ -2085,7 +2332,7 @@ Expands to the user ID of the current user, initialized at shell startup. This variable is readonly. .PD .PP -The following variables are used by the shell. In some cases, +The shell uses the following variables. In some cases, .B bash assigns a default value to a variable; these cases are noted below. @@ -2101,12 +2348,18 @@ below for a description of the various compatibility levels and their effects. The value may be a decimal number (e.g., 4.2) or an integer (e.g., 42) corresponding to the desired compatibility level. -If \fBBASH_COMPAT\fP is unset or set to the empty string, the compatibility +If +.SM +.B BASH_COMPAT +is unset or set to the empty string, the compatibility level is set to the default for the current version. -If \fBBASH_COMPAT\fP is set to a value that is not one of the valid +If +.SM +.B BASH_COMPAT +is set to a value that is not one of the valid compatibility levels, the shell prints an error message and sets the compatibility level to the default for the current version. -The valid values correspond to the compatibility levels +A subset of the valid values correspond to the compatibility levels described below under .SM .BR "SHELL COMPATIBILITY MODE" . @@ -2117,9 +2370,9 @@ The current version is also a valid value. .TP .B BASH_ENV If this parameter is set when \fBbash\fP is executing a shell script, -its value is interpreted as a filename containing commands to -initialize the shell, as in -.IR ~/.bashrc . +its expanded value is interpreted as a filename containing commands to +initialize the shell before it reads and executes commands from the +script. The value of .SM .B BASH_ENV @@ -2130,11 +2383,11 @@ expansion before being interpreted as a filename. is not used to search for the resultant filename. .TP .B BASH_XTRACEFD -If set to an integer corresponding to a valid file descriptor, \fBbash\fP -will write the trace output generated when -.if t \f(CWset -x\fP -.if n \fIset -x\fP -is enabled to that file descriptor. +If set to an integer corresponding to a valid file descriptor, +\fBbash\fP writes the trace output generated when +.Q "set \-x" +is enabled to that file descriptor, +instead of the standard error. The file descriptor is closed when .SM .B BASH_XTRACEFD @@ -2155,19 +2408,19 @@ being closed. The search path for the .B cd command. -This is a colon-separated list of directories in which the shell looks -for destination directories specified by the +This is a colon-separated list of directories where the shell looks for +directories specified as arguments to the .B cd command. A sample value is -.if t \f(CW".:~:/usr"\fP. -.if n ".:~:/usr". +.Q .:\*~:/usr . .TP .B CHILD_MAX Set the number of exited child status values for the shell to remember. -Bash will not allow this value to be decreased below a POSIX-mandated -minimum, and there is a maximum value (currently 8192) that this may -not exceed. +\fBBash\fP will not allow this value to be decreased below a +.SM POSIX\c +-mandated minimum, +and there is a maximum value (currently 8192) that this may not exceed. The minimum value is system-dependent. .TP .B COLUMNS @@ -2188,8 +2441,7 @@ Each array element contains one possible completion. .B EMACS If \fBbash\fP finds this variable in the environment when the shell starts with value -.if t \f(CWt\fP, -.if n "t", +.Q t , it assumes that the shell is running in an Emacs shell buffer and disables line editing. .TP @@ -2197,19 +2449,27 @@ line editing. Expanded and executed similarly to .SM .B BASH_ENV -(see \fBINVOCATION\fP above) -when an interactive shell is invoked in \fIposix mode\fP. +(see +.SM +.B INVOCATION +above) when an interactive shell is invoked in posix mode. .TP .B EXECIGNORE A colon-separated list of shell patterns (see \fBPattern Matching\fP) -defining the list of filenames to be ignored by command search using -\fBPATH\fP. +defining the set of filenames to be ignored by command search using +.SM +.BR PATH . Files whose full pathnames match one of these patterns are not considered executable files for the purposes of completion and command execution -via \fBPATH\fP lookup. +via +.SM +.B PATH +lookup. This does not affect the behavior of the \fB[\fP, \fBtest\fP, and \fB[[\fP commands. -Full pathnames in the command hash table are not subject to \fBEXECIGNORE\fP. +Full pathnames in the command hash table are not subject to +.SM +.BR EXECIGNORE . Use this variable to ignore shared library files that have the executable bit set, but are not executable files. The pattern matching honors the setting of the \fBextglob\fP shell @@ -2231,13 +2491,13 @@ A filename whose suffix matches one of the entries in .B FIGNORE is excluded from the list of matched filenames. A sample value is -.if t \f(CW".o:~"\fP. -.if n ".o:~". +.Q .o:\*~ . .TP .B FUNCNEST If set to a numeric value greater than 0, defines a maximum function -nesting level. Function invocations that exceed this nesting level -will cause the current command to abort. +nesting level. +Function invocations that exceed this nesting level +cause the current command to abort. .TP .B GLOBIGNORE A colon-separated list of patterns defining the set of file names to @@ -2247,6 +2507,64 @@ of the patterns in .SM .BR GLOBIGNORE , it is removed from the list of matches. +The pattern matching honors the setting of the \fBextglob\fP shell +option. +.TP +.B GLOBSORT +.PD +Controls how the results of pathname expansion are sorted. +The value of this variable specifies the sort criteria and sort order for +the results of pathname expansion. +If this variable is unset or set to the null string, pathname expansion +uses the historical behavior of sorting by name, +in ascending lexicographic order as determined by the +.SM +.B \%LC_COLLATE +shell variable. +.IP +If set, a valid value begins with an optional \fI+\fP, which is ignored, +or \fI\-\fP, which reverses the sort order from ascending to descending, +followed by a sort specifier. +The valid sort specifiers are +.IR name , +.IR \%numeric , +.IR size , +.IR mtime , +.IR atime , +.IR ctime , +and +.IR blocks , +which sort the files on name, +names in numeric rather than lexicographic order, +file size, modification time, access time, +inode change time, and number of blocks, respectively. +If any of the non-name keys compare as equal (e.g., if two files are +the same size), sorting uses the name as a secondary sort key. +.IP +For example, a value of \fI\-mtime\fP sorts the results in descending +order by modification time (newest first). +.IP +The \fInumeric\fP specifier treats names consisting solely of digits as +numbers and sorts them using their numeric value +(so +.Q 2 +sorts before +.Q 10 , +for example). +When using \fInumeric\fP, names containing non-digits sort after all +the all-digit names and are sorted by name using the traditional behavior. +.IP +A sort specifier of \fInosort\fP disables sorting completely; +.B bash +returns the results +in the order they are read from the file system, +ignoring any leading \fI\-\fP. +.IP +If the sort specifier is missing, it defaults to \fIname\fP, +so a value of \fI+\fP is equivalent to the null string, +and a value of \fI-\fP sorts by name in descending order. +Any invalid value restores the historical sorting behavior. +.PD 0 .TP .B HISTCONTROL A colon-separated list of values controlling how commands are saved on @@ -2258,7 +2576,7 @@ lines which begin with a character are not saved in the history list. A value of .I ignoredups -causes lines matching the previous history entry to not be saved. +causes lines matching the previous history entry not to be saved. A value of .I ignoreboth is shorthand for \fIignorespace\fP and \fIignoredups\fP. @@ -2271,52 +2589,101 @@ If .SM .B HISTCONTROL is unset, or does not include a valid value, -all lines read by the shell parser are saved on the history list, +\fBbash\fP saves all lines read by the shell parser on the history list, subject to the value of .SM .BR HISTIGNORE . -The second and subsequent lines of a multi-line compound command are -not tested, and are added to the history regardless of the value of +If the first line of a multi-line compound command was saved, +the second and subsequent lines are not tested, +and are added to the history regardless of the value of .SM .BR HISTCONTROL . +If the first line was not saved, the second and subsequent lines of +the command are not saved either. .TP .B HISTFILE The name of the file in which command history is saved (see .SM .B HISTORY -below). The default value is \fI~/.bash_history\fP. If unset, the -command history is not saved when a shell exits. +below). +\fBBash\fP assigns a default value of +.FN \*~/.bash_history . +If +.SM +.B HISTFILE +is unset or null, +the shell does not save the command history when it exits. .TP .B HISTFILESIZE -The maximum number of lines contained in the history file. When this -variable is assigned a value, the history file is truncated, if -necessary, -to contain no more than that number of lines by removing the oldest entries. +The maximum number of lines contained in the history file. +When this variable is assigned a value, the history file is truncated, +if necessary, to contain no more than +the number of history entries +that total no more than that number of lines +by removing the oldest entries. +If the history list contains multi-line entries, +the history file may contain more lines than this maximum +to avoid leaving partial history entries. The history file is also truncated to this size after -writing it when a shell exits. +writing it when a shell exits or by the +.B \%history +builtin. If the value is 0, the history file is truncated to zero size. Non-numeric values and numeric values less than zero inhibit truncation. -The shell sets the default value to the value of \fBHISTSIZE\fP +The shell sets the default value to the value of +.SM +.B HISTSIZE after reading any startup files. .TP .B HISTIGNORE A colon-separated list of patterns used to decide which command lines -should be saved on the history list. Each pattern is anchored at the -beginning of the line and must match the complete line (no implicit -`\fB*\fP' is appended). Each pattern is tested against the line +should be saved on the history list. +If a command line matches one of the patterns in the value of +.SM +.BR HISTIGNORE , +it is not saved on the history list. +Each pattern is anchored at the +beginning of the line and must match the complete line +(\fBbash\fP does not implicitly append a +.Q \fB*\fP ). +Each pattern is tested against the line after the checks specified by .SM .B HISTCONTROL are applied. -In addition to the normal shell pattern matching characters, `\fB&\fP' -matches the previous history line. `\fB&\fP' may be escaped using a -backslash; the backslash is removed before attempting a match. -The second and subsequent lines of a multi-line compound command are -not tested, and are added to the history regardless of the value of +In addition to the normal shell pattern matching characters, +.Q \fB&\fP +matches the previous history line. +A backslash escapes the +.Q \fB&\fP ; +the backslash is removed before attempting a match. +If the first line of a multi-line compound command was saved, +the second and subsequent lines are not tested, +and are added to the history regardless of the value of .SM .BR HISTIGNORE . -The pattern matching honors the setting of the \fBextglob\fP shell -option. +If the first line was not saved, the second and subsequent lines of +the command are not saved either. +The pattern matching honors the setting of the +.B \%extglob +shell option. +.IP +.SM +.B HISTIGNORE +subsumes some of the function of +.SM +.BR HISTCONTROL . +A pattern of +.Q & +is identical to +.Q \%ignoredups , +and a pattern of +.Q "[ ]*" +is identical to +.Q \%ignorespace . +Combining these two patterns, separating them with a colon, +provides the functionality of +.Q \%ignoreboth . .TP .B HISTSIZE The number of commands to remember in the command history (see @@ -2330,9 +2697,11 @@ The shell sets the default value to 500 after reading any startup files. .TP .B HISTTIMEFORMAT If this variable is set and not null, its value is used as a format string -for \fIstrftime\fP(3) to print the time stamp associated with each history +for +.IR strftime (3) +to print the time stamp associated with each history entry displayed by the \fBhistory\fP builtin. -If this variable is set, time stamps are written to the history file so +If this variable is set, the shell writes time stamps to the history file so they may be preserved across shell sessions. This uses the history comment character to distinguish timestamps from other history lines. @@ -2363,7 +2732,7 @@ to obtain the list of possible hostname completions. When .SM .B HOSTFILE -is unset, the hostname list is cleared. +is unset, \fBbash\fP clears the hostname list. .TP .B IFS The @@ -2372,23 +2741,30 @@ that is used for word splitting after expansion and to split lines into words with the .B read -builtin command. The default value is -``''. +builtin command. +Word splitting is described below under +.SM +.BR EXPANSION . +The default value is +.Q . .TP .B IGNOREEOF Controls the action of an interactive shell on receipt of an .SM .B EOF -character as the sole input. If set, the value is the number of -consecutive +character as the sole input. +If set, the value is the number of consecutive .SM .B EOF characters which must be typed as the first characters on an input line before .B bash -exits. If the variable exists but does not have a numeric value, or -has no value, the default value is 10. If it does not exist, +exits. +If the variable is set but does not have a numeric value, +or the value is null, +the default value is 10. +If it is unset, .SM .B EOF signifies the end of input to the shell. @@ -2397,7 +2773,7 @@ signifies the end of input to the shell. The filename for the .B readline startup file, overriding the default of -.FN ~/.inputrc +.FN \*~/.inputrc (see .SM .B READLINE @@ -2406,7 +2782,9 @@ below). .B INSIDE_EMACS If this variable appears in the environment when the shell starts, \fBbash\fP assumes that it is running inside an Emacs shell buffer -and may disable line editing, depending on the value of \fBTERM\fP. +and may disable line editing, depending on the value of +.SM +.BR TERM . .TP .B LANG Used to determine the locale category for any category not specifically @@ -2451,7 +2829,7 @@ option is enabled or in an interactive shell upon receipt of a .BR SIGWINCH . .TP .B MAIL -If this parameter is set to a file or directory name and the +If the value is set to a file or directory name and the .SM .B MAILPATH variable is not set, @@ -2463,21 +2841,26 @@ Maildir-format directory. Specifies how often (in seconds) .B bash -checks for mail. The default is 60 seconds. When it is time to check -for mail, the shell does so before displaying the primary prompt. +checks for mail. +The default is 60 seconds. +When it is time to check for mail, +the shell does so before displaying the primary prompt. If this variable is unset, or set to a value that is not a number greater than or equal to zero, the shell disables mail checking. .TP .B MAILPATH A colon-separated list of filenames to be checked for mail. The message to be printed when mail arrives in a particular file -may be specified by separating the filename from the message with a `?'. +may be specified by separating the filename from the message with a +.Q ? . When used in the text of the message, \fB$_\fP expands to the name of the current mailfile. -Example: +For example: .RS .PP -\fBMAILPATH\fP=\(aq/var/mail/bfox?"You have mail":~/shell\-mail?"$_ has mail!"\(aq +.EX +\fBMAILPATH\fP=\*'/var/mail/bfox?\*"You have mail\*":\*~/shell\-mail?\*"$_ has mail!\*"\*' +.EE .PP .B Bash can be configured to supply @@ -2493,7 +2876,7 @@ displays error messages generated by the .B getopts builtin command (see .SM -.B SHELL BUILTIN COMMANDS +.B "SHELL BUILTIN COMMANDS" below). .SM .B OPTERR @@ -2501,11 +2884,11 @@ is initialized to 1 each time the shell is invoked or a shell script is executed. .TP .B PATH -The search path for commands. It -is a colon-separated list of directories in which +The search path for commands. +It is a colon-separated list of directories in which the shell looks for commands (see .SM -.B COMMAND EXECUTION +.B "COMMAND EXECUTION" below). A zero-length (null) directory name in the value of .SM @@ -2517,28 +2900,33 @@ The default path is system-dependent, and is set by the administrator who installs .BR bash . A common value is -.na -.if t \f(CW/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin\fP. -.if n ``/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin''. -.ad +.RS +.RS 5n +.EX +/usr/local/bin:/usr/local/sbin:\c +.if \n(LL<78n .br +/usr/bin:/usr/sbin:/bin:/sbin +.EE +.RE +.RE .TP .B POSIXLY_CORRECT If this variable is in the environment when \fBbash\fP starts, the shell -enters \fIposix mode\fP before reading the startup files, as if the +enters posix mode before reading the startup files, as if the .B \-\-posix -invocation option had been supplied. If it is set while the shell is -running, \fBbash\fP enables \fIposix mode\fP, as if the command -.if t \f(CWset -o posix\fP -.if n \fIset -o posix\fP +invocation option had been supplied. +If it is set while the shell is +running, \fBbash\fP enables posix mode, as if the command +.Q "set \-o posix" had been executed. -When the shell enters \fIposix mode\fP, it sets this variable if it was +When the shell enters posix mode, it sets this variable if it was not already set. .TP .B PROMPT_COMMAND If this variable is set, and is an array, the value of each set element is executed as a command prior to issuing each primary prompt. -If this is set but not an array variable, +If this is set but not an array variable, its value is used as a command to execute instead. .TP .B PROMPT_DIRTRIM @@ -2547,7 +2935,8 @@ trailing directory components to retain when expanding the \fB\ew\fP and \fB\eW\fP prompt string escapes (see .SM .B PROMPTING -below). Characters removed are replaced with an ellipsis. +below). +Characters removed are replaced with an ellipsis. .TP .B PS0 The value of this parameter is expanded (see @@ -2560,22 +2949,24 @@ and before the command is executed. The value of this parameter is expanded (see .SM .B PROMPTING -below) and used as the primary prompt string. The default value is -``\fB\es\-\ev\e$ \fP''. +below) and used as the primary prompt string. +The default value is +.Q \es\-\ev\e$\ . .TP .B PS2 The value of this parameter is expanded as with .SM .B PS1 -and used as the secondary prompt string. The default is -``\fB> \fP''. +and used as the secondary prompt string. +The default is +.Q >\ . .TP .B PS3 The value of this parameter is used as the prompt for the .B select command (see .SM -.B SHELL GRAMMAR +.B "SHELL GRAMMAR" above). .TP .B PS4 @@ -2584,12 +2975,14 @@ The value of this parameter is expanded as with .B PS1 and the value is printed before each command .B bash -displays during an execution trace. The first character of -the expanded value of +displays during an execution trace. +The first character of the expanded value of .SM .B PS4 is replicated multiple times, as necessary, to indicate multiple -levels of indirection. The default is ``\fB+ \fP''. +levels of indirection. +The default is +.Q +\ . .TP .B SHELL This variable expands to the full pathname to the shell. @@ -2605,8 +2998,8 @@ reserved word should be displayed. The \fB%\fP character introduces an escape sequence that is expanded to a time value or other information. The escape sequences and their meanings are as follows; the -braces denote optional portions. -.sp .5 +brackets denote optional portions. +.PP .RS .PD 0 .TP 10 @@ -2630,9 +3023,10 @@ The CPU percentage, computed as (%U + %S) / %R. The optional \fIp\fP is a digit specifying the \fIprecision\fP, the number of fractional digits after a decimal point. A value of 0 causes no decimal point or fraction to be output. -At most three places after the decimal point may be specified; -values of \fIp\fP greater than 3 are changed to 3. -If \fIp\fP is not specified, the value 3 is used. +\fBtime\fP prints at most six digits after the decimal point; +values of \fIp\fP greater than 6 are changed to 6. +If \fIp\fP is not specified, +\fBtime\fP prints three digits after the decimal point. .IP The optional \fBl\fP specifies a longer format, including minutes, of the form \fIMM\fPm\fISS\fP.\fIFF\fPs. @@ -2640,17 +3034,15 @@ The value of \fIp\fP determines whether or not the fraction is included. .IP If this variable is not set, \fBbash\fP acts as if it had the -value \fB$\(aq\enreal\et%3lR\enuser\et%3lU\ensys\et%3lS\(aq\fP. -If the value is null, no timing information is displayed. +value \fB$\*'\enreal\et%3lR\enuser\et%3lU\ensys\et%3lS\*'\fP. +If the value is null, \fBbash\fP does not display any timing information. A trailing newline is added when the format string is displayed. .PD 0 .TP .B TMOUT If set to a value greater than zero, -.SM -.B TMOUT -is treated as the -default timeout for the \fBread\fP builtin. +the \fBread\fP builtin uses the value as its +default timeout. The \fBselect\fP command terminates if input does not arrive after .SM @@ -2660,8 +3052,8 @@ In an interactive shell, the value is interpreted as the number of seconds to wait for a line of input after issuing the primary prompt. .B Bash -terminates after waiting for that number of seconds if a complete -line of input does not arrive. +terminates after waiting for that number of seconds if a +complete line of input does not arrive. .TP .B TMPDIR If set, \fBbash\fP uses its value as the name of a directory in which @@ -2669,107 +3061,163 @@ If set, \fBbash\fP uses its value as the name of a directory in which .TP .B auto_resume This variable controls how the shell interacts with the user and -job control. If this variable is set, single word simple -commands without redirections are treated as candidates for resumption -of an existing stopped job. There is no ambiguity allowed; if there is -more than one job beginning with the string typed, the job most recently -accessed is selected. The +job control. +If this variable is set, simple commands +consisting of only a single word, +without redirections, are treated as candidates for resumption +of an existing stopped job. +There is no ambiguity allowed; if there is more than one job +beginning with or containing +the word, this selects the most recently accessed job. +The .I name of a stopped job, in this context, is the command line used to -start it. +start it, as displayed by \fBjobs\fP. If set to the value .IR exact , -the string supplied must match the name of a stopped job exactly; +the word must match the name of a stopped job exactly; if set to .IR substring , -the string supplied needs to match a substring of the name of a -stopped job. The +the word needs to match a substring of the name of a stopped job. +The .I substring value provides functionality analogous to the .B %? job identifier (see .SM -.B JOB CONTROL -below). If set to any other value, the supplied string must -be a prefix of a stopped job's name; this provides functionality -analogous to the \fB%\fP\fIstring\fP job identifier. +.B "JOB CONTROL" +below). +If set to any other value (e.g., +.IR prefix ), +the word must be a prefix of a stopped job's name; +this provides functionality analogous to the \fB%\fP\fIstring\fP job identifier. .TP .B histchars -The two or three characters which control history expansion -and tokenization (see -.SM -.B HISTORY EXPANSION -below). The first character is the \fIhistory expansion\fP character, -the character which signals the start of a history -expansion, normally `\fB!\fP'. -The second character is the \fIquick substitution\fP -character, which is used as shorthand for re-running the previous -command entered, substituting one string for another in the command. -The default is `\fB^\fP'. -The optional third character is the character -which indicates that the remainder of the line is a comment when found -as the first character of a word, normally `\fB#\fP'. The history -comment character causes history substitution to be skipped for the -remaining words on the line. It does not necessarily cause the shell -parser to treat the rest of the line as a comment. +The two or three characters which control history expansion, +quick substitution, and tokenization +(see +.SM +.B "HISTORY EXPANSION" +below). +The first character is the \fIhistory expansion\fP character, +the character which begins a history expansion, normally +.Q \fB!\fP . +The second character is the \fIquick substitution\fP character, normally +.Q \fB\*^\fP . +When it appears as the first character on the line, +history substitution repeats the previous command, +replacing one string with another. +The optional third character is the +\fIhistory comment\fP +character, normally +.Q \fB#\fP , +which indicates +that the remainder of the line is a comment +when it appears as the first character of a word. +The history comment character disables history substitution +for the remaining words on the line. +It does not necessarily cause the shell parser to treat the rest of the +line as a comment. .PD .SS Arrays .B Bash provides one-dimensional indexed and associative array variables. Any variable may be used as an indexed array; the .B declare -builtin will explicitly declare an array. +builtin explicitly declares an array. There is no maximum limit on the size of an array, nor any requirement that members be indexed or assigned contiguously. -Indexed arrays are referenced using integers (including arithmetic -expressions) and are zero-based; associative arrays are referenced -using arbitrary strings. +Indexed arrays are referenced using arithmetic expressions +that must expand to an integer +(see +.SM +.B +ARITHMETIC EVALUATION +below) +and are zero-based; +associative arrays are referenced using arbitrary strings. Unless otherwise noted, indexed array indices must be non-negative integers. .PP -An indexed array is created automatically if any variable is assigned to -using the syntax \fIname\fP[\fIsubscript\fP]=\fIvalue\fP. The +The shell performs +parameter and variable expansion, arithmetic expansion, +command substitution, and quote removal +on indexed array subscripts. +Since this +can potentially result in empty strings, +subscript indexing treats +those as expressions that evaluate to 0. +.PP +The shell performs +tilde expansion, +parameter and variable expansion, arithmetic expansion, +command substitution, and quote removal +on associative array subscripts. +Empty strings cannot be used as associative array keys. +.PP +\fBBash\fP automatically creates an indexed array +if any variable is assigned to using the syntax +.RS +\fIname\fP[\fIsubscript\fP]=\fIvalue\fP +\&. +.RE +The .I subscript -is treated as an arithmetic expression that must evaluate to a number. +is treated as an arithmetic expression that must evaluate to a number +greater than or equal to zero. To explicitly declare an indexed array, use -.B declare \-a \fIname\fP +.RS +.BI "declare \-a\ " name +.RE (see .SM -.B SHELL BUILTIN COMMANDS +.B "SHELL BUILTIN COMMANDS" below). -.B declare \-a \fIname\fP[\fIsubscript\fP] +.RS +\fBdeclare \-a\fP \fIname\fP[\fIsubscript\fP] +.RE is also accepted; the \fIsubscript\fP is ignored. .PP Associative arrays are created using -.BR "declare \-A \fIname\fP" . +.RS +.BI "declare \-A\ " name +.RE +\&. .PP -Attributes may be -specified for an array variable using the -.B declare +Attributes may be specified for an array variable using the +.B \%declare and -.B readonly -builtins. Each attribute applies to all members of an array. +.B \%readonly +builtins. +Each attribute applies to all members of an array. .PP -Arrays are assigned to using compound assignments of the form -\fIname\fP=\fB(\fPvalue\fI1\fP ... value\fIn\fP\fB)\fP, where each +Arrays are assigned using compound assignments of the form +\fIname\fP=\fB(\fPvalue\fI1\fP .\|.\|.\& value\fIn\fP\fB)\fP, where each \fIvalue\fP may be of the form [\fIsubscript\fP]=\fIstring\fP. Indexed array assignments do not require anything but \fIstring\fP. -Each \fIvalue\fP in the list is expanded using all the shell expansions +Each \fIvalue\fP in the list is expanded using the shell expansions described below under .SM -.BR EXPANSION . +.BR EXPANSION , +but \fIvalue\fPs that are valid variable assignments +including the brackets and subscript do not undergo +brace expansion and word splitting, as with individual +variable assignments. +.PP When assigning to indexed arrays, if the optional brackets and subscript are supplied, that index is assigned to; otherwise the index of the element assigned is the last index assigned -to by the statement plus one. Indexing starts at zero. +to by the statement plus one. +Indexing starts at zero. .PP When assigning to an associative array, the words in a compound assignment may be either assignment statements, for which the subscript is required, or a list of words that is interpreted as a sequence of alternating keys and values: -\fIname\fP=\fB( \fP\fIkey1 value1 key2 value2\fP ...\fB)\fP. +\fIname\fP=\fB( \fP\fIkey1 value1 key2 value2\fP .\|.\|.\&\fB)\fP. These are treated identically to -\fIname\fP=\fB(\fP [\fIkey1\fP]=\fIvalue1\fP [\fIkey2\fP]=\fIvalue2\fP ...\fB)\fP. +\fIname\fP=\fB(\fP [\fIkey1\fP]=\fIvalue1\fP [\fIkey2\fP]=\fIvalue2\fP +\&.\|.\|.\&\fB)\fP. The first word in the list determines how the remaining words are interpreted; all assignments in a list must be of the same type. When using key/value pairs, the keys may not be missing or empty; @@ -2777,8 +3225,10 @@ a final missing value is treated like the empty string. .PP This syntax is also accepted by the .B declare -builtin. Individual array elements may be assigned to using the +builtin. +Individual array elements may be assigned to using the \fIname\fP[\fIsubscript\fP]=\fIvalue\fP syntax introduced above. +.PP When assigning to an indexed array, if .I name is subscripted by a negative number, that number is @@ -2786,36 +3236,46 @@ interpreted as relative to one greater than the maximum index of \fIname\fP, so negative indices count back from the end of the array, and an index of \-1 references the last element. .PP -The += operator will append to an array variable when assigning +The +.Q += +operator appends to an array variable when assigning using the compound assignment syntax; see .SM .B PARAMETERS above. .PP -Any element of an array may be referenced using -${\fIname\fP[\fIsubscript\fP]}. The braces are required to avoid -conflicts with pathname expansion. If -\fIsubscript\fP is \fB@\fP or \fB*\fP, the word expands to -all members of \fIname\fP. These subscripts differ only when the -word appears within double quotes. If the word is double-quoted, -${\fIname\fP[*]} expands to a single +An array element is referenced using +${\fIname\fP[\fIsubscript\fP]}. +The braces are required to avoid conflicts with pathname expansion. +If \fIsubscript\fP is \fB@\fP or \fB*\fP, the word expands to +all members of \fIname\fP, +unless noted in the description of a builtin or word expansion. +These subscripts differ only when the +word appears within double quotes. +If the word is double-quoted, ${\fIname\fP[*]} expands to a single word with the value of each array member separated by the first character of the .SM .B IFS special variable, and ${\fIname\fP[@]} expands each element of -\fIname\fP to a separate word. When there are no array members, -${\fIname\fP[@]} expands to nothing. +\fIname\fP to a separate word. +When there are no array members, ${\fIname\fP[@]} expands to nothing. If the double-quoted expansion occurs within a word, the expansion of -the first parameter is joined with the beginning part of the original -word, and the expansion of the last parameter is joined with the last -part of the original word. +the first parameter is joined with the beginning part of the +expansion of the original word, +and the expansion of the last parameter is joined with the last +part of the +expansion of the original word. This is analogous to the expansion of the special parameters \fB*\fP and \fB@\fP (see -.B Special Parameters -above). ${#\fIname\fP[\fIsubscript\fP]} expands to the length of -${\fIname\fP[\fIsubscript\fP]}. If \fIsubscript\fP is \fB*\fP or -\fB@\fP, the expansion is the number of elements in the array. +.B "Special Parameters" +above). +.PP +${#\fIname\fP[\fIsubscript\fP]} expands to the length of +${\fIname\fP[\fIsubscript\fP]}. +If \fIsubscript\fP is \fB*\fP or \fB@\fP, +the expansion is the number of elements in the array. +.PP If the .I subscript used to reference an element of an indexed array @@ -2826,12 +3286,13 @@ array, and an index of \-1 references the last element. .PP Referencing an array variable without a subscript is equivalent to referencing the array with a subscript of 0. -Any reference to a variable using a valid subscript is legal, and +Any reference to a variable using a valid subscript is valid; .B bash -will create an array if necessary. +creates an array if necessary. .PP An array variable is considered set if a subscript has been assigned a -value. The null string is a valid value. +value. +The null string is a valid value. .PP It is possible to obtain the keys (indices) of an array as well as the values. ${\fB!\fP\fIname\fP[\fI@\fP]} and ${\fB!\fP\fIname\fP[\fI*\fP]} @@ -2841,16 +3302,18 @@ special parameters \fI@\fP and \fI*\fP within double quotes. .PP The .B unset -builtin is used to destroy arrays. \fBunset\fP \fIname\fP[\fIsubscript\fP] -destroys the array element at index \fIsubscript\fP, +builtin is used to destroy arrays. +\fBunset\fP \fIname\fP[\fIsubscript\fP] +unsets the array element at index \fIsubscript\fP, for both indexed and associative arrays. Negative subscripts to indexed arrays are interpreted as described above. Unsetting the last element of an array variable does not unset the variable. \fBunset\fP \fIname\fP, where \fIname\fP is an array, removes the entire array. -\fBunset\fP \fIname\fP[\fIsubscript\fP], where -\fIsubscript\fP is \fB*\fP or \fB@\fP, behaves differently depending on -whether \fIname\fP is an indexed or associative array. +\fBunset\fP \fIname\fP[\fIsubscript\fP] +behaves differently depending on +whether \fIname\fP is an indexed or associative array +when \fIsubscript\fP is \fB*\fP or \fB@\fP. If \fIname\fP is an associative array, this unsets the element with subscript \fB*\fP or \fB@\fP. If \fIname\fP is an indexed array, unset removes all of the elements but @@ -2858,8 +3321,11 @@ does not remove the array itself. .PP When using a variable name with a subscript as an argument to a command, such as with \fBunset\fP, without using the word expansion syntax -described above, the argument is subject to pathname expansion. -If pathname expansion is not desired, the argument should be quoted. +described above, +(e.g., unset a[4]), +the argument is subject to pathname expansion. +Quote the argument if pathname expansion is not desired +(e.g., unset \*'a[4]\*'). .PP The .BR declare , @@ -2879,30 +3345,37 @@ The builtin accepts a .B \-a option to assign a list of words read from the standard input -to an array. The +to an array. +The .B set and .B declare builtins display array values in a way that allows them to be reused as assignments. +Other builtins accept array name arguments as well +(e.g., \fBmapfile\fP); see the descriptions +of individual builtins below for details. +The shell provides a number of builtin array variables. .SH EXPANSION Expansion is performed on the command line after it has been split into -words. There are seven kinds of expansion performed: +words. The shell performs these expansions: .IR "brace expansion" , .IR "tilde expansion" , .IR "parameter and variable expansion" , .IR "command substitution" , .IR "arithmetic expansion" , .IR "word splitting" , +.IR "pathname expansion" , and -.IR "pathname expansion" . +.IR "quote removal" . .PP The order of expansions is: brace expansion; tilde expansion, parameter and variable expansion, arithmetic expansion, and command substitution (done in a left-to-right fashion); word splitting; -and pathname expansion. +pathname expansion; +and quote removal. .PP On systems that can support it, there is an additional expansion available: \fIprocess substitution\fP. @@ -2910,61 +3383,68 @@ This is performed at the same time as tilde, parameter, variable, and arithmetic expansion and command substitution. .PP -After these expansions are performed, quote characters present in the -original word are removed unless they have been quoted themselves -(\fIquote removal\fP). +\fIQuote removal\fP is always performed last. +It removes quote characters present in the original word, +not ones resulting from one of the other expansions, +unless they have been quoted themselves. .PP Only brace expansion, word splitting, and pathname expansion can increase the number of words of the expansion; other expansions expand a single word to a single word. The only exceptions to this are the expansions of -"\fB$@\fP" and "\fB${\fP\fIname\fP\fB[@]}\fP", +.B \&\*"$@\*" +and +.B \&\*"${\fIname\fP[@]}\*"\c \" keep leading \& for AT&T troff +.BR \& , \" .BR + \& + \*" doesn't work with AT&T troff and, in most cases, \fB$*\fP and \fB${\fP\fIname\fP\fB[*]}\fP as explained above (see .SM .BR PARAMETERS ). .SS Brace Expansion .I "Brace expansion" -is a mechanism by which arbitrary strings -may be generated. This mechanism is similar to +is a mechanism to generate arbitrary strings +sharing a common prefix and suffix, either of which can be empty. +This mechanism is similar to \fIpathname expansion\fP, but the filenames generated -need not exist. Patterns to be brace expanded take -the form of an optional +need not exist. +Patterns to be brace expanded are formed from an optional .IR preamble , followed by either a series of comma-separated strings or -a sequence expression between a pair of braces, followed by -an optional +a sequence expression between a pair of braces, +followed by an optional .IR postscript . -The preamble is prefixed to each string contained -within the braces, and the postscript is then appended -to each resulting string, expanding left to right. +The preamble is prefixed to each string contained within the braces, +and the postscript is then appended to each resulting string, +expanding left to right. .PP -Brace expansions may be nested. The results of each expanded -string are not sorted; left to right order is preserved. -For example, a\fB{\fPd,c,b\fB}\fPe expands into `ade ace abe'. +Brace expansions may be nested. +The results of each expanded string are not sorted; +brace expansion preserves left to right order. +For example, a\fB{\fPd,c,b\fB}\fPe expands into +.Q "ade ace abe" . .PP A sequence expression takes the form -\fB{\fP\fIx\fP\fB..\fP\fIy\fP\fB[..\fP\fIincr\fP\fB]}\fP, +\fIx\fP\fB..\fP\fIy\fP\fB[..\fP\fIincr\fP\fB]\fP, where \fIx\fP and \fIy\fP are either integers or single letters, and \fIincr\fP, an optional increment, is an integer. When integers are supplied, the expression expands to each number between \fIx\fP and \fIy\fP, inclusive. -Supplied integers may be prefixed with \fI0\fP to force each term to have the -same width. -When either \fIx\fP or \fPy\fP begins with a zero, the shell -attempts to force all generated terms to contain the same number of digits, +If either \fIx\fP or \fIy\fP begins with a zero, +each generated term will contain the same number of digits, zero-padding where necessary. When letters are supplied, the expression expands to each character lexicographically between \fIx\fP and \fIy\fP, inclusive, -using the default C locale. +using the C locale. Note that both \fIx\fP and \fIy\fP must be of the same type (integer or letter). When the increment is supplied, it is used as the difference between -each term. The default increment is 1 or \-1 as appropriate. +each term. +The default increment is 1 or \-1 as appropriate. .PP Brace expansion is performed before any other expansions, and any characters special to other expansions are preserved -in the result. It is strictly textual. +in the result. +It is strictly textual. .B Bash does not apply any syntactic interpretation to the context of the expansion or the text between the braces. @@ -2973,22 +3453,33 @@ A correctly-formed brace expansion must contain unquoted opening and closing braces, and at least one unquoted comma or a valid sequence expression. Any incorrectly formed brace expansion is left unchanged. -A \fB{\fP or \fB,\fP may be quoted with a backslash to prevent its +.PP +A +.Q { +or +Q , +may be quoted with a backslash to prevent its being considered part of a brace expression. -To avoid conflicts with parameter expansion, the string \fB${\fP -is not considered eligible for brace expansion, and inhibits brace -expansion until the closing \fB}\fP. +To avoid conflicts with parameter expansion, the string +.Q ${ +is not considered eligible for brace expansion, +and inhibits brace expansion until the closing +.Q } . .PP This construct is typically used as shorthand when the common prefix of the strings to be generated is longer than in the above example: -.RS .PP +.RS +.EX mkdir /usr/local/src/bash/{old,new,dist,bugs} +.EE .RE or .RS +.EX chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}} +.EE .RE .PP Brace expansion introduces a slight incompatibility with @@ -2998,18 +3489,17 @@ historical versions of does not treat opening or closing braces specially when they appear as part of a word, and preserves them in the output. .B Bash -removes braces from words as a consequence of brace -expansion. For example, a word entered to -.B sh -as \fIfile{1,2}\fP -appears identically in the output. The same word is -output as -.I file1 file2 -after expansion by -.BR bash . -If strict compatibility with +removes braces from words as a consequence of brace expansion. +For example, a word entered to .B sh -is desired, start +as +.Q file{1,2} +appears identically in the output. +.B Bash +outputs that word as +.Q "file1 file2" +after brace expansion. +Start .B bash with the .B +B @@ -3019,10 +3509,12 @@ option to the .B set command (see .SM -.B SHELL BUILTIN COMMANDS -below). +.B "SHELL BUILTIN COMMANDS" +below) for strict \fBsh\fP compatibility. .SS Tilde Expansion -If a word begins with an unquoted tilde character (`\fB~\fP'), all of +If a word begins with an unquoted tilde character (\c +.Q \fB\*~\fP ), +all of the characters preceding the first unquoted slash (or all characters, if there is no unquoted slash) are considered a \fItilde-prefix\fP. If none of the characters in the tilde-prefix are quoted, the @@ -3035,37 +3527,55 @@ value of the shell parameter If .SM .B HOME -is unset, the home directory of the user executing the shell is -substituted instead. +is unset, the tilde expands to +the home directory of the user executing the shell instead. Otherwise, the tilde-prefix is replaced with the home directory associated with the specified login name. .PP -If the tilde-prefix is a `~+', the value of the shell variable +If the tilde-prefix is a +.Q \*~+ , +the value of the shell variable .SM .B PWD replaces the tilde-prefix. -If the tilde-prefix is a `~\-', the value of the shell variable +If the tilde-prefix is a +.Q \*~\- , +the shell substitutes the value of the shell variable .SM .BR OLDPWD , -if it is set, is substituted. +if it is set. If the characters following the tilde in the tilde-prefix consist of a number \fIN\fP, optionally prefixed -by a `+' or a `\-', the tilde-prefix is replaced with the corresponding +by a +.Q + +or a +.Q \- , +the tilde-prefix is replaced with the corresponding element from the directory stack, as it would be displayed by the .B dirs -builtin invoked with the tilde-prefix as an argument. +builtin invoked with the characters following the tilde in the +tilde-prefix as an argument. If the characters following the tilde in the tilde-prefix consist of a -number without a leading `+' or `\-', `+' is assumed. +number without a leading +.Q + +or +.Q \- , +tilde expansion assumes +.Q + . +.PP +The results of tilde expansion are treated as if they were quoted, so +the replacement is not subject to word splitting and pathname expansion. .PP -If the login name is invalid, or the tilde expansion fails, the word -is unchanged. +If the login name is invalid, or the tilde expansion fails, the +tilde-prefix is unchanged. .PP -Each variable assignment is checked for unquoted tilde-prefixes immediately +\fBBash\fP checks each variable assignment +for unquoted tilde-prefixes immediately following a .B : or the first -.BR = . -In these cases, tilde expansion is also performed. +.BR = , +and performs tilde expansion in these cases. Consequently, one may use filenames with tildes in assignments to .SM .BR PATH , @@ -3076,30 +3586,37 @@ and .BR CDPATH , and the shell assigns the expanded value. .PP -Bash also performs tilde expansion on words satisfying the conditions of -variable assignments (as described above under +\fBBash\fP also performs tilde expansion on words satisfying the conditions +of variable assignments (as described above under .SM .BR PARAMETERS ) when they appear as arguments to simple commands. -Bash does not do this, except for the \fIdeclaration\fP commands listed -above, when in \fIposix mode\fP. +\fBBash\fP does not do this, +except for the \fIdeclaration\fP commands listed above, +when in posix mode. .SS Parameter Expansion -The `\fB$\fP' character introduces parameter expansion, -command substitution, or arithmetic expansion. The parameter name +The +.Q \fB$\fP +character introduces parameter expansion, +command substitution, or arithmetic expansion. +The parameter name or symbol to be expanded may be enclosed in braces, which are optional but serve to protect the variable to be expanded from characters immediately following it which could be interpreted as part of the name. .PP -When braces are used, the matching ending brace is the first `\fB}\fP' +When braces are used, the matching ending brace is the first +.Q \fB}\fP not escaped by a backslash or within a quoted string, and not within an embedded arithmetic expansion, command substitution, or parameter expansion. .PP -.PD 0 -.TP +The basic form of parameter expansion is +.PP ${\fIparameter\fP} -The value of \fIparameter\fP is substituted. The braces are required +.LP +which substitutes the value of \fIparameter\fP. +The braces are required when .I parameter is a positional parameter with more than one digit, @@ -3115,15 +3632,16 @@ If the first character of \fIparameter\fP is an exclamation point (\fB!\fP), and \fIparameter\fP is not a \fInameref\fP, it introduces a level of indirection. \fBBash\fP uses the value formed by expanding the rest of -\fIparameter\fP as the new \fIparameter\fP; this is then -expanded and that value is used in the rest of the expansion, rather +\fIparameter\fP as the new \fIparameter\fP; +this new parameter is then expanded and that value is used +in the rest of the expansion, rather than the expansion of the original \fIparameter\fP. This is known as \fIindirect expansion\fP. The value is subject to tilde expansion, parameter expansion, command substitution, and arithmetic expansion. If \fIparameter\fP is a nameref, this expands to the name of the parameter referenced by \fIparameter\fP instead of performing the -complete indirect expansion. +complete indirect expansion, for compatibility. The exceptions to this are the expansions of ${\fB!\fP\fIprefix\fP\fB*\fP} and ${\fB!\fP\fIname\fP[\fI@\fP]} described below. The exclamation point must immediately follow the left brace in order to @@ -3134,17 +3652,17 @@ parameter expansion, command substitution, and arithmetic expansion. .PP When not performing substring expansion, using the forms documented below (e.g., \fB:-\fP), -\fBbash\fP tests for a parameter that is unset or null. Omitting the colon -results in a test only for a parameter that is unset. +\fBbash\fP tests for a parameter that is unset or null. +Omitting the colon tests only for a parameter that is unset. .PP -.PD 0 .TP ${\fIparameter\fP\fB:\-\fP\fIword\fP} \fBUse Default Values\fP. If .I parameter is unset or null, the expansion of .I word -is substituted. Otherwise, the value of +is substituted. +Otherwise, the value of .I parameter is substituted. .TP @@ -3155,22 +3673,25 @@ If is unset or null, the expansion of .I word is assigned to +.IR parameter , +and the expansion is the final value of .IR parameter . -The value of -.I parameter -is then substituted. Positional parameters and special parameters may -not be assigned to in this way. +Positional parameters and special parameters may +not be assigned in this way. .TP ${\fIparameter\fP\fB:?\fP\fIword\fP} \fBDisplay Error if Null or Unset\fP. If .I parameter -is null or unset, the expansion of \fIword\fP (or a message to that effect +is null or unset, the shell writes +the expansion of \fIword\fP (or a message to that effect if .I word -is not present) is written to the standard error and the shell, if it -is not interactive, exits. Otherwise, the value of \fIparameter\fP is -substituted. +is not present) to the standard error and, if it +is not interactive, exits with a non-zero status. +An interactive shell does not exit, but does not execute the command +associated with the expansion. +Otherwise, the value of \fIparameter\fP is substituted. .TP ${\fIparameter\fP\fB:+\fP\fIword\fP} \fBUse Alternate Value\fP. @@ -3179,27 +3700,34 @@ If is null or unset, nothing is substituted, otherwise the expansion of .I word is substituted. +The value of \fIparameter\fP is not used. .TP -${\fIparameter\fP\fB:\fP\fIoffset\fP} .PD 0 +${\fIparameter\fP\fB:\fP\fIoffset\fP} .TP -${\fIparameter\fP\fB:\fP\fIoffset\fP\fB:\fP\fIlength\fP} .PD +${\fIparameter\fP\fB:\fP\fIoffset\fP\fB:\fP\fIlength\fP} \fBSubstring Expansion\fP. Expands to up to \fIlength\fP characters of the value of \fIparameter\fP starting at the character specified by \fIoffset\fP. If \fIparameter\fP is \fB@\fP or \fB*\fP, an indexed array subscripted by \fB@\fP or \fB*\fP, or an associative array name, the results differ as described below. -If \fIlength\fP is omitted, expands to the substring of the value of +If \fB:\fP\fIlength\fP is omitted (the first form above), this +expands to the substring of the value of \fIparameter\fP starting at the character specified by \fIoffset\fP and extending to the end of the value. +If \fIoffset\fP is omitted, +it is treated as 0. +If \fIlength\fP is omitted, +but the colon after \fIoffset\fP is present, +it is treated as 0. \fIlength\fP and \fIoffset\fP are arithmetic expressions (see .SM .B ARITHMETIC EVALUATION below). -.sp 1 +.IP If \fIoffset\fP evaluates to a number less than zero, the value is used as an offset in characters from the end of the value of \fIparameter\fP. @@ -3210,15 +3738,15 @@ a number of characters, and the expansion is the characters between \fIoffset\fP and that result. Note that a negative offset must be separated from the colon by at least one space to avoid being confused with the \fB:-\fP expansion. -.sp 1 +.IP If \fIparameter\fP is \fB@\fP or \fB*\fP, the result is \fIlength\fP positional parameters beginning at \fIoffset\fP. A negative \fIoffset\fP is taken relative to one greater than the greatest positional parameter, so an offset of \-1 evaluates to the last positional -parameter. +parameter (or 0 if there are no positional parameters). It is an expansion error if \fIlength\fP evaluates to a number less than zero. -.sp 1 +.IP If \fIparameter\fP is an indexed array name subscripted by @ or *, the result is the \fIlength\fP members of the array beginning with ${\fIparameter\fP[\fIoffset\fP]}. @@ -3226,17 +3754,17 @@ A negative \fIoffset\fP is taken relative to one greater than the maximum index of the specified array. It is an expansion error if \fIlength\fP evaluates to a number less than zero. -.sp 1 +.IP Substring expansion applied to an associative array produces undefined results. -.sp 1 +.IP Substring indexing is zero-based unless the positional parameters are used, in which case the indexing starts at 1 by default. If \fIoffset\fP is 0, and the positional parameters are used, \fB$0\fP is prefixed to the list. .TP -${\fB!\fP\fIprefix\fP\fB*\fP} .PD 0 +${\fB!\fP\fIprefix\fP\fB*\fP} .TP ${\fB!\fP\fIprefix\fP\fB@\fP} .PD @@ -3249,8 +3777,8 @@ special variable. When \fI@\fP is used and the expansion appears within double quotes, each variable name expands to a separate word. .TP -${\fB!\fP\fIname\fP[\fI@\fP]} .PD 0 +${\fB!\fP\fIname\fP[\fI@\fP]} .TP ${\fB!\fP\fIname\fP[\fI*\fP]} .PD @@ -3264,7 +3792,7 @@ key expands to a separate word. .TP ${\fB#\fP\fIparameter\fP} \fBParameter length\fP. -The length in characters of the value of \fIparameter\fP is substituted. +Substitutes the length in characters of the expanded value of \fIparameter\fP. If .I parameter is @@ -3286,8 +3814,8 @@ interpreted as relative to one greater than the maximum index of \fIparameter\fP, so negative indices count back from the end of the array, and an index of \-1 references the last element. .TP -${\fIparameter\fP\fB#\fP\fIword\fP} .PD 0 +${\fIparameter\fP\fB#\fP\fIword\fP} .TP ${\fIparameter\fP\fB##\fP\fIword\fP} .PD @@ -3298,15 +3826,18 @@ is expanded to produce a pattern just as in pathname expansion, and matched against the expanded value of .I parameter using the rules described under -.B Pattern Matching +.B "Pattern Matching" below. If the pattern matches the beginning of the value of .IR parameter , then the result of the expansion is the expanded value of .I parameter -with the shortest matching pattern (the ``\fB#\fP'' case) or the -longest matching pattern (the ``\fB##\fP'' case) deleted. +with the shortest matching pattern (the +.Q # +case) or the longest matching pattern (the +.Q ## +case) deleted. If .I parameter is @@ -3324,8 +3855,8 @@ or the pattern removal operation is applied to each member of the array in turn, and the expansion is the resultant list. .TP -${\fIparameter\fP\fB%\fP\fIword\fP} .PD 0 +${\fIparameter\fP\fB%\fP\fIword\fP} .TP ${\fIparameter\fP\fB%%\fP\fIword\fP} .PD @@ -3334,14 +3865,17 @@ The \fIword\fP is expanded to produce a pattern just as in pathname expansion, and matched against the expanded value of .I parameter using the rules described under -.B Pattern Matching +.B "Pattern Matching" below. If the pattern matches a trailing portion of the expanded value of .IR parameter , then the result of the expansion is the expanded value of .I parameter -with the shortest matching pattern (the ``\fB%\fP'' case) or the -longest matching pattern (the ``\fB%%\fP'' case) deleted. +with the shortest matching pattern (the +.Q % +case) or the longest matching pattern (the +.Q %% +case) deleted. If .I parameter is @@ -3359,8 +3893,8 @@ or the pattern removal operation is applied to each member of the array in turn, and the expansion is the resultant list. .TP -${\fIparameter\fP\fB/\fP\fIpattern\fP\fB/\fP\fIstring\fP} .PD 0 +${\fIparameter\fP\fB/\fP\fIpattern\fP\fB/\fP\fIstring\fP} .TP ${\fIparameter\fP\fB//\fP\fIpattern\fP\fB/\fP\fIstring\fP} .TP @@ -3369,37 +3903,37 @@ ${\fIparameter\fP\fB/#\fP\fIpattern\fP\fB/\fP\fIstring\fP} ${\fIparameter\fP\fB/%\fP\fIpattern\fP\fB/\fP\fIstring\fP} .PD \fBPattern substitution\fP. -The \fIpattern\fP is expanded to produce a pattern just as in -pathname expansion. -\fIParameter\fP is expanded and the longest match of \fIpattern\fP -against its value is replaced with \fIstring\fP. +The \fIpattern\fP is expanded to produce a pattern +and matched against the expanded value of \fIparameter\fP +as described under +.B "Pattern Matching" +below. +The longest match of \fIpattern\fP +in the expanded value is replaced with \fIstring\fP. \fIstring\fP undergoes tilde expansion, parameter and variable expansion, arithmetic expansion, command and process substitution, and quote removal. -The match is performed using the rules described under -.B Pattern Matching -below. +.IP In the first form above, only the first match is replaced. -If there are two slashes separating \fIparameter\fP and \fIpattern\fP +If there are two slashes separating \fIparameter\fP and \fIpattern\fP (the second form above), all matches of \fIpattern\fP are replaced with \fIstring\fP. If \fIpattern\fP is preceded by \fB#\fP (the third form above), it must match at the beginning of the expanded value of \fIparameter\fP. If \fIpattern\fP is preceded by \fB%\fP (the fourth form above), it must match at the end of the expanded value of \fIparameter\fP. +.IP If the expansion of \fIstring\fP is null, -matches of \fIpattern\fP are deleted. -If \fIstring\fP is null, matches of \fIpattern\fP are deleted and the \fB/\fP following \fIpattern\fP may be omitted. -.sp 1 +.IP If the \fBpatsub_replacement\fP shell option is enabled using \fBshopt\fP, any unquoted instances of \fB&\fP in \fIstring\fP are replaced with the matching portion of \fIpattern\fP. -.sp 1 +.IP Quoting any part of \fIstring\fP inhibits replacement in the expansion of the quoted portion, including replacement strings stored in shell variables. -Backslash will escape \fB&\fP in \fIstring\fP; the backslash is removed +Backslash escapes \fB&\fP in \fIstring\fP; the backslash is removed in order to permit a literal \fB&\fP in the replacement string. Backslash can also be used to escape a backslash; \fB\e\e\fP results in a literal backslash in the replacement. @@ -3411,11 +3945,18 @@ expanding \fIstring\fP; shell programmers should quote any occurrences of \fB&\fP they want to be taken literally in the replacement and ensure any instances of \fB&\fP they want to be replaced are unquoted. -.sp 1 +.IP +Like the pattern removal operators, double quotes surrounding the +replacement string quote the expanded characters, while double quotes +enclosing the entire parameter substitution do not, since +the expansion is performed in a +context that doesn't take any enclosing double quotes into account. +.IP If the .B nocasematch shell option is enabled, the match is performed without regard to the case of alphabetic characters. +.IP If .I parameter is @@ -3433,10 +3974,10 @@ or the substitution operation is applied to each member of the array in turn, and the expansion is the resultant list. .TP -${\fIparameter\fP\fB^\fP\fIpattern\fP} .PD 0 +${\fIparameter\fP\fB\*^\fP\fIpattern\fP} .TP -${\fIparameter\fP\fB^^\fP\fIpattern\fP} +${\fIparameter\fP\fB\*^\*^\fP\fIpattern\fP} .TP ${\fIparameter\fP\fB,\fP\fIpattern\fP} .TP @@ -3444,19 +3985,32 @@ ${\fIparameter\fP\fB,,\fP\fIpattern\fP} .PD \fBCase modification\fP. This expansion modifies the case of alphabetic characters in \fIparameter\fP. -The \fIpattern\fP is expanded to produce a pattern just as in -pathname expansion. -Each character in the expanded value of \fIparameter\fP is tested against -\fIpattern\fP, and, if it matches the pattern, its case is converted. +First, the \fIpattern\fP is expanded to produce a pattern +as described below under +.SM +.BR "Pattern Matching" . +.B Bash +then examines characters in the expanded value of \fIparameter\fP +against \fIpattern\fP as described below. +If a character matches the pattern, its case is converted. The pattern should not attempt to match more than one character. -The \fB^\fP operator converts lowercase letters matching \fIpattern\fP -to uppercase; the \fB,\fP operator converts matching uppercase letters -to lowercase. -The \fB^^\fP and \fB,,\fP expansions convert each matched character in the -expanded value; the \fB^\fP and \fB,\fP expansions match and convert only -the first character in the expanded value. +.IP +Using +.Q \*^ +converts lowercase letters matching \fIpattern\fP to uppercase; +.Q , +converts matching uppercase letters to lowercase. +The +\fB\*^\fP and \fB,\fP variants +examine the first character in the expanded value +and convert its case if it matches \fIpattern\fP; +the +\fB\*^\*^\fP and \fB,,\fP variants +examine all characters in the expanded value +and convert each one that matches \fIpattern\fP. If \fIpattern\fP is omitted, it is treated like a \fB?\fP, which matches every character. +.IP If .I parameter is @@ -3474,14 +4028,14 @@ or the case modification operation is applied to each member of the array in turn, and the expansion is the resultant list. .TP +.PD 0 ${\fIparameter\fP\fB@\fP\fIoperator\fP} \fBParameter transformation\fP. The expansion is either a transformation of the value of \fIparameter\fP or information about \fIparameter\fP itself, depending on the value of \fIoperator\fP. Each \fIoperator\fP is a single letter: -.sp 1 +.PP .RS -.PD 0 .TP .B U The expansion is a string that is the value of \fIparameter\fP with lowercase @@ -3501,7 +4055,8 @@ format that can be reused as input. .TP .B E The expansion is a string that is the value of \fIparameter\fP with backslash -escape sequences expanded as with the \fB$\(aq...\(aq\fP quoting mechanism. +escape sequences expanded as with the \fB$\*'\fP.\|.\|.\%\fB\*'\fP +quoting mechanism. .TP .B P The expansion is a string that is the result of expanding the value of @@ -3510,13 +4065,14 @@ The expansion is a string that is the result of expanding the value of .B A The expansion is a string in the form of an assignment statement or \fBdeclare\fP command that, if -evaluated, will recreate \fIparameter\fP with its attributes and value. +evaluated, recreates \fIparameter\fP with its attributes and value. .TP .B K Produces a possibly-quoted version of the value of \fIparameter\fP, except that it prints the values of indexed and associative arrays as a sequence of quoted key-value pairs (see \fBArrays\fP above). +The keys and values are quoted in a format that can be reused as input. .TP .B a The expansion is a string consisting of flag values representing @@ -3543,20 +4099,21 @@ or .BR * , the operation is applied to each member of the array in turn, and the expansion is the resultant list. -.sp 1 +.PP The result of the expansion is subject to word splitting and pathname expansion as described below. .RE .SS Command Substitution \fICommand substitution\fP allows the output of a command to replace -the command name. There are two forms: +the command itself. +There are two standard forms: .RS .PP \fB$(\fP\fIcommand\fP\|\fB)\fP .RE -or +or (deprecated) .RS -\fB\`\fP\fIcommand\fP\fB\`\fP +\fB\`\fP\fIcommand\fP\fB\`\fP. .RE .PP .B Bash @@ -3568,7 +4125,7 @@ word splitting. The command substitution \fB$(cat \fIfile\fP)\fR can be replaced by the equivalent but faster \fB$(< \fIfile\fP)\fR. .PP -When the old-style backquote form of substitution is used, +With the old-style backquote form of substitution, backslash retains its literal meaning except when followed by .BR $ , .BR \` , @@ -3579,14 +4136,55 @@ command substitution. When using the $(\^\fIcommand\fP\|) form, all characters between the parentheses make up the command; none are treated specially. .PP +There is an alternate form of command substitution: +.RS +.PP +\fB${\fP\fIc\fP \fIcommand\fP\fB;\fP\|\fB}\fP +.RE +.PP +which executes \fIcommand\fP in the current execution environment +and captures its output, again with trailing newlines removed. +.PP +The character \fIc\fP following the open brace must be a space, tab, +newline, or \fB|\fP, and the close brace must be in a position +where a reserved word may appear (i.e., preceded by a command terminator +such as semicolon). +\fBBash\fP allows the close brace to be joined to the remaining characters in +the word without being followed by a shell metacharacter as a reserved +word would usually require. +.PP +Any side effects of \fIcommand\fP take effect immediately +in the current execution environment and persist in the current +environment after the command completes (e.g., the \fBexit\fP builtin +exits the shell). +.PP +This type of command substitution superficially resembles executing an +unnamed shell function: local variables are created as when a shell +function is executing, and the \fBreturn\fP builtin forces +\fIcommand\fP to complete; +however, the rest of the execution environment, +including the positional parameters, is shared with the caller. +.PP +If the first character following the open brace +is a \fB|\fP, the construct expands to the +value of the \fBREPLY\fP shell variable after \fIcommand\fP executes, +without removing any trailing newlines, +and the standard output of \fIcommand\fP remains the same as in the +calling shell. +\fBBash\fP creates \fBREPLY\fP as an initially-unset local variable when +\fIcommand\fP executes, and restores \fBREPLY\fP to the value it had +before the command substitution after \fIcommand\fP completes, +as with any local variable. +.PP Command substitutions may be nested. To nest when using the backquoted form, escape the inner backquotes with backslashes. .PP -If the substitution appears within double quotes, word splitting and -pathname expansion are not performed on the results. +If the substitution appears within double quotes, \fBbash\fP does not perform +word splitting and pathname expansion on the results. .SS Arithmetic Expansion -Arithmetic expansion allows the evaluation of an arithmetic expression -and the substitution of the result. The format for arithmetic expansion is: +Arithmetic expansion evaluates an arithmetic expression +and substitutes the result. +The format for arithmetic expansion is: .RS .PP \fB$((\fP\fIexpression\fP\fB))\fP @@ -3596,11 +4194,16 @@ The .I expression undergoes the same expansions as if it were within double quotes, -but double quote characters in \fIexpression\fP are not treated specially -and are removed. +but unescaped double quote characters +in \fIexpression\fP are not treated +specially and are removed. All tokens in the expression undergo parameter and variable expansion, command substitution, and quote removal. The result is treated as the arithmetic expression to be evaluated. +Since the way Bash handles double quotes +can potentially result in empty strings, +arithmetic expansion treats +those as expressions that evaluate to 0. Arithmetic expansions may be nested. .PP The evaluation is performed according to the rules listed below under @@ -3610,7 +4213,9 @@ If .I expression is invalid, .B bash -prints a message indicating failure and no substitution occurs. +prints a message to standard error indicating failure, +does not perform the substitution, +and does not execute the command associated with the expansion. .SS Process Substitution \fIProcess substitution\fP allows a process's input or output to be referred to using a filename. @@ -3623,12 +4228,19 @@ appears as a filename. This filename is passed as an argument to the current command as the result of the expansion. -If the \fB>(\fP\fIlist\^\fP\fB)\fP form is used, writing to -the file will provide input for \fIlist\fP. If the -\fB<(\fP\fIlist\^\fP\fB)\fP form is used, the file passed as an -argument should be read to obtain the output of \fIlist\fP. +.PP +If the +\fB>(\fP\fIlist\^\fP\fB)\fP form is used, writing to +the file provides input for \fIlist\fP. +If the +\fB<(\fP\fIlist\^\fP\fB)\fP form is used, reading the file +obtains the output of \fIlist\fP. +No space may appear between the \fB<\fP or \fB>\fP +and the left parenthesis, otherwise the construct would be interpreted +as a redirection. +.PP Process substitution is supported on systems that support named -pipes (\fIFIFOs\fP) or the \fB/dev/fd\fP method of naming open files. +pipes (\fIFIFOs\fP) or the \fI/dev/fd\fP method of naming open files. .PP When available, process substitution is performed simultaneously with parameter and variable expansion, @@ -3642,83 +4254,77 @@ and arithmetic expansion that did not occur within double quotes for .IR "word splitting" . +Words that were not expanded are not split. .PP The shell treats each character of .SM .B IFS -as a delimiter, and splits the results of the other -expansions into words using these characters as field terminators. -If -.SM -.B IFS -is unset, or its -value is exactly -.BR , -the default, then -sequences of -.BR , -.BR , -and -.B -at the beginning and end of the results of the previous -expansions are ignored, and -any sequence of +as a delimiter, +and splits the results of the other expansions into words +using these characters as field terminators. +.PP +An \fIIFS whitespace\fP character is whitespace as defined above +(see \fBDefinitions\fP) that appears in the value of .SM -.B IFS -characters not at the beginning or end serves to delimit words. +.BR IFS . +Space, tab, and newline are always considered IFS whitespace, even +if they don't appear in the locale's \fBspace\fP category. +.PP If .SM .B IFS -has a value other than the default, then sequences of -the whitespace characters -.BR space , -.BR tab , -and -.B newline -are ignored at the beginning and end of the -word, as long as the whitespace character is in the -value of -.SM -.B IFS -(an -.SM -.B IFS -whitespace character). -Any character in -.SM -.B IFS -that is not +is unset, field splitting acts as if its value were +.BR , +and treats these characters as IFS whitespace. +If the value of .SM .B IFS -whitespace, along with any adjacent +is null, no word splitting occurs, +but implicit null arguments (see below) are still removed. +.PP +Word splitting begins by removing sequences of IFS whitespace characters +from the beginning and end of the results of the previous expansions, +then splits the remaining words. +.PP +If the value of .SM .B IFS -whitespace characters, delimits a field. -A sequence of +consists solely of IFS whitespace, +any sequence of IFS whitespace characters delimits a field, +so a field consists of characters that are not unquoted IFS +whitespace, and null fields result only from quoting. +.PP +If .SM .B IFS -whitespace characters is also treated as a delimiter. -If the value of +contains a non-whitespace character, then any character in +the value of .SM .B IFS -is null, no word splitting occurs. -.PP -Explicit null arguments (\^\f3"\^"\fP or \^\f3\(aq\^\(aq\fP\^) are retained +that is not IFS whitespace, +along with any adjacent IFS whitespace characters, delimits a field. +This means that adjacent non-IFS-whitespace delimiters produce a +null field. +A sequence of IFS whitespace characters also delimits a field. +.PP +Explicit null arguments (\^\fB\*"\^\*"\fP or +\^\fB\*'\^\*'\fP\^) are retained and passed to commands as empty strings. Unquoted implicit null arguments, resulting from the expansion of parameters that have no values, are removed. -If a parameter with no value is expanded within double quotes, a -null argument results and is retained -and passed to a command as an empty string. +Expanding a parameter with no value within double quotes +produces a null field, +which is retained and passed to a command as an empty string. +.PP When a quoted null argument appears as part of a word whose expansion is -non-null, the null argument is removed. +non-null, word splitting removes the null argument portion, +leaving the non-null expansion. That is, the word -\f(CW\-d\(aq\^\(aq\fP becomes \f(CW\-d\fP after word splitting and -null argument removal. -.PP -Note that if no expansion occurs, no splitting -is performed. -.SS Pathname Expansion +.Q "\-d\*'\^\*'" +becomes +.Q \-d +after word splitting and null argument removal. +.SS "Pathname Expansion" After word splitting, unless the .B \-f @@ -3732,12 +4338,13 @@ and If one of these characters appears, and is not quoted, then the word is regarded as a .IR pattern , -and replaced with an alphabetically sorted list of -filenames matching the pattern +and replaced with a sorted list of filenames matching the pattern (see .SM .B "Pattern Matching" -below). +below) +subject to the value of the \fBGLOBSORT\fP shell variable. +.PP If no matching filenames are found, and the shell option .B nullglob @@ -3748,49 +4355,55 @@ option is set, and no matches are found, the word is removed. If the .B failglob -shell option is set, and no matches are found, an error message -is printed and the command is not executed. +shell option is set, and no matches are found, +\fBbash\fP prints an error message and does not execute the command. If the shell option .B nocaseglob is enabled, the match is performed without regard to the case of alphabetic characters. +.PP When a pattern is used for pathname expansion, the character -.B ``.'' +.Q .\& at the start of a name or immediately following a slash must be matched explicitly, unless the shell option .B dotglob is set. In order to match the filenames -.B ``.'' +.FN .\& and -.BR ``..'' , -the pattern must begin with ``.'' (for example, ``.?''), +.FN ..\& , +the pattern must begin with +.Q .\& +(for example, +.Q .?\& ), even if .B dotglob is set. If the .B globskipdots shell option is enabled, the filenames -.B ``.'' +.FN .\& and -.BR ``..'' -are never matched, even if the pattern begins with a -.BR ``.'' . +.FN ..\& +never match, even if the pattern begins with a +.Q .\& . When not matching pathnames, the -.B ``.'' +.Q .\& character is not treated specially. +.PP When matching a pathname, the slash character must always be matched explicitly by a slash in the pattern, but in other matching contexts it can be matched by a special pattern character as described below under .SM .BR "Pattern Matching" . +.PP See the description of .B shopt below under .SM -.B SHELL BUILTIN COMMANDS +.B "SHELL BUILTIN COMMANDS" for a description of the .BR nocaseglob , .BR nullglob , @@ -3817,42 +4430,54 @@ If the \fBnocaseglob\fP option is set, the matching against the patterns in .B GLOBIGNORE is performed without regard to case. The filenames -.B ``.'' +.FN .\& and -.B ``..'' +.FN ..\& are always ignored when .SM .B GLOBIGNORE -is set and not null. However, setting +is set and not null. +However, setting .SM .B GLOBIGNORE to a non-null value has the effect of enabling the .B dotglob shell option, so all other filenames beginning with a -.B ``.'' -will match. +.Q .\& +match. To get the old behavior of ignoring filenames beginning with a -.BR ``.'' , +.Q .\& , make -.B ``.*'' +.Q .* one of the patterns in .SM -.BR GLOBIGNORE . +.B GLOBIGNORE\c +\&. The .B dotglob option is disabled when .SM .B GLOBIGNORE is unset. -The pattern matching honors the setting of the \fBextglob\fP shell +The +.B GLOBIGNORE +pattern matching honors the setting of the \fBextglob\fP shell option. .PP -\fBPattern Matching\fP +The value of the +.SM +.B GLOBSORT +shell variable controls how the results of pathname expansion are sorted, +as described above under +.BR "Shell Variables" . +.PP +.B "Pattern Matching" .PP Any character that appears in a pattern, other than the special pattern -characters described below, matches itself. The NUL character may not -occur in a pattern. A backslash escapes the following character; the -escaping backslash is discarded when matching. +characters described below, matches itself. +The NUL character may not occur in a pattern. +A backslash escapes the following character; the escaping backslash is +discarded when matching. The special pattern characters must be quoted if they are to be matched literally. .PP @@ -3865,31 +4490,40 @@ The special pattern characters have the following meanings: Matches any string, including the null string. When the \fBglobstar\fP shell option is enabled, and \fB*\fP is used in a pathname expansion context, two adjacent \fB*\fPs used as a single -pattern will match all files and zero or more directories and +pattern match all files and zero or more directories and subdirectories. -If followed by a \fB/\fP, two adjacent \fB*\fPs will match only directories +If followed by a \fB/\fP, two adjacent \fB*\fPs match only directories and subdirectories. .TP .B ? Matches any single character. .TP -.B [...] -Matches any one of the enclosed characters. A pair of characters -separated by a hyphen denotes a +.BR [ .\|.\|. ] +.PD +Matches any one of the characters enclosed between the brackets. +This is known as a \fIbracket expression\fP +and matches a single character. +A pair of characters separated by a hyphen denotes a \fIrange expression\fP; any character that falls between those two characters, inclusive, -using the current locale's collating sequence and character set, -is matched. If the first character following the +using the current locale's collating sequence and character set, matches. +If the first character following the .B [ is a .B ! or a -.B ^ -then any character not enclosed is matched. +.B \*^ +then any character not within the range matches. +To match a +.BR \- , +include it as the first or last character in the set. +To match a +.BR ] , +include it as the first character in the set. +.IP The sorting order of characters in range expressions, and the characters included in the range, -are determined by -the current locale and the values of the +are determined by the current locale and the values of the .SM .B LC_COLLATE or @@ -3900,62 +4534,44 @@ To obtain the traditional interpretation of range expressions, where .B [a\-d] is equivalent to .BR [abcd] , -set value of the +set the value of the +.B LC_COLLATE +or .B LC_ALL -shell variable to +shell variables to .BR C , or enable the .B globasciiranges shell option. -A -.B \- -may be matched by including it as the first or last character -in the set. -A -.B ] -may be matched by including it as the first character -in the set. -.br -.if t .sp 0.5 -.if n .sp 1 -Within -.B [ -and -.BR ] , +.IP +Within a bracket expression, \fIcharacter classes\fP can be specified using the syntax \fB[:\fP\fIclass\fP\fB:]\fP, where \fIclass\fP is one of the -following classes defined in the POSIX standard: -.PP +following classes defined in the +.SM POSIX +standard: +.IP .RS .B -.if n alnum alpha ascii blank cntrl digit graph lower print punct space upper word xdigit -.if t alnum alpha ascii blank cntrl digit graph lower print punct space upper word xdigit -.br +.if n alnum alpha ascii blank cntrl digit graph lower print punct space \ +upper word xdigit +.if t alnum alpha ascii blank cntrl digit graph lower \ +print punct space upper word xdigit +.RE +.IP A character class matches any character belonging to that class. The \fBword\fP character class matches letters, digits, and the character _. -.br -.if t .sp 0.5 -.if n .sp 1 -Within -.B [ -and -.BR ] , +.IP +Within a bracket expression, an \fIequivalence class\fP can be specified using the syntax \fB[=\fP\fIc\fP\fB=]\fP, which matches all characters with the same collation weight (as defined by the current locale) as the character \fIc\fP. -.br -.if t .sp 0.5 -.if n .sp 1 -Within -.B [ -and -.BR ] , +.IP +Within a bracket expression, the syntax \fB[.\fP\fIsymbol\fP\fB.]\fP matches the collating symbol \fIsymbol\fP. .RE -.RE -.PD .PP If the \fBextglob\fP shell option is enabled using the \fBshopt\fP builtin, the shell recognizes several extended pattern matching operators. @@ -3963,28 +4579,28 @@ In the following description, a \fIpattern-list\fP is a list of one or more patterns separated by a \fB|\fP. Composite patterns may be formed using one or more of the following sub-patterns: -.sp 1 +.PP .PD 0 .RS .TP \fB?(\fP\^\fIpattern-list\^\fP\fB)\fP -Matches zero or one occurrence of the given patterns +Matches zero or one occurrence of the given patterns. .TP \fB*(\fP\^\fIpattern-list\^\fP\fB)\fP -Matches zero or more occurrences of the given patterns +Matches zero or more occurrences of the given patterns. .TP \fB+(\fP\^\fIpattern-list\^\fP\fB)\fP -Matches one or more occurrences of the given patterns +Matches one or more occurrences of the given patterns. .TP \fB@(\fP\^\fIpattern-list\^\fP\fB)\fP -Matches one of the given patterns +Matches one of the given patterns. .TP \fB!(\fP\^\fIpattern-list\^\fP\fB)\fP -Matches anything except one of the given patterns +Matches anything except one of the given patterns. .RE .PD .PP -The\fBextglob\fP option changes the behavior of the parser, since the +The \fBextglob\fP option changes the behavior of the parser, since the parentheses are normally treated as operators with syntactic meaning. To ensure that extended matching patterns are parsed correctly, make sure that \fBextglob\fP is enabled before parsing constructs containing the @@ -3993,12 +4609,28 @@ patterns, including shell functions and command substitutions. When matching filenames, the \fBdotglob\fP shell option determines the set of filenames that are tested: when \fBdotglob\fP is enabled, the set of filenames includes all files -beginning with ``.'', but ``.'' and ``..'' must be matched by a -pattern or sub-pattern that begins with a dot; +beginning with +.Q .\& , +but +.FN .\& +and +.FN ..\& +must be matched by a pattern or sub-pattern that begins with a dot; when it is disabled, the set does not -include any filenames beginning with ``.'' unless the pattern -or sub-pattern begins with a ``.''. -As above, ``.'' only has a special meaning when matching filenames. +include any filenames beginning with +.Q .\& +unless the pattern or sub-pattern begins with a +.Q .\& . +If the +.B globskipdots +shell option is enabled, the filenames +.FN .\& +and +.FN ..\& +never appear in the set. +As above, +.Q .\& +only has a special meaning when matching filenames. .PP Complicated extended pattern matching against long strings is slow, especially when the patterns contain alternations and the strings @@ -4009,20 +4641,19 @@ strings instead of a single long string, may be faster. After the preceding expansions, all unquoted occurrences of the characters .BR \e , -.BR \(aq , -and \^\f3"\fP\^ that did not result from one of the above +.BR \*' , +and \^\fB\*"\fP\^ that did not result from one of the above expansions are removed. .SH REDIRECTION -Before a command is executed, its input and output -may be +Before a command is executed, its input and output may be .I redirected using a special notation interpreted by the shell. \fIRedirection\fP allows commands' file handles to be duplicated, opened, closed, made to refer to different files, and can change the files the command reads from and writes to. -Redirection may also be used to modify file handles in the -current shell execution environment. +When used with the \fBexec\fP builtin, +redirections modify file handles in the current shell execution environment. The following redirection operators may precede or appear anywhere within a .I simple command @@ -4034,35 +4665,46 @@ left to right. Each redirection that may be preceded by a file descriptor number may instead be preceded by a word of the form {\fIvarname\fP}. In this case, for each redirection operator except ->&- and <&-, the shell will allocate a file descriptor greater -than or equal to 10 and assign it to \fIvarname\fP. -If >&- or <&- is preceded -by {\fIvarname\fP}, the value of \fIvarname\fP defines the file -descriptor to close. +.B >&\- +and +.BR <&\- , +the shell allocates a file descriptor greater +than or equal to 10 and assigns it to \fIvarname\fP. +If {\fIvarname\fP} precedes +.B >&\- +or +.BR <&\- , +the value of \fIvarname\fP defines the file descriptor to close. If {\fIvarname\fP} is supplied, the redirection persists beyond -the scope of the command, allowing the shell programmer to manage -the file descriptor's lifetime manually. +the scope of the command, which allows the shell programmer to +manage the file descriptor's lifetime manually without using +the \fBexec\fP builtin. The \fBvarredir_close\fP shell option manages this behavior. .PP In the following descriptions, if the file descriptor number is omitted, and the first character of the redirection operator is -.BR < , -the redirection refers to the standard input (file descriptor -0). If the first character of the redirection operator is -.BR > , -the redirection refers to the standard output (file descriptor -1). +.Q < , +the redirection refers to the standard input (file descriptor 0). +If the first character of the redirection operator is +.Q > , +the redirection refers to the standard output (file descriptor 1). .PP -The word following the redirection operator in the following +The \fIword\fP following the redirection operator in the following descriptions, unless otherwise noted, is subjected to -brace expansion, tilde expansion, parameter and variable expansion, -command substitution, arithmetic expansion, quote removal, -pathname expansion, and word splitting. +brace expansion, +tilde expansion, +parameter and variable expansion, +command substitution, +arithmetic expansion, +quote removal, +pathname expansion, +and word splitting. If it expands to more than one word, .B bash reports an error. .PP -Note that the order of redirections is significant. For example, +The order of redirections is significant. +For example, the command .RS .PP @@ -4079,21 +4721,21 @@ ls 2\fB>&\fP1 \fB>\fP dirlist .PP directs only the standard output to file .IR dirlist , -because the standard error was duplicated from the standard output +because the standard error was directed to the standard output before the standard output was redirected to .IR dirlist . .PP \fBBash\fP handles several filenames specially when they are used in redirections, as described in the following table. If the operating system on which \fBbash\fP is running provides these -special files, bash will use them; otherwise it will emulate them +special files, \fBbash\fP uses them; otherwise it emulates them internally with the behavior described below. .RS .PP .PD 0 .TP .B /dev/fd/\fIfd\fP -If \fIfd\fP is a valid integer, file descriptor \fIfd\fP is duplicated. +If \fIfd\fP is a valid integer, duplicate file descriptor \fIfd\fP. .TP .B /dev/stdin File descriptor 0 is duplicated. @@ -4122,10 +4764,10 @@ Redirections using file descriptors greater than 9 should be used with care, as they may conflict with file descriptors the shell uses internally. .SS Redirecting Input -Redirection of input causes the file whose name results from +Redirecting input opens the file whose name results from the expansion of .I word -to be opened for reading on file descriptor +for reading on file descriptor .IR n , or the standard input (file descriptor 0) if .I n @@ -4137,14 +4779,15 @@ The general format for redirecting input is: [\fIn\fP]\fB<\fP\fIword\fP .RE .SS Redirecting Output -Redirection of output causes the file whose name results from +Redirecting output opens the file whose name results from the expansion of .I word -to be opened for writing on file descriptor +for writing on file descriptor .IR n , or the standard output (file descriptor 1) if .I n -is not specified. If the file does not exist it is created; +is not specified. +If the file does not exist it is created; if it does exist it is truncated to zero size. .PP The general format for redirecting output is: @@ -4159,7 +4802,7 @@ and the .B noclobber option to the .B set -builtin has been enabled, the redirection will fail if the file +builtin command has been enabled, the redirection fails if the file whose name results from the expansion of \fIword\fP exists and is a regular file. If the redirection operator is @@ -4170,18 +4813,19 @@ and the .B noclobber option to the .B set -builtin command is not enabled, the redirection is attempted even -if the file named by \fIword\fP exists. +builtin is not enabled, +\fBbash\fP attempts the redirection +even if the file named by \fIword\fP exists. .SS Appending Redirected Output -Redirection of output in this fashion -causes the file whose name results from -the expansion of +Redirecting output in this fashion opens +the file whose name results from the expansion of .I word -to be opened for appending on file descriptor +for appending on file descriptor .IR n , or the standard output (file descriptor 1) if .I n -is not specified. If the file does not exist it is created. +is not specified. +If the file does not exist it is created. .PP The general format for appending output is: .RS @@ -4189,11 +4833,10 @@ The general format for appending output is: [\fIn\fP]\fB>>\fP\fIword\fP .RE .SS Redirecting Standard Output and Standard Error -This construct allows both the +This construct redirects both the standard output (file descriptor 1) and the standard error output (file descriptor 2) -to be redirected to the file whose name is the -expansion of +to the file whose name is the expansion of .IR word . .PP There are two formats for redirecting standard output and @@ -4215,15 +4858,15 @@ This is semantically equivalent to .RE .PP When using the second form, \fIword\fP may not expand to a number or -\fB\-\fP. If it does, other redirection operators apply +\fB\-\fP. +If it does, other redirection operators apply (see \fBDuplicating File Descriptors\fP below) for compatibility reasons. .SS Appending Standard Output and Standard Error -This construct allows both the +This construct appends both the standard output (file descriptor 1) and the standard error output (file descriptor 2) -to be appended to the file whose name is the -expansion of +to the file whose name is the expansion of .IR word . .PP The format for appending standard output and standard error is: @@ -4241,11 +4884,10 @@ This is semantically equivalent to (see \fBDuplicating File Descriptors\fP below). .SS Here Documents This type of redirection instructs the shell to read input from the -current source until a line containing only +current source until it reads a line containing only .I delimiter -(with no trailing blanks) -is seen. All of -the lines read up to that point are then used as the standard +(with no trailing blanks). +All of the lines read up to that point then become the standard input (or file descriptor \fIn\fP if \fIn\fP is specified) for a command. .PP The format of here-documents is: @@ -4258,9 +4900,11 @@ The format of here-documents is: .fi .RE .PP -No parameter and variable expansion, command substitution, -arithmetic expansion, or pathname expansion is performed on +The shell does not perform +parameter and variable expansion, command substitution, +arithmetic expansion, or pathname expansion on .IR word . +.PP If any part of .I word is quoted, the @@ -4268,27 +4912,38 @@ is quoted, the is the result of quote removal on .IR word , and the lines in the here-document are not expanded. -If \fIword\fP is unquoted, +If \fIword\fP is unquoted, the +.I delimiter +is \fIword\fP itself, +and the here-document text is treated similarly to a double-quoted string: all lines of the here-document are subjected to parameter expansion, command substitution, and arithmetic expansion, the character sequence .B \e -is ignored, and +is treated literally, and .B \e must be used to quote the characters .BR \e , .BR $ , and -.BR \` . +.BR \` ; +however, double quote characters have no special meaning. .PP If the redirection operator is .BR <<\- , -then all leading tab characters are stripped from input lines and the -line containing +then the shell strips all leading tab characters from input lines +and the line containing .IR delimiter . This allows here-documents within shell scripts to be indented in a natural fashion. +.PP +If the delimiter is not quoted, the +.B \e +sequence is treated as a line continuation: the two lines are joined +and the backslash-newline is removed. +This happens while reading the here-document, before the check for +the ending delimiter, so joined lines can form the end delimiter. .SS "Here Strings" A variant of here documents, the format is: .RS @@ -4315,21 +4970,22 @@ The redirection operator is used to duplicate input file descriptors. If .I word -expands to one or more digits, the file descriptor denoted by +expands to one or more digits, file descriptor .I n is made to be a copy of that file descriptor. -If the digits in +It is a redirection error if the digits in .I word -do not specify a file descriptor open for input, a redirection error occurs. +do not specify a file descriptor open for input. If .I word evaluates to .BR \- , file descriptor .I n -is closed. If +is closed. +If .I n -is not specified, the standard input (file descriptor 0) is used. +is not specified, this uses the standard input (file descriptor 0). .PP The operator .RS @@ -4337,12 +4993,13 @@ The operator [\fIn\fP]\fB>&\fP\fIword\fP .RE .PP -is used similarly to duplicate output file descriptors. If +is used similarly to duplicate output file descriptors. +If .I n -is not specified, the standard output (file descriptor 1) is used. -If the digits in +is not specified, this uses the standard output (file descriptor 1). +It is a redirection error if the digits in .I word -do not specify a file descriptor open for output, a redirection error occurs. +do not specify a file descriptor open for output. If .I word evaluates to @@ -4350,9 +5007,10 @@ evaluates to file descriptor .I n is closed. -As a special case, if \fIn\fP is omitted, and \fIword\fP does not -expand to one or more digits or \fB\-\fP, the standard output and standard -error are redirected as described previously. +As a special case, if \fIn\fP is omitted, +and \fIword\fP does not expand to one or more digits or \fB\-\fP, +this redirects the standard output and standard error as described +previously. .SS "Moving File Descriptors" The redirection operator .RS @@ -4381,27 +5039,33 @@ The redirection operator [\fIn\fP]\fB<>\fP\fIword\fP .RE .PP -causes the file whose name is the expansion of +opens the file whose name is the expansion of .I word -to be opened for both reading and writing on file descriptor +for both reading and writing on file descriptor .IR n , or on file descriptor 0 if .I n -is not specified. If the file does not exist, it is created. +is not specified. +If the file does not exist, it is created. .SH ALIASES -\fIAliases\fP allow a string to be substituted for a word when it is used -as the first word of a simple command. -The shell maintains a list of aliases that may be set and unset with the -.B alias -and -.B unalias -builtin commands (see +\fIAliases\fP allow a string to be substituted for a word that is in +a position in the input where it can be the first word of a simple +command. +Aliases have names and corresponding values that are set +and unset using the \fBalias\fP and \fBunalias\fP builtin commands +(see .SM -.B SHELL BUILTIN COMMANDS +.B "SHELL BUILTIN COMMANDS" below). -The first word of each simple command, if unquoted, -is checked to see if it has an -alias. If so, that word is replaced by the text of the alias. +.PP +If the shell reads an unquoted word in the right position, it checks +the word to see if it matches an alias name. +If it matches, the shell +replaces the word with the alias value, and reads that value as if it +had been read instead of the word. +The shell doesn't look at any characters following the word before +attempting alias substitution. +.PP The characters \fB/\fP, \fB$\fP, \fB\`\fP, and \fB=\fP and any of the shell \fImetacharacters\fP or quoting characters listed above may not appear in an alias name. @@ -4417,10 +5081,11 @@ to for instance, and .B bash does not try to recursively expand the replacement text. +.PP If the last character of the alias value is a .IR blank , -then the next command -word following the alias is also checked for alias expansion. +the shell checks the next command +word following the alias for alias expansion. .PP Aliases are created and listed with the .B alias @@ -4432,7 +5097,7 @@ There is no mechanism for using arguments in the replacement text. If arguments are needed, use a shell function (see .SM .B FUNCTIONS -below). +below) instead. .PP Aliases are not expanded when the shell is not interactive, unless the @@ -4443,7 +5108,7 @@ shell option is set using .B shopt under .SM -\fBSHELL BUILTIN COMMANDS\fP +.B "SHELL BUILTIN COMMANDS" below). .PP The rules concerning the definition and use of aliases are @@ -4452,41 +5117,48 @@ somewhat confusing. always reads at least one complete line of input, and all lines that make up a compound command, before executing any of the commands on that line or the compound command. -Aliases are expanded when a -command is read, not when it is executed. Therefore, an +Aliases are expanded when a command is read, not when it is executed. +Therefore, an alias definition appearing on the same line as another -command does not take effect until the next line of input is read. +command does not take effect until the shell reads the next line of input, +and an alias definition in a compound command does not take +effect until the shell parses and executes the entire compound command. The commands following the alias definition -on that line are not affected by the new alias. +on that line, +or in the rest of a compound command, +are not affected by the new alias. This behavior is also an issue when functions are executed. Aliases are expanded when a function definition is read, not when the function is executed, because a function definition -is itself a command. As a consequence, aliases +is itself a command. +As a consequence, aliases defined in a function are not available until after that -function is executed. To be safe, always put +function is executed. +To be safe, always put alias definitions on a separate line, and do not use .B alias in compound commands. .PP -For almost every purpose, aliases are superseded by -shell functions. +For almost every purpose, shell functions are preferable to aliases. .SH FUNCTIONS A shell function, defined as described above under .SM .BR "SHELL GRAMMAR" , stores a series of commands for later execution. When the name of a shell function is used as a simple command name, -the list of commands associated with that function name is executed. +the shell executes +the list of commands associated with that function name. Functions are executed in the context of the -current shell; no new process is created to interpret +calling shell; there is no new process created to interpret them (contrast this with the execution of a shell script). +.PP When a function is executed, the arguments to the function become the positional parameters during its execution. The special parameter .B # -is updated to reflect the change. Special parameter \fB0\fP -is unchanged. +is updated to reflect the new positional parameters. +Special parameter \fB0\fP is unchanged. The first element of the .SM .B FUNCNAME @@ -4504,7 +5176,7 @@ traps (see the description of the .B trap builtin under .SM -.B SHELL BUILTIN COMMANDS +.B "SHELL BUILTIN COMMANDS" below) are not inherited unless the function has been given the \fBtrace\fP attribute (see the description of the .SM @@ -4519,7 +5191,7 @@ and the trap is not inherited unless the \fB\-o errtrace\fP shell option has been enabled. .PP -Variables local to the function may be declared with the +Variables local to the function are declared with the .B local builtin command (\fIlocal variables\fP). Ordinarily, variables and their values @@ -4531,17 +5203,21 @@ it calls). In the following description, the \fIcurrent scope\fP is a currently- executing function. Previous scopes consist of that function's caller and so on, -back to the "global" scope, where the shell is not executing -any shell function. -Consequently, a local variable at the current scope is a variable +back to the +.Q global +scope, where the shell is not executing any shell function. +A local variable at the current scope is a variable declared using the \fBlocal\fP or \fBdeclare\fP builtins in the function that is currently executing. .PP -Local variables "shadow" variables with the same name declared at -previous scopes. +Local variables +.Q shadow +variables with the same name declared at previous scopes. For instance, a local variable declared in a function -hides a global variable of the same name: references and assignments -refer to the local variable, leaving the global variable unmodified. +hides variables with the same name declared at previous scopes, +including global variables: references and assignments +refer to the local variable, leaving the variables +at previous scopes unmodified. When the function returns, the global variable is once again visible. .PP The shell uses \fIdynamic scoping\fP to control a variable's visibility @@ -4551,33 +5227,37 @@ are a result of the sequence of function calls that caused execution to reach the current function. The value of a variable that a function sees depends on its value within its caller, if any, whether that caller is -the "global" scope or another shell function. +the global +scope or another shell function. This is also the value that a local variable -declaration "shadows", and the value that is restored when the function -returns. +declaration shadows, +and the value that is restored when the function returns. .PP For example, if a variable \fIvar\fP is declared as local in function \fIfunc1\fP, and \fIfunc1\fP calls another function \fIfunc2\fP, -references to \fIvar\fP made from within \fIfunc2\fP will resolve to the +references to \fIvar\fP made from within \fIfunc2\fP resolve to the local variable \fIvar\fP from \fIfunc1\fP, shadowing any global variable named \fIvar\fP. .PP The \fBunset\fP builtin also acts using the same dynamic scope: if a -variable is local to the current scope, \fBunset\fP will unset it; +variable is local to the current scope, \fBunset\fP unsets it; otherwise the unset will refer to the variable found in any calling scope as described above. -If a variable at the current local scope is unset, it will remain so +If a variable at the current local scope is unset, it remains so (appearing as unset) until it is reset in that scope or until the function returns. Once the function returns, any instance of the variable at a previous -scope will become visible. +scope becomes visible. If the unset acts on a variable at a previous scope, any instance of a -variable with that name that had been shadowed will become visible +variable with that name that had been shadowed becomes visible (see below how the \fBlocalvar_unset\fP shell option changes this behavior). .PP -The \fBFUNCNEST\fP variable, if set to a numeric value greater -than 0, defines a maximum function nesting level. Function -invocations that exceed the limit cause the entire command to +The +.SM +.B FUNCNEST +variable, if set to a numeric value greater +than 0, defines a maximum function nesting level. +Function invocations that exceed the limit cause the entire command to abort. .PP If the builtin command @@ -4585,6 +5265,10 @@ If the builtin command is executed in a function, the function completes and execution resumes with the next command after the function call. +If \fBreturn\fP is supplied a numeric argument, +that is the function's return status; otherwise the function's +return status is the exit status of the last command executed +before the \fBreturn\fP. Any command associated with the \fBRETURN\fP trap is executed before execution resumes. When a function completes, the values of the @@ -4593,19 +5277,21 @@ positional parameters and the special parameter are restored to the values they had prior to the function's execution. .PP -Function names and definitions may be listed with the +The .B \-f option to the .B declare or .B typeset -builtin commands. The +builtin commands +lists function names and definitions. +The .B \-F option to .B declare or .B typeset -will list the function names only +lists the function names only (and optionally the source file and line number, if the \fBextdebug\fP shell option is enabled). Functions may be exported so that child shell processes @@ -4615,20 +5301,26 @@ automatically have them defined with the option to the .B export builtin. -A function definition may be deleted using the \fB\-f\fP option to +The \fB\-f\fP option to the .B unset -builtin. +builtin deletes a function definition. .PP Functions may be recursive. The \fBFUNCNEST\fP variable may be used to limit the depth of the function call stack and restrict the number of function invocations. -By default, no limit is imposed on the number of recursive calls. +By default, \fBbash\fP imposes no limit on the number of recursive calls. .SH "ARITHMETIC EVALUATION" The shell allows arithmetic expressions to be evaluated, under -certain circumstances (see the \fBlet\fP and \fBdeclare\fP builtin -commands, the \fB((\fP compound command, and \fBArithmetic Expansion\fP). -Evaluation is done in fixed-width integers with no check for overflow, +certain circumstances +(see the \fBlet\fP and \fBdeclare\fP builtin commands, +the \fB((\fP compound command, +the arithmetic \fBfor\fP command, +the \fB[[\fP conditional command, +and \fBArithmetic Expansion\fP). +.PP +Evaluation is done in the largest fixed-width integers available, +with no check for overflow, though division by 0 is trapped and flagged as an error. The operators and their precedence, associativity, and values are the same as in the C language. @@ -4641,13 +5333,13 @@ The levels are listed in order of decreasing precedence. .B \fIid\fP++ \fIid\fP\-\- variable post-increment and post-decrement .TP -.B \- + -unary minus and plus -.TP .B ++\fIid\fP \-\-\fIid\fP variable pre-increment and pre-decrement .TP -.B ! ~ +.B \- + +unary minus and plus +.TP +.B ! \*~ logical and bitwise negation .TP .B ** @@ -4671,7 +5363,7 @@ equality and inequality .B & bitwise AND .TP -.B ^ +.B \*^ bitwise exclusive OR .TP .B | @@ -4686,7 +5378,7 @@ logical OR .B \fIexpr\fP?\fIexpr\fP:\fIexpr\fP conditional operator .TP -.B = *= /= %= += \-= <<= >>= &= ^= |= +.B "= *= /= %= += \-= <<= >>= &= \*^= |=" assignment .TP .B \fIexpr1\fP , \fIexpr2\fP @@ -4697,8 +5389,12 @@ Shell variables are allowed as operands; parameter expansion is performed before the expression is evaluated. Within an expression, shell variables may also be referenced by name without using the parameter expansion syntax. +This means you can use "x", where \fIx\fP is a shell variable name, +in an arithmetic expression, and the shell will evaluate its value as +an expression and use the result. A shell variable that is null or unset evaluates to 0 when referenced -by name without using the parameter expansion syntax. +by name in an expression. +.PP The value of a variable is evaluated as an arithmetic expression when it is referenced, or when a variable which has been given the \fIinteger\fP attribute using \fBdeclare \-i\fP is assigned a value. @@ -4722,9 +5418,9 @@ If \fIbase\fP is less than or equal to 36, lowercase and uppercase letters may be used interchangeably to represent numbers between 10 and 35. .PP -Operators are evaluated in order of precedence. Sub-expressions in -parentheses are evaluated first and may override the precedence -rules above. +Operators are evaluated in precedence order. +Sub-expressions in parentheses are evaluated first +and may override the precedence rules above. .SH "CONDITIONAL EXPRESSIONS" Conditional expressions are used by the \fB[[\fP compound command and the \fBtest\fP and \fB[\fP builtin commands to test file attributes @@ -4733,26 +5429,37 @@ The \fBtest\fP and \fB[\fP commands determine their behavior based on the number of arguments; see the descriptions of those commands for any other command-specific actions. .PP -Expressions are formed from the following unary or binary primaries. +Expressions are formed from the unary or binary primaries listed below. +Unary expressions are often used to examine the status of a file +or shell variable. +Binary operators are used for string, numeric, and file attribute +comparisons. +.PP \fBBash\fP handles several filenames specially when they are used in expressions. If the operating system on which \fBbash\fP is running provides these special files, bash will use them; otherwise it will emulate them internally with this behavior: If any \fIfile\fP argument to one of the primaries is of the form -\fI/dev/fd/n\fP, then file descriptor \fIn\fP is checked. +.FN /dev/fd/n , +then \fBbash\fP checks file descriptor \fIn\fP. If the \fIfile\fP argument to one of the primaries is one of -\fI/dev/stdin\fP, \fI/dev/stdout\fP, or \fI/dev/stderr\fP, file -descriptor 0, 1, or 2, respectively, is checked. +.FN /dev/stdin , +.FN /dev/stdout , +or +.FN /dev/stderr , +\fBbash\fP checks file descriptor 0, 1, or 2, respectively. .PP Unless otherwise specified, primaries that operate on files follow symbolic links and operate on the target of the link, rather than the link itself. -.if t .sp 0.5 -.if n .sp 1 -When used with \fB[[\fP, the \fB<\fP and \fB>\fP operators sort +.PP +When used with \fB[[\fP, +or when the shell is in posix mode, +the \fB<\fP and \fB>\fP operators sort lexicographically using the current locale. -The \fBtest\fP command sorts using ASCII ordering. -.sp 1 +When the shell is not in posix mode, +the \fBtest\fP command sorts using ASCII ordering. +.PP .PD 0 .TP .B \-a \fIfile\fP @@ -4780,7 +5487,9 @@ True if \fIfile\fP exists and is set-group-id. True if \fIfile\fP exists and is a symbolic link. .TP .B \-k \fIfile\fP -True if \fIfile\fP exists and its ``sticky'' bit is set. +True if \fIfile\fP exists and its +.Q sticky +bit is set. .TP .B \-p \fIfile\fP True if \fIfile\fP exists and is a named pipe (FIFO). @@ -4812,7 +5521,8 @@ True if \fIfile\fP exists and is owned by the effective group id. True if \fIfile\fP exists and is a symbolic link. .TP .B \-N \fIfile\fP -True if \fIfile\fP exists and has been modified since it was last read. +True if \fIfile\fP exists and has been modified since it was last +accessed. .TP .B \-O \fIfile\fP True if \fIfile\fP exists and is owned by the effective user id. @@ -4820,18 +5530,6 @@ True if \fIfile\fP exists and is owned by the effective user id. .B \-S \fIfile\fP True if \fIfile\fP exists and is a socket. .TP -\fIfile1\fP \fB\-ef\fP \fIfile2\fP -True if \fIfile1\fP and \fIfile2\fP refer to the same device and -inode numbers. -.TP -\fIfile1\fP \-\fBnt\fP \fIfile2\fP -True if \fIfile1\fP is newer (according to modification date) than \fIfile2\fP, -or if \fIfile1\fP exists and \fPfile2\fP does not. -.TP -\fIfile1\fP \-\fBot\fP \fIfile2\fP -True if \fIfile1\fP is older than \fIfile2\fP, or if \fIfile2\fP exists -and \fIfile1\fP does not. -.TP .B \-o \fIoptname\fP True if the shell option .I optname @@ -4846,6 +5544,12 @@ builtin below. True if the shell variable .I varname is set (has been assigned a value). +If \fIvarname\fP is an indexed +array variable name subscripted by \fI@\fP or \fI*\fP, +this returns true if the array has any set elements. +If \fIvarname\fP is an associative +array variable name subscripted by \fI@\fP or \fI*\fP, +this returns true if an element with that key is set. .TP .B \-R \fIvarname\fP True if the shell variable @@ -4856,21 +5560,21 @@ is set and is a name reference. True if the length of \fIstring\fP is zero. .TP \fIstring\fP -.PD 0 .TP .B \-n \fIstring\fP -.PD True if the length of .I string is non-zero. +.PD .TP \fIstring1\fP \fB==\fP \fIstring2\fP .PD 0 .TP \fIstring1\fP \fB=\fP \fIstring2\fP -.PD -True if the strings are equal. \fB=\fP should be used -with the \fBtest\fP command for POSIX conformance. +True if the strings are equal. +\fB=\fP should be used with the \fBtest\fP command for +.SM POSIX +conformance. When used with the \fB[[\fP command, this performs pattern matching as described above (\fBCompound Commands\fP). .TP @@ -4882,6 +5586,21 @@ True if \fIstring1\fP sorts before \fIstring2\fP lexicographically. .TP \fIstring1\fP \fB>\fP \fIstring2\fP True if \fIstring1\fP sorts after \fIstring2\fP lexicographically. +.PD +.TP +.PD 0 +\fIfile1\fP \fB\-ef\fP \fIfile2\fP +True if \fIfile1\fP and \fIfile2\fP refer to the same device and +inode numbers. +.TP +\fIfile1\fP \-\fBnt\fP \fIfile2\fP +True if \fIfile1\fP is newer (according to modification date) than \fIfile2\fP, +or if \fIfile1\fP exists and \fPfile2\fP does not. +.TP +\fIfile1\fP \-\fBot\fP \fIfile2\fP +True if \fIfile1\fP is older than \fIfile2\fP, or if \fIfile2\fP exists +and \fIfile1\fP does not. +.PD .TP .I \fIarg1\fP \fBOP\fP \fIarg2\fP .SM @@ -4897,21 +5616,28 @@ or These arithmetic binary operators return true if \fIarg1\fP is equal to, not equal to, less than, less than or equal to, greater than, or greater than or equal to \fIarg2\fP, respectively. -.I Arg1 +.I arg1 and .I arg2 may be positive or negative integers. When used with the \fB[[\fP command, -.I Arg1 +.I arg1 and -.I Arg2 +.I arg2 are evaluated as arithmetic expressions (see .SM .B "ARITHMETIC EVALUATION" above). +Since the expansions the \fB[[\fP command performs on +.I arg1 +and +.I arg2 +can potentially result in empty strings, +arithmetic expression evaluation treats +those as expressions that evaluate to 0. .PD .SH "SIMPLE COMMAND EXPANSION" -When a simple command is executed, the shell performs the following +When the shell executes a simple command, it performs the following expansions, assignments, and redirections, from left to right, in the following order. .IP 1. @@ -4920,7 +5646,8 @@ preceding the command name) and redirections are saved for later processing. .IP 2. The words that are not variable assignments or redirections are -expanded. If any words remain after expansion, the first word +expanded. +If any words remain after expansion, the first word is taken to be the name of the command and the remaining words are the arguments. .IP 3. @@ -4943,27 +5670,31 @@ If any of the assignments attempts to assign a value to a readonly variable, an error occurs, and the command exits with a non-zero status. .PP If no command name results, redirections are performed, but do not -affect the current shell environment. A redirection error causes the -command to exit with a non-zero status. +affect the current shell environment. +A redirection error causes the command to exit with a non-zero status. .PP If there is a command name left after expansion, execution proceeds as -described below. Otherwise, the command exits. If one of the expansions -contained a command substitution, the exit status of the command is -the exit status of the last command substitution performed. If there -were no command substitutions, the command exits with a status of zero. +described below. +Otherwise, the command exits. +If one of the expansions contained a command substitution, +the exit status of the command is the exit status of +the last command substitution performed. +If there were no command substitutions, +the command exits with a zero status. .SH "COMMAND EXECUTION" After a command has been split into words, if it results in a -simple command and an optional list of arguments, the following -actions are taken. +simple command and an optional list of arguments, the shell performs +the following actions. .PP If the command name contains no slashes, the shell attempts to -locate it. If there exists a shell function by that name, that -function is invoked as described above in +locate it. +If there exists a shell function by that name, that function is +invoked as described above in .SM .BR FUNCTIONS . If the name does not match a function, the shell searches for -it in the list of shell builtins. If a match is found, that -builtin is invoked. +it in the list of shell builtins. +If a match is found, that builtin is invoked. .PP If the name is neither a shell function nor a builtin, and contains no slashes, @@ -4980,10 +5711,10 @@ under .SM .B "SHELL BUILTIN COMMANDS" below). -A full search of the directories in +Bash performs a full search of the directories in .SM .B PATH -is performed only if the command is not found in the hash table. +only if the command is not found in the hash table. If the search is unsuccessful, the shell searches for a defined shell function named \fBcommand_not_found_handle\fP. If that function exists, it is invoked in a separate execution environment @@ -5001,10 +5732,10 @@ to the command are set to the arguments given, if any. .PP If this execution fails because the file is not in executable format, and the file is not a directory, it is assumed to be -a \fIshell script\fP, a file -containing shell commands, and the shell creates a -new instance of itself -to execute it. +a \fIshell script\fP, a file containing shell commands, +and the shell creates a new instance of itself to execute it. +Bash tries to determine whether the file is a text file or a binary, +and will not execute files it determines to be binaries. This subshell reinitializes itself, so that the effect is as if a new shell had been invoked to handle the script, with the exception that the locations of @@ -5012,71 +5743,72 @@ commands remembered by the parent (see .B hash below under .SM -\fBSHELL BUILTIN COMMANDS\fP) +.B "SHELL BUILTIN COMMANDS" are retained by the child. .PP If the program is a file beginning with .BR #! , the remainder of the first line specifies an interpreter -for the program. The shell executes the +for the program. +The shell executes the specified interpreter on operating systems that do not -handle this executable format themselves. The arguments to the +handle this executable format themselves. +The arguments to the interpreter consist of a single optional argument following the interpreter name on the first line of the program, followed by the name of the program, followed by the command arguments, if any. -.SH COMMAND EXECUTION ENVIRONMENT +.SH "COMMAND EXECUTION ENVIRONMENT" The shell has an \fIexecution environment\fP, which consists of the following: .IP \(bu -open files inherited by the shell at invocation, as modified by -redirections supplied to the \fBexec\fP builtin +Open files inherited by the shell at invocation, as modified by +redirections supplied to the \fBexec\fP builtin. .IP \(bu -the current working directory as set by \fBcd\fP, \fBpushd\fP, or -\fBpopd\fP, or inherited by the shell at invocation +The current working directory as set by \fBcd\fP, \fBpushd\fP, or +\fBpopd\fP, or inherited by the shell at invocation. .IP \(bu -the file creation mode mask as set by \fBumask\fP or inherited from -the shell's parent +The file creation mode mask as set by \fBumask\fP or inherited from +the shell's parent. .IP \(bu -current traps set by \fBtrap\fP +Current traps set by \fBtrap\fP. .IP \(bu -shell parameters that are set by variable assignment or with \fBset\fP -or inherited from the shell's parent in the environment +Shell parameters that are set by variable assignment or with \fBset\fP +or inherited from the shell's parent in the environment. .IP \(bu -shell functions defined during execution or inherited from the shell's -parent in the environment +Shell functions defined during execution or inherited from the shell's +parent in the environment. .IP \(bu -options enabled at invocation (either by default or with command-line -arguments) or by \fBset\fP +Options enabled at invocation (either by default or with command-line +arguments) or by \fBset\fP. .IP \(bu -options enabled by \fBshopt\fP +Options enabled by \fBshopt\fP. .IP \(bu -shell aliases defined with \fBalias\fP +Shell aliases defined with \fBalias\fP. .IP \(bu -various process IDs, including those of background jobs, the value +Various process IDs, including those of background jobs, the value of \fB$$\fP, and the value of .SM -.B PPID +.BR PPID . .PP When a simple command other than a builtin or shell function is to be executed, it is invoked in a separate execution environment that consists of the following. Unless otherwise noted, the values are inherited from the shell. -.if n .sp 1 .IP \(bu -the shell's open files, plus any modifications and additions specified -by redirections to the command +The shell's open files, plus any modifications and additions specified +by redirections to the command. .IP \(bu -the current working directory +The current working directory. .IP \(bu -the file creation mode mask +The file creation mode mask. .IP \(bu -shell variables and functions marked for export, along with variables -exported for the command, passed in the environment +Shell variables and functions marked for export, along with variables +exported for the command, passed in the environment. .IP \(bu -traps caught by the shell are reset to the values inherited from the -shell's parent, and traps ignored by the shell are ignored +Traps caught by the shell are reset to the values inherited from the +shell's parent, and traps ignored by the shell are ignored. .PP A command invoked in this separate environment cannot affect the shell's execution environment. @@ -5087,17 +5819,26 @@ Command substitution, commands grouped with parentheses, and asynchronous commands are invoked in a subshell environment that is a duplicate of the shell environment, except that traps caught by the shell are reset to the values -that the shell inherited from its parent at invocation. Builtin -commands that are invoked as part of a pipeline are also executed in a -subshell environment. Changes made to the subshell environment +that the shell inherited from its parent at invocation. +Builtin commands that are invoked as part of a pipeline, +except possibly in the last element depending on the value of the +\fBlastpipe\fP shell option, +are also executed in a subshell environment. +Changes made to the subshell environment cannot affect the shell's execution environment. .PP -Subshells spawned to execute command substitutions inherit the value of -the \fB\-e\fP option from the parent shell. When not in \fIposix mode\fP, +When the shell is in posix mode, +subshells spawned to execute command substitutions inherit the value of +the \fB\-e\fP option from their parent shell. +When not in posix mode, \fBbash\fP clears the \fB\-e\fP option in such subshells. +See the +description of the \fBinherit_errexit\fP shell option below +for how to control this behavior when not in posix mode. .PP If a command is followed by a \fB&\fP and job control is not active, the -default standard input for the command is the empty file \fI/dev/null\fP. +default standard input for the command is the empty file +.FN /dev/null . Otherwise, the invoked command inherits the file descriptors of the calling shell as modified by redirections. .SH ENVIRONMENT @@ -5113,33 +5854,42 @@ On invocation, the shell scans its own environment and creates a parameter for each name found, automatically marking it for .I export -to child processes. Executed commands inherit the environment. +to child processes. +Executed commands inherit the environment. The -.B export +.BR export , +.BR "declare \-x" , and -.B declare \-x -commands allow parameters and functions to be added to and -deleted from the environment. If the value of a parameter -in the environment is modified, the new value becomes part -of the environment, replacing the old. The environment +.B unset +commands modify the environment by +adding and deleting parameters and functions. +If the value of a parameter +in the environment is modified, the new value automatically +becomes part of the environment, replacing the old. +The environment inherited by any executed command consists of the shell's initial environment, whose values may be modified in the shell, less any pairs removed by the .B unset -command, plus any additions via the +or +.B "export \-n" +commands, plus any additions via the .B export and -.B declare \-x +.B "declare \-x" commands. .PP -The environment for any -.I simple command -or function may be augmented temporarily by prefixing it with -parameter assignments, as described above in +If any parameter assignments, as described above in .SM -.BR PARAMETERS . +.BR PARAMETERS , +appear before a +.IR "simple command" , +the variable assignments are part of that command's environment +for as long as it executes. These assignment statements affect only the environment seen by that command. +If these assignments precede a call to a shell function, the variables +are local to the function and exported to that function's children. .PP If the .B \-k @@ -5154,20 +5904,23 @@ When .B bash invokes an external command, the variable .B _ -is set to the full filename of the command and passed to that +is set to the full pathname of the command and passed to that command in its environment. .SH "EXIT STATUS" The exit status of an executed command is the value returned by the -\fIwaitpid\fP system call or equivalent function. Exit statuses -fall between 0 and 255, though, as explained below, the shell may -use values above 125 specially. Exit statuses from shell builtins and -compound commands are also limited to this range. Under certain -circumstances, the shell will use special values to indicate specific -failure modes. +\fIwaitpid\fP system call or equivalent function. +Exit statuses fall between 0 and 255, though, as explained below, +the shell may use values above 125 specially. +Exit statuses from shell builtins and compound commands are also +limited to this range. +Under certain circumstances, the shell will use special values to +indicate specific failure modes. .PP For the shell's purposes, a command which exits with a -zero exit status has succeeded. An exit status of zero -indicates success. A non-zero exit status indicates failure. +zero exit status has succeeded. +So while an exit status of zero indicates success, a non-zero +exit status indicates failure. +.PP When a command terminates on a fatal signal \fIN\fP, \fBbash\fP uses the value of 128+\fIN\fP as the exit status. .PP @@ -5189,17 +5942,21 @@ parameter $?. .PP \fBBash\fP itself returns the exit status of the last command executed, unless a syntax error occurs, in which case it exits -with a non-zero value. See also the \fBexit\fP builtin -command below. +with a non-zero value. +See also the \fBexit\fP builtin command below. .SH SIGNALS When \fBbash\fP is interactive, in the absence of any traps, it ignores .SM .B SIGTERM (so that \fBkill 0\fP does not kill an interactive shell), -and +and catches and handles .SM .B SIGINT -is caught and handled (so that the \fBwait\fP builtin is interruptible). +(so that the \fBwait\fP builtin is interruptible). +When \fBbash\fP receives +.SM +.BR SIGINT , +it breaks out of any executing loops. In all cases, \fBbash\fP ignores .SM .BR SIGQUIT . @@ -5214,8 +5971,13 @@ and .SM .BR SIGTSTP . .PP -Non-builtin commands run by \fBbash\fP have signal handlers -set to the values inherited by the shell from its parent. +The \fBtrap\fP builtin modifies the shell's signal handling, as +described below. +.PP +Non-builtin commands \fBbash\fP executes have signal handlers +set to the values inherited by the shell from its parent, +unless \fBtrap\fP sets them to be ignored, in which case the child +process will ignore them as well. When job control is not in effect, asynchronous commands ignore .SM @@ -5241,21 +6003,24 @@ Before exiting, an interactive shell resends the .SM .B SIGHUP to all jobs, running or stopped. -Stopped jobs are sent +The shell sends .SM .B SIGCONT -to ensure that they receive the +to stopped jobs to ensure that they receive the .SM -.BR SIGHUP . +.B SIGHUP +(see +.SM +.B "JOB CONTROL" +below for more information about running and stopped jobs). To prevent the shell from -sending the signal to a particular job, it should be removed from the +sending the signal to a particular job, remove it from the jobs table with the .B disown builtin (see .SM .B "SHELL BUILTIN COMMANDS" -below) or marked -to not receive +below) or mark it not to receive .SM .B SIGHUP using @@ -5263,7 +6028,7 @@ using .PP If the .B huponexit -shell option has been set with +shell option has been set using .BR shopt , .B bash sends a @@ -5272,27 +6037,41 @@ sends a to all jobs when an interactive login shell exits. .PP If \fBbash\fP is waiting for a command to complete and receives a signal -for which a trap has been set, the trap will not be executed until -the command completes. -When \fBbash\fP is waiting for an asynchronous command via the \fBwait\fP -builtin, the reception of a signal for which a trap has been set will -cause the \fBwait\fP builtin to return immediately with an exit status -greater than 128, immediately after which the trap is executed. +for which a trap has been set, +it will not execute the trap until the command completes. +If \fBbash\fP is waiting for an asynchronous command via the \fBwait\fP +builtin, +and it receives a signal for which a trap has been set, +the \fBwait\fP builtin will return immediately with an exit status +greater than 128, immediately after which the shell executes the trap. .PP When job control is not enabled, and \fBbash\fP is waiting for a foreground command to complete, the shell receives keyboard-generated signals such as .SM .B SIGINT -(usually generated by \fB^C\fP) that users commonly intend to send +(usually generated by \fB\*^C\fP) that users commonly intend to send to that command. This happens because the shell and the command are in the -same process group as the terminal, and \fB^C\fP sends +same process group as the terminal, and \fB\*^C\fP sends .SM .B SIGINT to all processes in that process group. +Since \fBbash\fP does not enable job control by default when the +shell is not interactive, +this scenario is most common in non-interactive shells. +.PP +When job control is enabled, and \fBbash\fP is waiting for a foreground +command to complete, the shell does not receive keyboard-generated +signals, because it is not in the same process group as the terminal. +This scenario is most common in interactive shells, where \fBbash\fP +attempts to enable job control by default. +See +.SM +.B "JOB CONTROL" +below for more information about process groups. .PP -When \fBbash\fP is running without job control enabled and receives +When job control is not enabled, and \fBbash\fP receives .SM .B SIGINT while waiting for a foreground command, it waits until that foreground @@ -5304,13 +6083,18 @@ If the command terminates due to the .SM .BR SIGINT , \fBbash\fP concludes -that the user meant to end the entire script, and acts on the +that the user meant to send the +.SM +.B SIGINT +to the shell as well, and acts on the .SM .B SIGINT (e.g., by running a .SM .B SIGINT -trap or exiting itself); +trap, +exiting a non-interactive shell, +or returning to the top level to read a new command). .IP 2. If the command does not terminate due to .SM @@ -5335,21 +6119,45 @@ trap set on as it does with any other trapped signal it receives while it is waiting for the foreground command to complete, for compatibility. +.PP +When job control is enabled, \fBbash\fP does not receive keyboard-generated +signals such as +.SM +.B SIGINT +while it is waiting for a foreground command. +An interactive shell does not pay attention to the +.SM +.BR SIGINT , +even if the foreground command terminates as a result, other than noting +its exit status. +If the shell is not interactive, and +the foreground command terminates due to the +.SM +.BR SIGINT , +\fBbash\fP pretends it received the +.SM +.B SIGINT +itself (scenario 1 above), for compatibility. .SH "JOB CONTROL" .I Job control refers to the ability to selectively stop (\fIsuspend\fP) the execution of processes and continue (\fIresume\fP) -their execution at a later point. A user typically employs +their execution at a later point. +A user typically employs this facility via an interactive interface supplied jointly by the operating system kernel's terminal driver and .BR bash . .PP The shell associates a .I job -with each pipeline. It keeps a table of currently executing -jobs, which may be listed with the +with each pipeline. +It keeps a table of currently executing +jobs, which the .B jobs -command. When +command will display. +Each job has a \fIjob number\fP, which \fBjobs\fP displays between brackets. +Job numbers start at 1. +When .B bash starts a job asynchronously (in the .IR background ), @@ -5367,27 +6175,39 @@ uses the .I job abstraction as the basis for job control. .PP -To facilitate the implementation of the user interface to job -control, the operating system maintains the notion of a \fIcurrent terminal -process group ID\fP. Members of this process group (processes whose +To facilitate the implementation of the user interface to job control, +each process has a \fIprocess group ID\fP, and +the operating system maintains the notion of a \fIcurrent terminal +process group ID\fP. +This terminal process group ID is associated with the +\fIcontrolling terminal\fP. +.PP +Processes that have the same process group ID are said to be part of +the same \fIprocess group\fP. +Members of the \fIforeground\fP process group (processes whose process group ID is equal to the current terminal process group ID) receive keyboard-generated signals such as .SM .BR SIGINT . -These processes are said to be in the -.IR foreground . +Processes in the foreground process group are said to be +.I foreground +processes. .I Background -processes are those whose process group ID differs from the terminal's; +processes are those whose process group ID differs from the +controlling terminal's; such processes are immune to keyboard-generated signals. -Only foreground processes are allowed to read from or, if the -user so specifies with \f(CWstty tostop\fP, write to the -terminal. -Background processes which attempt to read from (write to when -\f(CWstty tostop\fP is in effect) the -terminal are sent a -.SM -.B SIGTTIN (SIGTTOU) -signal by the kernel's terminal driver, +Only foreground processes are allowed to read from or, +if the user so specifies with +.Q "stty tostop" , +write to the controlling terminal. +The system sends a +.SM +.B "SIGTTIN (SIGTTOU)" +signal to background processes which attempt to +read from (write to when +.Q tostop +is in effect) +the terminal, which, unless caught, suspends the process. .PP If the operating system on which @@ -5399,33 +6219,40 @@ contains facilities to use it. Typing the .I suspend character (typically -.BR ^Z , +.BR \*^Z , Control-Z) while a process is running -causes that process to be stopped and returns control to +stops that process and returns control to .BR bash . Typing the .I "delayed suspend" character (typically -.BR ^Y , -Control-Y) causes the process to be stopped when it -attempts to read input from the terminal, and control to -be returned to +.BR \*^Y , +Control-Y) causes the process stop when it +attempts to read input from the terminal, and returns control to .BR bash . -The user may then manipulate the state of this job, using the +The user then manipulates the state of this job, using the .B bg command to continue it in the background, the .B fg -command to continue it in the foreground, or -the +command to continue it in the foreground, or the .B kill -command to kill it. A \fB^Z\fP takes effect immediately, -and has the additional side effect of causing pending output -and typeahead to be discarded. +command to kill it. +The suspend character takes effect immediately, +and has the additional side effect of discarding any pending output +and typeahead. +To force a background process to stop, or stop a process +that's not associated with the current terminal session, +send it the +.SM +.B SIGSTOP +signal using \fBkill\fP. .PP There are a number of ways to refer to a job in the shell. -The character +The .B % -introduces a job specification (\fIjobspec\fP). Job number +character introduces a job specification (jobspec). +.PP +Job number .I n may be referred to as .BR %n . @@ -5433,85 +6260,102 @@ A job may also be referred to using a prefix of the name used to start it, or using a substring that appears in its command line. For example, .B %ce -refers to a stopped -job whose command name begins with +refers to a job whose command name begins with .BR ce . -If a prefix matches more than one job, -.B bash -reports an error. Using +Using .BR %?ce , on the other hand, refers to any job containing the string .B ce -in its command line. If the substring matches more than one job, +in its command line. +If the prefix or substring matches more than one job, .B bash -reports an error. The symbols +reports an error. +.PP +The symbols .B %% and .B %+ refer to the shell's notion of the -.IR "current job" , -which is the last job stopped while it was in -the foreground or started in the background. -The -.I "previous job" -may be referenced using -.BR %\- . +.IR "current job" . +A single % (with no accompanying job specification) also refers to the +current job. +.B %\- +refers to the +.IR "previous job" . +When a job starts in the background, +a job stops while in the foreground, +or a job is resumed in the background, +it becomes the current job. +The job that was the current job becomes the previous job. +When the current job terminates, the previous job becomes the +current job. If there is only a single job, \fB%+\fP and \fB%\-\fP can both be used to refer to that job. In output pertaining to jobs (e.g., the output of the .B jobs -command), the current job is always flagged with a +command), the current job is always marked with a .BR + , and the previous job with a .BR \- . -A single % (with no accompanying job specification) also refers to the -current job. .PP -Simply naming a job can be used to bring it into the -foreground: +Simply naming a job can be used to bring it into the foreground: .B %1 is a synonym for -\fB``fg %1''\fP, +.Q "fg %1" , bringing job 1 from the background into the foreground. Similarly, -.B ``%1 &'' +.Q "%1 &" resumes job 1 in the background, equivalent to -\fB``bg %1''\fP. +.Q "bg %1" . .PP The shell learns immediately whenever a job changes state. Normally, .B bash -waits until it is about to print a prompt before reporting +waits until it is about to print a prompt before +notifying the user about changes in a job's status so as to not interrupt -any other output. If the +any other output, +though it will notify of changes in a job's status after a +foreground command in +a list completes, before executing the next command in the list. +If the .B \-b option to the .B set builtin command is enabled, .B bash -reports such changes immediately. -Any trap on +reports status changes immediately. +\fBBash\fP executes any trap on .SM .B SIGCHLD -is executed for each child that exits. +for each child that terminates. +.PP +When a job terminates and \fBbash\fP notifies the user about it, +\fBbash\fP removes the job from the table. +It will not appear in \fBjobs\fP output, but \fBwait\fP will +report its exit status, as long as it's supplied the process ID +associated with the job as an argument. +When the table is empty, job numbers start over at 1. .PP -If an attempt to exit +If a user attempts to exit .B bash -is made while jobs are stopped (or, if the \fBcheckjobs\fP shell option has +while jobs are stopped (or, if the \fBcheckjobs\fP shell option has been enabled using the \fBshopt\fP builtin, running), the shell prints a warning message, and, if the \fBcheckjobs\fP option is enabled, lists the jobs and their statuses. The .B jobs command may then be used to inspect their status. -If a second attempt to exit is made without an intervening command, -the shell does not print another warning, and any stopped -jobs are terminated. +If the user immediately attempts to exit again, +without an intervening command, +\fBbash\fP does not print another warning, and +terminates any stopped jobs. .PP When the shell is waiting for a job or process using the \fBwait\fP builtin, and job control is enabled, \fBwait\fP will return when the -job changes state. The \fB\-f\fP option causes \fBwait\fP to wait +job changes state. +The \fB\-f\fP option causes \fBwait\fP to wait until the job or process terminates before returning. .SH PROMPTING When executing interactively, @@ -5523,83 +6367,102 @@ when it is ready to read a command, and the secondary prompt .SM .B PS2 when it needs more input to complete a command. +.PP +.B Bash +examines the value of the array variable \fBPROMPT_COMMAND\fP just before +printing each primary prompt. +If any elements in \fBPROMPT_COMMAND\fP are set and non-null, Bash +executes each value, in numeric order, +just as if it had been typed on the command line. .B Bash displays .SM .B PS0 after it reads a command but before executing it. +.PP .B Bash displays .SM .B PS4 as described above before tracing each command when the \fB\-x\fP option is enabled. +.PP .B Bash -allows these prompt strings to be customized by inserting a number of +allows the prompt strings +\fBPS0\fP, \fBPS1\fP, \fBPS2\fP, and \fBPS4\fP, +to be customized by inserting a number of backslash-escaped special characters that are decoded as follows: .RS -.PD 0 .TP .B \ea -an ASCII bell character (07) +An ASCII bell character (07). +.PD 0 .TP .B \ed -the date in "Weekday Month Date" format (e.g., "Tue May 26") +The date in +.Q "Weekday Month Date" +format (e.g., +.Q "Tue May 26" ). .TP .B \eD{\fIformat\fP} -the \fIformat\fP is passed to \fIstrftime\fP(3) and the result is inserted +The \fIformat\fP is passed to +.IR strftime (3) +and the result is inserted into the prompt string; an empty \fIformat\fP results in a locale-specific -time representation. The braces are required +time representation. +The braces are required. .TP .B \ee -an ASCII escape character (033) +An ASCII escape character (033). .TP .B \eh -the hostname up to the first `.' +The hostname up to the first +.Q . . .TP .B \eH -the hostname +The hostname. .TP .B \ej -the number of jobs currently managed by the shell +The number of jobs currently managed by the shell. .TP .B \el -the basename of the shell's terminal device name +The basename of the shell's terminal device name (e.g., +.Q ttys0 ). .TP .B \en -newline +A newline. .TP .B \er -carriage return +A carriage return. .TP .B \es -the name of the shell, the basename of +The name of the shell: the basename of .B $0 -(the portion following the final slash) +(the portion following the final slash). .TP .B \et -the current time in 24-hour HH:MM:SS format +The current time in 24-hour HH:MM:SS format. .TP .B \eT -the current time in 12-hour HH:MM:SS format +The current time in 12-hour HH:MM:SS format. .TP .B \e@ -the current time in 12-hour am/pm format +The current time in 12-hour am/pm format. .TP .B \eA -the current time in 24-hour HH:MM format +The current time in 24-hour HH:MM format. .TP .B \eu -the username of the current user +The username of the current user. .TP .B \ev -the version of \fBbash\fP (e.g., 2.00) +The \fBbash\fP version (e.g., 2.00). .TP .B \eV -the release of \fBbash\fP, version + patch level (e.g., 2.00.0) +The \fBbash\fP release, version + patch level (e.g., 2.00.0) .TP .B \ew -the value of the \fBPWD\fP shell variable (\fB$PWD\fP), +The value of the \fBPWD\fP shell variable (\fB$PWD\fP), with .SM .B $HOME @@ -5607,39 +6470,39 @@ abbreviated with a tilde (uses the value of the .SM .B PROMPT_DIRTRIM -variable) +variable). .TP .B \eW -the basename of \fB$PWD\fP, +The basename of \fB$PWD\fP, with .SM .B $HOME -abbreviated with a tilde +abbreviated with a tilde. .TP .B \e! -the history number of this command +The history number of this command. .TP .B \e# -the command number of this command +The command number of this command. .TP .B \e$ -if the effective UID is 0, a +If the effective UID is 0, a .BR # , otherwise a -.B $ +.BR $ . .TP .B \e\fInnn\fP -the character corresponding to the octal number \fInnn\fP +The character corresponding to the octal number \fInnn\fP. .TP .B \e\e -a backslash +A backslash. .TP .B \e[ -begin a sequence of non-printing characters, which could be used to -embed a terminal control sequence into the prompt +Begin a sequence of non-printing characters, which could be used to +embed a terminal control sequence into the prompt. .TP .B \e] -end a sequence of non-printing characters +End a sequence of non-printing characters. .PD .RE .PP @@ -5668,11 +6531,11 @@ word expansion. This is the library that handles reading input when using an interactive shell, unless the .B \-\-noediting -option is given at shell invocation. +option is supplied at shell invocation. Line editing is also used when using the \fB\-e\fP option to the \fBread\fP builtin. -By default, the line editing commands are similar to those of Emacs. -A vi-style line editing interface is also available. +By default, the line editing commands are similar to those of emacs; +a vi-style line editing interface is also available. Line editing can be enabled at any time using the .B \-o emacs or @@ -5681,7 +6544,7 @@ options to the .B set builtin (see .SM -.B SHELL BUILTIN COMMANDS +.B "SHELL BUILTIN COMMANDS" below). To turn off line editing after the shell is running, use the .B +o emacs @@ -5691,65 +6554,102 @@ options to the .B set builtin. .SS "Readline Notation" -In this section, the Emacs-style notation is used to denote -keystrokes. Control keys are denoted by C\-\fIkey\fR, e.g., C\-n -means Control\-N. Similarly, -.I meta -keys are denoted by M\-\fIkey\fR, so M\-x means Meta\-X. (On keyboards -without a +This section uses Emacs-style editing concepts and uses its +notation for keystrokes. +Control keys are denoted by C\-\fIkey\fP, e.g., C\-n means Control\-N. +Similarly, .I meta -key, M\-\fIx\fP means ESC \fIx\fP, i.e., press the Escape key -then the +keys are denoted by M\-\fIkey\fP, so M\-x means Meta\-X. +The Meta key is often labeled +.Q Alt +or +.Q Option . +.PP +On keyboards without a +.I Meta +key, M\-\fIx\fP means ESC \fIx\fP, +i.e., press and release the Escape key, +then press and release the .I x -key. This makes ESC the \fImeta prefix\fP. -The combination M\-C\-\fIx\fP means ESC\-Control\-\fIx\fP, -or press the Escape key -then hold the Control key while pressing the +key, in sequence. +This makes ESC the \fImeta prefix\fP. +The combination M\-C\-\fIx\fP means ESC Control\-\fIx\fP: +press and release the Escape key, +then press and hold the Control key while pressing the .I x -key.) -.PP -Readline commands may be given numeric +key, then release both. +.PP +On some keyboards, the Meta key modifier produces characters with +the eighth bit (0200) set. +You can use the \fBenable\-meta\-key\fP variable +to control whether or not it does this, if the keyboard allows it. +On many others, the terminal or terminal emulator converts the metafied +key to a key sequence beginning with ESC as described in the +preceding paragraph. +.PP +If your \fIMeta\fP key produces a key sequence with the ESC meta prefix, +you can make M-\fIkey\fP key bindings you specify (see +.B "Readline Key Bindings" +below) do the same thing by setting the \fBforce\-meta\-prefix\fP variable. +.PP +.B Readline +commands may be given numeric .IR arguments , which normally act as a repeat count. Sometimes, however, it is the sign of the argument that is significant. -Passing a negative argument to a command that acts in the forward -direction (e.g., \fBkill\-line\fP) causes that command to act in a -backward direction. +Passing a negative argument +to a command that acts in the forward direction (e.g., \fBkill\-line\fP) +makes that command act in a backward direction. Commands whose behavior with arguments deviates from this are noted below. .PP +The \fIpoint\fP is the current cursor position, and \fImark\fP refers +to a saved cursor position. +The text between the point and mark is referred to as the \fIregion\fP. +\fBReadline\fP has the concept of an \fIactive region\fP: +when the region is active, \fBreadline\fP redisplay +highlights the region using the +value of the \fBactive-region-start-color\fP variable. +The \fBenable\-active\-region\fP variable turns this on and off. +Several commands set the region to active; those are noted below. +.PP When a command is described as \fIkilling\fP text, the text deleted is saved for possible future retrieval -(\fIyanking\fP). The killed text is saved in a -\fIkill ring\fP. Consecutive kills cause the text to be -accumulated into one unit, which can be yanked all at once. +(\fIyanking\fP). +The killed text is saved in a \fIkill ring\fP. +Consecutive kills accumulate the deleted text +into one unit, which can be yanked all at once. Commands which do not kill text separate the chunks of text on the kill ring. .SS "Readline Initialization" -Readline is customized by putting commands in an initialization +.B Readline +is customized by putting commands in an initialization file (the \fIinputrc\fP file). The name of this file is taken from the value of the .SM -.B INPUTRC -variable. If that variable is unset, the default is -.IR ~/.inputrc . -If that file does not exist or cannot be read, the ultimate default is -.IR /etc/inputrc . -When a program which uses the readline library starts up, the -initialization file is read, and the key bindings and variables -are set. -There are only a few basic constructs allowed in the -readline initialization file. +.B \%INPUTRC +shell variable. +If that variable is unset, the default is +.FN \*~/.inputrc . +If that file does not exist or cannot be read, \fBreadline\fP looks for +.FN /etc/inputrc . +When a program that uses the \fBreadline\fP library starts up, +\fBreadline\fP reads the initialization file +and sets the key bindings and variables found there, +before reading any user input. +.PP +There are only a few basic constructs allowed in the inputrc file. Blank lines are ignored. Lines beginning with a \fB#\fP are comments. Lines beginning with a \fB$\fP indicate conditional constructs. Other lines denote key bindings and variable settings. .PP -The default key-bindings may be changed with an +The default key-bindings in this section +may be changed using key binding commands in the .I inputrc file. -Other programs that use this library may add their own commands -and bindings. +Programs that use the \fBreadline\fP library, including \fBbash\fP, +may add their own commands and bindings. .PP For example, placing .RS @@ -5760,45 +6660,57 @@ or .RS C\-Meta\-u: universal\-argument .RE +.LP into the .I inputrc -would make M\-C\-u execute the readline command +would make M\-C\-u execute the \fBreadline\fP command .IR universal\-argument . .PP -The following symbolic character names are recognized: -.IR RUBOUT , +Key bindings may contain the following symbolic character names: .IR DEL , .IR ESC , +.IR ESCAPE , .IR LFD , .IR NEWLINE , .IR RET , .IR RETURN , -.IR SPC , +.I RUBOUT +(a destructive backspace), .IR SPACE , +.IR SPC , and .IR TAB . .PP -In addition to command names, readline allows keys to be bound +In addition to command names, \fBreadline\fP allows keys to be bound to a string that is inserted when the key is pressed (a \fImacro\fP). +The difference between a macro and a command is that a macro is +enclosed in single or double quotes. .SS "Readline Key Bindings" The syntax for controlling key bindings in the .I inputrc -file is simple. All that is required is the name of the -command or the text of a macro and a key sequence to which -it should be bound. The name may be specified in one of two ways: -as a symbolic key name, possibly with \fIMeta\-\fP or \fIControl\-\fP -prefixes, or as a key sequence. +file is simple. +All that is required is the name of the command or the text of a macro +and a key sequence to which it should be bound. +The key sequence may be specified in one of two ways: +as a symbolic key name, +possibly with \fIMeta\-\fP or \fIControl\-\fP prefixes, +or as a key sequence composed of one or more characters +enclosed in double quotes. +The key sequence and name are separated by a colon. +There can be no whitespace between the name and the colon. .PP When using the form \fBkeyname\fP:\^\fIfunction\-name\fP or \fImacro\fP, .I keyname is the name of a key spelled out in English. For example: -.sp +.PP .RS +.EX +.nf Control-u: universal\-argument -.br -Meta-Rubout: backward-kill-word -.br -Control-o: "> output" +Meta-Rubout: backward\-kill\-word +Control-o: \*"> output\*" +.fi +.EE .RE .LP In the above example, @@ -5812,26 +6724,29 @@ and .I C\-o is bound to run the macro expressed on the right hand side (that is, to insert the text -.if t \f(CW> output\fP -.if n ``> output'' +.Q "> output" into the line). .PP -In the second form, \fB"keyseq"\fP:\^\fIfunction\-name\fP or \fImacro\fP, +In the second form, +\fB\*"keyseq\*"\fP:\^\fIfunction\-name\fP or \fImacro\fP, .B keyseq differs from .B keyname above in that strings denoting an entire key sequence may be specified by placing the sequence -within double quotes. Some GNU Emacs style key escapes can be -used, as in the following example, but the symbolic character names -are not recognized. -.sp +within double quotes. +Some GNU Emacs style key escapes can be +used, as in the following example, but none of +the symbolic character names are recognized. +.PP .RS -"\eC\-u": universal\-argument -.br -"\eC\-x\eC\-r": re\-read\-init\-file -.br -"\ee[11~": "Function Key 1" +.EX +.nf +\*"\eC\-u\*": universal\-argument +\*"\eC\-x\eC\-r\*": re\-read\-init\-file +\*"\ee[11\*~\*": \*"Function Key 1\*" +.fi +.EE .RE .PP In this example, @@ -5842,32 +6757,33 @@ is again bound to the function is bound to the function .BR re\-read\-init\-file , and -.I "ESC [ 1 1 ~" +.I "ESC [ 1 1 \*~" is bound to insert the text -.if t \f(CWFunction Key 1\fP. -.if n ``Function Key 1''. +.Q "Function Key 1" . .PP -The full set of GNU Emacs style escape sequences is +The full set of GNU Emacs style escape sequences available when specifying +key sequences is .RS .PD 0 .TP .B \eC\- -control prefix +A control prefix. .TP .B \eM\- -meta prefix +Adding the meta prefix or converting the following character to a meta +character, as described below under \fBforce-meta-prefix\fP. .TP .B \ee -an escape character +An escape character. .TP .B \e\e -backslash +Backslash. .TP -.B \e" -literal " +.B \e\*" +Literal \*", a double quote. .TP -.B \e\(aq -literal \(aq +.B \e\*' +Literal \*', a single quote. .RE .PD .PP @@ -5901,38 +6817,43 @@ horizontal tab vertical tab .TP .B \e\fInnn\fP -the eight-bit character whose value is the octal value \fInnn\fP -(one to three digits) +The eight-bit character whose value is the octal value \fInnn\fP +(one to three digits). .TP .B \ex\fIHH\fP -the eight-bit character whose value is the hexadecimal value \fIHH\fP -(one or two hex digits) +The eight-bit character whose value is the hexadecimal value \fIHH\fP +(one or two hex digits). .RE .PD .PP When entering the text of a macro, single or double quotes must be used to indicate a macro definition. Unquoted text is assumed to be a function name. -In the macro body, the backslash escapes described above are expanded. -Backslash will quote any other character in the macro text, -including " and \(aq. +The backslash escapes described above are expanded +in the macro body. +Backslash quotes any other character in the macro text, +including \*" and \*'. .PP .B Bash -allows the current readline key bindings to be displayed or modified -with the +will display or modify the current \fBreadline\fP key bindings with the .B bind -builtin command. The editing mode may be switched during interactive -use by using the -.B \-o -option to the +builtin command. +The +.B \-o emacs +or +.B \-o vi +options to the .B set -builtin command (see +builtin +(see .SM -.B SHELL BUILTIN COMMANDS -below). +.B "SHELL BUILTIN COMMANDS" +below) +change the editing mode during interactive use. .SS "Readline Variables" -Readline has variables that can be used to further customize its -behavior. A variable may be set in the +\fBReadline\fP has variables that can be used to further customize its +behavior. +A variable may be set in the .I inputrc file with a statement of the form .RS @@ -5941,23 +6862,34 @@ file with a statement of the form .RE or using the \fBbind\fP builtin command (see .SM -.B SHELL BUILTIN COMMANDS +.B "SHELL BUILTIN COMMANDS" below). .PP -Except where noted, readline variables can take the values +Except where noted, \fBreadline\fP variables can take the values .B On or .B Off (without regard to case). Unrecognized variable names are ignored. -When a variable value is read, empty or null values, "on" (case-insensitive), -and "1" are equivalent to \fBOn\fP. All other values are equivalent to +When \fBreadline\fP reads a variable value, empty or null values, +.Q "on" +(case-insensitive), and +.Q 1 +are equivalent to \fBOn\fP. +All other values are equivalent to \fBOff\fP. +.PP +The \fBbind \-V\fP command lists the current \fBreadline\fP variable names +and values (see +.SM +.B "SHELL BUILTIN COMMANDS" +below). +.PP The variables and their default values are: .PP .PD 0 .TP -.B active\-region\-start\-color +.B active\-region\-start\-color A string variable that controls the text color and background when displaying the text in the active region (see the description of \fBenable\-active\-region\fP below). @@ -5967,54 +6899,69 @@ It is output to the terminal before displaying the text in the active region. This variable is reset to the default value whenever the terminal type changes. The default value is the string that puts the terminal in standout mode, as obtained from the terminal's terminfo description. -A sample value might be \f(CW"\ee[01;33m"\fP. -.TP -.B active\-region\-end\-color -A string variable that "undoes" the effects of \fBactive\-region\-start\-color\fP -and restores "normal" terminal display appearance after displaying text -in the active region. +A sample value might be +.Q \ee[01;33m . +.TP +.B active\-region\-end\-color +A string variable that +.Q undoes +the effects of \fBactive\-region\-start\-color\fP +and restores +.Q normal +terminal display appearance after displaying text in the active region. This string must not take up any physical character positions on the display, so it should consist only of terminal escape sequences. It is output to the terminal after displaying the text in the active region. This variable is reset to the default value whenever the terminal type changes. The default value is the string that restores the terminal from standout mode, as obtained from the terminal's terminfo description. -A sample value might be \f(CW"\ee[0m"\fP. +A sample value might be +.Q \ee[0m . .TP .B bell\-style (audible) -Controls what happens when readline wants to ring the terminal bell. -If set to \fBnone\fP, readline never rings the bell. If set to -\fBvisible\fP, readline uses a visible bell if one is available. -If set to \fBaudible\fP, readline attempts to ring the terminal's bell. +Controls what happens when \fBreadline\fP wants to ring the terminal bell. +If set to \fBnone\fP, \fBreadline\fP never rings the bell. +If set to \fBvisible\fP, \fBreadline\fP uses a visible bell if one is available. +If set to \fBaudible\fP, \fBreadline\fP attempts to ring the terminal's bell. .TP .B bind\-tty\-special\-chars (On) -If set to \fBOn\fP, readline attempts to bind the control characters -treated specially by the kernel's terminal driver to their readline -equivalents. +If set to \fBOn\fP, \fBreadline\fP attempts to bind +the control characters that are treated specially by the kernel's +terminal driver to their \fBreadline\fP equivalents. +These override the default \fBreadline\fP bindings described here. +Type +.Q "stty \-a" +at a \fBbash\fP prompt to see your current terminal settings, +including the special control characters (usually \fBcchars\fP). .TP .B blink\-matching\-paren (Off) -If set to \fBOn\fP, readline attempts to briefly move the cursor to an +If set to \fBOn\fP, \fBreadline\fP attempts to briefly move the cursor to an opening parenthesis when a closing parenthesis is inserted. .TP .B colored\-completion\-prefix (Off) -If set to \fBOn\fP, when listing completions, readline displays the +If set to \fBOn\fP, when listing completions, \fBreadline\fP displays the common prefix of the set of possible completions using a different color. The color definitions are taken from the value of the \fBLS_COLORS\fP environment variable. If there is a color definition in \fB$LS_COLORS\fP for the custom suffix -"readline-colored-completion-prefix", readline uses this color for +.Q .readline-colored-completion-prefix , +\fBreadline\fP uses this color for the common prefix instead of its default. .TP .B colored\-stats (Off) -If set to \fBOn\fP, readline displays possible completions using different +If set to \fBOn\fP, \fBreadline\fP displays possible completions using different colors to indicate their file type. The color definitions are taken from the value of the \fBLS_COLORS\fP environment variable. +.\" Tucking multiple macro calls into a paragraph tag requires some +.\" finesse. We require `\c`, and while the single-font macros don't +.\" honor input trap continuation, the font alternation macros do. .TP -.B comment\-begin (``#'') -The string that is inserted when the readline +.BR comment\-begin\ ( \c +.Q \fB#\fP \fB)\fP +The string that the \fBreadline\fP .B insert\-comment -command is executed. +command inserts. This command is bound to .B M\-# in emacs mode and to @@ -6026,23 +6973,29 @@ The number of screen columns used to display possible matches when performing completion. The value is ignored if it is less than 0 or greater than the terminal screen width. -A value of 0 will cause matches to be displayed one per line. +A value of 0 causes matches to be displayed one per line. The default value is \-1. .TP .B completion\-ignore\-case (Off) -If set to \fBOn\fP, readline performs filename matching and completion +If set to \fBOn\fP, \fBreadline\fP performs filename matching and completion in a case\-insensitive fashion. .TP .B completion\-map\-case (Off) -If set to \fBOn\fP, and \fBcompletion\-ignore\-case\fP is enabled, readline +If set to \fBOn\fP, and \fBcompletion\-ignore\-case\fP is enabled, +.B readline treats hyphens (\fI\-\fP) and underscores (\fI_\fP) as equivalent when performing case\-insensitive filename matching and completion. .TP .B completion\-prefix\-display\-length (0) -The length in characters of the common prefix of a list of possible -completions that is displayed without modification. When set to a -value greater than zero, common prefixes longer than this value are -replaced with an ellipsis when displaying possible completions. +The maximum +length in characters of the common prefix of a list of possible +completions that is displayed without modification. +When set to a value greater than zero, \fBreadline\fP +replaces common prefixes longer than this value +with an ellipsis when displaying possible completions. +If a completion begins with a period, +and \fBeadline\fP is completing filenames, +it uses three underscores instead of an ellipsis. .TP .B completion\-query\-items (100) This determines when the user is queried about viewing @@ -6051,33 +7004,36 @@ generated by the \fBpossible\-completions\fP command. It may be set to any integer value greater than or equal to zero. If the number of possible completions is greater than or equal to the value of this variable, -readline will ask whether or not the user wishes to view them; -otherwise they are simply listed on the terminal. -A zero value means readline should never ask; negative values are +\fBreadline\fP asks whether or not the user wishes to view them; +otherwise \fBreadline\fP simply lists them on the terminal. +A zero value means \fBreadline\fP should never ask; negative values are treated as zero. .TP .B convert\-meta (On) -If set to \fBOn\fP, readline will convert characters with the -eighth bit set to an ASCII key sequence -by stripping the eighth bit and prefixing an -escape character (in effect, using escape as the \fImeta prefix\fP). -The default is \fIOn\fP, but readline will set it to \fIOff\fP if the -locale contains eight-bit characters. -This variable is dependent on the \fBLC_CTYPE\fP locale category, and -may change if the locale is changed. +If set to \fBOn\fP, \fBreadline\fP converts characters it reads +that have the eighth bit set to an ASCII key sequence by +clearing the eighth bit and prefixing it with an escape character +(converting the character to have the meta prefix). +The default is \fIOn\fP, but \fBreadline\fP sets it to \fIOff\fP +if the locale contains +characters whose encodings may include bytes with the eighth bit set. +This variable is dependent on the \fBLC_CTYPE\fP locale category, and +may change if the locale changes. +This variable also affects key bindings; see the description of +\fBforce\-meta\-prefix\fP below. .TP .B disable\-completion (Off) -If set to \fBOn\fP, readline will inhibit word completion. Completion -characters will be inserted into the line as if they had been -mapped to \fBself-insert\fP. +If set to \fBOn\fP, \fBreadline\fP inhibits word completion. +Completion characters are inserted into the line as if they +had been mapped to \fBself-insert\fP. .TP .B echo\-control\-characters (On) When set to \fBOn\fP, on operating systems that indicate they support it, -readline echoes a character corresponding to a signal generated from the +\fBreadline\fP echoes a character corresponding to a signal generated from the keyboard. .TP .B editing\-mode (emacs) -Controls whether readline begins with a set of key bindings similar +Controls whether \fBreadline\fP uses a set of key bindings similar to \fIEmacs\fP or \fIvi\fP. .B editing\-mode can be set to either @@ -6087,48 +7043,69 @@ or .TP .B emacs\-mode\-string (@) If the \fIshow\-mode\-in\-prompt\fP variable is enabled, -this string is displayed immediately before the last line of the primary -prompt when emacs editing mode is active. The value is expanded like a -key binding, so the standard set of meta- and control prefixes and +this string is displayed immediately before the last line of the +primary prompt when emacs editing mode is active. +The value is expanded like a +key binding, so the standard set of meta- and control- prefixes and backslash escape sequences is available. -Use the \e1 and \e2 escapes to begin and end sequences of +The \e1 and \e2 escapes begin and end sequences of non-printing characters, which can be used to embed a terminal control sequence into the mode string. .TP .B enable\-active\-region (On) -The \fIpoint\fP is the current cursor position, and \fImark\fP refers -to a saved cursor position. -The text between the point and mark is referred to as the \fIregion\fP. -When this variable is set to \fIOn\fP, readline allows certain commands -to designate the region as \fIactive\fP. -When the region is active, readline highlights the text in the region using -the value of the \fBactive\-region\-start\-color\fP, which defaults to the -string that enables +When this variable is set to \fIOn\fP, \fBreadline\fP allows certain commands +to designate the region as \fIactive\fP. +When the region is active, \fBreadline\fP +highlights the text in the region using the value of the +.B active\-region\-start\-color +variable, which defaults to the string that enables the terminal's standout mode. The active region shows the text inserted by bracketed-paste and any matching text found by incremental and non-incremental history searches. .TP .B enable\-bracketed\-paste (On) -When set to \fBOn\fP, readline configures the terminal to insert each +When set to \fBOn\fP, \fBreadline\fP configures the terminal to insert each paste into the editing buffer as a single string of characters, instead of treating each character as if it had been read from the keyboard. -This prevents readline from executing any editing commands bound to key +This is called \fIbracketed\-paste mode\fP; +it prevents \fBreadline\fP from executing any editing commands bound to key sequences appearing in the pasted text. .TP .B enable\-keypad (Off) -When set to \fBOn\fP, readline will try to enable the application -keypad when it is called. Some systems need this to enable the -arrow keys. +When set to \fBOn\fP, \fBreadline\fP tries to enable the application +keypad when it is called. +Some systems need this to enable the arrow keys. .TP .B enable\-meta\-key (On) -When set to \fBOn\fP, readline will try to enable any meta modifier -key the terminal claims to support when it is called. On many terminals, -the meta key is used to send eight-bit characters. +When set to \fBOn\fP, \fBreadline\fP tries to enable any meta modifier +key the terminal claims to support. +On many terminals, the Meta key is used to send eight-bit characters; +this variable checks for the terminal capability that indicates the +terminal can enable and disable a mode that sets the eighth bit of a +character (0200) if the Meta key is held down when the character is +typed (a meta character). .TP .B expand\-tilde (Off) -If set to \fBOn\fP, tilde expansion is performed when readline +If set to \fBOn\fP, \fBreadline\fP performs tilde expansion when it attempts word completion. .TP +.B force\-meta\-prefix (Off) +If set to \fBOn\fP, \fBreadline\fP modifies its behavior when binding key +sequences containing \eM- or Meta- +(see \fBKey Bindings\fP above) by converting a key sequence of the form +\eM\-\fIC\fP or Meta\-\fIC\fP to the two-character sequence +\fBESC\fP \fIC\fP (adding the meta prefix). +If +.B force\-meta\-prefix +is set to \fBOff\fP (the default), +\fBreadline\fP uses the value of the +.B convert\-meta +variable to determine whether to perform this conversion: +if \fBconvert\-meta\fP is \fBOn\fP, +\fBreadline\fP performs the conversion described above; +if it is \fBOff\fP, \fBreadline\fP converts \fIC\fP to a meta character by +setting the eighth bit (0200). +.TP .B history\-preserve\-point (Off) If set to \fBOn\fP, the history code attempts to place point at the same location on each history line retrieved with \fBprevious-history\fP @@ -6140,78 +7117,82 @@ If set to zero, any existing history entries are deleted and no new entries are saved. If set to a value less than zero, the number of history entries is not limited. -By default, the number of history entries is set to the value of the -\fBHISTSIZE\fP shell variable. -If an attempt is made to set \fIhistory\-size\fP to a non-numeric value, -the maximum number of history entries will be set to 500. +By default, \fBbash\fP sets the maximum number of history entries to +the value of the \fBHISTSIZE\fP shell variable. +Setting \fIhistory\-size\fP to a non-numeric value will set +the maximum number of history entries to 500. .TP .B horizontal\-scroll\-mode (Off) -When set to \fBOn\fP, makes readline use a single line for display, -scrolling the input horizontally on a single screen line when it -becomes longer than the screen width rather than wrapping to a new line. +Setting this variable to \fBOn\fP makes \fBreadline\fP use a single line +for display, scrolling the input horizontally on a single screen line +when it becomes longer than the screen width rather than wrapping to +a new line. This setting is automatically enabled for terminals of height 1. .TP .B input\-meta (Off) -If set to \fBOn\fP, readline will enable eight-bit input (that is, -it will not strip the eighth bit from the characters it reads), -regardless of what the terminal claims it can support. The name -.B meta\-flag -is a synonym for this variable. -The default is \fIOff\fP, but readline will set it to \fIOn\fP if the -locale contains eight-bit characters. -This variable is dependent on the \fBLC_CTYPE\fP locale category, and -may change if the locale is changed. -.TP -.B isearch\-terminators (``C\-[C\-J'') +If set to \fBOn\fP, \fBreadline\fP enables eight-bit input (that is, it +does not clear the eighth bit in the characters it reads), +regardless of what the terminal claims it can support. +The default is \fIOff\fP, but \fBreadline\fP sets it to \fIOn\fP +if the locale contains characters whose encodings may include bytes +with the eighth bit set. +This variable is dependent on the \fBLC_CTYPE\fP locale category, and +its value may change if the locale changes. +The name \fBmeta\-flag\fP is a synonym for \fBinput\-meta\fP. +.TP +.BR isearch\-terminators\ ( \c +.Q \fBC\-[C\-j\fP \fB)\fP The string of characters that should terminate an incremental search without subsequently executing the character as a command. If this variable has not been given a value, the characters -\fIESC\fP and \fIC\-J\fP will terminate an incremental search. +\fIESC\fP and \fBC\-j\fP terminate an incremental search. .TP .B keymap (emacs) -Set the current readline keymap. The set of valid keymap names is +Set the current \fBreadline\fP keymap. +The set of valid keymap names is \fIemacs, emacs\-standard, emacs\-meta, emacs\-ctlx, vi, vi\-command\fP, and .IR vi\-insert . -\fIvi\fP is equivalent to \fIvi\-command\fP; \fIemacs\fP is -equivalent to \fIemacs\-standard\fP. The default value is -.IR emacs ; +\fIvi\fP is equivalent to \fIvi\-command\fP; +\fIemacs\fP is equivalent to \fIemacs\-standard\fP. +The default value is \fIemacs\fP; the value of .B editing\-mode also affects the default keymap. .TP .B keyseq\-timeout (500) -Specifies the duration \fIreadline\fP will wait for a character when reading an -ambiguous key sequence (one that can form a complete key sequence using -the input read so far, or can take additional input to complete a longer -key sequence). -If no input is received within the timeout, \fIreadline\fP will use the shorter -but complete key sequence. +Specifies the duration \fBreadline\fP will wait for a character when +reading an ambiguous key sequence +(one that can form a complete key sequence using the input read so far, +or can take additional input to complete a longer key sequence). +If \fBreadline\fP does not receive any input within the timeout, +it uses the shorter but complete key sequence. The value is specified in milliseconds, so a value of 1000 means that -\fIreadline\fP will wait one second for additional input. +\fBreadline\fP will wait one second for additional input. If this variable is set to a value less than or equal to zero, or to a -non-numeric value, \fIreadline\fP will wait until another key is pressed to +non-numeric value, \fBreadline\fP waits until another key is pressed to decide which key sequence to complete. .TP .B mark\-directories (On) -If set to \fBOn\fP, completed directory names have a slash -appended. +If set to \fBOn\fP, completed directory names have a slash appended. .TP .B mark\-modified\-lines (Off) -If set to \fBOn\fP, history lines that have been modified are displayed +If set to \fBOn\fP, \fBreadline\fP displays history lines +that have been modified with a preceding asterisk (\fB*\fP). .TP .B mark\-symlinked\-directories (Off) If set to \fBOn\fP, completed names which are symbolic links to directories -have a slash appended (subject to the value of -\fBmark\-directories\fP). +have a slash appended, subject to the value of \fBmark\-directories\fP. .TP .B match\-hidden\-files (On) -This variable, when set to \fBOn\fP, causes readline to match files whose -names begin with a `.' (hidden files) when performing filename -completion. -If set to \fBOff\fP, the leading `.' must be -supplied by the user in the filename to be completed. +This variable, when set to \fBOn\fP, forces \fBreadline\fP to match files whose +names begin with a +.Q . +(hidden files) when performing filename completion. +If set to \fBOff\fP, the user must include the leading +.Q . +in the filename to be completed. .TP .B menu\-complete\-display\-prefix (Off) If set to \fBOn\fP, menu completion displays the common prefix of the @@ -6219,31 +7200,41 @@ list of possible completions (which may be empty) before cycling through the list. .TP .B output\-meta (Off) -If set to \fBOn\fP, readline will display characters with the +If set to \fBOn\fP, \fBreadline\fP displays characters with the eighth bit set directly rather than as a meta-prefixed escape sequence. -The default is \fIOff\fP, but readline will set it to \fIOn\fP if the -locale contains eight-bit characters. -This variable is dependent on the \fBLC_CTYPE\fP locale category, and -may change if the locale is changed. +The default is \fIOff\fP, but \fBreadline\fP sets it to \fIOn\fP +if the locale contains characters whose encodings may include +bytes with the eighth bit set. +This variable is dependent on the \fBLC_CTYPE\fP locale category, and +its value may change if the locale changes. .TP .B page\-completions (On) -If set to \fBOn\fP, readline uses an internal \fImore\fP-like pager +If set to \fBOn\fP, \fBreadline\fP uses an internal pager resembling +.IR more (1) to display a screenful of possible completions at a time. .TP +.B prefer\-visible\-bell +See \fBbell\-style\fP. +.TP .B print\-completions\-horizontally (Off) -If set to \fBOn\fP, readline will display completions with matches +If set to \fBOn\fP, \fBreadline\fP displays completions with matches sorted horizontally in alphabetical order, rather than down the screen. .TP .B revert\-all\-at\-newline (Off) -If set to \fBOn\fP, readline will undo all changes to history lines -before returning when \fBaccept\-line\fP is executed. By default, +If set to \fBOn\fP, \fBreadline\fP will undo all changes to history lines +before returning when executing \fBaccept\-line\fP. +By default, history lines may be modified and retain individual undo lists across calls to \fBreadline\fP. .TP +.B search\-ignore\-case (Off) +If set to \fBOn\fP, \fBreadline\fP performs incremental and non-incremental +history list searches in a case\-insensitive fashion. +.TP .B show\-all\-if\-ambiguous (Off) -This alters the default behavior of the completion functions. If -set to +This alters the default behavior of the completion functions. +If set to .BR On , words which have more than one possible completion cause the matches to be listed immediately instead of ringing the bell. @@ -6265,20 +7256,19 @@ The mode strings are user-settable (e.g., \fIemacs\-mode\-string\fP). .TP .B skip\-completed\-text (Off) If set to \fBOn\fP, this alters the default completion behavior when -inserting a single match into the line. It's only active when -performing completion in the middle of a word. If enabled, readline -does not insert characters from the completion that match characters -after point in the word being completed, so portions of the word -following the cursor are not duplicated. +inserting a single match into the line. +It's only active when performing completion in the middle of a word. +If enabled, \fBreadline\fP does not insert characters from the completion +that match characters after point in the word being completed, +so portions of the word following the cursor are not duplicated. .TP .B vi\-cmd\-mode\-string ((cmd)) If the \fIshow\-mode\-in\-prompt\fP variable is enabled, this string is displayed immediately before the last line of the primary prompt when vi editing mode is active and in command mode. -The value is expanded like a -key binding, so the standard set of meta- and control prefixes and -backslash escape sequences is available. -Use the \e1 and \e2 escapes to begin and end sequences of +The value is expanded like a key binding, so the standard set of +meta- and control- prefixes and backslash escape sequences is available. +The \e1 and \e2 escapes begin and end sequences of non-printing characters, which can be used to embed a terminal control sequence into the mode string. .TP @@ -6286,10 +7276,9 @@ sequence into the mode string. If the \fIshow\-mode\-in\-prompt\fP variable is enabled, this string is displayed immediately before the last line of the primary prompt when vi editing mode is active and in insertion mode. -The value is expanded like a -key binding, so the standard set of meta- and control prefixes and -backslash escape sequences is available. -Use the \e1 and \e2 escapes to begin and end sequences of +The value is expanded like a key binding, so the standard set of +meta- and control- prefixes and backslash escape sequences is available. +The \e1 and \e2 escapes begin and end sequences of non-printing characters, which can be used to embed a terminal control sequence into the mode string. .TP @@ -6299,43 +7288,52 @@ by \fIstat\fP(2) is appended to the filename when listing possible completions. .PD .SS "Readline Conditional Constructs" -Readline implements a facility similar in spirit to the conditional +.B Readline +implements a facility similar in spirit to the conditional compilation features of the C preprocessor which allows key bindings and variable settings to be performed as the result -of tests. There are four parser directives used. -.IP \fB$if\fP +of tests. +There are four parser directives available. +.TP +.B $if The .B $if construct allows bindings to be made based on the editing mode, the terminal being used, or the application using -readline. The text of the test, after any comparison operator, - extends to the end of the line; +\fBreadline\fP. +The text of the test, after any comparison operator, +extends to the end of the line; unless otherwise noted, no characters are required to isolate it. .RS -.IP \fBmode\fP +.TP +.B mode The \fBmode=\fP form of the \fB$if\fP directive is used to test -whether readline is in emacs or vi mode. +whether \fBreadline\fP is in emacs or vi mode. This may be used in conjunction with the \fBset keymap\fP command, for instance, to set bindings in the \fIemacs\-standard\fP and \fIemacs\-ctlx\fP keymaps only if -readline is starting out in emacs mode. -.IP \fBterm\fP +\fBreadline\fP is starting out in emacs mode. +.TP +.B term The \fBterm=\fP form may be used to include terminal-specific key bindings, perhaps to bind the key sequences output by the -terminal's function keys. The word on the right side of the +terminal's function keys. +The word on the right side of the .B = is tested against both the full name of the terminal and the portion -of the terminal name before the first \fB\-\fP. This allows -.I sun +of the terminal name before the first \fB\-\fP. +This allows +.I xterm to match both -.I sun +.I xterm and -.IR sun\-cmd , +.IR xterm\-256color , for instance. -.IP \fBversion\fP +.TP +.B version The \fBversion\fP test may be used to perform comparisons against -specific readline versions. -The \fBversion\fP expands to the current readline version. +specific \fBreadline\fP versions. +The \fBversion\fP expands to the current \fBreadline\fP version. The set of comparison operators includes .BR = , (and @@ -6348,59 +7346,72 @@ and .BR > . The version number supplied on the right side of the operator consists of a major version number, an optional decimal point, and an optional -minor version (e.g., \fB7.1\fP). If the minor version is omitted, it -is assumed to be \fB0\fP. +minor version (e.g., \fB7.1\fP). +If the minor version is omitted, it +defaults to \fB0\fP. The operator may be separated from the string \fBversion\fP and from the version number argument by whitespace. -.IP \fBapplication\fP -The \fBapplication\fP construct is used to include -application-specific settings. Each program using the readline +.TP +.I application +The \fIapplication\fP construct is used to include +application-specific settings. +Each program using the \fBreadline\fP library sets the \fIapplication name\fP, and an initialization file can test for a particular value. This could be used to bind key sequences to functions useful for -a specific program. For instance, the following command adds a +a specific program. +For instance, the following command adds a key sequence that quotes the current or previous word in \fBbash\fP: -.sp 1 +.PP .RS +.EX .nf \fB$if\fP Bash # Quote the current or previous word -"\eC\-xq": "\eeb\e"\eef\e"" +\*"\eC-xq\*": \*"\eeb\e\*"\eef\e\*"\*" \fB$endif\fP .fi +.EE .RE -.IP \fIvariable\fP -The \fIvariable\fP construct provides simple equality tests for readline +.TP +.I variable +The \fIvariable\fP construct provides simple equality tests for \fBreadline\fP variables and values. The permitted comparison operators are \fI=\fP, \fI==\fP, and \fI!=\fP. The variable name must be separated from the comparison operator by whitespace; the operator may be separated from the value on the right hand side by whitespace. -Both string and boolean variables may be tested. Boolean variables must be +String and boolean variables may be tested. +Boolean variables must be tested against the values \fIon\fP and \fIoff\fP. .RE -.IP \fB$endif\fP -This command, as seen in the previous example, terminates an -\fB$if\fP command. -.IP \fB$else\fP +.TP +.B $else Commands in this branch of the \fB$if\fP directive are executed if the test fails. -.IP \fB$include\fP +.TP +.B $endif +This command, as seen in the previous example, terminates an +\fB$if\fP command. +.TP +.B $include This directive takes a single filename as an argument and reads commands -and bindings from that file. For example, the following directive -would read \fI/etc/inputrc\fP: -.sp 1 +and key bindings from that file. +For example, the following directive would read +.FN /etc/inputrc : +.PP .RS .nf \fB$include\fP \^ \fI/etc/inputrc\fP .fi .RE .SS Searching -Readline provides commands for searching through the command history -(see +.B Readline +provides commands for searching through the command history (see .SM .B HISTORY -below) for lines containing a specified string. +below) +for lines containing a specified string. There are two search modes: .I incremental and @@ -6408,85 +7419,107 @@ and .PP Incremental searches begin before the user has finished typing the search string. -As each character of the search string is typed, readline displays +As each character of the search string is typed, \fBreadline\fP displays the next entry from the history matching the string typed so far. An incremental search requires only as many characters as needed to find the desired history entry. +When using emacs editing mode, type \fBC\-r\fP to +search backward in the history for a particular string. +Typing \fBC\-s\fP searches forward through the history. The characters present in the value of the \fBisearch-terminators\fP variable are used to terminate an incremental search. -If that variable has not been assigned a value the Escape and -Control-J characters will terminate an incremental search. -Control-G will abort an incremental search and restore the original -line. +If that variable has not been assigned a value, +\fIESC\fP and \fBC\-j\fP terminate an incremental search. +\fBC\-g\fP aborts an incremental search and restores the original line. When the search is terminated, the history entry containing the search string becomes the current line. .PP -To find other matching entries in the history list, type Control-S or -Control-R as appropriate. -This will search backward or forward in the history for the next +To find other matching entries in the history list, type \fBC\-r\fP or +\fBC\-s\fP as appropriate. +This searches backward or forward in the history for the next entry matching the search string typed so far. -Any other key sequence bound to a readline command will terminate -the search and execute that command. -For instance, a \fInewline\fP will terminate the search and accept +Any other key sequence bound to a \fBreadline\fP command terminates +the search and executes that command. +For instance, a newline terminates the search and accepts the line, thereby executing the command from the history list. +A movement command will terminate the search, make the last line found +the current line, and begin editing. .PP -Readline remembers the last incremental search string. If two -Control-Rs are typed without any intervening characters defining a -new search string, any remembered search string is used. +.B Readline +remembers the last incremental search string. +If two \fBC\-r\fPs are typed without any intervening characters defining +a new search string, \fBreadline\fP uses any remembered search string. .PP Non-incremental searches read the entire search string before starting -to search for matching history lines. The search string may be +to search for matching history entries. +The search string may be typed by the user or be part of the contents of the current line. .SS "Readline Command Names" The following is a list of the names of the commands and the default key sequences to which they are bound. Command names without an accompanying key sequence are unbound by default. +.PP In the following descriptions, \fIpoint\fP refers to the current cursor position, and \fImark\fP refers to a cursor position saved by the \fBset\-mark\fP command. The text between the point and mark is referred to as the \fIregion\fP. +.B Readline +has the concept of an \fIactive region\fP: +when the region is active, \fBreadline\fP redisplay +highlights the region using the value of the +.B active\-region\-start\-color +variable. +The \fBenable\-active\-region\fP \fBreadline\fP variable turns this on and off. +Several commands set the region to active; those are noted below. .SS Commands for Moving .PD 0 .TP .B beginning\-of\-line (C\-a) Move to the start of the current line. +This may also be bound to the Home key on some keyboards. .TP .B end\-of\-line (C\-e) Move to the end of the line. +This may also be bound to the End key on some keyboards. .TP .B forward\-char (C\-f) Move forward a character. +This may also be bound to the right arrow key on some keyboards. .TP .B backward\-char (C\-b) Move back a character. +This may also be bound to the left arrow key on some keyboards. .TP .B forward\-word (M\-f) -Move forward to the end of the next word. Words are composed of -alphanumeric characters (letters and digits). +Move forward to the end of the next word. +Words are composed of alphanumeric characters (letters and digits). .TP .B backward\-word (M\-b) Move back to the start of the current or previous word. Words are composed of alphanumeric characters (letters and digits). .TP -.B shell\-forward\-word +.B shell\-forward\-word (M\-C\-f) Move forward to the end of the next word. Words are delimited by non-quoted shell metacharacters. .TP -.B shell\-backward\-word +.B shell\-backward\-word (M\-C\-b) Move back to the start of the current or previous word. Words are delimited by non-quoted shell metacharacters. .TP .B previous\-screen\-line Attempt to move point to the same physical screen column on the previous -physical screen line. This will not have the desired effect if the current -readline line does not take up more than one physical line or if point is not -greater than the length of the prompt plus the screen width. +physical screen line. +This will not have the desired effect if the current +\fBreadline\fP line does not take up more than one physical line or if +point is not greater than the length of the prompt plus the screen width. .TP .B next\-screen\-line Attempt to move point to the same physical screen column on the next -physical screen line. This will not have the desired effect if the current -readline line does not take up more than one physical line or if the length -of the current readline line is not greater than the length of the prompt +physical screen line. +This will not have the desired effect if the current +\fBreadline\fP line does not take up more than one physical line or if +the length of the current \fBreadline\fP line is +not greater than the length of the prompt plus the screen width. .TP .B clear\-display (M\-C\-l) @@ -6498,7 +7531,7 @@ leaving the current line at the top of the screen. Clear the screen, then redraw the current line, leaving the current line at the top of the screen. -With an argument, refresh the current line without clearing the +With a numeric argument, refresh the current line without clearing the screen. .TP .B redraw\-current\-line @@ -6508,20 +7541,26 @@ Refresh the current line. .PD 0 .TP .B accept\-line (Newline, Return) -Accept the line regardless of where the cursor is. If this line is -non-empty, add it to the history list according to the state of the +Accept the line regardless of where the cursor is. +If this line is non-empty, add it to the history list according to the +state of the .SM .B HISTCONTROL -variable. If the line is a modified history -line, then restore the history line to its original state. +and +.B HISTIGNORE +variables. +If the line is a modified history line, +restore the history line to its original state. .TP .B previous\-history (C\-p) Fetch the previous command from the history list, moving back in the list. +This may also be bound to the up arrow key on some keyboards. .TP .B next\-history (C\-n) Fetch the next command from the history list, moving forward in the list. +This may also be bound to the down arrow key on some keyboards. .TP .B beginning\-of\-history (M\-<) Move to the first line in the history. @@ -6531,8 +7570,10 @@ Move to the end of the input history, i.e., the line currently being entered. .TP .B operate\-and\-get\-next (C\-o) -Accept the current line for execution and fetch the next line -relative to the current line from the history for editing. +Accept the current line for execution as if a +newline had been entered, +and fetch the next line relative to the current line from the history +for editing. A numeric argument, if supplied, specifies the history entry to use instead of the current line. .TP @@ -6543,35 +7584,46 @@ and make it the current line. Without an argument, move back to the first entry in the history list. .TP .B reverse\-search\-history (C\-r) -Search backward starting at the current line and moving `up' through -the history as necessary. This is an incremental search. +Search backward starting at the current line and moving +.Q up +through the history as necessary. +This is an incremental search. +This command sets the region to the matched text and activates the region. .TP .B forward\-search\-history (C\-s) -Search forward starting at the current line and moving `down' through -the history as necessary. This is an incremental search. +Search forward starting at the current line and moving +.Q down +through the history as necessary. +This is an incremental search. +This command sets the region to the matched text and activates the region. .TP .B non\-incremental\-reverse\-search\-history (M\-p) Search backward through the history starting at the current line using a non-incremental search for a string supplied by the user. +The search string may match anywhere in a history line. .TP .B non\-incremental\-forward\-search\-history (M\-n) -Search forward through the history using a non-incremental search for -a string supplied by the user. +Search forward through the history using a non-incremental search +for a string supplied by the user. +The search string may match anywhere in a history line. .TP -.B history\-search\-forward -Search forward through the history for the string of characters +.B history\-search\-backward +Search backward through the history for the string of characters between the start of the current line and the point. +The search string must match at the beginning of a history line. This is a non-incremental search. +This may be bound to the Page Up key on some keyboards. .TP -.B history\-search\-backward -Search backward through the history for the string of characters +.B history\-search\-forward +Search forward through the history for the string of characters between the start of the current line and the point. +The search string must match at the beginning of a history line. This is a non-incremental search. +This may be bound to the Page Down key on some keyboards. .TP .B history\-substring\-search\-backward Search backward through the history for the string of characters -between the start of the current line and the current cursor -position (the \fIpoint\fP). +between the start of the current line and the point. The search string may match anywhere in a history line. This is a non-incremental search. .TP @@ -6587,10 +7639,14 @@ the second word on the previous line) at point. With an argument .IR n , insert the \fIn\fPth word from the previous command (the words -in the previous command begin with word 0). A negative argument -inserts the \fIn\fPth word from the end of the previous command. -Once the argument \fIn\fP is computed, the argument is extracted -as if the "!\fIn\fP" history expansion had been specified. +in the previous command begin with word 0). +A negative argument inserts the \fIn\fPth word from the end of +the previous command. +Once the argument \fIn\fP is computed, +this uses the history expansion facilities to extract the +\fIn\fPth word, as if the +.Q !\fIn\fP +history expansion had been specified. .TP .B yank\-last\-arg (M\-.\^, M\-_\^) @@ -6601,31 +7657,39 @@ Successive calls to \fByank\-last\-arg\fP move back through the history list, inserting the last word (or the word specified by the argument to the first call) of each line in turn. Any numeric argument supplied to these successive calls determines -the direction to move through the history. A negative argument switches -the direction through the history (back or forward). -The history expansion facilities are used to extract the last word, -as if the "!$" history expansion had been specified. +the direction to move through the history. +A negative argument switches the direction through the history +(back or forward). +This uses the history expansion facilities to extract the +last word, as if the +.Q !$ +history expansion had been specified. .TP .B shell\-expand\-line (M\-C\-e) -Expand the line as the shell does. This -performs alias and history expansion as well as all of the shell -word expansions. See +Expand the line by performing shell word expansions. +This performs alias and history expansion, +\fB$\fP\*'\fIstring\fP\*' and \fB$\fP\*"\fIstring\fP\*" quoting, +tilde expansion, parameter and variable expansion, arithmetic expansion, +command and process substitution, +word splitting, and quote removal. +An explicit argument suppresses command and process substitution. +See .SM -.B HISTORY EXPANSION +.B "HISTORY EXPANSION" below for a description of history expansion. .TP -.B history\-expand\-line (M\-^) +.B history\-expand\-line (M\-\*^) Perform history expansion on the current line. See .SM -.B HISTORY EXPANSION +.B "HISTORY EXPANSION" below for a description of history expansion. .TP .B magic\-space Perform history expansion on the current line and insert a space. See .SM -.B HISTORY EXPANSION +.B "HISTORY EXPANSION" below for a description of history expansion. .TP .B alias\-expand\-line @@ -6656,10 +7720,9 @@ and \fIemacs\fP as the editor, in that order. .TP .B \fIend\-of\-file\fP (usually C\-d) The character indicating end-of-file as set, for example, by -.if t \f(CWstty\fP. -.if n ``stty''. +.IR stty (1). If this character is read when there are no characters -on the line, and point is at the beginning of the line, readline +on the line, and point is at the beginning of the line, \fBreadline\fP interprets it as the end of input and returns .SM .BR EOF . @@ -6669,9 +7732,11 @@ Delete the character at point. If this function is bound to the same character as the tty \fBEOF\fP character, as \fBC\-d\fP commonly is, see above for the effects. +This may also be bound to the Delete key on some keyboards. .TP .B backward\-delete\-char (Rubout) -Delete the character behind the cursor. When given a numeric argument, +Delete the character behind the cursor. +When given a numeric argument, save the deleted text on the kill ring. .TP .B forward\-backward\-delete\-char @@ -6680,15 +7745,28 @@ end of the line, in which case the character behind the cursor is deleted. .TP .B quoted\-insert (C\-q, C\-v) -Add the next character typed to the line verbatim. This is -how to insert characters like \fBC\-q\fP, for example. +Add the next character typed to the line verbatim. +This is how to insert characters like \fBC\-q\fP, for example. .TP .B tab\-insert (C\-v TAB) Insert a tab character. .TP -.B self\-insert (a,\ b,\ A,\ 1,\ !,\ ...) +.B "self\-insert (a, b, A, 1, !, \fR.\|.\|.\fP)" Insert the character typed. .TP +.B bracketed\-paste\-begin +This function is intended to be bound to the +.Q "bracketed paste" +escape +sequence sent by some terminals, and such a binding is assigned by default. +It allows \fBreadline\fP to insert the pasted text as a single unit +without treating each character as if it had been read from the keyboard. +The pasted characters +are inserted as if each one was bound to \fBself\-insert\fP instead of +executing any editing commands. +.IP +Bracketed paste sets the region to the inserted text and activates the region. +.TP .B transpose\-chars (C\-t) Drag the character before point forward over the character at point, moving point forward as well. @@ -6698,45 +7776,64 @@ Negative arguments have no effect. .TP .B transpose\-words (M\-t) Drag the word before point past the word after point, -moving point over that word as well. +moving point past that word as well. If point is at the end of the line, this transposes the last two words on the line. .TP +.B shell\-transpose\-words (M-C-t) +Drag the word before point past the word after point, +moving point past that word as well. +If the insertion point is at the end of the line, this transposes +the last two words on the line. +Word boundaries are the same as \fBshell\-forward\-word\fP and +\fBshell\-backward\-word\fP. +.TP .B upcase\-word (M\-u) -Uppercase the current (or following) word. With a negative argument, +Uppercase the current (or following) word. +With a negative argument, uppercase the previous word, but do not move point. .TP .B downcase\-word (M\-l) -Lowercase the current (or following) word. With a negative argument, +Lowercase the current (or following) word. +With a negative argument, lowercase the previous word, but do not move point. .TP .B capitalize\-word (M\-c) -Capitalize the current (or following) word. With a negative argument, +Capitalize the current (or following) word. +With a negative argument, capitalize the previous word, but do not move point. .TP .B overwrite\-mode -Toggle overwrite mode. With an explicit positive numeric argument, -switches to overwrite mode. With an explicit non-positive numeric -argument, switches to insert mode. This command affects only -\fBemacs\fP mode; \fBvi\fP mode does overwrite differently. +Toggle overwrite mode. +With an explicit positive numeric argument, switches to overwrite mode. +With an explicit non-positive numeric argument, switches to insert mode. +This command affects only \fBemacs\fP mode; +\fBvi\fP mode does overwrite differently. Each call to \fIreadline()\fP starts in insert mode. +.IP In overwrite mode, characters bound to \fBself\-insert\fP replace the text at point rather than pushing the text to the right. Characters bound to \fBbackward\-delete\-char\fP replace the character -before point with a space. By default, this command is unbound. +before point with a space. +By default, this command is unbound, +but may be bound to the Insert key on some keyboards. .PD .SS Killing and Yanking .PD 0 .TP .B kill\-line (C\-k) -Kill the text from point to the end of the line. +Kill the text from point to the end of the current line. +With a negative numeric argument, kill backward from the cursor to the +beginning of the line. .TP .B backward\-kill\-line (C\-x Rubout) -Kill backward to the beginning of the line. +Kill backward to the beginning of the current line. +With a negative numeric argument, kill forward from the cursor to the +end of the line. .TP .B unix\-line\-discard (C\-u) -Kill backward from point to the beginning of the line. -The killed text is saved on the kill-ring. +Kill backward from point to the beginning of the line, +saving the killed text on the kill-ring. .\" There is no real difference between this and backward-kill-line .TP .B kill\-whole\-line @@ -6751,7 +7848,7 @@ Word boundaries are the same as those used by \fBforward\-word\fP. Kill the word behind point. Word boundaries are the same as those used by \fBbackward\-word\fP. .TP -.B shell\-kill\-word +.B shell\-kill\-word (M\-C\-d) Kill from point to the end of the current word, or if between words, to the end of the next word. Word boundaries are the same as those used by \fBshell\-forward\-word\fP. @@ -6761,13 +7858,13 @@ Kill the word behind point. Word boundaries are the same as those used by \fBshell\-backward\-word\fP. .TP .B unix\-word\-rubout (C\-w) -Kill the word behind point, using white space as a word boundary. -The killed text is saved on the kill-ring. +Kill the word behind point, using white space as a word boundary, +saving the killed text on the kill-ring. .TP .B unix\-filename\-rubout Kill the word behind point, using white space and the slash character -as the word boundaries. -The killed text is saved on the kill-ring. +as the word boundaries, +saving the killed text on the kill-ring. .TP .B delete\-horizontal\-space (M\-\e) Delete all spaces and tabs around point. @@ -6776,7 +7873,8 @@ Delete all spaces and tabs around point. Kill the text in the current region. .TP .B copy\-region\-as\-kill -Copy the text in the region to the kill buffer. +Copy the text in the region to the kill buffer, +so it can be yanked immediately. .TP .B copy\-backward\-word Copy the word before point to the kill buffer. @@ -6790,7 +7888,8 @@ The word boundaries are the same as \fBforward\-word\fP. Yank the top of the kill ring into the buffer at point. .TP .B yank\-pop (M\-y) -Rotate the kill ring, and yank the new top. Only works following +Rotate the kill ring, and yank the new top. +Only works following .B yank or .BR yank\-pop . @@ -6798,9 +7897,10 @@ or .SS Numeric Arguments .PD 0 .TP -.B digit\-argument (M\-0, M\-1, ..., M\-\-) +.B digit\-argument (M\-0, M\-1, \fR.\|.\|.\fP, M\-\-) Add this digit to the argument already accumulating, or start a new -argument. M\-\- starts a negative argument. +argument. +M\-\- starts a negative argument. .TP .B universal\-argument This is another way to specify an argument. @@ -6810,8 +7910,8 @@ If the command is followed by digits, executing .B universal\-argument again ends the numeric argument, but is otherwise ignored. As a special case, if this command is immediately followed by a -character that is neither a digit nor minus sign, the argument count -for the next command is multiplied by four. +character that is neither a digit nor minus sign, +the argument count for the next command is multiplied by four. The argument count is initially one, so executing this function the first time makes the argument count four, a second time makes the argument count sixteen, and so on. @@ -6822,44 +7922,89 @@ argument count sixteen, and so on. .B complete (TAB) Attempt to perform completion on the text before point. .B Bash -attempts completion treating the text as a variable (if the -text begins with \fB$\fP), username (if the text begins with -\fB~\fP), hostname (if the text begins with \fB@\fP), or -command (including aliases and functions) in turn. If none -of these produces a match, filename completion is attempted. +attempts completion by first checking for any programmable +completions for the command word (see \fBProgrammable Completion\fP below), +otherwise treating the text as a +variable (if the text begins with \fB$\fP), +username (if the text begins with \fB\*~\fP), +hostname (if the text begins with \fB@\fP), or +command (including aliases, functions, and builtins) in turn. +If none of these produces a match, it falls back to filename completion. .TP .B possible\-completions (M\-?) List the possible completions of the text before point. +When displaying completions, \fBreadline\fP sets the number of columns used +for display to the value of \fBcompletion-display-width\fP, the value of +the shell variable +.SM +.BR COLUMNS , +or the screen width, in that order. .TP .B insert\-completions (M\-*) Insert all completions of the text before point that would have been generated by -\fBpossible\-completions\fP. +\fBpossible\-completions\fP, +separated by a space. .TP .B menu\-complete Similar to \fBcomplete\fP, but replaces the word to be completed with a single match from the list of possible completions. -Repeated execution of \fBmenu\-complete\fP steps through the list +Repeatedly executing \fBmenu\-complete\fP steps through the list of possible completions, inserting each match in turn. -At the end of the list of completions, the bell is rung +At the end of the list of completions, +\fBmenu\-complete\fP rings the bell (subject to the setting of \fBbell\-style\fP) -and the original text is restored. +and restores the original text. An argument of \fIn\fP moves \fIn\fP positions forward in the list -of matches; a negative argument may be used to move backward -through the list. +of matches; a negative argument moves backward through the list. This command is intended to be bound to \fBTAB\fP, but is unbound by default. .TP .B menu\-complete\-backward Identical to \fBmenu\-complete\fP, but moves backward through the list of possible completions, as if \fBmenu\-complete\fP had been given a -negative argument. This command is unbound by default. +negative argument. +This command is unbound by default. +.TP +.B export\-completions +Perform completion on the word before point as described above +and write the list of possible completions to \fBreadline\fP's output +stream using the following format, writing information on separate lines: +.RS +.PD +.IP \(bu +.PD 0 +the number of matches \fIN\fP; +.IP \(bu +the word being completed; +.IP \(bu +\fIS\fP:\fIE\fP, +where \fIS\fP and \fIE\fP are the start and end offsets of the word +in the \fBreadline\fP line buffer; then +.IP \(bu +each match, one per line +.RE +.PD +.IP +If there are no matches, the first line will be +.Q 0 , +and this command does not print any output after the \fIS\fP:\fIE\fP. +If there is only a single match, this prints a single line containing it. +If there is more than one match, this prints the common prefix of the +matches, which may be empty, on the first line after the \fIS\fP:\fIE\fP, +then the matches on subsequent lines. +In this case, \fIN\fP will include the first line with the common prefix. +.IP +The user or application +should be able to accommodate the possibility of a blank line. +The intent is that the user or application reads \fIN\fP lines after +the line containing \fIS\fP:\fIE\fP to obtain the match list. +This command is unbound by default. .TP .B delete\-char\-or\-list Deletes the character under the cursor if not at the beginning or end of the line (like \fBdelete\-char\fP). -If at the end of the line, behaves identically to -\fBpossible\-completions\fP. +At the end of the line, it behaves identically to \fBpossible\-completions\fP. This command is unbound by default. .TP .B complete\-filename (M\-/) @@ -6869,11 +8014,11 @@ Attempt filename completion on the text before point. List the possible completions of the text before point, treating it as a filename. .TP -.B complete\-username (M\-~) +.B complete\-username (M\-\*~) Attempt completion on the text before point, treating it as a username. .TP -.B possible\-username\-completions (C\-x ~) +.B possible\-username\-completions (C\-x \*~) List the possible completions of the text before point, treating it as a username. .TP @@ -6895,7 +8040,8 @@ treating it as a hostname. .TP .B complete\-command (M\-!) Attempt completion on the text before point, treating -it as a command name. Command completion attempts to +it as a command name. +Command completion attempts to match the text against aliases, reserved words, shell functions, shell builtins, and finally executable filenames, in that order. @@ -6906,7 +8052,7 @@ treating it as a command name. .TP .B dynamic\-complete\-history (M\-TAB) Attempt completion on the text before point, comparing -the text against lines from the history list for possible +the text against history list entries for possible completion matches. .TP .B dabbrev\-expand @@ -6917,10 +8063,10 @@ completion matches. .B complete\-into\-braces (M\-{) Perform filename completion and insert the list of possible completions enclosed within braces so the list is available to the shell (see -.B Brace Expansion +.B "Brace Expansion" above). .PD -.SS Keyboard Macros +.SS "Keyboard Macros" .PD 0 .TP .B start\-kbd\-macro (C\-x (\^) @@ -6950,7 +8096,7 @@ Abort the current editing command and ring the terminal's bell (subject to the setting of .BR bell\-style ). .TP -.B do\-lowercase\-version (M\-A, M\-B, M\-\fIx\fP, ...) +.B do\-lowercase\-version (M\-A, M\-B, M\-\fIx\fP, \fR.\|.\|.\fP) If the metafied character \fIx\fP is uppercase, run the command that is bound to the corresponding metafied lowercase character. The behavior is undefined if \fIx\fP is already lowercase. @@ -6967,7 +8113,8 @@ is equivalent to Incremental undo, separately remembered for each line. .TP .B revert\-line (M\-r) -Undo all changes made to this line. This is like executing the +Undo all changes made to this line. +This is like executing the .B undo command enough times to return the line to its initial state. .TP @@ -6975,39 +8122,43 @@ command enough times to return the line to its initial state. Perform tilde expansion on the current word. .TP .B set\-mark (C\-@, M\-) -Set the mark to the point. If a -numeric argument is supplied, the mark is set to that position. +Set the mark to the point. +If a numeric argument is supplied, set the mark to that position. .TP .B exchange\-point\-and\-mark (C\-x C\-x) -Swap the point with the mark. The current cursor position is set to -the saved position, and the old cursor position is saved as the mark. +Swap the point with the mark. +Set the current cursor position to the saved position, +then set the mark to the old cursor position. .TP .B character\-search (C\-]) -A character is read and point is moved to the next occurrence of that -character. A negative argument searches for previous occurrences. +Read a character and move point to the next occurrence of that character. +A negative argument searches for previous occurrences. .TP .B character\-search\-backward (M\-C\-]) -A character is read and point is moved to the previous occurrence of that -character. A negative argument searches for subsequent occurrences. +Read a character and move point to the previous occurrence of that character. +A negative argument searches for subsequent occurrences. .TP .B skip\-csi\-sequence Read enough characters to consume a multi-key sequence such as those -defined for keys like Home and End. Such sequences begin with a -Control Sequence Indicator (CSI), usually ESC\-[. If this sequence is -bound to "\e[", keys producing such sequences will have no effect -unless explicitly bound to a readline command, instead of inserting -stray characters into the editing buffer. This is unbound by default, -but usually bound to ESC\-[. +defined for keys like Home and End. +CSI sequences begin with a Control Sequence Indicator (CSI), usually +.IR "ESC [" . +If this sequence is bound to +.Q \ee[ , +keys producing CSI sequences have no effect +unless explicitly bound to a \fBreadline\fP command, +instead of inserting stray characters into the editing buffer. +This is unbound by default, but usually bound to +.IR "ESC [" . .TP .B insert\-comment (M\-#) -Without a numeric argument, the value of the readline +Without a numeric argument, insert the value of the \fBreadline\fP .B comment\-begin -variable is inserted at the beginning of the current line. +variable at the beginning of the current line. If a numeric argument is supplied, this command acts as a toggle: if the characters at the beginning of the line do not match the value -of \fBcomment\-begin\fP, the value is inserted, otherwise -the characters in \fBcomment\-begin\fP are deleted from the beginning of -the line. +of \fBcomment\-begin\fP, insert the value; otherwise delete +the characters in \fBcomment-begin\fP from the beginning of the line. In either case, the line is accepted as if a newline had been typed. The default value of \fBcomment\-begin\fP causes this command to make the current line @@ -7021,106 +8172,136 @@ or filename, in the same way as the \fBcdspell\fP shell option. Word boundaries are the same as those used by \fBshell\-forward\-word\fP. .TP .B glob\-complete\-word (M\-g) -The word before point is treated as a pattern for pathname expansion, -with an asterisk implicitly appended. This pattern is used to -generate a list of matching filenames for possible completions. +Treat the word before point as a pattern for pathname expansion, +with an asterisk implicitly appended, then use the pattern to +generate a list of matching file names for possible completions. .TP .B glob\-expand\-word (C\-x *) -The word before point is treated as a pattern for pathname expansion, -and the list of matching filenames is inserted, replacing the word. -If a numeric argument is supplied, an asterisk is appended before +Treat the word before point as a pattern for pathname expansion, +and insert the list of matching file names, replacing the word. +If a numeric argument is supplied, append a \fB*\fP before pathname expansion. .TP .B glob\-list\-expansions (C\-x g) -The list of expansions that would have been generated by +Display the list of expansions that would have been generated by .B glob\-expand\-word -is displayed, and the line is redrawn. -If a numeric argument is supplied, an asterisk is appended before +and redisplay the line. +If a numeric argument is supplied, append a \fB*\fP before pathname expansion. .TP .B dump\-functions -Print all of the functions and their key bindings to the -readline output stream. If a numeric argument is supplied, +Print all of the functions and their key bindings +to the \fBreadline\fP output stream. +If a numeric argument is supplied, the output is formatted in such a way that it can be made part of an \fIinputrc\fP file. .TP .B dump\-variables -Print all of the settable readline variables and their values to the -readline output stream. If a numeric argument is supplied, +Print all of the settable \fBreadline\fP variables and their values +to the \fBreadline\fP output stream. +If a numeric argument is supplied, the output is formatted in such a way that it can be made part of an \fIinputrc\fP file. .TP .B dump\-macros -Print all of the readline key sequences bound to macros and the -strings they output. If a numeric argument is supplied, +Print all of the \fBreadline\fP key sequences bound to macros and the +strings they output +to the \fBreadline\fP output stream. +If a numeric argument is supplied, the output is formatted in such a way that it can be made part of an \fIinputrc\fP file. .TP +.B execute\-named\-command (M-x) +Read a bindable \fBreadline\fP command name from the input and execute the +function to which it's bound, as if the key sequence to which it was +bound appeared in the input. +If this function is supplied with a numeric argument, it passes that +argument to the function it executes. +.TP .B display\-shell\-version (C\-x C\-v) Display version information about the current instance of .BR bash . .PD -.SS Programmable Completion -When word completion is attempted for an argument to a command for +.SS "Programmable Completion" +When a user attempts word completion +for a command or an argument to a command for which a completion specification (a \fIcompspec\fP) has been defined -using the \fBcomplete\fP builtin (see +using the \fBcomplete\fP builtin +(see .SM .B "SHELL BUILTIN COMMANDS" -below), the programmable completion facilities are invoked. +below), +\fBreadline\fP invokes the programmable completion facilities. .PP -First, the command name is identified. -If the command word is the empty string (completion attempted at the -beginning of an empty line), any compspec defined with -the \fB\-E\fP option to \fBcomplete\fP is used. +First, \fBbash\fP identifies the command name. If a compspec has been defined for that command, the compspec is used to generate the list of possible completions for the word. -If the command word is a full pathname, a compspec for the full -pathname is searched for first. -If no compspec is found for the full pathname, an attempt is made to +If the command word is the empty string (completion attempted at the +beginning of an empty line), \fBbash\fP uses any compspec defined with +the \fB\-E\fP option to \fBcomplete\fP. +The \fB\-I\fP option to \fBcomplete\fP +indicates that the command word is the first non-assignment word +on the line, or after a command delimiter such as +\fB;\fP or \fB|\fP. +This usually indicates command name completion. +.PP +If the command word is a full pathname, \fBbash\fP +searches for a compspec for the full pathname first. +If there is no compspec for the full pathname, \fBbash\fP attempts to find a compspec for the portion following the final slash. -If those searches do not result in a compspec, any compspec defined with -the \fB\-D\fP option to \fBcomplete\fP is used as the default. -If there is no default compspec, \fBbash\fP attempts alias expansion -on the command word as a final resort, and attempts to find a compspec -for the command word from any successful expansion. -.PP -Once a compspec has been found, it is used to generate the list of -matching words. -If a compspec is not found, the default \fBbash\fP completion as -described above under \fBCompleting\fP is performed. -.PP -First, the actions specified by the compspec are used. -Only matches which are prefixed by the word being completed are -returned. +If those searches do not result in a compspec, +or if there is no compspec for the command word, +\fBbash\fP uses any compspec defined with +the \fB\-D\fP option to \fBcomplete\fP as the default. +If there is no default compspec, \fBbash\fP performs alias expansion +on the command word as a final resort, +and attempts to find a compspec for the command word +resulting from any successful expansion. +.PP +If a compspec is not found, \fBbash\fP performs its default completion as +described above under \fBCompleting\fP. +Otherwise, once a compspec has been found, \fBbash\fP uses it to generate +the list of matching words. +.PP +First, \fBbash\fP performs the \fIactions\fP specified by the compspec. +This only returns matches which are prefixes +of the word being completed. When the .B \-f or .B \-d -option is used for filename or directory name completion, the shell -variable +option is used for filename or directory name completion, +\fBbash\fP uses the shell variable .SM .B FIGNORE -is used to filter the matches. +to filter the matches. .PP -Any completions specified by a pathname expansion pattern to the -\fB\-G\fP option are generated next. +Next, programmable completion generates matches +specified by a pathname expansion pattern +supplied as an argument to the +\fB\-G\fP option. The words generated by the pattern need not match the word being completed. -The -.SM -.B GLOBIGNORE -shell variable is not used to filter the matches, but the +\fBBash\fP +uses the .SM .B FIGNORE -variable is used. +variable to filter the matches, but does not use the +.SM +.B GLOBIGNORE +shell variable. .PP -Next, the string specified as the argument to the \fB\-W\fP option -is considered. +Next, completion considers +the string specified as the argument to the \fB\-W\fP option. The string is first split using the characters in the .SM .B IFS special variable as delimiters. -Shell quoting is honored. +This honors shell quoting within the string, in order to provide a +mechanism for the words to contain shell metacharacters or characters +in the value of +.SM +.BR IFS . Each word is then expanded using brace expansion, tilde expansion, parameter and variable expansion, command substitution, and arithmetic expansion, @@ -7130,11 +8311,13 @@ as described above under The results are split using the rules described above under \fBWord Splitting\fP. The results of the expansion are prefix-matched against the word being -completed, and the matching words become the possible completions. +completed, and the matching words become possible completions. .PP -After these matches have been generated, any shell function or command -specified with the \fB\-F\fP and \fB\-C\fP options is invoked. -When the command or function is invoked, the +After these matches have been generated, +\fBbash\fP executes any shell function or command +specified with the \fB\-F\fP and \fB\-C\fP options. +When the command or function is invoked, \fBbash\fP +assigns values to the .SM .BR COMP_LINE , .SM @@ -7144,28 +8327,31 @@ When the command or function is invoked, the and .SM .B COMP_TYPE -variables are assigned values as described above under -\fBShell Variables\fP. -If a shell function is being invoked, the +variables as described above +under \fBShell Variables\fP. +If a shell function is being invoked, \fBbash\fP +also sets the .SM .B COMP_WORDS and .SM .B COMP_CWORD -variables are also set. +variables. When the function or command is invoked, -the first argument (\fB$1\fP) is the name of the command whose arguments are -being completed, +the first argument (\fB$1\fP) is the name of the command whose arguments +are being completed, the second argument (\fB$2\fP) is the word being completed, and the third argument (\fB$3\fP) is the word preceding the word being completed on the current command line. -No filtering of the generated completions against the word being completed -is performed; the function or command has complete freedom in generating -the matches. +There is no filtering of the generated completions against the +word being completed; +the function or command has complete freedom in generating the matches +and they do not need to match a prefix of the word. .PP Any function specified with \fB\-F\fP is invoked first. The function may use any of the shell facilities, including the -\fBcompgen\fP builtin described below, to generate the matches. +\fBcompgen\fP and \fBcompopt\fP +builtins described below, to generate the matches. It must put the possible completions in the .SM .B COMPREPLY @@ -7175,81 +8361,110 @@ Next, any command specified with the \fB\-C\fP option is invoked in an environment equivalent to command substitution. It should print a list of completions, one per line, to the standard output. -Backslash may be used to escape a newline, if necessary. +Backslash will escape a newline, if necessary. +These are added to the set of possible completions. .PP -After all of the possible completions are generated, any filter -specified with the \fB\-X\fP option is applied to the list. +After generating all of the possible completions, +\fBbash\fP applies any filter +specified with the \fB\-X\fP option to the completions in the list. The filter is a pattern as used for pathname expansion; a \fB&\fP in the pattern is replaced with the text of the word being completed. A literal \fB&\fP may be escaped with a backslash; the backslash is removed before attempting a match. -Any completion that matches the pattern will be removed from the list. -A leading \fB!\fP negates the pattern; in this case any completion -not matching the pattern will be removed. +Any completion that matches the pattern is removed from the list. +A leading \fB!\fP negates the pattern; +in this case \fBbash\fP removes +any completion that does not match the pattern. If the .B nocasematch -shell option is enabled, the match is performed without regard to the case +shell option is enabled, +\fBbash\fP performs the match without regard to the case of alphabetic characters. .PP -Finally, any prefix and suffix specified with the \fB\-P\fP and \fB\-S\fP -options are added to each member of the completion list, and the result is -returned to the readline completion code as the list of possible -completions. +Finally, programmable completion adds +any prefix and suffix specified with the +\fB\-P\fP and \fB\-S\fP +options, respectively, to each completion, +and returns the result +to \fBreadline\fP as the list of possible completions. .PP If the previously-applied actions do not generate any matches, and the \fB\-o dirnames\fP option was supplied to \fBcomplete\fP when the -compspec was defined, directory name completion is attempted. +compspec was defined, \fBbash\fP attempts directory name completion. .PP If the \fB\-o plusdirs\fP option was supplied to \fBcomplete\fP when the -compspec was defined, directory name completion is attempted and any -matches are added to the results of the other actions. +compspec was defined, \fBbash\fP attempts directory name completion and +adds any matches to the set of possible completions. .PP By default, if a compspec is found, whatever it generates is returned to the completion code as the full set of possible completions. -The default \fBbash\fP completions are not attempted, and the readline -default of filename completion is disabled. +The default \fBbash\fP completions and the \fBreadline\fP +default of filename completion are disabled. If the \fB\-o bashdefault\fP option was supplied to \fBcomplete\fP when -the compspec was defined, the \fBbash\fP default completions are attempted -if the compspec generates no matches. -If the \fB\-o default\fP option was supplied to \fBcomplete\fP when the -compspec was defined, readline's default completion will be performed -if the compspec (and, if attempted, the default \fBbash\fP completions) -generate no matches. -.PP -When a compspec indicates that directory name completion is desired, -the programmable completion functions force readline to append a slash -to completed names which are symbolic links to directories, subject to -the value of the \fBmark\-directories\fP readline variable, regardless -of the setting of the \fBmark-symlinked\-directories\fP readline variable. -.PP -There is some support for dynamically modifying completions. This is -most useful when used in combination with a default completion specified -with \fBcomplete \-D\fP. -It's possible for shell functions executed as completion -handlers to indicate that completion should be retried by returning an -exit status of 124. If a shell function returns 124, and changes +the compspec was defined, +and the compspec generates no matches, +\fBbash\fP attempts its default completions. +If the compspec and, if attempted, the default \fBbash\fP completions +generate no matches, +and the \fB\-o default\fP option was supplied to +\fBcomplete\fP when the compspec was defined, +programmable completion performs \fBreadline\fP's default completion. +.PP +The options supplied to \fBcomplete\fP and \fBcompopt\fP +can control how \fBreadline\fP treats the completions. +For instance, the \fI\-o fullquote\fP option tells \fBreadline\fP +to quote the matches as if they were filenames. +See the description of \fBcomplete\fP below +for details. +.PP +When a compspec indicates that it wants directory name completion, +the programmable completion functions force \fBreadline\fP +to append a slash to completed names which are symbolic links +to directories, subject to the value of the +\fBmark\-directories\fP \fBreadline\fP variable, +regardless of the setting of the +\fBmark-symlinked\-directories\fP \fBreadline\fP variable. +.PP +There is some support for dynamically modifying completions. +This is most useful when used in combination with a default completion +specified with \fBcomplete \-D\fP. +It's possible for shell functions executed as completion functions +to indicate that completion should be retried by returning an +exit status of 124. +If a shell function returns 124, and changes the compspec associated with the command on which completion is being attempted (supplied as the first argument when the function is executed), programmable completion restarts from the beginning, with an -attempt to find a new compspec for that command. This allows a set of -completions to be built dynamically as completion is attempted, rather than -being loaded all at once. +attempt to find a new compspec for that command. +This can be used to build a set of completions dynamically +as completion is attempted, rather than loading them all at once. .PP For instance, assuming that there is a library of compspecs, each kept in a file corresponding to the name of the command, the following default completion function would load completions dynamically: -.PP -\f(CW_completion_loader() -.br +.RS +.EX +.nf +_completion_loader() { + . \*"/etc/bash_completion.d/$1.sh\*" \c +.if \n(LL<80n \{\ +\e .br - . "/etc/bash_completion.d/$1.sh" >/dev/null 2>&1 && return 124 -.br +.ti +4n +.\} +>/dev/null 2>&1 && return 124 } +complete \-D \-F _completion_loader \c +.if \n(LL<80n \{\ +\e .br -complete -D -F _completion_loader -o bashdefault -o default -.br -\fP +.ti +4n +.\} +\-o bashdefault \-o default +.fi +.EE +.RE .SH HISTORY When the .B \-o history @@ -7262,13 +8477,13 @@ The value of the .SM .B HISTSIZE variable is used as the -number of commands to save in a history list. -The text of the last +number of commands to save in a history list: +the shell saves the text of the last .SM .B HISTSIZE -commands (default 500) is saved. The shell -stores each command in the history list prior to parameter and -variable expansion (see +commands (default 500). +The shell stores each command in the history list prior to +parameter and variable expansion (see .SM .B EXPANSION above) but after history expansion is performed, subject to the @@ -7279,20 +8494,26 @@ and .SM .BR HISTCONTROL . .PP -On startup, the history is initialized from the file named by -the variable +On startup, \fBbash\fP initializes the history list +by reading history entries from the +file named by the .SM .B HISTFILE -(default \fI~/.bash_history\fP). -The file named by the value of +variable (default +.FN \*~/.bash_history ). +That file is referred to as the \fIhistory file\fP. +The history file is truncated, if necessary, +to contain no more than the number of history entries +specified by the value of the .SM -.B HISTFILE -is truncated, if necessary, to contain no more than -the number of lines specified by the value of +.B HISTFILESIZE +variable. +If .SM -.BR HISTFILESIZE . -If \fBHISTFILESIZE\fP is unset, or set to null, a non-numeric value, +.B HISTFILESIZE +is unset, or set to null, a non-numeric value, or a numeric value less than zero, the history file is not truncated. +.PP When the history file is read, lines beginning with the history comment character followed immediately by a digit are interpreted as timestamps for the following history line. @@ -7300,10 +8521,13 @@ These timestamps are optionally displayed depending on the value of the .SM .B HISTTIMEFORMAT variable. -When a shell with history enabled exits, the last +When present, history timestamps delimit history entries, making +multi-line entries possible. +.PP +When a shell with history enabled exits, \fBbash\fP copies the last .SM .B $HISTSIZE -lines are copied from the history list to +entries from the history list to .SM .BR $HISTFILE . If the @@ -7314,64 +8538,66 @@ shell option is enabled under .SM .B "SHELL BUILTIN COMMANDS" -below), the lines are appended to the history file, -otherwise the history file is overwritten. +below), \fBbash\fP appends the entries to the history file, +otherwise it overwrites the history file. If .SM .B HISTFILE -is unset, or if the history file is unwritable, the history is -not saved. +is unset or null, +or if the history file is unwritable, the history is not saved. +After saving the history, \fBbash\fP truncates the history file +to contain no more than +.SM +.B HISTFILESIZE +lines as described above. +.PP If the .SM .B HISTTIMEFORMAT -variable is set, time stamps are written to the history file, marked -with the history comment character, so -they may be preserved across shell sessions. +variable is set, the shell writes +the timestamp information +associated with each history entry to the history file, +marked with the history comment character, so +timestamps are preserved across shell sessions. This uses the history comment character to distinguish timestamps from other history lines. -After saving the history, the history file is truncated -to contain no more than +As above, when using .SM -.B HISTFILESIZE -lines. If -.SM -.B HISTFILESIZE -is unset, or set to null, a non-numeric value, -or a numeric value less than zero, the history file is not truncated. +.BR HISTTIMEFORMAT , +the timestamps delimit multi-line history entries. .PP -The builtin command +The .B fc -(see +builtin command (see .SM -.B SHELL BUILTIN COMMANDS -below) may be used to list or edit and re-execute a portion of -the history list. +.B "SHELL BUILTIN COMMANDS" +below) will list or edit and re-execute a portion of the history list. The .B history -builtin may be used to display or modify the history list and +builtin can display or modify the history list and manipulate the history file. When using command-line editing, search commands are available in each editing mode that provide access to the history list. .PP -The shell allows control over which commands are saved on the history -list. The +The shell allows control over which commands are saved on the history list. +The .SM .B HISTCONTROL and .SM .B HISTIGNORE -variables may be set to cause the shell to save only a subset of the -commands entered. -The +variables are used to save only a subset of the commands entered. +If the .B cmdhist -shell option, if enabled, causes the shell to attempt to save each +shell option is enabled, the shell attempts to save each line of a multi-line command in the same history entry, adding semicolons where necessary to preserve syntactic correctness. The .B lithist -shell option causes the shell to save the command with embedded newlines -instead of semicolons. See the description of the +shell option modifies \fBcmdhist\fP by saving +the command with embedded newlines instead of semicolons. +See the description of the .B shopt builtin below under .SM @@ -7381,17 +8607,20 @@ for information on setting and unsetting shell options. The shell supports a history expansion feature that is similar to the history expansion in .BR csh . -This section describes what syntax features are available. This -feature is enabled by default for interactive shells, and can be -disabled using the +This section describes what syntax features are available. +.PP +History expansion is enabled by default for interactive shells, +and can be disabled using the .B +H option to the .B set builtin command (see .SM -.B SHELL BUILTIN COMMANDS -below). Non-interactive shells do not perform history expansion -by default. +.B "SHELL BUILTIN COMMANDS" +below). +Non-interactive shells do not perform history expansion by default, +but it can be enabled with +.Q "set -H" . .PP History expansions introduce words from the history list into the input stream, making it easy to repeat commands, insert the @@ -7400,21 +8629,31 @@ fix errors in previous commands quickly. .PP History expansion is performed immediately after a complete line is read, before the shell breaks it into words, and is performed -on each line individually without taking quoting on previous lines into -account. +on each line individually. +The shell attempts to inform the history +expansion functions about quoting still in effect from previous lines. +.PP It takes place in two parts. -The first is to determine which line from the history list +The first is to determine which history list entry to use during substitution. -The second is to select portions of that line for inclusion into +The second is to select portions of that entry to include into the current one. -The line selected from the history is the \fIevent\fP, -and the portions of that line that are acted upon are \fIwords\fP. +.PP +The entry selected from the history is the \fIevent\fP, +and the portions of that entry that are acted upon are \fIwords\fP. Various \fImodifiers\fP are available to manipulate the selected words. -The line is broken into words in the same fashion as when reading input, +The entry is split into words in the same fashion as when reading input, so that several \fImetacharacter\fP-separated words surrounded by quotes are considered one word. +The \fIevent designator\fP selects the event, the optional +\fIword designator\fP selects words from the event, and +various optional \fImodifiers\fP are available to manipulate the +selected words. +.PP History expansions are introduced by the appearance of the history expansion character, which is \^\fB!\fP\^ by default. +History expansions may appear anywhere in the input, but do not nest. +.PP Only backslash (\^\fB\e\fP\^) and single quotes can quote the history expansion character, but the history expansion character is also treated as quoted if it immediately precedes the closing double quote @@ -7422,18 +8661,29 @@ in a double-quoted string. .PP Several characters inhibit history expansion if found immediately following the history expansion character, even if it is unquoted: -space, tab, newline, carriage return, and \fB=\fP. -If the \fBextglob\fP shell option is enabled, \fB(\fP will also -inhibit expansion. +space, tab, newline, carriage return, \fB=\fP, +and the other shell metacharacters defined above. +.PP +There is a special abbreviation for substitution, active when the +\fIquick substitution\fP character (described above under +.BR histchars ) +is the first character on the line. +It selects the previous history list entry, using an event designator +equivalent to \fB!!\fP, +and substitutes one string for another in that entry. +It is described below under \fBEvent Designators\fP. +This is the only history expansion that does not begin with the history +expansion character. .PP Several shell options settable with the .B shopt -builtin may be used to tailor the behavior of history expansion. +builtin will modify history expansion behavior +(see the description of the +.B shopt +builtin below).and If the .B histverify -shell option is enabled (see the description of the -.B shopt -builtin below), and +shell option is enabled, and .B readline is being used, history substitutions are not immediately passed to the shell parser. @@ -7444,21 +8694,22 @@ If .B readline is being used, and the .B histreedit -shell option is enabled, a failed history substitution will be reloaded +shell option is enabled, a failed history substitution is reloaded into the .B readline editing buffer for correction. +.PP The .B \-p option to the .B history -builtin command may be used to see what a history expansion will +builtin command shows what a history expansion will do before using it. The .B \-s option to the .B history -builtin may be used to add commands to the end of the history list +builtin will add commands to the end of the history list without actually executing them, so that they are available for subsequent recall. .PP @@ -7471,8 +8722,11 @@ The shell uses the history comment character to mark history timestamps when writing the history file. .SS Event Designators -An event designator is a reference to a command line entry in the -history list. +An event designator is a reference to an entry in the history list. +The event designator +consists of the portion of the word beginning with the history +expansion character and ending with the word designator if present, +or the end of the word. Unless the reference is absolute, events are relative to the current position in the history list. .PP @@ -7481,43 +8735,47 @@ position in the history list. .B ! Start a history substitution, except when followed by a .BR blank , -newline, carriage return, = -or ( (when the \fBextglob\fP shell option is enabled using -the \fBshopt\fP builtin). +newline, carriage return, =, +or, when the \fBextglob\fP shell option is enabled using +the \fBshopt\fP builtin, (. .TP -.B !\fIn\fR -Refer to command line +.B !\fIn\fP +Refer to history list entry .IR n . .TP -.B !\-\fIn\fR -Refer to the current command minus +.B !\-\fIn\fP +Refer to the current entry minus .IR n . .TP .B !! -Refer to the previous command. This is a synonym for `!\-1'. +Refer to the previous entry. +This is a synonym for +.Q !\-1 . .TP -.B !\fIstring\fR +.B !\fIstring\fP Refer to the most recent command preceding the current position in the history list starting with .IR string . .TP -.B !?\fIstring\fR\fB[?]\fR +.B !?\fIstring\fR\fB[?]\fP Refer to the most recent command preceding the current position in the history list containing .IR string . The trailing \fB?\fP may be omitted if .I string is followed immediately by a newline. -If \fIstring\fP is missing, the string from the most recent search is used; +If \fIstring\fP is missing, this uses +the string from the most recent search; it is an error if there is no previous search string. .TP -.B \d\s+2^\s-2\u\fIstring1\fP\d\s+2^\s-2\u\fIstring2\fP\d\s+2^\s-2\u -Quick substitution. Repeat the previous command, replacing +.B \d\s+2\*^\s-2\u\fIstring1\fP\d\s+2\*^\s-2\u\fIstring2\fP\d\s+2\*^\s-2\u +Quick substitution. +Repeat the previous command, replacing .I string1 with .IR string2 . Equivalent to -``!!:s\d\s+2^\s-2\u\fIstring1\fP\d\s+2^\s-2\u\fIstring2\fP\d\s+2^\s-2\u'' +.Q !!:s\d\s+2\*^\s-2\u\fIstring1\fP\d\s+2\*^\s-2\u\fIstring2\fP\d\s+2\*^\s-2\u (see \fBModifiers\fP below). .TP .B !# @@ -7525,11 +8783,13 @@ The entire command line typed so far. .PD .SS Word Designators Word designators are used to select desired words from the event. +They are optional; if the word designator isn't supplied, the history +expansion uses the entire event. A .B : separates the event specification from the word designator. It may be omitted if the word designator begins with a -.BR ^ , +.BR \*^ , .BR $ , .BR * , .BR \- , @@ -7542,32 +8802,43 @@ Words are inserted into the current line separated by single spaces. .PD 0 .TP .B 0 (zero) -The zeroth word. For the shell, this is the command -word. +The zeroth word. +For the shell, this is the command word. .TP .I n -The \fIn\fRth word. +The \fIn\fPth word. .TP -.B ^ -The first argument. That is, word 1. +.B \*^ +The first argument: word 1. .TP .B $ -The last word. This is usually the last argument, but will expand to the +The last word. +This is usually the last argument, but will expand to the zeroth word if there is only one word in the line. .TP .B % -The first word matched by the most recent `?\fIstring\fR?' search, +The first word matched by the most recent +.Q ?\fIstring\fP? +search, if the search string begins with a character that is part of a word. +By default, searches begin at the end of each line and proceed to the +beginning, so the first word matched is the one closest to the end of +the line. .TP .I x\fB\-\fPy -A range of words; `\-\fIy\fR' abbreviates `0\-\fIy\fR'. +A range of words; +.Q \-\fIy\fP +abbreviates +.Q 0\-\fIy\fP . .TP .B * -All of the words but the zeroth. This is a synonym -for `\fI1\-$\fP'. It is not an error to use +All of the words but the zeroth. +This is a synonym for +.Q \fI1\-$\fP . +It is not an error to use .B * -if there is just one -word in the event; the empty string is returned in that case. +if there is just one word in the event; +it expands to the empty string in that case. .TP .B x* Abbreviates \fIx\-$\fP. @@ -7578,19 +8849,20 @@ If \fBx\fP is missing, it defaults to 0. .PD .PP If a word designator is supplied without an event specification, the -previous command is used as the event. +previous command is used as the event, equivalent to \fB!!\fP. .SS Modifiers -After the optional word designator, there may appear a sequence of -one or more of the following modifiers, each preceded by a `:'. +After the optional word designator, the expansion may include a +sequence of one or more of the following modifiers, each preceded by a +.Q : . These modify, or edit, the word or words selected from the history event. .PP .PD 0 .TP .B h -Remove a trailing filename component, leaving only the head. +Remove a trailing pathname component, leaving only the head. .TP .B t -Remove all leading filename components, leaving the tail. +Remove all leading pathname components, leaving the tail. .TP .B r Remove a trailing suffix of the form \fI.xxx\fP, leaving the @@ -7611,8 +8883,8 @@ Quote the substituted words as with but break into words at .B blanks and newlines. -The \fBq\fP and \fBx\fP modifiers are mutually exclusive; the last one -supplied is used. +The \fBq\fP and \fBx\fP modifiers are mutually exclusive; +expansion uses the last one supplied. .TP .B s/\fIold\fP/\fInew\fP/ Substitute @@ -7623,15 +8895,15 @@ in the event line. Any character may be used as the delimiter in place of /. The final delimiter is optional if it is the last character of the event line. -The delimiter may be quoted in +A single backslash quotes the delimiter in .I old and -.I new -with a single backslash. If & appears in +.IR new . +If & appears in .IR new , -it is replaced by +it is replaced with .IR old . -A single backslash will quote the &. +A single backslash quotes the &. If .I old is null, it is set to the last @@ -7640,7 +8912,7 @@ substituted, or, if no previous history substitutions took place, the last .I string in a -.B !?\fIstring\fR\fB[?]\fR +.B !?\fIstring\fP[?] search. If .I new @@ -7652,17 +8924,26 @@ is deleted. Repeat the previous substitution. .TP .B g -Cause changes to be applied over the entire event line. This is -used in conjunction with `\fB:s\fP' (e.g., `\fB:gs/\fIold\fP/\fInew\fP/\fR') -or `\fB:&\fP'. If used with -`\fB:s\fP', any delimiter can be used -in place of /, and the final delimiter is optional +Cause changes to be applied over the entire event line. +This is used in conjunction with +.Q \fB:s\fP +(e.g., +.Q \fB:gs/\fIold\fP/\fInew\fP/\fR ) +or +.Q \fB:&\fP . +If used with +.Q \fB:s\fP , +any delimiter can be used in place of /, +and the final delimiter is optional if it is the last character of the event line. An \fBa\fP may be used as a synonym for \fBg\fP. .TP .B G -Apply the following `\fBs\fP' or `\fB&\fP' modifier once to each word -in the event line. +Apply the following +.Q \fBs\fP +or +.Q \fB&\fP +modifier once to each word in the event line. .PD .SH "SHELL BUILTIN COMMANDS" .\" start of bash_builtins @@ -7683,7 +8964,7 @@ and \fBshift\fP builtins accept and process arguments beginning with Other builtins that accept arguments but are not specified as accepting options interpret arguments beginning with \fB\-\fP as invalid options and require \fB\-\-\fP to prevent this interpretation. -.sp .5 +.PP .PD 0 .TP \fB:\fP [\fIarguments\fP] @@ -7694,93 +8975,96 @@ and performing any specified redirections. The return status is zero. .TP -\fB .\| \fP \fIfilename\fP [\fIarguments\fP] +\fB\&.\&\fP [\fB\-p\fP \fIpath\fP] \fIfilename\fP [\fIarguments\fP] .PD 0 .TP -\fBsource\fP \fIfilename\fP [\fIarguments\fP] +\fBsource\fP [\fB\-p\fP \fIpath\fP] \fIfilename\fP [\fIarguments\fP] .PD -Read and execute commands from +The \fB\&.\&\fP command (\fBsource\fP) reads and execute commands from .I filename -in the current -shell environment and return the exit status of the last command -executed from +in the current shell environment and returns the exit status of the +last command executed from .IR filename . -If -.I filename -does not contain a slash, filenames in -.SM -.B PATH -are used to find the directory containing -.IR filename , -but \fIfilename\fP does not need to be executable. -The file searched for in +.IP +If \fIfilename\fP does not contain a slash, \fB\&.\&\fP searches for it. +If the \fB\-p\fP option is supplied, \fB\&.\&\fP treats \fIpath\fP +as a colon-separated list of directories in which to find \fIfilename\fP; +otherwise, \fB\&.\&\fP uses the entries in .SM .B PATH -need not be executable. -When \fBbash\fP is not in \fIposix mode\fP, it searches -the current directory if no file is found in +to find the directory containing +.IR filename . +\fIfilename\fP does not need to be executable. +When \fBbash\fP is not in posix mode, it searches +the current directory if \fIfilename\fP is not found in .SM -.BR PATH . +.BR PATH , +but does not search the current directory if \fB\-p\fP is supplied. If the .B sourcepath option to the .B shopt -builtin command is turned off, the +builtin command is turned off, \fB\&.\&\fP does not search .SM -.B PATH -is not searched. +.BR PATH . +.IP If any \fIarguments\fP are supplied, they become the positional -parameters when \fIfilename\fP is executed. Otherwise the positional -parameters are unchanged. +parameters when \fIfilename\fP is executed. +Otherwise the positional parameters are unchanged. +.IP If the \fB\-T\fP option is enabled, \fB.\fP inherits any trap on \fBDEBUG\fP; if it is not, any \fBDEBUG\fP trap string is saved and restored around the call to \fB.\fP, and \fB.\fP unsets the \fBDEBUG\fP trap while it executes. If \fB\-T\fP is not set, and the sourced file changes -the \fBDEBUG\fP trap, the new value is retained when \fB.\fP completes. -The return status is the status of the last command exited within -the script (0 if no commands are executed), and false if +the \fBDEBUG\fP trap, the new value persists after \fB.\fP completes. +The return status is the status of the last command executed from +\fIfilename\fP (0 if no commands are executed), and non-zero if .I filename is not found or cannot be read. .TP -\fBalias\fP [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...] -\fBAlias\fP with no arguments or with the +\fBalias\fP [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] .\|.\|.] +With no arguments or with the .B \-p -option prints the list of aliases in the form +option, \fBalias\fP prints the list of aliases in the form \fBalias\fP \fIname\fP=\fIvalue\fP on standard output. -When arguments are supplied, an alias is defined for +When arguments are supplied, define an alias for each \fIname\fP whose \fIvalue\fP is given. A trailing space in \fIvalue\fP causes the next word to be -checked for alias substitution when the alias is expanded. +checked for alias substitution when the alias is expanded +during command parsing. For each \fIname\fP in the argument list for which no \fIvalue\fP -is supplied, the name and value of the alias is printed. -\fBAlias\fP returns true unless a \fIname\fP is given for which -no alias has been defined. +is supplied, print the name and value of the alias \fIname\fP. +\fBalias\fP returns true unless a \fIname\fP is given +(without a corresponding =\fIvalue\fP) +for which no alias has been defined. .TP -\fBbg\fP [\fIjobspec\fP ...] +\fBbg\fP [\fIjobspec\fP .\|.\|.] Resume each suspended job \fIjobspec\fP in the background, as if it had been started with .BR & . If .I jobspec -is not present, the shell's notion of the \fIcurrent job\fP is used. +is not present, the shell uses its notion of the \fIcurrent job\fP. .B bg .I jobspec returns 0 unless run when job control is disabled or, when run with job control enabled, any specified \fIjobspec\fP was not found or was started without job control. .TP -\fBbind\fP [\fB\-m\fP \fIkeymap\fP] [\fB\-lpsvPSVX\fP] +\fBbind\fP [\fB\-m\fP \fIkeymap\fP] [\fB\-lsvSVX\fP] .PD 0 .TP \fBbind\fP [\fB\-m\fP \fIkeymap\fP] [\fB\-q\fP \fIfunction\fP] [\fB\-u\fP \fIfunction\fP] [\fB\-r\fP \fIkeyseq\fP] .TP \fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fB\-f\fP \fIfilename\fP .TP -\fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fB\-x\fP \fIkeyseq\fP:\fIshell\-command\fP +\fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fB\-x\fP \fIkeyseq\fP[:] \fIshell\-command\fP .TP \fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fIkeyseq\fP:\fIfunction\-name\fP .TP +\fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fB\-p\fP|\fB\-P\fP [\fIreadline\-command\fP] +.TP \fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fIkeyseq\fP:\fIreadline\-command\fP .TP \fBbind\fP \fIreadline-command-line\fP @@ -7789,15 +9073,22 @@ Display current .B readline key and function bindings, bind a key sequence to a .B readline -function or macro, or set a +function or macro +or to a shell command, or set a .B readline variable. -Each non-option argument is a command as it would appear in a +Each non-option argument is a key binding or command as it would appear in a .B readline initialization file such as .IR .inputrc , but each binding or command must be passed as a separate argument; -e.g., '"\eC\-x\eC\-r": re\-read\-init\-file'. +e.g., \*'\*"\eC\-x\eC\-r\*": re\-read\-init\-file\*'. +In the following descriptions, output available to be re-read is formatted +as commands that would appear in a +.B readline +initialization file or that would be supplied as individual arguments to a +.B bind +command. Options, if supplied, have the following meanings: .RS .PD 0 @@ -7812,23 +9103,31 @@ names are \fIemacs, emacs\-standard, emacs\-meta, emacs\-ctlx, vi, vi\-move, vi\-command\fP, and .IR vi\-insert . -\fIvi\fP is equivalent to \fIvi\-command\fP (\fIvi\-move\fP is also -a synonym); \fIemacs\fP is -equivalent to \fIemacs\-standard\fP. +\fIvi\fP is equivalent to \fIvi\-command\fP +(\fIvi\-move\fP is also a synonym); +\fIemacs\fP is equivalent to \fIemacs\-standard\fP. .TP .B \-l List the names of all \fBreadline\fP functions. .TP .B \-p Display \fBreadline\fP function names and bindings in such a way -that they can be re-read. +that they can be +used as an argument to a subsequent +\fBbind\fP command or in a \fBreadline\fP initialization file. +If arguments remain after option processing, \fBbind\fP treats +them as \fBreadline\fP command names and restricts output to those names. .TP .B \-P List current \fBreadline\fP function names and bindings. +If arguments remain after option processing, \fBbind\fP treats +them as \fBreadline\fP command names and restricts output to those names. .TP .B \-s Display \fBreadline\fP key sequences bound to macros and the strings -they output in such a way that they can be re-read. +they output in such a way that they can be used +as an argument to a subsequent \fBbind\fP command +or in a \fBreadline\fP initialization file. .TP .B \-S Display \fBreadline\fP key sequences bound to macros and the strings @@ -7836,7 +9135,9 @@ they output. .TP .B \-v Display \fBreadline\fP variable names and values in such a way that they -can be re-read. +can be +used as an argument to a subsequent +\fBbind\fP command or in a \fBreadline\fP initialization file. .TP .B \-V List current \fBreadline\fP variable names and values. @@ -7845,17 +9146,26 @@ List current \fBreadline\fP variable names and values. Read key bindings from \fIfilename\fP. .TP .B \-q \fIfunction\fP -Query about which keys invoke the named \fIfunction\fP. +Display key sequences that invoke the named \fBreadline\fP \fIfunction\fP. .TP .B \-u \fIfunction\fP -Unbind all keys bound to the named \fIfunction\fP. +Unbind all key sequences bound to the named \fBreadline\fP \fIfunction\fP. .TP .B \-r \fIkeyseq\fP Remove any current binding for \fIkeyseq\fP. .TP -.B \-x \fIkeyseq\fP:\fIshell\-command\fP +.B \-x \fIkeyseq\fP[: ]\fIshell\-command\fP Cause \fIshell\-command\fP to be executed whenever \fIkeyseq\fP is entered. +The separator between \fIkeyseq\fP and \fIshell\-command\fP is either +whitespace or a colon optionally followed by whitespace. +If the separator is whitespace, \fIshell\-command\fP +must be enclosed in double quotes and \fBreadline\fP expands any of its +special backslash-escapes in \fIshell\-command\fP before saving it. +If the separator is a colon, any enclosing double quotes are optional, and +\fBreadline\fP does not expand the command string before saving it. +Since the entire key binding expression must be a single argument, it +should be enclosed in single quotes. When \fIshell\-command\fP is executed, the shell sets the .SM .B READLINE_LINE @@ -7867,7 +9177,7 @@ and .B READLINE_MARK variables to the current location of the insertion point and the saved insertion point (the mark), respectively. -The shell assigns any numeric argument the user supplied to the +The shell assigns any numeric argument the user supplied to the .SM .B READLINE_ARGUMENT variable. @@ -7884,10 +9194,11 @@ those new values will be reflected in the editing state. .TP .B \-X List all key sequences bound to shell commands and the associated commands -in a format that can be reused as input. +in a format that can be reused as +an argument to a subsequent \fBbind\fP command. .PD .PP -The return value is 0 unless an unrecognized option is given or an +The return value is 0 unless an unrecognized option is supplied or an error occurred. .RE .TP @@ -7898,7 +9209,8 @@ Exit from within a .BR until , or .B select -loop. If \fIn\fP is specified, break \fIn\fP levels. +loop. +If \fIn\fP is specified, \fBbreak\fP exits \fIn\fP enclosing loops. .I n must be \(>= 1. If .I n @@ -7907,7 +9219,7 @@ are exited. The return value is 0 unless \fIn\fP is not greater than or equal to 1. .TP \fBbuiltin\fP \fIshell\-builtin\fP [\fIarguments\fP] -Execute the specified shell builtin, passing it +Execute the specified shell builtin \fIshell\-builtin\fP, passing it .IR arguments , and return its exit status. This is useful when defining a @@ -7921,171 +9233,225 @@ is not a shell builtin command. \fBcaller\fP [\fIexpr\fP] Returns the context of any active subroutine call (a shell function or a script executed with the \fB.\fP or \fBsource\fP builtins). +.IP Without \fIexpr\fP, \fBcaller\fP displays the line number and source filename of the current subroutine call. If a non-negative integer is supplied as \fIexpr\fP, \fBcaller\fP displays the line number, subroutine name, and source file corresponding -to that position in the current execution call stack. This extra -information may be used, for example, to print a stack trace. The -current frame is frame 0. +to that position in the current execution call stack. +This extra information may be used, for example, to print a stack trace. +The current frame is frame 0. +.IP The return value is 0 unless the shell is not executing a subroutine call or \fIexpr\fP does not correspond to a valid position in the call stack. .TP -\fBcd\fP [\fB\-L\fP|[\fB\-P\fP [\fB\-e\fP]] [\-@]] [\fIdir\fP] +.PD 0 +\fBcd\fP [\fB\-L\fP] [\fB\-@\fP] [\fIdir\fP] +.TP +\fBcd\fP \fB\-P\fP [\fB\-e\fP] [\fB\-@\fP] [\fIdir\fP] +.PD Change the current directory to \fIdir\fP. if \fIdir\fP is not supplied, the value of the .SM .B HOME -shell variable is the default. +shell variable is used as \fIdir\fP. The variable .SM .B CDPATH -defines the search path for the directory containing -.IR dir : -each directory name in +exists, +and \fIdir\fP does not begin with a slash (/), +\fBcd\fP uses it as a search path: +the shell searches each directory name in .SM .B CDPATH -is searched for \fIdir\fP. +for \fIdir\fP. Alternative directory names in .SM .B CDPATH -are separated by a colon (:). A null directory name in +are separated by a colon (:). +A null directory name in .SM .B CDPATH -is the same as the current directory, i.e., ``\fB.\fP''. If -.I dir -begins with a slash (/), -then -.SM -.B CDPATH -is not used. The +is the same as the current directory, i.e., +.Q .\& . +.IP +The .B \-P option causes \fBcd\fP to use the physical directory structure by resolving symbolic links while traversing \fIdir\fP and -before processing instances of \fI..\fP in \fIdir\fP (see also the +before processing instances of +.FN .\|.\& +in \fIdir\fP (see also the .B \-P option to the .B set -builtin command); the +builtin command). +.IP +The .B \-L -option forces symbolic links to be followed by resolving the link -after processing instances of \fI..\fP in \fIdir\fP. -If \fI..\fP appears in \fIdir\fP, it is processed by removing the +option forces \fBcd\fP to follow symbolic links by resolving the link +after processing instances of +.FN .\|.\& +in \fIdir\fP. +If +.FN .\|.\& +appears in \fIdir\fP, \fBcd\fP processes it by removing the immediately previous pathname component from \fIdir\fP, back to a slash -or the beginning of \fIdir\fP. +or the beginning of \fIdir\fP, +and verifying that the portion of \fIdir\fP it has processed to +that point is still a valid directory name after removing the pathname +component. +If it is not a valid directory name, \fBcd\fP returns a non-zero status. +If neither +.B \-L +nor +.B \-P +is supplied, +.B cd +behaves as if +.B \-L +had been supplied. +.IP If the .B \-e option is supplied with .BR \-P , -and the current working directory cannot be successfully determined -after a successful directory change, \fBcd\fP will return an unsuccessful -status. +and \fBcd\fP cannot successfully determine the current working directory +after a successful directory change, it returns a non-zero status. +.IP On systems that support it, the \fB\-@\fP option presents the extended attributes associated with a file as a directory. +.IP An argument of .B \- is converted to .SM .B $OLDPWD -before the directory change is attempted. -If a non-empty directory name from +before attempting the directory change. +.IP +If \fBcd\fP uses a non-empty directory name from .SM -.B CDPATH -is used, or if -\fB\-\fP is the first argument, and the directory change is -successful, the absolute pathname of the new working directory is -written to the standard output. +.BR CDPATH , +or if \fB\-\fP is the first argument, and the directory change is +successful, \fBcd\fP writes the absolute pathname of the new +working directory to the standard output. +.IP If the directory change is successful, \fBcd\fP sets the value of the \fBPWD\fP environment variable to the new directory name, and sets the \fBOLDPWD\fP environment variable to the value of the current working directory before the change. +.IP The return value is true if the directory was successfully changed; false otherwise. .TP -\fBcommand\fP [\fB\-pVv\fP] \fIcommand\fP [\fIarg\fP ...] -Run +\fBcommand\fP [\fB\-pVv\fP] \fIcommand\fP [\fIarg\fP .\|.\|.] +The \fBcommand\fP builtin runs .I command with .I args -suppressing the normal shell function lookup. +suppressing the normal shell function lookup for \fIcommand\fP. Only builtin commands or commands found in the .SM .B PATH -are executed. If the +named \fIcommand\fP are executed. +If the .B \-p -option is given, the search for +option is supplied, the search for .I command is performed using a default value for .SM .B PATH that is guaranteed to find all of the standard utilities. +.IP If either the .B \-V or .B \-v -option is supplied, a description of -.I command -is printed. The +option is supplied, \fBcommand\fP prints a description of +.IR command . +The .B \-v -option causes a single word indicating the command or filename +option displays a single word indicating the command or filename used to invoke -.I command -to be displayed; the +.IR command ; +the .B \-V option produces a more verbose description. +.IP If the .B \-V or .B \-v -option is supplied, the exit status is 0 if +option is supplied, the exit status is zero if .I command -was found, and 1 if not. If neither option is supplied and -an error occurred or +was found, and non-zero if not. +If neither option is supplied and an error occurred or .I command -cannot be found, the exit status is 127. Otherwise, the exit status of the +cannot be found, the exit status is 127. +Otherwise, the exit status of the .B command builtin is the exit status of .IR command . .TP -\fBcompgen\fP [\fIoption\fP] [\fIword\fP] +\fBcompgen\fP [\fB\-V\fP \fIvarname\fP] [\fIoption\fP] [\fIword\fP] Generate possible completion matches for \fIword\fP according to the \fIoption\fPs, which may be any option accepted by the .B complete -builtin with the exception of \fB\-p\fP and \fB\-r\fP, and write -the matches to the standard output. +builtin with the exceptions of +.BR \-p , +.BR \-r , +.BR \-D , +.BR \-E , +and +.BR \-I , +and write the matches to the standard output. +.IP +If the \fB\-V\fP option is supplied, \fBcompgen\fP stores the generated +completions into the indexed array variable \fIvarname\fP instead of writing +them to the standard output. +.IP When using the \fB\-F\fP or \fB\-C\fP options, the various shell variables set by the programmable completion facilities, while available, will not have useful values. -.sp 1 +.IP The matches will be generated in the same way as if the programmable completion code had generated them directly from a completion specification with the same flags. If \fIword\fP is specified, only those completions matching \fIword\fP -will be displayed. -.sp 1 +will be displayed or stored. +.IP The return value is true unless an invalid option is supplied, or no matches were generated. .TP -\fBcomplete\fP [\fB\-abcdefgjksuv\fP] [\fB\-o\fP \fIcomp-option\fP] [\fB\-DEI\fP] [\fB\-A\fP \fIaction\fP] [\fB\-G\fP \fIglobpat\fP] [\fB\-W\fP \fIwordlist\fP] +\fBcomplete\fP [\fB\-abcdefgjksuv\fP] [\fB\-o\fP \fIcomp-option\fP] [\fB\-DEI\fP] [\fB\-A\fP \fIaction\fP] .br -[\fB\-F\fP \fIfunction\fP] [\fB\-C\fP \fIcommand\fP] [\fB\-X\fP \fIfilterpat\fP] [\fB\-P\fP \fIprefix\fP] [\fB\-S\fP \fIsuffix\fP] \fIname\fP [\fIname ...\fP] +[\fB\-G\fP \fIglobpat\fP] [\fB\-W\fP \fIwordlist\fP] [\fB\-F\fP \fIfunction\fP] [\fB\-C\fP \fIcommand\fP] +.br +[\fB\-X\fP \fIfilterpat\fP] [\fB\-P\fP \fIprefix\fP] \ +[\fB\-S\fP \fIsuffix\fP] \fIname\fP [\fIname\fP .\|.\|.] .PD 0 .TP -\fBcomplete\fP \fB\-pr\fP [\fB\-DEI\fP] [\fIname\fP ...] +\fBcomplete\fP \fB\-pr\fP [\fB\-DEI\fP] [\fIname\fP .\|.\|.] .PD Specify how arguments to each \fIname\fP should be completed. -If the \fB\-p\fP option is supplied, or if no options are supplied, -existing completion specifications are printed in a way that allows -them to be reused as input. +.IP +If the \fB\-p\fP option is supplied, or if no options or \fIname\fPs +are supplied, print existing completion specifications +in a way that allows them to be reused as input. The \fB\-r\fP option removes a completion specification for each \fIname\fP, or, if no \fIname\fPs are supplied, all completion specifications. +.IP The \fB\-D\fP option indicates that other supplied options and actions should -apply to the ``default'' command completion; that is, completion attempted +apply to the +.Q default +command completion; that is, completion attempted on a command for which no completion has previously been defined. The \fB\-E\fP option indicates that other supplied options and actions should -apply to ``empty'' command completion; that is, completion attempted on a +apply to +.Q empty +command completion; that is, completion attempted on a blank line. The \fB\-I\fP option indicates that other supplied options and actions should apply to completion on the initial non-assignment word on the line, or after @@ -8096,18 +9462,19 @@ over \fB\-E\fP, and both take precedence over \fB\-I\fP. If any of \fB\-D\fP, \fB\-E\fP, or \fB\-I\fP are supplied, any other \fIname\fP arguments are ignored; these completions only apply to the case specified by the option. -.sp 1 -The process of applying these completion specifications when word completion -is attempted is described -.ie \n(zZ=1 in \fIbash(1)\fP. +.IP +The process of applying these completion specifications when +attempting word completion is described +.ie \n(zZ=1 in \fIbash\fP(1). .el above under \fBProgrammable Completion\fP. -.sp 1 +.IP Other options, if specified, have the following meanings. The arguments to the \fB\-G\fP, \fB\-W\fP, and \fB\-X\fP options (and, if necessary, the \fB\-P\fP and \fB\-S\fP options) should be quoted to protect them from expansion before the .B complete builtin is invoked. +.IP .RS .PD 0 .TP 8 @@ -8122,33 +9489,38 @@ Perform the rest of the default \fBbash\fP completions if the compspec generates no matches. .TP 8 .B default -Use readline's default filename completion if the compspec generates +Use \fBreadline\fP's default filename completion if the compspec generates no matches. .TP 8 .B dirnames Perform directory name completion if the compspec generates no matches. .TP 8 .B filenames -Tell readline that the compspec generates filenames, so it can perform any -filename\-specific processing (like adding a slash to directory names, +Tell \fBreadline\fP that the compspec generates filenames, so it can perform +any filename\-specific processing (such as adding a slash to directory names, quoting special characters, or suppressing trailing spaces). -Intended to be used with shell functions. +This is intended to be used with shell functions. +.TP 8 +.B fullquote +Tell \fBreadline\fP to quote all the completed words even if they are not +filenames. .TP 8 .B noquote -Tell readline not to quote the completed words if they are filenames +Tell \fBreadline\fP not to quote the completed words if they are filenames (quoting filenames is the default). .TP 8 .B nosort -Tell readline not to sort the list of possible completions alphabetically. +Tell \fBreadline\fP not to sort the list of possible completions +alphabetically. .TP 8 .B nospace -Tell readline not to append a space (the default) to words completed at -the end of the line. +Tell \fBreadline\fP not to append a space (the default) to words completed +at the end of the line. .TP 8 .B plusdirs -After any matches defined by the compspec are generated, -directory name completion is attempted and any -matches are added to the results of the other actions. +After generating any matches defined by the compspec, +attempt directory name completion and add any +matches to the results of the other actions. .RE .TP 8 \fB\-A\fP \fIaction\fP @@ -8157,7 +9529,8 @@ completions: .RS .TP 8 .B alias -Alias names. May also be specified as \fB\-a\fP. +Alias names. +May also be specified as \fB\-a\fP. .TP 8 .B arrayvar Array variable names. @@ -8166,13 +9539,16 @@ Array variable names. \fBReadline\fP key binding names. .TP 8 .B builtin -Names of shell builtin commands. May also be specified as \fB\-b\fP. +Names of shell builtin commands. +May also be specified as \fB\-b\fP. .TP 8 .B command -Command names. May also be specified as \fB\-c\fP. +Command names. +May also be specified as \fB\-c\fP. .TP 8 .B directory -Directory names. May also be specified as \fB\-d\fP. +Directory names. +May also be specified as \fB\-d\fP. .TP 8 .B disabled Names of disabled shell builtins. @@ -8181,16 +9557,19 @@ Names of disabled shell builtins. Names of enabled shell builtins. .TP 8 .B export -Names of exported shell variables. May also be specified as \fB\-e\fP. +Names of exported shell variables. +May also be specified as \fB\-e\fP. .TP 8 .B file -File names. May also be specified as \fB\-f\fP. +File and directory names, similar to \fBreadline\fP's filename completion. +May also be specified as \fB\-f\fP. .TP 8 .B function Names of shell functions. .TP 8 .B group -Group names. May also be specified as \fB\-g\fP. +Group names. +May also be specified as \fB\-g\fP. .TP 8 .B helptopic Help topics as accepted by the \fBhelp\fP builtin. @@ -8202,16 +9581,19 @@ Hostnames, as taken from the file specified by the shell variable. .TP 8 .B job -Job names, if job control is active. May also be specified as \fB\-j\fP. +Job names, if job control is active. +May also be specified as \fB\-j\fP. .TP 8 .B keyword -Shell reserved words. May also be specified as \fB\-k\fP. +Shell reserved words. +May also be specified as \fB\-k\fP. .TP 8 .B running Names of running jobs, if job control is active. .TP 8 .B service -Service names. May also be specified as \fB\-s\fP. +Service names. +May also be specified as \fB\-s\fP. .TP 8 .B setopt Valid arguments for the \fB\-o\fP option to the \fBset\fP builtin. @@ -8226,10 +9608,12 @@ Signal names. Names of stopped jobs, if job control is active. .TP 8 .B user -User names. May also be specified as \fB\-u\fP. +User names. +May also be specified as \fB\-u\fP. .TP 8 .B variable -Names of all shell variables. May also be specified as \fB\-v\fP. +Names of all shell variables. +May also be specified as \fB\-v\fP. .RE .TP 8 \fB\-C\fP \fIcommand\fP @@ -8243,32 +9627,33 @@ environment. When the function is executed, the first argument (\fB$1\fP) is the name of the command whose arguments are being completed, -the second argument (\fB$2\fP) is the word being completed, -and the third argument (\fB$3\fP) is the word preceding the word being +the second argument (\fB$2\fP) is the word being completed, and +the third argument (\fB$3\fP) is the word preceding the word being completed on the current command line. -When it finishes, the possible completions are retrieved from the value -of the +When \fIfunction\fP finishes, +programmable completion retrieves +the possible completions from the value of the .SM .B COMPREPLY array variable. .TP 8 \fB\-G\fP \fIglobpat\fP -The pathname expansion pattern \fIglobpat\fP is expanded to generate +Expand the pathname expansion pattern \fIglobpat\fP to generate the possible completions. .TP 8 \fB\-P\fP \fIprefix\fP -\fIprefix\fP is added at the beginning of each possible completion +Add \fIprefix\fP to the beginning of each possible completion after all other options have been applied. .TP 8 \fB\-S\fP \fIsuffix\fP -\fIsuffix\fP is appended to each possible completion +Append \fIsuffix\fP to each possible completion after all other options have been applied. .TP 8 \fB\-W\fP \fIwordlist\fP -The \fIwordlist\fP is split using the characters in the +Split the \fIwordlist\fP using the characters in the .SM .B IFS -special variable as delimiters, and each resultant word is expanded. +special variable as delimiters, and expand each resulting word. Shell quoting is honored within \fIwordlist\fP, in order to provide a mechanism for the words to contain shell metacharacters or characters @@ -8276,7 +9661,7 @@ in the value of .SM .BR IFS . The possible completions are the members of the resultant list which -match the word being completed. +match a prefix of the word being completed. .TP 8 \fB\-X\fP \fIfilterpat\fP \fIfilterpat\fP is a pattern as used for pathname expansion. @@ -8288,7 +9673,14 @@ case, any completion not matching \fIfilterpat\fP is removed. .PD .PP The return value is true unless an invalid option is supplied, an option -other than \fB\-p\fP or \fB\-r\fP is supplied without a \fIname\fP +other than +.BR \-p , +.BR \-r , +.BR \-D , +.BR \-E , +or +.B \-I +is supplied without a \fIname\fP argument, an attempt is made to remove a completion specification for a \fIname\fP for which no specification exists, or an error occurs adding a completion specification. @@ -8298,27 +9690,32 @@ an error occurs adding a completion specification. Modify completion options for each \fIname\fP according to the \fIoption\fPs, or for the currently-executing completion if no \fIname\fPs are supplied. -If no \fIoption\fPs are given, display the completion options for each +If no \fIoption\fPs are supplied, display the completion options for each \fIname\fP or the current completion. The possible values of \fIoption\fP are those valid for the \fBcomplete\fP builtin described above. +.IP The \fB\-D\fP option indicates that other supplied options should -apply to the ``default'' command completion; that is, completion attempted -on a command for which no completion has previously been defined. -The \fB\-E\fP option indicates that other supplied options should -apply to ``empty'' command completion; that is, completion attempted on a -blank line. -The \fB\-I\fP option indicates that other supplied options should -apply to completion on the initial non-assignment word on the line, -or after a command delimiter such as \fB;\fP or \fB|\fP, which is usually -command name completion. -.sp 1 +apply to the +.Q default +command completion; +the \fB\-E\fP option indicates that other supplied options should +apply to +.Q empty +command completion; and +the \fB\-I\fP option indicates that other supplied options should +apply to completion on the initial word on the line. +These are determined in the same way as the \fBcomplete\fP builtin. +.IP +If multiple options are supplied, the \fB\-D\fP option takes precedence +over \fB\-E\fP, and both take precedence over \fB\-I\fP. +.IP The return value is true unless an invalid option is supplied, an attempt is made to modify the options for a \fIname\fP for which no completion specification exists, or an output error occurs. .TP \fBcontinue\fP [\fIn\fP] -Resume the next iteration of the enclosing +\fBcontinue\fP resumes the next iteration of the enclosing .BR for , .BR while , .BR until , @@ -8327,21 +9724,28 @@ or loop. If .I n -is specified, resume at the \fIn\fPth enclosing loop. +is specified, \fBbash\fP resumes the \fIn\fPth enclosing loop. .I n -must be \(>= 1. If +must be \(>= 1. +If .I n -is greater than the number of enclosing loops, the last enclosing loop -(the ``top-level'' loop) is resumed. +is greater than the number of enclosing loops, the shell resumes +the last enclosing loop +(the +.Q top-level +loop). The return value is 0 unless \fIn\fP is not greater than or equal to 1. .TP -\fBdeclare\fP [\fB\-aAfFgiIlnrtux\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...] +\fBdeclare\fP [\fB\-aAfFgiIlnrtux\fP] [\fB\-p\fP] \ +[\fIname\fP[=\fIvalue\fP] .\|.\|.] .PD 0 .TP -\fBtypeset\fP [\fB\-aAfFgiIlnrtux\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...] +\fBtypeset\fP [\fB\-aAfFgiIlnrtux\fP] [\fB\-p\fP] \ +[\fIname\fP[=\fIvalue\fP] .\|.\|.] .PD Declare variables and/or give them attributes. -If no \fIname\fPs are given then display the values of variables. +If no \fIname\fPs are given then display the values of variables +or functions. The .B \-p option will display the attributes and values of each @@ -8350,36 +9754,42 @@ When .B \-p is used with \fIname\fP arguments, additional options, other than \fB\-f\fP and \fB\-F\fP, are ignored. +.IP When .B \-p -is supplied without \fIname\fP arguments, it will display the attributes -and values of all variables having the attributes specified by the -additional options. -If no other options are supplied with \fB\-p\fP, \fBdeclare\fP will display -the attributes and values of all shell variables. The \fB\-f\fP option -will restrict the display to shell functions. +is supplied without \fIname\fP arguments, +\fBdeclare\fP will display the attributes and values +of all variables having the attributes specified by the additional options. +If no other options are supplied with \fB\-p\fP, \fBdeclare\fP will +display the attributes and values of all shell variables. +The \fB\-f\fP option restricts the display to shell functions. +.IP The .B \-F option inhibits the display of function definitions; only the function name and attributes are printed. If the \fBextdebug\fP shell option is enabled using \fBshopt\fP, the source file name and line number where each \fIname\fP -is defined are displayed as well. The +is defined are displayed as well. +The .B \-F option implies .BR \-f . +.IP The .B \-g option forces variables to be created or modified at the global scope, even when \fBdeclare\fP is executed in a shell function. -It is ignored in all other cases. +It is ignored when \fBdeclare\fP is not executed in a shell function. +.IP The .B \-I option causes local variables to inherit the attributes -(except the \fInameref\fP attribute) +(except the \fInameref\fP attribute) and value of any existing variable with the same \fIname\fP at a surrounding scope. If there is no existing variable, the local variable is initially unset. +.IP The following options can be used to restrict output to variables with the specified attribute or to give variables attributes: @@ -8389,23 +9799,24 @@ to give variables attributes: .B \-a Each \fIname\fP is an indexed array variable (see .B Arrays -.ie \n(zZ=1 in \fIbash(1)\fP). +.ie \n(zZ=1 in \fIbash\fP(1)). .el above). .TP .B \-A Each \fIname\fP is an associative array variable (see .B Arrays -.ie \n(zZ=1 in \fIbash(1)\fP). +.ie \n(zZ=1 in \fIbash\fP(1)). .el above). .TP .B \-f -Use function names only. +Each \fIname\fP refers to a shell function. .TP .B \-i -The variable is treated as an integer; arithmetic evaluation (see +The variable is treated as an integer; +arithmetic evaluation (see .SM .B "ARITHMETIC EVALUATION" -.ie \n(zZ=1 in \fIbash(1)\fP) +.ie \n(zZ=1 in \fIbash\fP(1)) .el above) is performed when the variable is assigned a value. .TP @@ -8425,7 +9836,8 @@ to \fIname\fP, except those using or changing the The nameref attribute cannot be applied to array variables. .TP .B \-r -Make \fIname\fPs readonly. These names cannot then be assigned values +Make \fIname\fPs readonly. +These names cannot then be assigned values by subsequent assignment statements or unset. .TP .B \-t @@ -8440,14 +9852,18 @@ converted to upper-case. The lower-case attribute is disabled. .TP .B \-x -Mark \fIname\fPs for export to subsequent commands via the environment. +Mark each \fIname\fP for export to subsequent commands via the environment. .PD .PP -Using `+' instead of `\-' -turns off the attribute instead, -with the exceptions that \fB+a\fP and \fB+A\fP +Using +.Q + +instead of +.Q \- +turns off the specified +attribute instead, with the exceptions that \fB+a\fP and \fB+A\fP may not be used to destroy array variables and \fB+r\fP will not remove the readonly attribute. +.PP When used in a function, .B declare and @@ -8462,15 +9878,15 @@ the variable is set to \fIvalue\fP. When using \fB\-a\fP or \fB\-A\fP and the compound assignment syntax to create array variables, additional attributes do not take effect until subsequent assignments. +.PP The return value is 0 unless an invalid option is encountered, an attempt is made to define a function using -.if n ``\-f foo=bar'', -.if t \f(CW\-f foo=bar\fP, +.Q "\-f foo=bar" , an attempt is made to assign a value to a readonly variable, an attempt is made to assign a value to an array variable without using the compound assignment syntax (see .B Arrays -.ie \n(zZ=1 in \fIbash(1)\fP), +.ie \n(zZ=1 in \fIbash\fP(1)), .el above), one of the \fInames\fP is not a valid shell variable name, an attempt is made to turn off readonly status for a readonly variable, @@ -8479,7 +9895,7 @@ or an attempt is made to display a non-existent function with \fB\-f\fP. .RE .TP .B dirs [\fB\-clpv\fP] [+\fIn\fP] [\-\fIn\fP] -Without options, displays the list of currently remembered directories. +Without options, display the list of currently remembered directories. The default display is on a single line with directory names separated by spaces. Directories are added to the list with the @@ -8488,6 +9904,8 @@ command; the .B popd command removes entries from the list. The current directory is always the first directory in the stack. +.IP +Options, if supplied, have the following meanings: .RS .PD 0 .TP @@ -8523,49 +9941,61 @@ invalid option is supplied or \fIn\fP indexes beyond the end of the directory stack. .RE .TP -\fBdisown\fP [\fB\-ar\fP] [\fB\-h\fP] [\fIjobspec\fP ... | \fIpid\fP ... ] +\fBdisown\fP [\fB\-ar\fP] [\fB\-h\fP] [\fIid\fP .\|.\|.] Without options, remove each -.I jobspec +.I id from the table of active jobs. -If -.I jobspec -is not present, and neither the \fB\-a\fP nor the \fB\-r\fP option -is supplied, the \fIcurrent job\fP is used. -If the \fB\-h\fP option is given, each -.I jobspec -is not removed from the table, but is marked so that +Each \fIid\fP may be a job specification \fIjobspec\fP +or a process ID \fIpid\fP; +if \fIid\fP is a \fIpid\fP, +\fBdisown\fP uses the job containing \fIpid\fP as \fIjobspec\fP. +.IP +If the \fB\-h\fP option is supplied, +\fBdisown\fP does not remove the jobs corresponding to each +.I id +from the jobs table, +but rather marks them so the shell does not send .SM .B SIGHUP -is not sent to the job if the shell receives a +to the job if the shell receives a .SM .BR SIGHUP . +.IP If no -.I jobspec +.I id is supplied, the .B \-a option means to remove or mark all jobs; the .B \-r -option without a -.I jobspec -argument restricts operation to running jobs. -The return value is 0 unless a -.I jobspec +option without an +.I id +argument removes or marks running jobs. +If no +.I id +is supplied, and neither the \fB\-a\fP nor the \fB\-r\fP option +is supplied, \fBdisown\fP removes or marks the current job. +.IP +The return value is 0 unless an +.I id does not specify a valid job. .TP -\fBecho\fP [\fB\-neE\fP] [\fIarg\fP ...] +\fBecho\fP [\fB\-neE\fP] [\fIarg\fP .\|.\|.] Output the \fIarg\fPs, separated by spaces, followed by a newline. The return status is 0 unless a write error occurs. -If \fB\-n\fP is specified, the trailing newline is -suppressed. If the \fB\-e\fP option is given, interpretation of -the following backslash-escaped characters is enabled. The +If \fB\-n\fP is specified, the trailing newline is not printed. +.IP +If the \fB\-e\fP option is given, \fBecho\fP interprets +the following backslash-escaped characters. +The .B \-E -option disables the interpretation of these escape characters, +option disables interpretation of these escape characters, even on systems where they are interpreted by default. -The \fBxpg_echo\fP shell option may be used to -dynamically determine whether or not \fBecho\fP expands these -escape characters by default. +The \fBxpg_echo\fP shell option determines +whether or not \fBecho\fP interprets any options +and expands these escape characters. .B echo does not interpret \fB\-\-\fP to mean the end of options. +.IP .B echo interprets the following escape sequences: .RS @@ -8604,38 +10034,54 @@ vertical tab backslash .TP .B \e0\fInnn\fP -the eight-bit character whose value is the octal value \fInnn\fP -(zero to three octal digits) +The eight-bit character whose value is the octal value \fInnn\fP +(zero to three octal digits). .TP .B \ex\fIHH\fP -the eight-bit character whose value is the hexadecimal value \fIHH\fP -(one or two hex digits) +The eight-bit character whose value is the hexadecimal value \fIHH\fP +(one or two hex digits). .TP .B \eu\fIHHHH\fP -the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value -\fIHHHH\fP (one to four hex digits) +The Unicode (ISO/IEC 10646) character whose value is the hexadecimal value +\fIHHHH\fP (one to four hex digits). .TP .B \eU\fIHHHHHHHH\fP -the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value -\fIHHHHHHHH\fP (one to eight hex digits) +The Unicode (ISO/IEC 10646) character whose value is the hexadecimal value +\fIHHHHHHHH\fP (one to eight hex digits). .PD +.PP +\fBecho\fP writes any unrecognized backslash-escaped characters unchanged. .RE .TP -\fBenable\fP [\fB\-a\fP] [\fB\-dnps\fP] [\fB\-f\fP \fIfilename\fP] [\fIname\fP ...] +\fBenable\fP [\fB\-a\fP] [\fB\-dnps\fP] [\fB\-f\fP \fIfilename\fP] \ +[\fIname\fP .\|.\|.] Enable and disable builtin shell commands. -Disabling a builtin allows a disk command which has the same name +Disabling a builtin allows an executable file which has the same name as a shell builtin to be executed without specifying a full pathname, -even though the shell normally searches for builtins before disk commands. -If \fB\-n\fP is used, each \fIname\fP -is disabled; otherwise, -\fInames\fP are enabled. For example, to use the +even though the shell normally searches for builtins before files. +.IP +If \fB\-n\fP is supplied, each \fIname\fP is disabled; otherwise, +\fIname\fPs are enabled. +For example, to use the .B test -binary found via the +binary found using .SM .B PATH instead of the shell builtin version, run -.if t \f(CWenable -n test\fP. -.if n ``enable -n test''. +.QN "enable \-n test" . +.IP +If no \fIname\fP arguments are supplied, or if the +.B \-p +option is supplied, print a list of shell builtins. +With no other option arguments, the list consists of all enabled +shell builtins. +If \fB\-n\fP is supplied, print only disabled builtins. +If \fB\-a\fP is supplied, the list printed includes all builtins, with an +indication of whether or not each is enabled. +The \fB\-s\fP option means to restrict the output to the +.SM POSIX +\fIspecial\fP builtins. +.IP The .B \-f option means to load the new builtin command @@ -8643,38 +10089,35 @@ option means to load the new builtin command from shared object .IR filename , on systems that support dynamic loading. -Bash will use the value of the \fBBASH_LOADABLES_PATH\fP variable as a +If \fIfilename\fP does not contain a slash, +\fBBash\fP will use the value of the \fBBASH_LOADABLES_PATH\fP variable as a colon-separated list of directories in which to search for \fIfilename\fP. -The default is system-dependent. +The default for \fBBASH_LOADABLES_PATH\fP is system-dependent, +and may include +.Q .\& +to force a search of the current directory. The .B \-d -option will delete a builtin previously loaded with -.BR \-f . -If no \fIname\fP arguments are given, or if the -.B \-p -option is supplied, a list of shell builtins is printed. -With no other option arguments, the list consists of all enabled -shell builtins. -If \fB\-n\fP is supplied, only disabled builtins are printed. -If \fB\-a\fP is supplied, the list printed includes all builtins, with an -indication of whether or not each is enabled. -If \fB\-s\fP is supplied, the output is restricted to the POSIX -\fIspecial\fP builtins. +option will delete a builtin previously loaded with \fB\-f\fP. +If \fI\-s\fP is used with \fI\-f\fP, the new builtin becomes a +.SM POSIX +special builtin. +.IP If no options are supplied and a \fIname\fP is not a shell builtin, -\fBenable\fP will attempt to load \fIname\fP from a shared object named -\fIname\fP, as if the command were -.if t \f(CWenable \-f\fP \fIname name\fP . -.if n ``enable -f \fIname name\fP . +\fBenable\fP will attempt to load \fIname\fP from a shared +object named \fIname\fP, as if the command were +.QN "enable \-f \fIname name\fP" . +.IP The return value is 0 unless a .I name is not a shell builtin or there is an error loading a new builtin from a shared object. .TP -\fBeval\fP [\fIarg\fP ...] -The \fIarg\fPs are read and concatenated together into a single -command. This command is then read and executed by the shell, and -its exit status is returned as the value of -.BR eval . +\fBeval\fP [\fIarg\fP .\|.\|.] +Concatenate the \fIarg\fPs together into a single command, separating +them with spaces. +\fBBash\fP then reads and execute this command, and returns its exit status +as the return status of \fBeval\fP. If there are no .IR args , or only null arguments, @@ -8684,8 +10127,9 @@ returns 0. \fBexec\fP [\fB\-cl\fP] [\fB\-a\fP \fIname\fP] [\fIcommand\fP [\fIarguments\fP]] If .I command -is specified, it replaces the shell. -No new process is created. The +is specified, it replaces the shell without creating a new process. +\fIcommand\fP cannot be a shell builtin or function. +The .I arguments become the arguments to \fIcommand\fP. If the @@ -8699,20 +10143,23 @@ does. The .B \-c option causes .I command -to be executed with an empty environment. If +to be executed with an empty environment. +If .B \-a is supplied, the shell passes .I name as the zeroth argument to the executed command. +.IP If .I command cannot be executed for some reason, a non-interactive shell exits, unless the .B execfail -shell option -is enabled. In that case, it returns failure. -An interactive shell returns failure if the file cannot be executed. +shell option is enabled. +In that case, it returns a non-zero status. +An interactive shell returns a non-zero status if the file cannot be executed. A subshell exits unconditionally if \fBexec\fP fails. +.IP If .I command is not specified, any redirections take effect in the current shell, @@ -8720,41 +10167,47 @@ and the return status is 0. If there is a redirection error, the return status is 1. .TP \fBexit\fP [\fIn\fP] -Cause the shell to exit -with a status of \fIn\fP. If +Cause the shell to exit with a status of \fIn\fP. +If .I n -is omitted, the exit status -is that of the last command executed. -A trap on +is omitted, the exit status is that of the last command executed. +Any trap on .SM .B EXIT is executed before the shell terminates. .TP -\fBexport\fP [\fB\-fn\fP\^] [\fIname\fP[=\fIword\fP]] ... +\fBexport\fP [\fB\-fn\fP\^] [\fIname\fP[=\fIvalue\fP]] .\|.\|. .PD 0 .TP -.B export \-p +.B export \-p [\fB\-f\fP\^] .PD The supplied .I names are marked for automatic export to the environment of -subsequently executed commands. If the +subsequently executed commands. +If the .B \-f option is given, the .I names refer to functions. +.IP +The +.B \-n +option unexports, or removes the export attribute, from each \fIname\fP. If no .I names -are given, or if the +are given, or if only the .B \-p -option is supplied, a list -of names of all exported variables is printed. -The -.B \-n -option causes the export property to be removed from each -\fIname\fP. -If a variable name is followed by =\fIword\fP, the value of -the variable is set to \fIword\fP. +option is supplied, +\fBexport\fP displays a list of names of all exported +variables on the standard output. +Using \fB\-p\fP and \fB\-f\fP together displays exported functions. +The \fB\-p\fP option displays output in a form that may be reused as input. +.IP +\fBexport\fP allows the value of a variable to be set when it is exported +or unexported by following the variable name with =\fIvalue\fP. +This sets the value of the variable to \fIvalue\fP while modifying the +export attribute. .B export returns an exit status of 0 unless an invalid option is encountered, @@ -8764,6 +10217,9 @@ is supplied with a .I name that is not a function. .TP +\fBfalse\fP +Does nothing; returns a non-zero status. +.TP \fBfc\fP [\fB\-e\fP \fIename\fP] [\fB\-lnr\fP] [\fIfirst\fP] [\fIlast\fP] .PD 0 .TP @@ -8781,16 +10237,16 @@ may be specified as a string (to locate the last command beginning with that string) or as a number (an index into the history list, where a negative number is used as an offset from the current command number). -When listing, a \fIfirst\fP or \fIlast\fP of -0 is equivalent to \-1 and \-0 is equivalent to the current -command (usually the \fBfc\fP command); otherwise 0 is equivalent to \-1 -and \-0 is invalid. +.IP +When listing, a \fIfirst\fP or \fIlast\fP of 0 is equivalent to \-1 +and \-0 is equivalent to the current command +(usually the \fBfc\fP command); +otherwise 0 is equivalent to \-1 and \-0 is invalid. If .I last is not specified, it is set to the current command for listing (so that -.if n ``fc \-l \-10'' -.if t \f(CWfc \-l \-10\fP +.QN "fc \-l \-10" prints the last 10 commands) and to .I first otherwise. @@ -8798,71 +10254,69 @@ If .I first is not specified, it is set to the previous command for editing and \-16 for listing. -.sp 1 +.IP +If the +.B \-l +option is supplied, the commands are listed on the standard output. The .B \-n option suppresses -the command numbers when listing. The +the command numbers when listing. +The .B \-r option reverses the order of -the commands. If the -.B \-l -option is given, -the commands are listed on -standard output. Otherwise, the editor given by +the commands. +.IP +Otherwise, \fBfc\fP invokes the editor named by .I ename -is invoked -on a file containing those commands. If +on a file containing those commands. +If .I ename -is not given, the -value of the +is not supplied, \fBfc\fP uses the value of the .SM .B FCEDIT -variable is used, and +variable, and the value of .SM .B EDITOR if .SM .B FCEDIT -is not set. If neither variable is set, -.FN vi -is used. When editing is complete, the edited commands are -echoed and executed. -.sp 1 -In the second form, \fIcommand\fP is re-executed after each instance -of \fIpat\fP is replaced by \fIrep\fP. +is not set. +If neither variable is set, \fBfc\fP uses +.FN vi. +When editing is complete, \fBfc\fP reads the file containing +the edited commands and echoes and executes them. +.IP +In the second form, \fBfc\fP re-executes \fIcommand\fP +after replacing each instance of \fIpat\fP with \fIrep\fP. \fICommand\fP is interpreted the same as \fIfirst\fP above. -A useful alias to use with this is -.if n ``r="fc -s"'', -.if t \f(CWr='fc \-s'\fP, +.IP +A useful alias to use with \fBfc\fP is +.Q "r=\*"fc \-s\*"" , so that typing -.if n ``r cc'' -.if t \f(CWr cc\fP +.Q "r cc" runs the last command beginning with -.if n ``cc'' -.if t \f(CWcc\fP +.Q cc and typing -.if n ``r'' -.if t \f(CWr\fP +.Q r re-executes the last command. -.sp 1 -If the first form is used, the return value is 0 unless an invalid +.IP +If the first form is used, the return value is zero unless an invalid option is encountered or .I first or .I last specify history lines out of range. -If the -.B \-e -option is supplied, the return value is the value of the last -command executed or failure if an error occurs with the temporary -file of commands. If the second form is used, the return status -is that of the command re-executed, unless +When editing and re-executing a file of commands, +the return value is the value of the last command executed +or failure if an error occurs with the temporary file. +If the second form is used, the return status +is that of the re-executed command, unless .I cmd -does not specify a valid history line, in which case +does not specify a valid history entry, in which case .B fc -returns failure. +returns a non-zero status. .TP \fBfg\fP [\fIjobspec\fP] Resume @@ -8870,7 +10324,7 @@ Resume in the foreground, and make it the current job. If .I jobspec -is not present, the shell's notion of the \fIcurrent job\fP is used. +is not present, \fBfg\fP uses the shell's notion of the \fIcurrent job\fP. The return value is that of the command placed into the foreground, or failure if run when job control is disabled or, when run with job control enabled, if @@ -8879,15 +10333,17 @@ does not specify a valid job or .I jobspec specifies a job that was started without job control. .TP -\fBgetopts\fP \fIoptstring\fP \fIname\fP [\fIarg ...\fP] +\fBgetopts\fP \fIoptstring\fP \fIname\fP [\fIarg\fP .\|.\|.] .B getopts -is used by shell procedures to parse positional parameters. +is used by shell scripts and functions to parse positional parameters +and obtain options and their arguments. .I optstring contains the option characters to be recognized; if a character is followed by a colon, the option is expected to have an argument, which should be separated from it by white space. The colon and question mark characters may not be used as option characters. +.IP Each time it is invoked, .B getopts places the next option in the shell variable @@ -8902,27 +10358,28 @@ variable .SM .B OPTIND is initialized to 1 each time the shell or a shell script -is invoked. When an option requires an argument, +is invoked. +When an option requires an argument, .B getopts places that argument into the variable .SM .BR OPTARG . +.IP The shell does not reset .SM .B OPTIND automatically; it must be manually reset between multiple calls to .B getopts -within the same shell invocation if a new set of parameters -is to be used. -.sp 1 -When the end of options is encountered, \fBgetopts\fP exits with a +within the same shell invocation to use a new set of parameters. +.IP +When it reaches the end of options, \fBgetopts\fP exits with a return value greater than zero. .SM .B OPTIND is set to the index of the first non-option argument, and \fIname\fP is set to ?. -.sp 1 +.IP .B getopts normally parses the positional parameters, but if more arguments are supplied as @@ -8930,26 +10387,29 @@ supplied as values, .B getopts parses those instead. -.sp 1 +.IP .B getopts -can report errors in two ways. If the first character of +can report errors in two ways. +If the first character of .I optstring -is a colon, +is a colon, \fBgetopts\fP uses .I silent -error reporting is used. In normal operation, diagnostic messages -are printed when invalid options or missing option arguments are -encountered. +error reporting. +In normal operation, \fBgetopts\fP prints diagnostic messages +when it encounters invalid options or missing option arguments. If the variable .SM .B OPTERR -is set to 0, no error messages will be displayed, even if the first -character of +is set to 0, +.B getopts +does not display any error messages, +even if the first character of .I optstring is not a colon. -.sp 1 -If an invalid option is seen, +.IP +If .B getopts -places ? into +detects an invalid option, it places ? into .I name and, if not silent, prints an error message and unsets @@ -8957,80 +10417,93 @@ prints an error message and unsets .BR OPTARG . If .B getopts -is silent, -the option character found is placed in +is silent, it assigns the option character found to .SM .B OPTARG -and no diagnostic message is printed. -.sp 1 +and does not print a diagnostic message. +.IP If a required argument is not found, and .B getopts -is not silent, -a question mark (\^\fB?\fP\^) is placed in -.IR name , +is not silent, it sets the value of \fIname\fP to +a question mark (\^\fB?\fP\^), unsets .SM -.B OPTARG -is unset, and a diagnostic message is printed. +.BR OPTARG , +and prints a diagnostic message. If .B getopts -is silent, then a colon (\^\fB:\fP\^) is placed in -.I name -and +is silent, it sets the value of \fIname\fP to a colon (\^\fB:\fP\^) +and sets .SM .B OPTARG -is set to the option character found. -.sp 1 +to the option character found. +.IP .B getopts returns true if an option, specified or unspecified, is found. It returns false if the end of options is encountered or an error occurs. .TP \fBhash\fP [\fB\-lr\fP] [\fB\-p\fP \fIfilename\fP] [\fB\-dt\fP] [\fIname\fP] -Each time \fBhash\fP is invoked, +Each time \fBhash\fP is invoked, it remembers the full pathname of the command .I name -is determined by searching +as determined by searching the directories in -.B $PATH -and remembered. Any previously-remembered pathname is discarded. +.BR $PATH . +Any previously-remembered pathname associated with \fIname\fP is discarded. If the .B \-p -option is supplied, no path search is performed, and +option is supplied, \fBhash\fP uses .I filename -is used as the full filename of the command. +as the full pathname of the command. +.IP The .B \-r option causes the shell to forget all remembered locations. +Assigning to the \fBPATH\fP variable also clears all hashed filenames. The .B \-d option causes the shell to forget the remembered location of each \fIname\fP. +.IP If the .B \-t -option is supplied, the full pathname to which each \fIname\fP corresponds -is printed. If multiple \fIname\fP arguments are supplied with \fB\-t\fP, -the \fIname\fP is printed before the hashed full pathname. +option is supplied, \fBhash\fP prints the full pathname corresponding to +each \fIname\fP. +If multiple \fIname\fP arguments are supplied with \fB\-t\fP, +\fBhash\fP prints the \fIname\fP before the corresponding hashed +full pathname. The .B \-l -option causes output to be displayed in a format that may be reused as input. +option displays output in a format that may be reused as input. +.IP If no arguments are given, or if only \fB\-l\fP is supplied, -information about remembered commands is printed. -The return status is true unless a +\fBhash\fP prints information about remembered commands. +The \fB\-t\fP, \fB\-d\fP, and \fB\-p\fP options (the options that +act on the \fIname\fP arguments) are mutually exclusive. +Only one will be active. +If more than one is supplied, \fB\-t\fP has higher priority than +\fB\-p\fP, and both have higher priority than \fB\-d\fP. +.IP +The return status is zero unless a .I name is not found or an invalid option is supplied. .TP \fBhelp\fP [\fB\-dms\fP] [\fIpattern\fP] -Display helpful information about builtin commands. If +Display helpful information about builtin commands. +If .I pattern is specified, .B help gives detailed help on all commands matching -.IR pattern ; -otherwise help for all the builtins and shell control structures -is printed. +.I pattern +as described below; +otherwise it displays a list of +all the builtins and shell compound commands. +.IP +Options, if supplied, have the follow meanings: .RS -.PD 0 .TP +.PD 0 .B \-d Display a short description of each \fIpattern\fP .TP @@ -9040,10 +10513,25 @@ Display the description of each \fIpattern\fP in a manpage-like format .B \-s Display only a short usage synopsis for each \fIpattern\fP .PD -.PP +.RE +.IP +If \fIpattern\fP contains pattern matching characters +(see +.SM +.B "Pattern Matching" +above) +it's treated as a shell pattern and +\fBhelp\fP prints the description of each +help topic matching \fIpattern\fP. +.IP +If not, and \fIpattern\fP exactly matches the name of a help topic, +\fBhelp\fP prints the description +associated with that topic. +Otherwise, \fBhelp\fP performs prefix matching and +prints the descriptions of all matching help topics. +.IP The return status is 0 unless no command matches .IR pattern . -.RE .TP \fBhistory [\fIn\fP] .PD 0 @@ -9052,48 +10540,62 @@ The return status is 0 unless no command matches .TP \fBhistory \-d\fP \fIoffset\fP .TP -\fBhistory \-d\fP \fIstart\fP\-\fIend\fP +\fBhistory \-d\fP \fIstart\fP-\fIend\fP .TP \fBhistory\fP \fB\-anrw\fP [\fIfilename\fP] .TP -\fBhistory\fP \fB\-p\fP \fIarg\fP [\fIarg ...\fP] +\fBhistory\fP \fB\-p\fP \fIarg\fP [\fIarg\fP .\|.\|.] .TP -\fBhistory\fP \fB\-s\fP \fIarg\fP [\fIarg ...\fP] +\fBhistory\fP \fB\-s\fP \fIarg\fP [\fIarg\fP .\|.\|.] .PD -With no options, display the command -history list with line numbers. Lines listed -with a +With no options, display the command history list with numbers. +Entries prefixed with a .B * -have been modified. An argument of +have been modified. +An argument of .I n lists only the last .I n -lines. +entries. If the shell variable .SM .B HISTTIMEFORMAT is set and not null, -it is used as a format string for \fIstrftime\fP(3) to display -the time stamp associated with each displayed history entry. -No intervening blank is printed between the formatted time stamp -and the history line. -If \fIfilename\fP is supplied, it is used as the -name of the history file; if not, the value of +it is used as a format string for +.IR strftime (3) +to display the time stamp associated with each displayed history entry. +If +.B history +uses +.SM +.BR HISTTIMEFORMAT , +it does not print an intervening space between the formatted time stamp +and the history entry. +.IP +If \fIfilename\fP is supplied, \fBhistory\fP uses it as the +name of the history file; if not, it uses the value of +.SM +.BR HISTFILE . +If \fIfilename\fP is not supplied and .SM .B HISTFILE -is used. Options, if supplied, have the following meanings: +is unset or null, the \fB\-a, \-n, \-r,\fP and \fB\-w\fP options +have no effect. +.IP +Options, if supplied, have the following meanings: .RS .PD 0 .TP .B \-c Clear the history list by deleting all the entries. +This can be used with the other options to replace the history list. .TP \fB\-d\fP \fIoffset\fP Delete the history entry at position \fIoffset\fP. If \fIoffset\fP is negative, it is interpreted as relative to one greater than the last history position, so negative indices count back from the end of the history, and an index of \-1 refers to the current -\fBhistory -d\fP command. +\fBhistory \-d\fP command. .TP \fB\-d\fP \fIstart\fP\-\fIend\fP Delete the range of history entries between positions \fIstart\fP and @@ -9102,75 +10604,75 @@ Positive and negative values for \fIstart\fP and \fIend\fP are interpreted as described above. .TP .B \-a -Append the ``new'' history lines to the history file. +Append the +.Q new +history lines to the history file. These are history lines entered since the beginning of the current \fBbash\fP session, but not already appended to the history file. .TP .B \-n -Read the history lines not already read from the history -file into the current history list. These are lines -appended to the history file since the beginning of the +Read the history lines not already read from the history file +and add them to the current history list. +These are lines appended to the history file since the beginning of the current \fBbash\fP session. .TP .B \-r -Read the contents of the history file -and append them to the current history list. +Read the history file and append its contents to the current history list. .TP .B \-w -Write the current history list to the history file, overwriting the -history file's contents. +Write the current history list to the history file, overwriting +the history file. .TP .B \-p Perform history substitution on the following \fIargs\fP and display -the result on the standard output. -Does not store the results in the history list. +the result on the standard output, +without storing the results in the history list. Each \fIarg\fP must be quoted to disable normal history expansion. .TP .B \-s Store the .I args -in the history list as a single entry. The last command in the -history list is removed before the -.I args -are added. +in the history list as a single entry. +The last command in the +history list is removed before adding the +.IR args . .PD -.PP +.RE +.IP If the .SM .B HISTTIMEFORMAT -variable is set, the time stamp information -associated with each history entry is written to the history file, -marked with the history comment character. +variable is set, \fBhistory\fP writes the time stamp information +associated with each history entry to the history file, +marked with the history comment character as described above. When the history file is read, lines beginning with the history comment character followed immediately by a digit are interpreted as timestamps for the following history entry. +.IP The return value is 0 unless an invalid option is encountered, an error occurs while reading or writing the history file, an invalid \fIoffset\fP or range is supplied as an argument to \fB\-d\fP, or the history expansion supplied as an argument to \fB\-p\fP fails. -.RE .TP -\fBjobs\fP [\fB\-lnprs\fP] [ \fIjobspec\fP ... ] +\fBjobs\fP [\fB\-lnprs\fP] [ \fIjobspec\fP .\|.\|. ] .PD 0 .TP -\fBjobs\fP \fB\-x\fP \fIcommand\fP [ \fIargs\fP ... ] +\fBjobs\fP \fB\-x\fP \fIcommand\fP [ \fIargs\fP .\|.\|. ] .PD -The first form lists the active jobs. The options have the following -meanings: +The first form lists the active jobs. +The options have the following meanings: .RS .PD 0 .TP .B \-l -List process IDs -in addition to the normal information. +List process IDs in addition to the normal information. .TP .B \-n Display information only about jobs that have changed status since the user was last notified of their status. .TP .B \-p -List only the process ID of the job's process group -leader. +List only the process ID of the job's process group leader. .TP .B \-r Display only running jobs. @@ -9178,15 +10680,16 @@ Display only running jobs. .B \-s Display only stopped jobs. .PD -.PP +.RE +.IP If .I jobspec -is given, output is restricted to information about that job. +is supplied, \fBjobs\fP restricts output to information about that job. The return status is 0 unless an invalid option is encountered or an invalid .I jobspec is supplied. -.PP +.IP If the .B \-x option is supplied, @@ -9198,25 +10701,27 @@ found in or .I args with the corresponding process group ID, and executes -.I command +.IR command , passing it .IR args , returning its exit status. -.RE .TP -\fBkill\fP [\fB\-s\fP \fIsigspec\fP | \fB\-n\fP \fIsignum\fP | \fB\-\fP\fIsigspec\fP] [\fIpid\fP | \fIjobspec\fP] ... +\fBkill\fP [\fB\-s\fP \fIsigspec\fP | \fB\-n\fP \fIsignum\fP | \fB\-\fP\fIsigspec\fP] \ +\fIid\fP [ .\|.\|. ] .PD 0 .TP \fBkill\fP \fB\-l\fP|\fB\-L\fP [\fIsigspec\fP | \fIexit_status\fP] .PD -Send the signal named by +Send the signal specified by .I sigspec or .I signum -to the processes named by -.I pid -or -.IR jobspec . +to the processes named by each +.IR id . +Each +.I id +may be a job specification \fIjobspec\fP +or a process ID \fIpid\fP. .I sigspec is either a case-insensitive signal name such as .SM @@ -9229,46 +10734,57 @@ prefix) or a signal number; is a signal number. If .I sigspec -is not present, then +is not supplied, then +.B kill +sends .SM -.B SIGTERM -is assumed. -An argument of +.BR SIGTERM . +.IP +The .B \-l -lists the signal names. +option lists the signal names. If any arguments are supplied when .B \-l -is given, the names of the signals corresponding to the arguments are -listed, and the return status is 0. +is given, +.B kill +lists the names of the signals corresponding to the arguments, +and the return status is 0. The \fIexit_status\fP argument to .B \-l is a number specifying either a signal number or the exit status of -a process terminated by a signal. +a process terminated by a signal; +if it is supplied, \fBkill\fP prints the name of the signal that caused +the process to terminate. +\fBkill\fP assumes that process exit statuses are greater than 128; +anything less than that is a signal number. The .B \-L option is equivalent to \fB\-l\fP. +.IP .B kill returns true if at least one signal was successfully sent, or false if an error occurs or an invalid option is encountered. .TP -\fBlet\fP \fIarg\fP [\fIarg\fP ...] +\fBlet\fP \fIarg\fP [\fIarg\fP .\|.\|.] Each .I arg -is an arithmetic expression to be evaluated (see +is evaluated as an arithmetic expression (see .SM .B "ARITHMETIC EVALUATION" -.ie \n(zZ=1 in \fIbash(1)\fP). +.ie \n(zZ=1 in \fIbash\fP(1)). .el above). If the last .I arg evaluates to 0, .B let -returns 1; 0 is returned otherwise. +returns 1; otherwise +.B let +returns 0. .TP -\fBlocal\fP [\fIoption\fP] [\fIname\fP[=\fIvalue\fP] ... | \- ] -For each argument, a local variable named +\fBlocal\fP [\fIoption\fP] [\fIname\fP[=\fIvalue\fP] .\|.\|. | \- ] +For each argument, create a local variable named .I name -is created, and assigned +and assign it .IR value . The \fIoption\fP can be any of the options accepted by \fBdeclare\fP. When @@ -9276,39 +10792,46 @@ When is used within a function, it causes the variable .I name to have a visible scope restricted to that function and its children. -If \fIname\fP is \-, the set of shell options is made local to the function -in which \fBlocal\fP is invoked: shell options changed using the -\fBset\fP builtin inside the function are restored to their original values -when the function returns. -The restore is effected as if a series of \fBset\fP commands were executed -to restore the values that were in place before the function. -With no operands, +It is an error to use .B local -writes a list of local variables to the standard output. It is -an error to use +when not within a function. +.IP +If \fIname\fP is \-, it makes the set of shell options +local to the function in which \fBlocal\fP is invoked: +any shell options changed using the \fBset\fP builtin inside +the function after the call to \fBlocal\fP are restored to their +original values when the function returns. +The restore is performed as if a series of \fBset\fP commands were +executed to restore the values that were in place before the function. +.IP +With no operands, .B local -when not within a function. The return status is 0 unless +writes a list of local variables to the standard output. +.IP +The return status is 0 unless .B local is used outside a function, an invalid .I name is supplied, or \fIname\fP is a readonly variable. .TP -.B logout -Exit a login shell. +.B logout [\fIn\fP] +Exit a login shell, +returning a status of \fIn\fP to the shell's parent. .TP \fBmapfile\fP [\fB\-d\fP \fIdelim\fP] [\fB\-n\fP \fIcount\fP] [\fB\-O\fP \fIorigin\fP] [\fB\-s\fP \fIcount\fP] [\fB\-t\fP] [\fB\-u\fP \fIfd\fP] [\fB\-C\fP \fIcallback\fP] [\fB\-c\fP \fIquantum\fP] [\fIarray\fP] .PD 0 .TP \fBreadarray\fP [\fB\-d\fP \fIdelim\fP] [\fB\-n\fP \fIcount\fP] [\fB\-O\fP \fIorigin\fP] [\fB\-s\fP \fIcount\fP] [\fB\-t\fP] [\fB\-u\fP \fIfd\fP] [\fB\-C\fP \fIcallback\fP] [\fB\-c\fP \fIquantum\fP] [\fIarray\fP] .PD -Read lines from the standard input into the indexed array variable -.IR array , +Read lines from the standard input, or from file descriptor .I fd if the .B \-u -option is supplied. +option is supplied, +into the indexed array variable +.IR array . The variable .SM .B MAPFILE @@ -9318,7 +10841,7 @@ Options, if supplied, have the following meanings: .PD 0 .TP .B \-d -The first character of \fIdelim\fP is used to terminate each input line, +Use the first character of \fIdelim\fP to terminate each input line, rather than newline. If \fIdelim\fP is the empty string, \fBmapfile\fP will terminate a line when it reads a NUL character. @@ -9326,7 +10849,8 @@ when it reads a NUL character. .B \-n Copy at most .I count -lines. If \fIcount\fP is 0, all lines are copied. +lines. +If \fIcount\fP is 0, copy all lines. .TP .B \-O Begin assigning to @@ -9347,14 +10871,16 @@ Read lines from file descriptor \fIfd\fP instead of the standard input. .B \-C Evaluate .I callback -each time \fIquantum\fP lines are read. The \fB\-c\fP option specifies +each time \fIquantum\fP lines are read. +The \fB\-c\fP option specifies .IR quantum . .TP .B \-c Specify the number of lines read between each call to .IR callback . .PD -.PP +.RE +.IP If .B \-C is specified without @@ -9365,88 +10891,86 @@ array element to be assigned and the line to be assigned to that element as additional arguments. \fIcallback\fP is evaluated after the line is read but before the array element is assigned. -.PP +.IP If not supplied with an explicit origin, \fBmapfile\fP will clear \fIarray\fP before assigning to it. -.PP -\fBmapfile\fP returns successfully unless an invalid option or option +.IP +\fBmapfile\fP returns zero unless an invalid option or option argument is supplied, \fIarray\fP is invalid or unassignable, or if \fIarray\fP is not an indexed array. -.RE .TP \fBpopd\fP [\-\fBn\fP] [+\fIn\fP] [\-\fIn\fP] -Removes entries from the directory stack. +Remove entries from the directory stack. The elements are numbered from 0 starting at the first directory -listed by \fBdirs\fP. -With no arguments, \fBpopd\fP -removes the top directory from the stack, and -changes to the new top directory. +listed by \fBdirs\fP, so \fBpopd\fP is equivalent to +.Q "popd +0." +With no arguments, \fBpopd\fP removes the top directory from the stack, +and changes to the new top directory. Arguments, if supplied, have the following meanings: .RS .PD 0 .TP .B \-n -Suppresses the normal change of directory when removing directories -from the stack, so that only the stack is manipulated. +Suppress the normal change of directory when removing directories +from the stack, only manipulate the stack. .TP \fB+\fP\fIn\fP -Removes the \fIn\fPth entry counting from the left of the list +Remove the \fIn\fPth entry counting from the left of the list shown by .BR dirs , starting with zero, from the stack. For example: -.if n ``popd +0'' -.if t \f(CWpopd +0\fP +.Q "popd +0" removes the first directory, -.if n ``popd +1'' -.if t \f(CWpopd +1\fP +.Q "popd +1" the second. .TP \fB\-\fP\fIn\fP -Removes the \fIn\fPth entry counting from the right of the list +Remove the \fIn\fPth entry counting from the right of the list shown by .BR dirs , starting with zero. For example: -.if n ``popd -0'' -.if t \f(CWpopd -0\fP +.Q "popd \-0" removes the last directory, -.if n ``popd -1'' -.if t \f(CWpopd -1\fP +.Q "popd \-1" the next to last. .PD -.PP +.RE +.IP If the top element of the directory stack is modified, and -the \fI-n\fP option was not supplied, \fBpopd\fP uses the \fBcd\fP +the \fI\-n\fP option was not supplied, \fBpopd\fP uses the \fBcd\fP builtin to change to the directory at the top of the stack. If the \fBcd\fP fails, \fBpopd\fP returns a non-zero value. -.PP +.IP Otherwise, .B popd -returns false if an invalid option is encountered, the directory stack -is empty, or a non-existent directory stack entry is specified. -.PP +returns false if an invalid option is supplied, the directory stack +is empty, or \fIn\fP specifies a non-existent directory stack entry. +.IP If the .B popd command is successful, -bash runs +\fBbash\fP runs .B dirs to show the final contents of the directory stack, and the return status is 0. -.RE .TP \fBprintf\fP [\fB\-v\fP \fIvar\fP] \fIformat\fP [\fIarguments\fP] Write the formatted \fIarguments\fP to the standard output under the control of the \fIformat\fP. -The \fB\-v\fP option causes the output to be assigned to the variable -\fIvar\fP rather than being printed to the standard output. -.sp 1 +The \fB\-v\fP option assigns the output to the variable +\fIvar\fP rather than printing it to the standard output. +.IP The \fIformat\fP is a character string which contains three types of objects: plain characters, which are simply copied to standard output, character escape sequences, which are converted and copied to the standard output, and format specifications, each of which causes printing of the next successive \fIargument\fP. -In addition to the standard \fIprintf\fP(1) format specifications, -\fBprintf\fP interprets the following extensions: +In addition to the standard +.IR printf (3) +format characters +.BR cCsSndiouxXeEfFgGaA , +\fBprintf\fP interprets the following additional format specifiers: .RS .PD 0 .TP @@ -9459,6 +10983,10 @@ in the same way as \fBecho \-e\fP. .B %q causes \fBprintf\fP to output the corresponding \fIargument\fP in a format that can be reused as shell input. +\fB%q\fP and \fB%Q\fP use the \fB$\*'\*'\fP quoting style if any characters +in the argument string require it, and backslash quoting otherwise. +If the format string uses the \fIprintf\fP alternate form, these two +formats quote the argument string using single quotes. .TP .B %Q like \fB%q\fP, but applies any supplied precision to the \fIargument\fP @@ -9466,38 +10994,53 @@ before quoting it. .TP .B %(\fIdatefmt\fP)T causes \fBprintf\fP to output the date-time string resulting from using -\fIdatefmt\fP as a format string for \fIstrftime\fP(3). +\fIdatefmt\fP as a format string for +.IR strftime (3). The corresponding \fIargument\fP is an integer representing the number of seconds since the epoch. -Two special argument values may be used: \-1 represents the current -time, and \-2 represents the time the shell was invoked. -If no argument is specified, conversion behaves as if \-1 had been given. +This format specifier recognizes two special argument values: +\-1 represents the current time, +and \-2 represents the time the shell was invoked. +If no argument is specified, conversion behaves as if \-1 had been supplied. This is an exception to the usual \fBprintf\fP behavior. .PD -.PP -The %b, %q, and %T directives all use the field width and precision +.RE +.IP +The %b, %q, and %T format specifiers all use the field width and precision arguments from the format specification and write that many bytes from (or use that wide a field for) the expanded argument, which usually contains more characters than the original. -.PP +.IP +The %n format specifier accepts a corresponding argument that is treated +as a shell variable name. +.IP +The %s and %c format specifiers accept an l (long) modifier, which forces +them to convert the argument string to a wide-character string and apply +any supplied field width and precision in terms of characters, not bytes. +The %S and %C format specifiers are equivalent to %ls and %lc, respectively. +.\" .IP +.\" The %s format specifier understands the "altform" flag (#) and behaves +.\" identically to the %b format specifier if it's supplied. +.IP Arguments to non-string format specifiers are treated as C constants, except that a leading plus or minus sign is allowed, and if the leading -character is a single or double quote, the value is the ASCII value of -the following character. -.PP +character is a single or double quote, the value is the numeric value of +the following character, using the current locale. +.IP The \fIformat\fP is reused as necessary to consume all of the \fIarguments\fP. If the \fIformat\fP requires more \fIarguments\fP than are supplied, the extra format specifications behave as if a zero value or null string, as appropriate, had been supplied. -The return value is zero on success, non-zero on failure. -.RE +The return value is zero on success, +non-zero if an invalid option is supplied or a write or assignment error +occurs. .TP \fBpushd\fP [\fB\-n\fP] [+\fIn\fP] [\-\fIn\fP] .PD 0 .TP \fBpushd\fP [\fB\-n\fP] [\fIdir\fP] .PD -Adds a directory to the top of the directory stack, or rotates +Add a directory to the top of the directory stack, or rotate the stack, making the new top of the stack the current working directory. With no arguments, \fBpushd\fP exchanges the top two elements of @@ -9507,11 +11050,11 @@ Arguments, if supplied, have the following meanings: .PD 0 .TP .B \-n -Suppresses the normal change of directory when rotating or -adding directories to the stack, so that only the stack is manipulated. +Suppress the normal change of directory when rotating or +adding directories to the stack, only manipulate the stack. .TP \fB+\fP\fIn\fP -Rotates the stack so that the \fIn\fPth directory +Rotate the stack so that the \fIn\fPth directory (counting from the left of the list shown by .BR dirs , starting with zero) @@ -9526,29 +11069,29 @@ starting with zero) is at the top. .I dir Adds .I dir -to the directory stack at the top +to the directory stack at the top. .PD -.PP +.RE +.IP After the stack has been modified, if the \fB\-n\fP option was not supplied, \fBpushd\fP uses the \fBcd\fP builtin to change to the directory at the top of the stack. If the \fBcd\fP fails, \fBpushd\fP returns a non-zero value. -.PP +.IP Otherwise, if no arguments are supplied, .B pushd -returns 0 unless the directory stack is empty. +returns zero unless the directory stack is empty. When rotating the directory stack, .B pushd -returns 0 unless the directory stack is empty or -a non-existent directory stack element is specified. -.PP +returns zero unless the directory stack is empty or +\fIn\fP specifies a non-existent directory stack element. +.IP If the .B pushd command is successful, -bash runs +\fBbash\fP runs .B dirs to show the final contents of the directory stack. -.RE .TP \fBpwd\fP [\fB\-LP\fP] Print the absolute pathname of the current working directory. @@ -9566,15 +11109,18 @@ The return status is 0 unless an error occurs while reading the name of the current directory or an invalid option is supplied. .TP -\fBread\fP [\fB\-ers\fP] [\fB\-a\fP \fIaname\fP] [\fB\-d\fP \fIdelim\fP] [\fB\-i\fP \fItext\fP] [\fB\-n\fP \fInchars\fP] [\fB\-N\fP \fInchars\fP] [\fB\-p\fP \fIprompt\fP] [\fB\-t\fP \fItimeout\fP] [\fB\-u\fP \fIfd\fP] [\fIname\fP ...] -One line is read from the standard input, or from the file descriptor +\fBread\fP [\fB\-Eers\fP] [\fB\-a\fP \fIaname\fP] \ +[\fB\-d\fP \fIdelim\fP] [\fB\-i\fP \fItext\fP] \ +[\fB\-n\fP \fInchars\fP] [\fB\-N\fP \fInchars\fP] \ +[\fB\-p\fP \fIprompt\fP] [\fB\-t\fP \fItimeout\fP] \ +[\fB\-u\fP \fIfd\fP] [\fIname\fP .\|.\|.] +Read one line from the standard input, or from the file descriptor \fIfd\fP supplied as an argument to the \fB\-u\fP option, -split into words as described -.ie \n(zZ=1 in \fIbash(1)\fP +split it into words as described +.ie \n(zZ=1 in \fIbash\fP (1) .el above under \fBWord Splitting\fP, -and the first word -is assigned to the first +and assign the first word to the first .IR name , the second word to the second .IR name , @@ -9584,23 +11130,24 @@ intervening delimiters are assigned to the last .IR name . If there are fewer words read from the input stream than names, the remaining names are assigned empty values. -The characters in +The characters in the value of the .SM .B IFS +variable are used to split the line into words using the same rules the shell uses for expansion (described -.ie \n(zZ=1 in \fIbash(1)\fP +.ie \n(zZ=1 in \fIbash\fP (1) .el above under \fBWord Splitting\fP). -The backslash character (\fB\e\fP) may be used to remove any special -meaning for the next character read and for line continuation. +The backslash character (\fB\e\fP) removes any special +meaning for the next character read and is used for line continuation. +.IP Options, if supplied, have the following meanings: .RS .PD 0 .TP .B \-a \fIaname\fP -The words are assigned to sequential indices -of the array variable +The words are assigned to sequential indices of the array variable .IR aname , starting at 0. .I aname @@ -9608,50 +11155,68 @@ is unset before any new values are assigned. Other \fIname\fP arguments are ignored. .TP .B \-d \fIdelim\fP -The first character of \fIdelim\fP is used to terminate the input line, +The first character of \fIdelim\fP terminates the input line, rather than newline. If \fIdelim\fP is the empty string, \fBread\fP will terminate a line when it reads a NUL character. .TP .B \-e -If the standard input -is coming from a terminal, +If the standard input is coming from a terminal, +\fBread\fP uses +.B readline +(see +.SM +.B READLINE +.ie \n(zZ=1 in \fIbash\fP(1)) +.el above) +to obtain the line. +\fBReadline\fP uses the current +(or default, if line editing was not previously active) +editing settings, but uses \fBreadline\fP's default filename completion. +.TP +.B \-E +If the standard input is coming from a terminal, +\fBread\fP uses .B readline (see .SM .B READLINE -.ie \n(zZ=1 in \fIbash(1)\fP) +.ie \n(zZ=1 in \fIbash\fP(1)) .el above) -is used to obtain the line. -Readline uses the current (or default, if line editing was not previously -active) editing settings, but uses readline's default filename completion. +to obtain the line. +.B Readline +uses the current (or default, if line editing was not previously +active) editing settings, but uses bash's default completion, including +programmable completion. .TP .B \-i \fItext\fP If .B readline -is being used to read the line, \fItext\fP is placed into the editing -buffer before editing begins. +is being used to read the line, \fBread\fP places \fItext\fP into +the editing buffer before editing begins. .TP .B \-n \fInchars\fP \fBread\fP returns after reading \fInchars\fP characters rather than -waiting for a complete line of input, but honors a delimiter if fewer -than \fInchars\fP characters are read before the delimiter. +waiting for a complete line of input, +unless it encounters EOF or \fBread\fP times out, +but honors a delimiter if it reads fewer +than \fInchars\fP characters before the delimiter. .TP .B \-N \fInchars\fP \fBread\fP returns after reading exactly \fInchars\fP characters rather -than waiting for a complete line of input, unless EOF is encountered or -\fBread\fP times out. -Delimiter characters encountered in the input are +than waiting for a complete line of input, +unless it encounters EOF or \fBread\fP times out. +Any delimiter characters in the input are not treated specially and do not cause \fBread\fP to return until -\fInchars\fP characters are read. +it has read \fInchars\fP characters. The result is not split on the characters in \fBIFS\fP; the intent is that the variable is assigned exactly the characters read (with the exception of backslash; see the \fB\-r\fP option below). .TP .B \-p \fIprompt\fP Display \fIprompt\fP on standard error, without a -trailing newline, before attempting to read any input. The prompt -is displayed only if input is coming from a terminal. +trailing newline, before attempting to read any input, but +only if input is coming from a terminal. .TP .B \-r Backslash does not act as an escape character. @@ -9660,55 +11225,55 @@ In particular, a backslash-newline pair may not then be used as a line continuation. .TP .B \-s -Silent mode. If input is coming from a terminal, characters are -not echoed. +Silent mode. +If input is coming from a terminal, characters are not echoed. .TP .B \-t \fItimeout\fP -Cause \fBread\fP to time out and return failure if a complete line of -input (or a specified number of characters) -is not read within \fItimeout\fP seconds. +Cause \fBread\fP to time out and return failure if it does not read +a complete line of input (or a specified number of characters) +within \fItimeout\fP seconds. \fItimeout\fP may be a decimal number with a fractional portion following the decimal point. This option is only effective if \fBread\fP is reading input from a terminal, pipe, or other special file; it has no effect when reading from regular files. -If \fBread\fP times out, \fBread\fP saves any partial input read into -the specified variable \fIname\fP. +If \fBread\fP times out, it saves any partial input read into +the specified variable \fIname\fP, and the exit status is greater than 128. If \fItimeout\fP is 0, \fBread\fP returns immediately, without trying to read any data. -The exit status is 0 if input is available on the specified file descriptor, -or the read will return EOF, -non-zero otherwise. -The exit status is greater than 128 if the timeout is exceeded. +In this case, the exit status is 0 if input is available on the specified +file descriptor, or the read will return EOF, non-zero otherwise. .TP .B \-u \fIfd\fP -Read input from file descriptor \fIfd\fP. +Read input from file descriptor \fIfd\fP instead of the standard input. .PD -.PP +.RE +.IP +Other than the case where \fIdelim\fP is the empty string, \fBread\fP +ignores any NUL characters in the input. +.IP If no .I names -are supplied, the line read, +are supplied, \fBread\fP assigns the line read, without the ending delimiter but otherwise unmodified, -is assigned to the variable +to the variable .SM .BR REPLY . +.IP The exit status is zero, unless end-of-file is encountered, \fBread\fP times out (in which case the status is greater than 128), a variable assignment error (such as assigning to a readonly variable) occurs, or an invalid file descriptor is supplied as the argument to \fB\-u\fP. -.RE .TP -\fBreadonly\fP [\fB\-aAf\fP] [\fB\-p\fP] [\fIname\fP[=\fIword\fP] ...] +\fBreadonly\fP [\fB\-aAf\fP] [\fB\-p\fP] [\fIname\fP[=\fIword\fP] .\|.\|.] .PD The given \fInames\fP are marked readonly; the values of these .I names -may not be changed by subsequent assignment. +may not be changed by subsequent assignment or unset. If the .B \-f -option is supplied, the functions corresponding to the -\fInames\fP are so -marked. +option is supplied, each \fIname\fP refers to a shell function. The .B \-a option restricts the variables to indexed arrays; the @@ -9719,17 +11284,21 @@ If both options are supplied, takes precedence. If no .I name -arguments are given, or if the +arguments are supplied, or if the .B \-p -option is supplied, a list of all readonly names is printed. +option is supplied, print a list of all readonly names. The other options may be used to restrict the output to a subset of the set of readonly names. The .B \-p -option causes output to be displayed in a format that -may be reused as input. -If a variable name is followed by =\fIword\fP, the value of -the variable is set to \fIword\fP. +option displays output in a format that may be reused as input. +.IP +\fBreadonly\fP allows the value of a variable to be set at the same time +the readonly attribute is changed by following the variable name with +=\fIvalue\fP. +This sets the value of the variable is to \fIvalue\fP while modifying +the readonly attribute. +.IP The return status is 0 unless an invalid option is encountered, one of the .I names @@ -9740,22 +11309,23 @@ is supplied with a that is not a function. .TP \fBreturn\fP [\fIn\fP] -Causes a function to stop executing and return the value specified by +Stop executing a shell function or sourced file and return the value +specified by .I n to its caller. If .I n is omitted, the return status is that of the last command -executed in the function body. +executed. If \fBreturn\fP is executed by a trap handler, the last command used to determine the status is the last command executed before the trap handler. If \fBreturn\fP is executed during a \fBDEBUG\fP trap, the last command used to determine the status is the last command executed by the trap handler before \fBreturn\fP was invoked. -If +.IP +When .B return -is used outside a function, -but during execution of a script by the +is used to terminate execution of a script being executed by the .B . (\fBsource\fP) command, it causes the shell to stop executing that script and return either @@ -9764,31 +11334,38 @@ or the exit status of the last command executed within the script as the exit status of the script. If \fIn\fP is supplied, the return value is its least significant 8 bits. +.IP +Any command associated with the \fBRETURN\fP trap is executed +before execution resumes after the function or script. +.IP The return status is non-zero if .B return -is supplied a non-numeric argument, or -is used outside a +is supplied a non-numeric argument, or is used outside a function and not during execution of a script by \fB.\fP\^ or \fBsource\fP. -Any command associated with the \fBRETURN\fP trap is executed -before execution resumes after the function or script. .TP -\fBset\fP [\fB\-abefhkmnptuvxBCEHPT\fP] [\fB\-o\fP \fIoption\-name\fP] [\fB\-\-\fP] [\fB\-\fP] [\fIarg\fP ...] +\fBset\fP [\fB\-abefhkmnptuvxBCEHPT\fP] [\fB\-o\fP \fIoption\-name\fP] \ +[\fB\-\-\fP] [\fB\-\fP] [\fIarg\fP .\|.\|.] .PD 0 .TP -\fBset\fP [\fB+abefhkmnptuvxBCEHPT\fP] [\fB+o\fP \fIoption\-name\fP] [\fB\-\-\fP] [\fB\-\fP] [\fIarg\fP ...] +\fBset\fP [\fB+abefhkmnptuvxBCEHPT\fP] [\fB+o\fP \fIoption\-name\fP] \ +[\fB\-\-\fP] [\fB\-\fP] [\fIarg\fP .\|.\|.] +.TP +\fBset \-o\fP +.TP +\fBset +o\fP .PD Without options, display the name and value of each shell variable in a format that can be reused as input for setting or resetting the currently-set variables. Read-only variables cannot be reset. -In \fIposix mode\fP, only shell variables are listed. +In posix mode, only shell variables are listed. The output is sorted according to the current locale. When options are specified, they set or unset shell attributes. Any arguments remaining after option processing are treated as values for the positional parameters and are assigned, in order, to .BR $1 , .BR $2 , -.B ... +\&.\|.\|., .BR $\fIn\fP . Options, if specified, have the following meanings: .RS @@ -9801,18 +11378,20 @@ subsequent commands. .TP 8 .B \-b Report the status of terminated background jobs -immediately, rather than before the next primary prompt. This is -effective only when job control is enabled. +immediately, rather than before the next primary prompt or after a +foreground command terminates. +This is effective only when job control is enabled. .TP 8 .B \-e +.PD Exit immediately if a \fIpipeline\fP (which may consist of a single \fIsimple command\fP), a \fIlist\fP, or a \fIcompound command\fP (see .SM -.B SHELL GRAMMAR -.ie \n(zZ=1 in \fIbash(1)\fP), +.B "SHELL GRAMMAR" +.ie \n(zZ=1 in \fIbash\fP(1)), .el above), exits with a non-zero status. The shell does not exit if the @@ -9820,7 +11399,7 @@ command that fails is part of the command list immediately following a .B while or .B until -keyword, +reserved word, part of the test following the .B if or @@ -9830,7 +11409,8 @@ reserved words, part of any command executed in a or .B || list except the command following the final \fB&&\fP or \fB||\fP, -any command in a pipeline but the last, +any command in a pipeline but the last +(subject to the state of the \fBpipefail\fP shell option), or if the command's return value is being inverted with .BR ! . @@ -9842,12 +11422,11 @@ This option applies to the shell environment and each subshell environment separately (see .SM .B "COMMAND EXECUTION ENVIRONMENT" -.ie \n(zZ=1 in \fIbash(1)\fP), +.ie \n(zZ=1 in \fIbash\fP(1)), .el above), and may cause subshells to exit before executing all the commands in the subshell. -.if t .sp 0.5 -.if n .sp 1 +.IP If a compound command or shell function executes in a context where \fB\-e\fP is being ignored, none of the commands executed within the compound command or function body @@ -9857,6 +11436,7 @@ If a compound command or shell function sets \fB\-e\fP while executing in a context where \fB\-e\fP is ignored, that setting will not have any effect until the compound command or the command containing the function call completes. +.PD 0 .TP 8 .B \-f Disable pathname expansion. @@ -9871,12 +11451,13 @@ are placed in the environment for a command, not just those that precede the command name. .TP 8 .B \-m -Monitor mode. Job control is enabled. This option is on -by default for interactive shells on systems that support -it (see +Monitor mode. +Job control is enabled. +This option is on by default for interactive shells on systems +that support it (see .SM -.B JOB CONTROL -.ie \n(zZ=1 in \fIbash(1)\fP). +.B "JOB CONTROL" +.ie \n(zZ=1 in \fIbash\fP(1)). .el above). All processes run in a separate process group. When a background job completes, the shell prints a line @@ -9929,7 +11510,7 @@ Same as .TP 8 .B history Enable command history, as described -.ie \n(zZ=1 in \fIbash(1)\fP +.ie \n(zZ=1 in \fIbash\fP(1) .el above under .SM @@ -9938,12 +11519,11 @@ This option is on by default in interactive shells. .TP 8 .B ignoreeof The effect is as if the shell command -.if t \f(CWIGNOREEOF=10\fP -.if n ``IGNOREEOF=10'' +.QN "IGNOREEOF=10" had been executed (see -.B Shell Variables -.ie \n(zZ=1 in \fIbash(1)\fP). +.B "Shell Variables" +.ie \n(zZ=1 in \fIbash\fP(1)). .el above). .TP 8 .B keyword @@ -9992,14 +11572,17 @@ commands in the pipeline exit successfully. This option is disabled by default. .TP 8 .B posix -Change the behavior of +Enable posix mode; +change the behavior of .B bash where the default operation differs -from the POSIX standard to match the standard (\fIposix mode\fP). +from the +.SM POSIX +standard to match the standard. See .SM .B "SEE ALSO" -.ie \n(zZ=1 in \fIbash(1)\fP +.ie \n(zZ=1 in \fIbash\fP(1) .el below for a reference to a document that details how posix mode affects bash's behavior. @@ -10019,30 +11602,30 @@ This also affects the editing interface used for \fBread \-e\fP. .B xtrace Same as .BR \-x . -.sp .5 .PP If .B \-o -is supplied with no \fIoption\-name\fP, the values of the current options are -printed. +is supplied with no \fIoption\-name\fP, +\fBset\fP prints the current shell option settings. If .B +o -is supplied with no \fIoption\-name\fP, a series of +is supplied with no \fIoption\-name\fP, +\fBset\fP prints a series of .B set -commands to recreate the current option settings is displayed on -the standard output. +commands to recreate the current option settings +on the standard output. .RE .TP 8 .B \-p Turn on .I privileged -mode. In this mode, the +mode. In this mode, the shell does not read the .SM .B $ENV and .SM .B $BASH_ENV -files are not processed, shell functions are not inherited from the +files, shell functions are not inherited from the environment, and the .SM .BR SHELLOPTS , @@ -10071,11 +11654,17 @@ Exit after reading and executing one command. .TP 8 .B \-u Treat unset variables and parameters other than the special -parameters "@" and "*", -or array variables subscripted with "@" or "*", -as an error when performing -parameter expansion. If expansion is attempted on an -unset variable or parameter, the shell prints an error message, and, +parameters +.Q @ +and +.Q * , +or array variables subscripted with +.Q @ +or +.Q * , +as an error when performing parameter expansion. +If expansion is attempted on an unset variable or parameter, +the shell prints an error message, and, if not interactive, exits with a non-zero status. .TP 8 .B \-v @@ -10088,12 +11677,12 @@ arithmetic \fBfor\fP command, display the expanded value of .SM .BR PS4 , followed by the command and its expanded arguments -or associated word list. +or associated word list, to the standard error. .TP 8 .B \-B The shell performs brace expansion (see -.B Brace Expansion -.ie \n(zZ=1 in \fIbash(1)\fP). +.B "Brace Expansion" +.ie \n(zZ=1 in \fIbash\fP(1)). .el above). This is on by default. .TP 8 @@ -10105,11 +11694,12 @@ does not overwrite an existing file with the .BR >& , and .B <> -redirection operators. This may be overridden when -creating output files by using the redirection operator +redirection operators. +Using the redirection operator .B >| instead of -.BR > . +.B > +will override this and force the creation of an output file. .TP 8 .B \-E If set, any trap on \fBERR\fP is inherited by shell functions, command @@ -10119,15 +11709,16 @@ The \fBERR\fP trap is normally not inherited in such cases. .B \-H Enable .B ! -style history substitution. This option is on by -default when the shell is interactive. +style history substitution. +This option is on by default when the shell is interactive. .TP 8 .B \-P If set, the shell does not resolve symbolic links when executing commands such as .B cd -that change the current working directory. It uses the -physical directory structure instead. By default, +that change the current working directory. +It uses the physical directory structure instead. +By default, .B bash follows the logical chain of directories when performing commands which change the current directory. @@ -10140,20 +11731,20 @@ The \fBDEBUG\fP and \fBRETURN\fP traps are normally not inherited in such cases. .TP 8 .B \-\- -If no arguments follow this option, then the positional parameters are -unset. Otherwise, the positional parameters are set to the +If no arguments follow this option, unset the positional parameters. +Otherwise, set the positional parameters to the \fIarg\fPs, even if some of them begin with a .BR \- . .TP 8 .B \- -Signal the end of options, cause all remaining \fIarg\fPs to be -assigned to the positional parameters. The +Signal the end of options, and assign all remaining \fIarg\fPs to +the positional parameters. +The .B \-x and .B \-v options are turned off. -If there are no \fIarg\fPs, -the positional parameters remain unchanged. +If there are no \fIarg\fPs, the positional parameters remain unchanged. .PD .PP The options are off by default unless otherwise noted. @@ -10162,13 +11753,13 @@ The options can also be specified as arguments to an invocation of the shell. The current set of options may be found in .BR $\- . -The return status is always true unless an invalid option is encountered. +The return status is always zero unless an invalid option is encountered. .RE .TP \fBshift\fP [\fIn\fP] -The positional parameters from \fIn\fP+1 ... are renamed to +Rename positional parameters from \fIn\fP+1 .\|.\|.\& to .B $1 -.B .... +.B .\|.\|.. Parameters represented by the numbers \fB$#\fP down to \fB$#\fP\-\fIn\fP+1 are unset. .I n @@ -10188,20 +11779,22 @@ is greater than .B $# or less than zero; otherwise 0. .TP -\fBshopt\fP [\fB\-pqsu\fP] [\fB\-o\fP] [\fIoptname\fP ...] +\fBshopt\fP [\fB\-pqsu\fP] [\fB\-o\fP] [\fIoptname\fP .\|.\|.] Toggle the values of settings controlling optional shell behavior. The settings can be either those listed below, or, if the .B \-o option is used, those available with the .B \-o option to the \fBset\fP builtin command. +.IP With no options, or with the .B \-p -option, a list of all settable options is displayed, with +option, display a list of all settable options, with an indication of whether or not each is set; -if \fIoptnames\fP are supplied, the output is restricted to those options. -The \fB\-p\fP option causes output to be displayed in a form that +if any \fIoptnames\fP are supplied, the output is restricted to those options. +The \fB\-p\fP option displays output in a form that may be reused as input. +.IP Other options have the following meanings: .RS .PD 0 @@ -10215,7 +11808,7 @@ Disable (unset) each \fIoptname\fP. .B \-q Suppresses normal output (quiet mode); the return status indicates whether the \fIoptname\fP is set or unset. -If multiple \fIoptname\fP arguments are given with +If multiple \fIoptname\fP arguments are supplied with .BR \-q , the return status is zero if all \fIoptnames\fP are enabled; non-zero otherwise. @@ -10244,21 +11837,28 @@ the return status is zero unless an \fIoptname\fP is not a valid shell option. .PP The list of \fBshopt\fP options is: -.if t .sp .5v -.if n .sp 1v +.PP .PD 0 .TP 8 -.B assoc_expand_once -If set, the shell suppresses multiple evaluation of associative array -subscripts during arithmetic expression evaluation, while executing +.B array_expand_once +If set, the shell suppresses multiple evaluation of +associative and indexed array subscripts +during arithmetic expression evaluation, while executing builtins that can perform variable assignments, and while executing builtins that perform array dereferencing. .TP 8 +.B assoc_expand_once +Deprecated; a synonym for \fBarray_expand_once\fP. +.TP 8 .B autocd If set, a command name that is the name of a directory is executed as if it were the argument to the \fBcd\fP command. This option is only used by interactive shells. .TP 8 +.B bash_source_fullpath +If set, filenames added to the \fBBASH_SOURCE\fP array variable are +converted to full pathnames (see \fBShell Variables\fP above). +.TP 8 .B cdable_vars If set, an argument to the .B cd @@ -10267,50 +11867,54 @@ is not a directory is assumed to be the name of a variable whose value is the directory to change to. .TP 8 .B cdspell -If set, minor errors in the spelling of a directory component in a +If set, the .B cd -command will be corrected. -The errors checked for are transposed characters, -a missing character, and one character too many. -If a correction is found, the corrected filename is printed, +command attempts to correct +minor errors in the spelling of a directory component. +Minor errors include transposed characters, +a missing character, and one extra character. +If \fBcd\fP corrects the directory name, it prints the corrected filename, and the command proceeds. This option is only used by interactive shells. .TP 8 .B checkhash If set, \fBbash\fP checks that a command found in the hash -table exists before trying to execute it. If a hashed command no -longer exists, a normal path search is performed. +table exists before trying to execute it. +If a hashed command no longer exists, \fBbash\fP performs a normal path search. .TP 8 .B checkjobs If set, \fBbash\fP lists the status of any stopped and running jobs before -exiting an interactive shell. If any jobs are running, this causes -the exit to be deferred until a second exit is attempted without an -intervening command (see +exiting an interactive shell. +If any jobs are running, \fBbash\fP defers the exit until a second +exit is attempted without an intervening command (see .SM .B "JOB CONTROL" -.ie \n(zZ=1 in \fIbash(1)\fP). +.ie \n(zZ=1 in \fIbash\fP(1)). .el above). The shell always postpones exiting if any jobs are stopped. .TP 8 .B checkwinsize If set, \fBbash\fP checks the window size after each external (non-builtin) -command and, if necessary, updates the values of +command +and, if necessary, updates the values of .SM .B LINES and .SM -.BR COLUMNS . +.BR COLUMNS , +using the file descriptor associated with the standard error +if it is a terminal. This option is enabled by default. .TP 8 .B cmdhist If set, .B bash attempts to save all lines of a multiple-line -command in the same history entry. This allows -easy re-editing of multi-line commands. +command in the same history entry. +This allows easy re-editing of multi-line commands. This option is enabled by default, but only has an effect if command history is enabled, as described -.ie \n(zZ=1 in \fIbash(1)\fP +.ie \n(zZ=1 in \fIbash\fP(1) .el above under .SM @@ -10330,15 +11934,14 @@ under .B compat43 .TP 8 .B compat44 -.TP 8 -.B compat50 .PD These control aspects of the shell's compatibility mode (see .SM .B "SHELL COMPATIBILITY MODE" -.ie \n(zZ=1 in \fIbash(1)\fP). +.ie \n(zZ=1 in \fIbash\fP(1)). .el below). +.PD 0 .TP 8 .B complete_fullquote If set, @@ -10363,8 +11966,8 @@ versions through 4.2. If set, .B bash replaces directory names with the results of word expansion when performing -filename completion. This changes the contents of the readline editing -buffer. +filename completion. +This changes the contents of the \fBreadline\fP editing buffer. If not set, .B bash attempts to preserve what the user typed. @@ -10378,12 +11981,13 @@ if the directory name initially supplied does not exist. .B dotglob If set, .B bash -includes filenames beginning with a `.' in the results of pathname -expansion. +includes filenames beginning with a +.Q .\& +in the results of pathname expansion. The filenames -.B ``.'' +.FN .\& and -.B ``..'' +.FN ..\& must always be matched explicitly, even if .B dotglob is set. @@ -10392,13 +11996,14 @@ is set. If set, a non-interactive shell will not exit if it cannot execute the file specified as an argument to the .B exec -builtin command. An interactive shell does not exit if +builtin. +An interactive shell does not exit if .B exec fails. .TP 8 .B expand_aliases If set, aliases are expanded as described -.ie \n(zZ=1 in \fIbash(1)\fP +.ie \n(zZ=1 in \fIbash\fP(1) .el above under .SM @@ -10406,8 +12011,7 @@ under This option is enabled by default for interactive shells. .TP 8 .B extdebug -If set at shell invocation, -or in a shell startup file, +If set at shell invocation, or in a shell startup file, arrange to execute the debugger profile before the shell starts, identical to the \fB\-\-debugger\fP option. If set after invocation, behavior intended for use by debuggers is enabled: @@ -10435,7 +12039,7 @@ and .SM .B BASH_ARGV are updated as described in their descriptions -.ie \n(zZ=1 in \fIbash(1)\fP). +.ie \n(zZ=1 in \fIbash\fP(1)). .el above). .TP .B 5. @@ -10450,16 +12054,17 @@ subshells invoked with \fB(\fP \fIcommand\fP \fB)\fP inherit the .RE .TP 8 .B extglob -If set, the extended pattern matching features described -.ie \n(zZ=1 in \fIbash(1)\fP +If set, enable the extended pattern matching features described +.ie \n(zZ=1 in \fIbash\fP(1) .el above under -\fBPathname Expansion\fP are enabled. +\fBPathname Expansion\fP. .TP 8 .B extquote -If set, \fB$\fP\(aq\fIstring\fP\(aq and \fB$\fP"\fIstring\fP" quoting is +If set, \fB$\fP\*'\fIstring\fP\*' and \fB$\fP\*"\fIstring\fP\*" quoting is performed within \fB${\fP\fIparameter\fP\fB}\fP expansions -enclosed in double quotes. This option is enabled by default. +enclosed in double quotes. +This option is enabled by default. .TP 8 .B failglob If set, patterns which fail to match filenames during pathname expansion @@ -10473,9 +12078,8 @@ shell variable cause words to be ignored when performing word completion even if the ignored words are the only possible completions. See -.SM -\fBSHELL VARIABLES\fP -.ie \n(zZ=1 in \fIbash(1)\fP +.B "Shell Variables" +.ie \n(zZ=1 in \fIbash\fP(1) .el above for a description of .SM @@ -10485,12 +12089,12 @@ This option is enabled by default. .B globasciiranges If set, range expressions used in pattern matching bracket expressions (see .SM -.B Pattern Matching -.ie \n(zZ=1 in \fIbash(1)\fP) +.B "Pattern Matching" +.ie \n(zZ=1 in \fIbash\fP(1)) .el above) -behave as if in the traditional C locale when performing -comparisons. That is, the current locale's collating sequence -is not taken into account, so +behave as if in the traditional C locale when performing comparisons. +That is, pattern matching does not take +the current locale's collating sequence into account, so .B b will not collate between .B A @@ -10500,11 +12104,11 @@ and upper-case and lower-case ASCII characters will collate together. .TP 8 .B globskipdots If set, pathname expansion will never match the filenames -.B ``.'' +.FN .\& and -.BR ``..'' , +.FN ..\& , even if the pattern begins with a -.BR ``.'' . +.Q .\& . This option is enabled by default. .TP 8 .B globstar @@ -10527,15 +12131,16 @@ variable when the shell exits, rather than overwriting the file. .B histreedit If set, and .B readline -is being used, a user is given the opportunity to re-edit a +is being used, the user is given the opportunity to re-edit a failed history substitution. .TP 8 .B histverify If set, and .B readline is being used, the results of history substitution are not immediately -passed to the shell parser. Instead, the resulting line is loaded into -the \fBreadline\fP editing buffer, allowing further modification. +passed to the shell parser. +Instead, the resulting line is loaded into the \fBreadline\fP editing buffer, +allowing further modification. .TP 8 .B hostcomplete If set, and @@ -10546,7 +12151,7 @@ word containing a \fB@\fP is being completed (see under .SM .B READLINE -.ie \n(zZ=1 in \fIbash(1)\fP). +.ie \n(zZ=1 in \fIbash\fP(1)). .el above). This is enabled by default. .TP 8 @@ -10559,16 +12164,16 @@ to all jobs when an interactive login shell exits. .B inherit_errexit If set, command substitution inherits the value of the \fBerrexit\fP option, instead of unsetting it in the subshell environment. -This option is enabled when \fIposix mode\fP is enabled. +This option is enabled when posix mode is enabled. .TP 8 .B interactive_comments -If set, allow a word beginning with -.B # -to cause that word and all remaining characters on that -line to be ignored in an interactive shell (see +In an interactive shell, a word beginning with \fB#\fP +causes that word and all remaining characters on that +line to be ignored, as in a non-interactive shell +(see .SM .B COMMENTS -.ie \n(zZ=1 in \fIbash(1)\fP). +.ie \n(zZ=1 in \fIbash\fP(1)). .el above). This option is enabled by default. .TP 8 @@ -10585,45 +12190,47 @@ embedded newlines rather than using semicolon separators where possible. .B localvar_inherit If set, local variables inherit the value and attributes of a variable of the same name that exists at a previous scope before any new value is -assigned. The nameref attribute is not inherited. +assigned. +The nameref attribute is not inherited. .TP 8 .B localvar_unset If set, calling \fBunset\fP on local variables in previous function scopes marks them so subsequent lookups find them unset until that function -returns. This is identical to the behavior of unsetting local variables -at the current function scope. +returns. +This is identical to the behavior of unsetting local variables at the +current function scope. .TP 8 .B login_shell The shell sets this option if it is started as a login shell (see .SM .B "INVOCATION" -.ie \n(zZ=1 in \fIbash(1)\fP). +.ie \n(zZ=1 in \fIbash\fP(1)). .el above). The value may not be changed. .TP 8 .B mailwarn If set, and a file that \fBbash\fP is checking for mail has been -accessed since the last time it was checked, the message ``The mail in -\fImailfile\fP has been read'' is displayed. +accessed since the last time it was checked, +\fBbash\fP displays the message +.Q "The mail in \fImailfile\fP has been read" . .TP 8 .B no_empty_cmd_completion If set, and .B readline is being used, .B bash -will not attempt to search the +does not search .SM .B PATH -for possible completions when -completion is attempted on an empty line. +for possible completions when completion is attempted on an empty line. .TP 8 .B nocaseglob If set, .B bash matches filenames in a case\-insensitive fashion when performing pathname expansion (see -.B Pathname Expansion -.ie \n(zZ=1 in \fIbash(1)\fP). +.B "Pathname Expansion" +.ie \n(zZ=1 in \fIbash\fP(1)). .el above). .TP 8 .B nocasematch @@ -10637,41 +12244,40 @@ or when filtering possible completions as part of programmable completion. .B noexpand_translation If set, .B bash -encloses the translated results of $"..." quoting in single quotes -instead of double quotes. +encloses the translated results of +.BR $\*" .\|.\|.\& \*" +quoting in single quotes instead of double quotes. If the string is not translated, this has no effect. .TP 8 .B nullglob -If set, -.B bash -allows patterns which match no -files (see -.B Pathname Expansion -.ie \n(zZ=1 in \fIbash(1)\fP) +If set, pathname expansion patterns which match no files +(see +.B "Pathname Expansion" +.ie \n(zZ=1 in \fIbash\fP(1)) .el above) -to expand to a null string, rather than themselves. +expand to nothing and are removed, rather than expanding to themselves. .TP 8 .B patsub_replacement If set, \fBbash\fP expands occurrences of \fB&\fP in the replacement string of pattern substitution to the text matched by the pattern, as described under \fBParameter Expansion\fP -.ie \n(zZ=1 in \fIbash(1)\fP. +.ie \n(zZ=1 in \fIbash\fP(1). .el above. This option is enabled by default. .TP 8 .B progcomp -If set, the programmable completion facilities (see +If set, enable the programmable completion facilities (see \fBProgrammable Completion\fP -.ie \n(zZ=1 in \fIbash(1)\fP) -.el above) -are enabled. +.ie \n(zZ=1 in \fIbash\fP(1)). +.el above). This option is enabled by default. .TP 8 .B progcomp_alias If set, and programmable completion is enabled, \fBbash\fP treats a command name that doesn't have any completions as a possible alias and attempts -alias expansion. If it has an alias, \fBbash\fP attempts programmable +alias expansion. +If it has an alias, \fBbash\fP attempts programmable completion using the command word resulting from the expanded alias. .TP 8 .B promptvars @@ -10680,7 +12286,7 @@ parameter expansion, command substitution, arithmetic expansion, and quote removal after being expanded as described in .SM .B PROMPTING -.ie \n(zZ=1 in \fIbash(1)\fP. +.ie \n(zZ=1 in \fIbash\fP(1). .el above. This option is enabled by default. .TP 8 @@ -10689,7 +12295,7 @@ The shell sets this option if it is started in restricted mode (see .SM .B "RESTRICTED SHELL" -.ie \n(zZ=1 in \fIbash(1)\fP). +.ie \n(zZ=1 in \fIbash\fP(1)). .el below). The value may not be changed. This is not reset when the startup files are executed, allowing @@ -10706,7 +12312,8 @@ If set, the \fB.\fP (\fBsource\fP) builtin uses the value of .SM .B PATH -to find the directory containing the file supplied as an argument. +to find the directory containing the file supplied as an argument when +the \fB\-p\fP option is not supplied. This option is enabled by default. .TP 8 .B varredir_close @@ -10714,13 +12321,15 @@ If set, the shell automatically closes file descriptors assigned using the \fI{varname}\fP redirection syntax (see .SM .B REDIRECTION -.ie \n(zZ=1 in \fIbash(1)\fP) +.ie \n(zZ=1 in \fIbash\fP(1)) .el above) instead of leaving them open when the command completes. .TP 8 .B xpg_echo If set, the \fBecho\fP builtin expands backslash-escape sequences by default. +If the \fBposix\fP shell option is also enabled, \fBecho\fP does not +interpret any options. .RE .PD .TP @@ -10728,11 +12337,11 @@ by default. Suspend the execution of this shell until it receives a .SM .B SIGCONT -signal. A login shell, -or a shell without job control enabled, +signal. +A login shell, or a shell without job control enabled, cannot be suspended; the .B \-f -option can be used to override this and force the suspension. +option will override this and force the suspension. The return status is 0 unless the shell is a login shell or job control is not enabled and @@ -10743,24 +12352,24 @@ is not supplied. .PD 0 .TP \fB[\fP \fIexpr\fP \fB]\fP +.PD Return a status of 0 (true) or 1 (false) depending on the evaluation of the conditional expression .IR expr . Each operator and operand must be a separate argument. -Expressions are composed of the primaries described -.ie \n(zZ=1 in \fIbash(1)\fP +Expressions are composed of the primaries described +.ie \n(zZ=1 in \fIbash\fP(1) .el above under .SM .BR "CONDITIONAL EXPRESSIONS" . \fBtest\fP does not accept any options, nor does it accept and ignore an argument of \fB\-\-\fP as signifying the end of options. -.if t .sp 0.5 -.if n .sp 1 +.IP Expressions may be combined using the following operators, listed in decreasing order of precedence. The evaluation depends on the number of arguments; see below. -Operator precedence is used when there are five or more arguments. +\fBtest\fP uses operator precedence when there are five or more arguments. .RS .PD 0 .TP @@ -10771,7 +12380,7 @@ is false. .TP .B ( \fIexpr\fP ) Returns the value of \fIexpr\fP. -This may be used to override the normal precedence of operators. +This may be used to override normal operator precedence. .TP \fIexpr1\fP \-\fBa\fP \fIexpr2\fP True if both @@ -10790,8 +12399,7 @@ is true. .PP \fBtest\fP and \fB[\fP evaluate conditional expressions using a set of rules based on the number of arguments. -.if t .sp 0.5 -.if n .sp 1 +.PP .PD 0 .TP 0 arguments @@ -10804,7 +12412,7 @@ The expression is true if and only if the argument is not null. If the first argument is \fB!\fP, the expression is true if and only if the second argument is null. If the first argument is one of the unary conditional operators listed -.ie \n(zZ=1 in \fIbash(1)\fP +.ie \n(zZ=1 in \fIbash\fP(1) .el above under .SM @@ -10816,7 +12424,7 @@ is false. 3 arguments The following conditions are applied in the order listed. If the second argument is one of the binary conditional operators listed -.ie \n(zZ=1 in \fIbash(1)\fP +.ie \n(zZ=1 in \fIbash\fP(1) .el above under .SM @@ -10836,7 +12444,6 @@ Otherwise, the expression is false. The following conditions are applied in the order listed. If the first argument is \fB!\fP, the result is the negation of the three-argument expression composed of the remaining arguments. -the two-argument test using the second and third arguments. If the first argument is exactly \fB(\fP and the fourth argument is exactly \fB)\fP, the result is the two-argument test of the second and third arguments. @@ -10846,51 +12453,82 @@ precedence using the rules listed above. 5 or more arguments The expression is parsed and evaluated according to precedence using the rules listed above. -.if t .sp 0.5 -.if n .sp 1 -.LP -When used with \fBtest\fP or \fB[\fP, the \fB<\fP and \fB>\fP operators -sort lexicographically using ASCII ordering. -.RE .PD +.PP +When the shell is in posix mode, or if the expression is part +of the \fB[[\fP command, +the \fB<\fP and \fB>\fP operators sort using the +current locale. +If the shell is not in posix mode, the \fBtest\fP and \fB[\fP +commands sort lexicographically using ASCII ordering. +.PP +The historical operator-precedence parsing with 4 or more arguments can +lead to ambiguities when it encounters strings that look like primaries. +The +.SM POSIX +standard has deprecated the \fB\-a\fP and \fB\-o\fP +primaries and enclosing expressions within parentheses. +Scripts should no longer use them. +It's much more reliable to restrict test invocations to a single primary, +and to replace uses of \fB\-a\fP and \fB\-o\fP with the shell's +\fB&&\fP and \fB||\fP list operators. +.RE .TP .B times Print the accumulated user and system times for the shell and -for processes run from the shell. The return status is 0. +for processes run from the shell. +The return status is 0. .TP -\fBtrap\fP [\fB\-lp\fP] [[\fIarg\fP] \fIsigspec\fP ...] -The command -.I arg -is to be read and executed when the shell receives -signal(s) +\fBtrap\fP [\fB\-lpP\fP] [[\fIaction\fP] \fIsigspec\fP .\|.\|.] +The +.I action +is a command that is read and executed when the shell receives +any of the signals .IR sigspec . If -.I arg +.I action is absent (and there is a single \fIsigspec\fP) or .BR \- , -each specified signal is -reset to its original disposition (the value it had -upon entrance to the shell). +each specified \fIsigspec\fP is +reset to the value it had when the shell was started. If -.I arg +.I action is the null string the signal specified by each .I sigspec is ignored by the shell and by the commands it invokes. +.IP +If no arguments are supplied, +.B trap +displays the actions associated with each trapped signal +as a set of \fBtrap\fP commands +that can be reused as shell input to +restore the current signal dispositions. If -.I arg -is not present and -.B \-p -has been supplied, then the trap commands associated with each -.I sigspec -are displayed. -If no arguments are supplied or if only .B \-p is given, -.B trap -prints the list of commands associated with each signal. +and +.I action +is not present, +then \fBtrap\fP displays the actions associated with each +.I sigspec +or, if none are supplied, for all trapped signals, +as a set of \fBtrap\fP commands +that can be reused as shell input to +restore the current signal dispositions. +The +.B \-P +option behaves similarly, but displays only the actions +associated with each \fIsigspec\fP argument. +.B \-P +requires at least one \fIsigspec\fP argument. +The \fB\-P\fP or \fB\-p\fP options may be used +in a subshell environment (e.g., command substitution) and, as +long as they are used before \fBtrap\fP is used to change a signal's +handling, will display the state of its parent's traps. +.IP The .B \-l -option causes the shell to print a list of signal names and +option prints a list of signal names and their corresponding numbers. Each .I sigspec @@ -10900,50 +12538,53 @@ Signal names are case insensitive and the .SM .B SIG prefix is optional. -.if t .sp 0.5 -.if n .sp 1 +If \fB\-l\fP is supplied with no \fIsigspec\fP arguments, it prints a +list of valid signal names. +.IP If a .I sigspec is .SM .B EXIT -(0) the command -.I arg +(0), +.I action is executed on exit from the shell. If a .I sigspec is .SM .BR DEBUG , -the command -.I arg +.I action is executed before every \fIsimple command\fP, \fIfor\fP command, -\fIcase\fP command, \fIselect\fP command, every arithmetic \fIfor\fP -command, and before the first command executes in a shell function (see +\fIcase\fP command, \fIselect\fP command, (( arithmetic command, +[[ conditional command, +arithmetic \fIfor\fP command, and before the first command executes +in a shell function (see .SM -.B SHELL GRAMMAR -.ie \n(zZ=1 in \fIbash(1)\fP). +.B "SHELL GRAMMAR" +.ie \n(zZ=1 in \fIbash\fP(1)). .el above). -Refer to the description of the \fBextdebug\fP option to the -\fBshopt\fP builtin for details of its effect on the \fBDEBUG\fP trap. +Refer to the description of the \fBextdebug\fP shell option +(see +.B shopt +.ie \n(zZ=1 in \fIbash\fP(1)) +.el above) +for details of its effect on the \fBDEBUG\fP trap. If a .I sigspec is .SM .BR RETURN , -the command -.I arg +.I action is executed each time a shell function or a script executed with the \fB.\fP or \fBsource\fP builtins finishes executing. -.if t .sp 0.5 -.if n .sp 1 +.IP If a .I sigspec is .SM .BR ERR , -the command -.I arg +.I action is executed whenever a pipeline (which may consist of a single simple command), a list, or a compound command returns a @@ -10957,7 +12598,7 @@ command is part of the command list immediately following a .B while or .B until -keyword, +reserved word, part of the test in an .I if statement, part of a command executed in a @@ -10965,14 +12606,16 @@ statement, part of a command executed in a or .B || list except the command following the final \fB&&\fP or \fB||\fP, -any command in a pipeline but the last, +any command in a pipeline but the last +(subject to the state of the \fBpipefail\fP shell option), or if the command's return value is being inverted using .BR ! . These are the same conditions obeyed by the \fBerrexit\fP (\fB\-e\fP) option. -.if t .sp 0.5 -.if n .sp 1 -Signals ignored upon entry to the shell cannot be trapped or reset. +.IP +When the shell is not interactive, +signals ignored upon entry to the shell cannot be trapped or reset. +Interactive shells permit trapping signals ignored on entry. Trapped signals that are not being ignored are reset to their original values in a subshell or subshell environment when one is created. The return status is false if any @@ -10981,11 +12624,14 @@ is invalid; otherwise .B trap returns true. .TP -\fBtype\fP [\fB\-aftpP\fP] \fIname\fP [\fIname\fP ...] -With no options, -indicate how each +\fBtrue\fP +Does nothing, returns a 0 status. +.TP +\fBtype\fP [\fB\-aftpP\fP] \fIname\fP [\fIname\fP .\|.\|.] +Indicate how each .I name would be interpreted if used as a command name. +.IP If the .B \-t option is used, @@ -10999,23 +12645,23 @@ or .I file if .I name -is an alias, shell reserved word, function, builtin, or disk file, +is an alias, shell reserved word, function, builtin, or executable file, respectively. If the .I name -is not found, then nothing is printed, and an exit status of false -is returned. +is not found, \fBtype\fP prints nothing and returns a non-zero exit status. +.IP If the .B \-p option is used, .B type -either returns the name of the disk file -that would be executed if +either returns the pathname of the executable file +that would be found by searching +.B $PATH +for .I name -were specified as a command name, or nothing if -.if t \f(CWtype -t name\fP -.if n ``type -t name'' +.Q "type \-t name" would not return .IR file . The @@ -11024,11 +12670,10 @@ option forces a .SM .B PATH search for each \fIname\fP, even if -.if t \f(CWtype -t name\fP -.if n ``type -t name'' +.Q "type \-t name" would not return .IR file . -If a command is hashed, +If \fIname\fP is present in the table of hashed commands, .B \-p and .B \-P @@ -11036,20 +12681,26 @@ print the hashed value, which is not necessarily the file that appears first in .SM .BR PATH . +.IP If the .B \-a option is used, .B type -prints all of the places that contain -an executable named +prints all of the places that contain a command named .IR name . -This includes aliases and functions, -if and only if the -.B \-p -option is not also used. -The table of hashed commands is not consulted +This includes aliases, reserved words, functions, and builtins, +but the path search options (\fB\-p\fP and \fB\-P\fP) +can be supplied to restrict the output to executable files. +\fBtype\fP does not consult the table of hashed commands when using -.BR \-a . +.B \-a +with +.BR \-p , +and only performs a +.SM +.B PATH +search for \fIname\fP. +.IP The .B \-f option suppresses shell function lookup, as with the \fBcommand\fP builtin. @@ -11063,13 +12714,15 @@ any are not found. \fBulimit\fP [\fB\-HS\fP] [\fB\-bcdefiklmnpqrstuvxPRT\fP [\fIlimit\fP]] .PD Provides control over the resources available to the shell and to -processes started by it, on systems that allow such control. -The \fB\-H\fP and \fB\-S\fP options specify that the hard or soft limit is -set for the given resource. +processes it starts, on systems that allow such control. +.IP +The \fB\-H\fP and \fB\-S\fP options specify whether +the hard or soft limit is set for the given resource. A hard limit cannot be increased by a non-root user once it is set; a soft limit may be increased up to the value of the hard limit. -If neither \fB\-H\fP nor \fB\-S\fP is specified, both the soft and hard -limits are set. +If neither \fB\-H\fP nor \fB\-S\fP is specified, +\fBulimit\fP sets both the soft and hard limits. +.IP The value of .I limit can be a number in the unit specified for the resource @@ -11082,92 +12735,97 @@ which stand for the current hard limit, the current soft limit, and no limit, respectively. If .I limit -is omitted, the current value of the soft limit of the resource is -printed, unless the \fB\-H\fP option is given. When more than one -resource is specified, the limit name and unit, if appropriate, -are printed before the value. +is omitted, \fBulimit\fP prints the current value of the soft limit of +the resource, unless the \fB\-H\fP option is given. +When more than one resource is specified, the limit name and unit, +if appropriate, are printed before the value. Other options are interpreted as follows: .RS .PD 0 .TP .B \-a -All current limits are reported; no limits are set +Report all current limits; no limits are set. .TP .B \-b -The maximum socket buffer size +The maximum socket buffer size. .TP .B \-c -The maximum size of core files created +The maximum size of core files created. .TP .B \-d -The maximum size of a process's data segment +The maximum size of a process's data segment. .TP .B \-e -The maximum scheduling priority ("nice") +The maximum scheduling priority (\c +.Q nice ). .TP .B \-f -The maximum size of files written by the shell and its children +The maximum size of files written by the shell and its children. .TP .B \-i -The maximum number of pending signals +The maximum number of pending signals. .TP .B \-k -The maximum number of kqueues that may be allocated +The maximum number of kqueues that may be allocated. .TP .B \-l -The maximum size that may be locked into memory +The maximum size that may be locked into memory. .TP .B \-m -The maximum resident set size (many systems do not honor this limit) +The maximum resident set size (many systems do not honor this limit). .TP .B \-n The maximum number of open file descriptors (most systems do not -allow this value to be set) +allow this value to be set). .TP .B \-p -The pipe size in 512-byte blocks (this may not be set) +The pipe size in 512-byte blocks (this may not be set). .TP .B \-q -The maximum number of bytes in POSIX message queues +The maximum number of bytes in +.SM POSIX +message queues. .TP .B \-r -The maximum real-time scheduling priority +The maximum real-time scheduling priority. .TP .B \-s -The maximum stack size +The maximum stack size. .TP .B \-t -The maximum amount of cpu time in seconds +The maximum amount of cpu time in seconds. .TP .B \-u -The maximum number of processes available to a single user +The maximum number of processes available to a single user. .TP .B \-v The maximum amount of virtual memory available to the shell and, on -some systems, to its children +some systems, to its children. .TP .B \-x -The maximum number of file locks +The maximum number of file locks. .TP .B \-P -The maximum number of pseudoterminals +The maximum number of pseudoterminals. .TP .B \-R -The maximum time a real-time process can run before blocking, in microseconds +The maximum time a real-time process can run before blocking, in microseconds. .TP .B \-T -The maximum number of threads +The maximum number of threads. .PD .PP If .I limit -is given, and the +is supplied, and the .B \-a option is not used, \fIlimit\fP is the new value of the specified resource. -If no option is given, then +If no option is supplied, then .B \-f -is assumed. Values are in 1024-byte increments, except for +is assumed. +.PP +Values are in 1024-byte increments, except for .BR \-t , which is in seconds; .BR \-R , @@ -11192,39 +12850,40 @@ or an error occurs while setting a new limit. .RE .TP \fBumask\fP [\fB\-p\fP] [\fB\-S\fP] [\fImode\fP] -The user file-creation mask is set to +Set the user file-creation mask to .IR mode . If .I mode -begins with a digit, it -is interpreted as an octal number; otherwise -it is interpreted as a symbolic mode mask similar +begins with a digit, it is interpreted as an octal number; +otherwise it is interpreted as a symbolic mode mask similar to that accepted by .IR chmod (1). If .I mode -is omitted, the current value of the mask is printed. +is omitted, \fBumask\fP prints the current value of the mask. The .B \-S -option causes the mask to be printed in symbolic form; the -default output is an octal number. +option without a \fImode\fP argument +prints the mask in a symbolic format; +the default output is an octal number. If the .B \-p option is supplied, and .I mode is omitted, the output is in a form that may be reused as input. -The return status is 0 if the mode was successfully changed or if -no \fImode\fP argument was supplied, and false otherwise. +The return status is zero if the mode was successfully changed or +if no \fImode\fP argument was supplied, and non-zero otherwise. .TP -\fBunalias\fP [\-\fBa\fP] [\fIname\fP ...] -Remove each \fIname\fP from the list of defined aliases. If +\fBunalias\fP [\-\fBa\fP] [\fIname\fP .\|.\|.] +Remove each \fIname\fP from the list of defined aliases. +If .B \-a -is supplied, all alias definitions are removed. The return -value is true unless a supplied +is supplied, remove all alias definitions. +The return value is true unless a supplied .I name is not a defined alias. .TP -\fBunset\fP [\-\fBfv\fP] [\-\fBn\fP] [\fIname\fP ...] +\fBunset\fP [\-\fBfv\fP] [\-\fBn\fP] [\fIname\fP .\|.\|.] For each .IR name , remove the corresponding variable or function. @@ -11233,7 +12892,6 @@ If the option is given, each .I name refers to a shell variable, and that variable is removed. -Read-only variables may not be unset. If .B \-f is specified, each @@ -11246,11 +12904,13 @@ option is supplied, and \fIname\fP is a variable with the \fInameref\fP attribute, \fIname\fP will be unset rather than the variable it references. \fB\-n\fP has no effect if the \fB\-f\fP option is supplied. +Read-only variables and functions may not be unset. +When variables or functions are removed, they are also removed +from the environment passed to subsequent commands. If no options are supplied, each \fIname\fP refers to a variable; if there is no variable by that name, a function with that name, if any, is unset. -Each unset variable or function is removed from the environment -passed to subsequent commands. +Some shell variables may not be unset. If any of .SM .BR BASH_ALIASES , @@ -11288,67 +12948,75 @@ or .SM .B SRANDOM are unset, they lose their special properties, even if they are -subsequently reset. The exit status is true unless a +subsequently reset. +The exit status is true unless a .I name is readonly or may not be unset. .TP -\fBwait\fP [\fB\-fn\fP] [\fP\-p\fP \fIvarname\fP] [\fIid ...\fP] -Wait for each specified child process and return its termination status. -Each -.I id -may be a process -ID or a job specification; if a job spec is given, all processes -in that job's pipeline are waited for. If -.I id -is not given, +\fBwait\fP [\fB\-fn\fP] [\fP\-p\fP \fIvarname\fP] [\fIid\fP .\|.\|.] +Wait for each specified child process \fIid\fP and return the +termination status of the last \fIid\fP. +Each \fIid\fP may be a process ID \fIpid\fP +or a job specification \fIjobspec\fP; +if a jobspec is supplied, \fBwait\fP waits for all processes in the job. +.IP +If no options or \fIid\fPs are supplied, \fBwait\fP waits for all running background jobs and -the last-executed process substitution, if its process id is the same as -\fB$!\fP, +the last-executed process substitution, +if its process id is the same as \fB$!\fP, and the return status is zero. -If the \fB\-n\fP option is supplied, -\fBwait\fP waits for a single job -from the list of \fIid\fPs or, if no \fIid\fPs are supplied, any job, +.IP +If the \fB\-n\fP option is supplied, \fBwait\fP waits for any one of +the given \fIid\fPs or, +if no \fIid\fPs are supplied, any job or process substitution, to complete and returns its exit status. -If none of the supplied arguments is a child of the shell, or if no arguments -are supplied and the shell has no unwaited-for children, the exit status -is 127. -If the \fB\-p\fP option is supplied, the process or job identifier of the job -for which the exit status is returned is assigned to the variable -\fIvarname\fP named by the option argument. -The variable will be unset initially, before any assignment. -This is useful only when the \fB\-n\fP option is supplied. +If none of the supplied \fIid\fPs is a child of the shell, +or if no \fIid\fPs are supplied and the shell has no unwaited-for children, +the exit status is 127. +.IP +If the \fB\-p\fP option is supplied, \fBwait\fP assigns +the process or job identifier of the job +for which the exit status is returned to the +variable \fIvarname\fP named by the option argument. +The variable, +which cannot be readonly, +will be unset initially, before any assignment. +This is useful only when used with the \fB\-n\fP option. +.IP Supplying the \fB\-f\fP option, when job control is enabled, -forces \fBwait\fP to wait for \fIid\fP to terminate before returning -its status, instead of returning when it changes status. -If -.I id -specifies a non-existent process or job, the return status is 127. -If \fBwait\fP is interrupted by a signal, the return status will be greater +forces \fBwait\fP to wait for each \fIid\fP to terminate before +returning its status, instead of returning when it changes status. +.IP +If none of the \fIid\fPs specify one of the shell's active child +processes, the return status is 127. +If \fBwait\fP is interrupted by a signal, +any \fIvarname\fP will remain unset, +and the return status will be greater than 128, as described under .B SIGNALS -.ie \n(zZ=1 in \fIbash(1)\fP. +.ie \n(zZ=1 in \fIbash\fP(1). .el above. -Otherwise, the return status is the exit status of the last -process or job waited for. +Otherwise, the return status is the exit status of the last \fIid\fP. .SH "SHELL COMPATIBILITY MODE" Bash-4.0 introduced the concept of a \fIshell compatibility level\fP, -specified as a set of options to the shopt builtin ( +specified as a set of options to the shopt builtin (\c .BR compat31 , .BR compat32 , .BR compat40 , .BR compat41 , and so on). There is only one current -compatibility level -- each option is mutually exclusive. +compatibility level \(em each option is mutually exclusive. The compatibility level is intended to allow users to select behavior from previous versions that is incompatible with newer versions -while they migrate scripts to use current features and -behavior. It's intended to be a temporary solution. +while they migrate scripts to use current features and behavior. +It's intended to be a temporary solution. .PP This section does not mention behavior that is standard for a particular -version (e.g., setting \fBcompat32\fP means that quoting the rhs of the regexp +version (e.g., setting \fBcompat32\fP means that quoting the right hand +side of the regexp matching operator quotes special regexp characters in the word, which is -default behavior in bash-3.2 and subsequent versions). +default behavior in bash-3.2 and subsequent versions). .PP If a user enables, say, \fBcompat32\fP, it may affect the behavior of other compatibility levels up to and including the current compatibility level. @@ -11371,17 +13039,18 @@ to this variable (a decimal version number like 4.2, or an integer corresponding to the \fBcompat\fP\fINN\fP option, like 42) determines the compatibility level. .PP -Starting with bash-4.4, Bash has begun deprecating older compatibility +Starting with bash-4.4, \fBbash\fP began deprecating older compatibility levels. Eventually, the options will be removed in favor of .SM .BR BASH_COMPAT . .PP -Bash-5.0 is the final version for which there will be an individual shopt -option for the previous version. Users should use +Bash-5.0 was the final version for which there was an individual shopt +option for the previous version. .SM .B BASH_COMPAT -on bash-5.0 and later versions. +is the only mechanism to control the compatibility level +in versions newer than bash-5.0. .PP The following table describes the behavior changes controlled by each compatibility level setting. @@ -11400,8 +13069,8 @@ and it is required for bash-5.1 and later versions. .PD 0 .RS .IP \(bu -quoting the rhs of the \fB[[\fP command's regexp matching operator (=~) -has no special effect +Quoting the rhs of the \fB[[\fP command's regexp matching operator (=\*~) +has no special effect. .RE .PD .TP @@ -11409,11 +13078,9 @@ has no special effect .PD 0 .RS .IP \(bu -interrupting a command list such as "a ; b ; c" causes the execution -of the next command in the list (in bash-4.0 and later versions, -the shell acts as if it received the interrupt, so -interrupting one command in a list aborts the execution of the -entire list) +The \fB<\fP and \fB>\fP operators to the \fB[[\fP command do not +consider the current locale when comparing strings; they use ASCII +ordering. .RE .PD .TP @@ -11421,10 +13088,10 @@ entire list) .PD 0 .RS .IP \(bu -the \fB<\fP and \fB>\fP operators to the \fB[[\fP command do not +The \fB<\fP and \fB>\fP operators to the \fB[[\fP command do not consider the current locale when comparing strings; they use ASCII ordering. -Bash versions prior to bash-4.1 use ASCII collation and +\fBBash\fP versions prior to bash-4.1 use ASCII collation and .IR strcmp (3); bash-4.1 and later use the current locale's collation sequence and .IR strcoll (3). @@ -11435,14 +13102,18 @@ bash-4.1 and later use the current locale's collation sequence and .PD 0 .RS .IP \(bu -in \fIposix\fP mode, \fBtime\fP may be followed by options and still be -recognized as a reserved word (this is POSIX interpretation 267) +In posix mode, \fBtime\fP may be followed by options and still be +recognized as a reserved word (this is +.SM POSIX +interpretation 267). .IP \(bu -in \fIposix\fP mode, the parser requires that an even number of single +In \fIposix\fP mode, the parser requires that an even number of single quotes occur in the \fIword\fP portion of a double-quoted parameter expansion and treats them specially, so that characters within the single quotes are considered quoted -(this is POSIX interpretation 221) +(this is +.SM POSIX +interpretation 221). .RE .PD .TP @@ -11450,15 +13121,17 @@ the single quotes are considered quoted .PD 0 .RS .IP \(bu -the replacement string in double-quoted pattern substitution does not -undergo quote removal, as it does in versions after bash-4.2 +The replacement string in double-quoted pattern substitution does not +undergo quote removal, as it does in versions after bash-4.2. .IP \(bu -in posix mode, single quotes are considered special when expanding +In posix mode, single quotes are considered special when expanding the \fIword\fP portion of a double-quoted parameter expansion and can be used to quote a closing brace or other special character -(this is part of POSIX interpretation 221); +(this is part of +.SM POSIX +interpretation 221); in later versions, single quotes -are not special within double-quoted word expansions +are not special within double-quoted word expansions. .RE .PD .TP @@ -11466,20 +13139,15 @@ are not special within double-quoted word expansions .PD 0 .RS .IP \(bu -the shell does not print a warning message if an attempt is made to -use a quoted compound assignment as an argument to declare -(e.g., declare -a foo=\(aq(1 2)\(aq). Later versions warn that this usage is -deprecated -.IP \(bu -word expansion errors are considered non-fatal errors that cause the +Word expansion errors are considered non-fatal errors that cause the current command to fail, even in posix mode (the default behavior is to make them fatal errors that cause the shell -to exit) +to exit). .IP \(bu -when executing a shell function, the loop state (while/until/etc.) +When executing a shell function, the loop state (while/until/etc.) is not reset, so \fBbreak\fP or \fBcontinue\fP in that function will break -or continue loops in the calling context. Bash-4.4 and later reset -the loop state to prevent this +or continue loops in the calling context. +Bash-4.4 and later reset the loop state to prevent this. .RE .PD .TP @@ -11487,23 +13155,23 @@ the loop state to prevent this .PD 0 .RS .IP \(bu -the shell sets up the values used by +The shell sets up the values used by .SM .B BASH_ARGV and .SM .B BASH_ARGC so they can expand to the shell's positional parameters even if extended -debugging mode is not enabled +debugging mode is not enabled. .IP \(bu -a subshell inherits loops from its parent context, so \fBbreak\fP +A subshell inherits loops from its parent context, so \fBbreak\fP or \fBcontinue\fP will cause the subshell to exit. Bash-5.0 and later reset the loop state to prevent the exit .IP \(bu -variable assignments preceding builtins like \fBexport\fP and \fBreadonly\fP +Variable assignments preceding builtins like \fBexport\fP and \fBreadonly\fP that set attributes continue to affect variables with the same name in the calling environment even if the shell is not in posix -mode +mode. .RE .PD .TP @@ -11514,17 +13182,18 @@ mode Bash-5.1 changed the way .SM .B $RANDOM -is generated to introduce slightly -more randomness. If the shell compatibility level is set to 50 or +is generated to introduce slightly more randomness. +If the shell compatibility level is set to 50 or lower, it reverts to the method from bash-5.0 and previous versions, so seeding the random number generator by assigning a value to .SM .B RANDOM -will produce the same sequence as in bash-5.0 +will produce the same sequence as in bash-5.0. .IP \(bu If the command hash table is empty, bash versions prior to bash-5.1 printed an informational message to that effect, even when producing -output that can be reused as input. Bash-5.1 suppresses that message +output that can be reused as input. +Bash-5.1 suppresses that message when the \fB\-l\fP option is supplied. .RE .PD @@ -11536,6 +13205,60 @@ when the \fB\-l\fP option is supplied. The \fBunset\fP builtin treats attempts to unset array subscripts \fB@\fP and \fB*\fP differently depending on whether the array is indexed or associative, and differently than in previous versions. +.IP \(bu +Arithmetic commands ( +.BR (( .\|.\|.\& )) +) and the expressions in an arithmetic for +statement can be expanded more than once. +.IP \(bu +Expressions used as arguments to arithmetic operators in the \fB[[\fP +conditional command can be expanded more than once. +.IP \(bu +The expressions in substring parameter brace expansion can be +expanded more than once. +.IP \(bu +The expressions in the +.BR $(( .\|.\|.\& )) +word expansion can be expanded more than once. +.IP \(bu +Arithmetic expressions used as indexed array subscripts can be +expanded more than once. +.IP \(bu +\fBtest \-v\fP, when given an argument of \fBA[@]\fP, where \fBA\fP is +an existing associative array, will return true if the array has any set +elements. +Bash-5.2 will look for and report on a key named \fB@\fP. +.IP \(bu +The ${\fIparameter\fP\fB[:]=\fP\fIvalue\fP} word expansion will return +\fIvalue\fP, before any variable-specific transformations have been +performed (e.g., converting to lowercase). +Bash-5.2 will return the final value assigned to the variable. +.IP \(bu +Parsing command substitutions will behave as if extended globbing +(see the description of the +.B shopt +builtin above) +is enabled, so that parsing a command substitution containing an extglob +pattern (say, as part of a shell function) will not fail. +This assumes the intent is to enable extglob before the command is executed +and word expansions are performed. +It will fail at word expansion time if extglob hasn't been +enabled by the time the command is executed. +.RE +.PD +.TP +\fBcompat52\fP +.PD 0 +.RS +.IP \(bu +The \fBtest\fP builtin uses its historical algorithm to parse parenthesized +subexpressions when given five or more arguments. +.IP \(bu +If the \fB\-p\fP or \fB\-P\fP option is supplied to the \fBbind\fP builtin, +\fBbind\fP treats any arguments remaining after option processing +as bindable command names, and +displays any key sequences bound to those commands, instead of treating +the arguments as key sequences to bind. .RE .PD .\" bash_builtins @@ -11550,17 +13273,16 @@ is started with the name .BR rbash , or the .B \-r -option is supplied at invocation, -the shell becomes restricted. +option is supplied at invocation, the shell becomes \fIrestricted\fP. A restricted shell is used to set up an environment more controlled than the standard shell. It behaves identically to .B bash with the exception that the following are disallowed or not performed: .IP \(bu -changing directories with \fBcd\fP +Changing directories with \fBcd\fP. .IP \(bu -setting or unsetting the values of +Setting or unsetting the values of .SM .BR SHELL , .SM @@ -11571,58 +13293,65 @@ setting or unsetting the values of .BR ENV , or .SM -.B BASH_ENV +.BR BASH_ENV . .IP \(bu -specifying command names containing -.B / +Specifying command names containing +.BR / . .IP \(bu -specifying a filename containing a +Specifying a filename containing a .B / as an argument to the .B . -builtin command +builtin command. .IP \(bu -specifying a filename containing a slash as an argument to the +Using the \fB\-p\fP option to the +.B . +builtin command to specify a search path. +.IP \(bu +Specifying a filename containing a slash as an argument to the .B history -builtin command +builtin command. .IP \(bu -specifying a filename containing a slash as an argument to the +Specifying a filename containing a slash as an argument to the .B \-p option to the .B hash -builtin command +builtin command. .IP \(bu -importing function definitions from the shell environment at startup +Importing function definitions from the shell environment at startup. .IP \(bu -parsing the value of +Parsing the values of +.SM +.B BASHOPTS +and .SM .B SHELLOPTS -from the shell environment at startup +from the shell environment at startup. .IP \(bu -redirecting output using the >, >|, <>, >&, &>, and >> redirection operators +Redirecting output using the >, >|, <>, >&, &>, and >> redirection operators. .IP \(bu -using the +Using the .B exec -builtin command to replace the shell with another command +builtin command to replace the shell with another command. .IP \(bu -adding or deleting builtin commands with the +Adding or deleting builtin commands with the .B \-f and .B \-d options to the .B enable -builtin command +builtin command. .IP \(bu -using the \fBenable\fP builtin command to enable disabled shell builtins +Using the \fBenable\fP builtin command to enable disabled shell builtins. .IP \(bu -specifying the +Specifying the .B \-p option to the .B command -builtin command +builtin command. .IP \(bu -turning off restricted mode with -\fBset +r\fP or \fBshopt -u restricted_shell\fP. +Turning off restricted mode with +\fBset +r\fP or \fBshopt \-u restricted_shell\fP. .PP These restrictions are enforced after any startup files are read. .PP @@ -11632,7 +13361,7 @@ These restrictions are enforced after any startup files are read. .SM .B "COMMAND EXECUTION" above), -\} +.\} .B rbash turns off any restrictions in the shell spawned to execute the script. @@ -11647,10 +13376,10 @@ script. .TP \fIThe Gnu History Library\fP, Brian Fox and Chet Ramey .TP -\fIPortable Operating System Interface (POSIX) Part 2: Shell and Utilities\fP, IEEE -- -http://pubs.opengroup.org/onlinepubs/9699919799/ +\fIPortable Operating System Interface (POSIX) Part 2: Shell and Utilities\fP, IEEE \(em +http://pubs.opengroup.org/onlinepubs/9799919799/ .TP -http://tiswww.case.edu/~chet/bash/POSIX -- a description of posix mode +http://tiswww.case.edu/\*~chet/bash/POSIX \(em a description of posix mode .TP \fIsh\fP(1), \fIksh\fP(1), \fIcsh\fP(1) .TP @@ -11667,20 +13396,20 @@ The \fBbash\fP executable .FN /etc/profile The systemwide initialization file, executed for login shells .TP -.FN ~/.bash_profile +.FN \*~/.bash_profile The personal initialization file, executed for login shells .TP -.FN ~/.bashrc +.FN \*~/.bashrc The individual per-interactive-shell startup file .TP -.FN ~/.bash_logout +.FN \*~/.bash_logout The individual login shell cleanup file, executed when a login shell exits .TP -.FN ~/.bash_history +.FN \*~/.bash_history The default value of \fBHISTFILE\fP, the file in which bash saves the command history .TP -.FN ~/.inputrc +.FN \*~/.inputrc Individual \fIreadline\fP initialization file .PD .SH AUTHORS @@ -11693,7 +13422,7 @@ Chet Ramey, Case Western Reserve University chet.ramey@case.edu .SH BUG REPORTS If you find a bug in -.B bash, +.BR bash , you should report it. But first, you should make sure that it really is a bug, and that it appears in the latest version of @@ -11706,8 +13435,9 @@ Once you have determined that a bug actually exists, use the .I bashbug command to submit a bug report. If you have a fix, you are encouraged to mail that as well! -Suggestions and `philosophical' bug reports may be mailed -to \fIbug-bash@gnu.org\fP or posted to the Usenet +You may send suggestions and +.Q philosophical +bug reports to \fIbug-bash@gnu.org\fP or post them to the Usenet newsgroup .BR gnu.bash.bug . .PP @@ -11715,15 +13445,17 @@ ALL bug reports should include: .PP .PD 0 .TP 20 -The version number of \fBbash\fR +The version number of \fBbash\fP .TP The hardware and operating system .TP The compiler used to compile .TP -A description of the bug behaviour +A description of the bug behavior .TP -A short script or `recipe' which exercises the bug +A short script or \c +.Q recipe " \c" +which exercises the bug .PD .PP .I bashbug @@ -11741,24 +13473,23 @@ There are some subtle differences between and traditional versions of .BR sh , mostly because of the -.SM -.B POSIX +.SM POSIX specification. .PP Aliases are confusing in some uses. .PP Shell builtin commands and functions are not stoppable/restartable. .PP -Compound commands and command sequences of the form `a ; b ; c' -are not handled gracefully when process suspension is attempted. +Compound commands and command lists of the form +.Q "a ; b ; c" +are not handled gracefully when combined with process suspension. When a process is stopped, the shell immediately executes the next -command in the sequence. -It suffices to place the sequence of commands between -parentheses to force it into a subshell, which may be stopped as -a unit. +command in the list or breaks out of any existing loops. +It suffices to enclose the command in parentheses to +force it into a subshell, which may be stopped as a unit, +or to start the command in the background and immediately +bring it into the foreground. .PP Array variables may not (yet) be exported. -.PP -There may be only one active coprocess at a time. .zZ .zY diff --git a/doc/bash.html b/doc/bash.html index d80936900..07c854448 100644 --- a/doc/bash.html +++ b/doc/bash.html @@ -3,7 +3,7 @@ -
BASH(1)2022 September 19BASH(1) +BASH(1)2025 April 7BASH(1)

Index @@ -26,12 +26,6 @@ - - - - - - @@ -54,28 +48,48 @@ bash - GNU Bourne-Again SHell

COPYRIGHT

-Bash is Copyright © 1989-2022 by the Free Software Foundation, Inc. +Bash is Copyright © 1989-2025 by the Free Software Foundation, Inc.  

DESCRIPTION

Bash -is an sh-compatible command language interpreter that -executes commands read from the standard input or from a file. +is a command language interpreter that +executes commands read from the standard input, from a string, +or from a file. +It is a reimplementation and extension of the Bourne shell, +the historical Unix command language interpreter. Bash also incorporates useful features from the Korn and C shells (ksh and csh).

+POSIX +is the name for a family of computing standards based on Unix. Bash is intended to be a conformant implementation of the -Shell and Utilities portion of the IEEE POSIX specification -(IEEE Standard 1003.1). +Shell and Utilities portion of the IEEE +POSIX +specification (IEEE Standard 1003.1). +Bash + +POSIX +mode (hereafter referred to as posix mode) +changes the shell's behavior where its default operation differs +from the standard to strictly conform to the standard. +See +SEE ALSO + + +below for a reference to a document that details how posix mode affects +bash's behavior. Bash -can be configured to be POSIX-conformant by default. +can be configured to be +POSIX +-conformant by default.  

OPTIONS

@@ -86,7 +100,6 @@ In addition, bash interprets the following options when it is invoked:

-

-c @@ -149,15 +162,15 @@ If the -s option is present, or if no arguments remain after option -processing, then commands are read from the standard input. +processing, the shell reads commands from the standard input. This option allows the positional parameters to be set when invoking an interactive shell or when reading input through a pipe.
-D
-A list of all double-quoted strings preceded by $ -is printed on the standard output. +Print a list of all double-quoted strings preceded by $ +on the standard output. These are the strings that are subject to language translation when the current locale is not C or POSIX. @@ -173,8 +186,9 @@ This implies the -n option; no commands will be executed. below). If shopt_option is present, -O sets the value of that option; +O unsets it. -If shopt_option is not supplied, the names and values of the shell -options accepted by shopt are printed on the standard output. +If shopt_option is not supplied, bash prints +the names and values of the shell +options accepted by shopt on the standard output. If the invocation option is +O, the output is displayed in a format that may be reused as input.
-- @@ -187,11 +201,12 @@ signals the end of options and disables further option processing. Any arguments after the -- -are treated as filenames and arguments. An argument of +are treated as a shell script filename (see below) +and arguments passed to that script. +An argument of - is equivalent to --. -

@@ -202,7 +217,6 @@ These options must appear on the command line before the single-character options to be recognized.

-

--debugger @@ -220,7 +234,8 @@ builtin below).
Equivalent to -D, but the output is in the GNU gettext -po (portable object) file format. + +(portable object) file format.
--dump-strings
@@ -229,14 +244,16 @@ Equivalent to -D.
Display a usage message on standard output and exit successfully. -
--init-file file
- +
+
+--init-file file
--rcfile file
Execute commands from file instead of the standard personal initialization file + ~/.bashrc if the shell is interactive (see @@ -263,11 +280,14 @@ Do not read either the system-wide startup file /etc/profile or any of the personal initialization files + ~/.bash_profile, + ~/.bash_login, or + ~/.profile. By default, @@ -282,6 +302,7 @@ below).
Do not read and execute the personal initialization file + ~/.bashrc if the shell is interactive. @@ -291,14 +312,11 @@ This option is on by default if the shell is invoked as
--posix
-Change the behavior of bash where the default operation differs -from the POSIX standard to match the standard (posix mode). -See -SEE ALSO - - -below for a reference to a document that details how posix mode affects -bash's behavior. +Enable posix mode; +change the behavior of bash +where the default operation differs from the +POSIX +standard to match the standard.
--restricted
@@ -318,7 +336,6 @@ Show version information for this instance of bash on the standard output and exit successfully. -
 

ARGUMENTS

@@ -329,9 +346,9 @@ If arguments remain after option processing, and neither the nor the -s -option has been supplied, the first argument is assumed to -be the name of a file containing shell commands. -If +option has been supplied, the first argument is treated as +the name of a file containing shell commands (a shell script). +When bash is invoked in this fashion, @@ -345,8 +362,10 @@ reads and executes commands from this file, then exits. Bash's exit status is the exit status of the last command executed in the script. If no commands are executed, the exit status is 0. -An attempt is first made to open the file in the current directory, and, -if no file is found, then the shell searches the directories in +Bash + +first attempts to open the file in the current directory, +and, if no file is found, searches the directories in PATH @@ -363,13 +382,13 @@ or one started with the option.

-An interactive shell is one started without non-option arguments +An interactive shell is one started without non-option arguments (unless -s is specified) and without the -c option, -whose standard input and error are +and whose standard input and standard error are both connected to terminals (as determined by isatty(3)), @@ -377,20 +396,20 @@ or one started with the -i option. +Bash + +sets PS1 -is set and +and $- includes i -if -bash - -is interactive, -allowing a shell script or a startup file to test this state. +if the shell is interactive, +so a shell script or a startup file can test this state.

The following paragraphs describe how @@ -416,10 +435,23 @@ When is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and -executes commands from the file /etc/profile, if that -file exists. -After reading that file, it looks for ~/.bash_profile, -~/.bash_login, and ~/.profile, in that order, and reads +executes commands from the file + +/etc/profile, + +if that file exists. +After reading that file, it looks for + +~/.bash_profile, + + +~/.bash_login, + +and + +~/.profile, + +in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile @@ -431,22 +463,32 @@ When an interactive login shell exits, or a non-interactive login shell executes the exit builtin command, bash -reads and executes commands from the file ~/.bash_logout, if it -exists. +reads and executes commands from the file + +~/.bash_logout, + +if it exists.

When an interactive shell that is not a login shell is started, bash -reads and executes commands from ~/.bashrc, if that file exists. -This may be inhibited by using the +reads and executes commands from + +~/.bashrc, + +if that file exists. +The --norc -option. -The --rcfile file option will force +option inhibits this behavior. +The --rcfile file option causes bash -to read and execute commands from file instead of ~/.bashrc. +to use file instead of + +~/.bashrc. +

When @@ -463,17 +505,24 @@ expanded value as the name of a file to read and execute. behaves as if the following command were executed:

+

-if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi + +if [ -n " +$BASH_ENV" + ]; then . " +$BASH_ENV" +; fi

-but the value of the + +but does not use the value of the PATH -variable is not used to search for the filename. +variable to search for the filename.

If @@ -486,20 +535,24 @@ it tries to mimic the startup behavior of historical versions of sh as closely as possible, -while conforming to the POSIX standard as well. +while conforming to the +POSIX +standard as well. When invoked as an interactive login shell, or a non-interactive -shell with the --login option, it first attempts to -read and execute commands from +shell with the --login option, it first attempts to read +and execute commands from + /etc/profile and + ~/.profile, in that order. The --noprofile -option may be used to inhibit this behavior. +option inhibits this behavior. When invoked as an interactive shell with the name sh, @@ -523,32 +576,30 @@ A non-interactive shell invoked with the name sh does not attempt to read any other startup files. +

+ When invoked as sh, bash -enters -posix - -mode after the startup files are read. +enters posix mode after reading the startup files.

When bash -is started in -posix - -mode, as with the +is started in posix mode, as with the --posix -command line option, it follows the POSIX standard for startup files. +command line option, it follows the +POSIX +standard for startup files. In this mode, interactive shells expand the ENV -variable and commands are read and executed from the file +variable and read and execute commands from the file whose name is the expanded value. No other startup files are read.

@@ -557,22 +608,31 @@ No other startup files are read. attempts to determine when it is being run with its standard input connected to a network connection, as when executed by -the historical remote shell daemon, usually rshd, +the historical and rarely-seen remote shell daemon, usually rshd, or the secure shell daemon sshd. If bash determines it is being run non-interactively in this fashion, -it reads and executes commands from ~/.bashrc, +it reads and executes commands from + +~/.bashrc, + if that file exists and is readable. -It will not do this if invoked as sh. +Bash + +does not read this file if invoked as sh. The --norc -option may be used to inhibit this behavior, and the +option inhibits this behavior, and the --rcfile -option may be used to force another file to be read, but neither +option makes bash use a different file instead of + +~/.bashrc, + +but neither rshd nor sshd generally invoke the shell with those options or allow them to be specified.

@@ -608,6 +668,11 @@ document.

A space or tab. +
whitespace + +
+A character belonging to the space character class in the +current locale, or for which isspace(3) returns true.
word
@@ -629,7 +694,8 @@ referred to as an
metacharacter
-A character that, when unquoted, separates words. One of the following: +A character that, when unquoted, separates words. +One of the following:
@@ -642,8 +708,8 @@ A character that, when unquoted, separates words. One of the following:
control operator
-A token that performs a control function. It is one of the following -symbols: +A token that performs a control function. +It is one of the following symbols:

@@ -693,7 +759,8 @@ This section describes the syntax of the various forms of shell commands. A simple command is a sequence of optional variable assignments followed by blank-separated words and redirections, and -terminated by a control operator. The first word +terminated by a control operator. +The first word specifies the command to be executed, and is passed as argument zero. The remaining words are passed as arguments to the invoked command.

@@ -732,7 +799,8 @@ This connection is performed before any redirections specified by the below). -If |& is used, command1's standard error, in addition to its +If |& is the pipeline operator, +command1's standard error, in addition to its standard output, is connected to command2's standard input through the pipe; it is shorthand for 2>&1 |. @@ -750,43 +818,46 @@ If the reserved word precedes a pipeline, the exit status of that pipeline is the logical negation of the exit status as described above. -The shell waits for all commands in the pipeline to +If a pipeline is executed synchronously, +the shell waits for all commands in the pipeline to terminate before returning a value.

If the time -reserved word precedes a pipeline, the elapsed as well as user and -system time consumed by its execution are reported when the pipeline -terminates. -The -p option changes the output format to that specified by POSIX. -When the shell is in posix mode, it does not recognize -time as a reserved word if the next token begins with a `-'. -The +reserved word precedes a pipeline, the shell reports the +elapsed as well as user and system time consumed by its execution +when the pipeline terminates. +The -p option changes the output format to that specified by +POSIX +. +When the shell is in posix mode, it does not recognize +time as a reserved word if the next token begins with a + +The value of the TIMEFORMAT -variable may be set to a format string that specifies how the timing +variable is a format string that specifies how the timing information should be displayed; see the description of TIMEFORMAT -under -Shell Variables +below under +Shell Variables. -below.

-When the shell is in posix mode, time -may be followed by a newline. In this case, the shell displays the +When the shell is in posix mode, time +may appear by itself as the only word in a simple command. +In this case, the shell displays the total user and system time consumed by the shell and its children. The TIMEFORMAT -variable may be used to specify the format of -the time information. +variable specifies the format of the time information.

Each command in a multi-command pipeline, @@ -794,12 +865,14 @@ where pipes are created, is executed in a subshell, which is a separate process. See -COMMAND EXECUTION ENVIRONMENT +COMMAND EXECUTION ENVIRONMENT + + for a description of subshells and a subshell environment. If the lastpipe option is enabled using the shopt builtin (see the description of shopt below), -the last element of a pipeline may be run by the shell process -when job control is not active. +and job control is not active, +the last element of a pipeline may be run by the shell process.  

Lists

@@ -855,8 +928,8 @@ Commands separated by a ; are executed sequentially; the shell waits for each -command to terminate in turn. The return status is the -exit status of the last command executed. +command to terminate in turn. +The return status is the exit status of the last command executed.

AND and OR lists are sequences of one or more pipelines separated by the @@ -907,26 +980,28 @@ newline in place of a semicolon.

(list)
list is executed in a subshell (see -COMMAND EXECUTION ENVIRONMENT +COMMAND EXECUTION ENVIRONMENT + + below for a description of a subshell environment). Variable assignments and builtin commands that affect the shell's environment do not remain in effect -after the command completes. The return status is the exit status of -list. +after the command completes. +The return status is the exit status of list.
{ list; }
-list is simply executed in the current shell environment. +list is executed in the current shell environment. list must be terminated with a newline or semicolon. This is known as a group command. -The return status is the exit status of -list. +The return status is the exit status of list. +
Note that unlike the metacharacters ( and ), { and } are reserved words and must occur where a reserved -word is permitted to be recognized. Since they do not cause a word -break, they must be separated from list by whitespace or another -shell metacharacter. +word is permitted to be recognized. +Since they do not cause a word break, they must be separated from +list by whitespace or another shell metacharacter.
((expression))
-The expression is evaluated according to the rules described -below under +The arithmetic expression is evaluated according to the rules +described below under ARITHMETIC EVALUATION. @@ -935,11 +1010,15 @@ otherwise the return status is 1. The expression undergoes the same expansions as if it were within double quotes, -but double quote characters in expression are not treated specially -and are removed. +but unescaped double quote characters +in expression are not treated +specially and are removed. +Since this can potentially result in empty strings, this command treats +those as expressions that evaluate to 0.
[[ expression ]]
-Return a status of 0 or 1 depending on the evaluation of -the conditional expression expression. + +Evaluate the conditional expression expression +and return a status of zero (true) or non-zero (false). Expressions are composed of the primaries described below under CONDITIONAL EXPRESSIONS. @@ -948,18 +1027,13 @@ The words between the [[ and ]] do not undergo word splitting and pathname expansion. The shell performs tilde expansion, parameter and variable expansion, arithmetic expansion, command substitution, process -substitution, and quote removal on those words -(the expansions that would occur if the words were enclosed in double quotes). +substitution, and quote removal on those words. Conditional operators such as -f must be unquoted to be recognized as primaries. -

- - +

When used with [[, the < and > operators sort lexicographically using the current locale. -

- - +

When the == and != operators are used, the string to the right of the operator is considered a pattern and matched according to the rules described below under Pattern Matching, @@ -972,17 +1046,22 @@ shell option is enabled, the match is performed without regard to the case of alphabetic characters. The return value is 0 if the string matches (==) or does not match (!=) the pattern, and 1 otherwise. -Any part of the pattern may be quoted to force the quoted portion -to be matched as a string. -

- - +If any part of the pattern is quoted, the quoted portion is matched +as a string: every character in the quoted portion matches itself, +instead of having any special pattern matching meaning. +

An additional binary operator, =~, is available, with the same precedence as == and !=. When it is used, the string to the right of the operator is considered -a POSIX extended regular expression and matched accordingly -(using the POSIX regcomp and regexec interfaces -usually described in regex(3)). +a +POSIX +extended regular expression and matched accordingly +(using the +POSIX +regcomp and regexec interfaces +usually described in +regex(3)). + The return value is 0 if the string matches the pattern, and 1 otherwise. If the regular expression is syntactically incorrect, the conditional @@ -992,20 +1071,19 @@ If the shell option is enabled, the match is performed without regard to the case of alphabetic characters. -If any part of the pattern is quoted, the quoted portion is matched literally. -This means every character in the quoted portion matches itself, -instead of having any special pattern matching meaning. +
+If any part of the pattern is quoted, the quoted portion is matched literally, +as above. If the pattern is stored in a shell variable, quoting the variable expansion forces the entire pattern to be matched literally. Treat bracket expressions in regular expressions carefully, since normal quoting and pattern characters lose their meanings between brackets. -

- - -The pattern will match if it matches any part of the string. +

+The match succeeds if the pattern matches any part of the string. Anchor the pattern using the ^ and $ regular expression operators to force it to match the entire string. +
The array variable BASH_REMATCH @@ -1022,26 +1100,23 @@ expression are saved in the remaining BASH_REMATCH -indices. The element of +indices. +The element of BASH_REMATCH with index n is the portion of the string matching the nth parenthesized subexpression. -Bash sets +Bash sets BASH_REMATCH in the global scope; declaring it as a local variable will lead to unexpected results. -

- - +

Expressions may be combined using the following operators, listed in decreasing order of precedence: -

- - +

@@ -1083,10 +1158,10 @@ operators do not evaluate expression2 if the value of the entire conditional expression.
-
for name [ [ in [ word ... ] ] ; ] do list ; done
-The list of words following in is expanded, generating a list +
for name [ [ in word ... ] ; ] do list ; done
+First, expand The list of words following in, generating a list of items. -The variable name is set to each element of this list +Then, the variable name is set to each element of this list in turn, and list is executed each time. If the in word is omitted, the for command executes list once for each positional parameter that is set (see @@ -1097,24 +1172,34 @@ below). The return status is the exit status of the last command that executes. If the expansion of the items following in results in an empty list, no commands are executed, and the return status is 0. -
for (( expr1 ; expr2 ; expr3 )) ; do list ; done
-First, the arithmetic expression expr1 is evaluated according +
for (( expr1 ; expr2 ; expr3 )) [;] do list ; done
+First, evaluate the arithmetic expression expr1 according to the rules described below under ARITHMETIC EVALUATION. -The arithmetic expression expr2 is then evaluated repeatedly +Then, repeatedly evaluate the arithmetic expression expr2 until it evaluates to zero. -Each time expr2 evaluates to a non-zero value, list is -executed and the arithmetic expression expr3 is evaluated. +Each time expr2 evaluates to a non-zero value, +execute list +and evaluate the arithmetic expression expr3. If any expression is omitted, it behaves as if it evaluates to 1. The return value is the exit status of the last command in list -that is executed, or false if any of the expressions is invalid. +that is executed, or non-zero if any of the expressions is invalid. +
+Use the break and continue builtins +(see +SHELL BUILTIN COMMANDS + + +below) +to control loop execution.
select name [ in word ] ; do list ; done
-The list of words following in is expanded, generating a list -of items, and the set of expanded words is printed on the standard -error, each preceded by a number. If the in -word is omitted, the positional parameters are printed (see +First, expand the list of words following in, +generating a list of items, and print the set of expanded words +the standard error, each preceded by a number. +If the in +word is omitted, print the positional parameters (see PARAMETERS @@ -1127,16 +1212,17 @@ then displays the prompt and reads a line from the standard input. If the line consists of a number corresponding to one of -the displayed words, then the value of +the displayed words, then select sets the value of name -is set to that word. -If the line is empty, the words and prompt are displayed again. -If EOF is read, the select command completes and returns 1. -Any other value read causes +to that word. +If the line is empty, select displays the words and prompt again. +If EOF is read, select completes and returns 1. +Any other value sets name -to be set to null. The line read is saved in the variable +to null. +The line read is saved in the variable REPLY. @@ -1155,13 +1241,17 @@ is the exit status of the last command executed in or zero if no commands were executed.
case word in [ [(] pattern [ | pattern ] -
+.. ) list ;; ] ... esac
A case command first expands word, and tries to match -it against each pattern in turn, using the matching rules +it against each pattern in turn, +proceeding from first to last, +using the matching rules described under Pattern Matching below. +A pattern list is a set of one or more patterns separated by , +and the ) operator terminates the pattern list. The word is expanded using tilde expansion, parameter and variable expansion, arithmetic expansion, command substitution, process substitution and quote removal. @@ -1173,30 +1263,35 @@ If the shell option is enabled, the match is performed without regard to the case of alphabetic characters. -When a match is found, the corresponding list is executed. -If the ;; operator is used, no subsequent matches are attempted after -the first pattern match. +A clause is a pattern list and an associated list. +
+When a match is found, case executes the corresponding list. +If the ;; operator terminates the case clause, the case +command completes after the first match. Using ;& in place of ;; causes execution to continue with -the list associated with the next set of patterns. +the list associated with the next pattern list. Using ;;& in place of ;; causes the shell to test the next pattern list in the statement, if any, and execute any associated list -on a successful match, +if the match succeeds, continuing the case statement execution as if the pattern list had not matched. -The exit status is zero if no -pattern matches. Otherwise, it is the exit status of the -last command executed in list. +The exit status is zero if no pattern matches. +
+Otherwise, it is the exit status of the +last command executed in the last list executed.
if list; then list; [ elif list; then list; ] ... [ else list; ] fi
The if list -is executed. If its exit status is zero, the -then list is executed. Otherwise, each elif -list is executed in turn, and if its exit status is zero, -the corresponding then list is executed and the -command completes. Otherwise, the else list is -executed, if present. The exit status is the exit status of the +is executed. +If its exit status is zero, the +then list is executed. +Otherwise, each elif list is executed in turn, +and if its exit status is zero, the corresponding then list +is executed and the command completes. +Otherwise, the else list is executed, if present. +The exit status is the exit status of the last command executed, or zero if no condition tested true.
while list-1; do list-2; done
@@ -1204,7 +1299,8 @@ last command executed, or zero if no condition tested true. The while command continuously executes the list list-2 as long as the last command in the list list-1 returns -an exit status of zero. The until command is identical +an exit status of zero. +The until command is identical to the while command, except that the test is negated: list-2 @@ -1252,7 +1348,7 @@ The recommended form to use for a coprocess is

-This form is recommended because simple commands result in the coprocess +This form is preferred because simple commands result in the coprocess always being named COPROC, and it is simpler to use and more complete than the other compound commands.

@@ -1295,7 +1391,7 @@ the file descriptors are not available in subshells. The process ID of the shell spawned to execute the coprocess is available as the value of the variable NAME_PID. The wait -builtin command may be used to wait for the coprocess to terminate. +builtin may be used to wait for the coprocess to terminate.

Since the coprocess is created as an asynchronous command, @@ -1325,17 +1421,23 @@ If the function reserved word is used, but the parentheses are not supplied, the braces are recommended. compound-command is executed whenever fname is specified as the name of a simple command. -When in posix mode, fname must be a valid shell name +When in posix mode, fname must be a valid shell name and may not be the name of one of the -POSIX special builtins. +POSIX +special builtins. In default mode, a function name can be any unquoted shell word that does not contain $. +

+

+ Any redirections (see REDIRECTION below) specified when a function is defined are performed when the function is executed. +

+ The exit status of a function definition is zero unless a syntax error occurs or a readonly function with the same name already exists. When executed, the exit status of a function is the exit status of the @@ -1344,7 +1446,6 @@ last command executed in the body. (See below.) -

 

COMMENTS

@@ -1361,19 +1462,25 @@ builtin is enabled (see below), a word beginning with # -causes that word and all remaining characters on that line to -be ignored. An interactive shell without the +introduces a comment. +A word begins at the beginning of a line, after unquoted whitespace, or +after an operator. +The comment causes that word and all remaining characters on that line to +be ignored. +An interactive shell without the interactive_comments -option enabled does not allow comments. The +option enabled does not allow comments. +The interactive_comments -option is on by default in interactive shells. +option is enabled by default in interactive shells.  

QUOTING

Quoting is used to remove the special meaning of certain -characters or words to the shell. Quoting can be used to +characters or words to the shell. +Quoting can be used to disable special treatment for special characters, to prevent reserved words from being recognized as such, and to prevent parameter expansion. @@ -1397,24 +1504,27 @@ below), the to prevent history expansion.

-There are three quoting mechanisms: the +There are four quoting mechanisms: the escape character, -single quotes, and double quotes. +single quotes, double quotes, +and dollar-single quotes.

A non-quoted backslash (\) is the escape character. It preserves the literal value of the next character that follows, -with the exception of <newline>. If a \<newline> pair -appears, and the backslash is not itself quoted, the \<newline> -is treated as a line continuation (that is, it is removed from the -input stream and effectively ignored). +removing any special meaning it has, +with the exception of <newline>. +If a \<newline> pair appears, and the backslash is not itself quoted, +the \<newline> is treated as a line continuation (that is, it is +removed from the input stream and effectively ignored).

Enclosing characters in single quotes preserves the literal value -of each character within the quotes. A single quote may not occur +of each character within the quotes. +A single quote may not occur between single quotes, even when preceded by a backslash.

@@ -1429,7 +1539,8 @@ of all characters within the quotes, with the exception of and, when history expansion is enabled, !. -When the shell is in posix mode, the ! has no special meaning +When the shell is in posix mode, +the ! has no special meaning within double quotes, even when history expansion is enabled. The characters $ @@ -1437,19 +1548,24 @@ The characters and ` -retain their special meaning within double quotes. The backslash -retains its special meaning only when followed by one of the following -characters: +retain their special meaning within double quotes. +The backslash retains its special meaning only when followed by one of +the following characters: $, `, -", +" +, \, or <newline>. +Backslashes preceding characters without a +special meaning are left unmodified. +

+ A double quote may be quoted within double quotes by preceding it with a backslash. If enabled, history expansion will be performed unless an @@ -1468,15 +1584,15 @@ The special parameters and @ -have special meaning when in double -quotes (see +have special meaning when in double quotes +(see PARAMETERS below).

-Character sequences of the form $aqstringaq are treated +Character sequences of the form $'string' are treated as a special variant of single quotes. The sequence expands to string, with backslash-escaped characters in string replaced as specified by the ANSI C standard. @@ -1523,11 +1639,11 @@ vertical tab

backslash -
\aq +
\'
single quote -
\dq +
\
double quote @@ -1538,27 +1654,27 @@ question mark
\nnn
-the eight-bit character whose value is the octal value nnn -(one to three octal digits) +The eight-bit character whose value is the octal value nnn +(one to three octal digits).
\xHH
-the eight-bit character whose value is the hexadecimal value HH -(one or two hex digits) +The eight-bit character whose value is the hexadecimal value HH +(one or two hex digits).
\uHHHH
-the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value -HHHH (one to four hex digits) +The Unicode (ISO/IEC 10646) character whose value is the hexadecimal value +HHHH (one to four hex digits).
\UHHHHHHHH
-the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value -HHHHHHHH (one to eight hex digits) +The Unicode (ISO/IEC 10646) character whose value is the hexadecimal value +HHHHHHHH (one to eight hex digits).
\cx
-a control-x character +A control-x character.
@@ -1566,17 +1682,20 @@ a control-x character The expanded result is single-quoted, as if the dollar sign had not been present. -

+  +

Translating Strings

-A double-quoted string preceded by a dollar sign ($dqstringdq) -will cause the string to be translated according to the current locale. +A double-quoted string preceded by a dollar sign ($" +string" +) +causes the string to be translated according to the current locale. The gettext infrastructure performs the lookup and translation, using the LC_MESSAGES, TEXTDOMAINDIR, and TEXTDOMAIN shell variables. If the current locale is C or POSIX, if there are no translations available, -or if the string is not translated, -the dollar sign is ignored. +or if the string is not translated, the dollar sign is ignored, +and the string is treated as double-quoted as described above. This is a form of double quoting, so the string remains double-quoted by default, whether or not it is translated and replaced. If the noexpand_translation option is enabled @@ -1586,10 +1705,10 @@ See the description of shopt below under -SHELLBUILTINCOMMANDS. +SHELL BUILTIN COMMANDS. -  + 

PARAMETERS

A @@ -1619,11 +1738,12 @@ below in SHELL BUILTIN COMMANDS). +The export and readonly builtins assign specific attributes.

-A parameter is set if it has been assigned a value. The null string is -a valid value. Once a variable is set, it may be unset only by using -the +A parameter is set if it has been assigned a value. +The null string is a valid value. +Once a variable is set, it may be unset only by using the unset builtin command (see @@ -1636,7 +1756,7 @@ below). A variable -may be assigned to by a statement of the form +is assigned to using a statement of the form

@@ -1648,7 +1768,8 @@ may be assigned to by a statement of the form If value -is not given, the variable is assigned the null string. All +is not given, the variable is assigned the null string. +All values undergo tilde expansion, parameter and variable expansion, @@ -1657,14 +1778,17 @@ removal (see EXPANSION -below). If the variable has its +below). +If the variable has its integer attribute set, then value -is evaluated as an arithmetic expression even if the $((...)) expansion is -not used (see +is evaluated as an arithmetic expression even if the +$((...)) + +expansion is not used (see Arithmetic Expansion below). @@ -1684,27 +1808,43 @@ and local builtin commands (declaration commands). -When in posix mode, these builtins may appear in a command after +When in posix mode, these builtins may appear in a command after one or more instances of the command builtin and retain these assignment statement properties.

In the context where an assignment statement is assigning a value -to a shell variable or array index, the += operator can be used to -append to or add to the variable's previous value. -This includes arguments to builtin commands such as declare that -accept assignment statements (declaration commands). -When += is applied to a variable for which the integer attribute has been -set, value is evaluated as an arithmetic expression and added to the -variable's current value, which is also evaluated. -When += is applied to an array variable using compound assignment (see +to a shell variable or array index, the + +operator appends to or adds to +the variable's previous value. +This includes arguments to declaration commands such as +declare + +that accept assignment statements. +When + +is applied to a variable for which the +integer + +attribute has been set, +the variable's current value and value are each evaluated as +arithmetic expressions, +and the sum of the results is assigned as the variable's value. +The current value is usually an integer constant, but may be an expression. +When + +is applied to an array variable using compound assignment +(see Arrays -below), the -variable's value is not unset (as it is when using =), and new values are -appended to the array beginning at one greater than the array's maximum index -(for indexed arrays) or added as additional key-value pairs in an -associative array. +below), +the variable's value is not unset +(as it is when using + +and new values are appended to the array +beginning at one greater than the array's maximum index (for indexed arrays) +or added as additional key-value pairs in an associative array. When applied to a string-valued variable, value is expanded and appended to the variable's value.

@@ -1724,41 +1864,56 @@ whose name is passed as an argument to the function. For instance, if a variable name is passed to a shell function as its first argument, running

+

-declare -n ref=$1 + +declare -n ref=$1

-inside the function creates a nameref variable ref whose value is -the variable name passed as the first argument. + +inside the function creates a local nameref variable ref whose value +is the variable name passed as the first argument. References and assignments to ref, and changes to its attributes, are treated as references, assignments, and attribute modifications to the variable whose name was passed as $1. If the control variable in a for loop has the nameref attribute, the list of words can be a list of shell variables, and a name reference -will be established for each word in the list, in turn, when the loop is +is established for each word in the list, in turn, when the loop is executed. Array variables cannot be given the nameref attribute. However, nameref variables can reference array variables and subscripted array variables. Namerefs can be unset using the -n option to the unset builtin. Otherwise, if unset is executed with the name of a nameref variable -as an argument, the variable referenced by the nameref variable will be unset. -  +as an argument, the variable referenced by the nameref variable is unset. +

+ +When the shell starts, it reads its environment and creates a shell +variable from each environment variable that has a valid name, +as described below +(see +ENVIRONMENT). + + + 

Positional Parameters

A positional parameter is a parameter denoted by one or more -digits, other than the single digit 0. Positional parameters are +digits, other than the single digit 0. +Positional parameters are assigned from the shell's arguments when it is invoked, and may be reassigned using the set -builtin command. Positional parameters may not be assigned to -with assignment statements. The positional parameters are +builtin command. +Positional parameters may not be assigned to +with assignment statements. +The positional parameters are temporarily replaced when a shell function is executed (see FUNCTIONS @@ -1772,35 +1927,48 @@ digit is expanded, it must be enclosed in braces (see below). -  +Without braces, a digit following $ can only refer to +one of the first nine positional parameters ($1-$9) or the +special parameter $0 (see the next section). + 

Special Parameters

-The shell treats several parameters specially. These parameters may -only be referenced; assignment to them is not allowed. - +The shell treats several parameters specially. +These parameters may only be referenced; assignment to them is +not allowed. +Special parameters are denoted by one of the following characters.
-
* - +
-Expands to the positional parameters, starting from one. +* + +($*) Expands to the positional parameters, starting from one. When the expansion is not within double quotes, each positional parameter expands to a separate word. -In contexts where it is performed, those words +In contexts where word expansions are performed, those words are subject to further word splitting and pathname expansion. -When the expansion occurs within double quotes, it expands to a single word -with the value of each parameter separated by the first character of the +When the expansion occurs within double quotes, it expands to a +single word with the value of each parameter separated by the first +character of the IFS -special variable. That is, "$*" is equivalent -to "$1c$2c...", where +variable. +That is, +$* + +is equivalent to +$1c$2c..., + +where c is the first character of the value of the IFS -variable. If +variable. +If IFS @@ -1813,38 +1981,47 @@ is null, the parameters are joined without intervening separators.
@
-Expands to the positional parameters, starting from one. +($@) Expands to the positional parameters, starting from one. In contexts where word splitting is performed, this expands each positional parameter to a separate word; if not within double quotes, these words are subject to word splitting. In contexts where word splitting is not performed, +such as the value portion of an assignment statement, this expands to a single word with each positional parameter separated by a space. -When the -expansion occurs within double quotes, each parameter expands to a -separate word. That is, "$@" is equivalent to -"$1" "$2" ... +When the expansion occurs within double quotes, +and word splitting is performed, +each parameter expands to a separate word. +That is, +$@ + +is equivalent to +$1 $2 ... + If the double-quoted expansion occurs within a word, the expansion of -the first parameter is joined with the beginning part of the original -word, and the expansion of the last parameter is joined with the last -part of the original word. -When there are no positional parameters, "$@" and +the first parameter is joined with the expansion of the +beginning part of the original word, +and the expansion of the last parameter is joined with the +expansion of the last part of the original word. +When there are no positional parameters, +$@ + +and $@ expand to nothing (i.e., they are removed).
#
-Expands to the number of positional parameters in decimal. +($#) Expands to the number of positional parameters in decimal.
?
-Expands to the exit status of the most recently executed foreground -pipeline. +($?) Expands to the exit status of the most recently executed command.
-
-Expands to the current option flags as specified upon invocation, +($-) Expands to the current option flags as specified upon invocation, by the set @@ -1856,13 +2033,13 @@ option).
$
-Expands to the process ID of the shell. In a subshell, it -expands to the process ID of the current shell, not the -subshell. +($$) Expands to the process ID of the shell. +In a subshell, it expands to the process ID of the parent shell, +not the subshell.
!
-Expands to the process ID of the job most recently placed into the +($!)Expands to the process ID of the job most recently placed into the background, whether executed as an asynchronous command or using the bg builtin (see JOB CONTROL @@ -1872,34 +2049,30 @@ below).
0
-Expands to the name of the shell or shell script. This is set at -shell initialization. If -bash - -is invoked with a file of commands, +($0) Expands to the name of the shell or shell script. +This is set at shell initialization. +If bash is invoked with a file of commands, $0 -is set to the name of that file. If -bash - -is started with the +is set to the name of that file. +If bash is started with the -c option, then $0 is set to the first argument after the string to be -executed, if one is present. Otherwise, it is set -to the filename used to invoke +executed, if one is present. +Otherwise, it is set to the filename used to invoke bash, as given by argument zero.
-  + 

Shell Variables

-The following variables are set by the shell: +The shell sets following variables:

@@ -1907,14 +2080,16 @@ The following variables are set by the shell:

_
-At shell startup, set to the pathname used to invoke the +($_, an underscore) +This has a number of meanings depending on context. +At shell startup, _ is set to the pathname used to invoke the shell or shell script being executed as passed in the environment or argument list. -Subsequently, expands to the last argument to the previous simple +Subsequently, it expands to the last argument to the previous simple command executed in the foreground, after expansion. -Also set to the full pathname used to invoke each command executed +It is also set to the full pathname used to invoke each command executed and placed in the environment exported to that command. -When checking mail, this parameter holds the name of the mail file +When checking mail, $_ expands to the name of the mail file currently being checked.
BASH @@ -1936,7 +2111,8 @@ builtin command (see SHELL BUILTIN COMMANDS -below). The options appearing in +below). +The options appearing in BASHOPTS @@ -1947,8 +2123,10 @@ by shopt. If this variable is in the environment when bash -starts up, each shell option in the list will be enabled before +starts up, the shell enables each option in the list before reading any startup files. +If this variable is exported, child shells will enable each option +in the list. This variable is read-only.
BASHPID @@ -1962,8 +2140,9 @@ Assignments to have no effect. If -BASHPID +BASHPID + is unset, it loses its special properties, even if it is subsequently reset.
BASH_ALIASES @@ -1972,11 +2151,12 @@ subsequently reset. An associative array variable whose members correspond to the internal list of aliases as maintained by the alias builtin. Elements added to this array appear in the alias list; however, -unsetting array elements currently does not cause aliases to be removed +unsetting array elements currently does not remove aliases from the alias list. If -BASH_ALIASES +BASH_ALIASES + is unset, it loses its special properties, even if it is subsequently reset.
BASH_ARGC @@ -1984,9 +2164,8 @@ subsequently reset.
An array variable whose values are the number of parameters in each frame of the current bash execution call stack. -The number of -parameters to the current subroutine (shell function or script executed -with . or source) is at the top of the stack. +The number of parameters to the current subroutine (shell function or +script executed with . or source) is at the top of the stack. When a subroutine is executed, the number of parameters passed is pushed onto BASH_ARGC. @@ -2005,14 +2184,19 @@ builtin below). Setting extdebug after the shell has started to execute a script, or referencing this variable when extdebug is not set, may result in inconsistent values. +Assignments to +BASH_ARGC + + +have no effect, and it may not be unset.
BASH_ARGV
An array variable containing all of the parameters in the current bash -execution call stack. The final parameter of the last subroutine call -is at the top of the stack; the first parameter of the initial call is -at the bottom. When a subroutine is executed, the parameters supplied -are pushed onto +execution call stack. +The final parameter of the last subroutine call is at the top of the stack; +the first parameter of the initial call is at the bottom. +When a subroutine is executed, the shell pushes the supplied parameters onto BASH_ARGV. @@ -2031,6 +2215,11 @@ builtin below). Setting extdebug after the shell has started to execute a script, or referencing this variable when extdebug is not set, may result in inconsistent values. +Assignments to +BASH_ARGV + + +have no effect, and it may not be unset.
BASH_ARGV0
@@ -2039,13 +2228,15 @@ script (identical to $0; see the description of special parameter 0 above). -Assignment to -BASH_ARGV0 +Assigning a value to +BASH_ARGV0 -causes the value assigned to also be assigned to $0. + +sets $0 to the same value. If -BASH_ARGV0 +BASH_ARGV0 + is unset, it loses its special properties, even if it is subsequently reset.
BASH_CMDS @@ -2053,23 +2244,25 @@ subsequently reset.
An associative array variable whose members correspond to the internal hash table of commands as maintained by the hash builtin. -Elements added to this array appear in the hash table; however, -unsetting array elements currently does not cause command names to be removed +Adding elements to this array makes them appear in the hash table; however, +unsetting array elements currently does not remove command names from the hash table. If -BASH_CMDS +BASH_CMDS + is unset, it loses its special properties, even if it is subsequently reset.
BASH_COMMAND
-The command currently being executed or about to be executed, unless the -shell is executing a command as the result of a trap, +Expands to the command currently being executed or about to be executed, +unless the shell is executing a command as the result of a trap, in which case it is the command executing at the time of the trap. If -BASH_COMMAND +BASH_COMMAND + is unset, it loses its special properties, even if it is subsequently reset.
BASH_EXECUTION_STRING @@ -2085,9 +2278,12 @@ where each corresponding member of was invoked. -${BASH_LINENO[$i]} is the line number in the source -file (${BASH_SOURCE[$i+1]}) where -${FUNCNAME[$i]} was called +${BASH_LINENO[$i]} +is the line number in the source file +(${BASH_SOURCE[$i+1]}) +where +${FUNCNAME[$i]} +was called (or ${BASH_LINENO[$i-1]} if referenced within another shell function). Use @@ -2095,14 +2291,32 @@ Use to obtain the current line number. +Assignments to +BASH_LINENO + + +have no effect, and it may not be unset.
BASH_LOADABLES_PATH
-A colon-separated list of directories in which the shell looks for -dynamically loadable builtins specified by the +A colon-separated list of directories in which the enable -command. +command +looks for +dynamically loadable builtins. +
BASH_MONOSECONDS + +
+Each time this variable is referenced, it expands to the value returned +by the system's monotonic clock, if one is available. +If there is no monotonic clock, this is equivalent to EPOCHSECONDS. +If +BASH_MONOSECONDS + + +is unset, it loses its special properties, even if it is +subsequently reset.
BASH_REMATCH
@@ -2125,6 +2339,11 @@ The shell function ${FUNCNAME[$i]} is defined in the file ${BASH_SOURCE[$i]} and called from ${BASH_SOURCE[$i+1]}. +Assignments to +BASH_SOURCE + + +have no effect, and it may not be unset.
BASH_SUBSHELL
@@ -2132,10 +2351,21 @@ Incremented by one within each subshell or subshell environment when the shell begins executing in that environment. The initial value is 0. If -BASH_SUBSHELL +BASH_SUBSHELL + is unset, it loses its special properties, even if it is subsequently reset. +
BASH_TRAPSIG + +
+Set to the signal number corresponding to the trap action being executed +during its execution. +See the description of trap under +SHELL BUILTIN COMMANDS + + +below for information about signal numbers and trap execution.
BASH_VERSINFO
@@ -2144,7 +2374,9 @@ this instance of bash. The values assigned to the array members are as follows: +

+

BASH_VERSINFO[0] @@ -2166,7 +2398,7 @@ The build version.
BASH_VERSINFO[4]
-The release status (e.g., beta1). +The release status (e.g., beta).
BASH_VERSINFO[5]
@@ -2176,12 +2408,14 @@ The value of
+
BASH_VERSION
Expands to a string describing the version of this instance of -bash. +bash +(e.g., 5.2.37(3)-release).
COMP_CWORD
@@ -2195,6 +2429,10 @@ below).
The key (or final key of a key sequence) used to invoke the current completion function. +This variable is available only in shell functions and external +commands invoked by the +programmable completion facilities (see Programmable Completion +below).
COMP_LINE
@@ -2217,7 +2455,7 @@ below).
COMP_TYPE
-Set to an integer value corresponding to the type of completion attempted +Set to an integer value corresponding to the type of attempted completion that caused a completion function to be called: TAB, for normal completion, ?, for listing completions after successive tabs, @@ -2278,7 +2516,7 @@ and popd builtins must be used to add and remove directories. -Assignment to this variable will not change the current directory. +Assigning to this variable does not change the current directory. If DIRSTACK @@ -2289,8 +2527,10 @@ subsequently reset.
Each time this parameter is referenced, it expands to the number of seconds -since the Unix Epoch (see time(3)) as a floating point value -with micro-second granularity. +since the Unix Epoch (see +time(3)) + +as a floating-point value with micro-second granularity. Assignments to EPOCHREALTIME @@ -2306,7 +2546,9 @@ subsequently reset.
Each time this parameter is referenced, it expands to the number of seconds -since the Unix Epoch (see time(3)). +since the Unix Epoch (see +time(3)). + Assignments to EPOCHSECONDS @@ -2326,12 +2568,12 @@ shell startup. This variable is readonly.
FUNCNAME
+ An array variable containing the names of all shell functions currently in the execution call stack. The element with index 0 is the name of any currently-executing shell function. The bottom-most element (the one with the highest index) is -"main". This variable exists only when a shell function is executing. Assignments to @@ -2345,17 +2587,37 @@ If is unset, it loses its special properties, even if it is subsequently reset. -

+

+This variable can be used with +BASH_LINENO + + +and +BASH_SOURCE. + + +Each element of +FUNCNAME + + +has corresponding elements in +BASH_LINENO + +and +BASH_SOURCE -This variable can be used with BASH_LINENO and BASH_SOURCE. -Each element of FUNCNAME has corresponding elements in -BASH_LINENO and BASH_SOURCE to describe the call stack. -For instance, ${FUNCNAME[$i]} was called from the file -${BASH_SOURCE[$i+1]} at line number + +to describe the call stack. +For instance, +${FUNCNAME[$i]} +was called from the file +${BASH_SOURCE[$i+1]} +at line number ${BASH_LINENO[$i]}. The caller builtin displays the current call stack using this information. +
GROUPS
@@ -2381,7 +2643,7 @@ Assignments to HISTCMD -are ignored. +have no effect. If HISTCMD @@ -2406,9 +2668,9 @@ The default is system-dependent.
Each time this parameter is referenced, the shell substitutes a decimal number representing the current sequential line number -(starting with 1) within a script or function. When not in a -script or function, the value substituted is not guaranteed to -be meaningful. +(starting with 1) within a script or function. +When not in a script or function, the value substituted is not +guaranteed to be meaningful. If LINENO @@ -2473,13 +2735,36 @@ The default is system-dependent. An array variable (see Arrays -below) containing a list of exit status values from the processes -in the most-recently-executed foreground pipeline (which may -contain only a single command). +below) containing a list of exit status values from the commands +in the most-recently-executed foreground pipeline, which may +consist of only a simple command +(see +SHELL GRAMMAR + + +above). +Bash sets +PIPESTATUS + + +after executing multi-element pipelines, +timed and negated pipelines, +simple commands, +subshells created with the ( operator, +the +[[ + +and +(( + +compound commands, and +after error conditions that result in the +shell aborting command execution.
PPID
-The process ID of the shell's parent. This variable is readonly. +The process ID of the shell's parent. +This variable is readonly.
PWD
@@ -2492,12 +2777,13 @@ command.
Each time this parameter is referenced, it expands to a random integer between 0 and 32767. -Assigning -a value to +Assigning a value to RANDOM initializes (seeds) the sequence of random numbers. +Seeding the random number generator with the same constant value +produces the same sequence of values. If RANDOM @@ -2507,8 +2793,10 @@ subsequently reset.
READLINE_ARGUMENT
-Any numeric argument given to a readline command that was defined using -bind -x +Any numeric argument given to a +readline + +command that was defined using (see SHELL BUILTIN COMMANDS @@ -2523,7 +2811,6 @@ The contents of the readline line buffer, for use with -bind -x (see SHELL BUILTIN COMMANDS @@ -2537,7 +2824,6 @@ The position of the mark (saved insertion point) in the readline line buffer, for use with -bind -x (see SHELL BUILTIN COMMANDS @@ -2553,7 +2839,6 @@ The position of the insertion point in the readline line buffer, for use with -bind -x (see SHELL BUILTIN COMMANDS @@ -2580,7 +2865,7 @@ the value returned upon subsequent references is the number of seconds since the assignment plus the value assigned. The number of seconds at shell invocation and the current time are always -determined by querying the system clock. +determined by querying the system clock at one-second resolution. If SECONDS @@ -2590,8 +2875,8 @@ subsequently reset.
SHELLOPTS
-A colon-separated list of enabled shell options. Each word in -the list is a valid argument for the +A colon-separated list of enabled shell options. +Each word in the list is a valid argument for the -o option to the @@ -2601,7 +2886,8 @@ builtin command (see SHELL BUILTIN COMMANDS -below). The options appearing in +below). +The options appearing in SHELLOPTS @@ -2612,8 +2898,10 @@ by set -o. If this variable is in the environment when bash -starts up, each shell option in the list will be enabled before +starts up, the shell enables each option in the list before reading any startup files. +If this variable is exported, child shells will enable each option +in the list. This variable is read-only.
SHLVL @@ -2625,9 +2913,17 @@ is started.
SRANDOM
-This variable expands to a 32-bit pseudo-random number each time it is -referenced. The random number generator is not linear on systems that -support /dev/urandom or arc4random, so each returned number +Each time it is referenced, this variable expands to a 32-bit pseudo-random +number. +The random number generator is not linear on systems that +support + +/dev/urandom + +or +arc4random(3), + +so each returned number has no relationship to the numbers preceding it. The random number generator cannot be seeded, so assignments to this variable have no effect. @@ -2646,7 +2942,7 @@ This variable is readonly.

-The following variables are used by the shell. In some cases, +The shell uses the following variables. In some cases, bash assigns a default value to a variable; these cases are noted @@ -2667,12 +2963,20 @@ below for a description of the various compatibility levels and their effects. The value may be a decimal number (e.g., 4.2) or an integer (e.g., 42) corresponding to the desired compatibility level. -If BASH_COMPAT is unset or set to the empty string, the compatibility +If +BASH_COMPAT + + +is unset or set to the empty string, the compatibility level is set to the default for the current version. -If BASH_COMPAT is set to a value that is not one of the valid +If +BASH_COMPAT + + +is set to a value that is not one of the valid compatibility levels, the shell prints an error message and sets the compatibility level to the default for the current version. -The valid values correspond to the compatibility levels +A subset of the valid values correspond to the compatibility levels described below under SHELL COMPATIBILITY MODE. @@ -2685,10 +2989,9 @@ The current version is also a valid value.

If this parameter is set when bash is executing a shell script, -its value is interpreted as a filename containing commands to -initialize the shell, as in -~/.bashrc. - +its expanded value is interpreted as a filename containing commands to +initialize the shell before it reads and executes commands from the +script. The value of BASH_ENV @@ -2702,11 +3005,11 @@ is not used to search for the resultant filename.
BASH_XTRACEFD
-If set to an integer corresponding to a valid file descriptor, bash -will write the trace output generated when -set -x +If set to an integer corresponding to a valid file descriptor, +bash writes the trace output generated when -is enabled to that file descriptor. +is enabled to that file descriptor, +instead of the standard error. The file descriptor is closed when BASH_XTRACEFD @@ -2732,21 +3035,21 @@ The search path for the cd command. -This is a colon-separated list of directories in which the shell looks -for destination directories specified by the +This is a colon-separated list of directories where the shell looks for +directories specified as arguments to the cd command. A sample value is -".:~:/usr".
CHILD_MAX
Set the number of exited child status values for the shell to remember. -Bash will not allow this value to be decreased below a POSIX-mandated -minimum, and there is a maximum value (currently 8192) that this may -not exceed. +Bash will not allow this value to be decreased below a +POSIX +-mandated minimum, +and there is a maximum value (currently 8192) that this may not exceed. The minimum value is system-dependent.
COLUMNS @@ -2772,7 +3075,6 @@ Each array element contains one possible completion.
If bash finds this variable in the environment when the shell starts with value -t, it assumes that the shell is running in an Emacs shell buffer and disables line editing. @@ -2783,20 +3085,32 @@ Expanded and executed similarly to BASH_ENV -(see INVOCATION above) -when an interactive shell is invoked in posix mode. +(see +INVOCATION + + +above) when an interactive shell is invoked in posix mode.
EXECIGNORE
A colon-separated list of shell patterns (see Pattern Matching) -defining the list of filenames to be ignored by command search using -PATH. +defining the set of filenames to be ignored by command search using +PATH. + + Files whose full pathnames match one of these patterns are not considered executable files for the purposes of completion and command execution -via PATH lookup. +via +PATH + + +lookup. This does not affect the behavior of the [, test, and [[ commands. -Full pathnames in the command hash table are not subject to EXECIGNORE. +Full pathnames in the command hash table are not subject to +EXECIGNORE. + + Use this variable to ignore shared library files that have the executable bit set, but are not executable files. The pattern matching honors the setting of the extglob shell @@ -2823,14 +3137,14 @@ A filename whose suffix matches one of the entries in is excluded from the list of matched filenames. A sample value is -".o:~".
FUNCNEST
If set to a numeric value greater than 0, defines a maximum function -nesting level. Function invocations that exceed this nesting level -will cause the current command to abort. +nesting level. +Function invocations that exceed this nesting level +cause the current command to abort.
GLOBIGNORE
@@ -2842,6 +3156,74 @@ of the patterns in it is removed from the list of matches. +The pattern matching honors the setting of the extglob shell +option. +
GLOBSORT + +
+ +Controls how the results of pathname expansion are sorted. +The value of this variable specifies the sort criteria and sort order for +the results of pathname expansion. +If this variable is unset or set to the null string, pathname expansion +uses the historical behavior of sorting by name, +in ascending lexicographic order as determined by the +LC_COLLATE + + +shell variable. +
+If set, a valid value begins with an optional +, which is ignored, +or -, which reverses the sort order from ascending to descending, +followed by a sort specifier. +The valid sort specifiers are +name, + +numeric, + +size, + +mtime, + +atime, + +ctime, + +and +blocks, + +which sort the files on name, +names in numeric rather than lexicographic order, +file size, modification time, access time, +inode change time, and number of blocks, respectively. +If any of the non-name keys compare as equal (e.g., if two files are +the same size), sorting uses the name as a secondary sort key. +
+For example, a value of -mtime sorts the results in descending +order by modification time (newest first). +
+The numeric specifier treats names consisting solely of digits as +numbers and sorts them using their numeric value +(so + +sorts before + +for example). +When using numeric, names containing non-digits sort after all +the all-digit names and are sorted by name using the traditional behavior. +
+A sort specifier of nosort disables sorting completely; +bash + +returns the results +in the order they are read from the file system, +ignoring any leading -. +
+If the sort specifier is missing, it defaults to name, +so a value of + is equivalent to the null string, +and a value of - sorts by name in descending order. +Any invalid value restores the historical sorting behavior. +
HISTCONTROL
@@ -2857,7 +3239,7 @@ character are not saved in the history list. A value of ignoredups -causes lines matching the previous history entry to not be saved. +causes lines matching the previous history entry not to be saved. A value of ignoreboth @@ -2873,16 +3255,19 @@ If is unset, or does not include a valid value, -all lines read by the shell parser are saved on the history list, +bash saves all lines read by the shell parser on the history list, subject to the value of HISTIGNORE. -The second and subsequent lines of a multi-line compound command are -not tested, and are added to the history regardless of the value of +If the first line of a multi-line compound command was saved, +the second and subsequent lines are not tested, +and are added to the history regardless of the value of HISTCONTROL. +If the first line was not saved, the second and subsequent lines of +the command are not saved either.
HISTFILE
@@ -2890,43 +3275,98 @@ The name of the file in which command history is saved (see HISTORY -below). The default value is ~/.bash_history. If unset, the -command history is not saved when a shell exits. +below). +Bash assigns a default value of + +~/.bash_history. + +If +HISTFILE + + +is unset or null, +the shell does not save the command history when it exits.
HISTFILESIZE
-The maximum number of lines contained in the history file. When this -variable is assigned a value, the history file is truncated, if -necessary, -to contain no more than that number of lines by removing the oldest entries. +The maximum number of lines contained in the history file. +When this variable is assigned a value, the history file is truncated, +if necessary, to contain no more than +the number of history entries +that total no more than that number of lines +by removing the oldest entries. +If the history list contains multi-line entries, +the history file may contain more lines than this maximum +to avoid leaving partial history entries. The history file is also truncated to this size after -writing it when a shell exits. +writing it when a shell exits or by the +history + +builtin. If the value is 0, the history file is truncated to zero size. Non-numeric values and numeric values less than zero inhibit truncation. -The shell sets the default value to the value of HISTSIZE +The shell sets the default value to the value of +HISTSIZE + + after reading any startup files.
HISTIGNORE
A colon-separated list of patterns used to decide which command lines -should be saved on the history list. Each pattern is anchored at the -beginning of the line and must match the complete line (no implicit -`*' is appended). Each pattern is tested against the line +should be saved on the history list. +If a command line matches one of the patterns in the value of +HISTIGNORE, + + +it is not saved on the history list. +Each pattern is anchored at the +beginning of the line and must match the complete line +(bash does not implicitly append a + +Each pattern is tested against the line after the checks specified by HISTCONTROL are applied. -In addition to the normal shell pattern matching characters, `&' -matches the previous history line. `&' may be escaped using a -backslash; the backslash is removed before attempting a match. -The second and subsequent lines of a multi-line compound command are -not tested, and are added to the history regardless of the value of +In addition to the normal shell pattern matching characters, + +matches the previous history line. +A backslash escapes the + +the backslash is removed before attempting a match. +If the first line of a multi-line compound command was saved, +the second and subsequent lines are not tested, +and are added to the history regardless of the value of HISTIGNORE. -The pattern matching honors the setting of the extglob shell -option. +If the first line was not saved, the second and subsequent lines of +the command are not saved either. +The pattern matching honors the setting of the +extglob + +shell option. +
+HISTIGNORE + + +subsumes some of the function of +HISTCONTROL. + + +A pattern of + +is identical to + +and a pattern of + +is identical to + +Combining these two patterns, separating them with a colon, +provides the functionality of +
HISTSIZE
@@ -2943,9 +3383,12 @@ The shell sets the default value to 500 after reading any startup files.
If this variable is set and not null, its value is used as a format string -for strftime(3) to print the time stamp associated with each history +for +strftime(3) + +to print the time stamp associated with each history entry displayed by the history builtin. -If this variable is set, time stamps are written to the history file so +If this variable is set, the shell writes time stamps to the history file so they may be preserved across shell sessions. This uses the history comment character to distinguish timestamps from other history lines. @@ -2985,7 +3428,7 @@ When HOSTFILE -is unset, the hostname list is cleared. +is unset, bash clears the hostname list.
IFS
@@ -2997,8 +3440,13 @@ for word splitting after expansion and to split lines into words with the read -builtin command. The default value is -``<space><tab><newline>''. +builtin command. +Word splitting is described below under +EXPANSION. + + +The default value is +
IGNOREEOF
@@ -3007,8 +3455,8 @@ action of an interactive shell on receipt of an EOF -character as the sole input. If set, the value is the number of -consecutive +character as the sole input. +If set, the value is the number of consecutive EOF @@ -3016,8 +3464,11 @@ characters which must be typed as the first characters on an input line before bash -exits. If the variable exists but does not have a numeric value, or -has no value, the default value is 10. If it does not exist, +exits. +If the variable is set but does not have a numeric value, +or the value is null, +the default value is 10. +If it is unset, EOF @@ -3042,7 +3493,10 @@ below).
If this variable appears in the environment when the shell starts, bash assumes that it is running inside an Emacs shell buffer -and may disable line editing, depending on the value of TERM. +and may disable line editing, depending on the value of +TERM. + +
LANG
@@ -3099,7 +3553,7 @@ option is enabled or in an interactive shell upon receipt of a
MAIL
-If this parameter is set to a file or directory name and the +If the value is set to a file or directory name and the MAILPATH @@ -3115,8 +3569,10 @@ Specifies how often (in seconds) bash -checks for mail. The default is 60 seconds. When it is time to check -for mail, the shell does so before displaying the primary prompt. +checks for mail. +The default is 60 seconds. +When it is time to check for mail, +the shell does so before displaying the primary prompt. If this variable is unset, or set to a value that is not a number greater than or equal to zero, the shell disables mail checking.
MAILPATH @@ -3124,14 +3580,21 @@ greater than or equal to zero, the shell disables mail checking.
A colon-separated list of filenames to be checked for mail. The message to be printed when mail arrives in a particular file -may be specified by separating the filename from the message with a `?'. +may be specified by separating the filename from the message with a + When used in the text of the message, $_ expands to the name of the current mailfile. -Example: +For example:

-MAILPATH=aq/var/mail/bfox?"You have mail":~/shell-mail?"$_ has mail!"aq + +MAILPATH='/var/mail/bfox?" +You have mail" +:~/shell-mail?" +$_ has mail!" +' +

Bash @@ -3164,8 +3627,8 @@ script is executed.

PATH
-The search path for commands. It -is a colon-separated list of directories in which +The search path for commands. +It is a colon-separated list of directories in which the shell looks for commands (see COMMAND EXECUTION @@ -3183,23 +3646,32 @@ and is set by the administrator who installs bash. A common value is +
+
+ +/usr/local/bin:/usr/local/sbin: +
+ -/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin. +/usr/bin:/usr/sbin:/bin:/sbin +
+ +
POSIXLY_CORRECT
If this variable is in the environment when bash starts, the shell -enters posix mode before reading the startup files, as if the +enters posix mode before reading the startup files, as if the --posix -invocation option had been supplied. If it is set while the shell is -running, bash enables posix mode, as if the command -set -o posix +invocation option had been supplied. +If it is set while the shell is +running, bash enables posix mode, as if the command had been executed. -When the shell enters posix mode, it sets this variable if it was +When the shell enters posix mode, it sets this variable if it was not already set.
PROMPT_COMMAND @@ -3207,7 +3679,7 @@ not already set. If this variable is set, and is an array, the value of each set element is executed as a command prior to issuing each primary prompt. -If this is set but not an array variable, +If this is set but not an array variable, its value is used as a command to execute instead.
PROMPT_DIRTRIM @@ -3218,7 +3690,8 @@ trailing directory components to retain when expanding the \w and PROMPTING -below). Characters removed are replaced with an ellipsis. +below). +Characters removed are replaced with an ellipsis.
PS0
@@ -3235,8 +3708,9 @@ The value of this parameter is expanded (see PROMPTING -below) and used as the primary prompt string. The default value is -``\s-\v\$ ''. +below) and used as the primary prompt string. +The default value is +
PS2
@@ -3244,8 +3718,9 @@ The value of this parameter is expanded as with PS1 -and used as the secondary prompt string. The default is -``> ''. +and used as the secondary prompt string. +The default is +
PS3
@@ -3267,13 +3742,15 @@ The value of this parameter is expanded as with and the value is printed before each command bash -displays during an execution trace. The first character of -the expanded value of +displays during an execution trace. +The first character of the expanded value of PS4 is replicated multiple times, as necessary, to indicate multiple -levels of indirection. The default is ``+ ''. +levels of indirection. +The default is +
SHELL
@@ -3293,8 +3770,10 @@ reserved word should be displayed. The % character introduces an escape sequence that is expanded to a time value or other information. The escape sequences and their meanings are as follows; the -braces denote optional portions. +brackets denote optional portions. +

+

@@ -3321,13 +3800,15 @@ The CPU percentage, computed as (%U + %S) / %R.
+
The optional p is a digit specifying the precision, the number of fractional digits after a decimal point. A value of 0 causes no decimal point or fraction to be output. -At most three places after the decimal point may be specified; -values of p greater than 3 are changed to 3. -If p is not specified, the value 3 is used. +time prints at most six digits after the decimal point; +values of p greater than 6 are changed to 6. +If p is not specified, +time prints three digits after the decimal point.
The optional l specifies a longer format, including minutes, of the form MMmSS.FFs. @@ -3335,19 +3816,16 @@ The value of p determines whether or not the fraction is included.
If this variable is not set, bash acts as if it had the -value $aq\nreal\t%3lR\nuser\t%3lU\nsys\t%3lSaq. -If the value is null, no timing information is displayed. +value $'\nreal\t%3lR\nuser\t%3lU\nsys\t%3lS'. +If the value is null, bash does not display any timing information. A trailing newline is added when the format string is displayed.
TMOUT
If set to a value greater than zero, -TMOUT - - -is treated as the -default timeout for the read builtin. +the read builtin uses the value as its +default timeout. The select command terminates if input does not arrive after TMOUT @@ -3359,8 +3837,8 @@ number of seconds to wait for a line of input after issuing the primary prompt. Bash -terminates after waiting for that number of seconds if a complete -line of input does not arrive. +terminates after waiting for that number of seconds if a +complete line of input does not arrive.
TMPDIR
@@ -3370,24 +3848,28 @@ If set, bash uses its value as the name of a directory in which
This variable controls how the shell interacts with the user and -job control. If this variable is set, single word simple -commands without redirections are treated as candidates for resumption -of an existing stopped job. There is no ambiguity allowed; if there is -more than one job beginning with the string typed, the job most recently -accessed is selected. The +job control. +If this variable is set, simple commands +consisting of only a single word, +without redirections, are treated as candidates for resumption +of an existing stopped job. +There is no ambiguity allowed; if there is more than one job +beginning with or containing +the word, this selects the most recently accessed job. +The name of a stopped job, in this context, is the command line used to -start it. +start it, as displayed by jobs. If set to the value exact, -the string supplied must match the name of a stopped job exactly; +the word must match the name of a stopped job exactly; if set to substring, -the string supplied needs to match a substring of the name of a -stopped job. The +the word needs to match a substring of the name of a stopped job. +The substring value provides functionality analogous to the @@ -3397,33 +3879,44 @@ job identifier (see JOB CONTROL -below). If set to any other value, the supplied string must -be a prefix of a stopped job's name; this provides functionality -analogous to the %string job identifier. +below). +If set to any other value (e.g., +prefix), + +the word must be a prefix of a stopped job's name; +this provides functionality analogous to the %string job identifier.
histchars
-The two or three characters which control history expansion -and tokenization (see +The two or three characters which control history expansion, +quick substitution, and tokenization +(see HISTORY EXPANSION -below). The first character is the history expansion character, -the character which signals the start of a history -expansion, normally `!'. -The second character is the quick substitution -character, which is used as shorthand for re-running the previous -command entered, substituting one string for another in the command. -The default is `^'. -The optional third character is the character -which indicates that the remainder of the line is a comment when found -as the first character of a word, normally `#'. The history -comment character causes history substitution to be skipped for the -remaining words on the line. It does not necessarily cause the shell -parser to treat the rest of the line as a comment. +below). +The first character is the history expansion character, +the character which begins a history expansion, normally + +The second character is the quick substitution character, normally + +When it appears as the first character on the line, +history substitution repeats the previous command, +replacing one string with another. +The optional third character is the +history comment +character, normally + +which indicates +that the remainder of the line is a comment +when it appears as the first character of a word. +The history comment character disables history substitution +for the remaining words on the line. +It does not necessarily cause the shell parser to treat the rest of the +line as a comment.
-  + 

Arrays

Bash @@ -3432,62 +3925,109 @@ provides one-dimensional indexed and associative array variables. Any variable may be used as an indexed array; the declare -builtin will explicitly declare an array. +builtin explicitly declares an array. There is no maximum limit on the size of an array, nor any requirement that members be indexed or assigned contiguously. -Indexed arrays are referenced using integers (including arithmetic -expressions) and are zero-based; associative arrays are referenced -using arbitrary strings. +Indexed arrays are referenced using arithmetic expressions +that must expand to an integer +(see +ARITHMETIC EVALUATION + + +below) +and are zero-based; +associative arrays are referenced using arbitrary strings. Unless otherwise noted, indexed array indices must be non-negative integers.

-An indexed array is created automatically if any variable is assigned to -using the syntax name[subscript]=value. The +The shell performs +parameter and variable expansion, arithmetic expansion, +command substitution, and quote removal +on indexed array subscripts. +Since this +can potentially result in empty strings, +subscript indexing treats +those as expressions that evaluate to 0. +

+ +The shell performs +tilde expansion, +parameter and variable expansion, arithmetic expansion, +command substitution, and quote removal +on associative array subscripts. +Empty strings cannot be used as associative array keys. +

+ +Bash automatically creates an indexed array +if any variable is assigned to using the syntax +

+name[subscript]=value +. +
+ +The subscript -is treated as an arithmetic expression that must evaluate to a number. +is treated as an arithmetic expression that must evaluate to a number +greater than or equal to zero. To explicitly declare an indexed array, use -declare -a name +
+declare -a name + +
(see SHELL BUILTIN COMMANDS below). -declare -a name[subscript] +
+declare -a name[subscript] +
is also accepted; the subscript is ignored.

Associative arrays are created using -declare -A name. +

+declare -A name +
+ +.

-Attributes may be -specified for an array variable using the +Attributes may be specified for an array variable using the declare and readonly -builtins. Each attribute applies to all members of an array. +builtins. +Each attribute applies to all members of an array.

-Arrays are assigned to using compound assignments of the form +Arrays are assigned using compound assignments of the form name=(value1 ... valuen), where each value may be of the form [subscript]=string. Indexed array assignments do not require anything but string. -Each value in the list is expanded using all the shell expansions +Each value in the list is expanded using the shell expansions described below under -EXPANSION. +EXPANSION, +but values that are valid variable assignments +including the brackets and subscript do not undergo +brace expansion and word splitting, as with individual +variable assignments. +

+ When assigning to indexed arrays, if the optional brackets and subscript are supplied, that index is assigned to; otherwise the index of the element assigned is the last index assigned -to by the statement plus one. Indexing starts at zero. +to by the statement plus one. +Indexing starts at zero.

When assigning to an associative array, the words in a compound assignment @@ -3496,7 +4036,8 @@ or a list of words that is interpreted as a sequence of alternating keys and values: name=( key1 value1 key2 value2 ...). These are treated identically to -name=( [key1]=value1 [key2]=value2 ...). +name=( [key1]=value1 [key2]=value2 +...). The first word in the list determines how the remaining words are interpreted; all assignments in a list must be of the same type. When using key/value pairs, the keys may not be missing or empty; @@ -3506,8 +4047,11 @@ a final missing value is treated like the empty string. This syntax is also accepted by the declare -builtin. Individual array elements may be assigned to using the +builtin. +Individual array elements may be assigned to using the name[subscript]=value syntax introduced above. +

+ When assigning to an indexed array, if name @@ -3517,7 +4061,9 @@ interpreted as relative to one greater than the maximum index of array, and an index of -1 references the last element.

-The += operator will append to an array variable when assigning +The + +operator appends to an array variable when assigning using the compound assignment syntax; see PARAMETERS @@ -3525,32 +4071,42 @@ using the compound assignment syntax; see above.

-Any element of an array may be referenced using -${name[subscript]}. The braces are required to avoid -conflicts with pathname expansion. If -subscript is @ or *, the word expands to -all members of name. These subscripts differ only when the -word appears within double quotes. If the word is double-quoted, -${name[*]} expands to a single +An array element is referenced using +${name[subscript]}. +The braces are required to avoid conflicts with pathname expansion. +If subscript is @ or *, the word expands to +all members of name, +unless noted in the description of a builtin or word expansion. +These subscripts differ only when the +word appears within double quotes. +If the word is double-quoted, ${name[*]} expands to a single word with the value of each array member separated by the first character of the IFS special variable, and ${name[@]} expands each element of -name to a separate word. When there are no array members, -${name[@]} expands to nothing. +name to a separate word. +When there are no array members, ${name[@]} expands to nothing. If the double-quoted expansion occurs within a word, the expansion of -the first parameter is joined with the beginning part of the original -word, and the expansion of the last parameter is joined with the last -part of the original word. +the first parameter is joined with the beginning part of the +expansion of the original word, +and the expansion of the last parameter is joined with the last +part of the +expansion of the original word. This is analogous to the expansion of the special parameters * and @ (see Special Parameters -above). ${#name[subscript]} expands to the length of -${name[subscript]}. If subscript is * or -@, the expansion is the number of elements in the array. +above). +

+ +${#name[subscript]} expands to the length of +${name[subscript]}. +If subscript is * or @, +the expansion is the number of elements in the array. +

+ If the subscript @@ -3563,14 +4119,15 @@ array, and an index of -1 references the last element. Referencing an array variable without a subscript is equivalent to referencing the array with a subscript of 0. -Any reference to a variable using a valid subscript is legal, and +Any reference to a variable using a valid subscript is valid; bash -will create an array if necessary. +creates an array if necessary.

An array variable is considered set if a subscript has been assigned a -value. The null string is a valid value. +value. +The null string is a valid value.

It is possible to obtain the keys (indices) of an array as well as the values. @@ -3583,16 +4140,18 @@ special parameters @ and * within double quotes. The unset -builtin is used to destroy arrays. unset name[subscript] -destroys the array element at index subscript, +builtin is used to destroy arrays. +unset name[subscript] +unsets the array element at index subscript, for both indexed and associative arrays. Negative subscripts to indexed arrays are interpreted as described above. Unsetting the last element of an array variable does not unset the variable. unset name, where name is an array, removes the entire array. -unset name[subscript], where -subscript is * or @, behaves differently depending on -whether name is an indexed or associative array. +unset name[subscript] +behaves differently depending on +whether name is an indexed or associative array +when subscript is * or @. If name is an associative array, this unsets the element with subscript * or @. If name is an indexed array, unset removes all of the elements but @@ -3601,8 +4160,11 @@ does not remove the array itself. When using a variable name with a subscript as an argument to a command, such as with unset, without using the word expansion syntax -described above, the argument is subject to pathname expansion. -If pathname expansion is not desired, the argument should be quoted. +described above, +(e.g., unset a[4]), +the argument is subject to pathname expansion. +Quote the argument if pathname expansion is not desired +(e.g., unset 'a[4]').

The @@ -3631,7 +4193,8 @@ builtin accepts a -a option to assign a list of words read from the standard input -to an array. The +to an array. +The set and @@ -3639,11 +4202,15 @@ and builtins display array values in a way that allows them to be reused as assignments. -  +Other builtins accept array name arguments as well +(e.g., mapfile); see the descriptions +of individual builtins below for details. +The shell provides a number of builtin array variables. + 

EXPANSION

Expansion is performed on the command line after it has been split into -words. There are seven kinds of expansion performed: +words. The shell performs these expansions: brace expansion, tilde expansion, @@ -3656,8 +4223,10 @@ words. There are seven kinds of expansion performed: word splitting, +pathname expansion, + and -pathname expansion. +quote removal.

@@ -3666,7 +4235,8 @@ brace expansion; tilde expansion, parameter and variable expansion, arithmetic expansion, and command substitution (done in a left-to-right fashion); word splitting; -and pathname expansion. +pathname expansion; +and quote removal.

On systems that can support it, there is an additional expansion @@ -3676,71 +4246,81 @@ same time as tilde, parameter, variable, and arithmetic expansion and command substitution.

-After these expansions are performed, quote characters present in the -original word are removed unless they have been quoted themselves -(quote removal). +Quote removal is always performed last. +It removes quote characters present in the original word, +not ones resulting from one of the other expansions, +unless they have been quoted themselves.

Only brace expansion, word splitting, and pathname expansion can increase the number of words of the expansion; other expansions expand a single word to a single word. The only exceptions to this are the expansions of -"$@" and "${name[@]}", +$@ + +and +${name[@]} , + + + and, in most cases, $* and ${name[*]} as explained above (see PARAMETERS). -  + 

Brace Expansion

Brace expansion -is a mechanism by which arbitrary strings -may be generated. This mechanism is similar to +is a mechanism to generate arbitrary strings +sharing a common prefix and suffix, either of which can be empty. +This mechanism is similar to pathname expansion, but the filenames generated -need not exist. Patterns to be brace expanded take -the form of an optional +need not exist. +Patterns to be brace expanded are formed from an optional preamble, followed by either a series of comma-separated strings or -a sequence expression between a pair of braces, followed by -an optional +a sequence expression between a pair of braces, +followed by an optional postscript. -The preamble is prefixed to each string contained -within the braces, and the postscript is then appended -to each resulting string, expanding left to right. +The preamble is prefixed to each string contained within the braces, +and the postscript is then appended to each resulting string, +expanding left to right.

-Brace expansions may be nested. The results of each expanded -string are not sorted; left to right order is preserved. -For example, a{d,c,b}e expands into `ade ace abe'. +Brace expansions may be nested. +The results of each expanded string are not sorted; +brace expansion preserves left to right order. +For example, a{d,c,b}e expands into +

A sequence expression takes the form -{x..y[..incr]}, +x..y[..incr], where x and y are either integers or single letters, and incr, an optional increment, is an integer. When integers are supplied, the expression expands to each number between x and y, inclusive. -Supplied integers may be prefixed with 0 to force each term to have the -same width. -When either x or y begins with a zero, the shell -attempts to force all generated terms to contain the same number of digits, +If either x or y begins with a zero, +each generated term will contain the same number of digits, zero-padding where necessary. When letters are supplied, the expression expands to each character lexicographically between x and y, inclusive, -using the default C locale. +using the C locale. Note that both x and y must be of the same type (integer or letter). When the increment is supplied, it is used as the difference between -each term. The default increment is 1 or -1 as appropriate. +each term. +The default increment is 1 or -1 as appropriate.

Brace expansion is performed before any other expansions, and any characters special to other expansions are preserved -in the result. It is strictly textual. +in the result. +It is strictly textual. Bash does not apply any syntactic interpretation to the context of the @@ -3751,25 +4331,37 @@ A correctly-formed brace expansion must contain unquoted opening and closing braces, and at least one unquoted comma or a valid sequence expression. Any incorrectly formed brace expansion is left unchanged. -A { or , may be quoted with a backslash to prevent its +

+ +A + +or +Q , +may be quoted with a backslash to prevent its being considered part of a brace expression. -To avoid conflicts with parameter expansion, the string ${ -is not considered eligible for brace expansion, and inhibits brace -expansion until the closing }. +To avoid conflicts with parameter expansion, the string + +is not considered eligible for brace expansion, +and inhibits brace expansion until the closing +

This construct is typically used as shorthand when the common prefix of the strings to be generated is longer than in the above example: -

+

+ mkdir /usr/local/src/bash/{old,new,dist,bugs} +
or
+ chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}} +

@@ -3784,22 +4376,19 @@ does not treat opening or closing braces specially when they appear as part of a word, and preserves them in the output. Bash -removes braces from words as a consequence of brace -expansion. For example, a word entered to +removes braces from words as a consequence of brace expansion. +For example, a word entered to sh -as file{1,2} -appears identically in the output. The same word is -output as -file1 file2 +as -after expansion by -bash. +appears identically in the output. +Bash -If strict compatibility with -sh +outputs that word as -is desired, start +after brace expansion. +Start bash with the @@ -3815,11 +4404,13 @@ command (see SHELL BUILTIN COMMANDS -below). -  +below) for strict sh compatibility. + 

Tilde Expansion

-If a word begins with an unquoted tilde character (`~'), all of +If a word begins with an unquoted tilde character ( + +all of the characters preceding the first unquoted slash (or all characters, if there is no unquoted slash) are considered a tilde-prefix. If none of the characters in the tilde-prefix are quoted, the @@ -3834,45 +4425,64 @@ If HOME -is unset, the home directory of the user executing the shell is -substituted instead. +is unset, the tilde expands to +the home directory of the user executing the shell instead. Otherwise, the tilde-prefix is replaced with the home directory associated with the specified login name.

-If the tilde-prefix is a `~+', the value of the shell variable +If the tilde-prefix is a + +the value of the shell variable PWD replaces the tilde-prefix. -If the tilde-prefix is a `~-', the value of the shell variable +If the tilde-prefix is a + +the shell substitutes the value of the shell variable OLDPWD, -if it is set, is substituted. +if it is set. If the characters following the tilde in the tilde-prefix consist of a number N, optionally prefixed -by a `+' or a `-', the tilde-prefix is replaced with the corresponding +by a + +or a + +the tilde-prefix is replaced with the corresponding element from the directory stack, as it would be displayed by the dirs -builtin invoked with the tilde-prefix as an argument. +builtin invoked with the characters following the tilde in the +tilde-prefix as an argument. If the characters following the tilde in the tilde-prefix consist of a -number without a leading `+' or `-', `+' is assumed. +number without a leading + +or + +tilde expansion assumes + +

+ +The results of tilde expansion are treated as if they were quoted, so +the replacement is not subject to word splitting and pathname expansion.

-If the login name is invalid, or the tilde expansion fails, the word -is unchanged. +If the login name is invalid, or the tilde expansion fails, the +tilde-prefix is unchanged.

-Each variable assignment is checked for unquoted tilde-prefixes immediately +Bash checks each variable assignment +for unquoted tilde-prefixes immediately following a : or the first -=. +=, -In these cases, tilde expansion is also performed. +and performs tilde expansion in these cases. Consequently, one may use filenames with tildes in assignments to PATH, @@ -3887,35 +4497,44 @@ and and the shell assigns the expanded value.

-Bash also performs tilde expansion on words satisfying the conditions of -variable assignments (as described above under +Bash also performs tilde expansion on words satisfying the conditions +of variable assignments (as described above under PARAMETERS) when they appear as arguments to simple commands. -Bash does not do this, except for the declaration commands listed -above, when in posix mode. -  +Bash does not do this, +except for the declaration commands listed above, +when in posix mode. + 

Parameter Expansion

-The `$' character introduces parameter expansion, -command substitution, or arithmetic expansion. The parameter name +The + +character introduces parameter expansion, +command substitution, or arithmetic expansion. +The parameter name or symbol to be expanded may be enclosed in braces, which are optional but serve to protect the variable to be expanded from characters immediately following it which could be interpreted as part of the name.

-When braces are used, the matching ending brace is the first `}' +When braces are used, the matching ending brace is the first + not escaped by a backslash or within a quoted string, and not within an embedded arithmetic expansion, command substitution, or parameter expansion.

+The basic form of parameter expansion is +

-

-
${parameter}
-The value of parameter is substituted. The braces are required +${parameter} +

+ +which substitutes the value of parameter. +The braces are required when parameter @@ -3928,22 +4547,22 @@ interpreted as part of its name. The parameter is a shell parameter as described above PARAMETERS) or an array reference (Arrays). -

If the first character of parameter is an exclamation point (!), and parameter is not a nameref, it introduces a level of indirection. Bash uses the value formed by expanding the rest of -parameter as the new parameter; this is then -expanded and that value is used in the rest of the expansion, rather +parameter as the new parameter; +this new parameter is then expanded and that value is used +in the rest of the expansion, rather than the expansion of the original parameter. This is known as indirect expansion. The value is subject to tilde expansion, parameter expansion, command substitution, and arithmetic expansion. If parameter is a nameref, this expands to the name of the parameter referenced by parameter instead of performing the -complete indirect expansion. +complete indirect expansion, for compatibility. The exceptions to this are the expansions of ${!prefix*} and ${!name[@]} described below. The exclamation point must immediately follow the left brace in order to @@ -3956,11 +4575,10 @@ parameter expansion, command substitution, and arithmetic expansion. When not performing substring expansion, using the forms documented below (e.g., :-), -bash tests for a parameter that is unset or null. Omitting the colon -results in a test only for a parameter that is unset. +bash tests for a parameter that is unset or null. +Omitting the colon tests only for a parameter that is unset.

-

${parameter:-word}
Use Default Values. If @@ -3969,7 +4587,8 @@ results in a test only for a parameter that is unset. is unset or null, the expansion of word -is substituted. Otherwise, the value of +is substituted. +Otherwise, the value of parameter is substituted. @@ -3982,25 +4601,28 @@ is unset or null, the expansion of word is assigned to +parameter, + +and the expansion is the final value of parameter. -The value of -parameter - -is then substituted. Positional parameters and special parameters may -not be assigned to in this way. +Positional parameters and special parameters may +not be assigned in this way.
${parameter:?word}
Display Error if Null or Unset. If parameter -is null or unset, the expansion of word (or a message to that effect +is null or unset, the shell writes +the expansion of word (or a message to that effect if word -is not present) is written to the standard error and the shell, if it -is not interactive, exits. Otherwise, the value of parameter is -substituted. +is not present) to the standard error and, if it +is not interactive, exits with a non-zero status. +An interactive shell does not exit, but does not execute the command +associated with the expansion. +Otherwise, the value of parameter is substituted.
${parameter:+word}
Use Alternate Value. If @@ -4010,25 +4632,34 @@ is null or unset, nothing is substituted, otherwise the expansion of word is substituted. -
${parameter:offset}
- -
${parameter:offset:length}
- +The value of parameter is not used. +
+
+${parameter:offset} +
+
+${parameter:offset:length} Substring Expansion. Expands to up to length characters of the value of parameter starting at the character specified by offset. If parameter is @ or *, an indexed array subscripted by @ or *, or an associative array name, the results differ as described below. -If length is omitted, expands to the substring of the value of +If :length is omitted (the first form above), this +expands to the substring of the value of parameter starting at the character specified by offset and extending to the end of the value. +If offset is omitted, +it is treated as 0. +If length is omitted, +but the colon after offset is present, +it is treated as 0. length and offset are arithmetic expressions (see ARITHMETIC EVALUATION below). -

+

If offset evaluates to a number less than zero, the value is used as an offset in characters from the end of the value of parameter. @@ -4039,15 +4670,15 @@ a number of characters, and the expansion is the characters between offset and that result. Note that a negative offset must be separated from the colon by at least one space to avoid being confused with the :- expansion. -

+

If parameter is @ or *, the result is length positional parameters beginning at offset. A negative offset is taken relative to one greater than the greatest positional parameter, so an offset of -1 evaluates to the last positional -parameter. +parameter (or 0 if there are no positional parameters). It is an expansion error if length evaluates to a number less than zero. -

+

If parameter is an indexed array name subscripted by @ or *, the result is the length members of the array beginning with ${parameter[offset]}. @@ -4055,16 +4686,17 @@ A negative offset is taken relative to one greater than the maximum index of the specified array. It is an expansion error if length evaluates to a number less than zero. -

+

Substring expansion applied to an associative array produces undefined results. -

+

Substring indexing is zero-based unless the positional parameters are used, in which case the indexing starts at 1 by default. If offset is 0, and the positional parameters are used, $0 is prefixed to the list. -
${!prefix*}
- +
+
+${!prefix*}
${!prefix@}
Names matching prefix. @@ -4076,8 +4708,9 @@ separated by the first character of the special variable. When @ is used and the expansion appears within double quotes, each variable name expands to a separate word. -
${!name[@]}
- +
+
+${!name[@]}
${!name[*]}
List of array keys. @@ -4089,7 +4722,7 @@ When @ is used and the expansion appears within double quotes, each key expands to a separate word.
${#parameter}
Parameter length. -The length in characters of the value of parameter is substituted. +Substitutes the length in characters of the expanded value of parameter. If parameter @@ -4117,8 +4750,9 @@ is an indexed array name subscripted by a negative number, that number is interpreted as relative to one greater than the maximum index of parameter, so negative indices count back from the end of the array, and an index of -1 references the last element. -
${parameter#word}
- +
+
+${parameter#word}
${parameter##word}
Remove matching prefix pattern. @@ -4140,8 +4774,11 @@ the value of then the result of the expansion is the expanded value of parameter -with the shortest matching pattern (the ``#'' case) or the -longest matching pattern (the ``##'' case) deleted. +with the shortest matching pattern (the + +case) or the longest matching pattern (the + +case) deleted. If parameter @@ -4164,8 +4801,9 @@ or the pattern removal operation is applied to each member of the array in turn, and the expansion is the resultant list. -
${parameter%word}
- +
+
+${parameter%word}
${parameter%%word}
Remove matching suffix pattern. @@ -4183,8 +4821,11 @@ If the pattern matches a trailing portion of the expanded value of then the result of the expansion is the expanded value of parameter -with the shortest matching pattern (the ``%'' case) or the -longest matching pattern (the ``%%'' case) deleted. +with the shortest matching pattern (the + +case) or the longest matching pattern (the + +case) deleted. If parameter @@ -4207,45 +4848,46 @@ or the pattern removal operation is applied to each member of the array in turn, and the expansion is the resultant list. -
${parameter/pattern/string}
- +
+
+${parameter/pattern/string}
${parameter//pattern/string}
${parameter/#pattern/string}
${parameter/%pattern/string}
Pattern substitution. -The pattern is expanded to produce a pattern just as in -pathname expansion. -Parameter is expanded and the longest match of pattern -against its value is replaced with string. -string undergoes tilde expansion, parameter and variable expansion, -arithmetic expansion, command and process substitution, and quote removal. -The match is performed using the rules described under +The pattern is expanded to produce a pattern +and matched against the expanded value of parameter +as described under Pattern Matching below. +The longest match of pattern +in the expanded value is replaced with string. +string undergoes tilde expansion, parameter and variable expansion, +arithmetic expansion, command and process substitution, and quote removal. +
In the first form above, only the first match is replaced. -If there are two slashes separating parameter and pattern +If there are two slashes separating parameter and pattern (the second form above), all matches of pattern are replaced with string. If pattern is preceded by # (the third form above), it must match at the beginning of the expanded value of parameter. If pattern is preceded by % (the fourth form above), it must match at the end of the expanded value of parameter. +
If the expansion of string is null, -matches of pattern are deleted. -If string is null, matches of pattern are deleted and the / following pattern may be omitted. -

+

If the patsub_replacement shell option is enabled using shopt, any unquoted instances of & in string are replaced with the matching portion of pattern. -

+

Quoting any part of string inhibits replacement in the expansion of the quoted portion, including replacement strings stored in shell variables. -Backslash will escape & in string; the backslash is removed +Backslash escapes & in string; the backslash is removed in order to permit a literal & in the replacement string. Backslash can also be used to escape a backslash; \\ results in a literal backslash in the replacement. @@ -4257,12 +4899,19 @@ expanding string; shell programmers should quote any occurrences of & they want to be taken literally in the replacement and ensure any instances of & they want to be replaced are unquoted. -

+

+Like the pattern removal operators, double quotes surrounding the +replacement string quote the expanded characters, while double quotes +enclosing the entire parameter substitution do not, since +the expansion is performed in a +context that doesn't take any enclosing double quotes into account. +
If the nocasematch shell option is enabled, the match is performed without regard to the case of alphabetic characters. +
If parameter @@ -4285,27 +4934,43 @@ or the substitution operation is applied to each member of the array in turn, and the expansion is the resultant list. -
${parameter^pattern}
- +
+
+${parameter^pattern}
${parameter^^pattern}
${parameter,pattern}
${parameter,,pattern}
Case modification. This expansion modifies the case of alphabetic characters in parameter. -The pattern is expanded to produce a pattern just as in -pathname expansion. -Each character in the expanded value of parameter is tested against -pattern, and, if it matches the pattern, its case is converted. +First, the pattern is expanded to produce a pattern +as described below under +Pattern Matching. + + +Bash + +then examines characters in the expanded value of parameter +against pattern as described below. +If a character matches the pattern, its case is converted. The pattern should not attempt to match more than one character. -The ^ operator converts lowercase letters matching pattern -to uppercase; the , operator converts matching uppercase letters -to lowercase. -The ^^ and ,, expansions convert each matched character in the -expanded value; the ^ and , expansions match and convert only -the first character in the expanded value. +
+Using + +converts lowercase letters matching pattern to uppercase; + +converts matching uppercase letters to lowercase. +The +^ and , variants +examine the first character in the expanded value +and convert its case if it matches pattern; +the +^^ and ,, variants +examine all characters in the expanded value +and convert each one that matches pattern. If pattern is omitted, it is treated like a ?, which matches every character. +
If parameter @@ -4328,14 +4993,17 @@ or the case modification operation is applied to each member of the array in turn, and the expansion is the resultant list. -
${parameter@operator}
+
+
+${parameter@operator} Parameter transformation. The expansion is either a transformation of the value of parameter or information about parameter itself, depending on the value of operator. Each operator is a single letter: +

-

+
U @@ -4361,7 +5029,8 @@ format that can be reused as input.
The expansion is a string that is the value of parameter with backslash -escape sequences expanded as with the $aq...aq quoting mechanism. +escape sequences expanded as with the $'...' +quoting mechanism.
P
@@ -4372,7 +5041,7 @@ The expansion is a string that is the result of expanding the value of
The expansion is a string in the form of an assignment statement or declare command that, if -evaluated, will recreate parameter with its attributes and value. +evaluated, recreates parameter with its attributes and value.
K
@@ -4380,6 +5049,7 @@ Produces a possibly-quoted version of the value of parameter, except that it prints the values of indexed and associative arrays as a sequence of quoted key-value pairs (see Arrays above). +The keys and values are quoted in a format that can be reused as input.
a
@@ -4417,25 +5087,26 @@ or the operation is applied to each member of the array in turn, and the expansion is the resultant list.

+ The result of the expansion is subject to word splitting and pathname expansion as described below.

-
-  + 

Command Substitution

Command substitution allows the output of a command to replace -the command name. There are two forms: +the command itself. +There are two standard forms:

$(command)

-or +or (deprecated)
-`command` +`command`.

@@ -4451,7 +5122,7 @@ The command substitution $(cat file) can be replaced by the equivalent but faster $(< file).

-When the old-style backquote form of substitution is used, +With the old-style backquote form of substitution, backslash retains its literal meaning except when followed by $, @@ -4466,17 +5137,66 @@ When using the $(command) form, all characters between the parentheses make up the command; none are treated specially.

+There is an alternate form of command substitution: +

+

+ +${c command;} +

+ +

+ +which executes command in the current execution environment +and captures its output, again with trailing newlines removed. +

+ +The character c following the open brace must be a space, tab, +newline, or |, and the close brace must be in a position +where a reserved word may appear (i.e., preceded by a command terminator +such as semicolon). +Bash allows the close brace to be joined to the remaining characters in +the word without being followed by a shell metacharacter as a reserved +word would usually require. +

+ +Any side effects of command take effect immediately +in the current execution environment and persist in the current +environment after the command completes (e.g., the exit builtin +exits the shell). +

+ +This type of command substitution superficially resembles executing an +unnamed shell function: local variables are created as when a shell +function is executing, and the return builtin forces +command to complete; +however, the rest of the execution environment, +including the positional parameters, is shared with the caller. +

+ +If the first character following the open brace +is a |, the construct expands to the +value of the REPLY shell variable after command executes, +without removing any trailing newlines, +and the standard output of command remains the same as in the +calling shell. +Bash creates REPLY as an initially-unset local variable when +command executes, and restores REPLY to the value it had +before the command substitution after command completes, +as with any local variable. +

+ Command substitutions may be nested. To nest when using the backquoted form, escape the inner backquotes with backslashes.

-If the substitution appears within double quotes, word splitting and -pathname expansion are not performed on the results. -  +If the substitution appears within double quotes, bash does not perform +word splitting and pathname expansion on the results. + 

Arithmetic Expansion

-Arithmetic expansion allows the evaluation of an arithmetic expression -and the substitution of the result. The format for arithmetic expansion is: +Arithmetic expansion evaluates an arithmetic expression +and substitutes the result. +The format for arithmetic expansion is:

@@ -4490,11 +5210,16 @@ The undergoes the same expansions as if it were within double quotes, -but double quote characters in expression are not treated specially -and are removed. +but unescaped double quote characters +in expression are not treated +specially and are removed. All tokens in the expression undergo parameter and variable expansion, command substitution, and quote removal. The result is treated as the arithmetic expression to be evaluated. +Since the way Bash handles double quotes +can potentially result in empty strings, +arithmetic expansion treats +those as expressions that evaluate to 0. Arithmetic expansions may be nested.

@@ -4508,8 +5233,10 @@ If is invalid, bash -prints a message indicating failure and no substitution occurs. -  +prints a message to standard error indicating failure, +does not perform the substitution, +and does not execute the command associated with the expansion. + 

Process Substitution

Process substitution allows a process's input or output to be @@ -4523,19 +5250,28 @@ appears as a filename. This filename is passed as an argument to the current command as the result of the expansion. -If the >(list) form is used, writing to -the file will provide input for list. If the -<(list) form is used, the file passed as an -argument should be read to obtain the output of list. +

+ +If the +>(list) form is used, writing to +the file provides input for list. +If the +<(list) form is used, reading the file +obtains the output of list. +No space may appear between the < or > +and the left parenthesis, otherwise the construct would be interpreted +as a redirection. +

+ Process substitution is supported on systems that support named -pipes (FIFOs) or the /dev/fd method of naming open files. +pipes (FIFOs) or the /dev/fd method of naming open files.

When available, process substitution is performed simultaneously with parameter and variable expansion, command substitution, and arithmetic expansion. -  + 

Word Splitting

The shell scans the results of @@ -4546,104 +5282,95 @@ arithmetic expansion that did not occur within double quotes for word splitting. +Words that were not expanded are not split.

The shell treats each character of IFS -as a delimiter, and splits the results of the other -expansions into words using these characters as field terminators. -If -IFS - - -is unset, or its -value is exactly -<space><tab><newline>, - -the default, then -sequences of -<space>, - -<tab>, - -and -<newline> +as a delimiter, +and splits the results of the other expansions into words +using these characters as field terminators. +

-at the beginning and end of the results of the previous -expansions are ignored, and -any sequence of -IFS +An IFS whitespace character is whitespace as defined above +(see Definitions) that appears in the value of +IFS. -characters not at the beginning or end serves to delimit words. +Space, tab, and newline are always considered IFS whitespace, even +if they don't appear in the locale's space category. +

+ If IFS -has a value other than the default, then sequences of -the whitespace characters -space, - -tab, - -and -newline +is unset, field splitting acts as if its value were +<space><tab><newline>, -are ignored at the beginning and end of the -word, as long as the whitespace character is in the -value of +and treats these characters as IFS whitespace. +If the value of IFS -(an -IFS +is null, no word splitting occurs, +but implicit null arguments (see below) are still removed. +

- -whitespace character). -Any character in -IFS +Word splitting begins by removing sequences of IFS whitespace characters +from the beginning and end of the results of the previous expansions, +then splits the remaining words. +

- -that is not +If the value of IFS -whitespace, along with any adjacent -IFS +consists solely of IFS whitespace, +any sequence of IFS whitespace characters delimits a field, +so a field consists of characters that are not unquoted IFS +whitespace, and null fields result only from quoting. +

- -whitespace characters, delimits a field. -A sequence of +If IFS -whitespace characters is also treated as a delimiter. -If the value of +contains a non-whitespace character, then any character in +the value of IFS -is null, no word splitting occurs. +that is not IFS whitespace, +along with any adjacent IFS whitespace characters, delimits a field. +This means that adjacent non-IFS-whitespace delimiters produce a +null field. +A sequence of IFS whitespace characters also delimits a field.

-Explicit null arguments ("" or aqaq) are retained +Explicit null arguments (" +" + or +'') are retained and passed to commands as empty strings. Unquoted implicit null arguments, resulting from the expansion of parameters that have no values, are removed. -If a parameter with no value is expanded within double quotes, a -null argument results and is retained -and passed to a command as an empty string. +Expanding a parameter with no value within double quotes +produces a null field, +which is retained and passed to a command as an empty string. +

+ When a quoted null argument appears as part of a word whose expansion is -non-null, the null argument is removed. +non-null, word splitting removes the null argument portion, +leaving the non-null expansion. That is, the word --daqaq becomes -d after word splitting and -null argument removal. -

-Note that if no expansion occurs, no splitting -is performed. -  +becomes + +after word splitting and null argument removal. + 

Pathname Expansion

After word splitting, @@ -4665,13 +5392,15 @@ If one of these characters appears, and is not quoted, then the word is regarded as a pattern, -and replaced with an alphabetically sorted list of -filenames matching the pattern +and replaced with a sorted list of filenames matching the pattern (see Pattern Matching -below). +below) +subject to the value of the GLOBSORT shell variable. +

+ If no matching filenames are found, and the shell option nullglob @@ -4685,16 +5414,17 @@ the word is removed. If the failglob -shell option is set, and no matches are found, an error message -is printed and the command is not executed. +shell option is set, and no matches are found, +bash prints an error message and does not execute the command. If the shell option nocaseglob is enabled, the match is performed without regard to the case of alphabetic characters. +

+ When a pattern is used for pathname expansion, the character -``.'' at the start of a name or immediately following a slash must be matched explicitly, unless the shell option @@ -4702,12 +5432,17 @@ must be matched explicitly, unless the shell option is set. In order to match the filenames -``.'' + +. and -``..'', -the pattern must begin with ``.'' (for example, ``.?''), +.., + +the pattern must begin with + +(for example, + even if dotglob @@ -4716,18 +5451,20 @@ If the globskipdots shell option is enabled, the filenames -``.'' + +. and -``..'' -are never matched, even if the pattern begins with a -``.''. +.. + +never match, even if the pattern begins with a When not matching pathnames, the -``.'' character is not treated specially. +

+ When matching a pathname, the slash character must always be matched explicitly by a slash in the pattern, but in other matching contexts it can be matched by a special pattern character as described @@ -4735,6 +5472,8 @@ below under Pattern Matching. +

+ See the description of shopt @@ -4779,16 +5518,19 @@ If the nocaseglob option is set, the matching against the patterns in is performed without regard to case. The filenames -``.'' + +. and -``..'' + +.. are always ignored when GLOBIGNORE -is set and not null. However, setting +is set and not null. +However, setting GLOBIGNORE @@ -4796,19 +5538,17 @@ to a non-null value has the effect of enabling the dotglob shell option, so all other filenames beginning with a -``.'' -will match. +match. To get the old behavior of ignoring filenames beginning with a -``.'', make -``.*'' one of the patterns in -GLOBIGNORE. +GLOBIGNORE +. The dotglob @@ -4817,17 +5557,32 @@ option is disabled when is unset. -The pattern matching honors the setting of the extglob shell +The +GLOBIGNORE + +pattern matching honors the setting of the extglob shell option.

+The value of the +GLOBSORT + + +shell variable controls how the results of pathname expansion are sorted, +as described above under +Shell Variables. + +

+ Pattern Matching +

Any character that appears in a pattern, other than the special pattern -characters described below, matches itself. The NUL character may not -occur in a pattern. A backslash escapes the following character; the -escaping backslash is discarded when matching. +characters described below, matches itself. +The NUL character may not occur in a pattern. +A backslash escapes the following character; the escaping backslash is +discarded when matching. The special pattern characters must be quoted if they are to be matched literally.

@@ -4844,23 +5599,26 @@ The special pattern characters have the following meanings: Matches any string, including the null string. When the globstar shell option is enabled, and * is used in a pathname expansion context, two adjacent *s used as a single -pattern will match all files and zero or more directories and +pattern match all files and zero or more directories and subdirectories. -If followed by a /, two adjacent *s will match only directories +If followed by a /, two adjacent *s match only directories and subdirectories.

?
Matches any single character. -
[...] +
[...]
-Matches any one of the enclosed characters. A pair of characters -separated by a hyphen denotes a + +Matches any one of the characters enclosed between the brackets. +This is known as a bracket expression +and matches a single character. +A pair of characters separated by a hyphen denotes a range expression; any character that falls between those two characters, inclusive, -using the current locale's collating sequence and character set, -is matched. If the first character following the +using the current locale's collating sequence and character set, matches. +If the first character following the [ is a @@ -4869,11 +5627,19 @@ is a or a ^ -then any character not enclosed is matched. +then any character not within the range matches. +To match a +-, + +include it as the first or last character in the set. +To match a +], + +include it as the first character in the set. +
The sorting order of characters in range expressions, and the characters included in the range, -are determined by -the current locale and the values of the +are determined by the current locale and the values of the LC_COLLATE @@ -4888,84 +5654,48 @@ To obtain the traditional interpretation of range expressions, where is equivalent to [abcd], -set value of the +set the value of the +LC_COLLATE + +or LC_ALL -shell variable to +shell variables to C, or enable the globasciiranges shell option. -A -- - -may be matched by including it as the first or last character -in the set. -A -] - -may be matched by including it as the first character -in the set. -
- -

- - -Within -[ - -and -], - +

+Within a bracket expression, character classes can be specified using the syntax [:class:], where class is one of the -following classes defined in the POSIX standard: -
-

- +following classes defined in the +POSIX +standard: +

alnum alpha ascii blank cntrl digit graph lower print punct space upper word xdigit -
+
+
A character class matches any character belonging to that class. The word character class matches letters, digits, and the character _. -
- -

- - -Within -[ - -and -], - +

+Within a bracket expression, an equivalence class can be specified using the syntax [=c=], which matches all characters with the same collation weight (as defined by the current locale) as the character c. -
- -

- - -Within -[ - -and -], - +

+Within a bracket expression, the syntax [.symbol.] matches the collating symbol symbol. -
- -
- +

@@ -4977,24 +5707,25 @@ Composite patterns may be formed using one or more of the following sub-patterns:

+

?(pattern-list)
-Matches zero or one occurrence of the given patterns +Matches zero or one occurrence of the given patterns.
*(pattern-list)
-Matches zero or more occurrences of the given patterns +Matches zero or more occurrences of the given patterns.
+(pattern-list)
-Matches one or more occurrences of the given patterns +Matches one or more occurrences of the given patterns.
@(pattern-list)
-Matches one of the given patterns +Matches one of the given patterns.
!(pattern-list)
-Matches anything except one of the given patterns +Matches anything except one of the given patterns.

-Theextglob option changes the behavior of the parser, since the +The extglob option changes the behavior of the parser, since the parentheses are normally treated as operators with syntactic meaning. To ensure that extended matching patterns are parsed correctly, make sure that extglob is enabled before parsing constructs containing the @@ -5004,12 +5735,37 @@ patterns, including shell functions and command substitutions. When matching filenames, the dotglob shell option determines the set of filenames that are tested: when dotglob is enabled, the set of filenames includes all files -beginning with ``.'', but ``.'' and ``..'' must be matched by a -pattern or sub-pattern that begins with a dot; +beginning with + +but + +. + +and + +.. + +must be matched by a pattern or sub-pattern that begins with a dot; when it is disabled, the set does not -include any filenames beginning with ``.'' unless the pattern -or sub-pattern begins with a ``.''. -As above, ``.'' only has a special meaning when matching filenames. +include any filenames beginning with + +unless the pattern or sub-pattern begins with a + +If the +globskipdots + +shell option is enabled, the filenames + +. + +and + +.. + +never appear in the set. +As above, + +only has a special meaning when matching filenames.

Complicated extended pattern matching against long strings is slow, @@ -5017,22 +5773,22 @@ especially when the patterns contain alternations and the strings contain multiple matches. Using separate matches against shorter strings, or using arrays of strings instead of a single long string, may be faster. -  + 

Quote Removal

After the preceding expansions, all unquoted occurrences of the characters \, -aq, +', -and " that did not result from one of the above +and " + that did not result from one of the above expansions are removed. -  + 

REDIRECTION

-Before a command is executed, its input and output -may be +Before a command is executed, its input and output may be redirected using a special notation interpreted by the shell. @@ -5040,8 +5796,8 @@ using a special notation interpreted by the shell. duplicated, opened, closed, made to refer to different files, and can change the files the command reads from and writes to. -Redirection may also be used to modify file handles in the -current shell execution environment. +When used with the exec builtin, +redirections modify file handles in the current shell execution environment. The following redirection operators may precede or appear anywhere within a simple command @@ -5056,41 +5812,54 @@ left to right. Each redirection that may be preceded by a file descriptor number may instead be preceded by a word of the form {varname}. In this case, for each redirection operator except ->&- and <&-, the shell will allocate a file descriptor greater -than or equal to 10 and assign it to varname. -If >&- or <&- is preceded -by {varname}, the value of varname defines the file -descriptor to close. +>&- + +and +<&-, + +the shell allocates a file descriptor greater +than or equal to 10 and assigns it to varname. +If {varname} precedes +>&- + +or +<&-, + +the value of varname defines the file descriptor to close. If {varname} is supplied, the redirection persists beyond -the scope of the command, allowing the shell programmer to manage -the file descriptor's lifetime manually. +the scope of the command, which allows the shell programmer to +manage the file descriptor's lifetime manually without using +the exec builtin. The varredir_close shell option manages this behavior.

In the following descriptions, if the file descriptor number is omitted, and the first character of the redirection operator is -<, -the redirection refers to the standard input (file descriptor -0). If the first character of the redirection operator is ->, +the redirection refers to the standard input (file descriptor 0). +If the first character of the redirection operator is -the redirection refers to the standard output (file descriptor -1). +the redirection refers to the standard output (file descriptor 1).

-The word following the redirection operator in the following +The word following the redirection operator in the following descriptions, unless otherwise noted, is subjected to -brace expansion, tilde expansion, parameter and variable expansion, -command substitution, arithmetic expansion, quote removal, -pathname expansion, and word splitting. +brace expansion, +tilde expansion, +parameter and variable expansion, +command substitution, +arithmetic expansion, +quote removal, +pathname expansion, +and word splitting. If it expands to more than one word, bash reports an error.

-Note that the order of redirections is significant. For example, +The order of redirections is significant. +For example, the command

@@ -5115,7 +5884,7 @@ ls 2>&1 > dirlist directs only the standard output to file dirlist, -because the standard error was duplicated from the standard output +because the standard error was directed to the standard output before the standard output was redirected to dirlist. @@ -5124,7 +5893,7 @@ before the standard output was redirected to Bash handles several filenames specially when they are used in redirections, as described in the following table. If the operating system on which bash is running provides these -special files, bash will use them; otherwise it will emulate them +special files, bash uses them; otherwise it emulates them internally with the behavior described below.

@@ -5134,7 +5903,7 @@ internally with the behavior described below.

/dev/fd/fd
-If fd is a valid integer, file descriptor fd is duplicated. +If fd is a valid integer, duplicate file descriptor fd.
/dev/stdin
@@ -5170,14 +5939,14 @@ A failure to open or create a file causes the redirection to fail. Redirections using file descriptors greater than 9 should be used with care, as they may conflict with file descriptors the shell uses internally. -  + 

Redirecting Input

-Redirection of input causes the file whose name results from +Redirecting input opens the file whose name results from the expansion of word -to be opened for reading on file descriptor +for reading on file descriptor n, or the standard input (file descriptor 0) if @@ -5193,20 +5962,21 @@ The general format for redirecting input is: [n]<word
-  + 

Redirecting Output

-Redirection of output causes the file whose name results from +Redirecting output opens the file whose name results from the expansion of word -to be opened for writing on file descriptor +for writing on file descriptor n, or the standard output (file descriptor 1) if n -is not specified. If the file does not exist it is created; +is not specified. +If the file does not exist it is created; if it does exist it is truncated to zero size.

@@ -5228,7 +5998,7 @@ and the option to the set -builtin has been enabled, the redirection will fail if the file +builtin command has been enabled, the redirection fails if the file whose name results from the expansion of word exists and is a regular file. If the redirection operator is @@ -5243,23 +6013,24 @@ and the option to the set -builtin command is not enabled, the redirection is attempted even -if the file named by word exists. -  +builtin is not enabled, +bash attempts the redirection +even if the file named by word exists. + 

Appending Redirected Output

-Redirection of output in this fashion -causes the file whose name results from -the expansion of +Redirecting output in this fashion opens +the file whose name results from the expansion of word -to be opened for appending on file descriptor +for appending on file descriptor n, or the standard output (file descriptor 1) if n -is not specified. If the file does not exist it is created. +is not specified. +If the file does not exist it is created.

The general format for appending output is: @@ -5269,14 +6040,13 @@ The general format for appending output is: [n]>>word

-  + 

Redirecting Standard Output and Standard Error

-This construct allows both the +This construct redirects both the standard output (file descriptor 1) and the standard error output (file descriptor 2) -to be redirected to the file whose name is the -expansion of +to the file whose name is the expansion of word.

@@ -5307,17 +6077,17 @@ This is semantically equivalent to

When using the second form, word may not expand to a number or --. If it does, other redirection operators apply +-. +If it does, other redirection operators apply (see Duplicating File Descriptors below) for compatibility reasons. -  + 

Appending Standard Output and Standard Error

-This construct allows both the +This construct appends both the standard output (file descriptor 1) and the standard error output (file descriptor 2) -to be appended to the file whose name is the -expansion of +to the file whose name is the expansion of word.

@@ -5341,16 +6111,15 @@ This is semantically equivalent to

(see Duplicating File Descriptors below). -  + 

Here Documents

This type of redirection instructs the shell to read input from the -current source until a line containing only +current source until it reads a line containing only delimiter -(with no trailing blanks) -is seen. All of -the lines read up to that point are then used as the standard +(with no trailing blanks). +All of the lines read up to that point then become the standard input (or file descriptor n if n is specified) for a command.

@@ -5368,10 +6137,13 @@ The format of here-documents is:

-No parameter and variable expansion, command substitution, -arithmetic expansion, or pathname expansion is performed on +The shell does not perform +parameter and variable expansion, command substitution, +arithmetic expansion, or pathname expansion on word. +

+ If any part of word @@ -5382,13 +6154,17 @@ is the result of quote removal on word, and the lines in the here-document are not expanded. -If word is unquoted, +If word is unquoted, the +delimiter + +is word itself, +and the here-document text is treated similarly to a double-quoted string: all lines of the here-document are subjected to parameter expansion, command substitution, and arithmetic expansion, the character sequence \<newline> -is ignored, and +is treated literally, and \ must be used to quote the characters @@ -5397,21 +6173,31 @@ must be used to quote the characters $, and -`. +`; +however, double quote characters have no special meaning.

If the redirection operator is <<-, -then all leading tab characters are stripped from input lines and the -line containing +then the shell strips all leading tab characters from input lines +and the line containing delimiter. This allows here-documents within shell scripts to be indented in a natural fashion. -  +

+ +If the delimiter is not quoted, the +\<newline> + +sequence is treated as a line continuation: the two lines are joined +and the backslash-newline is removed. +This happens while reading the here-document, before the check for +the ending delimiter, so joined lines can form the end delimiter. + 

Here Strings

A variant of here documents, the format is: @@ -5433,7 +6219,7 @@ Pathname expansion and word splitting are not performed. The result is supplied as a single string, with a newline appended, to the command on its standard input (or file descriptor n if n is specified). -  + 

Duplicating File Descriptors

The redirection operator @@ -5449,14 +6235,14 @@ is used to duplicate input file descriptors. If word -expands to one or more digits, the file descriptor denoted by +expands to one or more digits, file descriptor n is made to be a copy of that file descriptor. -If the digits in +It is a redirection error if the digits in word -do not specify a file descriptor open for input, a redirection error occurs. +do not specify a file descriptor open for input. If word @@ -5466,10 +6252,11 @@ evaluates to file descriptor n -is closed. If +is closed. +If n -is not specified, the standard input (file descriptor 0) is used. +is not specified, this uses the standard input (file descriptor 0).

The operator @@ -5481,14 +6268,15 @@ The operator

-is used similarly to duplicate output file descriptors. If +is used similarly to duplicate output file descriptors. +If n -is not specified, the standard output (file descriptor 1) is used. -If the digits in +is not specified, this uses the standard output (file descriptor 1). +It is a redirection error if the digits in word -do not specify a file descriptor open for output, a redirection error occurs. +do not specify a file descriptor open for output. If word @@ -5499,10 +6287,11 @@ file descriptor n is closed. -As a special case, if n is omitted, and word does not -expand to one or more digits or -, the standard output and standard -error are redirected as described previously. -  +As a special case, if n is omitted, +and word does not expand to one or more digits or -, +this redirects the standard output and standard error as described +previously. + 

Moving File Descriptors

The redirection operator @@ -5534,7 +6323,7 @@ moves the file descriptor digit to file descriptor n, or the standard output (file descriptor 1) if n is not specified. -  + 

Opening File Descriptors for Reading and Writing

The redirection operator @@ -5546,35 +6335,41 @@ The redirection operator

-causes the file whose name is the expansion of +opens the file whose name is the expansion of word -to be opened for both reading and writing on file descriptor +for both reading and writing on file descriptor n, or on file descriptor 0 if n -is not specified. If the file does not exist, it is created. -  +is not specified. +If the file does not exist, it is created. + 

ALIASES

-Aliases allow a string to be substituted for a word when it is used -as the first word of a simple command. -The shell maintains a list of aliases that may be set and unset with the -alias - -and -unalias - -builtin commands (see +Aliases allow a string to be substituted for a word that is in +a position in the input where it can be the first word of a simple +command. +Aliases have names and corresponding values that are set +and unset using the alias and unalias builtin commands +(see SHELL BUILTIN COMMANDS below). -The first word of each simple command, if unquoted, -is checked to see if it has an -alias. If so, that word is replaced by the text of the alias. +

+ +If the shell reads an unquoted word in the right position, it checks +the word to see if it matches an alias name. +If it matches, the shell +replaces the word with the alias value, and reads that value as if it +had been read instead of the word. +The shell doesn't look at any characters following the word before +attempting alias substitution. +

+ The characters /, $, `, and = and any of the shell metacharacters or quoting characters listed above may not appear in an alias name. @@ -5593,11 +6388,13 @@ for instance, and bash does not try to recursively expand the replacement text. +

+ If the last character of the alias value is a blank, -then the next command -word following the alias is also checked for alias expansion. +the shell checks the next command +word following the alias for alias expansion.

Aliases are created and listed with the @@ -5614,7 +6411,7 @@ If arguments are needed, use a shell function (see FUNCTIONS -below). +below) instead.

Aliases are not expanded when the shell is not interactive, unless @@ -5628,7 +6425,9 @@ shell option is set using shopt under -SHELL BUILTIN COMMANDS +SHELL BUILTIN COMMANDS + + below).

@@ -5639,27 +6438,32 @@ somewhat confusing. always reads at least one complete line of input, and all lines that make up a compound command, before executing any of the commands on that line or the compound command. -Aliases are expanded when a -command is read, not when it is executed. Therefore, an +Aliases are expanded when a command is read, not when it is executed. +Therefore, an alias definition appearing on the same line as another -command does not take effect until the next line of input is read. +command does not take effect until the shell reads the next line of input, +and an alias definition in a compound command does not take +effect until the shell parses and executes the entire compound command. The commands following the alias definition -on that line are not affected by the new alias. +on that line, +or in the rest of a compound command, +are not affected by the new alias. This behavior is also an issue when functions are executed. Aliases are expanded when a function definition is read, not when the function is executed, because a function definition -is itself a command. As a consequence, aliases +is itself a command. +As a consequence, aliases defined in a function are not available until after that -function is executed. To be safe, always put +function is executed. +To be safe, always put alias definitions on a separate line, and do not use alias in compound commands.

-For almost every purpose, aliases are superseded by -shell functions. -  +For almost every purpose, shell functions are preferable to aliases. + 

FUNCTIONS

A shell function, defined as described above under @@ -5668,18 +6472,21 @@ A shell function, defined as described above under
stores a series of commands for later execution. When the name of a shell function is used as a simple command name, -the list of commands associated with that function name is executed. +the shell executes +the list of commands associated with that function name. Functions are executed in the context of the -current shell; no new process is created to interpret +calling shell; there is no new process created to interpret them (contrast this with the execution of a shell script). +

+ When a function is executed, the arguments to the function become the positional parameters during its execution. The special parameter # -is updated to reflect the change. Special parameter 0 -is unchanged. +is updated to reflect the new positional parameters. +Special parameter 0 is unchanged. The first element of the FUNCNAME @@ -5721,7 +6528,7 @@ trap is not inherited unless the -o errtrace shell option has been enabled.

-Variables local to the function may be declared with the +Variables local to the function are declared with the local builtin command (local variables). @@ -5735,18 +6542,22 @@ it calls). In the following description, the current scope is a currently- executing function. Previous scopes consist of that function's caller and so on, -back to the "global" scope, where the shell is not executing -any shell function. -Consequently, a local variable at the current scope is a variable +back to the + +scope, where the shell is not executing any shell function. +A local variable at the current scope is a variable declared using the local or declare builtins in the function that is currently executing.

-Local variables "shadow" variables with the same name declared at -previous scopes. +Local variables + +variables with the same name declared at previous scopes. For instance, a local variable declared in a function -hides a global variable of the same name: references and assignments -refer to the local variable, leaving the global variable unmodified. +hides variables with the same name declared at previous scopes, +including global variables: references and assignments +refer to the local variable, leaving the variables +at previous scopes unmodified. When the function returns, the global variable is once again visible.

@@ -5757,36 +6568,41 @@ are a result of the sequence of function calls that caused execution to reach the current function. The value of a variable that a function sees depends on its value within its caller, if any, whether that caller is -the "global" scope or another shell function. +the global +scope or another shell function. This is also the value that a local variable -declaration "shadows", and the value that is restored when the function -returns. +declaration shadows, +and the value that is restored when the function returns.

For example, if a variable var is declared as local in function func1, and func1 calls another function func2, -references to var made from within func2 will resolve to the +references to var made from within func2 resolve to the local variable var from func1, shadowing any global variable named var.

The unset builtin also acts using the same dynamic scope: if a -variable is local to the current scope, unset will unset it; +variable is local to the current scope, unset unsets it; otherwise the unset will refer to the variable found in any calling scope as described above. -If a variable at the current local scope is unset, it will remain so +If a variable at the current local scope is unset, it remains so (appearing as unset) until it is reset in that scope or until the function returns. Once the function returns, any instance of the variable at a previous -scope will become visible. +scope becomes visible. If the unset acts on a variable at a previous scope, any instance of a -variable with that name that had been shadowed will become visible +variable with that name that had been shadowed becomes visible (see below how the localvar_unset shell option changes this behavior).

-The FUNCNEST variable, if set to a numeric value greater -than 0, defines a maximum function nesting level. Function -invocations that exceed the limit cause the entire command to +The +FUNCNEST + + +variable, if set to a numeric value greater +than 0, defines a maximum function nesting level. +Function invocations that exceed the limit cause the entire command to abort.

@@ -5796,6 +6612,10 @@ If the builtin command is executed in a function, the function completes and execution resumes with the next command after the function call. +If return is supplied a numeric argument, +that is the function's return status; otherwise the function's +return status is the exit status of the last command executed +before the return. Any command associated with the RETURN trap is executed before execution resumes. When a function completes, the values of the @@ -5806,7 +6626,7 @@ are restored to the values they had prior to the function's execution.

-Function names and definitions may be listed with the +The -f option to the @@ -5815,7 +6635,9 @@ option to the or typeset -builtin commands. The +builtin commands +lists function names and definitions. +The -F option to @@ -5824,7 +6646,7 @@ option to or typeset -will list the function names only +lists the function names only (and optionally the source file and line number, if the extdebug shell option is enabled). Functions may be exported so that child shell processes @@ -5836,24 +6658,31 @@ option to the export builtin. -A function definition may be deleted using the -f option to +The -f option to the unset -builtin. +builtin deletes a function definition.

Functions may be recursive. The FUNCNEST variable may be used to limit the depth of the function call stack and restrict the number of function invocations. -By default, no limit is imposed on the number of recursive calls. -  +By default, bash imposes no limit on the number of recursive calls. + 

ARITHMETIC EVALUATION

The shell allows arithmetic expressions to be evaluated, under -certain circumstances (see the let and declare builtin -commands, the (( compound command, and Arithmetic Expansion). -Evaluation is done in fixed-width integers with no check for overflow, +certain circumstances +(see the let and declare builtin commands, +the (( compound command, +the arithmetic for command, +the [[ conditional command, +and Arithmetic Expansion). +

+ +Evaluation is done in the largest fixed-width integers available, +with no check for overflow, though division by 0 is trapped and flagged as an error. The operators and their precedence, associativity, and values are the same as in the C language. @@ -5868,14 +6697,14 @@ The levels are listed in order of decreasing precedence.

variable post-increment and post-decrement -
- + - -
-unary minus and plus
++id --id
variable pre-increment and pre-decrement +
- + + +
+unary minus and plus
! ~
@@ -5944,8 +6773,13 @@ Shell variables are allowed as operands; parameter expansion is performed before the expression is evaluated. Within an expression, shell variables may also be referenced by name without using the parameter expansion syntax. +This means you can use "x", where x is a shell variable name, +in an arithmetic expression, and the shell will evaluate its value as +an expression and use the result. A shell variable that is null or unset evaluates to 0 when referenced -by name without using the parameter expansion syntax. +by name in an expression. +

+ The value of a variable is evaluated as an arithmetic expression when it is referenced, or when a variable which has been given the integer attribute using declare -i is assigned a value. @@ -5971,10 +6805,10 @@ letters may be used interchangeably to represent numbers between 10 and 35.

-Operators are evaluated in order of precedence. Sub-expressions in -parentheses are evaluated first and may override the precedence -rules above. -  +Operators are evaluated in precedence order. +Sub-expressions in parentheses are evaluated first +and may override the precedence rules above. + 

CONDITIONAL EXPRESSIONS

Conditional expressions are used by the [[ compound command and @@ -5985,29 +6819,50 @@ the number of arguments; see the descriptions of those commands for any other command-specific actions.

-Expressions are formed from the following unary or binary primaries. +Expressions are formed from the unary or binary primaries listed below. +Unary expressions are often used to examine the status of a file +or shell variable. +Binary operators are used for string, numeric, and file attribute +comparisons. +

+ Bash handles several filenames specially when they are used in expressions. If the operating system on which bash is running provides these special files, bash will use them; otherwise it will emulate them internally with this behavior: If any file argument to one of the primaries is of the form -/dev/fd/n, then file descriptor n is checked. + +/dev/fd/n, + +then bash checks file descriptor n. If the file argument to one of the primaries is one of -/dev/stdin, /dev/stdout, or /dev/stderr, file -descriptor 0, 1, or 2, respectively, is checked. + +/dev/stdin, + + +/dev/stdout, + +or + +/dev/stderr, + +bash checks file descriptor 0, 1, or 2, respectively.

Unless otherwise specified, primaries that operate on files follow symbolic links and operate on the target of the link, rather than the link itself.

- -When used with [[, the < and > operators sort +When used with [[, +or when the shell is in posix mode, +the < and > operators sort lexicographically using the current locale. -The test command sorts using ASCII ordering. +When the shell is not in posix mode, +the test command sorts using ASCII ordering.

+

-a file @@ -6044,7 +6899,9 @@ True if file exists and is a symbolic link.
-k file
-True if file exists and its ``sticky'' bit is set. +True if file exists and its + +bit is set.
-p file
@@ -6087,7 +6944,8 @@ True if file exists and is a symbolic link.
-N file
-True if file exists and has been modified since it was last read. +True if file exists and has been modified since it was last +accessed.
-O file
@@ -6096,15 +6954,6 @@ True if file exists and is owned by the effective user id.
True if file exists and is a socket. -
file1 -ef file2
-True if file1 and file2 refer to the same device and -inode numbers. -
file1 -nt file2
-True if file1 is newer (according to modification date) than file2, -or if file1 exists and file2 does not. -
file1 -ot file2
-True if file1 is older than file2, or if file2 exists -and file1 does not.
-o optname
@@ -6126,6 +6975,12 @@ True if the shell variable varname is set (has been assigned a value). +If varname is an indexed +array variable name subscripted by @ or *, +this returns true if the array has any set elements. +If varname is an associative +array variable name subscripted by @ or *, +this returns true if an element with that key is set.
-R varname
@@ -6138,21 +6993,21 @@ is set and is a name reference.
True if the length of string is zero.
string
-
-n string
- True if the length of string is non-zero. +
string1 == string2
string1 = string2
- -True if the strings are equal. = should be used -with the test command for POSIX conformance. +True if the strings are equal. += should be used with the test command for +POSIX +conformance. When used with the [[ command, this performs pattern matching as described above (Compound Commands).
string1 != string2
@@ -6161,6 +7016,19 @@ True if the strings are not equal. True if string1 sorts before string2 lexicographically.
string1 > string2
True if string1 sorts after string2 lexicographically. + +
+
+file1 -ef file2 +True if file1 and file2 refer to the same device and +inode numbers. +
file1 -nt file2
+True if file1 is newer (according to modification date) than file2, +or if file1 exists and file2 does not. +
file1 -ot file2
+True if file1 is older than file2, or if file2 exists +and file1 does not. +
arg1 OP arg2
@@ -6184,29 +7052,38 @@ or These arithmetic binary operators return true if arg1 is equal to, not equal to, less than, less than or equal to, greater than, or greater than or equal to arg2, respectively. -Arg1 +arg1 and arg2 may be positive or negative integers. When used with the [[ command, -Arg1 +arg1 and -Arg2 +arg2 are evaluated as arithmetic expressions (see ARITHMETIC EVALUATION above). +Since the expansions the [[ command performs on +arg1 + +and +arg2 + +can potentially result in empty strings, +arithmetic expression evaluation treats +those as expressions that evaluate to 0.
-  + 

SIMPLE COMMAND EXPANSION

-When a simple command is executed, the shell performs the following +When the shell executes a simple command, it performs the following expansions, assignments, and redirections, from left to right, in the following order.
@@ -6216,7 +7093,8 @@ preceding the command name) and redirections are saved for later processing.
2.
The words that are not variable assignments or redirections are -expanded. If any words remain after expansion, the first word +expanded. +If any words remain after expansion, the first word is taken to be the name of the command and the remaining words are the arguments.
3.
@@ -6243,32 +7121,36 @@ an error occurs, and the command exits with a non-zero status.

If no command name results, redirections are performed, but do not -affect the current shell environment. A redirection error causes the -command to exit with a non-zero status. +affect the current shell environment. +A redirection error causes the command to exit with a non-zero status.

If there is a command name left after expansion, execution proceeds as -described below. Otherwise, the command exits. If one of the expansions -contained a command substitution, the exit status of the command is -the exit status of the last command substitution performed. If there -were no command substitutions, the command exits with a status of zero. -  +described below. +Otherwise, the command exits. +If one of the expansions contained a command substitution, +the exit status of the command is the exit status of +the last command substitution performed. +If there were no command substitutions, +the command exits with a zero status. + 

COMMAND EXECUTION

After a command has been split into words, if it results in a -simple command and an optional list of arguments, the following -actions are taken. +simple command and an optional list of arguments, the shell performs +the following actions.

If the command name contains no slashes, the shell attempts to -locate it. If there exists a shell function by that name, that -function is invoked as described above in +locate it. +If there exists a shell function by that name, that function is +invoked as described above in FUNCTIONS. If the name does not match a function, the shell searches for -it in the list of shell builtins. If a match is found, that -builtin is invoked. +it in the list of shell builtins. +If a match is found, that builtin is invoked.

If the name is neither a shell function nor a builtin, @@ -6291,11 +7173,11 @@ under below). -A full search of the directories in +Bash performs a full search of the directories in PATH -is performed only if the command is not found in the hash table. +only if the command is not found in the hash table. If the search is unsuccessful, the shell searches for a defined shell function named command_not_found_handle. If that function exists, it is invoked in a separate execution environment @@ -6315,10 +7197,10 @@ to the command are set to the arguments given, if any. If this execution fails because the file is not in executable format, and the file is not a directory, it is assumed to be -a shell script, a file -containing shell commands, and the shell creates a -new instance of itself -to execute it. +a shell script, a file containing shell commands, +and the shell creates a new instance of itself to execute it. +Bash tries to determine whether the file is a text file or a binary, +and will not execute files it determines to be binaries. This subshell reinitializes itself, so that the effect is as if a new shell had been invoked to handle the script, with the exception that the locations of @@ -6326,7 +7208,9 @@ commands remembered by the parent (see hash below under -SHELL BUILTIN COMMANDS) +SHELL BUILTIN COMMANDS + + are retained by the child.

@@ -6334,47 +7218,49 @@ If the program is a file beginning with #!, the remainder of the first line specifies an interpreter -for the program. The shell executes the +for the program. +The shell executes the specified interpreter on operating systems that do not -handle this executable format themselves. The arguments to the +handle this executable format themselves. +The arguments to the interpreter consist of a single optional argument following the interpreter name on the first line of the program, followed by the name of the program, followed by the command arguments, if any. -  + 

COMMAND EXECUTION ENVIRONMENT

The shell has an execution environment, which consists of the following:
*
-open files inherited by the shell at invocation, as modified by -redirections supplied to the exec builtin +Open files inherited by the shell at invocation, as modified by +redirections supplied to the exec builtin.
*
-the current working directory as set by cd, pushd, or -popd, or inherited by the shell at invocation +The current working directory as set by cd, pushd, or +popd, or inherited by the shell at invocation.
*
-the file creation mode mask as set by umask or inherited from -the shell's parent +The file creation mode mask as set by umask or inherited from +the shell's parent.
*
-current traps set by trap +Current traps set by trap.
*
-shell parameters that are set by variable assignment or with set -or inherited from the shell's parent in the environment +Shell parameters that are set by variable assignment or with set +or inherited from the shell's parent in the environment.
*
-shell functions defined during execution or inherited from the shell's -parent in the environment +Shell functions defined during execution or inherited from the shell's +parent in the environment.
*
-options enabled at invocation (either by default or with command-line -arguments) or by set +Options enabled at invocation (either by default or with command-line +arguments) or by set.
*
-options enabled by shopt +Options enabled by shopt.
*
-shell aliases defined with alias +Shell aliases defined with alias.
*
-various process IDs, including those of background jobs, the value +Various process IDs, including those of background jobs, the value of $$, and the value of -PPID +PPID.
@@ -6385,21 +7271,20 @@ is to be executed, it is invoked in a separate execution environment that consists of the following. Unless otherwise noted, the values are inherited from the shell. -
*
-the shell's open files, plus any modifications and additions specified -by redirections to the command +The shell's open files, plus any modifications and additions specified +by redirections to the command.
*
-the current working directory +The current working directory.
*
-the file creation mode mask +The file creation mode mask.
*
-shell variables and functions marked for export, along with variables -exported for the command, passed in the environment +Shell variables and functions marked for export, along with variables +exported for the command, passed in the environment.
*
-traps caught by the shell are reset to the values inherited from the -shell's parent, and traps ignored by the shell are ignored +Traps caught by the shell are reset to the values inherited from the +shell's parent, and traps ignored by the shell are ignored.

@@ -6414,22 +7299,33 @@ Command substitution, commands grouped with parentheses, and asynchronous commands are invoked in a subshell environment that is a duplicate of the shell environment, except that traps caught by the shell are reset to the values -that the shell inherited from its parent at invocation. Builtin -commands that are invoked as part of a pipeline are also executed in a -subshell environment. Changes made to the subshell environment +that the shell inherited from its parent at invocation. +Builtin commands that are invoked as part of a pipeline, +except possibly in the last element depending on the value of the +lastpipe shell option, +are also executed in a subshell environment. +Changes made to the subshell environment cannot affect the shell's execution environment.

-Subshells spawned to execute command substitutions inherit the value of -the -e option from the parent shell. When not in posix mode, +When the shell is in posix mode, +subshells spawned to execute command substitutions inherit the value of +the -e option from their parent shell. +When not in posix mode, bash clears the -e option in such subshells. +See the +description of the inherit_errexit shell option below +for how to control this behavior when not in posix mode.

If a command is followed by a & and job control is not active, the -default standard input for the command is the empty file /dev/null. +default standard input for the command is the empty file + +/dev/null. + Otherwise, the invoked command inherits the file descriptors of the calling shell as modified by redirections. -  + 

ENVIRONMENT

When a program is invoked it is given an array of strings @@ -6448,23 +7344,31 @@ creates a parameter for each name found, automatically marking it for export -to child processes. Executed commands inherit the environment. +to child processes. +Executed commands inherit the environment. The -export +export, + +declare -x, and -declare -x +unset -commands allow parameters and functions to be added to and -deleted from the environment. If the value of a parameter -in the environment is modified, the new value becomes part -of the environment, replacing the old. The environment +commands modify the environment by +adding and deleting parameters and functions. +If the value of a parameter +in the environment is modified, the new value automatically +becomes part of the environment, replacing the old. +The environment inherited by any executed command consists of the shell's initial environment, whose values may be modified in the shell, less any pairs removed by the unset -command, plus any additions via the +or +export -n + +commands, plus any additions via the export and @@ -6473,16 +7377,19 @@ and commands.

-The environment for any -simple command - -or function may be augmented temporarily by prefixing it with -parameter assignments, as described above in -PARAMETERS. +If any parameter assignments, as described above in +PARAMETERS, +appear before a +simple command, + +the variable assignments are part of that command's environment +for as long as it executes. These assignment statements affect only the environment seen by that command. +If these assignments precede a call to a shell function, the variables +are local to the function and exported to that function's children.

If the @@ -6504,23 +7411,27 @@ When invokes an external command, the variable _ -is set to the full filename of the command and passed to that +is set to the full pathname of the command and passed to that command in its environment. -  + 

EXIT STATUS

The exit status of an executed command is the value returned by the -waitpid system call or equivalent function. Exit statuses -fall between 0 and 255, though, as explained below, the shell may -use values above 125 specially. Exit statuses from shell builtins and -compound commands are also limited to this range. Under certain -circumstances, the shell will use special values to indicate specific -failure modes. +waitpid system call or equivalent function. +Exit statuses fall between 0 and 255, though, as explained below, +the shell may use values above 125 specially. +Exit statuses from shell builtins and compound commands are also +limited to this range. +Under certain circumstances, the shell will use special values to +indicate specific failure modes.

For the shell's purposes, a command which exits with a -zero exit status has succeeded. An exit status of zero -indicates success. A non-zero exit status indicates failure. +zero exit status has succeeded. +So while an exit status of zero indicates success, a non-zero +exit status indicates failure. +

+ When a command terminates on a fatal signal N, bash uses the value of 128+N as the exit status.

@@ -6547,9 +7458,9 @@ parameter $?. Bash itself returns the exit status of the last command executed, unless a syntax error occurs, in which case it exits -with a non-zero value. See also the exit builtin -command below. -  +with a non-zero value. +See also the exit builtin command below. + 

SIGNALS

When bash is interactive, in the absence of any traps, it ignores @@ -6557,11 +7468,16 @@ When bash is interactive, in the absence of any traps, it ignores
(so that kill 0 does not kill an interactive shell), -and +and catches and handles SIGINT -is caught and handled (so that the wait builtin is interruptible). +(so that the wait builtin is interruptible). +When bash receives +SIGINT, + + +it breaks out of any executing loops. In all cases, bash ignores SIGQUIT. @@ -6582,8 +7498,14 @@ and

-Non-builtin commands run by bash have signal handlers -set to the values inherited by the shell from its parent. +The trap builtin modifies the shell's signal handling, as +described below. +

+ +Non-builtin commands bash executes have signal handlers +set to the values inherited by the shell from its parent, +unless trap sets them to be ignored, in which case the child +process will ignore them as well. When job control is not in effect, asynchronous commands ignore SIGINT @@ -6617,16 +7539,21 @@ Before exiting, an interactive shell resends the to all jobs, running or stopped. -Stopped jobs are sent +The shell sends SIGCONT -to ensure that they receive the -SIGHUP. +to stopped jobs to ensure that they receive the +SIGHUP + + +(see +JOB CONTROL +below for more information about running and stopped jobs). To prevent the shell from -sending the signal to a particular job, it should be removed from the +sending the signal to a particular job, remove it from the jobs table with the disown @@ -6634,8 +7561,7 @@ builtin (see SHELL BUILTIN COMMANDS -below) or marked -to not receive +below) or mark it not to receive SIGHUP @@ -6647,7 +7573,7 @@ using If the huponexit -shell option has been set with +shell option has been set using shopt, bash @@ -6660,12 +7586,13 @@ to all jobs when an interactive login shell exits.

If bash is waiting for a command to complete and receives a signal -for which a trap has been set, the trap will not be executed until -the command completes. -When bash is waiting for an asynchronous command via the wait -builtin, the reception of a signal for which a trap has been set will -cause the wait builtin to return immediately with an exit status -greater than 128, immediately after which the trap is executed. +for which a trap has been set, +it will not execute the trap until the command completes. +If bash is waiting for an asynchronous command via the wait +builtin, +and it receives a signal for which a trap has been set, +the wait builtin will return immediately with an exit status +greater than 128, immediately after which the shell executes the trap.

When job control is not enabled, and bash is waiting for a foreground @@ -6682,9 +7609,24 @@ same process group as the terminal, and ^C sends to all processes in that process group. +Since bash does not enable job control by default when the +shell is not interactive, +this scenario is most common in non-interactive shells. +

+ +When job control is enabled, and bash is waiting for a foreground +command to complete, the shell does not receive keyboard-generated +signals, because it is not in the same process group as the terminal. +This scenario is most common in interactive shells, where bash +attempts to enable job control by default. +See +JOB CONTROL + + +below for more information about process groups.

-When bash is running without job control enabled and receives +When job control is not enabled, and bash receives SIGINT @@ -6700,7 +7642,11 @@ If the command terminates due to the bash concludes -that the user meant to end the entire script, and acts on the +that the user meant to send the +SIGINT + + +to the shell as well, and acts on the SIGINT @@ -6708,7 +7654,9 @@ that the user meant to end the entire script, and acts on the SIGINT -trap or exiting itself); +trap, +exiting a non-interactive shell, +or returning to the top level to read a new command).

2.
If the command does not terminate due to SIGINT, @@ -6739,14 +7687,39 @@ as it does with any other trapped signal it receives while it is waiting for the foreground command to complete, for compatibility.
-  +

+ +When job control is enabled, bash does not receive keyboard-generated +signals such as +SIGINT + + +while it is waiting for a foreground command. +An interactive shell does not pay attention to the +SIGINT, + + +even if the foreground command terminates as a result, other than noting +its exit status. +If the shell is not interactive, and +the foreground command terminates due to the +SIGINT, + + +bash pretends it received the +SIGINT + + +itself (scenario 1 above), for compatibility. + 

JOB CONTROL

Job control refers to the ability to selectively stop (suspend) the execution of processes and continue (resume) -their execution at a later point. A user typically employs +their execution at a later point. +A user typically employs this facility via an interactive interface supplied jointly by the operating system kernel's terminal driver and bash. @@ -6756,11 +7729,15 @@ by the operating system kernel's terminal driver and The shell associates a job -with each pipeline. It keeps a table of currently executing -jobs, which may be listed with the +with each pipeline. +It keeps a table of currently executing +jobs, which the jobs -command. When +command will display. +Each job has a job number, which jobs displays between brackets. +Job numbers start at 1. +When bash starts a job asynchronously (in the @@ -6786,31 +7763,44 @@ uses the abstraction as the basis for job control.

-To facilitate the implementation of the user interface to job -control, the operating system maintains the notion of a current terminal -process group ID. Members of this process group (processes whose +To facilitate the implementation of the user interface to job control, +each process has a process group ID, and +the operating system maintains the notion of a current terminal +process group ID. +This terminal process group ID is associated with the +controlling terminal. +

+ +Processes that have the same process group ID are said to be part of +the same process group. +Members of the foreground process group (processes whose process group ID is equal to the current terminal process group ID) receive keyboard-generated signals such as SIGINT. -These processes are said to be in the -foreground. +Processes in the foreground process group are said to be +foreground +processes. Background -processes are those whose process group ID differs from the terminal's; +processes are those whose process group ID differs from the +controlling terminal's; such processes are immune to keyboard-generated signals. -Only foreground processes are allowed to read from or, if the -user so specifies with stty tostop, write to the -terminal. -Background processes which attempt to read from (write to when -stty tostop is in effect) the -terminal are sent a +Only foreground processes are allowed to read from or, +if the user so specifies with + +write to the controlling terminal. +The system sends a SIGTTIN (SIGTTOU) -signal by the kernel's terminal driver, +signal to background processes which attempt to +read from (write to when + +is in effect) +the terminal, which, unless caught, suspends the process.

@@ -6829,7 +7819,7 @@ character (typically ^Z, Control-Z) while a process is running -causes that process to be stopped and returns control to +stops that process and returns control to bash. Typing the @@ -6838,31 +7828,40 @@ Typing the character (typically ^Y, -Control-Y) causes the process to be stopped when it -attempts to read input from the terminal, and control to -be returned to +Control-Y) causes the process stop when it +attempts to read input from the terminal, and returns control to bash. -The user may then manipulate the state of this job, using the +The user then manipulates the state of this job, using the bg command to continue it in the background, the fg -command to continue it in the foreground, or -the +command to continue it in the foreground, or the kill -command to kill it. A ^Z takes effect immediately, -and has the additional side effect of causing pending output -and typeahead to be discarded. +command to kill it. +The suspend character takes effect immediately, +and has the additional side effect of discarding any pending output +and typeahead. +To force a background process to stop, or stop a process +that's not associated with the current terminal session, +send it the +SIGSTOP + + +signal using kill.

There are a number of ways to refer to a job in the shell. -The character +The % -introduces a job specification (jobspec). Job number +character introduces a job specification (jobspec). +

+ +Job number n may be referred to as @@ -6873,75 +7872,82 @@ start it, or using a substring that appears in its command line. For example, %ce -refers to a stopped -job whose command name begins with +refers to a job whose command name begins with ce. -If a prefix matches more than one job, -bash - -reports an error. Using +Using %?ce, on the other hand, refers to any job containing the string ce -in its command line. If the substring matches more than one job, +in its command line. +If the prefix or substring matches more than one job, bash -reports an error. The symbols +reports an error. +

+ +The symbols %% and %+ refer to the shell's notion of the -current job, +current job. -which is the last job stopped while it was in -the foreground or started in the background. -The -previous job +A single % (with no accompanying job specification) also refers to the +current job. +%- -may be referenced using -%-. +refers to the +previous job. +When a job starts in the background, +a job stops while in the foreground, +or a job is resumed in the background, +it becomes the current job. +The job that was the current job becomes the previous job. +When the current job terminates, the previous job becomes the +current job. If there is only a single job, %+ and %- can both be used to refer to that job. In output pertaining to jobs (e.g., the output of the jobs -command), the current job is always flagged with a +command), the current job is always marked with a +, and the previous job with a -. -A single % (with no accompanying job specification) also refers to the -current job.

-Simply naming a job can be used to bring it into the -foreground: +Simply naming a job can be used to bring it into the foreground: %1 is a synonym for -``fg %1'', + bringing job 1 from the background into the foreground. Similarly, -``%1 &'' resumes job 1 in the background, equivalent to -``bg %1''. +

The shell learns immediately whenever a job changes state. Normally, bash -waits until it is about to print a prompt before reporting +waits until it is about to print a prompt before +notifying the user about changes in a job's status so as to not interrupt -any other output. If the +any other output, +though it will notify of changes in a job's status after a +foreground command in +a list completes, before executing the next command in the list. +If the -b option to the @@ -6951,18 +7957,26 @@ builtin command is enabled, bash -reports such changes immediately. -Any trap on +reports status changes immediately. +Bash executes any trap on SIGCHLD -is executed for each child that exits. +for each child that terminates.

-If an attempt to exit +When a job terminates and bash notifies the user about it, +bash removes the job from the table. +It will not appear in jobs output, but wait will +report its exit status, as long as it's supplied the process ID +associated with the job as an argument. +When the table is empty, job numbers start over at 1. +

+ +If a user attempts to exit bash -is made while jobs are stopped (or, if the checkjobs shell option has +while jobs are stopped (or, if the checkjobs shell option has been enabled using the shopt builtin, running), the shell prints a warning message, and, if the checkjobs option is enabled, lists the jobs and their statuses. @@ -6970,16 +7984,18 @@ The jobs command may then be used to inspect their status. -If a second attempt to exit is made without an intervening command, -the shell does not print another warning, and any stopped -jobs are terminated. +If the user immediately attempts to exit again, +without an intervening command, +bash does not print another warning, and +terminates any stopped jobs.

When the shell is waiting for a job or process using the wait builtin, and job control is enabled, wait will return when the -job changes state. The -f option causes wait to wait +job changes state. +The -f option causes wait to wait until the job or process terminates before returning. -  + 

PROMPTING

When executing interactively, @@ -6994,6 +8010,15 @@ when it is ready to read a command, and the secondary prompt
when it needs more input to complete a command. +

+ +Bash + +examines the value of the array variable PROMPT_COMMAND just before +printing each primary prompt. +If any elements in PROMPT_COMMAND are set and non-null, Bash +executes each value, in numeric order, +just as if it had been typed on the command line. Bash displays @@ -7001,6 +8026,8 @@ displays after it reads a command but before executing it. +

+ Bash displays @@ -7009,94 +8036,107 @@ displays as described above before tracing each command when the -x option is enabled. +

+ Bash -allows these prompt strings to be customized by inserting a number of +allows the prompt strings +PS0, PS1, PS2, and PS4, +to be customized by inserting a number of backslash-escaped special characters that are decoded as follows:

-
\a
-an ASCII bell character (07) +An ASCII bell character (07). +
\d
-the date in "Weekday Month Date" format (e.g., "Tue May 26") +The date in + +format (e.g., +
\D{format}
-the format is passed to strftime(3) and the result is inserted +The format is passed to +strftime(3) + +and the result is inserted into the prompt string; an empty format results in a locale-specific -time representation. The braces are required +time representation. +The braces are required.
\e
-an ASCII escape character (033) +An ASCII escape character (033).
\h
-the hostname up to the first `.' +The hostname up to the first +
\H
-the hostname +The hostname.
\j
-the number of jobs currently managed by the shell +The number of jobs currently managed by the shell.
\l
-the basename of the shell's terminal device name +The basename of the shell's terminal device name (e.g., +
\n
-newline +A newline.
\r
-carriage return +A carriage return.
\s
-the name of the shell, the basename of +The name of the shell: the basename of $0 -(the portion following the final slash) +(the portion following the final slash).
\t
-the current time in 24-hour HH:MM:SS format +The current time in 24-hour HH:MM:SS format.
\T
-the current time in 12-hour HH:MM:SS format +The current time in 12-hour HH:MM:SS format.
\@
-the current time in 12-hour am/pm format +The current time in 12-hour am/pm format.
\A
-the current time in 24-hour HH:MM format +The current time in 24-hour HH:MM format.
\u
-the username of the current user +The username of the current user.
\v
-the version of bash (e.g., 2.00) +The bash version (e.g., 2.00).
\V
-the release of bash, version + patch level (e.g., 2.00.0) +The bash release, version + patch level (e.g., 2.00.0)
\w
-the value of the PWD shell variable ($PWD), +The value of the PWD shell variable ($PWD), with $HOME @@ -7106,50 +8146,50 @@ abbreviated with a tilde PROMPT_DIRTRIM -variable) +variable).
\W
-the basename of $PWD, +The basename of $PWD, with $HOME -abbreviated with a tilde +abbreviated with a tilde.
\!
-the history number of this command +The history number of this command.
\#
-the command number of this command +The command number of this command.
\$
-if the effective UID is 0, a +If the effective UID is 0, a #, otherwise a -$ +$.
\nnn
-the character corresponding to the octal number nnn +The character corresponding to the octal number nnn.
\\
-a backslash +A backslash.
\[
-begin a sequence of non-printing characters, which could be used to -embed a terminal control sequence into the prompt +Begin a sequence of non-printing characters, which could be used to +embed a terminal control sequence into the prompt.
\]
-end a sequence of non-printing characters +End a sequence of non-printing characters.
@@ -7180,18 +8220,18 @@ below). This can have unwanted side effects if escaped portions of the string appear within command substitution or contain characters special to word expansion. -  + 

READLINE

This is the library that handles reading input when using an interactive shell, unless the --noediting -option is given at shell invocation. +option is supplied at shell invocation. Line editing is also used when using the -e option to the read builtin. -By default, the line editing commands are similar to those of Emacs. -A vi-style line editing interface is also available. +By default, the line editing commands are similar to those of emacs; +a vi-style line editing interface is also available. Line editing can be enabled at any time using the -o emacs @@ -7216,82 +8256,129 @@ options to the set builtin. -  + 

Readline Notation

-In this section, the Emacs-style notation is used to denote -keystrokes. Control keys are denoted by C-key, e.g., C-n -means Control-N. Similarly, -meta +This section uses Emacs-style editing concepts and uses its +notation for keystrokes. +Control keys are denoted by C-key, e.g., C-n means Control-N. +Similarly, +meta + +keys are denoted by M-key, so M-x means Meta-X. +The Meta key is often labeled + +or + +

-keys are denoted by M-key, so M-x means Meta-X. (On keyboards -without a -meta +On keyboards without a +Meta -key, M-x means ESC x, i.e., press the Escape key -then the +key, M-x means ESC x, +i.e., press and release the Escape key, +then press and release the x -key. This makes ESC the meta prefix. -The combination M-C-x means ESC-Control-x, -or press the Escape key -then hold the Control key while pressing the +key, in sequence. +This makes ESC the meta prefix. +The combination M-C-x means ESC Control-x: +press and release the Escape key, +then press and hold the Control key while pressing the x -key.) +key, then release both. +

+ +On some keyboards, the Meta key modifier produces characters with +the eighth bit (0200) set. +You can use the enable-meta-key variable +to control whether or not it does this, if the keyboard allows it. +On many others, the terminal or terminal emulator converts the metafied +key to a key sequence beginning with ESC as described in the +preceding paragraph. +

+ +If your Meta key produces a key sequence with the ESC meta prefix, +you can make M-key key bindings you specify (see +Readline Key Bindings + +below) do the same thing by setting the force-meta-prefix variable.

-Readline commands may be given numeric +Readline + +commands may be given numeric arguments, which normally act as a repeat count. Sometimes, however, it is the sign of the argument that is significant. -Passing a negative argument to a command that acts in the forward -direction (e.g., kill-line) causes that command to act in a -backward direction. +Passing a negative argument +to a command that acts in the forward direction (e.g., kill-line) +makes that command act in a backward direction. Commands whose behavior with arguments deviates from this are noted below.

+The point is the current cursor position, and mark refers +to a saved cursor position. +The text between the point and mark is referred to as the region. +Readline has the concept of an active region: +when the region is active, readline redisplay +highlights the region using the +value of the active-region-start-color variable. +The enable-active-region variable turns this on and off. +Several commands set the region to active; those are noted below. +

+ When a command is described as killing text, the text deleted is saved for possible future retrieval -(yanking). The killed text is saved in a -kill ring. Consecutive kills cause the text to be -accumulated into one unit, which can be yanked all at once. +(yanking). +The killed text is saved in a kill ring. +Consecutive kills accumulate the deleted text +into one unit, which can be yanked all at once. Commands which do not kill text separate the chunks of text on the kill ring. -  + 

Readline Initialization

-Readline is customized by putting commands in an initialization +Readline + +is customized by putting commands in an initialization file (the inputrc file). The name of this file is taken from the value of the INPUTRC -variable. If that variable is unset, the default is +shell variable. +If that variable is unset, the default is + ~/.inputrc. -If that file does not exist or cannot be read, the ultimate default is +If that file does not exist or cannot be read, readline looks for + /etc/inputrc. -When a program which uses the readline library starts up, the -initialization file is read, and the key bindings and variables -are set. -There are only a few basic constructs allowed in the -readline initialization file. +When a program that uses the readline library starts up, +readline reads the initialization file +and sets the key bindings and variables found there, +before reading any user input. +

+ +There are only a few basic constructs allowed in the inputrc file. Blank lines are ignored. Lines beginning with a # are comments. Lines beginning with a $ indicate conditional constructs. Other lines denote key bindings and variable settings.

-The default key-bindings may be changed with an +The default key-bindings in this section +may be changed using key binding commands in the inputrc file. -Other programs that use this library may add their own commands -and bindings. +Programs that use the readline library, including bash, +may add their own commands and bindings.

For example, placing @@ -7306,21 +8393,23 @@ or C-Meta-u: universal-argument +

+ into the inputrc -would make M-C-u execute the readline command +would make M-C-u execute the readline command universal-argument.

-The following symbolic character names are recognized: -RUBOUT, - +Key bindings may contain the following symbolic character names: DEL, ESC, +ESCAPE, + LFD, NEWLINE, @@ -7329,28 +8418,38 @@ The following symbolic character names are recognized: RETURN, -SPC, +RUBOUT +(a destructive backspace), SPACE, +SPC, + and TAB.

-In addition to command names, readline allows keys to be bound +In addition to command names, readline allows keys to be bound to a string that is inserted when the key is pressed (a macro). -  +The difference between a macro and a command is that a macro is +enclosed in single or double quotes. + 

Readline Key Bindings

The syntax for controlling key bindings in the inputrc -file is simple. All that is required is the name of the -command or the text of a macro and a key sequence to which -it should be bound. The name may be specified in one of two ways: -as a symbolic key name, possibly with Meta- or Control- -prefixes, or as a key sequence. +file is simple. +All that is required is the name of the command or the text of a macro +and a key sequence to which it should be bound. +The key sequence may be specified in one of two ways: +as a symbolic key name, +possibly with Meta- or Control- prefixes, +or as a key sequence composed of one or more characters +enclosed in double quotes. +The key sequence and name are separated by a colon. +There can be no whitespace between the name and the colon.

When using the form keyname:function-name or macro, @@ -7358,14 +8457,18 @@ When using the form keyname:function-name or macro, is the name of a key spelled out in English. For example:

+

-Control-u: universal-argument -
+
+Control-u: universal-argument
 Meta-Rubout: backward-kill-word
-
+Control-o: " +> output" + +
+ -Control-o: "> output"

@@ -7386,12 +8489,14 @@ and is bound to run the macro expressed on the right hand side (that is, to insert the text -> output into the line).

-In the second form, "keyseq":function-name or macro, +In the second form, +" +keyseq" +:function-name or macro, keyseq differs from @@ -7399,18 +8504,29 @@ differs from above in that strings denoting an entire key sequence may be specified by placing the sequence -within double quotes. Some GNU Emacs style key escapes can be -used, as in the following example, but the symbolic character names -are not recognized. +within double quotes. +Some GNU Emacs style key escapes can be +used, as in the following example, but none of +the symbolic character names are recognized.

+

-"\C-u": universal-argument -
-"\C-x\C-r": re-read-init-file -
+
+"
+\C-u"
+: universal-argument
+"
+\C-x\C-r"
+: re-read-init-file
+"
+\e[11~"
+: "
+Function Key 1"
+
+
+ -"\e[11~": "Function Key 1"

@@ -7430,38 +8546,40 @@ and ESC [ 1 1 ~ is bound to insert the text -Function Key 1.

-The full set of GNU Emacs style escape sequences is +The full set of GNU Emacs style escape sequences available when specifying +key sequences is

\C-
-control prefix +A control prefix.
\M-
-meta prefix +Adding the meta prefix or converting the following character to a meta +character, as described below under force-meta-prefix.
\e
-an escape character +An escape character.
\\
-backslash +Backslash.
\
-literal " -
\aq +Literal " +, a double quote. +
\'
-literal aq +Literal ', a single quote.
@@ -7507,13 +8625,13 @@ vertical tab
\nnn
-the eight-bit character whose value is the octal value nnn -(one to three digits) +The eight-bit character whose value is the octal value nnn +(one to three digits).
\xHH
-the eight-bit character whose value is the hexadecimal value HH -(one or two hex digits) +The eight-bit character whose value is the hexadecimal value HH +(one or two hex digits). @@ -7522,34 +8640,41 @@ the eight-bit character whose value is the hexadecimal value HH When entering the text of a macro, single or double quotes must be used to indicate a macro definition. Unquoted text is assumed to be a function name. -In the macro body, the backslash escapes described above are expanded. -Backslash will quote any other character in the macro text, -including " and aq. +The backslash escapes described above are expanded +in the macro body. +Backslash quotes any other character in the macro text, +including " + and '.

Bash -allows the current readline key bindings to be displayed or modified -with the +will display or modify the current readline key bindings with the bind -builtin command. The editing mode may be switched during interactive -use by using the --o +builtin command. +The +-o emacs -option to the +or +-o vi + +options to the set -builtin command (see +builtin +(see SHELL BUILTIN COMMANDS -below). -  +below) +change the editing mode during interactive use. + 

Readline Variables

-Readline has variables that can be used to further customize its -behavior. A variable may be set in the +Readline has variables that can be used to further customize its +behavior. +A variable may be set in the inputrc file with a statement of the form @@ -7566,7 +8691,7 @@ or using the bind builtin command (see below).

-Except where noted, readline variables can take the values +Except where noted, readline variables can take the values On or @@ -7574,15 +8699,29 @@ or (without regard to case). Unrecognized variable names are ignored. -When a variable value is read, empty or null values, "on" (case-insensitive), -and "1" are equivalent to On. All other values are equivalent to +When readline reads a variable value, empty or null values, + +(case-insensitive), and + +are equivalent to On. +All other values are equivalent to Off. +

+ +The bind -V command lists the current readline variable names +and values (see +SHELL BUILTIN COMMANDS + + +below). +

+ The variables and their default values are:

-
active-region-start-color +
active-region-start-color
A string variable that controls the text color and background when displaying @@ -7594,62 +8733,77 @@ It is output to the terminal before displaying the text in the active region. This variable is reset to the default value whenever the terminal type changes. The default value is the string that puts the terminal in standout mode, as obtained from the terminal's terminfo description. -A sample value might be "\e[01;33m". -
active-region-end-color +A sample value might be + +
active-region-end-color
-A string variable that "undoes" the effects of active-region-start-color -and restores "normal" terminal display appearance after displaying text -in the active region. +A string variable that + +the effects of active-region-start-color +and restores + +terminal display appearance after displaying text in the active region. This string must not take up any physical character positions on the display, so it should consist only of terminal escape sequences. It is output to the terminal after displaying the text in the active region. This variable is reset to the default value whenever the terminal type changes. The default value is the string that restores the terminal from standout mode, as obtained from the terminal's terminfo description. -A sample value might be "\e[0m". +A sample value might be +
bell-style (audible)
-Controls what happens when readline wants to ring the terminal bell. -If set to none, readline never rings the bell. If set to -visible, readline uses a visible bell if one is available. -If set to audible, readline attempts to ring the terminal's bell. +Controls what happens when readline wants to ring the terminal bell. +If set to none, readline never rings the bell. +If set to visible, readline uses a visible bell if one is available. +If set to audible, readline attempts to ring the terminal's bell.
bind-tty-special-chars (On)
-If set to On, readline attempts to bind the control characters -treated specially by the kernel's terminal driver to their readline -equivalents. +If set to On, readline attempts to bind +the control characters that are treated specially by the kernel's +terminal driver to their readline equivalents. +These override the default readline bindings described here. +Type + +at a bash prompt to see your current terminal settings, +including the special control characters (usually cchars).
blink-matching-paren (Off)
-If set to On, readline attempts to briefly move the cursor to an +If set to On, readline attempts to briefly move the cursor to an opening parenthesis when a closing parenthesis is inserted.
colored-completion-prefix (Off)
-If set to On, when listing completions, readline displays the +If set to On, when listing completions, readline displays the common prefix of the set of possible completions using a different color. The color definitions are taken from the value of the LS_COLORS environment variable. If there is a color definition in $LS_COLORS for the custom suffix -"readline-colored-completion-prefix", readline uses this color for + +readline uses this color for the common prefix instead of its default.
colored-stats (Off)
-If set to On, readline displays possible completions using different +If set to On, readline displays possible completions using different colors to indicate their file type. The color definitions are taken from the value of the LS_COLORS environment variable. -
comment-begin (``#'') + + + +
comment-begin (
-The string that is inserted when the readline + +The string that the readline insert-comment -command is executed. +command inserts. This command is bound to M-# @@ -7664,26 +8818,33 @@ The number of screen columns used to display possible matches when performing completion. The value is ignored if it is less than 0 or greater than the terminal screen width. -A value of 0 will cause matches to be displayed one per line. +A value of 0 causes matches to be displayed one per line. The default value is -1.
completion-ignore-case (Off)
-If set to On, readline performs filename matching and completion +If set to On, readline performs filename matching and completion in a case-insensitive fashion.
completion-map-case (Off)
-If set to On, and completion-ignore-case is enabled, readline +If set to On, and completion-ignore-case is enabled, +readline + treats hyphens (-) and underscores (_) as equivalent when performing case-insensitive filename matching and completion.
completion-prefix-display-length (0)
-The length in characters of the common prefix of a list of possible -completions that is displayed without modification. When set to a -value greater than zero, common prefixes longer than this value are -replaced with an ellipsis when displaying possible completions. +The maximum +length in characters of the common prefix of a list of possible +completions that is displayed without modification. +When set to a value greater than zero, readline +replaces common prefixes longer than this value +with an ellipsis when displaying possible completions. +If a completion begins with a period, +and eadline is completing filenames, +it uses three underscores instead of an ellipsis.
completion-query-items (100)
@@ -7693,37 +8854,40 @@ generated by the possible-completions command. It may be set to any integer value greater than or equal to zero. If the number of possible completions is greater than or equal to the value of this variable, -readline will ask whether or not the user wishes to view them; -otherwise they are simply listed on the terminal. -A zero value means readline should never ask; negative values are +readline asks whether or not the user wishes to view them; +otherwise readline simply lists them on the terminal. +A zero value means readline should never ask; negative values are treated as zero.
convert-meta (On)
-If set to On, readline will convert characters with the -eighth bit set to an ASCII key sequence -by stripping the eighth bit and prefixing an -escape character (in effect, using escape as the meta prefix). -The default is On, but readline will set it to Off if the -locale contains eight-bit characters. -This variable is dependent on the LC_CTYPE locale category, and -may change if the locale is changed. +If set to On, readline converts characters it reads +that have the eighth bit set to an ASCII key sequence by +clearing the eighth bit and prefixing it with an escape character +(converting the character to have the meta prefix). +The default is On, but readline sets it to Off +if the locale contains +characters whose encodings may include bytes with the eighth bit set. +This variable is dependent on the LC_CTYPE locale category, and +may change if the locale changes. +This variable also affects key bindings; see the description of +force-meta-prefix below.
disable-completion (Off)
-If set to On, readline will inhibit word completion. Completion -characters will be inserted into the line as if they had been -mapped to self-insert. +If set to On, readline inhibits word completion. +Completion characters are inserted into the line as if they +had been mapped to self-insert.
echo-control-characters (On)
When set to On, on operating systems that indicate they support it, -readline echoes a character corresponding to a signal generated from the +readline echoes a character corresponding to a signal generated from the keyboard.
editing-mode (emacs)
-Controls whether readline begins with a set of key bindings similar +Controls whether readline uses a set of key bindings similar to Emacs or vi. editing-mode @@ -7737,52 +8901,77 @@ or
If the show-mode-in-prompt variable is enabled, -this string is displayed immediately before the last line of the primary -prompt when emacs editing mode is active. The value is expanded like a -key binding, so the standard set of meta- and control prefixes and +this string is displayed immediately before the last line of the +primary prompt when emacs editing mode is active. +The value is expanded like a +key binding, so the standard set of meta- and control- prefixes and backslash escape sequences is available. -Use the \1 and \2 escapes to begin and end sequences of +The \1 and \2 escapes begin and end sequences of non-printing characters, which can be used to embed a terminal control sequence into the mode string.
enable-active-region (On)
-The point is the current cursor position, and mark refers -to a saved cursor position. -The text between the point and mark is referred to as the region. -When this variable is set to On, readline allows certain commands -to designate the region as active. -When the region is active, readline highlights the text in the region using -the value of the active-region-start-color, which defaults to the -string that enables +When this variable is set to On, readline allows certain commands +to designate the region as active. +When the region is active, readline +highlights the text in the region using the value of the +active-region-start-color + +variable, which defaults to the string that enables the terminal's standout mode. The active region shows the text inserted by bracketed-paste and any matching text found by incremental and non-incremental history searches.
enable-bracketed-paste (On)
-When set to On, readline configures the terminal to insert each +When set to On, readline configures the terminal to insert each paste into the editing buffer as a single string of characters, instead of treating each character as if it had been read from the keyboard. -This prevents readline from executing any editing commands bound to key +This is called bracketed-paste mode; +it prevents readline from executing any editing commands bound to key sequences appearing in the pasted text.
enable-keypad (Off)
-When set to On, readline will try to enable the application -keypad when it is called. Some systems need this to enable the -arrow keys. +When set to On, readline tries to enable the application +keypad when it is called. +Some systems need this to enable the arrow keys.
enable-meta-key (On)
-When set to On, readline will try to enable any meta modifier -key the terminal claims to support when it is called. On many terminals, -the meta key is used to send eight-bit characters. +When set to On, readline tries to enable any meta modifier +key the terminal claims to support. +On many terminals, the Meta key is used to send eight-bit characters; +this variable checks for the terminal capability that indicates the +terminal can enable and disable a mode that sets the eighth bit of a +character (0200) if the Meta key is held down when the character is +typed (a meta character).
expand-tilde (Off)
-If set to On, tilde expansion is performed when readline +If set to On, readline performs tilde expansion when it attempts word completion. +
force-meta-prefix (Off) + +
+If set to On, readline modifies its behavior when binding key +sequences containing \M- or Meta- +(see Key Bindings above) by converting a key sequence of the form +\M-C or Meta-C to the two-character sequence +ESC C (adding the meta prefix). +If +force-meta-prefix + +is set to Off (the default), +readline uses the value of the +convert-meta + +variable to determine whether to perform this conversion: +if convert-meta is On, +readline performs the conversion described above; +if it is Off, readline converts C to a meta character by +setting the eighth bit (0200).
history-preserve-point (Off)
@@ -7797,49 +8986,50 @@ If set to zero, any existing history entries are deleted and no new entries are saved. If set to a value less than zero, the number of history entries is not limited. -By default, the number of history entries is set to the value of the -HISTSIZE shell variable. -If an attempt is made to set history-size to a non-numeric value, -the maximum number of history entries will be set to 500. +By default, bash sets the maximum number of history entries to +the value of the HISTSIZE shell variable. +Setting history-size to a non-numeric value will set +the maximum number of history entries to 500.
horizontal-scroll-mode (Off)
-When set to On, makes readline use a single line for display, -scrolling the input horizontally on a single screen line when it -becomes longer than the screen width rather than wrapping to a new line. +Setting this variable to On makes readline use a single line +for display, scrolling the input horizontally on a single screen line +when it becomes longer than the screen width rather than wrapping to +a new line. This setting is automatically enabled for terminals of height 1.
input-meta (Off)
-If set to On, readline will enable eight-bit input (that is, -it will not strip the eighth bit from the characters it reads), -regardless of what the terminal claims it can support. The name -meta-flag - -is a synonym for this variable. -The default is Off, but readline will set it to On if the -locale contains eight-bit characters. -This variable is dependent on the LC_CTYPE locale category, and -may change if the locale is changed. -
isearch-terminators (``C-[C-J'') +If set to On, readline enables eight-bit input (that is, it +does not clear the eighth bit in the characters it reads), +regardless of what the terminal claims it can support. +The default is Off, but readline sets it to On +if the locale contains characters whose encodings may include bytes +with the eighth bit set. +This variable is dependent on the LC_CTYPE locale category, and +its value may change if the locale changes. +The name meta-flag is a synonym for input-meta. +
isearch-terminators (
+ The string of characters that should terminate an incremental search without subsequently executing the character as a command. If this variable has not been given a value, the characters -ESC and C-J will terminate an incremental search. +ESC and C-j terminate an incremental search.
keymap (emacs)
-Set the current readline keymap. The set of valid keymap names is +Set the current readline keymap. +The set of valid keymap names is emacs, emacs-standard, emacs-meta, emacs-ctlx, vi, vi-command, and vi-insert. -vi is equivalent to vi-command; emacs is -equivalent to emacs-standard. The default value is -emacs; - +vi is equivalent to vi-command; +emacs is equivalent to emacs-standard. +The default value is emacs; the value of editing-mode @@ -7847,41 +9037,42 @@ also affects the default keymap.
keyseq-timeout (500)
-Specifies the duration readline will wait for a character when reading an -ambiguous key sequence (one that can form a complete key sequence using -the input read so far, or can take additional input to complete a longer -key sequence). -If no input is received within the timeout, readline will use the shorter -but complete key sequence. +Specifies the duration readline will wait for a character when +reading an ambiguous key sequence +(one that can form a complete key sequence using the input read so far, +or can take additional input to complete a longer key sequence). +If readline does not receive any input within the timeout, +it uses the shorter but complete key sequence. The value is specified in milliseconds, so a value of 1000 means that -readline will wait one second for additional input. +readline will wait one second for additional input. If this variable is set to a value less than or equal to zero, or to a -non-numeric value, readline will wait until another key is pressed to +non-numeric value, readline waits until another key is pressed to decide which key sequence to complete.
mark-directories (On)
-If set to On, completed directory names have a slash -appended. +If set to On, completed directory names have a slash appended.
mark-modified-lines (Off)
-If set to On, history lines that have been modified are displayed +If set to On, readline displays history lines +that have been modified with a preceding asterisk (*).
mark-symlinked-directories (Off)
If set to On, completed names which are symbolic links to directories -have a slash appended (subject to the value of -mark-directories). +have a slash appended, subject to the value of mark-directories.
match-hidden-files (On)
-This variable, when set to On, causes readline to match files whose -names begin with a `.' (hidden files) when performing filename -completion. -If set to Off, the leading `.' must be -supplied by the user in the filename to be completed. +This variable, when set to On, forces readline to match files whose +names begin with a + +(hidden files) when performing filename completion. +If set to Off, the user must include the leading + +in the filename to be completed.
menu-complete-display-prefix (Off)
@@ -7891,35 +9082,48 @@ the list.
output-meta (Off)
-If set to On, readline will display characters with the +If set to On, readline displays characters with the eighth bit set directly rather than as a meta-prefixed escape sequence. -The default is Off, but readline will set it to On if the -locale contains eight-bit characters. -This variable is dependent on the LC_CTYPE locale category, and -may change if the locale is changed. +The default is Off, but readline sets it to On +if the locale contains characters whose encodings may include +bytes with the eighth bit set. +This variable is dependent on the LC_CTYPE locale category, and +its value may change if the locale changes.
page-completions (On)
-If set to On, readline uses an internal more-like pager +If set to On, readline uses an internal pager resembling +more(1) + to display a screenful of possible completions at a time. +
prefer-visible-bell + +
+See bell-style.
print-completions-horizontally (Off)
-If set to On, readline will display completions with matches +If set to On, readline displays completions with matches sorted horizontally in alphabetical order, rather than down the screen.
revert-all-at-newline (Off)
-If set to On, readline will undo all changes to history lines -before returning when accept-line is executed. By default, +If set to On, readline will undo all changes to history lines +before returning when executing accept-line. +By default, history lines may be modified and retain individual undo lists across calls to readline. +
search-ignore-case (Off) + +
+If set to On, readline performs incremental and non-incremental +history list searches in a case-insensitive fashion.
show-all-if-ambiguous (Off)
-This alters the default behavior of the completion functions. If -set to +This alters the default behavior of the completion functions. +If set to On, words which have more than one possible completion cause the @@ -7946,21 +9150,20 @@ The mode strings are user-settable (e.g., emacs-mode-string).
If set to On, this alters the default completion behavior when -inserting a single match into the line. It's only active when -performing completion in the middle of a word. If enabled, readline -does not insert characters from the completion that match characters -after point in the word being completed, so portions of the word -following the cursor are not duplicated. +inserting a single match into the line. +It's only active when performing completion in the middle of a word. +If enabled, readline does not insert characters from the completion +that match characters after point in the word being completed, +so portions of the word following the cursor are not duplicated.
vi-cmd-mode-string ((cmd))
If the show-mode-in-prompt variable is enabled, this string is displayed immediately before the last line of the primary prompt when vi editing mode is active and in command mode. -The value is expanded like a -key binding, so the standard set of meta- and control prefixes and -backslash escape sequences is available. -Use the \1 and \2 escapes to begin and end sequences of +The value is expanded like a key binding, so the standard set of +meta- and control- prefixes and backslash escape sequences is available. +The \1 and \2 escapes begin and end sequences of non-printing characters, which can be used to embed a terminal control sequence into the mode string.
vi-ins-mode-string ((ins)) @@ -7969,10 +9172,9 @@ sequence into the mode string. If the show-mode-in-prompt variable is enabled, this string is displayed immediately before the last line of the primary prompt when vi editing mode is active and in insertion mode. -The value is expanded like a -key binding, so the standard set of meta- and control prefixes and -backslash escape sequences is available. -Use the \1 and \2 escapes to begin and end sequences of +The value is expanded like a key binding, so the standard set of +meta- and control- prefixes and backslash escape sequences is available. +The \1 and \2 escapes begin and end sequences of non-printing characters, which can be used to embed a terminal control sequence into the mode string.
visible-stats (Off) @@ -7983,53 +9185,67 @@ by stat(2) is appended to the filename when listing possible completions.
-  + 

Readline Conditional Constructs

-Readline implements a facility similar in spirit to the conditional +Readline + +implements a facility similar in spirit to the conditional compilation features of the C preprocessor which allows key bindings and variable settings to be performed as the result -of tests. There are four parser directives used. +of tests. +There are four parser directives available.
-
$if
+
$if + +
The $if construct allows bindings to be made based on the editing mode, the terminal being used, or the application using -readline. The text of the test, after any comparison operator, -
 extends to the end of the line; +readline. +The text of the test, after any comparison operator, +extends to the end of the line; unless otherwise noted, no characters are required to isolate it.
-
mode
+
mode + +
The mode= form of the $if directive is used to test -whether readline is in emacs or vi mode. +whether readline is in emacs or vi mode. This may be used in conjunction with the set keymap command, for instance, to set bindings in the emacs-standard and emacs-ctlx keymaps only if -readline is starting out in emacs mode. -
term
+readline is starting out in emacs mode. +
term + +
The term= form may be used to include terminal-specific key bindings, perhaps to bind the key sequences output by the -terminal's function keys. The word on the right side of the +terminal's function keys. +The word on the right side of the = is tested against both the full name of the terminal and the portion -of the terminal name before the first -. This allows -sun +of the terminal name before the first -. +This allows +xterm to match both -sun +xterm and -sun-cmd, +xterm-256color, for instance. -
version
+
version + +
The version test may be used to perform comparisons against -specific readline versions. -The version expands to the current readline version. +specific readline versions. +The version expands to the current readline version. The set of comparison operators includes =, @@ -8049,51 +9265,81 @@ and The version number supplied on the right side of the operator consists of a major version number, an optional decimal point, and an optional -minor version (e.g., 7.1). If the minor version is omitted, it -is assumed to be 0. +minor version (e.g., 7.1). +If the minor version is omitted, it +defaults to 0. The operator may be separated from the string version and from the version number argument by whitespace. -
application
-The application construct is used to include -application-specific settings. Each program using the readline +
application + +
+The application construct is used to include +application-specific settings. +Each program using the readline library sets the application name, and an initialization file can test for a particular value. This could be used to bind key sequences to functions useful for -a specific program. For instance, the following command adds a +a specific program. +For instance, the following command adds a key sequence that quotes the current or previous word in bash: +

+

+
 $if Bash
 # Quote the current or previous word
-"\C-xq": "\eb\"\ef\""
+"
+\C-xq"
+: "
+\eb\"
+\ef\"
+"
+
 $endif
 
+
-
variable
-The variable construct provides simple equality tests for readline +
+
variable + +
+The variable construct provides simple equality tests for readline variables and values. The permitted comparison operators are =, ==, and !=. The variable name must be separated from the comparison operator by whitespace; the operator may be separated from the value on the right hand side by whitespace. -Both string and boolean variables may be tested. Boolean variables must be +String and boolean variables may be tested. +Boolean variables must be tested against the values on and off.
-
$endif
-This command, as seen in the previous example, terminates an -$if command. -
$else
+
$else + +
Commands in this branch of the $if directive are executed if the test fails. -
$include
+
$endif + +
+This command, as seen in the previous example, terminates an +$if command. +
$include + +
This directive takes a single filename as an argument and reads commands -and bindings from that file. For example, the following directive -would read /etc/inputrc: +and key bindings from that file. +For example, the following directive would read + +/etc/inputrc: + +

+

 $include  /etc/inputrc
@@ -8101,16 +9347,17 @@ would read /etc/inputrc:
 
 
- -  + 

Searching

-Readline provides commands for searching through the command history -(see +Readline + +provides commands for searching through the command history (see HISTORY -below) for lines containing a specified string. +below) +for lines containing a specified string. There are two search modes: incremental @@ -8121,49 +9368,68 @@ and Incremental searches begin before the user has finished typing the search string. -As each character of the search string is typed, readline displays +As each character of the search string is typed, readline displays the next entry from the history matching the string typed so far. An incremental search requires only as many characters as needed to find the desired history entry. +When using emacs editing mode, type C-r to +search backward in the history for a particular string. +Typing C-s searches forward through the history. The characters present in the value of the isearch-terminators variable are used to terminate an incremental search. -If that variable has not been assigned a value the Escape and -Control-J characters will terminate an incremental search. -Control-G will abort an incremental search and restore the original -line. +If that variable has not been assigned a value, +ESC and C-j terminate an incremental search. +C-g aborts an incremental search and restores the original line. When the search is terminated, the history entry containing the search string becomes the current line.

-To find other matching entries in the history list, type Control-S or -Control-R as appropriate. -This will search backward or forward in the history for the next +To find other matching entries in the history list, type C-r or +C-s as appropriate. +This searches backward or forward in the history for the next entry matching the search string typed so far. -Any other key sequence bound to a readline command will terminate -the search and execute that command. -For instance, a newline will terminate the search and accept +Any other key sequence bound to a readline command terminates +the search and executes that command. +For instance, a newline terminates the search and accepts the line, thereby executing the command from the history list. +A movement command will terminate the search, make the last line found +the current line, and begin editing.

-Readline remembers the last incremental search string. If two -Control-Rs are typed without any intervening characters defining a -new search string, any remembered search string is used. +Readline + +remembers the last incremental search string. +If two C-rs are typed without any intervening characters defining +a new search string, readline uses any remembered search string.

Non-incremental searches read the entire search string before starting -to search for matching history lines. The search string may be +to search for matching history entries. +The search string may be typed by the user or be part of the contents of the current line. -  + 

Readline Command Names

The following is a list of the names of the commands and the default key sequences to which they are bound. Command names without an accompanying key sequence are unbound by default. +

+ In the following descriptions, point refers to the current cursor position, and mark refers to a cursor position saved by the set-mark command. The text between the point and mark is referred to as the region. -  +Readline + +has the concept of an active region: +when the region is active, readline redisplay +highlights the region using the value of the +active-region-start-color + +variable. +The enable-active-region readline variable turns this on and off. +Several commands set the region to active; those are noted below. + 

Commands for Moving

@@ -8172,34 +9438,38 @@ The text between the point and mark is referred to as the region.
Move to the start of the current line. +This may also be bound to the Home key on some keyboards.
end-of-line (C-e)
Move to the end of the line. +This may also be bound to the End key on some keyboards.
forward-char (C-f)
Move forward a character. +This may also be bound to the right arrow key on some keyboards.
backward-char (C-b)
Move back a character. +This may also be bound to the left arrow key on some keyboards.
forward-word (M-f)
-Move forward to the end of the next word. Words are composed of -alphanumeric characters (letters and digits). +Move forward to the end of the next word. +Words are composed of alphanumeric characters (letters and digits).
backward-word (M-b)
Move back to the start of the current or previous word. Words are composed of alphanumeric characters (letters and digits). -
shell-forward-word +
shell-forward-word (M-C-f)
Move forward to the end of the next word. Words are delimited by non-quoted shell metacharacters. -
shell-backward-word +
shell-backward-word (M-C-b)
Move back to the start of the current or previous word. @@ -8208,16 +9478,19 @@ Words are delimited by non-quoted shell metacharacters.
Attempt to move point to the same physical screen column on the previous -physical screen line. This will not have the desired effect if the current -readline line does not take up more than one physical line or if point is not -greater than the length of the prompt plus the screen width. +physical screen line. +This will not have the desired effect if the current +readline line does not take up more than one physical line or if +point is not greater than the length of the prompt plus the screen width.
next-screen-line
Attempt to move point to the same physical screen column on the next -physical screen line. This will not have the desired effect if the current -readline line does not take up more than one physical line or if the length -of the current readline line is not greater than the length of the prompt +physical screen line. +This will not have the desired effect if the current +readline line does not take up more than one physical line or if +the length of the current readline line is +not greater than the length of the prompt plus the screen width.
clear-display (M-C-l) @@ -8231,7 +9504,7 @@ leaving the current line at the top of the screen. Clear the screen, then redraw the current line, leaving the current line at the top of the screen. -With an argument, refresh the current line without clearing the +With a numeric argument, refresh the current line without clearing the screen.
redraw-current-line @@ -8239,7 +9512,7 @@ screen. Refresh the current line. -  + 

Commands for Manipulating the History

@@ -8247,23 +9520,30 @@ Refresh the current line.
accept-line (Newline, Return)
-Accept the line regardless of where the cursor is. If this line is -non-empty, add it to the history list according to the state of the +Accept the line regardless of where the cursor is. +If this line is non-empty, add it to the history list according to the +state of the HISTCONTROL -variable. If the line is a modified history -line, then restore the history line to its original state. +and +HISTIGNORE + +variables. +If the line is a modified history line, +restore the history line to its original state.
previous-history (C-p)
Fetch the previous command from the history list, moving back in the list. +This may also be bound to the up arrow key on some keyboards.
next-history (C-n)
Fetch the next command from the history list, moving forward in the list. +This may also be bound to the down arrow key on some keyboards.
beginning-of-history (M-<)
@@ -8276,8 +9556,10 @@ entered.
operate-and-get-next (C-o)
-Accept the current line for execution and fetch the next line -relative to the current line from the history for editing. +Accept the current line for execution as if a +newline had been entered, +and fetch the next line relative to the current line from the history +for editing. A numeric argument, if supplied, specifies the history entry to use instead of the current line.
fetch-history @@ -8289,41 +9571,52 @@ Without an argument, move back to the first entry in the history list.
reverse-search-history (C-r)
-Search backward starting at the current line and moving `up' through -the history as necessary. This is an incremental search. +Search backward starting at the current line and moving + +through the history as necessary. +This is an incremental search. +This command sets the region to the matched text and activates the region.
forward-search-history (C-s)
-Search forward starting at the current line and moving `down' through -the history as necessary. This is an incremental search. +Search forward starting at the current line and moving + +through the history as necessary. +This is an incremental search. +This command sets the region to the matched text and activates the region.
non-incremental-reverse-search-history (M-p)
Search backward through the history starting at the current line using a non-incremental search for a string supplied by the user. +The search string may match anywhere in a history line.
non-incremental-forward-search-history (M-n)
-Search forward through the history using a non-incremental search for -a string supplied by the user. -
history-search-forward +Search forward through the history using a non-incremental search +for a string supplied by the user. +The search string may match anywhere in a history line. +
history-search-backward
-Search forward through the history for the string of characters +Search backward through the history for the string of characters between the start of the current line and the point. +The search string must match at the beginning of a history line. This is a non-incremental search. -
history-search-backward +This may be bound to the Page Up key on some keyboards. +
history-search-forward
-Search backward through the history for the string of characters +Search forward through the history for the string of characters between the start of the current line and the point. +The search string must match at the beginning of a history line. This is a non-incremental search. +This may be bound to the Page Down key on some keyboards.
history-substring-search-backward
Search backward through the history for the string of characters -between the start of the current line and the current cursor -position (the point). +between the start of the current line and the point. The search string may match anywhere in a history line. This is a non-incremental search.
history-substring-search-forward @@ -8342,10 +9635,14 @@ With an argument n, insert the nth word from the previous command (the words -in the previous command begin with word 0). A negative argument -inserts the nth word from the end of the previous command. -Once the argument n is computed, the argument is extracted -as if the "!n" history expansion had been specified. +in the previous command begin with word 0). +A negative argument inserts the nth word from the end of +the previous command. +Once the argument n is computed, +this uses the history expansion facilities to extract the +nth word, as if the + +history expansion had been specified.
yank-last-arg (M-., M-_)
@@ -8356,16 +9653,26 @@ Successive calls to yank-last-arg move back through the history list, inserting the last word (or the word specified by the argument to the first call) of each line in turn. Any numeric argument supplied to these successive calls determines -the direction to move through the history. A negative argument switches -the direction through the history (back or forward). -The history expansion facilities are used to extract the last word, -as if the "!$" history expansion had been specified. +the direction to move through the history. +A negative argument switches the direction through the history +(back or forward). +This uses the history expansion facilities to extract the +last word, as if the + +history expansion had been specified.
shell-expand-line (M-C-e)
-Expand the line as the shell does. This -performs alias and history expansion as well as all of the shell -word expansions. See +Expand the line by performing shell word expansions. +This performs alias and history expansion, +$'string' and $" +string" + quoting, +tilde expansion, parameter and variable expansion, arithmetic expansion, +command and process substitution, +word splitting, and quote removal. +An explicit argument suppresses command and process substitution. +See HISTORY EXPANSION @@ -8420,7 +9727,7 @@ commands. and emacs as the editor, in that order. -  + 

Commands for Changing Text

@@ -8429,10 +9736,10 @@ and emacs as the editor, in that order.
The character indicating end-of-file as set, for example, by -stty. +stty(1). If this character is read when there are no characters -on the line, and point is at the beginning of the line, readline +on the line, and point is at the beginning of the line, readline interprets it as the end of input and returns EOF. @@ -8444,10 +9751,12 @@ Delete the character at point. If this function is bound to the same character as the tty EOF character, as C-d commonly is, see above for the effects. +This may also be bound to the Delete key on some keyboards.
backward-delete-char (Rubout)
-Delete the character behind the cursor. When given a numeric argument, +Delete the character behind the cursor. +When given a numeric argument, save the deleted text on the kill ring.
forward-backward-delete-char @@ -8458,16 +9767,30 @@ deleted.
quoted-insert (C-q, C-v)
-Add the next character typed to the line verbatim. This is -how to insert characters like C-q, for example. +Add the next character typed to the line verbatim. +This is how to insert characters like C-q, for example.
tab-insert (C-v TAB)
Insert a tab character. -
self-insert (a, b, A, 1, !, ...) +
self-insert (a, b, A, 1, !, ...)
Insert the character typed. +
bracketed-paste-begin + +
+This function is intended to be bound to the + +escape +sequence sent by some terminals, and such a binding is assigned by default. +It allows readline to insert the pasted text as a single unit +without treating each character as if it had been read from the keyboard. +The pasted characters +are inserted as if each one was bound to self-insert instead of +executing any editing commands. +
+Bracketed paste sets the region to the inserted text and activates the region.
transpose-chars (C-t)
@@ -8480,39 +9803,55 @@ Negative arguments have no effect.
Drag the word before point past the word after point, -moving point over that word as well. +moving point past that word as well. If point is at the end of the line, this transposes the last two words on the line. +
shell-transpose-words (M-C-t) + +
+Drag the word before point past the word after point, +moving point past that word as well. +If the insertion point is at the end of the line, this transposes +the last two words on the line. +Word boundaries are the same as shell-forward-word and +shell-backward-word.
upcase-word (M-u)
-Uppercase the current (or following) word. With a negative argument, +Uppercase the current (or following) word. +With a negative argument, uppercase the previous word, but do not move point.
downcase-word (M-l)
-Lowercase the current (or following) word. With a negative argument, +Lowercase the current (or following) word. +With a negative argument, lowercase the previous word, but do not move point.
capitalize-word (M-c)
-Capitalize the current (or following) word. With a negative argument, +Capitalize the current (or following) word. +With a negative argument, capitalize the previous word, but do not move point.
overwrite-mode
-Toggle overwrite mode. With an explicit positive numeric argument, -switches to overwrite mode. With an explicit non-positive numeric -argument, switches to insert mode. This command affects only -emacs mode; vi mode does overwrite differently. +Toggle overwrite mode. +With an explicit positive numeric argument, switches to overwrite mode. +With an explicit non-positive numeric argument, switches to insert mode. +This command affects only emacs mode; +vi mode does overwrite differently. Each call to readline() starts in insert mode. +
In overwrite mode, characters bound to self-insert replace the text at point rather than pushing the text to the right. Characters bound to backward-delete-char replace the character -before point with a space. By default, this command is unbound. +before point with a space. +By default, this command is unbound, +but may be bound to the Insert key on some keyboards. -  + 

Killing and Yanking

@@ -8520,16 +9859,20 @@ before point with a space. By default, this command is unbound.
kill-line (C-k)
-Kill the text from point to the end of the line. +Kill the text from point to the end of the current line. +With a negative numeric argument, kill backward from the cursor to the +beginning of the line.
backward-kill-line (C-x Rubout)
-Kill backward to the beginning of the line. +Kill backward to the beginning of the current line. +With a negative numeric argument, kill forward from the cursor to the +end of the line.
unix-line-discard (C-u)
-Kill backward from point to the beginning of the line. -The killed text is saved on the kill-ring. +Kill backward from point to the beginning of the line, +saving the killed text on the kill-ring.
kill-whole-line @@ -8546,7 +9889,7 @@ Word boundaries are the same as those used by forward-word.
Kill the word behind point. Word boundaries are the same as those used by backward-word. -
shell-kill-word +
shell-kill-word (M-C-d)
Kill from point to the end of the current word, or if between @@ -8560,14 +9903,14 @@ Word boundaries are the same as those used by shell-backward-word.
unix-word-rubout (C-w)
-Kill the word behind point, using white space as a word boundary. -The killed text is saved on the kill-ring. +Kill the word behind point, using white space as a word boundary, +saving the killed text on the kill-ring.
unix-filename-rubout
Kill the word behind point, using white space and the slash character -as the word boundaries. -The killed text is saved on the kill-ring. +as the word boundaries, +saving the killed text on the kill-ring.
delete-horizontal-space (M-\)
@@ -8579,7 +9922,8 @@ Kill the text in the current region.
copy-region-as-kill
-Copy the text in the region to the kill buffer. +Copy the text in the region to the kill buffer, +so it can be yanked immediately.
copy-backward-word
@@ -8597,7 +9941,8 @@ Yank the top of the kill ring into the buffer at point.
yank-pop (M-y)
-Rotate the kill ring, and yank the new top. Only works following +Rotate the kill ring, and yank the new top. +Only works following yank or @@ -8605,16 +9950,17 @@ or -  + 

Numeric Arguments

-
digit-argument (M-0, M-1, ..., M--) +
digit-argument (M-0, M-1, ..., M--)
Add this digit to the argument already accumulating, or start a new -argument. M-- starts a negative argument. +argument. +M-- starts a negative argument.
universal-argument
@@ -8626,14 +9972,14 @@ If the command is followed by digits, executing again ends the numeric argument, but is otherwise ignored. As a special case, if this command is immediately followed by a -character that is neither a digit nor minus sign, the argument count -for the next command is multiplied by four. +character that is neither a digit nor minus sign, +the argument count for the next command is multiplied by four. The argument count is initially one, so executing this function the first time makes the argument count four, a second time makes the argument count sixteen, and so on.
-  + 

Completing

@@ -8644,34 +9990,45 @@ argument count sixteen, and so on. Attempt to perform completion on the text before point. Bash -attempts completion treating the text as a variable (if the -text begins with $), username (if the text begins with -~), hostname (if the text begins with @), or -command (including aliases and functions) in turn. If none -of these produces a match, filename completion is attempted. +attempts completion by first checking for any programmable +completions for the command word (see Programmable Completion below), +otherwise treating the text as a +variable (if the text begins with $), +username (if the text begins with ~), +hostname (if the text begins with @), or +command (including aliases, functions, and builtins) in turn. +If none of these produces a match, it falls back to filename completion.
possible-completions (M-?)
List the possible completions of the text before point. +When displaying completions, readline sets the number of columns used +for display to the value of completion-display-width, the value of +the shell variable +COLUMNS, + + +or the screen width, in that order.
insert-completions (M-*)
Insert all completions of the text before point that would have been generated by -possible-completions. +possible-completions, +separated by a space.
menu-complete
Similar to complete, but replaces the word to be completed with a single match from the list of possible completions. -Repeated execution of menu-complete steps through the list +Repeatedly executing menu-complete steps through the list of possible completions, inserting each match in turn. -At the end of the list of completions, the bell is rung +At the end of the list of completions, +menu-complete rings the bell (subject to the setting of bell-style) -and the original text is restored. +and restores the original text. An argument of n moves n positions forward in the list -of matches; a negative argument may be used to move backward -through the list. +of matches; a negative argument moves backward through the list. This command is intended to be bound to TAB, but is unbound by default.
menu-complete-backward @@ -8679,14 +10036,52 @@ by default.
Identical to menu-complete, but moves backward through the list of possible completions, as if menu-complete had been given a -negative argument. This command is unbound by default. +negative argument. +This command is unbound by default. +
export-completions + +
+Perform completion on the word before point as described above +and write the list of possible completions to readline's output +stream using the following format, writing information on separate lines: +
+ +
+
*
+ +the number of matches N; +
*
+the word being completed; +
*
+S:E, +where S and E are the start and end offsets of the word +in the readline line buffer; then +
*
+each match, one per line +
+ + +
+If there are no matches, the first line will be + +and this command does not print any output after the S:E. +If there is only a single match, this prints a single line containing it. +If there is more than one match, this prints the common prefix of the +matches, which may be empty, on the first line after the S:E, +then the matches on subsequent lines. +In this case, N will include the first line with the common prefix. +
+The user or application +should be able to accommodate the possibility of a blank line. +The intent is that the user or application reads N lines after +the line containing S:E to obtain the match list. +This command is unbound by default.
delete-char-or-list
Deletes the character under the cursor if not at the beginning or end of the line (like delete-char). -If at the end of the line, behaves identically to -possible-completions. +At the end of the line, it behaves identically to possible-completions. This command is unbound by default.
complete-filename (M-/) @@ -8731,7 +10126,8 @@ treating it as a hostname.
Attempt completion on the text before point, treating -it as a command name. Command completion attempts to +it as a command name. +Command completion attempts to match the text against aliases, reserved words, shell functions, shell builtins, and finally executable filenames, in that order. @@ -8744,7 +10140,7 @@ treating it as a command name.
Attempt completion on the text before point, comparing -the text against lines from the history list for possible +the text against history list entries for possible completion matches.
dabbrev-expand @@ -8762,7 +10158,7 @@ enclosed within braces so the list is available to the shell (see above). -  + 

Keyboard Macros

@@ -8788,7 +10184,7 @@ Print the last keyboard macro defined in a format suitable for the inputrc file. -  + 

Miscellaneous

@@ -8830,7 +10226,8 @@ Incremental undo, separately remembered for each line.
revert-line (M-r)
-Undo all changes made to this line. This is like executing the +Undo all changes made to this line. +This is like executing the undo command enough times to return the line to its initial state. @@ -8841,45 +10238,51 @@ Perform tilde expansion on the current word.
set-mark (C-@, M-<space>)
-Set the mark to the point. If a -numeric argument is supplied, the mark is set to that position. +Set the mark to the point. +If a numeric argument is supplied, set the mark to that position.
exchange-point-and-mark (C-x C-x)
-Swap the point with the mark. The current cursor position is set to -the saved position, and the old cursor position is saved as the mark. +Swap the point with the mark. +Set the current cursor position to the saved position, +then set the mark to the old cursor position.
character-search (C-])
-A character is read and point is moved to the next occurrence of that -character. A negative argument searches for previous occurrences. +Read a character and move point to the next occurrence of that character. +A negative argument searches for previous occurrences.
character-search-backward (M-C-])
-A character is read and point is moved to the previous occurrence of that -character. A negative argument searches for subsequent occurrences. +Read a character and move point to the previous occurrence of that character. +A negative argument searches for subsequent occurrences.
skip-csi-sequence
Read enough characters to consume a multi-key sequence such as those -defined for keys like Home and End. Such sequences begin with a -Control Sequence Indicator (CSI), usually ESC-[. If this sequence is -bound to "\[", keys producing such sequences will have no effect -unless explicitly bound to a readline command, instead of inserting -stray characters into the editing buffer. This is unbound by default, -but usually bound to ESC-[. +defined for keys like Home and End. +CSI sequences begin with a Control Sequence Indicator (CSI), usually +ESC [. + +If this sequence is bound to + +keys producing CSI sequences have no effect +unless explicitly bound to a readline command, +instead of inserting stray characters into the editing buffer. +This is unbound by default, but usually bound to +ESC [. +
insert-comment (M-#)
-Without a numeric argument, the value of the readline +Without a numeric argument, insert the value of the readline comment-begin -variable is inserted at the beginning of the current line. +variable at the beginning of the current line. If a numeric argument is supplied, this command acts as a toggle: if the characters at the beginning of the line do not match the value -of comment-begin, the value is inserted, otherwise -the characters in comment-begin are deleted from the beginning of -the line. +of comment-begin, insert the value; otherwise delete +the characters in comment-begin from the beginning of the line. In either case, the line is accepted as if a newline had been typed. The default value of comment-begin causes this command to make the current line @@ -8895,46 +10298,58 @@ Word boundaries are the same as those used by shell-forward-word.
glob-complete-word (M-g)
-The word before point is treated as a pattern for pathname expansion, -with an asterisk implicitly appended. This pattern is used to -generate a list of matching filenames for possible completions. +Treat the word before point as a pattern for pathname expansion, +with an asterisk implicitly appended, then use the pattern to +generate a list of matching file names for possible completions.
glob-expand-word (C-x *)
-The word before point is treated as a pattern for pathname expansion, -and the list of matching filenames is inserted, replacing the word. -If a numeric argument is supplied, an asterisk is appended before +Treat the word before point as a pattern for pathname expansion, +and insert the list of matching file names, replacing the word. +If a numeric argument is supplied, append a * before pathname expansion.
glob-list-expansions (C-x g)
-The list of expansions that would have been generated by +Display the list of expansions that would have been generated by glob-expand-word -is displayed, and the line is redrawn. -If a numeric argument is supplied, an asterisk is appended before +and redisplay the line. +If a numeric argument is supplied, append a * before pathname expansion.
dump-functions
-Print all of the functions and their key bindings to the -readline output stream. If a numeric argument is supplied, +Print all of the functions and their key bindings +to the readline output stream. +If a numeric argument is supplied, the output is formatted in such a way that it can be made part of an inputrc file.
dump-variables
-Print all of the settable readline variables and their values to the -readline output stream. If a numeric argument is supplied, +Print all of the settable readline variables and their values +to the readline output stream. +If a numeric argument is supplied, the output is formatted in such a way that it can be made part of an inputrc file.
dump-macros
-Print all of the readline key sequences bound to macros and the -strings they output. If a numeric argument is supplied, +Print all of the readline key sequences bound to macros and the +strings they output +to the readline output stream. +If a numeric argument is supplied, the output is formatted in such a way that it can be made part of an inputrc file. +
execute-named-command (M-x) + +
+Read a bindable readline command name from the input and execute the +function to which it's bound, as if the key sequence to which it was +bound appeared in the input. +If this function is supplied with a numeric argument, it passes that +argument to the function it executes.
display-shell-version (C-x C-v)
@@ -8943,81 +10358,102 @@ Display version information about the current instance of -  + 

Programmable Completion

-When word completion is attempted for an argument to a command for +When a user attempts word completion +for a command or an argument to a command for which a completion specification (a compspec) has been defined -using the complete builtin (see +using the complete builtin +(see SHELL BUILTIN COMMANDS -below), the programmable completion facilities are invoked. +below), +readline invokes the programmable completion facilities.

-First, the command name is identified. -If the command word is the empty string (completion attempted at the -beginning of an empty line), any compspec defined with -the -E option to complete is used. +First, bash identifies the command name. If a compspec has been defined for that command, the compspec is used to generate the list of possible completions for the word. -If the command word is a full pathname, a compspec for the full -pathname is searched for first. -If no compspec is found for the full pathname, an attempt is made to +If the command word is the empty string (completion attempted at the +beginning of an empty line), bash uses any compspec defined with +the -E option to complete. +The -I option to complete +indicates that the command word is the first non-assignment word +on the line, or after a command delimiter such as +; or |. +This usually indicates command name completion. +

+ +If the command word is a full pathname, bash +searches for a compspec for the full pathname first. +If there is no compspec for the full pathname, bash attempts to find a compspec for the portion following the final slash. -If those searches do not result in a compspec, any compspec defined with -the -D option to complete is used as the default. -If there is no default compspec, bash attempts alias expansion -on the command word as a final resort, and attempts to find a compspec -for the command word from any successful expansion. +If those searches do not result in a compspec, +or if there is no compspec for the command word, +bash uses any compspec defined with +the -D option to complete as the default. +If there is no default compspec, bash performs alias expansion +on the command word as a final resort, +and attempts to find a compspec for the command word +resulting from any successful expansion.

-Once a compspec has been found, it is used to generate the list of -matching words. -If a compspec is not found, the default bash completion as -described above under Completing is performed. +If a compspec is not found, bash performs its default completion as +described above under Completing. +Otherwise, once a compspec has been found, bash uses it to generate +the list of matching words.

-First, the actions specified by the compspec are used. -Only matches which are prefixed by the word being completed are -returned. +First, bash performs the actions specified by the compspec. +This only returns matches which are prefixes +of the word being completed. When the -f or -d -option is used for filename or directory name completion, the shell -variable +option is used for filename or directory name completion, +bash uses the shell variable FIGNORE -is used to filter the matches. +to filter the matches.

-Any completions specified by a pathname expansion pattern to the --G option are generated next. +Next, programmable completion generates matches +specified by a pathname expansion pattern +supplied as an argument to the +-G option. The words generated by the pattern need not match the word being completed. -The -GLOBIGNORE +Bash +uses the +FIGNORE -shell variable is not used to filter the matches, but the -FIGNORE +variable to filter the matches, but does not use the +GLOBIGNORE -variable is used. +shell variable.

-Next, the string specified as the argument to the -W option -is considered. +Next, completion considers +the string specified as the argument to the -W option. The string is first split using the characters in the IFS special variable as delimiters. -Shell quoting is honored. +This honors shell quoting within the string, in order to provide a +mechanism for the words to contain shell metacharacters or characters +in the value of +IFS. + + Each word is then expanded using brace expansion, tilde expansion, parameter and variable expansion, command substitution, and arithmetic expansion, @@ -9028,12 +10464,14 @@ as described above under The results are split using the rules described above under Word Splitting. The results of the expansion are prefix-matched against the word being -completed, and the matching words become the possible completions. +completed, and the matching words become possible completions.

-After these matches have been generated, any shell function or command -specified with the -F and -C options is invoked. -When the command or function is invoked, the +After these matches have been generated, +bash executes any shell function or command +specified with the -F and -C options. +When the command or function is invoked, bash +assigns values to the COMP_LINE, @@ -9047,9 +10485,10 @@ and COMP_TYPE -variables are assigned values as described above under -Shell Variables. -If a shell function is being invoked, the +variables as described above +under Shell Variables. +If a shell function is being invoked, bash +also sets the COMP_WORDS @@ -9057,21 +10496,23 @@ and COMP_CWORD -variables are also set. -When the function or command is invoked, -the first argument ($1) is the name of the command whose arguments are -being completed, +variables. +When the function or command is invoked, +the first argument ($1) is the name of the command whose arguments +are being completed, the second argument ($2) is the word being completed, and the third argument ($3) is the word preceding the word being completed on the current command line. -No filtering of the generated completions against the word being completed -is performed; the function or command has complete freedom in generating -the matches. +There is no filtering of the generated completions against the +word being completed; +the function or command has complete freedom in generating the matches +and they do not need to match a prefix of the word.

Any function specified with -F is invoked first. The function may use any of the shell facilities, including the -compgen builtin described below, to generate the matches. +compgen and compopt +builtins described below, to generate the matches. It must put the possible completions in the COMPREPLY @@ -9083,97 +10524,125 @@ Next, any command specified with the -C option is invoked in an environment equivalent to command substitution. It should print a list of completions, one per line, to the standard output. -Backslash may be used to escape a newline, if necessary. +Backslash will escape a newline, if necessary. +These are added to the set of possible completions.

-After all of the possible completions are generated, any filter -specified with the -X option is applied to the list. +After generating all of the possible completions, +bash applies any filter +specified with the -X option to the completions in the list. The filter is a pattern as used for pathname expansion; a & in the pattern is replaced with the text of the word being completed. A literal & may be escaped with a backslash; the backslash is removed before attempting a match. -Any completion that matches the pattern will be removed from the list. -A leading ! negates the pattern; in this case any completion -not matching the pattern will be removed. +Any completion that matches the pattern is removed from the list. +A leading ! negates the pattern; +in this case bash removes +any completion that does not match the pattern. If the nocasematch -shell option is enabled, the match is performed without regard to the case +shell option is enabled, +bash performs the match without regard to the case of alphabetic characters.

-Finally, any prefix and suffix specified with the -P and -S -options are added to each member of the completion list, and the result is -returned to the readline completion code as the list of possible -completions. +Finally, programmable completion adds +any prefix and suffix specified with the +-P and -S +options, respectively, to each completion, +and returns the result +to readline as the list of possible completions.

If the previously-applied actions do not generate any matches, and the -o dirnames option was supplied to complete when the -compspec was defined, directory name completion is attempted. +compspec was defined, bash attempts directory name completion.

If the -o plusdirs option was supplied to complete when the -compspec was defined, directory name completion is attempted and any -matches are added to the results of the other actions. +compspec was defined, bash attempts directory name completion and +adds any matches to the set of possible completions.

By default, if a compspec is found, whatever it generates is returned to the completion code as the full set of possible completions. -The default bash completions are not attempted, and the readline -default of filename completion is disabled. +The default bash completions and the readline +default of filename completion are disabled. If the -o bashdefault option was supplied to complete when -the compspec was defined, the bash default completions are attempted -if the compspec generates no matches. -If the -o default option was supplied to complete when the -compspec was defined, readline's default completion will be performed -if the compspec (and, if attempted, the default bash completions) -generate no matches. -

- -When a compspec indicates that directory name completion is desired, -the programmable completion functions force readline to append a slash -to completed names which are symbolic links to directories, subject to -the value of the mark-directories readline variable, regardless -of the setting of the mark-symlinked-directories readline variable. -

- -There is some support for dynamically modifying completions. This is -most useful when used in combination with a default completion specified -with complete -D. -It's possible for shell functions executed as completion -handlers to indicate that completion should be retried by returning an -exit status of 124. If a shell function returns 124, and changes +the compspec was defined, +and the compspec generates no matches, +bash attempts its default completions. +If the compspec and, if attempted, the default bash completions +generate no matches, +and the -o default option was supplied to +complete when the compspec was defined, +programmable completion performs readline's default completion. +

+ +The options supplied to complete and compopt +can control how readline treats the completions. +For instance, the -o fullquote option tells readline +to quote the matches as if they were filenames. +See the description of complete below +for details. +

+ +When a compspec indicates that it wants directory name completion, +the programmable completion functions force readline +to append a slash to completed names which are symbolic links +to directories, subject to the value of the +mark-directories readline variable, +regardless of the setting of the +mark-symlinked-directories readline variable. +

+ +There is some support for dynamically modifying completions. +This is most useful when used in combination with a default completion +specified with complete -D. +It's possible for shell functions executed as completion functions +to indicate that completion should be retried by returning an +exit status of 124. +If a shell function returns 124, and changes the compspec associated with the command on which completion is being attempted (supplied as the first argument when the function is executed), programmable completion restarts from the beginning, with an -attempt to find a new compspec for that command. This allows a set of -completions to be built dynamically as completion is attempted, rather than -being loaded all at once. +attempt to find a new compspec for that command. +This can be used to build a set of completions dynamically +as completion is attempted, rather than loading them all at once.

For instance, assuming that there is a library of compspecs, each kept in a file corresponding to the name of the command, the following default completion function would load completions dynamically: -

- -_completion_loader() -
+

+
+_completion_loader()
 {
+  . "
+/etc/bash_completion.d/$1.sh"
+ 
+\
 
-       . "/etc/bash_completion.d/$1.sh" >/dev/null 2>&1 && return 124

- +     +>/dev/null 2>&1 && return 124 } +complete -D -F _completion_loader +\
-complete -D -F _completion_loader -o bashdefault -o default
+     +-o bashdefault -o default +
-
-  + +
+ + 

HISTORY

When the @@ -9190,14 +10659,14 @@ The value of the
variable is used as the -number of commands to save in a history list. -The text of the last +number of commands to save in a history list: +the shell saves the text of the last HISTSIZE -commands (default 500) is saved. The shell -stores each command in the history list prior to parameter and -variable expansion (see +commands (default 500). +The shell stores each command in the history list prior to +parameter and variable expansion (see EXPANSION @@ -9212,23 +10681,32 @@ and

-On startup, the history is initialized from the file named by -the variable +On startup, bash initializes the history list +by reading history entries from the +file named by the HISTFILE -(default ~/.bash_history). -The file named by the value of -HISTFILE +variable (default + +~/.bash_history). + +That file is referred to as the history file. +The history file is truncated, if necessary, +to contain no more than the number of history entries +specified by the value of the +HISTFILESIZE -is truncated, if necessary, to contain no more than -the number of lines specified by the value of -HISTFILESIZE. +variable. +If +HISTFILESIZE -If HISTFILESIZE is unset, or set to null, a non-numeric value, +is unset, or set to null, a non-numeric value, or a numeric value less than zero, the history file is not truncated. +

+ When the history file is read, lines beginning with the history comment character followed immediately by a digit are interpreted as timestamps for the following history line. @@ -9237,11 +10715,15 @@ These timestamps are optionally displayed depending on the value of the variable. -When a shell with history enabled exits, the last +When present, history timestamps delimit history entries, making +multi-line entries possible. +

+ +When a shell with history enabled exits, bash copies the last $HISTSIZE -lines are copied from the history list to +entries from the history list to $HISTFILE. @@ -9256,57 +10738,60 @@ under SHELL BUILTIN COMMANDS -below), the lines are appended to the history file, -otherwise the history file is overwritten. +below), bash appends the entries to the history file, +otherwise it overwrites the history file. If HISTFILE -is unset, or if the history file is unwritable, the history is -not saved. +is unset or null, +or if the history file is unwritable, the history is not saved. +After saving the history, bash truncates the history file +to contain no more than +HISTFILESIZE + + +lines as described above. +

+ If the HISTTIMEFORMAT -variable is set, time stamps are written to the history file, marked -with the history comment character, so -they may be preserved across shell sessions. +variable is set, the shell writes +the timestamp information +associated with each history entry to the history file, +marked with the history comment character, so +timestamps are preserved across shell sessions. This uses the history comment character to distinguish timestamps from other history lines. -After saving the history, the history file is truncated -to contain no more than -HISTFILESIZE +As above, when using +HISTTIMEFORMAT, -lines. If -HISTFILESIZE - - -is unset, or set to null, a non-numeric value, -or a numeric value less than zero, the history file is not truncated. +the timestamps delimit multi-line history entries.

-The builtin command +The fc -(see +builtin command (see SHELL BUILTIN COMMANDS -below) may be used to list or edit and re-execute a portion of -the history list. +below) will list or edit and re-execute a portion of the history list. The history -builtin may be used to display or modify the history list and +builtin can display or modify the history list and manipulate the history file. When using command-line editing, search commands are available in each editing mode that provide access to the history list.

-The shell allows control over which commands are saved on the history -list. The +The shell allows control over which commands are saved on the history list. +The HISTCONTROL @@ -9314,19 +10799,19 @@ and HISTIGNORE -variables may be set to cause the shell to save only a subset of the -commands entered. -The +variables are used to save only a subset of the commands entered. +If the cmdhist -shell option, if enabled, causes the shell to attempt to save each +shell option is enabled, the shell attempts to save each line of a multi-line command in the same history entry, adding semicolons where necessary to preserve syntactic correctness. The lithist -shell option causes the shell to save the command with embedded newlines -instead of semicolons. See the description of the +shell option modifies cmdhist by saving +the command with embedded newlines instead of semicolons. +See the description of the shopt builtin below under @@ -9334,16 +10819,18 @@ builtin below under for information on setting and unsetting shell options. -  + 

HISTORY EXPANSION

The shell supports a history expansion feature that is similar to the history expansion in csh. -This section describes what syntax features are available. This -feature is enabled by default for interactive shells, and can be -disabled using the +This section describes what syntax features are available. +

+ +History expansion is enabled by default for interactive shells, +and can be disabled using the +H option to the @@ -9353,8 +10840,10 @@ builtin command (see SHELL BUILTIN COMMANDS -below). Non-interactive shells do not perform history expansion -by default. +below). +Non-interactive shells do not perform history expansion by default, +but it can be enabled with +

History expansions introduce words from the history list into @@ -9365,21 +10854,35 @@ fix errors in previous commands quickly. History expansion is performed immediately after a complete line is read, before the shell breaks it into words, and is performed -on each line individually without taking quoting on previous lines into -account. +on each line individually. +The shell attempts to inform the history +expansion functions about quoting still in effect from previous lines. +

+ It takes place in two parts. -The first is to determine which line from the history list +The first is to determine which history list entry to use during substitution. -The second is to select portions of that line for inclusion into +The second is to select portions of that entry to include into the current one. -The line selected from the history is the event, -and the portions of that line that are acted upon are words. +

+ +The entry selected from the history is the event, +and the portions of that entry that are acted upon are words. Various modifiers are available to manipulate the selected words. -The line is broken into words in the same fashion as when reading input, +The entry is split into words in the same fashion as when reading input, so that several metacharacter-separated words surrounded by quotes are considered one word. +The event designator selects the event, the optional +word designator selects words from the event, and +various optional modifiers are available to manipulate the +selected words. +

+ History expansions are introduced by the appearance of the history expansion character, which is ! by default. +History expansions may appear anywhere in the input, but do not nest. +

+ Only backslash (\) and single quotes can quote the history expansion character, but the history expansion character is also treated as quoted if it immediately precedes the closing double quote @@ -9388,22 +10891,35 @@ in a double-quoted string. Several characters inhibit history expansion if found immediately following the history expansion character, even if it is unquoted: -space, tab, newline, carriage return, and =. -If the extglob shell option is enabled, ( will also -inhibit expansion. +space, tab, newline, carriage return, =, +and the other shell metacharacters defined above. +

+ +There is a special abbreviation for substitution, active when the +quick substitution character (described above under +histchars) + +is the first character on the line. +It selects the previous history list entry, using an event designator +equivalent to !!, +and substitutes one string for another in that entry. +It is described below under Event Designators. +This is the only history expansion that does not begin with the history +expansion character.

Several shell options settable with the shopt -builtin may be used to tailor the behavior of history expansion. +builtin will modify history expansion behavior +(see the description of the +shopt + +builtin below).and If the histverify -shell option is enabled (see the description of the -shopt - -builtin below), and +shell option is enabled, and readline is being used, history substitutions are not immediately passed to @@ -9418,18 +10934,20 @@ If is being used, and the histreedit -shell option is enabled, a failed history substitution will be reloaded +shell option is enabled, a failed history substitution is reloaded into the readline editing buffer for correction. +

+ The -p option to the history -builtin command may be used to see what a history expansion will +builtin command shows what a history expansion will do before using it. The -s @@ -9437,7 +10955,7 @@ The option to the history -builtin may be used to add commands to the end of the history list +builtin will add commands to the end of the history list without actually executing them, so that they are available for subsequent recall.

@@ -9452,11 +10970,14 @@ above under The shell uses the history comment character to mark history timestamps when writing the history file. -  + 

Event Designators

-An event designator is a reference to a command line entry in the -history list. +An event designator is a reference to an entry in the history list. +The event designator +consists of the portion of the word beginning with the history +expansion character and ending with the word designator if present, +or the end of the word. Unless the reference is absolute, events are relative to the current position in the history list.

@@ -9469,25 +10990,27 @@ position in the history list. Start a history substitution, except when followed by a blank, -newline, carriage return, = -or ( (when the extglob shell option is enabled using -the shopt builtin). +newline, carriage return, =, +or, when the extglob shell option is enabled using +the shopt builtin, (.

!n
-Refer to command line +Refer to history list entry n.
!-n
-Refer to the current command minus +Refer to the current entry minus n.
!!
-Refer to the previous command. This is a synonym for `!-1'. +Refer to the previous entry. +This is a synonym for +
!string
@@ -9506,19 +11029,21 @@ The trailing ? may be omitted if string is followed immediately by a newline. -If string is missing, the string from the most recent search is used; +If string is missing, this uses +the string from the most recent search; it is an error if there is no previous search string.
^string1^string2^
-Quick substitution. Repeat the previous command, replacing +Quick substitution. +Repeat the previous command, replacing string1 with string2. Equivalent to -``!!:s^string1^string2^'' + (see Modifiers below).
!# @@ -9526,10 +11051,12 @@ Equivalent to The entire command line typed so far. -  + 

Word Designators

Word designators are used to select desired words from the event. +They are optional; if the word designator isn't supplied, the history +expansion uses the entire event. A : @@ -9556,8 +11083,8 @@ Words are inserted into the current line separated by single spaces.
0 (zero)
-The zeroth word. For the shell, this is the command -word. +The zeroth word. +For the shell, this is the command word.
n
@@ -9565,30 +11092,41 @@ The nth word.
^
-The first argument. That is, word 1. +The first argument: word 1.
$
-The last word. This is usually the last argument, but will expand to the +The last word. +This is usually the last argument, but will expand to the zeroth word if there is only one word in the line.
%
-The first word matched by the most recent `?string?' search, +The first word matched by the most recent + +search, if the search string begins with a character that is part of a word. +By default, searches begin at the end of each line and proceed to the +beginning, so the first word matched is the one closest to the end of +the line.
x-y
-A range of words; `-y' abbreviates `0-y'. +A range of words; + +abbreviates +
*
-All of the words but the zeroth. This is a synonym -for `1-$'. It is not an error to use +All of the words but the zeroth. +This is a synonym for + +It is not an error to use * -if there is just one -word in the event; the empty string is returned in that case. +if there is just one word in the event; +it expands to the empty string in that case.
x*
@@ -9603,12 +11141,13 @@ If x is missing, it defaults to 0.

If a word designator is supplied without an event specification, the -previous command is used as the event. -  +previous command is used as the event, equivalent to !!. + 

Modifiers

-After the optional word designator, there may appear a sequence of -one or more of the following modifiers, each preceded by a `:'. +After the optional word designator, the expansion may include a +sequence of one or more of the following modifiers, each preceded by a + These modify, or edit, the word or words selected from the history event.

@@ -9617,11 +11156,11 @@ These modify, or edit, the word or words selected from the history event.

h
-Remove a trailing filename component, leaving only the head. +Remove a trailing pathname component, leaving only the head.
t
-Remove all leading filename components, leaving the tail. +Remove all leading pathname components, leaving the tail.
r
@@ -9649,8 +11188,8 @@ but break into words at blanks and newlines. -The q and x modifiers are mutually exclusive; the last one -supplied is used. +The q and x modifiers are mutually exclusive; +expansion uses the last one supplied.
s/old/new/
@@ -9664,19 +11203,19 @@ in the event line. Any character may be used as the delimiter in place of /. The final delimiter is optional if it is the last character of the event line. -The delimiter may be quoted in +A single backslash quotes the delimiter in old and -new +new. -with a single backslash. If & appears in +If & appears in new, -it is replaced by +it is replaced with old. -A single backslash will quote the &. +A single backslash quotes the &. If old @@ -9688,7 +11227,7 @@ the last string in a -!?string[?] +!?string[?] search. If @@ -9705,21 +11244,30 @@ Repeat the previous substitution.
g
-Cause changes to be applied over the entire event line. This is -used in conjunction with `:s' (e.g., `:gs/old/new/') -or `:&'. If used with -`:s', any delimiter can be used -in place of /, and the final delimiter is optional +Cause changes to be applied over the entire event line. +This is used in conjunction with + +(e.g., + +or + +If used with + +any delimiter can be used in place of /, +and the final delimiter is optional if it is the last character of the event line. An a may be used as a synonym for g.
G
-Apply the following `s' or `&' modifier once to each word -in the event line. +Apply the following + +or + +modifier once to each word in the event line. -  + 

SHELL BUILTIN COMMANDS

@@ -9745,6 +11293,7 @@ options interpret arguments beginning with - as invalid options and require -- to prevent this interpretation.

+

: [arguments]
@@ -9754,78 +11303,77 @@ No effect; the command does nothing beyond expanding and performing any specified redirections. The return status is zero. -
. filename [arguments]
+
. [-p path] filename [arguments]
-
source filename [arguments]
+
source [-p path] filename [arguments]
-Read and execute commands from +The . command (source) reads and execute commands from filename -in the current -shell environment and return the exit status of the last command -executed from +in the current shell environment and returns the exit status of the +last command executed from filename. -If -filename - -does not contain a slash, filenames in +
+If filename does not contain a slash, . searches for it. +If the -p option is supplied, . treats path +as a colon-separated list of directories in which to find filename; +otherwise, . uses the entries in PATH -are used to find the directory containing -filename, - -but filename does not need to be executable. -The file searched for in -PATH +to find the directory containing +filename. - -need not be executable. -When bash is not in posix mode, it searches -the current directory if no file is found in -PATH. +filename does not need to be executable. +When bash is not in posix mode, it searches +the current directory if filename is not found in +PATH, +but does not search the current directory if -p is supplied. If the sourcepath option to the shopt -builtin command is turned off, the -PATH +builtin command is turned off, . does not search +PATH. -is not searched. +
If any arguments are supplied, they become the positional -parameters when filename is executed. Otherwise the positional -parameters are unchanged. +parameters when filename is executed. +Otherwise the positional parameters are unchanged. +
If the -T option is enabled, . inherits any trap on DEBUG; if it is not, any DEBUG trap string is saved and restored around the call to ., and . unsets the DEBUG trap while it executes. If -T is not set, and the sourced file changes -the DEBUG trap, the new value is retained when . completes. -The return status is the status of the last command exited within -the script (0 if no commands are executed), and false if +the DEBUG trap, the new value persists after . completes. +The return status is the status of the last command executed from +filename (0 if no commands are executed), and non-zero if filename is not found or cannot be read.
alias [-p] [name[=value] ...]
-Alias with no arguments or with the +With no arguments or with the -p -option prints the list of aliases in the form +option, alias prints the list of aliases in the form alias name=value on standard output. -When arguments are supplied, an alias is defined for +When arguments are supplied, define an alias for each name whose value is given. A trailing space in value causes the next word to be -checked for alias substitution when the alias is expanded. +checked for alias substitution when the alias is expanded +during command parsing. For each name in the argument list for which no value -is supplied, the name and value of the alias is printed. -Alias returns true unless a name is given for which -no alias has been defined. +is supplied, print the name and value of the alias name. +alias returns true unless a name is given +(without a corresponding =value) +for which no alias has been defined.
bg [jobspec ...]
Resume each suspended job jobspec in the background, as if it had been started with @@ -9834,7 +11382,7 @@ had been started with If jobspec -is not present, the shell's notion of the current job is used. +is not present, the shell uses its notion of the current job. bg jobspec @@ -9842,12 +11390,13 @@ is not present, the shell's notion of the current job is used. returns 0 unless run when job control is disabled or, when run with job control enabled, any specified jobspec was not found or was started without job control. -
bind [-m keymap] [-lpsvPSVX]
+
bind [-m keymap] [-lsvSVX]
bind [-m keymap] [-q function] [-u function] [-r keyseq]
bind [-m keymap] -f filename
-
bind [-m keymap] -x keyseq:shell-command
+
bind [-m keymap] -x keyseq[:] shell-command
bind [-m keymap] keyseq:function-name
+
bind [-m keymap] -p|-P [readline-command]
bind [-m keymap] keyseq:readline-command
bind readline-command-line
@@ -9857,18 +11406,29 @@ Display current key and function bindings, bind a key sequence to a readline -function or macro, or set a +function or macro +or to a shell command, or set a readline variable. -Each non-option argument is a command as it would appear in a +Each non-option argument is a key binding or command as it would appear in a readline initialization file such as .inputrc, but each binding or command must be passed as a separate argument; -e.g., '"\C-x\C-r": re-read-init-file'. +e.g., '" +\C-x\C-r" +: re-read-init-file'. +In the following descriptions, output available to be re-read is formatted +as commands that would appear in a +readline + +initialization file or that would be supplied as individual arguments to a +bind + +command. Options, if supplied, have the following meanings:
@@ -9888,9 +11448,9 @@ names are vi-move, vi-command, and vi-insert. -vi is equivalent to vi-command (vi-move is also -a synonym); emacs is -equivalent to emacs-standard. +vi is equivalent to vi-command +(vi-move is also a synonym); +emacs is equivalent to emacs-standard.
-l
@@ -9899,16 +11459,24 @@ List the names of all readline functions.
Display readline function names and bindings in such a way -that they can be re-read. +that they can be +used as an argument to a subsequent +bind command or in a readline initialization file. +If arguments remain after option processing, bind treats +them as readline command names and restricts output to those names.
-P
List current readline function names and bindings. +If arguments remain after option processing, bind treats +them as readline command names and restricts output to those names.
-s
Display readline key sequences bound to macros and the strings -they output in such a way that they can be re-read. +they output in such a way that they can be used +as an argument to a subsequent bind command +or in a readline initialization file.
-S
@@ -9918,7 +11486,9 @@ they output.
Display readline variable names and values in such a way that they -can be re-read. +can be +used as an argument to a subsequent +bind command or in a readline initialization file.
-V
@@ -9930,20 +11500,29 @@ Read key bindings from filename.
-q function
-Query about which keys invoke the named function. +Display key sequences that invoke the named readline function.
-u function
-Unbind all keys bound to the named function. +Unbind all key sequences bound to the named readline function.
-r keyseq
Remove any current binding for keyseq. -
-x keyseq:shell-command +
-x keyseq[: ]shell-command
Cause shell-command to be executed whenever keyseq is entered. +The separator between keyseq and shell-command is either +whitespace or a colon optionally followed by whitespace. +If the separator is whitespace, shell-command +must be enclosed in double quotes and readline expands any of its +special backslash-escapes in shell-command before saving it. +If the separator is a colon, any enclosing double quotes are optional, and +readline does not expand the command string before saving it. +Since the entire key binding expression must be a single argument, it +should be enclosed in single quotes. When shell-command is executed, the shell sets the READLINE_LINE @@ -9958,7 +11537,7 @@ and variables to the current location of the insertion point and the saved insertion point (the mark), respectively. -The shell assigns any numeric argument the user supplied to the +The shell assigns any numeric argument the user supplied to the READLINE_ARGUMENT @@ -9980,12 +11559,13 @@ those new values will be reflected in the editing state.
List all key sequences bound to shell commands and the associated commands -in a format that can be reused as input. +in a format that can be reused as +an argument to a subsequent bind command.

-The return value is 0 unless an unrecognized option is given or an +The return value is 0 unless an unrecognized option is supplied or an error occurred.

@@ -10000,7 +11580,8 @@ Exit from within a or select -loop. If n is specified, break n levels. +loop. +If n is specified, break exits n enclosing loops. n must be >= 1. If @@ -10010,7 +11591,7 @@ is greater than the number of enclosing loops, all enclosing loops are exited. The return value is 0 unless n is not greater than or equal to 1.
builtin shell-builtin [arguments]
-Execute the specified shell builtin, passing it +Execute the specified shell builtin shell-builtin, passing it arguments, and return its exit status. @@ -10025,81 +11606,116 @@ is not a shell builtin command.
caller [expr]
Returns the context of any active subroutine call (a shell function or a script executed with the . or source builtins). +
Without expr, caller displays the line number and source filename of the current subroutine call. If a non-negative integer is supplied as expr, caller displays the line number, subroutine name, and source file corresponding -to that position in the current execution call stack. This extra -information may be used, for example, to print a stack trace. The -current frame is frame 0. +to that position in the current execution call stack. +This extra information may be used, for example, to print a stack trace. +The current frame is frame 0. +
The return value is 0 unless the shell is not executing a subroutine call or expr does not correspond to a valid position in the call stack. -
cd [-L|[-P [-e]] [-@]] [dir]
+
+
+cd [-L] [-@] [dir] +
cd -P [-e] [-@] [dir]
+ Change the current directory to dir. if dir is not supplied, the value of the HOME -shell variable is the default. +shell variable is used as dir. The variable CDPATH -defines the search path for the directory containing -dir: - -each directory name in +exists, +and dir does not begin with a slash (/), +cd uses it as a search path: +the shell searches each directory name in CDPATH -is searched for dir. +for dir. Alternative directory names in CDPATH -are separated by a colon (:). A null directory name in +are separated by a colon (:). +A null directory name in CDPATH -is the same as the current directory, i.e., ``.''. If -dir - -begins with a slash (/), -then -CDPATH +is the same as the current directory, i.e., - -is not used. The +
+The -P option causes cd to use the physical directory structure by resolving symbolic links while traversing dir and -before processing instances of .. in dir (see also the +before processing instances of + +.. + +in dir (see also the -P option to the set -builtin command); the +builtin command). +
+The -L -option forces symbolic links to be followed by resolving the link -after processing instances of .. in dir. -If .. appears in dir, it is processed by removing the +option forces cd to follow symbolic links by resolving the link +after processing instances of + +.. + +in dir. +If + +.. + +appears in dir, cd processes it by removing the immediately previous pathname component from dir, back to a slash -or the beginning of dir. +or the beginning of dir, +and verifying that the portion of dir it has processed to +that point is still a valid directory name after removing the pathname +component. +If it is not a valid directory name, cd returns a non-zero status. +If neither +-L + +nor +-P + +is supplied, +cd + +behaves as if +-L + +had been supplied. +
If the -e option is supplied with -P, -and the current working directory cannot be successfully determined -after a successful directory change, cd will return an unsuccessful -status. +and cd cannot successfully determine the current working directory +after a successful directory change, it returns a non-zero status. +
On systems that support it, the -@ option presents the extended attributes associated with a file as a directory. +
An argument of - @@ -10107,37 +11723,40 @@ is converted to $OLDPWD -before the directory change is attempted. -If a non-empty directory name from -CDPATH +before attempting the directory change. +
+If cd uses a non-empty directory name from +CDPATH, -is used, or if -- is the first argument, and the directory change is -successful, the absolute pathname of the new working directory is -written to the standard output. +or if - is the first argument, and the directory change is +successful, cd writes the absolute pathname of the new +working directory to the standard output. +
If the directory change is successful, cd sets the value of the PWD environment variable to the new directory name, and sets the OLDPWD environment variable to the value of the current working directory before the change. +
The return value is true if the directory was successfully changed; false otherwise.
command [-pVv] command [arg ...]
-Run +The command builtin runs command with args -suppressing the normal shell function lookup. +suppressing the normal shell function lookup for command. Only builtin commands or commands found in the PATH -are executed. If the +named command are executed. +If the -p -option is given, the search for +option is supplied, the search for command is performed using a default value for @@ -10145,83 +11764,111 @@ is performed using a default value for that is guaranteed to find all of the standard utilities. +
If either the -V or -v -option is supplied, a description of -command +option is supplied, command prints a description of +command. -is printed. The +The -v -option causes a single word indicating the command or filename +option displays a single word indicating the command or filename used to invoke -command +command; -to be displayed; the +the -V option produces a more verbose description. +
If the -V or -v -option is supplied, the exit status is 0 if +option is supplied, the exit status is zero if command -was found, and 1 if not. If neither option is supplied and -an error occurred or +was found, and non-zero if not. +If neither option is supplied and an error occurred or command -cannot be found, the exit status is 127. Otherwise, the exit status of the +cannot be found, the exit status is 127. +Otherwise, the exit status of the command builtin is the exit status of command. -
compgen [option] [word]
+
compgen [-V varname] [option] [word]
Generate possible completion matches for word according to the options, which may be any option accepted by the complete -builtin with the exception of -p and -r, and write -the matches to the standard output. +builtin with the exceptions of +-p, + +-r, + +-D, + +-E, + +and +-I, + +and write the matches to the standard output. +
+If the -V option is supplied, compgen stores the generated +completions into the indexed array variable varname instead of writing +them to the standard output. +
When using the -F or -C options, the various shell variables set by the programmable completion facilities, while available, will not have useful values. -

+

The matches will be generated in the same way as if the programmable completion code had generated them directly from a completion specification with the same flags. If word is specified, only those completions matching word -will be displayed. -

+will be displayed or stored. +

The return value is true unless an invalid option is supplied, or no matches were generated. -
complete [-abcdefgjksuv] [-o comp-option] [-DEI] [-A action] [-G globpat] [-W wordlist]
+
complete [-abcdefgjksuv] [-o comp-option] [-DEI] [-A action]
+
+ +[-G globpat] [-W wordlist] [-F function] [-C command]
-[-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] name [name ...] +[-X filterpat] [-P prefix] [-S suffix] name [name ...]
complete -pr [-DEI] [name ...]
Specify how arguments to each name should be completed. -If the -p option is supplied, or if no options are supplied, -existing completion specifications are printed in a way that allows -them to be reused as input. +
+If the -p option is supplied, or if no options or names +are supplied, print existing completion specifications +in a way that allows them to be reused as input. The -r option removes a completion specification for each name, or, if no names are supplied, all completion specifications. +
The -D option indicates that other supplied options and actions should -apply to the ``default'' command completion; that is, completion attempted +apply to the + +command completion; that is, completion attempted on a command for which no completion has previously been defined. The -E option indicates that other supplied options and actions should -apply to ``empty'' command completion; that is, completion attempted on a +apply to + +command completion; that is, completion attempted on a blank line. The -I option indicates that other supplied options and actions should apply to completion on the initial non-assignment word on the line, or after @@ -10232,12 +11879,12 @@ over -E, and both take precedence over -I. If any of -D, -E, or -I are supplied, any other name arguments are ignored; these completions only apply to the case specified by the option. -

-The process of applying these completion specifications when word completion -is attempted is described +

+The process of applying these completion specifications when +attempting word completion is described above under Programmable Completion. -

+

Other options, if specified, have the following meanings. The arguments to the -G, -W, and -X options (and, if necessary, the -P and -S options) @@ -10245,6 +11892,7 @@ should be quoted to protect them from expansion before the complete builtin is invoked. +
@@ -10262,7 +11910,7 @@ generates no matches.
default
-Use readline's default filename completion if the compspec generates +Use readline's default filename completion if the compspec generates no matches.
dirnames @@ -10271,30 +11919,36 @@ Perform directory name completion if the compspec generates no matches.
filenames
-Tell readline that the compspec generates filenames, so it can perform any -filename-specific processing (like adding a slash to directory names, +Tell readline that the compspec generates filenames, so it can perform +any filename-specific processing (such as adding a slash to directory names, quoting special characters, or suppressing trailing spaces). -Intended to be used with shell functions. +This is intended to be used with shell functions. +
fullquote + +
+Tell readline to quote all the completed words even if they are not +filenames.
noquote
-Tell readline not to quote the completed words if they are filenames +Tell readline not to quote the completed words if they are filenames (quoting filenames is the default).
nosort
-Tell readline not to sort the list of possible completions alphabetically. +Tell readline not to sort the list of possible completions +alphabetically.
nospace
-Tell readline not to append a space (the default) to words completed at -the end of the line. +Tell readline not to append a space (the default) to words completed +at the end of the line.
plusdirs
-After any matches defined by the compspec are generated, -directory name completion is attempted and any -matches are added to the results of the other actions. +After generating any matches defined by the compspec, +attempt directory name completion and add any +matches to the results of the other actions.
-A action
@@ -10305,7 +11959,8 @@ completions:
alias
-Alias names. May also be specified as -a. +Alias names. +May also be specified as -a.
arrayvar
@@ -10317,15 +11972,18 @@ Array variable names.
builtin
-Names of shell builtin commands. May also be specified as -b. +Names of shell builtin commands. +May also be specified as -b.
command
-Command names. May also be specified as -c. +Command names. +May also be specified as -c.
directory
-Directory names. May also be specified as -d. +Directory names. +May also be specified as -d.
disabled
@@ -10337,11 +11995,13 @@ Names of enabled shell builtins.
export
-Names of exported shell variables. May also be specified as -e. +Names of exported shell variables. +May also be specified as -e.
file
-File names. May also be specified as -f. +File and directory names, similar to readline's filename completion. +May also be specified as -f.
function
@@ -10349,7 +12009,8 @@ Names of shell functions.
group
-Group names. May also be specified as -g. +Group names. +May also be specified as -g.
helptopic
@@ -10365,11 +12026,13 @@ shell variable.
job
-Job names, if job control is active. May also be specified as -j. +Job names, if job control is active. +May also be specified as -j.
keyword
-Shell reserved words. May also be specified as -k. +Shell reserved words. +May also be specified as -k.
running
@@ -10377,7 +12040,8 @@ Names of running jobs, if job control is active.
service
-Service names. May also be specified as -s. +Service names. +May also be specified as -s.
setopt
@@ -10397,11 +12061,13 @@ Names of stopped jobs, if job control is active.
user
-User names. May also be specified as -u. +User names. +May also be specified as -u.
variable
-Names of all shell variables. May also be specified as -v. +Names of all shell variables. +May also be specified as -v.
-C command
@@ -10414,30 +12080,31 @@ environment. When the function is executed, the first argument ($1) is the name of the command whose arguments are being completed, -the second argument ($2) is the word being completed, -and the third argument ($3) is the word preceding the word being +the second argument ($2) is the word being completed, and +the third argument ($3) is the word preceding the word being completed on the current command line. -When it finishes, the possible completions are retrieved from the value -of the +When function finishes, +programmable completion retrieves +the possible completions from the value of the COMPREPLY array variable.
-G globpat
-The pathname expansion pattern globpat is expanded to generate +Expand the pathname expansion pattern globpat to generate the possible completions.
-P prefix
-prefix is added at the beginning of each possible completion +Add prefix to the beginning of each possible completion after all other options have been applied.
-S suffix
-suffix is appended to each possible completion +Append suffix to each possible completion after all other options have been applied.
-W wordlist
-The wordlist is split using the characters in the +Split the wordlist using the characters in the IFS -special variable as delimiters, and each resultant word is expanded. +special variable as delimiters, and expand each resulting word. Shell quoting is honored within wordlist, in order to provide a mechanism for the words to contain shell metacharacters or characters @@ -10446,7 +12113,7 @@ in the value of The possible completions are the members of the resultant list which -match the word being completed. +match a prefix of the word being completed.
-X filterpat
filterpat is a pattern as used for pathname expansion. It is applied to the list of possible completions generated by the @@ -10459,7 +12126,19 @@ case, any completion not matching filterpat is removed.

The return value is true unless an invalid option is supplied, an option -other than -p or -r is supplied without a name +other than +-p, + +-r, + +-D, + +-E, + +or +-I + +is supplied without a name argument, an attempt is made to remove a completion specification for a name for which no specification exists, or an error occurs adding a completion specification. @@ -10469,26 +12148,31 @@ an error occurs adding a completion specification. Modify completion options for each name according to the options, or for the currently-executing completion if no names are supplied. -If no options are given, display the completion options for each +If no options are supplied, display the completion options for each name or the current completion. The possible values of option are those valid for the complete builtin described above. +

The -D option indicates that other supplied options should -apply to the ``default'' command completion; that is, completion attempted -on a command for which no completion has previously been defined. -The -E option indicates that other supplied options should -apply to ``empty'' command completion; that is, completion attempted on a -blank line. -The -I option indicates that other supplied options should -apply to completion on the initial non-assignment word on the line, -or after a command delimiter such as ; or |, which is usually -command name completion. -

+apply to the + +command completion; +the -E option indicates that other supplied options should +apply to + +command completion; and +the -I option indicates that other supplied options should +apply to completion on the initial word on the line. +These are determined in the same way as the complete builtin. +

+If multiple options are supplied, the -D option takes precedence +over -E, and both take precedence over -I. +
The return value is true unless an invalid option is supplied, an attempt is made to modify the options for a name for which no completion specification exists, or an output error occurs.
continue [n]
-Resume the next iteration of the enclosing +continue resumes the next iteration of the enclosing for, while, @@ -10502,21 +12186,26 @@ loop. If n -is specified, resume at the nth enclosing loop. +is specified, bash resumes the nth enclosing loop. n -must be >= 1. If +must be >= 1. +If n -is greater than the number of enclosing loops, the last enclosing loop -(the ``top-level'' loop) is resumed. +is greater than the number of enclosing loops, the shell resumes +the last enclosing loop +(the + +loop). The return value is 0 unless n is not greater than or equal to 1.
declare [-aAfFgiIlnrtux] [-p] [name[=value] ...]
typeset [-aAfFgiIlnrtux] [-p] [name[=value] ...]
Declare variables and/or give them attributes. -If no names are given then display the values of variables. +If no names are given then display the values of variables +or functions. The -p @@ -10528,15 +12217,17 @@ When is used with name arguments, additional options, other than -f and -F, are ignored. +
When -p -is supplied without name arguments, it will display the attributes -and values of all variables having the attributes specified by the -additional options. -If no other options are supplied with -p, declare will display -the attributes and values of all shell variables. The -f option -will restrict the display to shell functions. +is supplied without name arguments, +declare will display the attributes and values +of all variables having the attributes specified by the additional options. +If no other options are supplied with -p, declare will +display the attributes and values of all shell variables. +The -f option restricts the display to shell functions. +
The -F @@ -10544,26 +12235,30 @@ option inhibits the display of function definitions; only the function name and attributes are printed. If the extdebug shell option is enabled using shopt, the source file name and line number where each name -is defined are displayed as well. The +is defined are displayed as well. +The -F option implies -f. +
The -g option forces variables to be created or modified at the global scope, even when declare is executed in a shell function. -It is ignored in all other cases. +It is ignored when declare is not executed in a shell function. +
The -I option causes local variables to inherit the attributes -(except the nameref attribute) +(except the nameref attribute) and value of any existing variable with the same name at a surrounding scope. If there is no existing variable, the local variable is initially unset. +
The following options can be used to restrict output to variables with the specified attribute or to give variables attributes: @@ -10589,11 +12284,12 @@ above).
-f
-Use function names only. +Each name refers to a shell function.
-i
-The variable is treated as an integer; arithmetic evaluation (see +The variable is treated as an integer; +arithmetic evaluation (see ARITHMETIC EVALUATION @@ -10620,7 +12316,8 @@ The nameref attribute cannot be applied to array variables.
-r
-Make names readonly. These names cannot then be assigned values +Make names readonly. +These names cannot then be assigned values by subsequent assignment statements or unset.
-t @@ -10638,16 +12335,21 @@ The lower-case attribute is disabled.
-x
-Mark names for export to subsequent commands via the environment. +Mark each name for export to subsequent commands via the environment.

-Using `+' instead of `-' -turns off the attribute instead, -with the exceptions that +a and +A +Using + +instead of + +turns off the specified +attribute instead, with the exceptions that +a and +A may not be used to destroy array variables and +r will not remove the readonly attribute. +

+ When used in a function, declare @@ -10665,10 +12367,11 @@ the variable is set to value. When using -a or -A and the compound assignment syntax to create array variables, additional attributes do not take effect until subsequent assignments. +

+ The return value is 0 unless an invalid option is encountered, an attempt is made to define a function using --f foo=bar, an attempt is made to assign a value to a readonly variable, an attempt is made to assign a value to an array variable without using the compound assignment syntax (see @@ -10685,7 +12388,7 @@ or an attempt is made to display a non-existent function with -f.

dirs [-clpv] [+n] [-n]
-Without options, displays the list of currently remembered directories. +Without options, display the list of currently remembered directories. The default display is on a single line with directory names separated by spaces. Directories are added to the list with the @@ -10696,6 +12399,8 @@ command; the command removes entries from the list. The current directory is always the first directory in the stack. +
+Options, if supplied, have the following meanings:
@@ -10738,29 +12443,32 @@ invalid option is supplied or n indexes beyond the end of the directory stack.
-
disown [-ar] [-h] [jobspec ... | pid ... ]
+
disown [-ar] [-h] [id ...]
Without options, remove each -jobspec +id from the table of active jobs. -If -jobspec - -is not present, and neither the -a nor the -r option -is supplied, the current job is used. -If the -h option is given, each -jobspec +Each id may be a job specification jobspec +or a process ID pid; +if id is a pid, +disown uses the job containing pid as jobspec. +
+If the -h option is supplied, +disown does not remove the jobs corresponding to each +id -is not removed from the table, but is marked so that +from the jobs table, +but rather marks them so the shell does not send SIGHUP -is not sent to the job if the shell receives a +to the job if the shell receives a SIGHUP. +
If no -jobspec +id is supplied, the -a @@ -10768,30 +12476,39 @@ is supplied, the option means to remove or mark all jobs; the -r -option without a -jobspec +option without an +id -argument restricts operation to running jobs. -The return value is 0 unless a -jobspec +argument removes or marks running jobs. +If no +id + +is supplied, and neither the -a nor the -r option +is supplied, disown removes or marks the current job. +
+The return value is 0 unless an +id does not specify a valid job.
echo [-neE] [arg ...]
Output the args, separated by spaces, followed by a newline. The return status is 0 unless a write error occurs. -If -n is specified, the trailing newline is -suppressed. If the -e option is given, interpretation of -the following backslash-escaped characters is enabled. The +If -n is specified, the trailing newline is not printed. +
+If the -e option is given, echo interprets +the following backslash-escaped characters. +The -E -option disables the interpretation of these escape characters, +option disables interpretation of these escape characters, even on systems where they are interpreted by default. -The xpg_echo shell option may be used to -dynamically determine whether or not echo expands these -escape characters by default. +The xpg_echo shell option determines +whether or not echo interprets any options +and expands these escape characters. echo does not interpret -- to mean the end of options. +
echo interprets the following escape sequences: @@ -10844,43 +12561,69 @@ backslash
\0nnn
-the eight-bit character whose value is the octal value nnn -(zero to three octal digits) +The eight-bit character whose value is the octal value nnn +(zero to three octal digits).
\xHH
-the eight-bit character whose value is the hexadecimal value HH -(one or two hex digits) +The eight-bit character whose value is the hexadecimal value HH +(one or two hex digits).
\uHHHH
-the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value -HHHH (one to four hex digits) +The Unicode (ISO/IEC 10646) character whose value is the hexadecimal value +HHHH (one to four hex digits).
\UHHHHHHHH
-the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value -HHHHHHHH (one to eight hex digits) +The Unicode (ISO/IEC 10646) character whose value is the hexadecimal value +HHHHHHHH (one to eight hex digits). -
+ +

+ +echo writes any unrecognized backslash-escaped characters unchanged. +

enable [-a] [-dnps] [-f filename] [name ...]
Enable and disable builtin shell commands. -Disabling a builtin allows a disk command which has the same name +Disabling a builtin allows an executable file which has the same name as a shell builtin to be executed without specifying a full pathname, -even though the shell normally searches for builtins before disk commands. -If -n is used, each name -is disabled; otherwise, -names are enabled. For example, to use the +even though the shell normally searches for builtins before files. +
+If -n is supplied, each name is disabled; otherwise, +names are enabled. +For example, to use the test -binary found via the +binary found using PATH instead of the shell builtin version, run -enable -n test. + +``enable -n test''. + + + + + + +
+If no name arguments are supplied, or if the +-p + +option is supplied, print a list of shell builtins. +With no other option arguments, the list consists of all enabled +shell builtins. +If -n is supplied, print only disabled builtins. +If -a is supplied, the list printed includes all builtins, with an +indication of whether or not each is enabled. +The -s option means to restrict the output to the +POSIX +special builtins. +
The -f @@ -10891,42 +12634,44 @@ from shared object filename, on systems that support dynamic loading. -Bash will use the value of the BASH_LOADABLES_PATH variable as a +If filename does not contain a slash, +Bash will use the value of the BASH_LOADABLES_PATH variable as a colon-separated list of directories in which to search for filename. -The default is system-dependent. +The default for BASH_LOADABLES_PATH is system-dependent, +and may include + +to force a search of the current directory. The -d -option will delete a builtin previously loaded with --f. +option will delete a builtin previously loaded with -f. +If -s is used with -f, the new builtin becomes a +POSIX +special builtin. +
+If no options are supplied and a name is not a shell builtin, +enable will attempt to load name from a shared +object named name, as if the command were + + +``enable -f name name''. + + -If no name arguments are given, or if the --p -option is supplied, a list of shell builtins is printed. -With no other option arguments, the list consists of all enabled -shell builtins. -If -n is supplied, only disabled builtins are printed. -If -a is supplied, the list printed includes all builtins, with an -indication of whether or not each is enabled. -If -s is supplied, the output is restricted to the POSIX -special builtins. -If no options are supplied and a name is not a shell builtin, -enable will attempt to load name from a shared object named -name, as if the command were -enable -f name name . + +
The return value is 0 unless a name is not a shell builtin or there is an error loading a new builtin from a shared object.
eval [arg ...]
-The args are read and concatenated together into a single -command. This command is then read and executed by the shell, and -its exit status is returned as the value of -eval. - +Concatenate the args together into a single command, separating +them with spaces. +Bash then reads and execute this command, and returns its exit status +as the return status of eval. If there are no args, @@ -10938,8 +12683,9 @@ returns 0. If command -is specified, it replaces the shell. -No new process is created. The +is specified, it replaces the shell without creating a new process. +command cannot be a shell builtin or function. +The arguments become the arguments to command. @@ -10959,13 +12705,15 @@ does. The option causes command -to be executed with an empty environment. If +to be executed with an empty environment. +If -a is supplied, the shell passes name as the zeroth argument to the executed command. +
If command @@ -10973,10 +12721,11 @@ cannot be executed for some reason, a non-interactive shell exits, unless the execfail -shell option -is enabled. In that case, it returns failure. -An interactive shell returns failure if the file cannot be executed. +shell option is enabled. +In that case, it returns a non-zero status. +An interactive shell returns a non-zero status if the file cannot be executed. A subshell exits unconditionally if exec fails. +
If command @@ -10984,20 +12733,19 @@ is not specified, any redirections take effect in the current shell, and the return status is 0. If there is a redirection error, the return status is 1.
exit [n]
-Cause the shell to exit -with a status of n. If +Cause the shell to exit with a status of n. +If n -is omitted, the exit status -is that of the last command executed. -A trap on +is omitted, the exit status is that of the last command executed. +Any trap on EXIT is executed before the shell terminates. -
export [-fn] [name[=word]] ...
+
export [-fn] [name[=value]] ...
-
export -p +
export -p [-f]
@@ -11005,28 +12753,35 @@ The supplied names are marked for automatic export to the environment of -subsequently executed commands. If the +subsequently executed commands. +If the -f option is given, the names refer to functions. +
+The +-n + +option unexports, or removes the export attribute, from each name. If no names -are given, or if the +are given, or if only the -p -option is supplied, a list -of names of all exported variables is printed. -The --n - -option causes the export property to be removed from each -name. -If a variable name is followed by =word, the value of -the variable is set to word. +option is supplied, +export displays a list of names of all exported +variables on the standard output. +Using -p and -f together displays exported functions. +The -p option displays output in a form that may be reused as input. +
+export allows the value of a variable to be set when it is exported +or unexported by following the variable name with =value. +This sets the value of the variable to value while modifying the +export attribute. export returns an exit status of 0 unless an invalid option is @@ -11038,6 +12793,8 @@ is supplied with a name that is not a function. +
false
+Does nothing; returns a non-zero status.
fc [-e ename] [-lnr] [first] [last]
fc -s [pat=rep] [cmd]
@@ -11058,17 +12815,25 @@ may be specified as a string (to locate the last command beginning with that string) or as a number (an index into the history list, where a negative number is used as an offset from the current command number). -When listing, a first or last of -0 is equivalent to -1 and -0 is equivalent to the current -command (usually the fc command); otherwise 0 is equivalent to -1 -and -0 is invalid. +
+When listing, a first or last of 0 is equivalent to -1 +and -0 is equivalent to the current command +(usually the fc command); +otherwise 0 is equivalent to -1 and -0 is invalid. If last is not specified, it is set to the current command for listing (so that -fc -l -10 + +``fc -l -10'' + + + + + + prints the last 10 commands) and to first @@ -11078,33 +12843,34 @@ If is not specified, it is set to the previous command for editing and -16 for listing. -

+

+If the +-l + +option is supplied, the commands are listed on the standard output. The -n option suppresses -the command numbers when listing. The +the command numbers when listing. +The -r option reverses the order of -the commands. If the --l - -option is given, -the commands are listed on -standard output. Otherwise, the editor given by +the commands. +
+Otherwise, fc invokes the editor named by ename -is invoked -on a file containing those commands. If +on a file containing those commands. +If ename -is not given, the -value of the +is not supplied, fc uses the value of the FCEDIT -variable is used, and +variable, and the value of EDITOR @@ -11113,31 +12879,29 @@ if FCEDIT -is not set. If neither variable is set, +is not set. +If neither variable is set, fc uses -vi +vi. -is used. When editing is complete, the edited commands are -echoed and executed. -

-In the second form, command is re-executed after each instance -of pat is replaced by rep. +When editing is complete, fc reads the file containing +the edited commands and echoes and executes them. +

+In the second form, fc re-executes command +after replacing each instance of pat with rep. Command is interpreted the same as first above. -A useful alias to use with this is +
+A useful alias to use with fc is -r='fc -s', so that typing -r cc runs the last command beginning with -cc and typing -r re-executes the last command. -

-If the first form is used, the return value is 0 unless an invalid +

+If the first form is used, the return value is zero unless an invalid option is encountered or first @@ -11145,19 +12909,17 @@ or last specify history lines out of range. -If the --e - -option is supplied, the return value is the value of the last -command executed or failure if an error occurs with the temporary -file of commands. If the second form is used, the return status -is that of the command re-executed, unless +When editing and re-executing a file of commands, +the return value is the value of the last command executed +or failure if an error occurs with the temporary file. +If the second form is used, the return status +is that of the re-executed command, unless cmd -does not specify a valid history line, in which case +does not specify a valid history entry, in which case fc -returns failure. +returns a non-zero status.
fg [jobspec]
Resume jobspec @@ -11166,7 +12928,7 @@ in the foreground, and make it the current job. If jobspec -is not present, the shell's notion of the current job is used. +is not present, fg uses the shell's notion of the current job. The return value is that of the command placed into the foreground, or failure if run when job control is disabled or, when run with job control enabled, if @@ -11176,10 +12938,11 @@ does not specify a valid job or jobspec specifies a job that was started without job control. -
getopts optstring name [arg ...]
+
getopts optstring name [arg ...]
getopts -is used by shell procedures to parse positional parameters. +is used by shell scripts and functions to parse positional parameters +and obtain options and their arguments. optstring contains the option characters to be recognized; if a character @@ -11187,6 +12950,7 @@ is followed by a colon, the option is expected to have an argument, which should be separated from it by white space. The colon and question mark characters may not be used as option characters. +
Each time it is invoked, getopts @@ -11206,13 +12970,15 @@ variable is initialized to 1 each time the shell or a shell script -is invoked. When an option requires an argument, +is invoked. +When an option requires an argument, getopts places that argument into the variable OPTARG. +
The shell does not reset OPTIND @@ -11221,17 +12987,16 @@ automatically; it must be manually reset between multiple calls to getopts -within the same shell invocation if a new set of parameters -is to be used. -

-When the end of options is encountered, getopts exits with a +within the same shell invocation to use a new set of parameters. +

+When it reaches the end of options, getopts exits with a return value greater than zero. OPTIND is set to the index of the first non-option argument, and name is set to ?. -

+

getopts normally parses the positional parameters, but if more arguments are @@ -11242,32 +13007,36 @@ values, getopts parses those instead. -

+

getopts -can report errors in two ways. If the first character of +can report errors in two ways. +If the first character of optstring -is a colon, +is a colon, getopts uses silent -error reporting is used. In normal operation, diagnostic messages -are printed when invalid options or missing option arguments are -encountered. +error reporting. +In normal operation, getopts prints diagnostic messages +when it encounters invalid options or missing option arguments. If the variable OPTERR -is set to 0, no error messages will be displayed, even if the first -character of +is set to 0, +getopts + +does not display any error messages, +even if the first character of optstring is not a colon. -

-If an invalid option is seen, +

+If getopts -places ? into +detects an invalid option, it places ? into name and, if not silent, @@ -11278,101 +13047,112 @@ prints an error message and unsets If getopts -is silent, -the option character found is placed in +is silent, it assigns the option character found to OPTARG -and no diagnostic message is printed. -

+and does not print a diagnostic message. +

If a required argument is not found, and getopts -is not silent, -a question mark (?) is placed in -name, - -OPTARG +is not silent, it sets the value of name to +a question mark (?), unsets +OPTARG, -is unset, and a diagnostic message is printed. +and prints a diagnostic message. If getopts -is silent, then a colon (:) is placed in -name - -and +is silent, it sets the value of name to a colon (:) +and sets OPTARG -is set to the option character found. -

+to the option character found. +

getopts returns true if an option, specified or unspecified, is found. It returns false if the end of options is encountered or an error occurs.
hash [-lr] [-p filename] [-dt] [name]
-Each time hash is invoked, +Each time hash is invoked, it remembers the full pathname of the command name -is determined by searching +as determined by searching the directories in -$PATH +$PATH. -and remembered. Any previously-remembered pathname is discarded. +Any previously-remembered pathname associated with name is discarded. If the -p -option is supplied, no path search is performed, and +option is supplied, hash uses filename -is used as the full filename of the command. +as the full pathname of the command. +
The -r option causes the shell to forget all remembered locations. +Assigning to the PATH variable also clears all hashed filenames. The -d option causes the shell to forget the remembered location of each name. +
If the -t -option is supplied, the full pathname to which each name corresponds -is printed. If multiple name arguments are supplied with -t, -the name is printed before the hashed full pathname. +option is supplied, hash prints the full pathname corresponding to +each name. +If multiple name arguments are supplied with -t, +hash prints the name before the corresponding hashed +full pathname. The -l -option causes output to be displayed in a format that may be reused as input. +option displays output in a format that may be reused as input. +
If no arguments are given, or if only -l is supplied, -information about remembered commands is printed. -The return status is true unless a +hash prints information about remembered commands. +The -t, -d, and -p options (the options that +act on the name arguments) are mutually exclusive. +Only one will be active. +If more than one is supplied, -t has higher priority than +-p, and both have higher priority than -d. +
+The return status is zero unless a name is not found or an invalid option is supplied.
help [-dms] [pattern]
-Display helpful information about builtin commands. If +Display helpful information about builtin commands. +If pattern is specified, help gives detailed help on all commands matching -pattern; +pattern -otherwise help for all the builtins and shell control structures -is printed. +as described below; +otherwise it displays a list of +all the builtins and shell compound commands. +
+Options, if supplied, have the follow meanings:
-
-
-d - +
+-d + Display a short description of each pattern
-m @@ -11383,50 +13163,81 @@ Display the description of each pattern in a manpage-like format
Display only a short usage synopsis for each pattern -
-

+

+ +
+If pattern contains pattern matching characters +(see +Pattern Matching + +above) +it's treated as a shell pattern and +help prints the description of each +help topic matching pattern. +
+If not, and pattern exactly matches the name of a help topic, +help prints the description +associated with that topic. +Otherwise, help performs prefix matching and +prints the descriptions of all matching help topics. +
The return status is 0 unless no command matches pattern. - -
history [n]
history -c
history -d offset
history -d start-end
history -anrw [filename]
-
history -p arg [arg ...]
-
history -s arg [arg ...]
+
history -p arg [arg ...]
+
history -s arg [arg ...]
-With no options, display the command -history list with line numbers. Lines listed -with a +With no options, display the command history list with numbers. +Entries prefixed with a * -have been modified. An argument of +have been modified. +An argument of n lists only the last n -lines. +entries. If the shell variable HISTTIMEFORMAT is set and not null, -it is used as a format string for strftime(3) to display -the time stamp associated with each displayed history entry. -No intervening blank is printed between the formatted time stamp -and the history line. -If filename is supplied, it is used as the -name of the history file; if not, the value of +it is used as a format string for +strftime(3) + +to display the time stamp associated with each displayed history entry. +If +history + +uses +HISTTIMEFORMAT, + + +it does not print an intervening space between the formatted time stamp +and the history entry. +
+If filename is supplied, history uses it as the +name of the history file; if not, it uses the value of +HISTFILE. + + +If filename is not supplied and HISTFILE -is used. Options, if supplied, have the following meanings: +is unset or null, the -a, -n, -r, and -w options +have no effect. +
+Options, if supplied, have the following meanings:
@@ -11434,6 +13245,7 @@ is used. Options, if supplied, have the following meanings:
Clear the history list by deleting all the entries. +This can be used with the other options to replace the history list.
-d offset
Delete the history entry at position offset. If offset is negative, it is interpreted as relative to one greater @@ -11448,32 +13260,33 @@ are interpreted as described above.
-a
-Append the ``new'' history lines to the history file. +Append the + +history lines to the history file. These are history lines entered since the beginning of the current bash session, but not already appended to the history file.
-n
-Read the history lines not already read from the history -file into the current history list. These are lines -appended to the history file since the beginning of the +Read the history lines not already read from the history file +and add them to the current history list. +These are lines appended to the history file since the beginning of the current bash session.
-r
-Read the contents of the history file -and append them to the current history list. +Read the history file and append its contents to the current history list.
-w
-Write the current history list to the history file, overwriting the -history file's contents. +Write the current history list to the history file, overwriting +the history file.
-p
Perform history substitution on the following args and display -the result on the standard output. -Does not store the results in the history list. +the result on the standard output, +without storing the results in the history list. Each arg must be quoted to disable normal history expansion.
-s @@ -11481,45 +13294,43 @@ Each arg must be quoted to disable normal history expansion. Store the args -in the history list as a single entry. The last command in the -history list is removed before the -args +in the history list as a single entry. +The last command in the +history list is removed before adding the +args. -are added. -
-

+

+
If the HISTTIMEFORMAT -variable is set, the time stamp information -associated with each history entry is written to the history file, -marked with the history comment character. +variable is set, history writes the time stamp information +associated with each history entry to the history file, +marked with the history comment character as described above. When the history file is read, lines beginning with the history comment character followed immediately by a digit are interpreted as timestamps for the following history entry. +
The return value is 0 unless an invalid option is encountered, an error occurs while reading or writing the history file, an invalid offset or range is supplied as an argument to -d, or the history expansion supplied as an argument to -p fails. - -
jobs [-lnprs] [ jobspec ... ]
jobs -x command [ args ... ]
-The first form lists the active jobs. The options have the following -meanings: +The first form lists the active jobs. +The options have the following meanings:
-l
-List process IDs -in addition to the normal information. +List process IDs in addition to the normal information.
-n
@@ -11528,8 +13339,7 @@ the user was last notified of their status.
-p
-List only the process ID of the job's process group -leader. +List only the process ID of the job's process group leader.
-r
@@ -11539,20 +13349,19 @@ Display only running jobs.
Display only stopped jobs. -
-

+

+
If jobspec -is given, output is restricted to information about that job. +is supplied, jobs restricts output to information about that job. The return status is 0 unless an invalid option is encountered or an invalid jobspec is supplied. -

- +

If the -x @@ -11569,30 +13378,30 @@ or args with the corresponding process group ID, and executes -command +command, passing it args, returning its exit status. - - -
kill [-s sigspec | -n signum | -sigspec] [pid | jobspec] ...
+
kill [-s sigspec | -n signum | -sigspec] id [ ... ]
kill -l|-L [sigspec | exit_status]
-Send the signal named by +Send the signal specified by sigspec or signum -to the processes named by -pid +to the processes named by each +id. -or -jobspec. +Each +id +may be a job specification jobspec +or a process ID pid. sigspec is either a case-insensitive signal name such as @@ -11610,29 +13419,40 @@ is a signal number. If sigspec -is not present, then -SIGTERM +is not supplied, then +kill + +sends +SIGTERM. -is assumed. -An argument of +
+The -l -lists the signal names. +option lists the signal names. If any arguments are supplied when -l -is given, the names of the signals corresponding to the arguments are -listed, and the return status is 0. +is given, +kill + +lists the names of the signals corresponding to the arguments, +and the return status is 0. The exit_status argument to -l is a number specifying either a signal number or the exit status of -a process terminated by a signal. +a process terminated by a signal; +if it is supplied, kill prints the name of the signal that caused +the process to terminate. +kill assumes that process exit statuses are greater than 128; +anything less than that is a signal number. The -L option is equivalent to -l. +
kill returns true if at least one signal was successfully sent, or false @@ -11641,7 +13461,7 @@ if an error occurs or an invalid option is encountered. Each arg -is an arithmetic expression to be evaluated (see +is evaluated as an arithmetic expression (see ARITHMETIC EVALUATION @@ -11653,12 +13473,15 @@ If the last evaluates to 0, let -returns 1; 0 is returned otherwise. +returns 1; otherwise +let + +returns 0.
local [option] [name[=value] ... | - ]
-For each argument, a local variable named +For each argument, create a local variable named name -is created, and assigned +and assign it value. The option can be any of the options accepted by declare. @@ -11669,20 +13492,25 @@ is used within a function, it causes the variable name to have a visible scope restricted to that function and its children. -If name is -, the set of shell options is made local to the function -in which local is invoked: shell options changed using the -set builtin inside the function are restored to their original values -when the function returns. -The restore is effected as if a series of set commands were executed -to restore the values that were in place before the function. -With no operands, +It is an error to use local -writes a list of local variables to the standard output. It is -an error to use +when not within a function. +
+If name is -, it makes the set of shell options +local to the function in which local is invoked: +any shell options changed using the set builtin inside +the function after the call to local are restored to their +original values when the function returns. +The restore is performed as if a series of set commands were +executed to restore the values that were in place before the function. +
+With no operands, local -when not within a function. The return status is 0 unless +writes a list of local variables to the standard output. +
+The return status is 0 unless local is used outside a function, an invalid @@ -11690,24 +13518,26 @@ is used outside a function, an invalid is supplied, or name is a readonly variable. -
logout +
logout [n]
-Exit a login shell. +Exit a login shell, +returning a status of n to the shell's parent.
mapfile [-d delim] [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] [array]
readarray [-d delim] [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] [array]
-Read lines from the standard input into the indexed array variable -array, - +Read lines from the standard input, or from file descriptor fd if the -u -option is supplied. +option is supplied, +into the indexed array variable +array. + The variable MAPFILE @@ -11720,7 +13550,7 @@ Options, if supplied, have the following meanings:
-d
-The first character of delim is used to terminate each input line, +Use the first character of delim to terminate each input line, rather than newline. If delim is the empty string, mapfile will terminate a line when it reads a NUL character. @@ -11730,7 +13560,8 @@ when it reads a NUL character. Copy at most count -lines. If count is 0, all lines are copied. +lines. +If count is 0, copy all lines.
-O
@@ -11759,7 +13590,8 @@ Read lines from file descriptor fd instead of the standard input. Evaluate callback -each time quantum lines are read. The -c option specifies +each time quantum lines are read. +The -c option specifies quantum.
-c @@ -11769,9 +13601,9 @@ Specify the number of lines read between each call to callback. - -

+ +

If -C @@ -11784,24 +13616,20 @@ array element to be assigned and the line to be assigned to that element as additional arguments. callback is evaluated after the line is read but before the array element is assigned. -

- +

If not supplied with an explicit origin, mapfile will clear array before assigning to it. -

- -mapfile returns successfully unless an invalid option or option +

+mapfile returns zero unless an invalid option or option argument is supplied, array is invalid or unassignable, or if array is not an indexed array. - -
popd [-n] [+n] [-n]
-Removes entries from the directory stack. +Remove entries from the directory stack. The elements are numbered from 0 starting at the first directory -listed by dirs. -With no arguments, popd -removes the top directory from the stack, and -changes to the new top directory. +listed by dirs, so popd is equivalent to + +With no arguments, popd removes the top directory from the stack, +and changes to the new top directory. Arguments, if supplied, have the following meanings:
@@ -11809,74 +13637,71 @@ Arguments, if supplied, have the following meanings:
-n
-Suppresses the normal change of directory when removing directories -from the stack, so that only the stack is manipulated. +Suppress the normal change of directory when removing directories +from the stack, only manipulate the stack.
+n
-Removes the nth entry counting from the left of the list +Remove the nth entry counting from the left of the list shown by dirs, starting with zero, from the stack. For example: -popd +0 removes the first directory, -popd +1 the second.
-n
-Removes the nth entry counting from the right of the list +Remove the nth entry counting from the right of the list shown by dirs, starting with zero. For example: -popd -0 removes the last directory, -popd -1 the next to last. -
-

+ +

If the top element of the directory stack is modified, and the -n option was not supplied, popd uses the cd builtin to change to the directory at the top of the stack. If the cd fails, popd returns a non-zero value. -

- +

Otherwise, popd -returns false if an invalid option is encountered, the directory stack -is empty, or a non-existent directory stack entry is specified. -

- +returns false if an invalid option is supplied, the directory stack +is empty, or n specifies a non-existent directory stack entry. +

If the popd command is successful, -bash runs +bash runs dirs to show the final contents of the directory stack, and the return status is 0. - -
printf [-v var] format [arguments]
Write the formatted arguments to the standard output under the control of the format. -The -v option causes the output to be assigned to the variable -var rather than being printed to the standard output. -

+The -v option assigns the output to the variable +var rather than printing it to the standard output. +

The format is a character string which contains three types of objects: plain characters, which are simply copied to standard output, character escape sequences, which are converted and copied to the standard output, and format specifications, each of which causes printing of the next successive argument. -In addition to the standard printf(1) format specifications, -printf interprets the following extensions: +In addition to the standard +printf(3) + +format characters +cCsSndiouxXeEfFgGaA, + +printf interprets the following additional format specifiers:
@@ -11892,6 +13717,10 @@ in the same way as echo -e.
causes printf to output the corresponding argument in a format that can be reused as shell input. +%q and %Q use the $'' quoting style if any characters +in the argument string require it, and backslash quoting otherwise. +If the format string uses the printf alternate form, these two +formats quote the argument string using single quotes.
%Q
@@ -11901,41 +13730,53 @@ before quoting it.
causes printf to output the date-time string resulting from using -datefmt as a format string for strftime(3). +datefmt as a format string for +strftime(3). + The corresponding argument is an integer representing the number of seconds since the epoch. -Two special argument values may be used: -1 represents the current -time, and -2 represents the time the shell was invoked. -If no argument is specified, conversion behaves as if -1 had been given. +This format specifier recognizes two special argument values: +-1 represents the current time, +and -2 represents the time the shell was invoked. +If no argument is specified, conversion behaves as if -1 had been supplied. This is an exception to the usual printf behavior. -
-

+

-The %b, %q, and %T directives all use the field width and precision +
+The %b, %q, and %T format specifiers all use the field width and precision arguments from the format specification and write that many bytes from (or use that wide a field for) the expanded argument, which usually contains more characters than the original. -

+

+The %n format specifier accepts a corresponding argument that is treated +as a shell variable name. +
+The %s and %c format specifiers accept an l (long) modifier, which forces +them to convert the argument string to a wide-character string and apply +any supplied field width and precision in terms of characters, not bytes. +The %S and %C format specifiers are equivalent to %ls and %lc, respectively. + + +
Arguments to non-string format specifiers are treated as C constants, except that a leading plus or minus sign is allowed, and if the leading -character is a single or double quote, the value is the ASCII value of -the following character. -

- +character is a single or double quote, the value is the numeric value of +the following character, using the current locale. +

The format is reused as necessary to consume all of the arguments. If the format requires more arguments than are supplied, the extra format specifications behave as if a zero value or null string, as appropriate, had been supplied. -The return value is zero on success, non-zero on failure. - - +The return value is zero on success, +non-zero if an invalid option is supplied or a write or assignment error +occurs.
pushd [-n] [+n] [-n]
pushd [-n] [dir]
-Adds a directory to the top of the directory stack, or rotates +Add a directory to the top of the directory stack, or rotate the stack, making the new top of the stack the current working directory. With no arguments, pushd exchanges the top two elements of @@ -11947,10 +13788,10 @@ Arguments, if supplied, have the following meanings:
-n
-Suppresses the normal change of directory when rotating or -adding directories to the stack, so that only the stack is manipulated. +Suppress the normal change of directory when rotating or +adding directories to the stack, only manipulate the stack.
+n
-Rotates the stack so that the nth directory +Rotate the stack so that the nth directory (counting from the left of the list shown by dirs, @@ -11968,38 +13809,34 @@ starting with zero) is at the top. Adds dir -to the directory stack at the top +to the directory stack at the top. - -

+ +

After the stack has been modified, if the -n option was not supplied, pushd uses the cd builtin to change to the directory at the top of the stack. If the cd fails, pushd returns a non-zero value. -

- +

Otherwise, if no arguments are supplied, pushd -returns 0 unless the directory stack is empty. +returns zero unless the directory stack is empty. When rotating the directory stack, pushd -returns 0 unless the directory stack is empty or -a non-existent directory stack element is specified. -

- +returns zero unless the directory stack is empty or +n specifies a non-existent directory stack element. +

If the pushd command is successful, -bash runs +bash runs dirs to show the final contents of the directory stack. - -
pwd [-LP]
Print the absolute pathname of the current working directory. The pathname printed contains no symbolic links if the @@ -12019,15 +13856,14 @@ option is used, the pathname printed may contain symbolic links. The return status is 0 unless an error occurs while reading the name of the current directory or an invalid option is supplied. -
read [-ers] [-a aname] [-d delim] [-i text] [-n nchars] [-N nchars] [-p prompt] [-t timeout] [-u fd] [name ...]
-One line is read from the standard input, or from the file descriptor +
read [-Eers] [-a aname] [-d delim] [-i text] [-n nchars] [-N nchars] [-p prompt] [-t timeout] [-u fd] [name ...]
+Read one line from the standard input, or from the file descriptor fd supplied as an argument to the -u option, -split into words as described +split it into words as described above under Word Splitting, -and the first word -is assigned to the first +and assign the first word to the first name, the second word to the second @@ -12040,17 +13876,19 @@ intervening delimiters are assigned to the last If there are fewer words read from the input stream than names, the remaining names are assigned empty values. -The characters in +The characters in the value of the IFS +variable are used to split the line into words using the same rules the shell uses for expansion (described above under Word Splitting). -The backslash character (\) may be used to remove any special -meaning for the next character read and for line continuation. +The backslash character (\) removes any special +meaning for the next character read and is used for line continuation. +
Options, if supplied, have the following meanings:
@@ -12058,8 +13896,7 @@ Options, if supplied, have the following meanings:
-a aname
-The words are assigned to sequential indices -of the array variable +The words are assigned to sequential indices of the array variable aname, starting at 0. @@ -12070,15 +13907,15 @@ Other name arguments are ignored.
-d delim
-The first character of delim is used to terminate the input line, +The first character of delim terminates the input line, rather than newline. If delim is the empty string, read will terminate a line when it reads a NUL character.
-e
-If the standard input -is coming from a terminal, +If the standard input is coming from a terminal, +read uses readline (see @@ -12087,32 +13924,54 @@ is coming from a terminal, above) -is used to obtain the line. -Readline uses the current (or default, if line editing was not previously -active) editing settings, but uses readline's default filename completion. +to obtain the line. +Readline uses the current +(or default, if line editing was not previously active) +editing settings, but uses readline's default filename completion. +
-E + +
+If the standard input is coming from a terminal, +read uses +readline + +(see +READLINE + + + +above) +to obtain the line. +Readline + +uses the current (or default, if line editing was not previously +active) editing settings, but uses bash's default completion, including +programmable completion.
-i text
If readline -is being used to read the line, text is placed into the editing -buffer before editing begins. +is being used to read the line, read places text into +the editing buffer before editing begins.
-n nchars
read returns after reading nchars characters rather than -waiting for a complete line of input, but honors a delimiter if fewer -than nchars characters are read before the delimiter. +waiting for a complete line of input, +unless it encounters EOF or read times out, +but honors a delimiter if it reads fewer +than nchars characters before the delimiter.
-N nchars
read returns after reading exactly nchars characters rather -than waiting for a complete line of input, unless EOF is encountered or -read times out. -Delimiter characters encountered in the input are +than waiting for a complete line of input, +unless it encounters EOF or read times out. +Any delimiter characters in the input are not treated specially and do not cause read to return until -nchars characters are read. +it has read nchars characters. The result is not split on the characters in IFS; the intent is that the variable is assigned exactly the characters read (with the exception of backslash; see the -r option below). @@ -12120,8 +13979,8 @@ that the variable is assigned exactly the characters read
Display prompt on standard error, without a -trailing newline, before attempting to read any input. The prompt -is displayed only if input is coming from a terminal. +trailing newline, before attempting to read any input, but +only if input is coming from a terminal.
-r
@@ -12132,63 +13991,61 @@ continuation.
-s
-Silent mode. If input is coming from a terminal, characters are -not echoed. +Silent mode. +If input is coming from a terminal, characters are not echoed.
-t timeout
-Cause read to time out and return failure if a complete line of -input (or a specified number of characters) -is not read within timeout seconds. +Cause read to time out and return failure if it does not read +a complete line of input (or a specified number of characters) +within timeout seconds. timeout may be a decimal number with a fractional portion following the decimal point. This option is only effective if read is reading input from a terminal, pipe, or other special file; it has no effect when reading from regular files. -If read times out, read saves any partial input read into -the specified variable name. +If read times out, it saves any partial input read into +the specified variable name, and the exit status is greater than 128. If timeout is 0, read returns immediately, without trying to read any data. -The exit status is 0 if input is available on the specified file descriptor, -or the read will return EOF, -non-zero otherwise. -The exit status is greater than 128 if the timeout is exceeded. +In this case, the exit status is 0 if input is available on the specified +file descriptor, or the read will return EOF, non-zero otherwise.
-u fd
-Read input from file descriptor fd. +Read input from file descriptor fd instead of the standard input. -
-

+ +

+Other than the case where delim is the empty string, read +ignores any NUL characters in the input. +
If no names -are supplied, the line read, +are supplied, read assigns the line read, without the ending delimiter but otherwise unmodified, -is assigned to the variable +to the variable REPLY. +
The exit status is zero, unless end-of-file is encountered, read times out (in which case the status is greater than 128), a variable assignment error (such as assigning to a readonly variable) occurs, or an invalid file descriptor is supplied as the argument to -u. - -
readonly [-aAf] [-p] [name[=word] ...]
The given names are marked readonly; the values of these names -may not be changed by subsequent assignment. +may not be changed by subsequent assignment or unset. If the -f -option is supplied, the functions corresponding to the -names are so -marked. +option is supplied, each name refers to a shell function. The -a @@ -12203,19 +14060,23 @@ takes precedence. If no name -arguments are given, or if the +arguments are supplied, or if the -p -option is supplied, a list of all readonly names is printed. +option is supplied, print a list of all readonly names. The other options may be used to restrict the output to a subset of the set of readonly names. The -p -option causes output to be displayed in a format that -may be reused as input. -If a variable name is followed by =word, the value of -the variable is set to word. +option displays output in a format that may be reused as input. +
+readonly allows the value of a variable to be set at the same time +the readonly attribute is changed by following the variable name with +=value. +This sets the value of the variable is to value while modifying +the readonly attribute. +
The return status is 0 unless an invalid option is encountered, one of the names @@ -12228,7 +14089,8 @@ is supplied with a that is not a function.
return [n]
-Causes a function to stop executing and return the value specified by +Stop executing a shell function or sourced file and return the value +specified by n to its caller. @@ -12236,17 +14098,17 @@ If n is omitted, the return status is that of the last command -executed in the function body. +executed. If return is executed by a trap handler, the last command used to determine the status is the last command executed before the trap handler. If return is executed during a DEBUG trap, the last command used to determine the status is the last command executed by the trap handler before return was invoked. -If +
+When return -is used outside a function, -but during execution of a script by the +is used to terminate execution of a script being executed by the . (source) command, it causes the shell to stop executing @@ -12257,23 +14119,26 @@ or the exit status of the last command executed within the script as the exit status of the script. If n is supplied, the return value is its least significant 8 bits. +
+Any command associated with the RETURN trap is executed +before execution resumes after the function or script. +
The return status is non-zero if return -is supplied a non-numeric argument, or -is used outside a +is supplied a non-numeric argument, or is used outside a function and not during execution of a script by . or source. -Any command associated with the RETURN trap is executed -before execution resumes after the function or script.
set [-abefhkmnptuvxBCEHPT] [-o option-name] [--] [-] [arg ...]
set [+abefhkmnptuvxBCEHPT] [+o option-name] [--] [-] [arg ...]
+
set -o
+
set +o
Without options, display the name and value of each shell variable in a format that can be reused as input for setting or resetting the currently-set variables. Read-only variables cannot be reset. -In posix mode, only shell variables are listed. +In posix mode, only shell variables are listed. The output is sorted according to the current locale. When options are specified, they set or unset shell attributes. Any arguments remaining after option processing are treated @@ -12282,8 +14147,7 @@ as values for the positional parameters and are assigned, in order, to $2, -... - +..., $n. Options, if specified, have the following meanings: @@ -12300,11 +14164,13 @@ subsequent commands.
Report the status of terminated background jobs -immediately, rather than before the next primary prompt. This is -effective only when job control is enabled. +immediately, rather than before the next primary prompt or after a +foreground command terminates. +This is effective only when job control is enabled.
-e
+ Exit immediately if a pipeline (which may consist of a single simple command), a list, @@ -12323,7 +14189,7 @@ command that fails is part of the command list immediately following a or until -keyword, +reserved word, part of the test following the if @@ -12337,7 +14203,8 @@ or || list except the command following the final && or ||, -any command in a pipeline but the last, +any command in a pipeline but the last +(subject to the state of the pipefail shell option), or if the command's return value is being inverted with !. @@ -12355,9 +14222,7 @@ separately (see above), and may cause subshells to exit before executing all the commands in the subshell. -

- - +

If a compound command or shell function executes in a context where -e is being ignored, none of the commands executed within the compound command or function body @@ -12367,6 +14232,7 @@ If a compound command or shell function sets -e while executing in a context where -e is ignored, that setting will not have any effect until the compound command or the command containing the function call completes. +
-f
@@ -12385,9 +14251,10 @@ those that precede the command name.
-m
-Monitor mode. Job control is enabled. This option is on -by default for interactive shells on systems that support -it (see +Monitor mode. +Job control is enabled. +This option is on by default for interactive shells on systems +that support it (see JOB CONTROL @@ -12475,7 +14342,14 @@ This option is on by default in interactive shells.
The effect is as if the shell command -IGNOREEOF=10 + + +``IGNOREEOF=10'' + + + + + had been executed (see @@ -12551,11 +14425,14 @@ This option is disabled by default.
posix
-Change the behavior of +Enable posix mode; +change the behavior of bash where the default operation differs -from the POSIX standard to match the standard (posix mode). +from the +POSIX +standard to match the standard. See SEE ALSO @@ -12587,23 +14464,23 @@ This also affects the editing interface used for read -e. Same as -x. -

If -o -is supplied with no option-name, the values of the current options are -printed. +is supplied with no option-name, +set prints the current shell option settings. If +o -is supplied with no option-name, a series of +is supplied with no option-name, +set prints a series of set -commands to recreate the current option settings is displayed on -the standard output. +commands to recreate the current option settings +on the standard output.

-p @@ -12612,7 +14489,7 @@ the standard output. Turn on privileged -mode. In this mode, the +mode. In this mode, the shell does not read the $ENV @@ -12620,7 +14497,7 @@ and $BASH_ENV -files are not processed, shell functions are not inherited from the +files, shell functions are not inherited from the environment, and the SHELLOPTS, @@ -12656,11 +14533,17 @@ Exit after reading and executing one command.
Treat unset variables and parameters other than the special -parameters "@" and "*", -or array variables subscripted with "@" or "*", -as an error when performing -parameter expansion. If expansion is attempted on an -unset variable or parameter, the shell prints an error message, and, +parameters + +and + +or array variables subscripted with + +or + +as an error when performing parameter expansion. +If expansion is attempted on an unset variable or parameter, +the shell prints an error message, and, if not interactive, exits with a non-zero status.
-v @@ -12676,7 +14559,7 @@ arithmetic for command, display the expanded value of followed by the command and its expanded arguments -or associated word list. +or associated word list, to the standard error.
-B
@@ -12700,13 +14583,14 @@ does not overwrite an existing file with the and <> -redirection operators. This may be overridden when -creating output files by using the redirection operator +redirection operators. +Using the redirection operator >| instead of ->. +> +will override this and force the creation of an output file.
-E
@@ -12719,8 +14603,8 @@ The ERR trap is normally not inherited in such cases. Enable ! -style history substitution. This option is on by -default when the shell is interactive. +style history substitution. +This option is on by default when the shell is interactive.
-P
@@ -12728,8 +14612,9 @@ If set, the shell does not resolve symbolic links when executing commands such as cd -that change the current working directory. It uses the -physical directory structure instead. By default, +that change the current working directory. +It uses the physical directory structure instead. +By default, bash follows the logical chain of directories when performing commands @@ -12745,24 +14630,24 @@ in such cases.
--
-If no arguments follow this option, then the positional parameters are -unset. Otherwise, the positional parameters are set to the +If no arguments follow this option, unset the positional parameters. +Otherwise, set the positional parameters to the args, even if some of them begin with a -.
-
-Signal the end of options, cause all remaining args to be -assigned to the positional parameters. The +Signal the end of options, and assign all remaining args to +the positional parameters. +The -x and -v options are turned off. -If there are no args, -the positional parameters remain unchanged. +If there are no args, the positional parameters remain unchanged.

@@ -12774,11 +14659,11 @@ the shell. The current set of options may be found in $-. -The return status is always true unless an invalid option is encountered. +The return status is always zero unless an invalid option is encountered.

shift [n]
-The positional parameters from n+1 ... are renamed to +Rename positional parameters from n+1 ... to $1 .... @@ -12816,14 +14701,16 @@ option is used, those available with the -o option to the set builtin command. +
With no options, or with the -p -option, a list of all settable options is displayed, with +option, display a list of all settable options, with an indication of whether or not each is set; -if optnames are supplied, the output is restricted to those options. -The -p option causes output to be displayed in a form that +if any optnames are supplied, the output is restricted to those options. +The -p option displays output in a form that may be reused as input. +
Other options have the following meanings:
@@ -12841,7 +14728,7 @@ Disable (unset) each optname.
Suppresses normal output (quiet mode); the return status indicates whether the optname is set or unset. -If multiple optname arguments are given with +If multiple optname arguments are supplied with -q, the return status is zero if all optnames are enabled; non-zero @@ -12884,21 +14771,30 @@ The list of shopt options is:

-

-
assoc_expand_once +
array_expand_once
-If set, the shell suppresses multiple evaluation of associative array -subscripts during arithmetic expression evaluation, while executing +If set, the shell suppresses multiple evaluation of +associative and indexed array subscripts +during arithmetic expression evaluation, while executing builtins that can perform variable assignments, and while executing builtins that perform array dereferencing. +
assoc_expand_once + +
+Deprecated; a synonym for array_expand_once.
autocd
If set, a command name that is the name of a directory is executed as if it were the argument to the cd command. This option is only used by interactive shells. +
bash_source_fullpath + +
+If set, filenames added to the BASH_SOURCE array variable are +converted to full pathnames (see Shell Variables above).
cdable_vars
@@ -12911,28 +14807,29 @@ value is the directory to change to.
cdspell
-If set, minor errors in the spelling of a directory component in a +If set, the cd -command will be corrected. -The errors checked for are transposed characters, -a missing character, and one character too many. -If a correction is found, the corrected filename is printed, +command attempts to correct +minor errors in the spelling of a directory component. +Minor errors include transposed characters, +a missing character, and one extra character. +If cd corrects the directory name, it prints the corrected filename, and the command proceeds. This option is only used by interactive shells.
checkhash
If set, bash checks that a command found in the hash -table exists before trying to execute it. If a hashed command no -longer exists, a normal path search is performed. +table exists before trying to execute it. +If a hashed command no longer exists, bash performs a normal path search.
checkjobs
If set, bash lists the status of any stopped and running jobs before -exiting an interactive shell. If any jobs are running, this causes -the exit to be deferred until a second exit is attempted without an -intervening command (see +exiting an interactive shell. +If any jobs are running, bash defers the exit until a second +exit is attempted without an intervening command (see JOB CONTROL @@ -12943,14 +14840,17 @@ The shell always postpones exiting if any jobs are stopped.
If set, bash checks the window size after each external (non-builtin) -command and, if necessary, updates the values of +command +and, if necessary, updates the values of LINES and -COLUMNS. +COLUMNS, +using the file descriptor associated with the standard error +if it is a terminal. This option is enabled by default.
cmdhist @@ -12959,8 +14859,8 @@ If set, bash attempts to save all lines of a multiple-line -command in the same history entry. This allows -easy re-editing of multi-line commands. +command in the same history entry. +This allows easy re-editing of multi-line commands. This option is enabled by default, but only has an effect if command history is enabled, as described @@ -12990,9 +14890,6 @@ under
compat44 -
-
compat50 -
These control aspects of the shell's compatibility mode @@ -13002,6 +14899,7 @@ These control aspects of the shell's compatibility mode below). +
complete_fullquote
@@ -13031,8 +14929,8 @@ If set, bash replaces directory names with the results of word expansion when performing -filename completion. This changes the contents of the readline editing -buffer. +filename completion. +This changes the contents of the readline editing buffer. If not set, bash @@ -13051,13 +14949,16 @@ if the directory name initially supplied does not exist. If set, bash -includes filenames beginning with a `.' in the results of pathname -expansion. +includes filenames beginning with a + +in the results of pathname expansion. The filenames -``.'' + +. and -``..'' + +.. must always be matched explicitly, even if dotglob @@ -13070,7 +14971,8 @@ If set, a non-interactive shell will not exit if it cannot execute the file specified as an argument to the exec -builtin command. An interactive shell does not exit if +builtin. +An interactive shell does not exit if exec fails. @@ -13088,8 +14990,7 @@ This option is enabled by default for interactive shells.
extdebug
-If set at shell invocation, -or in a shell startup file, +If set at shell invocation, or in a shell startup file, arrange to execute the debugger profile before the shell starts, identical to the --debugger option. If set after invocation, behavior intended for use by debuggers is enabled: @@ -13143,17 +15044,20 @@ subshells invoked with ( command ) inherit the
extglob
-If set, the extended pattern matching features described +If set, enable the extended pattern matching features described above under -Pathname Expansion are enabled. +Pathname Expansion.
extquote
-If set, $aqstringaq and $"string" quoting is +If set, $'string' and $" +string" + quoting is performed within ${parameter} expansions -enclosed in double quotes. This option is enabled by default. +enclosed in double quotes. +This option is enabled by default.
failglob
@@ -13170,7 +15074,8 @@ shell variable cause words to be ignored when performing word completion even if the ignored words are the only possible completions. See -SHELL VARIABLES +Shell Variables + above for a description of @@ -13187,9 +15092,9 @@ If set, range expressions used in pattern matching bracket expressions (see above) -behave as if in the traditional C locale when performing -comparisons. That is, the current locale's collating sequence -is not taken into account, so +behave as if in the traditional C locale when performing comparisons. +That is, pattern matching does not take +the current locale's collating sequence into account, so b will not collate between @@ -13203,13 +15108,14 @@ and upper-case and lower-case ASCII characters will collate together.
If set, pathname expansion will never match the filenames -``.'' + +. and -``..'', + +.., even if the pattern begins with a -``.''. This option is enabled by default.
globstar @@ -13239,7 +15145,7 @@ variable when the shell exits, rather than overwriting the file. If set, and readline -is being used, a user is given the opportunity to re-edit a +is being used, the user is given the opportunity to re-edit a failed history substitution.
histverify @@ -13248,8 +15154,9 @@ If set, and readline is being used, the results of history substitution are not immediately -passed to the shell parser. Instead, the resulting line is loaded into -the readline editing buffer, allowing further modification. +passed to the shell parser. +Instead, the resulting line is loaded into the readline editing buffer, +allowing further modification.
hostcomplete
@@ -13280,15 +15187,14 @@ to all jobs when an interactive login shell exits.
If set, command substitution inherits the value of the errexit option, instead of unsetting it in the subshell environment. -This option is enabled when posix mode is enabled. +This option is enabled when posix mode is enabled.
interactive_comments
-If set, allow a word beginning with -# - -to cause that word and all remaining characters on that -line to be ignored in an interactive shell (see +In an interactive shell, a word beginning with # +causes that word and all remaining characters on that +line to be ignored, as in a non-interactive shell +(see COMMENTS @@ -13313,14 +15219,16 @@ embedded newlines rather than using semicolon separators where possible.
If set, local variables inherit the value and attributes of a variable of the same name that exists at a previous scope before any new value is -assigned. The nameref attribute is not inherited. +assigned. +The nameref attribute is not inherited.
localvar_unset
If set, calling unset on local variables in previous function scopes marks them so subsequent lookups find them unset until that function -returns. This is identical to the behavior of unsetting local variables -at the current function scope. +returns. +This is identical to the behavior of unsetting local variables at the +current function scope.
login_shell
@@ -13335,8 +15243,9 @@ The value may not be changed.
If set, and a file that bash is checking for mail has been -accessed since the last time it was checked, the message ``The mail in -mailfile has been read'' is displayed. +accessed since the last time it was checked, +bash displays the message +
no_empty_cmd_completion
@@ -13346,12 +15255,11 @@ If set, and is being used, bash -will not attempt to search the +does not search PATH -for possible completions when -completion is attempted on an empty line. +for possible completions when completion is attempted on an empty line.
nocaseglob
@@ -13380,22 +15288,21 @@ or when filtering possible completions as part of programmable completion. If set, bash -encloses the translated results of $"..." quoting in single quotes -instead of double quotes. +encloses the translated results of +$ ... + +quoting in single quotes instead of double quotes. If the string is not translated, this has no effect.
nullglob
-If set, -bash - -allows patterns which match no -files (see +If set, pathname expansion patterns which match no files +(see Pathname Expansion above) -to expand to a null string, rather than themselves. +expand to nothing and are removed, rather than expanding to themselves.
patsub_replacement
@@ -13409,18 +15316,18 @@ This option is enabled by default.
progcomp
-If set, the programmable completion facilities (see +If set, enable the programmable completion facilities (see Programmable Completion -above) -are enabled. +above). This option is enabled by default.
progcomp_alias
If set, and programmable completion is enabled, bash treats a command name that doesn't have any completions as a possible alias and attempts -alias expansion. If it has an alias, bash attempts programmable +alias expansion. +If it has an alias, bash attempts programmable completion using the command word resulting from the expanded alias.
promptvars @@ -13463,7 +15370,8 @@ If set, the PATH -to find the directory containing the file supplied as an argument. +to find the directory containing the file supplied as an argument when +the -p option is not supplied. This option is enabled by default.
varredir_close @@ -13481,6 +15389,8 @@ instead of leaving them open when the command completes.
If set, the echo builtin expands backslash-escape sequences by default. +If the posix shell option is also enabled, echo does not +interpret any options.
@@ -13489,12 +15399,12 @@ Suspend the execution of this shell until it receives a SIGCONT -signal. A login shell, -or a shell without job control enabled, +signal. +A login shell, or a shell without job control enabled, cannot be suspended; the -f -option can be used to override this and force the suspension. +option will override this and force the suspension. The return status is 0 unless the shell is a login shell or job control is not enabled and @@ -13504,12 +15414,13 @@ is not supplied.
test expr
[ expr ]
+ Return a status of 0 (true) or 1 (false) depending on the evaluation of the conditional expression expr. Each operator and operand must be a separate argument. -Expressions are composed of the primaries described +Expressions are composed of the primaries described above under @@ -13518,13 +15429,11 @@ under test does not accept any options, nor does it accept and ignore an argument of -- as signifying the end of options. -

- - +

Expressions may be combined using the following operators, listed in decreasing order of precedence. The evaluation depends on the number of arguments; see below. -Operator precedence is used when there are five or more arguments. +test uses operator precedence when there are five or more arguments.
@@ -13539,7 +15448,7 @@ is false.
Returns the value of expr. -This may be used to override the normal precedence of operators. +This may be used to override normal operator precedence.
expr1 -a expr2
True if both expr1 @@ -13565,7 +15474,6 @@ expressions using a set of rules based on the number of arguments.

-

0 arguments
The expression is false. @@ -13607,7 +15515,6 @@ Otherwise, the expression is false. The following conditions are applied in the order listed. If the first argument is !, the result is the negation of the three-argument expression composed of the remaining arguments. -the two-argument test using the second and third arguments. If the first argument is exactly ( and the fourth argument is exactly ), the result is the two-argument test of the second and third arguments. @@ -13616,67 +15523,99 @@ precedence using the rules listed above.
5 or more arguments
The expression is parsed and evaluated according to precedence using the rules listed above. -

-

-When used with test or [, the < and > operators -sort lexicographically using ASCII ordering. -

+When the shell is in posix mode, or if the expression is part +of the [[ command, +the < and > operators sort using the +current locale. +If the shell is not in posix mode, the test and [ +commands sort lexicographically using ASCII ordering. +

+The historical operator-precedence parsing with 4 or more arguments can +lead to ambiguities when it encounters strings that look like primaries. +The +POSIX +standard has deprecated the -a and -o +primaries and enclosing expressions within parentheses. +Scripts should no longer use them. +It's much more reliable to restrict test invocations to a single primary, +and to replace uses of -a and -o with the shell's +&& and || list operators. +

times
Print the accumulated user and system times for the shell and -for processes run from the shell. The return status is 0. -
trap [-lp] [[arg] sigspec ...]
-The command -arg +for processes run from the shell. +The return status is 0. +
trap [-lpP] [[action] sigspec ...]
+The +action -is to be read and executed when the shell receives -signal(s) +is a command that is read and executed when the shell receives +any of the signals sigspec. If -arg +action is absent (and there is a single sigspec) or -, -each specified signal is -reset to its original disposition (the value it had -upon entrance to the shell). +each specified sigspec is +reset to the value it had when the shell was started. If -arg +action is the null string the signal specified by each sigspec is ignored by the shell and by the commands it invokes. -If -arg +
+If no arguments are supplied, +trap -is not present and +displays the actions associated with each trapped signal +as a set of trap commands +that can be reused as shell input to +restore the current signal dispositions. +If -p -has been supplied, then the trap commands associated with each +is given, +and +action + +is not present, +then trap displays the actions associated with each sigspec -are displayed. -If no arguments are supplied or if only --p +or, if none are supplied, for all trapped signals, +as a set of trap commands +that can be reused as shell input to +restore the current signal dispositions. +The +-P -is given, -trap +option behaves similarly, but displays only the actions +associated with each sigspec argument. +-P -prints the list of commands associated with each signal. +requires at least one sigspec argument. +The -P or -p options may be used +in a subshell environment (e.g., command substitution) and, as +long as they are used before trap is used to change a signal's +handling, will display the state of its parent's traps. +
The -l -option causes the shell to print a list of signal names and +option prints a list of signal names and their corresponding numbers. Each sigspec @@ -13688,9 +15627,9 @@ Signal names are case insensitive and the prefix is optional. -

- - +If -l is supplied with no sigspec arguments, it prints a +list of valid signal names. +

If a sigspec @@ -13698,8 +15637,8 @@ is EXIT -(0) the command -arg +(0), +action is executed on exit from the shell. If a @@ -13709,19 +15648,25 @@ is DEBUG, -the command -arg +action is executed before every simple command, for command, -case command, select command, every arithmetic for -command, and before the first command executes in a shell function (see +case command, select command, (( arithmetic command, +[[ conditional command, +arithmetic for command, and before the first command executes +in a shell function (see SHELL GRAMMAR above). -Refer to the description of the extdebug option to the -shopt builtin for details of its effect on the DEBUG trap. +Refer to the description of the extdebug shell option +(see +shopt + + +above) +for details of its effect on the DEBUG trap. If a sigspec @@ -13729,14 +15674,11 @@ is RETURN, -the command -arg +action is executed each time a shell function or a script executed with the . or source builtins finishes executing. -

- - +

If a sigspec @@ -13744,8 +15686,7 @@ is ERR, -the command -arg +action is executed whenever a pipeline (which may consist of a single simple @@ -13763,7 +15704,7 @@ command is part of the command list immediately following a or until -keyword, +reserved word, part of the test in an if @@ -13774,16 +15715,17 @@ or || list except the command following the final && or ||, -any command in a pipeline but the last, +any command in a pipeline but the last +(subject to the state of the pipefail shell option), or if the command's return value is being inverted using !. These are the same conditions obeyed by the errexit (-e) option. -

- - -Signals ignored upon entry to the shell cannot be trapped or reset. +

+When the shell is not interactive, +signals ignored upon entry to the shell cannot be trapped or reset. +Interactive shells permit trapping signals ignored on entry. Trapped signals that are not being ignored are reset to their original values in a subshell or subshell environment when one is created. The return status is false if any @@ -13793,12 +15735,14 @@ is invalid; otherwise trap returns true. +
true
+Does nothing, returns a 0 status.
type [-aftpP] name [name ...]
-With no options, -indicate how each +Indicate how each name would be interpreted if used as a command name. +
If the -t @@ -13820,26 +15764,27 @@ or if name -is an alias, shell reserved word, function, builtin, or disk file, +is an alias, shell reserved word, function, builtin, or executable file, respectively. If the name -is not found, then nothing is printed, and an exit status of false -is returned. +is not found, type prints nothing and returns a non-zero exit status. +
If the -p option is used, type -either returns the name of the disk file -that would be executed if +either returns the pathname of the executable file +that would be found by searching +$PATH + +for name -were specified as a command name, or nothing if -type -t name would not return file. @@ -13852,12 +15797,11 @@ option forces a search for each name, even if -type -t name would not return file. -If a command is hashed, +If name is present in the table of hashed commands, -p and @@ -13868,25 +15812,32 @@ first in PATH. +
If the -a option is used, type -prints all of the places that contain -an executable named +prints all of the places that contain a command named name. -This includes aliases and functions, -if and only if the --p - -option is not also used. -The table of hashed commands is not consulted +This includes aliases, reserved words, functions, and builtins, +but the path search options (-p and -P) +can be supplied to restrict the output to executable files. +type does not consult the table of hashed commands when using --a. +-a + +with +-p, +and only performs a +PATH + + +search for name. +
The -f @@ -13900,13 +15851,15 @@ any are not found.
ulimit [-HS] [-bcdefiklmnpqrstuvxPRT [limit]]
Provides control over the resources available to the shell and to -processes started by it, on systems that allow such control. -The -H and -S options specify that the hard or soft limit is -set for the given resource. +processes it starts, on systems that allow such control. +
+The -H and -S options specify whether +the hard or soft limit is set for the given resource. A hard limit cannot be increased by a non-root user once it is set; a soft limit may be increased up to the value of the hard limit. -If neither -H nor -S is specified, both the soft and hard -limits are set. +If neither -H nor -S is specified, +ulimit sets both the soft and hard limits. +
The value of limit @@ -13924,10 +15877,10 @@ no limit, respectively. If limit -is omitted, the current value of the soft limit of the resource is -printed, unless the -H option is given. When more than one -resource is specified, the limit name and unit, if appropriate, -are printed before the value. +is omitted, ulimit prints the current value of the soft limit of +the resource, unless the -H option is given. +When more than one resource is specified, the limit name and unit, +if appropriate, are printed before the value. Other options are interpreted as follows:
@@ -13935,93 +15888,96 @@ Other options are interpreted as follows:
-a
-All current limits are reported; no limits are set +Report all current limits; no limits are set.
-b
-The maximum socket buffer size +The maximum socket buffer size.
-c
-The maximum size of core files created +The maximum size of core files created.
-d
-The maximum size of a process's data segment +The maximum size of a process's data segment.
-e
-The maximum scheduling priority ("nice") +The maximum scheduling priority ( +
-f
-The maximum size of files written by the shell and its children +The maximum size of files written by the shell and its children.
-i
-The maximum number of pending signals +The maximum number of pending signals.
-k
-The maximum number of kqueues that may be allocated +The maximum number of kqueues that may be allocated.
-l
-The maximum size that may be locked into memory +The maximum size that may be locked into memory.
-m
-The maximum resident set size (many systems do not honor this limit) +The maximum resident set size (many systems do not honor this limit).
-n
The maximum number of open file descriptors (most systems do not -allow this value to be set) +allow this value to be set).
-p
-The pipe size in 512-byte blocks (this may not be set) +The pipe size in 512-byte blocks (this may not be set).
-q
-The maximum number of bytes in POSIX message queues +The maximum number of bytes in +POSIX +message queues.
-r
-The maximum real-time scheduling priority +The maximum real-time scheduling priority.
-s
-The maximum stack size +The maximum stack size.
-t
-The maximum amount of cpu time in seconds +The maximum amount of cpu time in seconds.
-u
-The maximum number of processes available to a single user +The maximum number of processes available to a single user.
-v
The maximum amount of virtual memory available to the shell and, on -some systems, to its children +some systems, to its children.
-x
-The maximum number of file locks +The maximum number of file locks.
-P
-The maximum number of pseudoterminals +The maximum number of pseudoterminals.
-R
-The maximum time a real-time process can run before blocking, in microseconds +The maximum time a real-time process can run before blocking, in microseconds.
-T
-The maximum number of threads +The maximum number of threads.

@@ -14029,15 +15985,18 @@ The maximum number of threads If limit -is given, and the +is supplied, and the -a option is not used, limit is the new value of the specified resource. -If no option is given, then +If no option is supplied, then -f -is assumed. Values are in 1024-byte increments, except for +is assumed. +

+ +Values are in 1024-byte increments, except for -t, which is in seconds; @@ -14073,27 +16032,27 @@ or an error occurs while setting a new limit.

umask [-p] [-S] [mode]
-The user file-creation mask is set to +Set the user file-creation mask to mode. If mode -begins with a digit, it -is interpreted as an octal number; otherwise -it is interpreted as a symbolic mode mask similar +begins with a digit, it is interpreted as an octal number; +otherwise it is interpreted as a symbolic mode mask similar to that accepted by chmod(1). If mode -is omitted, the current value of the mask is printed. +is omitted, umask prints the current value of the mask. The -S -option causes the mask to be printed in symbolic form; the -default output is an octal number. +option without a mode argument +prints the mask in a symbolic format; +the default output is an octal number. If the -p @@ -14101,14 +16060,15 @@ option is supplied, and mode is omitted, the output is in a form that may be reused as input. -The return status is 0 if the mode was successfully changed or if -no mode argument was supplied, and false otherwise. +The return status is zero if the mode was successfully changed or +if no mode argument was supplied, and non-zero otherwise.
unalias [-a] [name ...]
-Remove each name from the list of defined aliases. If +Remove each name from the list of defined aliases. +If -a -is supplied, all alias definitions are removed. The return -value is true unless a supplied +is supplied, remove all alias definitions. +The return value is true unless a supplied name is not a defined alias. @@ -14124,7 +16084,6 @@ option is given, each name refers to a shell variable, and that variable is removed. -Read-only variables may not be unset. If -f @@ -14140,11 +16099,13 @@ option is supplied, and name is a variable with the nameref attribute, name will be unset rather than the variable it references. -n has no effect if the -f option is supplied. +Read-only variables and functions may not be unset. +When variables or functions are removed, they are also removed +from the environment passed to subsequent commands. If no options are supplied, each name refers to a variable; if there is no variable by that name, a function with that name, if any, is unset. -Each unset variable or function is removed from the environment -passed to subsequent commands. +Some shell variables may not be unset. If any of BASH_ALIASES, @@ -14199,54 +16160,58 @@ or are unset, they lose their special properties, even if they are -subsequently reset. The exit status is true unless a +subsequently reset. +The exit status is true unless a name is readonly or may not be unset. -
wait [-fn] [-p varname] [id ...]
-Wait for each specified child process and return its termination status. -Each -id - -may be a process -ID or a job specification; if a job spec is given, all processes -in that job's pipeline are waited for. If -id - -is not given, +
wait [-fn] [-p varname] [id ...]
+Wait for each specified child process id and return the +termination status of the last id. +Each id may be a process ID pid +or a job specification jobspec; +if a jobspec is supplied, wait waits for all processes in the job. +
+If no options or ids are supplied, wait waits for all running background jobs and -the last-executed process substitution, if its process id is the same as -$!, +the last-executed process substitution, +if its process id is the same as $!, and the return status is zero. -If the -n option is supplied, -wait waits for a single job -from the list of ids or, if no ids are supplied, any job, +
+If the -n option is supplied, wait waits for any one of +the given ids or, +if no ids are supplied, any job or process substitution, to complete and returns its exit status. -If none of the supplied arguments is a child of the shell, or if no arguments -are supplied and the shell has no unwaited-for children, the exit status -is 127. -If the -p option is supplied, the process or job identifier of the job -for which the exit status is returned is assigned to the variable -varname named by the option argument. -The variable will be unset initially, before any assignment. -This is useful only when the -n option is supplied. +If none of the supplied ids is a child of the shell, +or if no ids are supplied and the shell has no unwaited-for children, +the exit status is 127. +
+If the -p option is supplied, wait assigns +the process or job identifier of the job +for which the exit status is returned to the +variable varname named by the option argument. +The variable, +which cannot be readonly, +will be unset initially, before any assignment. +This is useful only when used with the -n option. +
Supplying the -f option, when job control is enabled, -forces wait to wait for id to terminate before returning -its status, instead of returning when it changes status. -If -id - -specifies a non-existent process or job, the return status is 127. -If wait is interrupted by a signal, the return status will be greater +forces wait to wait for each id to terminate before +returning its status, instead of returning when it changes status. +
+If none of the ids specify one of the shell's active child +processes, the return status is 127. +If wait is interrupted by a signal, +any varname will remain unset, +and the return status will be greater than 128, as described under SIGNALS above. -Otherwise, the return status is the exit status of the last -process or job waited for. +Otherwise, the return status is the exit status of the last id. -  + 

SHELL COMPATIBILITY MODE

Bash-4.0 introduced the concept of a shell compatibility level, @@ -14261,17 +16226,18 @@ specified as a set of options to the shopt builtin ( and so on). There is only one current -compatibility level -- each option is mutually exclusive. +compatibility level - each option is mutually exclusive. The compatibility level is intended to allow users to select behavior from previous versions that is incompatible with newer versions -while they migrate scripts to use current features and -behavior. It's intended to be a temporary solution. +while they migrate scripts to use current features and behavior. +It's intended to be a temporary solution.

This section does not mention behavior that is standard for a particular -version (e.g., setting compat32 means that quoting the rhs of the regexp +version (e.g., setting compat32 means that quoting the right hand +side of the regexp matching operator quotes special regexp characters in the word, which is -default behavior in bash-3.2 and subsequent versions). +default behavior in bash-3.2 and subsequent versions).

If a user enables, say, compat32, it may affect the behavior of other @@ -14298,7 +16264,7 @@ corresponding to the compatNN option, like 42) determines the compatibility level.

-Starting with bash-4.4, Bash has begun deprecating older compatibility +Starting with bash-4.4, bash began deprecating older compatibility levels. Eventually, the options will be removed in favor of BASH_COMPAT. @@ -14306,12 +16272,13 @@ Eventually, the options will be removed in favor of

-Bash-5.0 is the final version for which there will be an individual shopt -option for the previous version. Users should use +Bash-5.0 was the final version for which there was an individual shopt +option for the previous version. BASH_COMPAT -on bash-5.0 and later versions. +is the only mechanism to control the compatibility level +in versions newer than bash-5.0.

The following table describes the behavior changes controlled by each @@ -14333,8 +16300,8 @@ and it is required for bash-5.1 and later versions.

*
-quoting the rhs of the [[ command's regexp matching operator (=~) -has no special effect +Quoting the rhs of the [[ command's regexp matching operator (=~) +has no special effect.
@@ -14343,11 +16310,9 @@ has no special effect
*
-interrupting a command list such as "a ; b ; c" causes the execution -of the next command in the list (in bash-4.0 and later versions, -the shell acts as if it received the interrupt, so -interrupting one command in a list aborts the execution of the -entire list) +The < and > operators to the [[ command do not +consider the current locale when comparing strings; they use ASCII +ordering.
@@ -14356,10 +16321,10 @@ entire list)
*
-the < and > operators to the [[ command do not +The < and > operators to the [[ command do not consider the current locale when comparing strings; they use ASCII ordering. -Bash versions prior to bash-4.1 use ASCII collation and +Bash versions prior to bash-4.1 use ASCII collation and strcmp(3); bash-4.1 and later use the current locale's collation sequence and @@ -14373,14 +16338,18 @@ bash-4.1 and later use the current locale's collation sequence and
*
-in posix mode, time may be followed by options and still be -recognized as a reserved word (this is POSIX interpretation 267) +In posix mode, time may be followed by options and still be +recognized as a reserved word (this is +POSIX +interpretation 267).
*
-in posix mode, the parser requires that an even number of single +In posix mode, the parser requires that an even number of single quotes occur in the word portion of a double-quoted parameter expansion and treats them specially, so that characters within the single quotes are considered quoted -(this is POSIX interpretation 221) +(this is +POSIX +interpretation 221).
@@ -14389,15 +16358,17 @@ the single quotes are considered quoted
*
-the replacement string in double-quoted pattern substitution does not -undergo quote removal, as it does in versions after bash-4.2 +The replacement string in double-quoted pattern substitution does not +undergo quote removal, as it does in versions after bash-4.2.
*
-in posix mode, single quotes are considered special when expanding +In posix mode, single quotes are considered special when expanding the word portion of a double-quoted parameter expansion and can be used to quote a closing brace or other special character -(this is part of POSIX interpretation 221); +(this is part of +POSIX +interpretation 221); in later versions, single quotes -are not special within double-quoted word expansions +are not special within double-quoted word expansions.
@@ -14406,20 +16377,15 @@ are not special within double-quoted word expansions
*
-the shell does not print a warning message if an attempt is made to -use a quoted compound assignment as an argument to declare -(e.g., declare -a foo=aq(1 2)aq). Later versions warn that this usage is -deprecated -
*
-word expansion errors are considered non-fatal errors that cause the +Word expansion errors are considered non-fatal errors that cause the current command to fail, even in posix mode (the default behavior is to make them fatal errors that cause the shell -to exit) +to exit).
*
-when executing a shell function, the loop state (while/until/etc.) +When executing a shell function, the loop state (while/until/etc.) is not reset, so break or continue in that function will break -or continue loops in the calling context. Bash-4.4 and later reset -the loop state to prevent this +or continue loops in the calling context. +Bash-4.4 and later reset the loop state to prevent this.
@@ -14428,7 +16394,7 @@ the loop state to prevent this
*
-the shell sets up the values used by +The shell sets up the values used by BASH_ARGV @@ -14437,16 +16403,16 @@ and so they can expand to the shell's positional parameters even if extended -debugging mode is not enabled +debugging mode is not enabled.
*
-a subshell inherits loops from its parent context, so break +A subshell inherits loops from its parent context, so break or continue will cause the subshell to exit. Bash-5.0 and later reset the loop state to prevent the exit
*
-variable assignments preceding builtins like export and readonly +Variable assignments preceding builtins like export and readonly that set attributes continue to affect variables with the same name in the calling environment even if the shell is not in posix -mode +mode.
@@ -14459,18 +16425,19 @@ Bash-5.1 changed the way $RANDOM -is generated to introduce slightly -more randomness. If the shell compatibility level is set to 50 or +is generated to introduce slightly more randomness. +If the shell compatibility level is set to 50 or lower, it reverts to the method from bash-5.0 and previous versions, so seeding the random number generator by assigning a value to RANDOM -will produce the same sequence as in bash-5.0 +will produce the same sequence as in bash-5.0.
*
If the command hash table is empty, bash versions prior to bash-5.1 printed an informational message to that effect, even when producing -output that can be reused as input. Bash-5.1 suppresses that message +output that can be reused as input. +Bash-5.1 suppresses that message when the -l option is supplied.
@@ -14483,13 +16450,71 @@ when the -l option is supplied. The unset builtin treats attempts to unset array subscripts @ and * differently depending on whether the array is indexed or associative, and differently than in previous versions. +
*
+Arithmetic commands ( +((...)) + +) and the expressions in an arithmetic for +statement can be expanded more than once. +
*
+Expressions used as arguments to arithmetic operators in the [[ +conditional command can be expanded more than once. +
*
+The expressions in substring parameter brace expansion can be +expanded more than once. +
*
+The expressions in the +$((...)) + +word expansion can be expanded more than once. +
*
+Arithmetic expressions used as indexed array subscripts can be +expanded more than once. +
*
+test -v, when given an argument of A[@], where A is +an existing associative array, will return true if the array has any set +elements. +Bash-5.2 will look for and report on a key named @. +
*
+The ${parameter[:]=value} word expansion will return +value, before any variable-specific transformations have been +performed (e.g., converting to lowercase). +Bash-5.2 will return the final value assigned to the variable. +
*
+Parsing command substitutions will behave as if extended globbing +(see the description of the +shopt + +builtin above) +is enabled, so that parsing a command substitution containing an extglob +pattern (say, as part of a shell function) will not fail. +This assumes the intent is to enable extglob before the command is executed +and word expansions are performed. +It will fail at word expansion time if extglob hasn't been +enabled by the time the command is executed. + + + +
compat52
+ +
+
+
*
+The test builtin uses its historical algorithm to parse parenthesized +subexpressions when given five or more arguments. +
*
+If the -p or -P option is supplied to the bind builtin, +bind treats any arguments remaining after option processing +as bindable command names, and +displays any key sequences bound to those commands, instead of treating +the arguments as key sequences to bind.
-  + 

RESTRICTED SHELL

@@ -14505,8 +16530,7 @@ is started with the name or the -r -option is supplied at invocation, -the shell becomes restricted. +option is supplied at invocation, the shell becomes restricted. A restricted shell is used to set up an environment more controlled than the standard shell. It behaves identically to @@ -14515,9 +16539,9 @@ It behaves identically to with the exception that the following are disallowed or not performed:
*
-changing directories with cd +Changing directories with cd.
*
-setting or unsetting the values of +Setting or unsetting the values of SHELL, @@ -14531,51 +16555,60 @@ setting or unsetting the values of or -BASH_ENV +BASH_ENV.
*
-specifying command names containing -/ +Specifying command names containing +/.
*
-specifying a filename containing a +Specifying a filename containing a / as an argument to the . -builtin command +builtin command. +
*
+Using the -p option to the +. + +builtin command to specify a search path.
*
-specifying a filename containing a slash as an argument to the +Specifying a filename containing a slash as an argument to the history -builtin command +builtin command.
*
-specifying a filename containing a slash as an argument to the +Specifying a filename containing a slash as an argument to the -p option to the hash -builtin command +builtin command.
*
-importing function definitions from the shell environment at startup +Importing function definitions from the shell environment at startup.
*
-parsing the value of +Parsing the values of +BASHOPTS + + +and SHELLOPTS -from the shell environment at startup +from the shell environment at startup.
*
-redirecting output using the >, >|, <>, >&, &>, and >> redirection operators +Redirecting output using the >, >|, <>, >&, &>, and >> redirection operators.
*
-using the +Using the exec -builtin command to replace the shell with another command +builtin command to replace the shell with another command.
*
-adding or deleting builtin commands with the +Adding or deleting builtin commands with the -f and @@ -14584,19 +16617,19 @@ and options to the enable -builtin command +builtin command.
*
-using the enable builtin command to enable disabled shell builtins +Using the enable builtin command to enable disabled shell builtins.
*
-specifying the +Specifying the -p option to the command -builtin command +builtin command.
*
-turning off restricted mode with +Turning off restricted mode with set +r or shopt -u restricted_shell.

@@ -14613,13 +16646,14 @@ These restrictions are enforced after any startup files are read. above), + rbash turns off any restrictions in the shell spawned to execute the script. -  + 

SEE ALSO

@@ -14627,15 +16661,15 @@ script.
Bash Reference Manual, Brian Fox and Chet Ramey
The Gnu Readline Library, Brian Fox and Chet Ramey
The Gnu History Library, Brian Fox and Chet Ramey
-
Portable Operating System Interface (POSIX) Part 2: Shell and Utilities, IEEE --
-http://pubs.opengroup.org/onlinepubs/9699919799/ -
http://tiswww.case.edu/~chet/bash/POSIX -- a description of posix mode
+
Portable Operating System Interface (POSIX) Part 2: Shell and Utilities, IEEE -
+http://pubs.opengroup.org/onlinepubs/9799919799/ +
http://tiswww.case.edu/~chet/bash/POSIX - a description of posix mode
sh(1), ksh(1), csh(1)
emacs(1), vi(1)
readline(3)
-  + 

FILES

@@ -14678,7 +16712,7 @@ command history Individual readline initialization file -  + 

AUTHORS

Brian Fox, Free Software Foundation @@ -14691,11 +16725,11 @@ Chet Ramey, Case Western Reserve University
chet.ramey@case.edu -  + 

BUG REPORTS

If you find a bug in -bash, +bash, you should report it. But first, you should make sure that it really is a bug, and that it appears in the latest @@ -14712,8 +16746,9 @@ Once you have determined that a bug actually exists, use the command to submit a bug report. If you have a fix, you are encouraged to mail that as well! -Suggestions and `philosophical' bug reports may be mailed -to bug-bash@gnu.org or posted to the Usenet +You may send suggestions and + +bug reports to bug-bash@gnu.org or post them to the Usenet newsgroup gnu.bash.bug. @@ -14727,8 +16762,10 @@ ALL bug reports should include:
The version number of bash
The hardware and operating system
The compiler used to compile
-
A description of the bug behaviour
-
A short script or `recipe' which exercises the bug
+
A description of the bug behavior
+
A short script or
+ +which exercises the bug

@@ -14743,7 +16780,7 @@ Comments and bug reports concerning this manual page should be directed to chet.ramey@case.edu. -  + 

BUGS

It's too big and too slow. @@ -14756,9 +16793,7 @@ and traditional versions of sh, mostly because of the -POSIX - - +POSIX specification.

@@ -14768,26 +16803,25 @@ Aliases are confusing in some uses. Shell builtin commands and functions are not stoppable/restartable.

-Compound commands and command sequences of the form `a ; b ; c' -are not handled gracefully when process suspension is attempted. +Compound commands and command lists of the form + +are not handled gracefully when combined with process suspension. When a process is stopped, the shell immediately executes the next -command in the sequence. -It suffices to place the sequence of commands between -parentheses to force it into a subshell, which may be stopped as -a unit. +command in the list or breaks out of any existing loops. +It suffices to enclose the command in parentheses to +force it into a subshell, which may be stopped as a unit, +or to start the command in the background and immediately +bring it into the foreground.

Array variables may not (yet) be exported. -

- -There may be only one active coprocess at a time.


-
GNU Bash 5.22022 September 19BASH(1) +GNU Bash 5.32025 April 7BASH(1)

@@ -14813,87 +16847,90 @@ There may be only one active coprocess at a time.
COMMENTS
QUOTING
-
PARAMETERS
-
Positional Parameters
-
Special Parameters
-
Shell Variables
-
Arrays
+
Translating Strings
+
+
PARAMETERS
+
+
Positional Parameters
+
Special Parameters
+
Shell Variables
+
Arrays
-
EXPANSION
+
EXPANSION
-
Brace Expansion
-
Tilde Expansion
-
Parameter Expansion
-
Command Substitution
-
Arithmetic Expansion
-
Process Substitution
-
Word Splitting
-
Pathname Expansion
-
Quote Removal
+
Brace Expansion
+
Tilde Expansion
+
Parameter Expansion
+
Command Substitution
+
Arithmetic Expansion
+
Process Substitution
+
Word Splitting
+
Pathname Expansion
+
Quote Removal
-
REDIRECTION
+
REDIRECTION
-
Redirecting Input
-
Redirecting Output
-
Appending Redirected Output
-
Redirecting Standard Output and Standard Error
-
Appending Standard Output and Standard Error
-
Here Documents
-
Here Strings
-
Duplicating File Descriptors
-
Moving File Descriptors
-
Opening File Descriptors for Reading and Writing
+
Redirecting Input
+
Redirecting Output
+
Appending Redirected Output
+
Redirecting Standard Output and Standard Error
+
Appending Standard Output and Standard Error
+
Here Documents
+
Here Strings
+
Duplicating File Descriptors
+
Moving File Descriptors
+
Opening File Descriptors for Reading and Writing
-
ALIASES
-
FUNCTIONS
-
ARITHMETIC EVALUATION
-
CONDITIONAL EXPRESSIONS
-
SIMPLE COMMAND EXPANSION
-
COMMAND EXECUTION
-
COMMAND EXECUTION ENVIRONMENT
-
ENVIRONMENT
-
EXIT STATUS
-
SIGNALS
-
JOB CONTROL
-
PROMPTING
-
READLINE
+
ALIASES
+
FUNCTIONS
+
ARITHMETIC EVALUATION
+
CONDITIONAL EXPRESSIONS
+
SIMPLE COMMAND EXPANSION
+
COMMAND EXECUTION
+
COMMAND EXECUTION ENVIRONMENT
+
ENVIRONMENT
+
EXIT STATUS
+
SIGNALS
+
JOB CONTROL
+
PROMPTING
+
READLINE
-
Readline Notation
-
Readline Initialization
-
Readline Key Bindings
-
Readline Variables
-
Readline Conditional Constructs
-
Searching
-
Readline Command Names
-
Commands for Moving
-
Commands for Manipulating the History
-
Commands for Changing Text
-
Killing and Yanking
-
Numeric Arguments
-
Completing
-
Keyboard Macros
-
Miscellaneous
-
Programmable Completion
+
Readline Notation
+
Readline Initialization
+
Readline Key Bindings
+
Readline Variables
+
Readline Conditional Constructs
+
Searching
+
Readline Command Names
+
Commands for Moving
+
Commands for Manipulating the History
+
Commands for Changing Text
+
Killing and Yanking
+
Numeric Arguments
+
Completing
+
Keyboard Macros
+
Miscellaneous
+
Programmable Completion
-
HISTORY
-
HISTORY EXPANSION
+
HISTORY
+
HISTORY EXPANSION
-
Event Designators
-
Word Designators
-
Modifiers
+
Event Designators
+
Word Designators
+
Modifiers
-
SHELL BUILTIN COMMANDS
-
SHELL COMPATIBILITY MODE
-
RESTRICTED SHELL
-
SEE ALSO
-
FILES
-
AUTHORS
-
BUG REPORTS
-
BUGS
+
SHELL BUILTIN COMMANDS
+
SHELL COMPATIBILITY MODE
+
RESTRICTED SHELL
+
SEE ALSO
+
FILES
+
AUTHORS
+
BUG REPORTS
+
BUGS

-This document was created by man2html from /usr/local/src/bash/bash-20220907/doc/bash.1.
-Time: 19 September 2022 12:02:51 EDT +This document was created by man2html from /usr/local/src/bash/bash-20250502/doc/bash.1.
+Time: 04 May 2025 17:25:09 EDT diff --git a/doc/bash.info b/doc/bash.info index 6d31de621..48df32fc9 100644 --- a/doc/bash.info +++ b/doc/bash.info @@ -1,12 +1,12 @@ -This is bash.info, produced by makeinfo version 6.8 from bashref.texi. +This is bash.info, produced by makeinfo version 7.2 from bashref.texi. This text is a brief description of the features that are present in the -Bash shell (version 5.2, 19 September 2022). +Bash shell (version 5.3, 18 May 2025). - This is Edition 5.2, last updated 19 September 2022, of 'The GNU Bash -Reference Manual', for 'Bash', Version 5.2. + This is Edition 5.3, last updated 18 May 2025, of ‘The GNU Bash +Reference Manual’, for ‘Bash’, Version 5.3. - Copyright (C) 1988-2022 Free Software Foundation, Inc. + Copyright © 1988-2025 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, @@ -26,16 +26,16 @@ Bash Features ************* This text is a brief description of the features that are present in the -Bash shell (version 5.2, 19 September 2022). The Bash home page is +Bash shell (version 5.3, 18 May 2025). The Bash home page is . - This is Edition 5.2, last updated 19 September 2022, of 'The GNU Bash -Reference Manual', for 'Bash', Version 5.2. + This is Edition 5.3, last updated 18 May 2025, of ‘The GNU Bash +Reference Manual’, for ‘Bash’, Version 5.3. Bash contains features that appear in other popular shells, and some features that only appear in Bash. Some of the shells that Bash has -borrowed concepts from are the Bourne Shell ('sh'), the Korn Shell -('ksh'), and the C-shell ('csh' and its successor, 'tcsh'). The +borrowed concepts from are the Bourne Shell (‘sh’), the Korn Shell +(‘ksh’), and the C-shell (‘csh’ and its successor, ‘tcsh’). The following menu breaks the features up into categories, noting which features were inspired by other shells and which are specific to Bash. @@ -83,23 +83,23 @@ File: bash.info, Node: What is Bash?, Next: What is a shell?, Up: Introductio ================= Bash is the shell, or command language interpreter, for the GNU -operating system. The name is an acronym for the 'Bourne-Again SHell', +operating system. The name is an acronym for the ‘Bourne-Again SHell’, a pun on Stephen Bourne, the author of the direct ancestor of the -current Unix shell 'sh', which appeared in the Seventh Edition Bell Labs +current Unix shell ‘sh’, which appeared in the Seventh Edition Bell Labs Research version of Unix. - Bash is largely compatible with 'sh' and incorporates useful features -from the Korn shell 'ksh' and the C shell 'csh'. It is intended to be a + Bash is largely compatible with ‘sh’ and incorporates useful features +from the Korn shell ‘ksh’ and the C shell ‘csh’. It is intended to be a conformant implementation of the IEEE POSIX Shell and Tools portion of the IEEE POSIX specification (IEEE Standard 1003.1). It offers -functional improvements over 'sh' for both interactive and programming +functional improvements over ‘sh’ for both interactive and programming use. While the GNU operating system provides other shells, including a -version of 'csh', Bash is the default shell. Like other GNU software, +version of ‘csh’, Bash is the default shell. Like other GNU software, Bash is quite portable. It currently runs on nearly every version of -Unix and a few other operating systems - independently-supported ports -exist for MS-DOS, OS/2, and Windows platforms. +Unix and a few other operating systems − independently-supported ports +exist for Windows and other platforms.  File: bash.info, Node: What is a shell?, Prev: What is Bash?, Up: Introduction @@ -114,29 +114,30 @@ expanded to create larger expressions. A Unix shell is both a command interpreter and a programming language. As a command interpreter, the shell provides the user interface to the rich set of GNU utilities. The programming language -features allow these utilities to be combined. Files containing -commands can be created, and become commands themselves. These new +features allow these utilities to be combined. Users can create files +containing commands, and these become commands themselves. These new commands have the same status as system commands in directories such as -'/bin', allowing users or groups to establish custom environments to +‘/bin’, allowing users or groups to establish custom environments to automate their common tasks. Shells may be used interactively or non-interactively. In interactive mode, they accept input typed from the keyboard. When -executing non-interactively, shells execute commands read from a file. +executing non-interactively, shells execute commands read from a file or +a string. A shell allows execution of GNU commands, both synchronously and asynchronously. The shell waits for synchronous commands to complete before accepting more input; asynchronous commands continue to execute in parallel with the shell while it reads and executes additional -commands. The "redirection" constructs permit fine-grained control of +commands. The “redirection” constructs permit fine-grained control of the input and output of those commands. Moreover, the shell allows control over the contents of commands' environments. - Shells also provide a small set of built-in commands ("builtins") + Shells also provide a small set of built-in commands (“builtins”) implementing functionality impossible or inconvenient to obtain via -separate utilities. For example, 'cd', 'break', 'continue', and 'exec' +separate utilities. For example, ‘cd’, ‘break’, ‘continue’, and ‘exec’ cannot be implemented outside of the shell because they directly -manipulate the shell itself. The 'history', 'getopts', 'kill', or 'pwd' +manipulate the shell itself. The ‘history’, ‘getopts’, ‘kill’, or ‘pwd’ builtins, among others, could be implemented in separate utilities, but they are more convenient to use as builtin commands. All of the shell builtins are described in subsequent sections. @@ -149,7 +150,7 @@ constructs, quoting, and functions. Shells offer features geared specifically for interactive use rather than to augment the programming language. These interactive features include job control, command line editing, command history and aliases. -Each of these features is described in this manual. +This manual describes how Bash provides all of these features.  File: bash.info, Node: Definitions, Next: Basic Shell Features, Prev: Introduction, Up: Top @@ -159,90 +160,94 @@ File: bash.info, Node: Definitions, Next: Basic Shell Features, Prev: Introdu These definitions are used throughout the remainder of this manual. -'POSIX' +‘POSIX’ A family of open system standards based on Unix. Bash is primarily concerned with the Shell and Utilities portion of the POSIX 1003.1 standard. -'blank' +‘blank’ A space or tab character. -'builtin' +‘whitespace’ + A character belonging to the ‘space’ character class in the current + locale, or for which ‘isspace()’ returns true. + +‘builtin’ A command that is implemented internally by the shell itself, rather than by an executable program somewhere in the file system. -'control operator' - A 'token' that performs a control function. It is a 'newline' or - one of the following: '||', '&&', '&', ';', ';;', ';&', ';;&', '|', - '|&', '(', or ')'. +‘control operator’ + A ‘token’ that performs a control function. It is a ‘newline’ or + one of the following: ‘||’, ‘&&’, ‘&’, ‘;’, ‘;;’, ‘;&’, ‘;;&’, ‘|’, + ‘|&’, ‘(’, or ‘)’. -'exit status' +‘exit status’ The value returned by a command to its caller. The value is restricted to eight bits, so the maximum value is 255. -'field' +‘field’ A unit of text that is the result of one of the shell expansions. After expansion, when executing a command, the resulting fields are used as the command name and arguments. -'filename' +‘filename’ A string of characters used to identify a file. -'job' +‘job’ A set of processes comprising a pipeline, and any processes descended from it, that are all in the same process group. -'job control' +‘job control’ A mechanism by which users can selectively stop (suspend) and restart (resume) execution of processes. -'metacharacter' +‘metacharacter’ A character that, when unquoted, separates words. A metacharacter - is a 'space', 'tab', 'newline', or one of the following characters: - '|', '&', ';', '(', ')', '<', or '>'. + is a ‘space’, ‘tab’, ‘newline’, or one of the following characters: + ‘|’, ‘&’, ‘;’, ‘(’, ‘)’, ‘<’, or ‘>’. -'name' - A 'word' consisting solely of letters, numbers, and underscores, - and beginning with a letter or underscore. 'Name's are used as +‘name’ + A ‘word’ consisting solely of letters, numbers, and underscores, + and beginning with a letter or underscore. ‘Name’s are used as shell variable and function names. Also referred to as an - 'identifier'. + ‘identifier’. -'operator' - A 'control operator' or a 'redirection operator'. *Note +‘operator’ + A ‘control operator’ or a ‘redirection operator’. *Note Redirections::, for a list of redirection operators. Operators - contain at least one unquoted 'metacharacter'. + contain at least one unquoted ‘metacharacter’. -'process group' +‘process group’ A collection of related processes each having the same process group ID. -'process group ID' - A unique identifier that represents a 'process group' during its +‘process group ID’ + A unique identifier that represents a ‘process group’ during its lifetime. -'reserved word' - A 'word' that has a special meaning to the shell. Most reserved - words introduce shell flow control constructs, such as 'for' and - 'while'. +‘reserved word’ + A ‘word’ that has a special meaning to the shell. Most reserved + words introduce shell flow control constructs, such as ‘for’ and + ‘while’. -'return status' - A synonym for 'exit status'. +‘return status’ + A synonym for ‘exit status’. -'signal' +‘signal’ A mechanism by which a process may be notified by the kernel of an event occurring in the system. -'special builtin' +‘special builtin’ A shell builtin command that has been classified as special by the POSIX standard. -'token' +‘token’ A sequence of characters considered a single unit by the shell. It - is either a 'word' or an 'operator'. + is either a ‘word’ or an ‘operator’. -'word' +‘word’ A sequence of characters treated as a unit by the shell. Words may - not include unquoted 'metacharacters'. + not include unquoted ‘metacharacters’.  File: bash.info, Node: Basic Shell Features, Next: Shell Builtin Commands, Prev: Definitions, Up: Top @@ -250,9 +255,9 @@ File: bash.info, Node: Basic Shell Features, Next: Shell Builtin Commands, Pr 3 Basic Shell Features ********************** -Bash is an acronym for 'Bourne-Again SHell'. The Bourne shell is the +Bash is an acronym for ‘Bourne-Again SHell’. The Bourne shell is the traditional Unix shell originally written by Stephen Bourne. All of the -Bourne shell builtin commands are available in Bash, The rules for +Bourne shell builtin commands are available in Bash, and the rules for evaluation and quoting are taken from the POSIX specification for the 'standard' Unix shell. @@ -287,7 +292,7 @@ File: bash.info, Node: Shell Syntax, Next: Shell Commands, Up: Basic Shell Fe When the shell reads input, it proceeds through a sequence of operations. If the input indicates the beginning of a comment, the -shell ignores the comment symbol ('#'), and the rest of that line. +shell ignores the comment symbol (‘#’), and the rest of that line. Otherwise, roughly speaking, the shell reads its input and divides the input into words and operators, employing the quoting rules to @@ -309,12 +314,12 @@ The following is a brief description of the shell's operation when it reads and executes a command. Basically, the shell does the following: 1. Reads its input from a file (*note Shell Scripts::), from a string - supplied as an argument to the '-c' invocation option (*note + supplied as an argument to the ‘-c’ invocation option (*note Invoking Bash::), or from the user's terminal. 2. Breaks the input into words and operators, obeying the quoting rules described in *note Quoting::. These tokens are separated by - 'metacharacters'. Alias expansion is performed by this step (*note + ‘metacharacters’. This step performs alias expansion (*note Aliases::). 3. Parses the tokens into simple and compound commands (*note Shell @@ -357,13 +362,14 @@ as such, and to prevent parameter expansion. Each of the shell metacharacters (*note Definitions::) has special meaning to the shell and must be quoted if it is to represent itself. -When the command history expansion facilities are being used (*note -History Interaction::), the "history expansion" character, usually '!', + + When the command history expansion facilities are being used (*note +History Interaction::), the “history expansion” character, usually ‘!’, must be quoted to prevent history expansion. *Note Bash History Facilities::, for more details concerning history expansion. - There are three quoting mechanisms: the "escape character", single -quotes, and double quotes. + There are four quoting mechanisms: the “escape character”, single +quotes, double quotes, and dollar-single quotes.  File: bash.info, Node: Escape Character, Next: Single Quotes, Up: Quoting @@ -371,11 +377,12 @@ File: bash.info, Node: Escape Character, Next: Single Quotes, Up: Quoting 3.1.2.1 Escape Character ........................ -A non-quoted backslash '\' is the Bash escape character. It preserves -the literal value of the next character that follows, with the exception -of 'newline'. If a '\newline' pair appears, and the backslash itself is -not quoted, the '\newline' is treated as a line continuation (that is, -it is removed from the input stream and effectively ignored). +A non-quoted backslash ‘\’ is the Bash escape character. It preserves +the literal value of the next character that follows, removing any +special meaning it has, with the exception of ‘newline’. If a +‘\newline’ pair appears, and the backslash itself is not quoted, the +‘\newline’ is treated as a line continuation (that is, it is removed +from the input stream and effectively ignored).  File: bash.info, Node: Single Quotes, Next: Double Quotes, Prev: Escape Character, Up: Quoting @@ -383,7 +390,7 @@ File: bash.info, Node: Single Quotes, Next: Double Quotes, Prev: Escape Chara 3.1.2.2 Single Quotes ..................... -Enclosing characters in single quotes (''') preserves the literal value +Enclosing characters in single quotes (‘'’) preserves the literal value of each character within the quotes. A single quote may not occur between single quotes, even when preceded by a backslash. @@ -393,23 +400,24 @@ File: bash.info, Node: Double Quotes, Next: ANSI-C Quoting, Prev: Single Quot 3.1.2.3 Double Quotes ..................... -Enclosing characters in double quotes ('"') preserves the literal value -of all characters within the quotes, with the exception of '$', '`', -'\', and, when history expansion is enabled, '!'. When the shell is in -POSIX mode (*note Bash POSIX Mode::), the '!' has no special meaning +Enclosing characters in double quotes (‘"’) preserves the literal value +of all characters within the quotes, with the exception of ‘$’, ‘`’, +‘\’, and, when history expansion is enabled, ‘!’. When the shell is in +POSIX mode (*note Bash POSIX Mode::), the ‘!’ has no special meaning within double quotes, even when history expansion is enabled. The -characters '$' and '`' retain their special meaning within double quotes +characters ‘$’ and ‘`’ retain their special meaning within double quotes (*note Shell Expansions::). The backslash retains its special meaning -only when followed by one of the following characters: '$', '`', '"', -'\', or 'newline'. Within double quotes, backslashes that are followed +only when followed by one of the following characters: ‘$’, ‘`’, ‘"’, +‘\’, or ‘newline’. Within double quotes, backslashes that are followed by one of these characters are removed. Backslashes preceding -characters without a special meaning are left unmodified. A double -quote may be quoted within double quotes by preceding it with a -backslash. If enabled, history expansion will be performed unless an -'!' appearing in double quotes is escaped using a backslash. The -backslash preceding the '!' is not removed. +characters without a special meaning are left unmodified. - The special parameters '*' and '@' have special meaning when in + A double quote may be quoted within double quotes by preceding it +with a backslash. If enabled, history expansion will be performed +unless an ‘!’ appearing in double quotes is escaped using a backslash. +The backslash preceding the ‘!’ is not removed. + + The special parameters ‘*’ and ‘@’ have special meaning when in double quotes (*note Shell Parameter Expansion::).  @@ -418,51 +426,51 @@ File: bash.info, Node: ANSI-C Quoting, Next: Locale Translation, Prev: Double 3.1.2.4 ANSI-C Quoting ...................... -Character sequences of the form $'STRING' are treated as a special kind -of single quotes. The sequence expands to STRING, with +Character sequences of the form ‘$'STRING'’ are treated as a special +kind of single quotes. The sequence expands to STRING, with backslash-escaped characters in STRING replaced as specified by the ANSI C standard. Backslash escape sequences, if present, are decoded as follows: -'\a' +‘\a’ alert (bell) -'\b' +‘\b’ backspace -'\e' -'\E' - an escape character (not ANSI C) -'\f' +‘\e’ +‘\E’ + An escape character (not in ANSI C). +‘\f’ form feed -'\n' +‘\n’ newline -'\r' +‘\r’ carriage return -'\t' +‘\t’ horizontal tab -'\v' +‘\v’ vertical tab -'\\' +‘\\’ backslash -'\'' +‘\'’ single quote -'\"' +‘\"’ double quote -'\?' +‘\?’ question mark -'\NNN' - the eight-bit character whose value is the octal value NNN (one to - three octal digits) -'\xHH' - the eight-bit character whose value is the hexadecimal value HH - (one or two hex digits) -'\uHHHH' - the Unicode (ISO/IEC 10646) character whose value is the - hexadecimal value HHHH (one to four hex digits) -'\UHHHHHHHH' - the Unicode (ISO/IEC 10646) character whose value is the - hexadecimal value HHHHHHHH (one to eight hex digits) -'\cX' - a control-X character +‘\NNN’ + The eight-bit character whose value is the octal value NNN (one to + three octal digits). +‘\xHH’ + The eight-bit character whose value is the hexadecimal value HH + (one or two hex digits). +‘\uHHHH’ + The Unicode (ISO/IEC 10646) character whose value is the + hexadecimal value HHHH (one to four hex digits). +‘\UHHHHHHHH’ + The Unicode (ISO/IEC 10646) character whose value is the + hexadecimal value HHHHHHHH (one to eight hex digits). +‘\cX’ + A control-X character. The expanded result is single-quoted, as if the dollar sign had not been present. @@ -478,17 +486,18 @@ File: bash.info, Node: Locale Translation, Prev: ANSI-C Quoting, Up: Quoting * Creating Internationalized Scripts:: How to use translations and different languages in your scripts. -Prefixing a double-quoted string with a dollar sign ('$'), such as -$"hello, world", will cause the string to be translated according to the -current locale. The 'gettext' infrastructure performs the lookup and -translation, using the 'LC_MESSAGES', 'TEXTDOMAINDIR', and 'TEXTDOMAIN' +Prefixing a double-quoted string with a dollar sign (‘$’), such as +$"hello, world", causes the string to be translated according to the +current locale. The ‘gettext’ infrastructure performs the lookup and +translation, using the ‘LC_MESSAGES’, ‘TEXTDOMAINDIR’, and ‘TEXTDOMAIN’ shell variables, as explained below. See the gettext documentation for -additional details not covered here. If the current locale is 'C' or -'POSIX', if there are no translations available, of if the string is not -translated, the dollar sign is ignored. Since this is a form of double +additional details not covered here. If the current locale is ‘C’ or +‘POSIX’, if there are no translations available, or if the string is not +translated, the dollar sign is ignored, and the string is treated as +double-quoted as described above. Since this is a form of double quoting, the string remains double-quoted by default, whether or not it -is translated and replaced. If the 'noexpand_translation' option is -enabled using the 'shopt' builtin (*note The Shopt Builtin::), +is translated and replaced. If the ‘noexpand_translation’ option is +enabled using the ‘shopt’ builtin (*note The Shopt Builtin::), translated strings are single-quoted instead of double-quoted. The rest of this section is a brief overview of how you use gettext @@ -503,21 +512,21 @@ using $"...", you create a gettext "template" file using the command bash --dump-po-strings SCRIPTNAME > DOMAIN.pot -The DOMAIN is your "message domain". It's just an arbitrary string +The DOMAIN is your “message domain”. It's just an arbitrary string that's used to identify the files gettext needs, like a package or script name. It needs to be unique among all the message domains on systems where you install the translations, so gettext knows which translations correspond to your script. You'll use the template file to create translations for each target language. The template file -conventionally has the suffix '.pot'. +conventionally has the suffix ‘.pot’. You copy this template file to a separate file for each target language you want to support (called "PO" files, which use the suffix -'.po'). PO files use various naming conventions, but when you are +‘.po’). PO files use various naming conventions, but when you are working to translate a template file into a particular language, you first copy the template file to a file whose name is the language you -want to target, with the '.po' suffix. For instance, the Spanish -translations of your strings would be in a file named 'es.po', and to +want to target, with the ‘.po’ suffix. For instance, the Spanish +translations of your strings would be in a file named ‘es.po’, and to get started using a message domain named "example," you would run cp example.pot es.po @@ -534,7 +543,7 @@ be done manually. gettext tools to produce what are called "MO" files, which are compiled versions of the PO files the gettext tools use to look up translations efficiently. MO files are also called "message catalog" files. You use -the 'msgfmt' program to do this. For instance, if you had a file with +the ‘msgfmt’ program to do this. For instance, if you had a file with Spanish translations, you could run msgfmt -o es.mo es.po @@ -542,29 +551,29 @@ Spanish translations, you could run to produce the corresponding MO file. Once you have the MO files, you decide where to install them and use -the 'TEXTDOMAINDIR' shell variable to tell the gettext tools where they +the ‘TEXTDOMAINDIR’ shell variable to tell the gettext tools where they are. Make sure to use the same message domain to name the MO files as you did for the PO files when you install them. - Your users will use the 'LANG' or 'LC_MESSAGES' shell variables to + Your users will use the ‘LANG’ or ‘LC_MESSAGES’ shell variables to select the desired language. - You set the 'TEXTDOMAIN' variable to the script's message domain. As + You set the ‘TEXTDOMAIN’ variable to the script's message domain. As above, you use the message domain to name your translation files. - You, or possibly your users, set the 'TEXTDOMAINDIR' variable to the + You, or possibly your users, set the ‘TEXTDOMAINDIR’ variable to the name of a directory where the message catalog files are stored. If you install the message files into the system's standard message catalog directory, you don't need to worry about this variable. The directory where the message catalog files are stored varies between systems. Some use the message catalog selected by the -'LC_MESSAGES' shell variable. Others create the name of the message -catalog from the value of the 'TEXTDOMAIN' shell variable, possibly -adding the '.mo' suffix. If you use the 'TEXTDOMAIN' variable, you may -need to set the 'TEXTDOMAINDIR' variable to the location of the message +‘LC_MESSAGES’ shell variable. Others create the name of the message +catalog from the value of the ‘TEXTDOMAIN’ shell variable, possibly +adding the ‘.mo’ suffix. If you use the ‘TEXTDOMAIN’ variable, you may +need to set the ‘TEXTDOMAINDIR’ variable to the location of the message catalog files, as above. It's common to use both variables in this -fashion: '$TEXTDOMAINDIR'/'$LC_MESSAGES'/LC_MESSAGES/'$TEXTDOMAIN'.mo. +fashion: ‘$TEXTDOMAINDIR’/‘$LC_MESSAGES’/LC_MESSAGES/‘$TEXTDOMAIN’.mo. If you used that last convention, and you wanted to store the message catalog files with Spanish (es) and Esperanto (eo) translations into a @@ -579,7 +588,7 @@ local directory you use for custom translation files, you could run When all of this is done, and the message catalog files containing the compiled translations are installed in the correct location, your users will be able to see translated strings in any of the supported -languages by setting the 'LANG' or 'LC_MESSAGES' environment variables +languages by setting the ‘LANG’ or ‘LC_MESSAGES’ environment variables before running your script.  @@ -589,13 +598,15 @@ File: bash.info, Node: Comments, Prev: Quoting, Up: Shell Syntax -------------- In a non-interactive shell, or an interactive shell in which the -'interactive_comments' option to the 'shopt' builtin is enabled (*note -The Shopt Builtin::), a word beginning with '#' causes that word and all -remaining characters on that line to be ignored. An interactive shell -without the 'interactive_comments' option enabled does not allow -comments. The 'interactive_comments' option is on by default in -interactive shells. *Note Interactive Shells::, for a description of -what makes a shell interactive. +‘interactive_comments’ option to the ‘shopt’ builtin is enabled (*note +The Shopt Builtin::), a word beginning with ‘#’ introduces a comment. A +word begins at the beginning of a line, after unquoted whitespace, or +after an operator. The comment causes that word and all remaining +characters on that line to be ignored. An interactive shell without the +‘interactive_comments’ option enabled does not allow comments. The +‘interactive_comments’ option is enabled by default in interactive +shells. *Note Interactive Shells::, for a description of what makes a +shell interactive.  File: bash.info, Node: Shell Commands, Next: Shell Functions, Prev: Shell Syntax, Up: Basic Shell Features @@ -603,7 +614,7 @@ File: bash.info, Node: Shell Commands, Next: Shell Functions, Prev: Shell Syn 3.2 Shell Commands ================== -A simple shell command such as 'echo a b c' consists of the command +A simple shell command such as ‘echo a b c’ consists of the command itself followed by arguments, separated by spaces. More complex shell commands are composed of simple commands arranged @@ -634,14 +645,14 @@ are used to begin and end the shell's compound commands. The following words are recognized as reserved when unquoted and the first word of a command (see below for exceptions): -'if' 'then' 'elif' 'else' 'fi' 'time' -'for' 'in' 'until' 'while' 'do' 'done' -'case' 'esac' 'coproc''select''function' -'{' '}' '[[' ']]' '!' +‘if’ ‘then’ ‘elif’ ‘else’ ‘fi’ ‘time’ +‘for’ ‘in’ ‘until’ ‘while’ ‘do’ ‘done’ +‘case’ ‘esac’ ‘coproc’‘select’‘function’ +‘{’ ‘}’ ‘[[’ ‘]]’ ‘!’ -'in' is recognized as a reserved word if it is the third word of a -'case' or 'select' command. 'in' and 'do' are recognized as reserved -words if they are the third word in a 'for' command. +‘in’ is recognized as a reserved word if it is the third word of a +‘case’ or ‘select’ command. ‘in’ and ‘do’ are recognized as reserved +words if they are the third word in a ‘for’ command.  File: bash.info, Node: Simple Commands, Next: Pipelines, Prev: Reserved Words, Up: Shell Commands @@ -649,14 +660,14 @@ File: bash.info, Node: Simple Commands, Next: Pipelines, Prev: Reserved Words 3.2.2 Simple Commands --------------------- -A simple command is the kind of command encountered most often. It's -just a sequence of words separated by 'blank's, terminated by one of the -shell's control operators (*note Definitions::). The first word +A simple command is the kind of command that's executed most often. +It's just a sequence of words separated by ‘blank’s, terminated by one +of the shell's control operators (*note Definitions::). The first word generally specifies a command to be executed, with the rest of the words being that command's arguments. The return status (*note Exit Status::) of a simple command is its -exit status as provided by the POSIX 1003.1 'waitpid' function, or 128+N +exit status as provided by the POSIX 1003.1 ‘waitpid’ function, or 128+N if the command was terminated by signal N.  @@ -665,8 +676,8 @@ File: bash.info, Node: Pipelines, Next: Lists, Prev: Simple Commands, Up: Sh 3.2.3 Pipelines --------------- -A 'pipeline' is a sequence of one or more commands separated by one of -the control operators '|' or '|&'. +A ‘pipeline’ is a sequence of one or more commands separated by one of +the control operators ‘|’ or ‘|&’. The format for a pipeline is [time [-p]] [!] COMMAND1 [ | or |& COMMAND2 ] ... @@ -676,49 +687,52 @@ the input of the next command. That is, each command reads the previous command's output. This connection is performed before any redirections specified by COMMAND1. - If '|&' is used, COMMAND1's standard error, in addition to its -standard output, is connected to COMMAND2's standard input through the -pipe; it is shorthand for '2>&1 |'. This implicit redirection of the -standard error to the standard output is performed after any -redirections specified by COMMAND1. - - The reserved word 'time' causes timing statistics to be printed for -the pipeline once it finishes. The statistics currently consist of -elapsed (wall-clock) time and user and system time consumed by the -command's execution. The '-p' option changes the output format to that -specified by POSIX. When the shell is in POSIX mode (*note Bash POSIX -Mode::), it does not recognize 'time' as a reserved word if the next -token begins with a '-'. The 'TIMEFORMAT' variable may be set to a -format string that specifies how the timing information should be + If ‘|&’ is the pipeline operator, COMMAND1's standard error, in +addition to its standard output, is connected to COMMAND2's standard +input through the pipe; it is shorthand for ‘2>&1 |’. This implicit +redirection of the standard error to the standard output is performed +after any redirections specified by COMMAND1, consistent with that +shorthand. + + If the reserved word ‘time’ precedes the pipeline, Bash prints timing +statistics for the pipeline once it finishes. The statistics currently +consist of elapsed (wall-clock) time and user and system time consumed +by the command's execution. The ‘-p’ option changes the output format +to that specified by POSIX. When the shell is in POSIX mode (*note Bash +POSIX Mode::), it does not recognize ‘time’ as a reserved word if the +next token begins with a ‘-’. The value of the ‘TIMEFORMAT’ variable is +a format string that specifies how the timing information should be displayed. *Note Bash Variables::, for a description of the available -formats. The use of 'time' as a reserved word permits the timing of -shell builtins, shell functions, and pipelines. An external 'time' +formats. Providing ‘time’ as a reserved word permits the timing of +shell builtins, shell functions, and pipelines. An external ‘time’ command cannot time these easily. - When the shell is in POSIX mode (*note Bash POSIX Mode::), 'time' may -be followed by a newline. In this case, the shell displays the total -user and system time consumed by the shell and its children. The -'TIMEFORMAT' variable may be used to specify the format of the time + When the shell is in POSIX mode (*note Bash POSIX Mode::), you can +use ‘time’ by itself as a simple command. In this case, the shell +displays the total user and system time consumed by the shell and its +children. The ‘TIMEFORMAT’ variable specifies the format of the time information. - If the pipeline is not executed asynchronously (*note Lists::), the + If a pipeline is not executed asynchronously (*note Lists::), the shell waits for all commands in the pipeline to complete. Each command in a multi-command pipeline, where pipes are created, is -executed in its own "subshell", which is a separate process (*note -Command Execution Environment::). If the 'lastpipe' option is enabled -using the 'shopt' builtin (*note The Shopt Builtin::), the last element -of a pipeline may be run by the shell process when job control is not -active. +executed in its own “subshell”, which is a separate process (*note +Command Execution Environment::). If the ‘lastpipe’ option is enabled +using the ‘shopt’ builtin (*note The Shopt Builtin::), and job control +is not active, the last element of a pipeline may be run by the shell +process. The exit status of a pipeline is the exit status of the last command -in the pipeline, unless the 'pipefail' option is enabled (*note The Set -Builtin::). If 'pipefail' is enabled, the pipeline's return status is +in the pipeline, unless the ‘pipefail’ option is enabled (*note The Set +Builtin::). If ‘pipefail’ is enabled, the pipeline's return status is the value of the last (rightmost) command to exit with a non-zero status, or zero if all commands exit successfully. If the reserved word -'!' precedes the pipeline, the exit status is the logical negation of -the exit status as described above. The shell waits for all commands in -the pipeline to terminate before returning a value. +‘!’ precedes the pipeline, the exit status is the logical negation of +the exit status as described above. If a pipeline is not executed +asynchronously (*note Lists::), the shell waits for all commands in the +pipeline to terminate before returning a value. The return status of an +asynchronous pipeline is 0.  File: bash.info, Node: Lists, Next: Compound Commands, Prev: Pipelines, Up: Shell Commands @@ -726,31 +740,31 @@ File: bash.info, Node: Lists, Next: Compound Commands, Prev: Pipelines, Up: 3.2.4 Lists of Commands ----------------------- -A 'list' is a sequence of one or more pipelines separated by one of the -operators ';', '&', '&&', or '||', and optionally terminated by one of -';', '&', or a 'newline'. +A ‘list’ is a sequence of one or more pipelines separated by one of the +operators ‘;’, ‘&’, ‘&&’, or ‘||’, and optionally terminated by one of +‘;’, ‘&’, or a ‘newline’. - Of these list operators, '&&' and '||' have equal precedence, -followed by ';' and '&', which have equal precedence. + Of these list operators, ‘&&’ and ‘||’ have equal precedence, +followed by ‘;’ and ‘&’, which have equal precedence. - A sequence of one or more newlines may appear in a 'list' to delimit + A sequence of one or more newlines may appear in a ‘list’ to delimit commands, equivalent to a semicolon. - If a command is terminated by the control operator '&', the shell + If a command is terminated by the control operator ‘&’, the shell executes the command asynchronously in a subshell. This is known as -executing the command in the "background", and these are referred to as -"asynchronous" commands. The shell does not wait for the command to +executing the command in the “background”, and these are referred to as +“asynchronous” commands. The shell does not wait for the command to finish, and the return status is 0 (true). When job control is not active (*note Job Control::), the standard input for asynchronous commands, in the absence of any explicit redirections, is redirected -from '/dev/null'. +from ‘/dev/null’. - Commands separated by a ';' are executed sequentially; the shell + Commands separated by a ‘;’ are executed sequentially; the shell waits for each command to terminate in turn. The return status is the exit status of the last command executed. AND and OR lists are sequences of one or more pipelines separated by -the control operators '&&' and '||', respectively. AND and OR lists are +the control operators ‘&&’ and ‘||’, respectively. AND and OR lists are executed with left associativity. An AND list has the form @@ -802,11 +816,11 @@ File: bash.info, Node: Looping Constructs, Next: Conditional Constructs, Up: Bash supports the following looping constructs. - Note that wherever a ';' appears in the description of a command's + Note that wherever a ‘;’ appears in the description of a command's syntax, it may be replaced with one or more newlines. -'until' - The syntax of the 'until' command is: +‘until’ + The syntax of the ‘until’ command is: until TEST-COMMANDS; do CONSEQUENT-COMMANDS; done @@ -815,8 +829,8 @@ syntax, it may be replaced with one or more newlines. the last command executed in CONSEQUENT-COMMANDS, or zero if none was executed. -'while' - The syntax of the 'while' command is: +‘while’ + The syntax of the ‘while’ command is: while TEST-COMMANDS; do CONSEQUENT-COMMANDS; done @@ -825,38 +839,38 @@ syntax, it may be replaced with one or more newlines. command executed in CONSEQUENT-COMMANDS, or zero if none was executed. -'for' - The syntax of the 'for' command is: +‘for’ + The syntax of the ‘for’ command is: - for NAME [ [in [WORDS ...] ] ; ] do COMMANDS; done + for NAME [ [in WORDS ...] ; ] do COMMANDS; done - Expand WORDS (*note Shell Expansions::), and execute COMMANDS once - for each member in the resultant list, with NAME bound to the - current member. If 'in WORDS' is not present, the 'for' command + Expand WORDS (*note Shell Expansions::), and then execute COMMANDS + once for each word in the resultant list, with NAME bound to the + current word. If ‘in WORDS’ is not present, the ‘for’ command executes the COMMANDS once for each positional parameter that is - set, as if 'in "$@"' had been specified (*note Special + set, as if ‘in "$@"’ had been specified (*note Special Parameters::). The return status is the exit status of the last command that executes. If there are no items in the expansion of WORDS, no commands are executed, and the return status is zero. - An alternate form of the 'for' command is also supported: + There is an alternate form of the ‘for’ command which is similar to + the C language: - for (( EXPR1 ; EXPR2 ; EXPR3 )) ; do COMMANDS ; done + for (( EXPR1 ; EXPR2 ; EXPR3 )) [;] do COMMANDS ; done - First, the arithmetic expression EXPR1 is evaluated according to - the rules described below (*note Shell Arithmetic::). The - arithmetic expression EXPR2 is then evaluated repeatedly until it - evaluates to zero. Each time EXPR2 evaluates to a non-zero value, - COMMANDS are executed and the arithmetic expression EXPR3 is - evaluated. If any expression is omitted, it behaves as if it - evaluates to 1. The return value is the exit status of the last - command in COMMANDS that is executed, or false if any of the - expressions is invalid. + First, evaluate the arithmetic expression EXPR1 according to the + rules described below (*note Shell Arithmetic::). Then, repeatedly + evaluate the arithmetic expression EXPR2 until it evaluates to + zero. Each time EXPR2 evaluates to a non-zero value, execute + COMMANDS and evaluate the arithmetic expression EXPR3. If any + expression is omitted, it behaves as if it evaluates to 1. The + return value is the exit status of the last command in COMMANDS + that is executed, or non-zero if any of the expressions is invalid. - The 'break' and 'continue' builtins (*note Bourne Shell Builtins::) -may be used to control loop execution. + Use the ‘break’ and ‘continue’ builtins (*note Bourne Shell +Builtins::) to control loop execution.  File: bash.info, Node: Conditional Constructs, Next: Command Grouping, Prev: Looping Constructs, Up: Compound Commands @@ -864,8 +878,8 @@ File: bash.info, Node: Conditional Constructs, Next: Command Grouping, Prev: 3.2.5.2 Conditional Constructs .............................. -'if' - The syntax of the 'if' command is: +‘if’ + The syntax of the ‘if’ command is: if TEST-COMMANDS; then CONSEQUENT-COMMANDS; @@ -876,47 +890,48 @@ File: bash.info, Node: Conditional Constructs, Next: Command Grouping, Prev: The TEST-COMMANDS list is executed, and if its return status is zero, the CONSEQUENT-COMMANDS list is executed. If TEST-COMMANDS - returns a non-zero status, each 'elif' list is executed in turn, + returns a non-zero status, each ‘elif’ list is executed in turn, and if its exit status is zero, the corresponding MORE-CONSEQUENTS - is executed and the command completes. If 'else - ALTERNATE-CONSEQUENTS' is present, and the final command in the - final 'if' or 'elif' clause has a non-zero exit status, then + is executed and the command completes. If ‘else + ALTERNATE-CONSEQUENTS’ is present, and the final command in the + final ‘if’ or ‘elif’ clause has a non-zero exit status, then ALTERNATE-CONSEQUENTS is executed. The return status is the exit status of the last command executed, or zero if no condition tested true. -'case' - The syntax of the 'case' command is: +‘case’ + The syntax of the ‘case’ command is: case WORD in [ [(] PATTERN [| PATTERN]...) COMMAND-LIST ;;]... esac - 'case' will selectively execute the COMMAND-LIST corresponding to - the first PATTERN that matches WORD. The match is performed - according to the rules described below in *note Pattern Matching::. - If the 'nocasematch' shell option (see the description of 'shopt' - in *note The Shopt Builtin::) is enabled, the match is performed - without regard to the case of alphabetic characters. The '|' is - used to separate multiple patterns, and the ')' operator terminates - a pattern list. A list of patterns and an associated command-list - is known as a CLAUSE. + ‘case’ will selectively execute the COMMAND-LIST corresponding to + the first PATTERN that matches WORD, proceeding from the first + pattern to the last. The match is performed according to the rules + described below in *note Pattern Matching::. If the ‘nocasematch’ + shell option (see the description of ‘shopt’ in *note The Shopt + Builtin::) is enabled, the match is performed without regard to the + case of alphabetic characters. The ‘|’ is used to separate + multiple patterns in a pattern list, and the ‘)’ operator + terminates the pattern list. A pattern list and an associated + COMMAND-LIST is known as a CLAUSE. - Each clause must be terminated with ';;', ';&', or ';;&'. The WORD - undergoes tilde expansion, parameter expansion, command - substitution, arithmetic expansion, and quote removal (*note Shell - Parameter Expansion::) before matching is attempted. Each PATTERN + Each clause must be terminated with ‘;;’, ‘;&’, or ‘;;&’. The WORD undergoes tilde expansion, parameter expansion, command - substitution, arithmetic expansion, process substitution, and quote - removal. + substitution, process substitution, arithmetic expansion, and quote + removal (*note Shell Parameter Expansion::) before the shell + attempts to match the pattern. Each PATTERN undergoes tilde + expansion, parameter expansion, command substitution, arithmetic + expansion, process substitution, and quote removal. - There may be an arbitrary number of 'case' clauses, each terminated - by a ';;', ';&', or ';;&'. The first pattern that matches + There may be an arbitrary number of ‘case’ clauses, each terminated + by a ‘;;’, ‘;&’, or ‘;;&’. The first pattern that matches determines the command-list that is executed. It's a common idiom - to use '*' as the final pattern to define the default case, since + to use ‘*’ as the final pattern to define the default case, since that pattern will always match. - Here is an example using 'case' in a script that could be used to + Here is an example using ‘case’ in a script that could be used to describe one interesting feature of an animal: echo -n "Enter the name of an animal: " @@ -929,39 +944,38 @@ File: bash.info, Node: Conditional Constructs, Next: Command Grouping, Prev: esac echo " legs." - - If the ';;' operator is used, no subsequent matches are attempted - after the first pattern match. Using ';&' in place of ';;' causes + If the ‘;;’ operator is used, the ‘case’ command completes after + the first pattern match. Using ‘;&’ in place of ‘;;’ causes execution to continue with the COMMAND-LIST associated with the - next clause, if any. Using ';;&' in place of ';;' causes the shell + next clause, if any. Using ‘;;&’ in place of ‘;;’ causes the shell to test the patterns in the next clause, if any, and execute any - associated COMMAND-LIST on a successful match, continuing the case + associated COMMAND-LIST if the match succeeds, continuing the case statement execution as if the pattern list had not matched. - The return status is zero if no PATTERN is matched. Otherwise, the - return status is the exit status of the COMMAND-LIST executed. + The return status is zero if no PATTERN matches. Otherwise, the + return status is the exit status of the last COMMAND-LIST executed. -'select' +‘select’ - The 'select' construct allows the easy generation of menus. It has - almost the same syntax as the 'for' command: + The ‘select’ construct allows the easy generation of menus. It has + almost the same syntax as the ‘for’ command: select NAME [in WORDS ...]; do COMMANDS; done - The list of words following 'in' is expanded, generating a list of - items, and the set of expanded words is printed on the standard - error output stream, each preceded by a number. If the 'in WORDS' - is omitted, the positional parameters are printed, as if 'in "$@"' - had been specified. 'select' then displays the 'PS3' prompt and - reads a line from the standard input. If the line consists of a - number corresponding to one of the displayed words, then the value - of NAME is set to that word. If the line is empty, the words and - prompt are displayed again. If 'EOF' is read, the 'select' command + First, expand the list of words following ‘in’, generating a list + of items, and print the set of expanded words on the standard error + stream, each preceded by a number. If the ‘in WORDS’ is omitted, + print the positional parameters, as if ‘in "$@"’ had been + specified. ‘select’ then displays the ‘PS3’ prompt and reads a + line from the standard input. If the line consists of a number + corresponding to one of the displayed words, then ‘select’ sets the + value of NAME to that word. If the line is empty, ‘select’ + displays the words and prompt again. If ‘EOF’ is read, ‘select’ completes and returns 1. Any other value read causes NAME to be - set to null. The line read is saved in the variable 'REPLY'. + set to null. The line read is saved in the variable ‘REPLY’. - The COMMANDS are executed after each selection until a 'break' - command is executed, at which point the 'select' command completes. + The COMMANDS are executed after each selection until a ‘break’ + command is executed, at which point the ‘select’ command completes. Here is an example that allows the user to pick a filename from the current directory, and displays the name and index of the file @@ -973,57 +987,58 @@ File: bash.info, Node: Conditional Constructs, Next: Command Grouping, Prev: break; done -'((...))' +‘((...))’ (( EXPRESSION )) The arithmetic EXPRESSION is evaluated according to the rules described below (*note Shell Arithmetic::). The EXPRESSION undergoes the same expansions as if it were within double quotes, - but double quote characters in EXPRESSION are not treated specially - are removed. If the value of the expression is non-zero, the + but unescaped double quote characters in EXPRESSION are not treated + specially and are removed. Since this can potentially result in + empty strings, this command treats those as expressions that + evaluate to 0. If the value of the expression is non-zero, the return status is 0; otherwise the return status is 1. -'[[...]]' +‘[[...]]’ [[ EXPRESSION ]] - Return a status of 0 or 1 depending on the evaluation of the - conditional expression EXPRESSION. Expressions are composed of the - primaries described below in *note Bash Conditional Expressions::. - The words between the '[[' and ']]' do not undergo word splitting - and filename expansion. The shell performs tilde expansion, - parameter and variable expansion, arithmetic expansion, command - substitution, process substitution, and quote removal on those - words (the expansions that would occur if the words were enclosed - in double quotes). Conditional operators such as '-f' must be - unquoted to be recognized as primaries. - - When used with '[[', the '<' and '>' operators sort + Evaluate the conditional expression EXPRESSION and return a status + of zero (true) or non-zero (false). Expressions are composed of + the primaries described below in *note Bash Conditional + Expressions::. The words between the ‘[[’ and ‘]]’ do not undergo + word splitting and filename expansion. The shell performs tilde + expansion, parameter and variable expansion, arithmetic expansion, + command substitution, process substitution, and quote removal on + those words. Conditional operators such as ‘-f’ must be unquoted + to be recognized as primaries. + + When used with ‘[[’, the ‘<’ and ‘>’ operators sort lexicographically using the current locale. - When the '==' and '!=' operators are used, the string to the right + When the ‘==’ and ‘!=’ operators are used, the string to the right of the operator is considered a pattern and matched according to the rules described below in *note Pattern Matching::, as if the - 'extglob' shell option were enabled. The '=' operator is identical - to '=='. If the 'nocasematch' shell option (see the description of - 'shopt' in *note The Shopt Builtin::) is enabled, the match is + ‘extglob’ shell option were enabled. The ‘=’ operator is identical + to ‘==’. If the ‘nocasematch’ shell option (see the description of + ‘shopt’ in *note The Shopt Builtin::) is enabled, the match is performed without regard to the case of alphabetic characters. The - return value is 0 if the string matches ('==') or does not match - ('!=') the pattern, and 1 otherwise. + return value is 0 if the string matches (‘==’) or does not match + (‘!=’) the pattern, and 1 otherwise. If you quote any part of the pattern, using any of the shell's quoting mechanisms, the quoted portion is matched literally. This means every character in the quoted portion matches itself, instead of having any special pattern matching meaning. - An additional binary operator, '=~', is available, with the same - precedence as '==' and '!='. When you use '=~', the string to the + An additional binary operator, ‘=~’, is available, with the same + precedence as ‘==’ and ‘!=’. When you use ‘=~’, the string to the right of the operator is considered a POSIX extended regular expression pattern and matched accordingly (using the POSIX - 'regcomp' and 'regexec' interfaces usually described in regex(3)). + ‘regcomp’ and ‘regexec’ interfaces usually described in regex(3)). The return value is 0 if the string matches the pattern, and 1 if it does not. If the regular expression is syntactically incorrect, - the conditional expression returns 2. If the 'nocasematch' shell - option (see the description of 'shopt' in *note The Shopt + the conditional expression returns 2. If the ‘nocasematch’ shell + option (see the description of ‘shopt’ in *note The Shopt Builtin::) is enabled, the match is performed without regard to the case of alphabetic characters. @@ -1033,41 +1048,41 @@ File: bash.info, Node: Conditional Constructs, Next: Command Grouping, Prev: variable expansion forces the entire pattern to be matched literally. - The pattern will match if it matches any part of the string. If - you want to force the pattern to match the entire string, anchor - the pattern using the '^' and '$' regular expression operators. + The match succeeds if the pattern matches any part of the string. + If you want to force the pattern to match the entire string, anchor + the pattern using the ‘^’ and ‘$’ regular expression operators. For example, the following will match a line (stored in the shell - variable 'line') if there is a sequence of characters anywhere in + variable ‘line’) if there is a sequence of characters anywhere in the value consisting of any number, including zero, of characters - in the 'space' character class, immediately followed by zero or one - instances of 'a', then a 'b': + in the ‘space’ character class, immediately followed by zero or one + instances of ‘a’, then a ‘b’: [[ $line =~ [[:space:]]*(a)?b ]] - That means values for 'line' like 'aab', ' aaaaaab', 'xaby', and ' - ab' will all match, as will a line containing a 'b' anywhere in its + That means values for ‘line’ like ‘aab’, ‘ aaaaaab’, ‘xaby’, and ‘ + ab’ will all match, as will a line containing a ‘b’ anywhere in its value. If you want to match a character that's special to the regular - expression grammar ('^$|[]()\.*+?'), it has to be quoted to remove - its special meaning. This means that in the pattern 'xxx.txt', the - '.' matches any character in the string (its usual regular - expression meaning), but in the pattern '"xxx.txt"', it can only - match a literal '.'. + expression grammar (‘^$|[]()\.*+?’), it has to be quoted to remove + its special meaning. This means that in the pattern ‘xxx.txt’, the + ‘.’ matches any character in the string (its usual regular + expression meaning), but in the pattern ‘"xxx.txt"’, it can only + match a literal ‘.’. Likewise, if you want to include a character in your pattern that has a special meaning to the regular expression grammar, you must make sure it's not quoted. If you want to anchor a pattern at the beginning or end of the string, for instance, you cannot quote the - '^' or '$' characters using any form of shell quoting. + ‘^’ or ‘$’ characters using any form of shell quoting. - If you want to match 'initial string' at the start of a line, the + If you want to match ‘initial string’ at the start of a line, the following will work: [[ $line =~ ^"initial string" ]] but this will not: [[ $line =~ "^initial string" ]] - because in the second example the '^' is quoted and doesn't have + because in the second example the ‘^’ is quoted and doesn't have its usual special meaning. It is sometimes difficult to specify a regular expression properly @@ -1105,13 +1120,13 @@ File: bash.info, Node: Conditional Constructs, Next: Command Grouping, Prev: The first two matches will succeed, but the second two will not, because in the second two the backslash will be part of the pattern to be matched. In the first two examples, the pattern passed to - the regular expression parser is '\.'. The backslash removes the - special meaning from '.', so the literal '.' matches. In the + the regular expression parser is ‘\.’. The backslash removes the + special meaning from ‘.’, so the literal ‘.’ matches. In the second two examples, the pattern passed to the regular expression - parser has the backslash quoted (e.g., '\\\.'), which will not + parser has the backslash quoted (e.g., ‘\\\.’), which will not match the string, since it does not contain a backslash. If the - string in the first examples were anything other than '.', say 'a', - the pattern would not match, because the quoted '.' in the pattern + string in the first examples were anything other than ‘.’, say ‘a’, + the pattern would not match, because the quoted ‘.’ in the pattern loses its special meaning of matching any single character. Bracket expressions in regular expressions can be sources of errors @@ -1122,7 +1137,7 @@ File: bash.info, Node: Conditional Constructs, Next: Command Grouping, Prev: purpose. Though it might seem like a strange way to write it, the following - pattern will match a '.' in the string: + pattern will match a ‘.’ in the string: [[ . =~ [.] ]] @@ -1135,35 +1150,35 @@ File: bash.info, Node: Conditional Constructs, Next: Command Grouping, Prev: twice as much as possible, so shell quoting should be sufficient to quote special pattern characters where that's necessary. - The array variable 'BASH_REMATCH' records which parts of the string - matched the pattern. The element of 'BASH_REMATCH' with index 0 + The array variable ‘BASH_REMATCH’ records which parts of the string + matched the pattern. The element of ‘BASH_REMATCH’ with index 0 contains the portion of the string matching the entire regular expression. Substrings matched by parenthesized subexpressions within the regular expression are saved in the remaining - 'BASH_REMATCH' indices. The element of 'BASH_REMATCH' with index N + ‘BASH_REMATCH’ indices. The element of ‘BASH_REMATCH’ with index N is the portion of the string matching the Nth parenthesized subexpression. - Bash sets 'BASH_REMATCH' in the global scope; declaring it as a + Bash sets ‘BASH_REMATCH’ in the global scope; declaring it as a local variable will lead to unexpected results. Expressions may be combined using the following operators, listed in decreasing order of precedence: - '( EXPRESSION )' + ‘( EXPRESSION )’ Returns the value of EXPRESSION. This may be used to override the normal precedence of operators. - '! EXPRESSION' + ‘! EXPRESSION’ True if EXPRESSION is false. - 'EXPRESSION1 && EXPRESSION2' + ‘EXPRESSION1 && EXPRESSION2’ True if both EXPRESSION1 and EXPRESSION2 are true. - 'EXPRESSION1 || EXPRESSION2' + ‘EXPRESSION1 || EXPRESSION2’ True if either EXPRESSION1 or EXPRESSION2 is true. - The '&&' and '||' operators do not evaluate EXPRESSION2 if the + The ‘&&’ and ‘||’ operators do not evaluate EXPRESSION2 if the value of EXPRESSION1 is sufficient to determine the return value of the entire conditional expression. @@ -1178,7 +1193,7 @@ unit. When commands are grouped, redirections may be applied to the entire command list. For example, the output of all the commands in the list may be redirected to a single stream. -'()' +‘()’ ( LIST ) Placing a list of commands between parentheses forces the shell to @@ -1187,17 +1202,17 @@ list may be redirected to a single stream. Since the LIST is executed in a subshell, variable assignments do not remain in effect after the subshell completes. -'{}' +‘{}’ { LIST; } Placing a list of commands between curly braces causes the list to - be executed in the current shell context. No subshell is created. - The semicolon (or newline) following LIST is required. + be executed in the current shell environment. No subshell is + created. The semicolon (or newline) following LIST is required. In addition to the creation of a subshell, there is a subtle difference between these two constructs due to historical reasons. The braces are reserved words, so they must be separated from the LIST by -'blank's or other shell metacharacters. The parentheses are operators, +‘blank’s or other shell metacharacters. The parentheses are operators, and are recognized as separate tokens by the shell even if they are not separated from the LIST by whitespace. @@ -1210,9 +1225,9 @@ File: bash.info, Node: Coprocesses, Next: GNU Parallel, Prev: Compound Comman 3.2.6 Coprocesses ----------------- -A 'coprocess' is a shell command preceded by the 'coproc' reserved word. +A ‘coprocess’ is a shell command preceded by the ‘coproc’ reserved word. A coprocess is executed asynchronously in a subshell, as if the command -had been terminated with the '&' control operator, with a two-way pipe +had been terminated with the ‘&’ control operator, with a two-way pipe established between the executing shell and the coprocess. The syntax for a coprocess is: @@ -1222,14 +1237,14 @@ established between the executing shell and the coprocess. This creates a coprocess named NAME. COMMAND may be either a simple command (*note Simple Commands::) or a compound command (*note Compound Commands::). NAME is a shell variable name. If NAME is not supplied, -the default name is 'COPROC'. +the default name is ‘COPROC’. The recommended form to use for a coprocess is coproc NAME { COMMAND; } -This form is recommended because simple commands result in the coprocess -always being named 'COPROC', and it is simpler to use and more complete +This form is preferred because simple commands result in the coprocess +always being named ‘COPROC’, and it is simpler to use and more complete than the other compound commands. There are other forms of coprocesses: @@ -1239,7 +1254,7 @@ than the other compound commands. coproc SIMPLE-COMMAND If COMMAND is a compound command, NAME is optional. The word following -'coproc' determines whether that word is interpreted as a variable name: +‘coproc’ determines whether that word is interpreted as a variable name: it is interpreted as NAME if it is not a reserved word that introduces a compound command. If COMMAND is a simple command, NAME is not allowed; this is to avoid confusion between NAME and the first word of the simple @@ -1259,11 +1274,11 @@ process substitutions, the file descriptors are not available in subshells. The process ID of the shell spawned to execute the coprocess is -available as the value of the variable 'NAME_PID'. The 'wait' builtin -command may be used to wait for the coprocess to terminate. +available as the value of the variable ‘NAME_PID’. The ‘wait’ builtin +may be used to wait for the coprocess to terminate. Since the coprocess is created as an asynchronous command, the -'coproc' command always returns success. The return status of a +‘coproc’ command always returns success. The return status of a coprocess is the exit status of COMMAND.  @@ -1281,7 +1296,7 @@ arguments, whether they are filenames, usernames, hostnames, or lines read from files. GNU Parallel provides shorthand references to many of the most common operations (input lines, various portions of the input line, different ways to specify the input source, and so on). Parallel -can replace 'xargs' or feed commands from its input sources to several +can replace ‘xargs’ or feed commands from its input sources to several different instances of Bash. For a complete description, refer to the GNU Parallel documentation, @@ -1296,10 +1311,10 @@ File: bash.info, Node: Shell Functions, Next: Shell Parameters, Prev: Shell C Shell functions are a way to group commands for later execution using a single name for the group. They are executed just like a "regular" -command. When the name of a shell function is used as a simple command -name, the list of commands associated with that function name is -executed. Shell functions are executed in the current shell context; no -new process is created to interpret them. +simple command. When the name of a shell function is used as a simple +command name, the shell executes the list of commands associated with +that function name. Shell functions are executed in the current shell +context; there is no new process created to interpret them. Functions are declared using this syntax: FNAME () COMPOUND-COMMAND [ REDIRECTIONS ] @@ -1309,20 +1324,20 @@ new process is created to interpret them. function FNAME [()] COMPOUND-COMMAND [ REDIRECTIONS ] This defines a shell function named FNAME. The reserved word -'function' is optional. If the 'function' reserved word is supplied, -the parentheses are optional. The "body" of the function is the +‘function’ is optional. If the ‘function’ reserved word is supplied, +the parentheses are optional. The “body” of the function is the compound command COMPOUND-COMMAND (*note Compound Commands::). That command is usually a LIST enclosed between { and }, but may be any -compound command listed above. If the 'function' reserved word is used, -but the parentheses are not supplied, the braces are recommended. -COMPOUND-COMMAND is executed whenever FNAME is specified as the name of -a simple command. When the shell is in POSIX mode (*note Bash POSIX -Mode::), FNAME must be a valid shell name and may not be the same as one -of the special builtins (*note Special Builtins::). In default mode, a -function name can be any unquoted shell word that does not contain '$'. -Any redirections (*note Redirections::) associated with the shell -function are performed when the function is executed. A function -definition may be deleted using the '-f' option to the 'unset' builtin +compound command listed above. If the ‘function’ reserved word is used, +but the parentheses are not supplied, the braces are recommended. When +the shell is in POSIX mode (*note Bash POSIX Mode::), FNAME must be a +valid shell name and may not be the same as one of the special builtins +(*note Special Builtins::). When not in POSIX mode, a function name can +be any unquoted shell word that does not contain ‘$’. + + Any redirections (*note Redirections::) associated with the shell +function are performed when the function is executed. Function +definitions are deleted using the ‘-f’ option to the ‘unset’ builtin (*note Bourne Shell Builtins::). The exit status of a function definition is zero unless a syntax @@ -1332,76 +1347,82 @@ last command executed in the body. Note that for historical reasons, in the most common usage the curly braces that surround the body of the function must be separated from the -body by 'blank's or newlines. This is because the braces are reserved +body by ‘blank’s or newlines. This is because the braces are reserved words and are only recognized as such when they are separated from the -command list by whitespace or another shell metacharacter. Also, when -using the braces, the LIST must be terminated by a semicolon, a '&', or -a newline. +command list by whitespace or another shell metacharacter. When using +the braces, the LIST must be terminated by a semicolon, a ‘&’, or a +newline. + + COMPOUND-COMMAND is executed whenever FNAME is specified as the name +of a simple command. Functions are executed in the context of the +calling shell; there is no new process created to interpret them +(contrast this with the execution of a shell script). When a function is executed, the arguments to the function become the positional parameters during its execution (*note Positional -Parameters::). The special parameter '#' that expands to the number of -positional parameters is updated to reflect the change. Special -parameter '0' is unchanged. The first element of the 'FUNCNAME' -variable is set to the name of the function while the function is -executing. +Parameters::). The special parameter ‘#’ that expands to the number of +positional parameters is updated to reflect the new set of positional +parameters. Special parameter ‘0’ is unchanged. The first element of +the ‘FUNCNAME’ variable is set to the name of the function while the +function is executing. All other aspects of the shell execution environment are identical -between a function and its caller with these exceptions: the 'DEBUG' and -'RETURN' traps are not inherited unless the function has been given the -'trace' attribute using the 'declare' builtin or the '-o functrace' -option has been enabled with the 'set' builtin, (in which case all -functions inherit the 'DEBUG' and 'RETURN' traps), and the 'ERR' trap is -not inherited unless the '-o errtrace' shell option has been enabled. -*Note Bourne Shell Builtins::, for the description of the 'trap' +between a function and its caller with these exceptions: the ‘DEBUG’ and +‘RETURN’ traps are not inherited unless the function has been given the +‘trace’ attribute using the ‘declare’ builtin or the ‘-o functrace’ +option has been enabled with the ‘set’ builtin, (in which case all +functions inherit the ‘DEBUG’ and ‘RETURN’ traps), and the ‘ERR’ trap is +not inherited unless the ‘-o errtrace’ shell option has been enabled. +*Note Bourne Shell Builtins::, for the description of the ‘trap’ builtin. - The 'FUNCNEST' variable, if set to a numeric value greater than 0, + The ‘FUNCNEST’ variable, if set to a numeric value greater than 0, defines a maximum function nesting level. Function invocations that exceed the limit cause the entire command to abort. - If the builtin command 'return' is executed in a function, the + If the builtin command ‘return’ is executed in a function, the function completes and execution resumes with the next command after the -function call. Any command associated with the 'RETURN' trap is +function call. Any command associated with the ‘RETURN’ trap is executed before execution resumes. When a function completes, the -values of the positional parameters and the special parameter '#' are -restored to the values they had prior to the function's execution. If a -numeric argument is given to 'return', that is the function's return +values of the positional parameters and the special parameter ‘#’ are +restored to the values they had prior to the function's execution. If +‘return’ is supplied a numeric argument, that is the function's return status; otherwise the function's return status is the exit status of the -last command executed before the 'return'. +last command executed before the ‘return’. - Variables local to the function may be declared with the 'local' -builtin ("local variables"). Ordinarily, variables and their values are -shared between a function and its caller. These variables are visible -only to the function and the commands it invokes. This is particularly + Variables local to the function are declared with the ‘local’ builtin +(“local variables”). Ordinarily, variables and their values are shared +between a function and its caller. These variables are visible only to +the function and the commands it invokes. This is particularly important when a shell function calls other functions. - In the following description, the "current scope" is a currently- + In the following description, the “current scope” is a currently- executing function. Previous scopes consist of that function's caller and so on, back to the "global" scope, where the shell is not executing -any shell function. Consequently, a local variable at the current local -scope is a variable declared using the 'local' or 'declare' builtins in -the function that is currently executing. +any shell function. A local variable at the current local scope is a +variable declared using the ‘local’ or ‘declare’ builtins in the +function that is currently executing. Local variables "shadow" variables with the same name declared at previous scopes. For instance, a local variable declared in a function -hides a global variable of the same name: references and assignments -refer to the local variable, leaving the global variable unmodified. +hides variables with the same name declared at previous scopes, +including global variables: references and assignments refer to the +local variable, leaving the variables at previous scopes unmodified. When the function returns, the global variable is once again visible. - The shell uses "dynamic scoping" to control a variable's visibility + The shell uses “dynamic scoping” to control a variable's visibility within functions. With dynamic scoping, visible variables and their values are a result of the sequence of function calls that caused execution to reach the current function. The value of a variable that a function sees depends on its value within its caller, if any, whether -that caller is the "global" scope or another shell function. This is -also the value that a local variable declaration "shadows", and the -value that is restored when the function returns. +that caller is the global scope or another shell function. This is also +the value that a local variable declaration shadows, and the value that +is restored when the function returns. - For example, if a variable 'var' is declared as local in function -'func1', and 'func1' calls another function 'func2', references to 'var' -made from within 'func2' will resolve to the local variable 'var' from -'func1', shadowing any global variable named 'var'. + For example, if a variable ‘var’ is declared as local in function +‘func1’, and ‘func1’ calls another function ‘func2’, references to ‘var’ +made from within ‘func2’ resolve to the local variable ‘var’ from +‘func1’, shadowing any global variable named ‘var’. The following script demonstrates this behavior. When executed, the script displays @@ -1422,29 +1443,30 @@ script displays var=global func1 - The 'unset' builtin also acts using the same dynamic scope: if a -variable is local to the current scope, 'unset' will unset it; otherwise -the unset will refer to the variable found in any calling scope as -described above. If a variable at the current local scope is unset, it -will remain so (appearing as unset) until it is reset in that scope or -until the function returns. Once the function returns, any instance of -the variable at a previous scope will become visible. If the unset acts -on a variable at a previous scope, any instance of a variable with that -name that had been shadowed will become visible (see below how -'localvar_unset'shell option changes this behavior). - - Function names and definitions may be listed with the '-f' option to -the 'declare' ('typeset') builtin command (*note Bash Builtins::). The -'-F' option to 'declare' or 'typeset' will list the function names only -(and optionally the source file and line number, if the 'extdebug' shell -option is enabled). Functions may be exported so that child shell -processes (those created when executing a separate shell invocation) -automatically have them defined with the '-f' option to the 'export' -builtin (*note Bourne Shell Builtins::). - - Functions may be recursive. The 'FUNCNEST' variable may be used to + The ‘unset’ builtin also acts using the same dynamic scope: if a +variable is local to the current scope, ‘unset’ unsets it; otherwise the +unset will refer to the variable found in any calling scope as described +above. If a variable at the current local scope is unset, it remains so +(appearing as unset) until it is reset in that scope or until the +function returns. Once the function returns, any instance of the +variable at a previous scope becomes visible. If the unset acts on a +variable at a previous scope, any instance of a variable with that name +that had been shadowed becomes visible (see below how the +‘localvar_unset’ shell option changes this behavior). + + The ‘-f’ option to the ‘declare’ (‘typeset’) builtin command (*note +Bash Builtins::) lists function names and definitions. The ‘-F’ option +to ‘declare’ or ‘typeset’ lists the function names only (and optionally +the source file and line number, if the ‘extdebug’ shell option is +enabled). Functions may be exported so that child shell processes +(those created when executing a separate shell invocation) automatically +have them defined with the ‘-f’ option to the ‘export’ builtin (*note +Bourne Shell Builtins::). The ‘-f’ option to the ‘unset’ builtin (*note +Bourne Shell Builtins::) deletes a function definition. + + Functions may be recursive. The ‘FUNCNEST’ variable may be used to limit the depth of the function call stack and restrict the number of -function invocations. By default, no limit is placed on the number of +function invocations. By default, Bash places no limit on the number of recursive calls.  @@ -1458,50 +1480,54 @@ File: bash.info, Node: Shell Parameters, Next: Shell Expansions, Prev: Shell * Positional Parameters:: The shell's command-line arguments. * Special Parameters:: Parameters denoted by special characters. -A "parameter" is an entity that stores values. It can be a 'name', a -number, or one of the special characters listed below. A "variable" is -a parameter denoted by a 'name'. A variable has a 'value' and zero or -more 'attributes'. Attributes are assigned using the 'declare' builtin -command (see the description of the 'declare' builtin in *note Bash -Builtins::). +A “parameter” is an entity that stores values. It can be a ‘name’, a +number, or one of the special characters listed below. A “variable” is +a parameter denoted by a ‘name’. A variable has a ‘value’ and zero or +more ‘attributes’. Attributes are assigned using the ‘declare’ builtin +command (see the description of the ‘declare’ builtin in *note Bash +Builtins::). The ‘export’ and ‘readonly’ builtins assign specific +attributes. A parameter is set if it has been assigned a value. The null string is a valid value. Once a variable is set, it may be unset only by using -the 'unset' builtin command. +the ‘unset’ builtin command. - A variable may be assigned to by a statement of the form + A variable is assigned to using a statement of the form NAME=[VALUE] If VALUE is not given, the variable is assigned the null string. All VALUEs undergo tilde expansion, parameter and variable expansion, command substitution, arithmetic expansion, and quote removal (*note -Shell Parameter Expansion::). If the variable has its 'integer' +Shell Parameter Expansion::). If the variable has its ‘integer’ attribute set, then VALUE is evaluated as an arithmetic expression even -if the '$((...))' expansion is not used (*note Arithmetic Expansion::). +if the ‘$((...))’ expansion is not used (*note Arithmetic Expansion::). Word splitting and filename expansion are not performed. Assignment -statements may also appear as arguments to the 'alias', 'declare', -'typeset', 'export', 'readonly', and 'local' builtin commands -("declaration" commands). When in POSIX mode (*note Bash POSIX Mode::), +statements may also appear as arguments to the ‘alias’, ‘declare’, +‘typeset’, ‘export’, ‘readonly’, and ‘local’ builtin commands +(“declaration commands”). When in POSIX mode (*note Bash POSIX Mode::), these builtins may appear in a command after one or more instances of -the 'command' builtin and retain these assignment statement properties. +the ‘command’ builtin and retain these assignment statement properties. +For example, + command export var=value In the context where an assignment statement is assigning a value to -a shell variable or array index (*note Arrays::), the '+=' operator can -be used to append to or add to the variable's previous value. This -includes arguments to builtin commands such as 'declare' that accept -assignment statements (declaration commands). When '+=' is applied to a -variable for which the 'integer' attribute has been set, VALUE is -evaluated as an arithmetic expression and added to the variable's -current value, which is also evaluated. When '+=' is applied to an +a shell variable or array index (*note Arrays::), the ‘+=’ operator +appends to or adds to the variable's previous value. This includes +arguments to declaration commands such as ‘declare’ that accept +assignment statements. When ‘+=’ is applied to a variable for which the +‘integer’ attribute has been set, the variable's current value and VALUE +are each evaluated as arithmetic expressions, and the sum of the results +is assigned as the variable's value. The current value is usually an +integer constant, but may be an expression. When ‘+=’ is applied to an array variable using compound assignment (*note Arrays::), the -variable's value is not unset (as it is when using '='), and new values +variable's value is not unset (as it is when using ‘=’), and new values are appended to the array beginning at one greater than the array's maximum index (for indexed arrays), or added as additional key-value pairs in an associative array. When applied to a string-valued variable, VALUE is expanded and appended to the variable's value. - A variable can be assigned the 'nameref' attribute using the '-n' -option to the 'declare' or 'local' builtin commands (*note Bash -Builtins::) to create a "nameref", or a reference to another variable. + A variable can be assigned the ‘nameref’ attribute using the ‘-n’ +option to the ‘declare’ or ‘local’ builtin commands (*note Bash +Builtins::) to create a “nameref”, or a reference to another variable. This allows variables to be manipulated indirectly. Whenever the nameref variable is referenced, assigned to, unset, or has its attributes modified (other than using or changing the nameref attribute @@ -1511,21 +1537,25 @@ shell functions to refer to a variable whose name is passed as an argument to the function. For instance, if a variable name is passed to a shell function as its first argument, running declare -n ref=$1 -inside the function creates a nameref variable 'ref' whose value is the -variable name passed as the first argument. References and assignments -to 'ref', and changes to its attributes, are treated as references, -assignments, and attribute modifications to the variable whose name was -passed as '$1'. +inside the function creates a local nameref variable ‘ref’ whose value +is the variable name passed as the first argument. References and +assignments to ‘ref’, and changes to its attributes, are treated as +references, assignments, and attribute modifications to the variable +whose name was passed as ‘$1’. - If the control variable in a 'for' loop has the nameref attribute, + If the control variable in a ‘for’ loop has the nameref attribute, the list of words can be a list of shell variables, and a name reference -will be established for each word in the list, in turn, when the loop is +is established for each word in the list, in turn, when the loop is executed. Array variables cannot be given the nameref attribute. However, nameref variables can reference array variables and subscripted -array variables. Namerefs can be unset using the '-n' option to the -'unset' builtin (*note Bourne Shell Builtins::). Otherwise, if 'unset' +array variables. Namerefs can be unset using the ‘-n’ option to the +‘unset’ builtin (*note Bourne Shell Builtins::). Otherwise, if ‘unset’ is executed with the name of a nameref variable as an argument, the -variable referenced by the nameref variable will be unset. +variable referenced by the nameref variable is unset. + + When the shell starts, it reads its environment and creates a shell +variable from each environment variable that has a valid name, as +described below (*note Environment::).  File: bash.info, Node: Positional Parameters, Next: Special Parameters, Up: Shell Parameters @@ -1533,18 +1563,20 @@ File: bash.info, Node: Positional Parameters, Next: Special Parameters, Up: S 3.4.1 Positional Parameters --------------------------- -A "positional parameter" is a parameter denoted by one or more digits, -other than the single digit '0'. Positional parameters are assigned +A “positional parameter” is a parameter denoted by one or more digits, +other than the single digit ‘0’. Positional parameters are assigned from the shell's arguments when it is invoked, and may be reassigned -using the 'set' builtin command. Positional parameter 'N' may be -referenced as '${N}', or as '$N' when 'N' consists of a single digit. +using the ‘set’ builtin command. Positional parameter ‘N’ may be +referenced as ‘${N}’, or as ‘$N’ when ‘N’ consists of a single digit. Positional parameters may not be assigned to with assignment statements. -The 'set' and 'shift' builtins are used to set and unset them (*note +The ‘set’ and ‘shift’ builtins are used to set and unset them (*note Shell Builtin Commands::). The positional parameters are temporarily replaced when a shell function is executed (*note Shell Functions::). When a positional parameter consisting of more than a single digit is -expanded, it must be enclosed in braces. +expanded, it must be enclosed in braces. Without braces, a digit +following ‘$’ can only refer to one of the first nine positional +parameters ($1\-$9) or the special parameter $0 (see below).  File: bash.info, Node: Special Parameters, Prev: Positional Parameters, Up: Shell Parameters @@ -1553,65 +1585,67 @@ File: bash.info, Node: Special Parameters, Prev: Positional Parameters, Up: S ------------------------ The shell treats several parameters specially. These parameters may -only be referenced; assignment to them is not allowed. +only be referenced; assignment to them is not allowed. Special +parameters are denoted by one of the following characters. -'*' +‘*’ ($*) Expands to the positional parameters, starting from one. When the expansion is not within double quotes, each positional - parameter expands to a separate word. In contexts where it is - performed, those words are subject to further word splitting and - filename expansion. When the expansion occurs within double - quotes, it expands to a single word with the value of each - parameter separated by the first character of the 'IFS' special - variable. That is, '"$*"' is equivalent to '"$1C$2C..."', where C - is the first character of the value of the 'IFS' variable. If - 'IFS' is unset, the parameters are separated by spaces. If 'IFS' - is null, the parameters are joined without intervening separators. - -'@' + parameter expands to a separate word. In contexts where word + expansions are performed, those words are subject to further word + splitting and filename expansion. When the expansion occurs within + double quotes, it expands to a single word with the value of each + parameter separated by the first character of the ‘IFS’ variable. + That is, ‘"$*"’ is equivalent to ‘"$1C$2C..."’, where C is the + first character of the value of the ‘IFS’ variable. If ‘IFS’ is + unset, the parameters are separated by spaces. If ‘IFS’ is null, + the parameters are joined without intervening separators. + +‘@’ ($@) Expands to the positional parameters, starting from one. In contexts where word splitting is performed, this expands each positional parameter to a separate word; if not within double quotes, these words are subject to word splitting. In contexts - where word splitting is not performed, this expands to a single - word with each positional parameter separated by a space. When the - expansion occurs within double quotes, and word splitting is - performed, each parameter expands to a separate word. That is, - '"$@"' is equivalent to '"$1" "$2" ...'. If the double-quoted - expansion occurs within a word, the expansion of the first - parameter is joined with the beginning part of the original word, - and the expansion of the last parameter is joined with the last - part of the original word. When there are no positional - parameters, '"$@"' and '$@' expand to nothing (i.e., they are - removed). - -'#' + where word splitting is not performed, such as the value portion of + an assignment statement, this expands to a single word with each + positional parameter separated by a space. When the expansion + occurs within double quotes, and word splitting is performed, each + parameter expands to a separate word. That is, ‘"$@"’ is + equivalent to ‘"$1" "$2" ...’. If the double-quoted expansion + occurs within a word, the expansion of the first parameter is + joined with the expansion of the beginning part of the original + word, and the expansion of the last parameter is joined with the + expansion of the last part of the original word. When there are no + positional parameters, ‘"$@"’ and ‘$@’ expand to nothing (i.e., + they are removed). + +‘#’ ($#) Expands to the number of positional parameters in decimal. -'?' +‘?’ ($?) Expands to the exit status of the most recently executed - foreground pipeline. + command. -'-' +‘-’ ($-, a hyphen.) Expands to the current option flags as specified - upon invocation, by the 'set' builtin command, or those set by the - shell itself (such as the '-i' option). + upon invocation, by the ‘set’ builtin command, or those set by the + shell itself (such as the ‘-i’ option). -'$' +‘$’ ($$) Expands to the process ID of the shell. In a subshell, it expands to the process ID of the invoking shell, not the subshell. -'!' +‘!’ ($!) Expands to the process ID of the job most recently placed into the background, whether executed as an asynchronous command or - using the 'bg' builtin (*note Job Control Builtins::). + using the ‘bg’ builtin (*note Job Control Builtins::). -'0' +‘0’ ($0) Expands to the name of the shell or shell script. This is set at shell initialization. If Bash is invoked with a file of - commands (*note Shell Scripts::), '$0' is set to the name of that - file. If Bash is started with the '-c' option (*note Invoking - Bash::), then '$0' is set to the first argument after the string to + commands (*note Shell Scripts::), ‘$0’ is set to the name of that + file. If Bash is started with the ‘-c’ option (*note Invoking + Bash::), then ‘$0’ is set to the first argument after the string to be executed, if one is present. Otherwise, it is set to the filename used to invoke Bash, as given by argument zero. @@ -1622,15 +1656,16 @@ File: bash.info, Node: Shell Expansions, Next: Redirections, Prev: Shell Para ==================== Expansion is performed on the command line after it has been split into -'token's. There are seven kinds of expansion performed: +‘token’s. Bash performs these expansions: - * brace expansion - * tilde expansion - * parameter and variable expansion - * command substitution - * arithmetic expansion - * word splitting - * filename expansion + • brace expansion + • tilde expansion + • parameter and variable expansion + • command substitution + • arithmetic expansion + • word splitting + • filename expansion + • quote removal * Menu: @@ -1649,26 +1684,24 @@ Expansion is performed on the command line after it has been split into The order of expansions is: brace expansion; tilde expansion, parameter and variable expansion, arithmetic expansion, and command -substitution (done in a left-to-right fashion); word splitting; and -filename expansion. +substitution (done in a left-to-right fashion); word splitting; filename +expansion; and quote removal. On systems that can support it, there is an additional expansion -available: "process substitution". This is performed at the same time +available: “process substitution”. This is performed at the same time as tilde, parameter, variable, and arithmetic expansion and command substitution. - After these expansions are performed, quote characters present in the -original word are removed unless they have been quoted themselves -("quote removal"). + “Quote removal” is always performed last. It removes quote +characters present in the original word, not ones resulting from one of +the other expansions, unless they have been quoted themselves. *Note +Quote Removal:: for more details. Only brace expansion, word splitting, and filename expansion can increase the number of words of the expansion; other expansions expand a single word to a single word. The only exceptions to this are the -expansions of '"$@"' and '$*' (*note Special Parameters::), and -'"${NAME[@]}"' and '${NAME[*]}' (*note Arrays::). - - After all expansions, 'quote removal' (*note Quote Removal::) is -performed. +expansions of ‘"$@"’ and ‘$*’ (*note Special Parameters::), and +‘"${NAME[@]}"’ and ‘${NAME[*]}’ (*note Arrays::).  File: bash.info, Node: Brace Expansion, Next: Tilde Expansion, Up: Shell Expansions @@ -1676,30 +1709,29 @@ File: bash.info, Node: Brace Expansion, Next: Tilde Expansion, Up: Shell Expa 3.5.1 Brace Expansion --------------------- -Brace expansion is a mechanism by which arbitrary strings may be -generated. This mechanism is similar to "filename expansion" (*note -Filename Expansion::), but the filenames generated need not exist. -Patterns to be brace expanded take the form of an optional PREAMBLE, -followed by either a series of comma-separated strings or a sequence -expression between a pair of braces, followed by an optional POSTSCRIPT. -The preamble is prefixed to each string contained within the braces, and -the postscript is then appended to each resulting string, expanding left -to right. +Brace expansion is a mechanism to generate arbitrary strings sharing a +common prefix and suffix, either of which can be empty. This mechanism +is similar to “filename expansion” (*note Filename Expansion::), but the +filenames generated need not exist. Patterns to be brace expanded are +formed from an optional PREAMBLE, followed by either a series of +comma-separated strings or a sequence expression between a pair of +braces, followed by an optional POSTSCRIPT. The preamble is prefixed to +each string contained within the braces, and the postscript is then +appended to each resulting string, expanding left to right. Brace expansions may be nested. The results of each expanded string -are not sorted; left to right order is preserved. For example, +are not sorted; brace expansion preserves left to right order. For +example, bash$ echo a{d,c,b}e ade ace abe - A sequence expression takes the form '{X..Y[..INCR]}', where X and Y + A sequence expression takes the form ‘X..Y[..INCR]’, where X and Y are either integers or letters, and INCR, an optional increment, is an integer. When integers are supplied, the expression expands to each -number between X and Y, inclusive. Supplied integers may be prefixed -with '0' to force each term to have the same width. When either X or Y -begins with a zero, the shell attempts to force all generated terms to -contain the same number of digits, zero-padding where necessary. When -letters are supplied, the expression expands to each character -lexicographically between X and Y, inclusive, using the default C +number between X and Y, inclusive. If either X or Y begins with a zero, +each generated term will contain the same number of digits, zero-padding +where necessary. When letters are supplied, the expression expands to +each character lexicographically between X and Y, inclusive, using the C locale. Note that both X and Y must be of the same type (integer or letter). When the increment is supplied, it is used as the difference between each term. The default increment is 1 or -1 as appropriate. @@ -1713,10 +1745,10 @@ to the context of the expansion or the text between the braces. closing braces, and at least one unquoted comma or a valid sequence expression. Any incorrectly formed brace expansion is left unchanged. - A { or ',' may be quoted with a backslash to prevent its being + A ‘{’ or ‘,’ may be quoted with a backslash to prevent its being considered part of a brace expression. To avoid conflicts with -parameter expansion, the string '${' is not considered eligible for -brace expansion, and inhibits brace expansion until the closing '}'. +parameter expansion, the string ‘${’ is not considered eligible for +brace expansion, and inhibits brace expansion until the closing ‘}’. This construct is typically used as shorthand when the common prefix of the strings to be generated is longer than in the above example: @@ -1724,68 +1756,82 @@ of the strings to be generated is longer than in the above example: or chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}} + Brace expansion introduces a slight incompatibility with historical +versions of ‘sh’. ‘sh’ does not treat opening or closing braces +specially when they appear as part of a word, and preserves them in the +output. Bash removes braces from words as a consequence of brace +expansion. For example, a word entered to ‘sh’ as ‘file{1,2}’ appears +identically in the output. Bash outputs that word as ‘file1 file2’ +after brace expansion. Start Bash with the ‘+B’ option or disable brace +expansion with the ‘+B’ option to the ‘set’ command (*note Shell Builtin +Commands::) for strict ‘sh’ compatibility. +  File: bash.info, Node: Tilde Expansion, Next: Shell Parameter Expansion, Prev: Brace Expansion, Up: Shell Expansions 3.5.2 Tilde Expansion --------------------- -If a word begins with an unquoted tilde character ('~'), all of the +If a word begins with an unquoted tilde character (‘~’), all of the characters up to the first unquoted slash (or all characters, if there -is no unquoted slash) are considered a "tilde-prefix". If none of the +is no unquoted slash) are considered a “tilde-prefix”. If none of the characters in the tilde-prefix are quoted, the characters in the -tilde-prefix following the tilde are treated as a possible "login name". +tilde-prefix following the tilde are treated as a possible “login name”. If this login name is the null string, the tilde is replaced with the -value of the 'HOME' shell variable. If 'HOME' is unset, the home -directory of the user executing the shell is substituted instead. +value of the ‘HOME’ shell variable. If ‘HOME’ is unset, the tilde +expands to the home directory of the user executing the shell instead. Otherwise, the tilde-prefix is replaced with the home directory associated with the specified login name. - If the tilde-prefix is '~+', the value of the shell variable 'PWD' -replaces the tilde-prefix. If the tilde-prefix is '~-', the value of -the shell variable 'OLDPWD', if it is set, is substituted. + If the tilde-prefix is ‘~+’, the value of the shell variable ‘PWD’ +replaces the tilde-prefix. If the tilde-prefix is ‘~-’, the shell +substitutes the value of the shell variable ‘OLDPWD’, if it is set. If the characters following the tilde in the tilde-prefix consist of -a number N, optionally prefixed by a '+' or a '-', the tilde-prefix is +a number N, optionally prefixed by a ‘+’ or a ‘-’, the tilde-prefix is replaced with the corresponding element from the directory stack, as it -would be displayed by the 'dirs' builtin invoked with the characters +would be displayed by the ‘dirs’ builtin invoked with the characters following tilde in the tilde-prefix as an argument (*note The Directory Stack::). If the tilde-prefix, sans the tilde, consists of a number -without a leading '+' or '-', '+' is assumed. +without a leading ‘+’ or ‘-’, tilde expansion assumes ‘+’. + + The results of tilde expansion are treated as if they were quoted, so +the replacement is not subject to word splitting and filename expansion. - If the login name is invalid, or the tilde expansion fails, the word -is left unchanged. + If the login name is invalid, or the tilde expansion fails, the +tilde-prefix is left unchanged. - Each variable assignment is checked for unquoted tilde-prefixes -immediately following a ':' or the first '='. In these cases, tilde -expansion is also performed. Consequently, one may use filenames with -tildes in assignments to 'PATH', 'MAILPATH', and 'CDPATH', and the shell + Bash checks each variable assignment for unquoted tilde-prefixes +immediately following a ‘:’ or the first ‘=’, and performs tilde +expansion in these cases. Consequently, one may use filenames with +tildes in assignments to ‘PATH’, ‘MAILPATH’, and ‘CDPATH’, and the shell assigns the expanded value. The following table shows how Bash treats unquoted tilde-prefixes: -'~' - The value of '$HOME' -'~/foo' - '$HOME/foo' +‘~’ + The value of ‘$HOME’. +‘~/foo’ + ‘$HOME/foo’ -'~fred/foo' - The subdirectory 'foo' of the home directory of the user 'fred' +‘~fred/foo’ + The directory or file ‘foo’ in the home directory of the user + ‘fred’. -'~+/foo' - '$PWD/foo' +‘~+/foo’ + ‘$PWD/foo’ -'~-/foo' - '${OLDPWD-'~-'}/foo' +‘~-/foo’ + ‘${OLDPWD-'~-'}/foo’ -'~N' - The string that would be displayed by 'dirs +N' +‘~N’ + The string that would be displayed by ‘dirs +N’. -'~+N' - The string that would be displayed by 'dirs +N' +‘~+N’ + The string that would be displayed by ‘dirs +N’. -'~-N' - The string that would be displayed by 'dirs -N' +‘~-N’ + The string that would be displayed by ‘dirs -N’. Bash also performs tilde expansion on words satisfying the conditions of variable assignments (*note Shell Parameters::) when they appear as @@ -1798,104 +1844,159 @@ File: bash.info, Node: Shell Parameter Expansion, Next: Command Substitution, 3.5.3 Shell Parameter Expansion ------------------------------- -The '$' character introduces parameter expansion, command substitution, +The ‘$’ character introduces parameter expansion, command substitution, or arithmetic expansion. The parameter name or symbol to be expanded may be enclosed in braces, which are optional but serve to protect the variable to be expanded from characters immediately following it which -could be interpreted as part of the name. +could be interpreted as part of the name. For example, if the first +positional parameter has the value ‘a’, then ‘${11}’ expands to the +value of the eleventh positional parameter, while ‘$11’ expands to ‘a1’. - When braces are used, the matching ending brace is the first '}' not + When braces are used, the matching ending brace is the first ‘}’ not escaped by a backslash or within a quoted string, and not within an embedded arithmetic expansion, command substitution, or parameter expansion. - The basic form of parameter expansion is ${PARAMETER}. The value of -PARAMETER is substituted. The PARAMETER is a shell parameter as -described above (*note Shell Parameters::) or an array reference (*note -Arrays::). The braces are required when PARAMETER is a positional -parameter with more than one digit, or when PARAMETER is followed by a -character that is not to be interpreted as part of its name. + The basic form of parameter expansion is ${PARAMETER}, which +substitutes the value of PARAMETER. The PARAMETER is a shell parameter +as described above (*note Shell Parameters::) or an array reference +(*note Arrays::). The braces are required when PARAMETER is a +positional parameter with more than one digit, or when PARAMETER is +followed by a character that is not to be interpreted as part of its +name. If the first character of PARAMETER is an exclamation point (!), and PARAMETER is not a nameref, it introduces a level of indirection. Bash uses the value formed by expanding the rest of PARAMETER as the new -PARAMETER; this is then expanded and that value is used in the rest of -the expansion, rather than the expansion of the original PARAMETER. -This is known as 'indirect expansion'. The value is subject to tilde -expansion, parameter expansion, command substitution, and arithmetic -expansion. If PARAMETER is a nameref, this expands to the name of the -variable referenced by PARAMETER instead of performing the complete -indirect expansion. The exceptions to this are the expansions of -${!PREFIX*} and ${!NAME[@]} described below. The exclamation point must -immediately follow the left brace in order to introduce indirection. +PARAMETER; this new parameter is then expanded and that value is used in +the rest of the expansion, rather than the expansion of the original +PARAMETER. This is known as ‘indirect expansion’. The value is subject +to tilde expansion, parameter expansion, command substitution, and +arithmetic expansion. If PARAMETER is a nameref, this expands to the +name of the variable referenced by PARAMETER instead of performing the +complete indirect expansion, for compatibility. The exceptions to this +are the expansions of ${!PREFIX*} and ${!NAME[@]} described below. The +exclamation point must immediately follow the left brace in order to +introduce indirection. In each of the cases below, WORD is subject to tilde expansion, parameter expansion, command substitution, and arithmetic expansion. - When not performing substring expansion, using the form described -below (e.g., ':-'), Bash tests for a parameter that is unset or null. + When not performing substring expansion, using the forms described +below (e.g., ‘:-’), Bash tests for a parameter that is unset or null. Omitting the colon results in a test only for a parameter that is unset. Put another way, if the colon is included, the operator tests for both PARAMETER's existence and that its value is not null; if the colon is omitted, the operator tests only for existence. -'${PARAMETER:-WORD}' +‘${PARAMETER:−WORD}’ If PARAMETER is unset or null, the expansion of WORD is substituted. Otherwise, the value of PARAMETER is substituted. $ v=123 $ echo ${v-unset} 123 + $ echo ${v:-unset-or-null} + 123 + $ unset v + $ echo ${v-unset} + unset + $ v= + $ echo ${v-unset} + + $ echo ${v:-unset-or-null} + unset-or-null -'${PARAMETER:=WORD}' +‘${PARAMETER:=WORD}’ If PARAMETER is unset or null, the expansion of WORD is assigned to - PARAMETER. The value of PARAMETER is then substituted. Positional - parameters and special parameters may not be assigned to in this - way. + PARAMETER, and the result of the expansion is the final value of + PARAMETER. Positional parameters and special parameters may not be + assigned in this way. + + $ unset var + $ : ${var=DEFAULT} + $ echo $var + DEFAULT + $ var= + $ : ${var=DEFAULT} + $ echo $var $ var= $ : ${var:=DEFAULT} $ echo $var DEFAULT + $ unset var + $ : ${var:=DEFAULT} + $ echo $var + DEFAULT -'${PARAMETER:?WORD}' - If PARAMETER is null or unset, the expansion of WORD (or a message - to that effect if WORD is not present) is written to the standard - error and the shell, if it is not interactive, exits. Otherwise, - the value of PARAMETER is substituted. +‘${PARAMETER:?WORD}’ + If PARAMETER is null or unset, the shell writes the expansion of + WORD (or a message to that effect if WORD is not present) to the + standard error and, if it is not interactive, exits with a non-zero + status. An interactive shell does not exit, but does not execute + the command associated with the expansion. Otherwise, the value of + PARAMETER is substituted. $ var= $ : ${var:?var is unset or null} bash: var: var is unset or null + $ echo ${var?var is unset} + + $ unset var + $ : ${var?var is unset} + bash: var: var is unset + $ : ${var:?var is unset or null} + bash: var: var is unset or null + $ var=123 + $ echo ${var:?var is unset or null} + 123 -'${PARAMETER:+WORD}' +‘${PARAMETER:+WORD}’ If PARAMETER is null or unset, nothing is substituted, otherwise - the expansion of WORD is substituted. + the expansion of WORD is substituted. The value of PARAMETER is + not used. $ var=123 $ echo ${var:+var is set and not null} var is set and not null + $ echo ${var+var is set} + var is set + $ var= + $ echo ${var:+var is set and not null} + + $ echo ${var+var is set} + var is set + $ unset var + $ echo ${var+var is set} -'${PARAMETER:OFFSET}' -'${PARAMETER:OFFSET:LENGTH}' + $ echo ${var:+var is set and not null} + + $ + +‘${PARAMETER:OFFSET}’ +‘${PARAMETER:OFFSET:LENGTH}’ This is referred to as Substring Expansion. It expands to up to LENGTH characters of the value of PARAMETER starting at the - character specified by OFFSET. If PARAMETER is '@' or '*', an - indexed array subscripted by '@' or '*', or an associative array - name, the results differ as described below. If LENGTH is omitted, - it expands to the substring of the value of PARAMETER starting at - the character specified by OFFSET and extending to the end of the - value. LENGTH and OFFSET are arithmetic expressions (*note Shell - Arithmetic::). + character specified by OFFSET. If PARAMETER is ‘@’ or ‘*’, an + indexed array subscripted by ‘@’ or ‘*’, or an associative array + name, the results differ as described below. If :LENGTH is omitted + (the first form above), this expands to the substring of the value + of PARAMETER starting at the character specified by OFFSET and + extending to the end of the value. If OFFSET is omitted, it is + treated as 0. If LENGTH is omitted, but the colon after OFFSET is + present, it is treated as 0. LENGTH and OFFSET are arithmetic + expressions (*note Shell Arithmetic::). If OFFSET evaluates to a number less than zero, the value is used as an offset in characters from the end of the value of PARAMETER. If LENGTH evaluates to a number less than zero, it is interpreted as an offset in characters from the end of the value of PARAMETER rather than a number of characters, and the expansion is the - characters between OFFSET and that result. Note that a negative - offset must be separated from the colon by at least one space to - avoid being confused with the ':-' expansion. + characters between OFFSET and that result. + + Note that a negative offset must be separated from the colon by at + least one space to avoid being confused with the ‘:-’ expansion. Here are some examples illustrating substring expansion on parameters and subscripted arrays: @@ -1952,11 +2053,12 @@ omitted, the operator tests only for existence. $ echo ${array[0]: -7:-2} bcdef - If PARAMETER is '@' or '*', the result is LENGTH positional + If PARAMETER is ‘@’ or ‘*’, the result is LENGTH positional parameters beginning at OFFSET. A negative OFFSET is taken relative to one greater than the greatest positional parameter, so - an offset of -1 evaluates to the last positional parameter. It is - an expansion error if LENGTH evaluates to a number less than zero. + an offset of -1 evaluates to the last positional parameter (or 0 if + there are no positional parameters). It is an expansion error if + LENGTH evaluates to a number less than zero. The following examples illustrate substring expansion using positional parameters: @@ -1979,9 +2081,9 @@ omitted, the operator tests only for existence. $ echo ${@: -7:0} - If PARAMETER is an indexed array name subscripted by '@' or '*', + If PARAMETER is an indexed array name subscripted by ‘@’ or ‘*’, the result is the LENGTH members of the array beginning with - '${PARAMETER[OFFSET]}'. A negative OFFSET is taken relative to one + ‘${PARAMETER[OFFSET]}’. A negative OFFSET is taken relative to one greater than the maximum index of the specified array. It is an expansion error if LENGTH evaluates to a number less than zero. @@ -2009,101 +2111,102 @@ omitted, the operator tests only for existence. Substring indexing is zero-based unless the positional parameters are used, in which case the indexing starts at 1 by default. If - OFFSET is 0, and the positional parameters are used, '$0' is + OFFSET is 0, and the positional parameters are used, ‘$0’ is prefixed to the list. -'${!PREFIX*}' -'${!PREFIX@}' +‘${!PREFIX*}’ +‘${!PREFIX@}’ Expands to the names of variables whose names begin with PREFIX, - separated by the first character of the 'IFS' special variable. - When '@' is used and the expansion appears within double quotes, + separated by the first character of the ‘IFS’ special variable. + When ‘@’ is used and the expansion appears within double quotes, each variable name expands to a separate word. -'${!NAME[@]}' -'${!NAME[*]}' +‘${!NAME[@]}’ +‘${!NAME[*]}’ If NAME is an array variable, expands to the list of array indices (keys) assigned in NAME. If NAME is not an array, expands to 0 if - NAME is set and null otherwise. When '@' is used and the expansion + NAME is set and null otherwise. When ‘@’ is used and the expansion appears within double quotes, each key expands to a separate word. -'${#PARAMETER}' - The length in characters of the expanded value of PARAMETER is - substituted. If PARAMETER is '*' or '@', the value substituted is - the number of positional parameters. If PARAMETER is an array name - subscripted by '*' or '@', the value substituted is the number of - elements in the array. If PARAMETER is an indexed array name - subscripted by a negative number, that number is interpreted as - relative to one greater than the maximum index of PARAMETER, so - negative indices count back from the end of the array, and an index - of -1 references the last element. - -'${PARAMETER#WORD}' -'${PARAMETER##WORD}' - The WORD is expanded to produce a pattern and matched according to - the rules described below (*note Pattern Matching::). If the - pattern matches the beginning of the expanded value of PARAMETER, - then the result of the expansion is the expanded value of PARAMETER - with the shortest matching pattern (the '#' case) or the longest - matching pattern (the '##' case) deleted. If PARAMETER is '@' or - '*', the pattern removal operation is applied to each positional - parameter in turn, and the expansion is the resultant list. If - PARAMETER is an array variable subscripted with '@' or '*', the - pattern removal operation is applied to each member of the array in - turn, and the expansion is the resultant list. - -'${PARAMETER%WORD}' -'${PARAMETER%%WORD}' - The WORD is expanded to produce a pattern and matched according to - the rules described below (*note Pattern Matching::). If the - pattern matches a trailing portion of the expanded value of - PARAMETER, then the result of the expansion is the value of - PARAMETER with the shortest matching pattern (the '%' case) or the - longest matching pattern (the '%%' case) deleted. If PARAMETER is - '@' or '*', the pattern removal operation is applied to each - positional parameter in turn, and the expansion is the resultant - list. If PARAMETER is an array variable subscripted with '@' or - '*', the pattern removal operation is applied to each member of the - array in turn, and the expansion is the resultant list. - -'${PARAMETER/PATTERN/STRING}' -'${PARAMETER//PATTERN/STRING}' -'${PARAMETER/#PATTERN/STRING}' -'${PARAMETER/%PATTERN/STRING}' - The PATTERN is expanded to produce a pattern just as in filename - expansion. PARAMETER is expanded and the longest match of PATTERN - against its value is replaced with STRING. STRING undergoes tilde - expansion, parameter and variable expansion, arithmetic expansion, - command and process substitution, and quote removal. The match is - performed according to the rules described below (*note Pattern - Matching::). +‘${#PARAMETER}’ + Substitutes the length in characters of the value of PARAMETER. If + PARAMETER is ‘*’ or ‘@’, the value substituted is the number of + positional parameters. If PARAMETER is an array name subscripted + by ‘*’ or ‘@’, the value substituted is the number of elements in + the array. If PARAMETER is an indexed array name subscripted by a + negative number, that number is interpreted as relative to one + greater than the maximum index of PARAMETER, so negative indices + count back from the end of the array, and an index of -1 references + the last element. + +‘${PARAMETER#WORD}’ +‘${PARAMETER##WORD}’ + The WORD is expanded to produce a pattern and matched against the + expanded value of PARAMETER according to the rules described below + (*note Pattern Matching::). If the pattern matches the beginning + of the expanded value of PARAMETER, then the result of the + expansion is the expanded value of PARAMETER with the shortest + matching pattern (the ‘#’ case) or the longest matching pattern + (the ‘##’ case) deleted. If PARAMETER is ‘@’ or ‘*’, the pattern + removal operation is applied to each positional parameter in turn, + and the expansion is the resultant list. If PARAMETER is an array + variable subscripted with ‘@’ or ‘*’, the pattern removal operation + is applied to each member of the array in turn, and the expansion + is the resultant list. + +‘${PARAMETER%WORD}’ +‘${PARAMETER%%WORD}’ + The WORD is expanded to produce a pattern and matched against the + expanded value of PARAMETER according to the rules described below + (*note Pattern Matching::). If the pattern matches a trailing + portion of the expanded value of PARAMETER, then the result of the + expansion is the value of PARAMETER with the shortest matching + pattern (the ‘%’ case) or the longest matching pattern (the ‘%%’ + case) deleted. If PARAMETER is ‘@’ or ‘*’, the pattern removal + operation is applied to each positional parameter in turn, and the + expansion is the resultant list. If PARAMETER is an array variable + subscripted with ‘@’ or ‘*’, the pattern removal operation is + applied to each member of the array in turn, and the expansion is + the resultant list. + +‘${PARAMETER/PATTERN/STRING}’ +‘${PARAMETER//PATTERN/STRING}’ +‘${PARAMETER/#PATTERN/STRING}’ +‘${PARAMETER/%PATTERN/STRING}’ + The PATTERN is expanded to produce a pattern and matched against + the expanded value of PARAMETER as described below (*note Pattern + Matching::). The longest match of PATTERN in the expanded value is + replaced with STRING. STRING undergoes tilde expansion, parameter + and variable expansion, arithmetic expansion, command and process + substitution, and quote removal. In the first form above, only the first match is replaced. If there are two slashes separating PARAMETER and PATTERN (the second form above), all matches of PATTERN are replaced with STRING. If - PATTERN is preceded by '#' (the third form above), it must match at + PATTERN is preceded by ‘#’ (the third form above), it must match at the beginning of the expanded value of PARAMETER. If PATTERN is - preceded by '%' (the fourth form above), it must match at the end - of the expanded value of PARAMETER. If the expansion of STRING is - null, matches of PATTERN are deleted. If STRING is null, matches - of PATTERN are deleted and the '/' following PATTERN may be - omitted. + preceded by ‘%’ (the fourth form above), it must match at the end + of the expanded value of PARAMETER. - If the 'patsub_replacement' shell option is enabled using 'shopt', - any unquoted instances of '&' in STRING are replaced with the - matching portion of PATTERN. This is intended to duplicate a - common 'sed' idiom. + If the expansion of STRING is null, matches of PATTERN are deleted + and the ‘/’ following PATTERN may be omitted. + + If the ‘patsub_replacement’ shell option is enabled using ‘shopt’ + (*note The Shopt Builtin::), any unquoted instances of ‘&’ in + STRING are replaced with the matching portion of PATTERN. This is + intended to duplicate a common ‘sed’ idiom. Quoting any part of STRING inhibits replacement in the expansion of the quoted portion, including replacement strings stored in shell - variables. Backslash will escape '&' in STRING; the backslash is - removed in order to permit a literal '&' in the replacement string. + variables. Backslash escapes ‘&’ in STRING; the backslash is + removed in order to permit a literal ‘&’ in the replacement string. Users should take care if STRING is double-quoted to avoid unwanted interactions between the backslash and double-quoting, since backslash has special meaning within double quotes. Pattern - substitution performs the check for unquoted '&' after expanding + substitution performs the check for unquoted ‘&’ after expanding STRING, so users should ensure to properly quote any occurrences of - '&' they want to be taken literally in the replacement and ensure - any instances of '&' they want to be replaced are unquoted. + ‘&’ they want to be taken literally in the replacement and ensure + any instances of ‘&’ they want to be replaced are unquoted. For instance, @@ -2130,102 +2233,106 @@ omitted, the operator tests only for existence. a context that doesn't take any enclosing double quotes into account. - Since backslash can escape '&', it can also escape a backslash in - the replacement string. This means that '\\' will insert a literal - backslash into the replacement, so these two 'echo' commands + Since backslash can escape ‘&’, it can also escape a backslash in + the replacement string. This means that ‘\\’ will insert a literal + backslash into the replacement, so these two ‘echo’ commands var=abcdef rep='\\&xyz' echo ${var/abc/\\&xyz} echo ${var/abc/$rep} - will both output '\abcxyzdef'. + will both output ‘\abcxyzdef’. It should rarely be necessary to enclose only STRING in double quotes. - If the 'nocasematch' shell option (see the description of 'shopt' + If the ‘nocasematch’ shell option (see the description of ‘shopt’ in *note The Shopt Builtin::) is enabled, the match is performed - without regard to the case of alphabetic characters. If PARAMETER - is '@' or '*', the substitution operation is applied to each - positional parameter in turn, and the expansion is the resultant - list. If PARAMETER is an array variable subscripted with '@' or - '*', the substitution operation is applied to each member of the - array in turn, and the expansion is the resultant list. - -'${PARAMETER^PATTERN}' -'${PARAMETER^^PATTERN}' -'${PARAMETER,PATTERN}' -'${PARAMETER,,PATTERN}' + without regard to the case of alphabetic characters. + + If PARAMETER is ‘@’ or ‘*’, the substitution operation is applied + to each positional parameter in turn, and the expansion is the + resultant list. If PARAMETER is an array variable subscripted with + ‘@’ or ‘*’, the substitution operation is applied to each member of + the array in turn, and the expansion is the resultant list. + +‘${PARAMETER^PATTERN}’ +‘${PARAMETER^^PATTERN}’ +‘${PARAMETER,PATTERN}’ +‘${PARAMETER,,PATTERN}’ This expansion modifies the case of alphabetic characters in - PARAMETER. The PATTERN is expanded to produce a pattern just as in - filename expansion. Each character in the expanded value of - PARAMETER is tested against PATTERN, and, if it matches the + PARAMETER. First, the PATTERN is expanded to produce a pattern as + described below in *note Pattern Matching::. + + ‘Bash’ then examines characters in the expanded value of PARAMETER + against PATTERN as described below. If a character matches the pattern, its case is converted. The pattern should not attempt to match more than one character. - The '^' operator converts lowercase letters matching PATTERN to - uppercase; the ',' operator converts matching uppercase letters to - lowercase. The '^^' and ',,' expansions convert each matched - character in the expanded value; the '^' and ',' expansions match - and convert only the first character in the expanded value. If - PATTERN is omitted, it is treated like a '?', which matches every - character. + Using ‘^’ converts lowercase letters matching PATTERN to uppercase; + ‘,’ converts matching uppercase letters to lowercase. The ‘^’ and + ‘,’ variants examine the first character in the expanded value and + convert its case if it matches PATTERN; the ‘^^’ and ‘,,’ variants + examine all characters in the expanded value and convert each one + that matches PATTERN. If PATTERN is omitted, it is treated like a + ‘?’, which matches every character. - If PARAMETER is '@' or '*', the case modification operation is + If PARAMETER is ‘@’ or ‘*’, the case modification operation is applied to each positional parameter in turn, and the expansion is the resultant list. If PARAMETER is an array variable subscripted - with '@' or '*', the case modification operation is applied to each + with ‘@’ or ‘*’, the case modification operation is applied to each member of the array in turn, and the expansion is the resultant list. -'${PARAMETER@OPERATOR}' +‘${PARAMETER@OPERATOR}’ The expansion is either a transformation of the value of PARAMETER or information about PARAMETER itself, depending on the value of OPERATOR. Each OPERATOR is a single letter: - 'U' + ‘U’ The expansion is a string that is the value of PARAMETER with lowercase alphabetic characters converted to uppercase. - 'u' + ‘u’ The expansion is a string that is the value of PARAMETER with the first character converted to uppercase, if it is alphabetic. - 'L' + ‘L’ The expansion is a string that is the value of PARAMETER with uppercase alphabetic characters converted to lowercase. - 'Q' + ‘Q’ The expansion is a string that is the value of PARAMETER quoted in a format that can be reused as input. - 'E' + ‘E’ The expansion is a string that is the value of PARAMETER with - backslash escape sequences expanded as with the '$'...'' + backslash escape sequences expanded as with the ‘$'...'’ quoting mechanism. - 'P' + ‘P’ The expansion is a string that is the result of expanding the value of PARAMETER as if it were a prompt string (*note Controlling the Prompt::). - 'A' + ‘A’ The expansion is a string in the form of an assignment - statement or 'declare' command that, if evaluated, will - recreate PARAMETER with its attributes and value. - 'K' + statement or ‘declare’ command that, if evaluated, recreates + PARAMETER with its attributes and value. + ‘K’ Produces a possibly-quoted version of the value of PARAMETER, except that it prints the values of indexed and associative arrays as a sequence of quoted key-value pairs (*note - Arrays::). - 'a' + Arrays::). The keys and values are quoted in a format that + can be reused as input. + ‘a’ The expansion is a string consisting of flag values representing PARAMETER's attributes. - 'k' - Like the 'K' transformation, but expands the keys and values + ‘k’ + Like the ‘K’ transformation, but expands the keys and values of indexed and associative arrays to separate words after word splitting. - If PARAMETER is '@' or '*', the operation is applied to each + If PARAMETER is ‘@’ or ‘*’, the operation is applied to each positional parameter in turn, and the expansion is the resultant - list. If PARAMETER is an array variable subscripted with '@' or - '*', the operation is applied to each member of the array in turn, + list. If PARAMETER is an array variable subscripted with ‘@’ or + ‘*’, the operation is applied to each member of the array in turn, and the expansion is the resultant list. The result of the expansion is subject to word splitting and @@ -2238,30 +2345,77 @@ File: bash.info, Node: Command Substitution, Next: Arithmetic Expansion, Prev -------------------------- Command substitution allows the output of a command to replace the -command itself. Command substitution occurs when a command is enclosed -as follows: +command itself. The standard form of command substitution occurs when a +command is enclosed as follows: $(COMMAND) -or - `COMMAND` +or (deprecated) + `COMMAND`. -Bash performs the expansion by executing COMMAND in a subshell +Bash performs command substitution by executing COMMAND in a subshell environment and replacing the command substitution with the standard output of the command, with any trailing newlines deleted. Embedded newlines are not deleted, but they may be removed during word splitting. -The command substitution '$(cat FILE)' can be replaced by the equivalent -but faster '$(< FILE)'. +The command substitution ‘$(cat FILE)’ can be replaced by the equivalent +but faster ‘$(< FILE)’. - When the old-style backquote form of substitution is used, backslash -retains its literal meaning except when followed by '$', '`', or '\'. -The first backquote not preceded by a backslash terminates the command -substitution. When using the '$(COMMAND)' form, all characters between + With the old-style backquote form of substitution, backslash retains +its literal meaning except when followed by ‘$’, ‘`’, or ‘\’. The first +backquote not preceded by a backslash terminates the command +substitution. When using the ‘$(COMMAND)’ form, all characters between the parentheses make up the command; none are treated specially. + There is an alternate form of command substitution: + + ${C COMMAND; } + +which executes COMMAND in the current execution environment and captures +its output, again with trailing newlines removed. + + The character C following the open brace must be a space, tab, +newline, or ‘|’, and the close brace must be in a position where a +reserved word may appear (i.e., preceded by a command terminator such as +semicolon). Bash allows the close brace to be joined to the remaining +characters in the word without being followed by a shell metacharacter +as a reserved word would usually require. + + Any side effects of COMMAND take effect immediately in the current +execution environment and persist in the current environment after the +command completes (e.g., the ‘exit’ builtin exits the shell). + + This type of command substitution superficially resembles executing +an unnamed shell function: local variables are created as when a shell +function is executing, and the ‘return’ builtin forces COMMAND to +complete; however, the rest of the execution environment, including the +positional parameters, is shared with the caller. + + If the first character following the open brace is a ‘|’, the +construct expands to the value of the ‘REPLY’ shell variable after +COMMAND executes, without removing any trailing newlines, and the +standard output of COMMAND remains the same as in the calling shell. +Bash creates ‘REPLY’ as an initially-unset local variable when COMMAND +executes, and restores ‘REPLY’ to the value it had before the command +substitution after COMMAND completes, as with any local variable. + + For example, this construct expands to ‘12345’, and leaves the shell +variable ‘X’ unchanged in the current execution environment: + + + ${ local X=12345 ; echo $X; } + +(not declaring ‘X’ as local would modify its value in the current +environment, as with normal shell function execution), while this +construct does not require any output to expand to ‘12345’: + + ${| REPLY=12345; } + +and restores ‘REPLY’ to the value it had before the command +substitution. + Command substitutions may be nested. To nest when using the backquoted form, escape the inner backquotes with backslashes. - If the substitution appears within double quotes, word splitting and -filename expansion are not performed on the results. + If the substitution appears within double quotes, Bash does not +perform word splitting and filename expansion on the results.  File: bash.info, Node: Arithmetic Expansion, Next: Process Substitution, Prev: Command Substitution, Up: Shell Expansions @@ -2269,23 +2423,25 @@ File: bash.info, Node: Arithmetic Expansion, Next: Process Substitution, Prev 3.5.5 Arithmetic Expansion -------------------------- -Arithmetic expansion allows the evaluation of an arithmetic expression -and the substitution of the result. The format for arithmetic expansion -is: +Arithmetic expansion evaluates an arithmetic expression and substitutes +the result. The format for arithmetic expansion is: $(( EXPRESSION )) The EXPRESSION undergoes the same expansions as if it were within -double quotes, but double quote characters in EXPRESSION are not treated -specially and are removed. All tokens in the expression undergo -parameter and variable expansion, command substitution, and quote -removal. The result is treated as the arithmetic expression to be -evaluated. Arithmetic expansions may be nested. +double quotes, but unescaped double quote characters in EXPRESSION are +not treated specially and are removed. All tokens in the expression +undergo parameter and variable expansion, command substitution, and +quote removal. The result is treated as the arithmetic expression to be +evaluated. Since the way Bash handles double quotes can potentially +result in empty strings, arithmetic expansion treats those as +expressions that evaluate to 0. Arithmetic expansions may be nested. The evaluation is performed according to the rules listed below (*note Shell Arithmetic::). If the expression is invalid, Bash prints a -message indicating failure to the standard error and no substitution -occurs. +message indicating failure to the standard error, does not perform the +substitution, and does not execute the command associated with the +expansion.  File: bash.info, Node: Process Substitution, Next: Word Splitting, Prev: Arithmetic Expansion, Up: Shell Expansions @@ -2300,14 +2456,16 @@ or >(LIST) The process LIST is run asynchronously, and its input or output appears as a filename. This filename is passed as an argument to the current -command as the result of the expansion. If the '>(LIST)' form is used, -writing to the file will provide input for LIST. If the '<(LIST)' form -is used, the file passed as an argument should be read to obtain the -output of LIST. Note that no space may appear between the '<' or '>' +command as the result of the expansion. + + If the ‘>(LIST)’ form is used, writing to the file provides input for +LIST. If the ‘<(LIST)’ form is used, reading the file obtains the +output of LIST. Note that no space may appear between the ‘<’ or ‘>’ and the left parenthesis, otherwise the construct would be interpreted -as a redirection. Process substitution is supported on systems that -support named pipes (FIFOs) or the '/dev/fd' method of naming open -files. +as a redirection. + + Process substitution is supported on systems that support named pipes +(FIFOs) or the ‘/dev/fd’ method of naming open files. When available, process substitution is performed simultaneously with parameter and variable expansion, command substitution, and arithmetic @@ -2321,34 +2479,47 @@ File: bash.info, Node: Word Splitting, Next: Filename Expansion, Prev: Proces The shell scans the results of parameter expansion, command substitution, and arithmetic expansion that did not occur within double -quotes for word splitting. - - The shell treats each character of '$IFS' as a delimiter, and splits -the results of the other expansions into words using these characters as -field terminators. If 'IFS' is unset, or its value is exactly -'', the default, then sequences of ' ', -'', and '' at the beginning and end of the results of the -previous expansions are ignored, and any sequence of 'IFS' characters -not at the beginning or end serves to delimit words. If 'IFS' has a -value other than the default, then sequences of the whitespace -characters 'space', 'tab', and 'newline' are ignored at the beginning -and end of the word, as long as the whitespace character is in the value -of 'IFS' (an 'IFS' whitespace character). Any character in 'IFS' that -is not 'IFS' whitespace, along with any adjacent 'IFS' whitespace -characters, delimits a field. A sequence of 'IFS' whitespace characters -is also treated as a delimiter. If the value of 'IFS' is null, no word -splitting occurs. - - Explicit null arguments ('""' or '''') are retained and passed to +quotes for word splitting. Words that were not expanded are not split. + + The shell treats each character of ‘$IFS’ as a delimiter, and splits +the results of the other expansions into fields using these characters +as field terminators. + + An “IFS whitespace” character is whitespace as defined above (*note +Definitions::) that appears in the value of ‘IFS’. Space, tab, and +newline are always considered IFS whitespace, even if they don't appear +in the locale's ‘space’ category. + + If ‘IFS’ is unset, word splitting behaves as if its value were +‘’, and treats these characters as IFS whitespace. +If the value of ‘IFS’ is null, no word splitting occurs, but implicit +null arguments (see below) are still removed. + + Word splitting begins by removing sequences of IFS whitespace +characters from the beginning and end of the results of the previous +expansions, then splits the remaining words. + + If the value of ‘IFS’ consists solely of IFS whitespace, any sequence +of IFS whitespace characters delimits a field, so a field consists of +characters that are not unquoted IFS whitespace, and null fields result +only from quoting. + + If ‘IFS’ contains a non-whitespace character, then any character in +the value of ‘IFS’ that is not IFS whitespace, along with any adjacent +IFS whitespace characters, delimits a field. This means that adjacent +non-IFS-whitespace delimiters produce a null field. A sequence of IFS +whitespace characters also delimits a field. + + Explicit null arguments (‘""’ or ‘''’) are retained and passed to commands as empty strings. Unquoted implicit null arguments, resulting -from the expansion of parameters that have no values, are removed. If a -parameter with no value is expanded within double quotes, a null -argument results and is retained and passed to a command as an empty -string. When a quoted null argument appears as part of a word whose -expansion is non-null, the null argument is removed. That is, the word -'-d''' becomes '-d' after word splitting and null argument removal. +from the expansion of parameters that have no values, are removed. +Expanding a parameter with no value within double quotes produces a null +field, which is retained and passed to a command as an empty string. - Note that if no expansion occurs, no splitting is performed. + When a quoted null argument appears as part of a word whose expansion +is non-null, word splitting removes the null argument portion, leaving +the non-null expansion. That is, the word ‘-d''’ becomes ‘-d’ after +word splitting and null argument removal.  File: bash.info, Node: Filename Expansion, Next: Quote Removal, Prev: Word Splitting, Up: Shell Expansions @@ -2360,26 +2531,28 @@ File: bash.info, Node: Filename Expansion, Next: Quote Removal, Prev: Word Sp * Pattern Matching:: How the shell matches patterns. -After word splitting, unless the '-f' option has been set (*note The Set -Builtin::), Bash scans each word for the characters '*', '?', and '['. +After word splitting, unless the ‘-f’ option has been set (*note The Set +Builtin::), Bash scans each word for the characters ‘*’, ‘?’, and ‘[’. If one of these characters appears, and is not quoted, then the word is -regarded as a PATTERN, and replaced with an alphabetically sorted list -of filenames matching the pattern (*note Pattern Matching::). If no -matching filenames are found, and the shell option 'nullglob' is -disabled, the word is left unchanged. If the 'nullglob' option is set, -and no matches are found, the word is removed. If the 'failglob' shell -option is set, and no matches are found, an error message is printed and -the command is not executed. If the shell option 'nocaseglob' is -enabled, the match is performed without regard to the case of alphabetic -characters. - - When a pattern is used for filename expansion, the character '.' at +regarded as a PATTERN, and replaced with a sorted list of filenames +matching the pattern (*note Pattern Matching::), subject to the value of +the ‘GLOBSORT’ shell variable (*note Bash Variables::). + + If no matching filenames are found, and the shell option ‘nullglob’ +is disabled, the word is left unchanged. If the ‘nullglob’ option is +set, and no matches are found, the word is removed. If the ‘failglob’ +shell option is set, and no matches are found, Bash prints an error +message and does not execute the command. If the shell option +‘nocaseglob’ is enabled, the match is performed without regard to the +case of alphabetic characters. + + When a pattern is used for filename expansion, the character ‘.’ at the start of a filename or immediately following a slash must be matched -explicitly, unless the shell option 'dotglob' is set. In order to match -the filenames '.' and '..', the pattern must begin with '.' (for -example, '.?'), even if 'dotglob' is set. If the 'globskipdots' shell -option is enabled, the filenames '.' and '..' are never matched, even if -the pattern begins with a '.'. When not matching filenames, the '.' +explicitly, unless the shell option ‘dotglob’ is set. In order to match +the filenames ‘.’ and ‘..’, the pattern must begin with ‘.’ (for +example, ‘.?’), even if ‘dotglob’ is set. If the ‘globskipdots’ shell +option is enabled, the filenames ‘.’ and ‘..’ never match, even if the +pattern begins with a ‘.’. When not matching filenames, the ‘.’ character is not treated specially. When matching a filename, the slash character must always be matched @@ -2387,22 +2560,27 @@ explicitly by a slash in the pattern, but in other matching contexts it can be matched by a special pattern character as described below (*note Pattern Matching::). - See the description of 'shopt' in *note The Shopt Builtin::, for a -description of the 'nocaseglob', 'nullglob', 'globskipdots', 'failglob', -and 'dotglob' options. - - The 'GLOBIGNORE' shell variable may be used to restrict the set of -file names matching a pattern. If 'GLOBIGNORE' is set, each matching -file name that also matches one of the patterns in 'GLOBIGNORE' is -removed from the list of matches. If the 'nocaseglob' option is set, -the matching against the patterns in 'GLOBIGNORE' is performed without -regard to case. The filenames '.' and '..' are always ignored when -'GLOBIGNORE' is set and not null. However, setting 'GLOBIGNORE' to a -non-null value has the effect of enabling the 'dotglob' shell option, so -all other filenames beginning with a '.' will match. To get the old -behavior of ignoring filenames beginning with a '.', make '.*' one of -the patterns in 'GLOBIGNORE'. The 'dotglob' option is disabled when -'GLOBIGNORE' is unset. + See the description of ‘shopt’ in *note The Shopt Builtin::, for a +description of the ‘nocaseglob’, ‘nullglob’, ‘globskipdots’, ‘failglob’, +and ‘dotglob’ options. + + The ‘GLOBIGNORE’ shell variable may be used to restrict the set of +file names matching a pattern. If ‘GLOBIGNORE’ is set, each matching +file name that also matches one of the patterns in ‘GLOBIGNORE’ is +removed from the list of matches. If the ‘nocaseglob’ option is set, +the matching against the patterns in ‘GLOBIGNORE’ is performed without +regard to case. The filenames ‘.’ and ‘..’ are always ignored when +‘GLOBIGNORE’ is set and not null. However, setting ‘GLOBIGNORE’ to a +non-null value has the effect of enabling the ‘dotglob’ shell option, so +all other filenames beginning with a ‘.’ match. To get the old behavior +of ignoring filenames beginning with a ‘.’, make ‘.*’ one of the +patterns in ‘GLOBIGNORE’. The ‘dotglob’ option is disabled when +‘GLOBIGNORE’ is unset. The ‘GLOBIGNORE’ pattern matching honors the +setting of the ‘extglob’ shell option. + + The value of the ‘GLOBSORT’ shell variable controls how the results +of pathname expansion are sorted, as described below (*note Bash +Variables::).  File: bash.info, Node: Pattern Matching, Up: Filename Expansion @@ -2417,91 +2595,102 @@ escaping backslash is discarded when matching. The special pattern characters must be quoted if they are to be matched literally. The special pattern characters have the following meanings: -'*' - Matches any string, including the null string. When the 'globstar' - shell option is enabled, and '*' is used in a filename expansion - context, two adjacent '*'s used as a single pattern will match all - files and zero or more directories and subdirectories. If followed - by a '/', two adjacent '*'s will match only directories and - subdirectories. -'?' +‘*’ + Matches any string, including the null string. When the ‘globstar’ + shell option is enabled, and ‘*’ is used in a filename expansion + context, two adjacent ‘*’s used as a single pattern match all files + and zero or more directories and subdirectories. If followed by a + ‘/’, two adjacent ‘*’s match only directories and subdirectories. +‘?’ Matches any single character. -'[...]' - Matches any one of the enclosed characters. A pair of characters - separated by a hyphen denotes a RANGE EXPRESSION; any character - that falls between those two characters, inclusive, using the - current locale's collating sequence and character set, is matched. - If the first character following the '[' is a '!' or a '^' then any - character not enclosed is matched. A '-' may be matched by - including it as the first or last character in the set. A ']' may - be matched by including it as the first character in the set. The - sorting order of characters in range expressions, and the +‘[...]’ + Matches any one of the characters enclosed between the brackets. + This is known as a “bracket expression” and matches a single + character. A pair of characters separated by a hyphen denotes a + “range expression”; any character that falls between those two + characters, inclusive, using the current locale's collating + sequence and character set, matches. If the first character + following the ‘[’ is a ‘!’ or a ‘^’ then any character not within + the range matches. To match a ‘−’, include it as the first or last + character in the set. To match a ‘]’, include it as the first + character in the set. + + The sorting order of characters in range expressions, and the characters included in the range, are determined by the current - locale and the values of the 'LC_COLLATE' and 'LC_ALL' shell + locale and the values of the ‘LC_COLLATE’ and ‘LC_ALL’ shell variables, if set. - For example, in the default C locale, '[a-dx-z]' is equivalent to - '[abcdxyz]'. Many locales sort characters in dictionary order, and - in these locales '[a-dx-z]' is typically not equivalent to - '[abcdxyz]'; it might be equivalent to '[aBbCcDdxYyZz]', for + For example, in the default C locale, ‘[a-dx-z]’ is equivalent to + ‘[abcdxyz]’. Many locales sort characters in dictionary order, and + in these locales ‘[a-dx-z]’ is typically not equivalent to + ‘[abcdxyz]’; it might be equivalent to ‘[aBbCcDdxYyZz]’, for example. To obtain the traditional interpretation of ranges in bracket expressions, you can force the use of the C locale by - setting the 'LC_COLLATE' or 'LC_ALL' environment variable to the - value 'C', or enable the 'globasciiranges' shell option. + setting the ‘LC_COLLATE’ or ‘LC_ALL’ environment variable to the + value ‘C’, or enable the ‘globasciiranges’ shell option. - Within '[' and ']', "character classes" can be specified using the - syntax '[:'CLASS':]', where CLASS is one of the following classes - defined in the POSIX standard: + Within a bracket expression, “character classes” can be specified + using the syntax ‘[:’CLASS‘:]’, where CLASS is one of the following + classes defined in the POSIX standard: alnum alpha ascii blank cntrl digit graph lower print punct space upper word xdigit A character class matches any character belonging to that class. - The 'word' character class matches letters, digits, and the - character '_'. + The ‘word’ character class matches letters, digits, and the + character ‘_’. + + For instance, the following pattern will match any character + belonging to the ‘space’ character class in the current locale, + then any upper case letter or ‘!’, a dot, and finally any lower + case letter or a hyphen. - Within '[' and ']', an "equivalence class" can be specified using - the syntax '[='C'=]', which matches all characters with the same - collation weight (as defined by the current locale) as the - character C. + [[:space:]][[:upper:]!].[-[:lower:]] - Within '[' and ']', the syntax '[.'SYMBOL'.]' matches the collating - symbol SYMBOL. + Within a bracket expression, an “equivalence class” can be + specified using the syntax ‘[=’C‘=]’, which matches all characters + with the same collation weight (as defined by the current locale) + as the character C. - If the 'extglob' shell option is enabled using the 'shopt' builtin, + Within a bracket expression, the syntax ‘[.’SYMBOL‘.]’ matches the + collating symbol SYMBOL. + + If the ‘extglob’ shell option is enabled using the ‘shopt’ builtin, the shell recognizes several extended pattern matching operators. In the following description, a PATTERN-LIST is a list of one or more -patterns separated by a '|'. When matching filenames, the 'dotglob' +patterns separated by a ‘|’. When matching filenames, the ‘dotglob’ shell option determines the set of filenames that are tested, as described above. Composite patterns may be formed using one or more of the following sub-patterns: -'?(PATTERN-LIST)' +‘?(PATTERN-LIST)’ Matches zero or one occurrence of the given patterns. -'*(PATTERN-LIST)' +‘*(PATTERN-LIST)’ Matches zero or more occurrences of the given patterns. -'+(PATTERN-LIST)' +‘+(PATTERN-LIST)’ Matches one or more occurrences of the given patterns. -'@(PATTERN-LIST)' +‘@(PATTERN-LIST)’ Matches one of the given patterns. -'!(PATTERN-LIST)' +‘!(PATTERN-LIST)’ Matches anything except one of the given patterns. - The 'extglob' option changes the behavior of the parser, since the + The ‘extglob’ option changes the behavior of the parser, since the parentheses are normally treated as operators with syntactic meaning. To ensure that extended matching patterns are parsed correctly, make -sure that 'extglob' is enabled before parsing constructs containing the +sure that ‘extglob’ is enabled before parsing constructs containing the patterns, including shell functions and command substitutions. - When matching filenames, the 'dotglob' shell option determines the -set of filenames that are tested: when 'dotglob' is enabled, the set of -filenames includes all files beginning with '.', but the filenames '.' -and '..' must be matched by a pattern or sub-pattern that begins with a + When matching filenames, the ‘dotglob’ shell option determines the +set of filenames that are tested: when ‘dotglob’ is enabled, the set of +filenames includes all files beginning with ‘.’, but the filenames ‘.’ +and ‘..’ must be matched by a pattern or sub-pattern that begins with a dot; when it is disabled, the set does not include any filenames -beginning with "." unless the pattern or sub-pattern begins with a '.'. -As above, '.' only has a special meaning when matching filenames. +beginning with ‘.’ unless the pattern or sub-pattern begins with a ‘.’. +If the ‘globskipdots’ shell option is enabled, the filenames ‘.’ and +‘..’ never appear in the set. As above, ‘.’ only has a special meaning +when matching filenames. Complicated extended pattern matching against long strings is slow, especially when the patterns contain alternations and the strings @@ -2516,7 +2705,7 @@ File: bash.info, Node: Quote Removal, Prev: Filename Expansion, Up: Shell Exp ------------------- After the preceding expansions, all unquoted occurrences of the -characters '\', ''', and '"' that did not result from one of the above +characters ‘\’, ‘'’, and ‘"’ that did not result from one of the above expansions are removed.  @@ -2525,40 +2714,40 @@ File: bash.info, Node: Redirections, Next: Executing Commands, Prev: Shell Ex 3.6 Redirections ================ -Before a command is executed, its input and output may be "redirected" -using a special notation interpreted by the shell. "Redirection" allows +Before a command is executed, its input and output may be “redirected” +using a special notation interpreted by the shell. “Redirection” allows commands' file handles to be duplicated, opened, closed, made to refer to different files, and can change the files the command reads from and -writes to. Redirection may also be used to modify file handles in the -current shell execution environment. The following redirection -operators may precede or appear anywhere within a simple command or may -follow a command. Redirections are processed in the order they appear, -from left to right. +writes to. When used with the ‘exec’ builtin, redirections modify file +handles in the current shell execution environment. The following +redirection operators may precede or appear anywhere within a simple +command or may follow a command. Redirections are processed in the +order they appear, from left to right. Each redirection that may be preceded by a file descriptor number may instead be preceded by a word of the form {VARNAME}. In this case, for -each redirection operator except >&- and <&-, the shell will allocate a -file descriptor greater than 10 and assign it to {VARNAME}. If >&- or -<&- is preceded by {VARNAME}, the value of VARNAME defines the file -descriptor to close. If {VARNAME} is supplied, the redirection persists -beyond the scope of the command, allowing the shell programmer to manage -the file descriptor's lifetime manually. The 'varredir_close' shell -option manages this behavior (*note The Shopt Builtin::). +each redirection operator except ‘>&-’ and ‘<&-’, the shell allocates a +file descriptor greater than or equal to 10 and assigns it to {VARNAME}. +If {VARNAME} precedes ‘>&-’ or ‘<&-’, the value of VARNAME defines the +file descriptor to close. If {VARNAME} is supplied, the redirection +persists beyond the scope of the command, which allows the shell +programmer to manage the file descriptor's lifetime manually without +using the ‘exec’ builtin. The ‘varredir_close’ shell option manages +this behavior (*note The Shopt Builtin::). In the following descriptions, if the file descriptor number is -omitted, and the first character of the redirection operator is '<', the +omitted, and the first character of the redirection operator is ‘<’, the redirection refers to the standard input (file descriptor 0). If the -first character of the redirection operator is '>', the redirection +first character of the redirection operator is ‘>’, the redirection refers to the standard output (file descriptor 1). - The word following the redirection operator in the following + The WORD following the redirection operator in the following descriptions, unless otherwise noted, is subjected to brace expansion, -tilde expansion, parameter expansion, command substitution, arithmetic -expansion, quote removal, filename expansion, and word splitting. If it -expands to more than one word, Bash reports an error. +tilde expansion, parameter and variable expansion, command substitution, +arithmetic expansion, quote removal, filename expansion, and word +splitting. If it expands to more than one word, Bash reports an error. - Note that the order of redirections is significant. For example, the -command + The order of redirections is significant. For example, the command ls > DIRLIST 2>&1 directs both standard output (file descriptor 1) and standard error (file descriptor 2) to the file DIRLIST, while the command @@ -2569,28 +2758,28 @@ was redirected to DIRLIST. Bash handles several filenames specially when they are used in redirections, as described in the following table. If the operating -system on which Bash is running provides these special files, bash will -use them; otherwise it will emulate them internally with the behavior -described below. +system on which Bash is running provides these special files, Bash uses +them; otherwise it emulates them internally with the behavior described +below. -'/dev/fd/FD' - If FD is a valid integer, file descriptor FD is duplicated. +‘/dev/fd/FD’ + If FD is a valid integer, duplicate file descriptor FD. -'/dev/stdin' +‘/dev/stdin’ File descriptor 0 is duplicated. -'/dev/stdout' +‘/dev/stdout’ File descriptor 1 is duplicated. -'/dev/stderr' +‘/dev/stderr’ File descriptor 2 is duplicated. -'/dev/tcp/HOST/PORT' +‘/dev/tcp/HOST/PORT’ If HOST is a valid hostname or Internet address, and PORT is an integer port number or service name, Bash attempts to open the corresponding TCP socket. -'/dev/udp/HOST/PORT' +‘/dev/udp/HOST/PORT’ If HOST is a valid hostname or Internet address, and PORT is an integer port number or service name, Bash attempts to open the corresponding UDP socket. @@ -2604,9 +2793,9 @@ internally. 3.6.1 Redirecting Input ----------------------- -Redirection of input causes the file whose name results from the -expansion of WORD to be opened for reading on file descriptor 'n', or -the standard input (file descriptor 0) if 'n' is not specified. +Redirecting input opens the file whose name results from the expansion +of WORD for reading on file descriptor ‘n’, or the standard input (file +descriptor 0) if ‘n’ is not specified. The general format for redirecting input is: [N][|]WORD - If the redirection operator is '>', and the 'noclobber' option to the -'set' builtin has been enabled, the redirection will fail if the file -whose name results from the expansion of WORD exists and is a regular -file. If the redirection operator is '>|', or the redirection operator -is '>' and the 'noclobber' option is not enabled, the redirection is -attempted even if the file named by WORD exists. + If the redirection operator is ‘>’, and the ‘noclobber’ option to the +‘set’ builtin command has been enabled, the redirection fails if the +file whose name results from the expansion of WORD exists and is a +regular file. If the redirection operator is ‘>|’, or the redirection +operator is ‘>’ and the ‘noclobber’ option to the ‘set’ builtin is not +enabled, Bash attempts the redirection even if the file named by WORD +exists. 3.6.3 Appending Redirected Output --------------------------------- -Redirection of output in this fashion causes the file whose name results -from the expansion of WORD to be opened for appending on file descriptor -N, or the standard output (file descriptor 1) if N is not specified. If -the file does not exist it is created. +Redirecting output in this fashion opens the file whose name results +from the expansion of WORD for appending on file descriptor N, or the +standard output (file descriptor 1) if N is not specified. If the file +does not exist it is created. The general format for appending output is: [N]>>WORD @@ -2644,9 +2833,9 @@ the file does not exist it is created. 3.6.4 Redirecting Standard Output and Standard Error ---------------------------------------------------- -This construct allows both the standard output (file descriptor 1) and -the standard error output (file descriptor 2) to be redirected to the -file whose name is the expansion of WORD. +This construct redirects both the standard output (file descriptor 1) +and the standard error output (file descriptor 2) to the file whose name +is the expansion of WORD. There are two formats for redirecting standard output and standard error: @@ -2656,16 +2845,16 @@ and Of the two forms, the first is preferred. This is semantically equivalent to >WORD 2>&1 - When using the second form, WORD may not expand to a number or '-'. + When using the second form, WORD may not expand to a number or ‘-’. If it does, other redirection operators apply (see Duplicating File Descriptors below) for compatibility reasons. 3.6.5 Appending Standard Output and Standard Error -------------------------------------------------- -This construct allows both the standard output (file descriptor 1) and -the standard error output (file descriptor 2) to be appended to the file -whose name is the expansion of WORD. +This construct appends both the standard output (file descriptor 1) and +the standard error output (file descriptor 2) to the file whose name is +the expansion of WORD. The format for appending standard output and standard error is: &>>WORD @@ -2677,29 +2866,39 @@ This is semantically equivalent to -------------------- This type of redirection instructs the shell to read input from the -current source until a line containing only WORD (with no trailing -blanks) is seen. All of the lines read up to that point are then used -as the standard input (or file descriptor N if N is specified) for a +current source until it reads a line containing only DELIMITER (with no +trailing blanks). All of the lines read up to that point then become +the standard input (or file descriptor N if N is specified) for a command. The format of here-documents is: - [N]<<[-]WORD + [N]<<[−]WORD HERE-DOCUMENT DELIMITER - No parameter and variable expansion, command substitution, arithmetic -expansion, or filename expansion is performed on WORD. If any part of -WORD is quoted, the DELIMITER is the result of quote removal on WORD, -and the lines in the here-document are not expanded. If WORD is -unquoted, all lines of the here-document are subjected to parameter -expansion, command substitution, and arithmetic expansion, the character -sequence '\newline' is ignored, and '\' must be used to quote the -characters '\', '$', and '`'. - - If the redirection operator is '<<-', then all leading tab characters -are stripped from input lines and the line containing DELIMITER. This -allows here-documents within shell scripts to be indented in a natural -fashion. + The shell does not perform parameter and variable expansion, command +substitution, arithmetic expansion, or filename expansion on WORD. + + If any part of WORD is quoted, the DELIMITER is the result of quote +removal on WORD, and the lines in the here-document are not expanded. +If WORD is unquoted, DELIMITER is WORD itself, and the here-document +text is treated similarly to a double-quoted string: all lines of the +here-document are subjected to parameter expansion, command +substitution, and arithmetic expansion, the character sequence +‘\newline’ is treated literally, and ‘\’ must be used to quote the +characters ‘\’, ‘$’, and ‘`’; however, double quote characters have no +special meaning. + + If the redirection operator is ‘<<-’, the shell strips leading tab +characters are stripped from input lines and the line containing +DELIMITER. This allows here-documents within shell scripts to be +indented in a natural fashion. + + If the delimiter is not quoted, the ‘\’ sequence is treated +as a line continuation: the two lines are joined and the +backslash-newline is removed. This happens while reading the +here-document, before the check for the ending delimiter, so joined +lines can form the end delimiter. 3.6.7 Here Strings ------------------ @@ -2719,21 +2918,21 @@ standard input (or file descriptor N if N is specified). The redirection operator [N]<&WORD is used to duplicate input file descriptors. If WORD expands to one or -more digits, the file descriptor denoted by N is made to be a copy of -that file descriptor. If the digits in WORD do not specify a file -descriptor open for input, a redirection error occurs. If WORD -evaluates to '-', file descriptor N is closed. If N is not specified, -the standard input (file descriptor 0) is used. +more digits, file descriptor N is made to be a copy of that file +descriptor. It is a redirection error if the digits in WORD do not +specify a file descriptor open for input. If WORD evaluates to ‘-’, +file descriptor N is closed. If N is not specified, this uses the +standard input (file descriptor 0). The operator [N]>&WORD is used similarly to duplicate output file descriptors. If N is not -specified, the standard output (file descriptor 1) is used. If the -digits in WORD do not specify a file descriptor open for output, a -redirection error occurs. If WORD evaluates to '-', file descriptor N -is closed. As a special case, if N is omitted, and WORD does not expand -to one or more digits or '-', the standard output and standard error are -redirected as described previously. +specified, this uses the standard output (file descriptor 1). It is a +redirection error if the digits in WORD do not specify a file descriptor +open for output. If WORD evaluates to ‘-’, file descriptor N is closed. +As a special case, if N is omitted, and WORD does not expand to one or +more digits or ‘-’, this redirects the standard output and standard +error as described previously. 3.6.9 Moving File Descriptors ----------------------------- @@ -2754,9 +2953,9 @@ output (file descriptor 1) if N is not specified. The redirection operator [N]<>WORD -causes the file whose name is the expansion of WORD to be opened for -both reading and writing on file descriptor N, or on file descriptor 0 -if N is not specified. If the file does not exist, it is created. +opens the file whose name is the expansion of WORD for both reading and +writing on file descriptor N, or on file descriptor 0 if N is not +specified. If the file does not exist, it is created.  File: bash.info, Node: Executing Commands, Next: Shell Scripts, Prev: Redirections, Up: Basic Shell Features @@ -2784,7 +2983,7 @@ File: bash.info, Node: Simple Command Expansion, Next: Command Search and Exec 3.7.1 Simple Command Expansion ------------------------------ -When a simple command is executed, the shell performs the following +When the shell executes a simple command, it performs the following expansions, assignments, and redirections, from left to right, in the following order. @@ -2800,7 +2999,7 @@ following order. 3. Redirections are performed as described above (*note Redirections::). - 4. The text after the '=' in each variable assignment undergoes tilde + 4. The text after the ‘=’ in each variable assignment undergoes tilde expansion, parameter expansion, command substitution, arithmetic expansion, and quote removal before being assigned to the variable. @@ -2821,8 +3020,8 @@ command to exit with a non-zero status. as described below. Otherwise, the command exits. If one of the expansions contained a command substitution, the exit status of the command is the exit status of the last command substitution performed. -If there were no command substitutions, the command exits with a status -of zero. +If there were no command substitutions, the command exits with a zero +status.  File: bash.info, Node: Command Search and Execution, Next: Command Execution Environment, Prev: Simple Command Expansion, Up: Executing Commands @@ -2831,8 +3030,8 @@ File: bash.info, Node: Command Search and Execution, Next: Command Execution E ---------------------------------- After a command has been split into words, if it results in a simple -command and an optional list of arguments, the following actions are -taken. +command and an optional list of arguments, the shell performs the +following actions. 1. If the command name contains no slashes, the shell attempts to locate it. If there exists a shell function by that name, that @@ -2843,14 +3042,14 @@ taken. invoked. 3. If the name is neither a shell function nor a builtin, and contains - no slashes, Bash searches each element of '$PATH' for a directory + no slashes, Bash searches each element of ‘$PATH’ for a directory containing an executable file by that name. Bash uses a hash table to remember the full pathnames of executable files to avoid - multiple 'PATH' searches (see the description of 'hash' in *note - Bourne Shell Builtins::). A full search of the directories in - '$PATH' is performed only if the command is not found in the hash + multiple ‘PATH’ searches (see the description of ‘hash’ in *note + Bourne Shell Builtins::). Bash performs a full search of the + directories in ‘$PATH’ only if the command is not found in the hash table. If the search is unsuccessful, the shell searches for a - defined shell function named 'command_not_found_handle'. If that + defined shell function named ‘command_not_found_handle’. If that function exists, it is invoked in a separate execution environment with the original command and the original command's arguments as its arguments, and the function's exit status becomes the exit @@ -2865,8 +3064,8 @@ taken. 5. If this execution fails because the file is not in executable format, and the file is not a directory, it is assumed to be a - "shell script" and the shell executes it as described in *note - Shell Scripts::. + “shell script”, a file containing shell commands, and the shell + executes it as described in *note Shell Scripts::. 6. If the command was not begun asynchronously, the shell waits for the command to complete and collects its exit status. @@ -2877,74 +3076,79 @@ File: bash.info, Node: Command Execution Environment, Next: Environment, Prev 3.7.3 Command Execution Environment ----------------------------------- -The shell has an "execution environment", which consists of the +The shell has an “execution environment”, which consists of the following: - * open files inherited by the shell at invocation, as modified by - redirections supplied to the 'exec' builtin + • Open files inherited by the shell at invocation, as modified by + redirections supplied to the ‘exec’ builtin. - * the current working directory as set by 'cd', 'pushd', or 'popd', - or inherited by the shell at invocation + • The current working directory as set by ‘cd’, ‘pushd’, or ‘popd’, + or inherited by the shell at invocation. - * the file creation mode mask as set by 'umask' or inherited from the - shell's parent + • The file creation mode mask as set by ‘umask’ or inherited from the + shell's parent. - * current traps set by 'trap' + • Current traps set by ‘trap’. - * shell parameters that are set by variable assignment or with 'set' - or inherited from the shell's parent in the environment + • Shell parameters that are set by variable assignment or with ‘set’ + or inherited from the shell's parent in the environment. - * shell functions defined during execution or inherited from the - shell's parent in the environment + • Shell functions defined during execution or inherited from the + shell's parent in the environment. - * options enabled at invocation (either by default or with - command-line arguments) or by 'set' + • Options enabled at invocation (either by default or with + command-line arguments) or by ‘set’. - * options enabled by 'shopt' (*note The Shopt Builtin::) + • Options enabled by ‘shopt’ (*note The Shopt Builtin::). - * shell aliases defined with 'alias' (*note Aliases::) + • Shell aliases defined with ‘alias’ (*note Aliases::). - * various process IDs, including those of background jobs (*note - Lists::), the value of '$$', and the value of '$PPID' + • Various process IDs, including those of background jobs (*note + Lists::), the value of ‘$$’, and the value of ‘$PPID’. When a simple command other than a builtin or shell function is to be executed, it is invoked in a separate execution environment that consists of the following. Unless otherwise noted, the values are inherited from the shell. - * the shell's open files, plus any modifications and additions - specified by redirections to the command + • The shell's open files, plus any modifications and additions + specified by redirections to the command. - * the current working directory + • The current working directory. - * the file creation mode mask + • The file creation mode mask. - * shell variables and functions marked for export, along with + • Shell variables and functions marked for export, along with variables exported for the command, passed in the environment - (*note Environment::) + (*note Environment::). - * traps caught by the shell are reset to the values inherited from - the shell's parent, and traps ignored by the shell are ignored + • Traps caught by the shell are reset to the values inherited from + the shell's parent, and traps ignored by the shell are ignored. A command invoked in this separate environment cannot affect the shell's execution environment. - A "subshell" is a copy of the shell process. + A “subshell” is a copy of the shell process. Command substitution, commands grouped with parentheses, and asynchronous commands are invoked in a subshell environment that is a duplicate of the shell environment, except that traps caught by the shell are reset to the values that the shell inherited from its parent -at invocation. Builtin commands that are invoked as part of a pipeline -are also executed in a subshell environment. Changes made to the -subshell environment cannot affect the shell's execution environment. - - Subshells spawned to execute command substitutions inherit the value -of the '-e' option from the parent shell. When not in POSIX mode, Bash -clears the '-e' option in such subshells. - - If a command is followed by a '&' and job control is not active, the -default standard input for the command is the empty file '/dev/null'. +at invocation. Builtin commands that are invoked as part of a pipeline, +except possibly in the last element depending on the value of the +‘lastpipe’ shell option (*note The Shopt Builtin::), are also executed +in a subshell environment. Changes made to the subshell environment +cannot affect the shell's execution environment. + + When the shell is in POSIX mode, subshells spawned to execute command +substitutions inherit the value of the ‘-e’ option from the parent +shell. When not in POSIX mode, Bash clears the ‘-e’ option in such +subshells See the description of the ‘inherit_errexit’ shell option +(*note Bash Builtins::) for how to control this behavior when not in +POSIX mode. + + If a command is followed by a ‘&’ and job control is not active, the +default standard input for the command is the empty file ‘/dev/null’. Otherwise, the invoked command inherits the file descriptors of the calling shell as modified by redirections. @@ -2955,32 +3159,35 @@ File: bash.info, Node: Environment, Next: Exit Status, Prev: Command Executio ----------------- When a program is invoked it is given an array of strings called the -"environment". This is a list of name-value pairs, of the form -'name=value'. +“environment”. This is a list of name-value pairs, of the form +‘name=value’. Bash provides several ways to manipulate the environment. On invocation, the shell scans its own environment and creates a parameter -for each name found, automatically marking it for 'export' to child -processes. Executed commands inherit the environment. The 'export' and -'declare -x' commands allow parameters and functions to be added to and -deleted from the environment. If the value of a parameter in the -environment is modified, the new value becomes part of the environment, -replacing the old. The environment inherited by any executed command -consists of the shell's initial environment, whose values may be -modified in the shell, less any pairs removed by the 'unset' and 'export --n' commands, plus any additions via the 'export' and 'declare -x' -commands. - - The environment for any simple command or function may be augmented -temporarily by prefixing it with parameter assignments, as described in -*note Shell Parameters::. These assignment statements affect only the -environment seen by that command. - - If the '-k' option is set (*note The Set Builtin::), then all +for each name found, automatically marking it for ‘export’ to child +processes. Executed commands inherit the environment. The ‘export’, +‘declare -x’, and ‘unset’ commands modify the environment by adding and +deleting parameters and functions. If the value of a parameter in the +environment is modified, the new value automatically becomes part of the +environment, replacing the old. The environment inherited by any +executed command consists of the shell's initial environment, whose +values may be modified in the shell, less any pairs removed by the +‘unset’ and ‘export -n’ commands, plus any additions via the ‘export’ +and ‘declare -x’ commands. + + If any parameter assignment statements, as described in *note Shell +Parameters::, appear before a simple command, the variable assignments +are part of that command's environment for as long as it executes. +These assignment statements affect only the environment seen by that +command. If these assignments precede a call to a shell function, the +variables are local to the function and exported to that function's +children. + + If the ‘-k’ option is set (*note The Set Builtin::), then all parameter assignments are placed in the environment for a command, not just those that precede the command name. - When Bash invokes an external command, the variable '$_' is set to + When Bash invokes an external command, the variable ‘$_’ is set to the full pathname of the command and passed to that command in its environment. @@ -2991,18 +3198,21 @@ File: bash.info, Node: Exit Status, Next: Signals, Prev: Environment, Up: Ex ----------------- The exit status of an executed command is the value returned by the -'waitpid' system call or equivalent function. Exit statuses fall +‘waitpid’ system call or equivalent function. Exit statuses fall between 0 and 255, though, as explained below, the shell may use values above 125 specially. Exit statuses from shell builtins and compound commands are also limited to this range. Under certain circumstances, the shell will use special values to indicate specific failure modes. For the shell's purposes, a command which exits with a zero exit -status has succeeded. A non-zero exit status indicates failure. This -seemingly counter-intuitive scheme is used so there is one well-defined -way to indicate success and a variety of ways to indicate various -failure modes. When a command terminates on a fatal signal whose number -is N, Bash uses the value 128+N as the exit status. +status has succeeded. So while an exit status of zero indicates +success, a non-zero exit status indicates failure. This seemingly +counter-intuitive scheme is used so there is one well-defined way to +indicate success and a variety of ways to indicate various failure +modes. + + When a command terminates on a fatal signal whose number is N, Bash +uses the value 128+N as the exit status. If a command is not found, the child process created to execute it returns a status of 127. If a command is found but is not executable, @@ -3024,6 +3234,11 @@ arguments. The exit status of the last command is available in the special parameter $? (*note Special Parameters::). + Bash itself returns the exit status of the last command executed, +unless a syntax error occurs, in which case it exits with a non-zero +value. See also the ‘exit’ builtin command (*note Bourne Shell +Builtins::. +  File: bash.info, Node: Signals, Prev: Exit Status, Up: Executing Commands @@ -3031,66 +3246,88 @@ File: bash.info, Node: Signals, Prev: Exit Status, Up: Executing Commands ------------- When Bash is interactive, in the absence of any traps, it ignores -'SIGTERM' (so that 'kill 0' does not kill an interactive shell), and -'SIGINT' is caught and handled (so that the 'wait' builtin is -interruptible). When Bash receives a 'SIGINT', it breaks out of any -executing loops. In all cases, Bash ignores 'SIGQUIT'. If job control -is in effect (*note Job Control::), Bash ignores 'SIGTTIN', 'SIGTTOU', -and 'SIGTSTP'. - - Non-builtin commands started by Bash have signal handlers set to the -values inherited by the shell from its parent. When job control is not -in effect, asynchronous commands ignore 'SIGINT' and 'SIGQUIT' in -addition to these inherited handlers. Commands run as a result of -command substitution ignore the keyboard-generated job control signals -'SIGTTIN', 'SIGTTOU', and 'SIGTSTP'. - - The shell exits by default upon receipt of a 'SIGHUP'. Before -exiting, an interactive shell resends the 'SIGHUP' to all jobs, running -or stopped. Stopped jobs are sent 'SIGCONT' to ensure that they receive -the 'SIGHUP'. To prevent the shell from sending the 'SIGHUP' signal to -a particular job, it should be removed from the jobs table with the -'disown' builtin (*note Job Control Builtins::) or marked to not receive -'SIGHUP' using 'disown -h'. - - If the 'huponexit' shell option has been set with 'shopt' (*note The -Shopt Builtin::), Bash sends a 'SIGHUP' to all jobs when an interactive +‘SIGTERM’ (so that ‘kill 0’ does not kill an interactive shell), and +catches and handles ‘SIGINT’ (so that the ‘wait’ builtin is +interruptible). When Bash receives a ‘SIGINT’, it breaks out of any +executing loops. In all cases, Bash ignores ‘SIGQUIT’. If job control +is in effect (*note Job Control::), Bash ignores ‘SIGTTIN’, ‘SIGTTOU’, +and ‘SIGTSTP’. + + The ‘trap’ builtin modifies the shell's signal handling, as described +below (*note Bourne Shell Builtins::. + + Non-builtin commands Bash executes have signal handlers set to the +values inherited by the shell from its parent, unless ‘trap’ sets them +to be ignored, in which case the child process will ignore them as well. +When job control is not in effect, asynchronous commands ignore ‘SIGINT’ +and ‘SIGQUIT’ in addition to these inherited handlers. Commands run as +a result of command substitution ignore the keyboard-generated job +control signals ‘SIGTTIN’, ‘SIGTTOU’, and ‘SIGTSTP’. + + The shell exits by default upon receipt of a ‘SIGHUP’. Before +exiting, an interactive shell resends the ‘SIGHUP’ to all jobs, running +or stopped. The shell sends ‘SIGCONT’ to stopped jobs to ensure that +they receive the ‘SIGHUP’ (*Note Job Control::, for more information +about running and stopped jobs). To prevent the shell from sending the +‘SIGHUP’ signal to a particular job, remove it from the jobs table with +the ‘disown’ builtin (*note Job Control Builtins::) or mark it not to +receive ‘SIGHUP’ using ‘disown -h’. + + If the ‘huponexit’ shell option has been set using ‘shopt’ (*note The +Shopt Builtin::), Bash sends a ‘SIGHUP’ to all jobs when an interactive login shell exits. If Bash is waiting for a command to complete and receives a signal -for which a trap has been set, the trap will not be executed until the -command completes. When Bash is waiting for an asynchronous command via -the 'wait' builtin, the reception of a signal for which a trap has been -set will cause the 'wait' builtin to return immediately with an exit -status greater than 128, immediately after which the trap is executed. +for which a trap has been set, it will not execute the trap until the +command completes. If Bash is waiting for an asynchronous command via +the ‘wait’ builtin, and it receives a signal for which a trap has been +set, the ‘wait’ builtin will return immediately with an exit status +greater than 128, immediately after which the shell executes the trap. When job control is not enabled, and Bash is waiting for a foreground command to complete, the shell receives keyboard-generated signals such -as 'SIGINT' (usually generated by '^C') that users commonly intend to +as ‘SIGINT’ (usually generated by ‘^C’) that users commonly intend to send to that command. This happens because the shell and the command -are in the same process group as the terminal, and '^C' sends 'SIGINT' -to all processes in that process group. See *note Job Control::, for a -more in-depth discussion of process groups. - - When Bash is running without job control enabled and receives -'SIGINT' while waiting for a foreground command, it waits until that -foreground command terminates and then decides what to do about the -'SIGINT': - - 1. If the command terminates due to the 'SIGINT', Bash concludes that - the user meant to end the entire script, and acts on the 'SIGINT' - (e.g., by running a 'SIGINT' trap or exiting itself); - - 2. If the pipeline does not terminate due to 'SIGINT', the program - handled the 'SIGINT' itself and did not treat it as a fatal signal. - In that case, Bash does not treat 'SIGINT' as a fatal signal, - either, instead assuming that the 'SIGINT' was used as part of the - program's normal operation (e.g., 'emacs' uses it to abort editing +are in the same process group as the terminal, and ‘^C’ sends ‘SIGINT’ +to all processes in that process group. Since Bash does not enable job +control by default when the shell is not interactive, this scenario is +most common in non-interactive shells. + + When job control is enabled, and Bash is waiting for a foreground +command to complete, the shell does not receive keyboard-generated +signals, because it is not in the same process group as the terminal. +This scenario is most common in interactive shells, where Bash attempts +to enable job control by default. See *note Job Control::, for a more +in-depth discussion of process groups. + + When job control is not enabled, and Bash receives ‘SIGINT’ while +waiting for a foreground command, it waits until that foreground command +terminates and then decides what to do about the ‘SIGINT’: + + 1. If the command terminates due to the ‘SIGINT’, Bash concludes that + the user meant to send the ‘SIGINT’ to the shell as well, and acts + on the ‘SIGINT’ (e.g., by running a ‘SIGINT’ trap, exiting a + non-interactive shell, or returning to the top level to read a new + command). + + 2. If the command does not terminate due to ‘SIGINT’, the program + handled the ‘SIGINT’ itself and did not treat it as a fatal signal. + In that case, Bash does not treat ‘SIGINT’ as a fatal signal, + either, instead assuming that the ‘SIGINT’ was used as part of the + program's normal operation (e.g., ‘emacs’ uses it to abort editing commands) or deliberately discarded. However, Bash will run any - trap set on 'SIGINT', as it does with any other trapped signal it + trap set on ‘SIGINT’, as it does with any other trapped signal it receives while it is waiting for the foreground command to complete, for compatibility. + When job control is enabled, Bash does not receive keyboard-generated +signals such as ‘SIGINT’ while it is waiting for a foreground command. +An interactive shell does not pay attention to the ‘SIGINT’, even if the +foreground command terminates as a result, other than noting its exit +status. If the shell is not interactive, and the foreground command +terminates due to the ‘SIGINT’, Bash pretends it received the ‘SIGINT’ +itself (scenario 1 above), for compatibility. +  File: bash.info, Node: Shell Scripts, Prev: Executing Commands, Up: Basic Shell Features @@ -3099,39 +3336,43 @@ File: bash.info, Node: Shell Scripts, Prev: Executing Commands, Up: Basic She A shell script is a text file containing shell commands. When such a file is used as the first non-option argument when invoking Bash, and -neither the '-c' nor '-s' option is supplied (*note Invoking Bash::), +neither the ‘-c’ nor ‘-s’ option is supplied (*note Invoking Bash::), Bash reads and executes commands from the file, then exits. This mode -of operation creates a non-interactive shell. The shell first searches -for the file in the current directory, and looks in the directories in -'$PATH' if not found there. +of operation creates a non-interactive shell. If the filename does not +contain any slashes, the shell first searches for the file in the +current directory, and looks in the directories in ‘$PATH’ if not found +there. + + Bash tries to determine whether the file is a text file or a binary, +and will not execute files it determines to be binaries. - When Bash runs a shell script, it sets the special parameter '0' to + When Bash runs a shell script, it sets the special parameter ‘0’ to the name of the file, rather than the name of the shell, and the positional parameters are set to the remaining arguments, if any are given. If no additional arguments are supplied, the positional parameters are unset. - A shell script may be made executable by using the 'chmod' command to + A shell script may be made executable by using the ‘chmod’ command to turn on the execute bit. When Bash finds such a file while searching -the '$PATH' for a command, it creates a new instance of itself to +the ‘$PATH’ for a command, it creates a new instance of itself to execute it. In other words, executing filename ARGUMENTS is equivalent to executing bash filename ARGUMENTS -if 'filename' is an executable shell script. This subshell +if ‘filename’ is an executable shell script. This subshell reinitializes itself, so that the effect is as if a new shell had been invoked to interpret the script, with the exception that the locations -of commands remembered by the parent (see the description of 'hash' in +of commands remembered by the parent (see the description of ‘hash’ in *note Bourne Shell Builtins::) are retained by the child. - Most versions of Unix make this a part of the operating system's -command execution mechanism. If the first line of a script begins with -the two characters '#!', the remainder of the line specifies an -interpreter for the program and, depending on the operating system, one -or more optional arguments for that interpreter. Thus, you can specify -Bash, 'awk', Perl, or some other interpreter and write the rest of the -script file in that language. + The GNU operating system, and most versions of Unix, make this a part +of the operating system's command execution mechanism. If the first +line of a script begins with the two characters ‘#!’, the remainder of +the line specifies an interpreter for the program and, depending on the +operating system, one or more optional arguments for that interpreter. +Thus, you can specify Bash, ‘awk’, Perl, or some other interpreter and +write the rest of the script file in that language. The arguments to the interpreter consist of one or more optional arguments following the interpreter name on the first line of the script @@ -3144,12 +3385,12 @@ older versions of Unix limit the interpreter name and a single argument to a maximum of 32 characters, so it's not portable to assume that using more than one argument will work. - Bash scripts often begin with '#! /bin/bash' (assuming that Bash has -been installed in '/bin'), since this ensures that Bash will be used to + Bash scripts often begin with ‘#! /bin/bash’ (assuming that Bash has +been installed in ‘/bin’), since this ensures that Bash will be used to interpret the script, even if it is executed under another shell. It's -a common idiom to use 'env' to find 'bash' even if it's been installed -in another directory: '#!/usr/bin/env bash' will find the first -occurrence of 'bash' in '$PATH'. +a common idiom to use ‘env’ to find ‘bash’ even if it's been installed +in another directory: ‘#!/usr/bin/env bash’ will find the first +occurrence of ‘bash’ in ‘$PATH’.  File: bash.info, Node: Shell Builtin Commands, Next: Shell Variables, Prev: Basic Shell Features, Up: Top @@ -3188,14 +3429,14 @@ Completion Builtins::). Many of the builtins have been extended by POSIX or Bash. Unless otherwise noted, each builtin command documented as accepting -options preceded by '-' accepts '--' to signify the end of the options. -The ':', 'true', 'false', and 'test'/'[' builtins do not accept options -and do not treat '--' specially. The 'exit', 'logout', 'return', -'break', 'continue', 'let', and 'shift' builtins accept and process -arguments beginning with '-' without requiring '--'. Other builtins +options preceded by ‘-’ accepts ‘--’ to signify the end of the options. +The ‘:’, ‘true’, ‘false’, and ‘test’/‘[’ builtins do not accept options +and do not treat ‘--’ specially. The ‘exit’, ‘logout’, ‘return’, +‘break’, ‘continue’, ‘let’, and ‘shift’ builtins accept and process +arguments beginning with ‘-’ without requiring ‘--’. Other builtins that accept arguments but are not specified as accepting options -interpret arguments beginning with '-' as invalid options and require -'--' to prevent this interpretation. +interpret arguments beginning with ‘-’ as invalid options and require +‘--’ to prevent this interpretation.  File: bash.info, Node: Bourne Shell Builtins, Next: Bash Builtins, Up: Shell Builtin Commands @@ -3207,302 +3448,364 @@ The following shell builtin commands are inherited from the Bourne Shell. These commands are implemented as specified by the POSIX standard. -': (a colon)' +‘: (a colon)’ : [ARGUMENTS] Do nothing beyond expanding ARGUMENTS and performing redirections. The return status is zero. -'. (a period)' - . FILENAME [ARGUMENTS] - - Read and execute commands from the FILENAME argument in the current - shell context. If FILENAME does not contain a slash, the 'PATH' - variable is used to find FILENAME, but FILENAME does not need to be - executable. When Bash is not in POSIX mode, it searches the - current directory if FILENAME is not found in '$PATH'. If any - ARGUMENTS are supplied, they become the positional parameters when - FILENAME is executed. Otherwise the positional parameters are - unchanged. If the '-T' option is enabled, '.' inherits any trap on - 'DEBUG'; if it is not, any 'DEBUG' trap string is saved and - restored around the call to '.', and '.' unsets the 'DEBUG' trap - while it executes. If '-T' is not set, and the sourced file - changes the 'DEBUG' trap, the new value is retained when '.' - completes. The return status is the exit status of the last - command executed, or zero if no commands are executed. If FILENAME - is not found, or cannot be read, the return status is non-zero. - This builtin is equivalent to 'source'. - -'break' +‘. (a period)’ + . [-p PATH] FILENAME [ARGUMENTS] + + The ‘.’ command reads and execute commands from the FILENAME + argument in the current shell context. + + If FILENAME does not contain a slash, ‘.’ searches for it. If ‘-p’ + is supplied, ‘.’ treats PATH as a colon-separated list of + directories in which to find FILENAME; otherwise, ‘.’ uses the + directories in ‘PATH’ to find FILENAME. FILENAME does not need to + be executable. When Bash is not in POSIX mode, it searches the + current directory if FILENAME is not found in ‘$PATH’, but does not + search the current directory if ‘-p’ is supplied. If the + ‘sourcepath’ option (*note The Shopt Builtin::) is turned off, ‘.’ + does not search ‘PATH’. + + If any ARGUMENTS are supplied, they become the positional + parameters when FILENAME is executed. Otherwise the positional + parameters are unchanged. + + If the ‘-T’ option is enabled, ‘.’ inherits any trap on ‘DEBUG’; if + it is not, any ‘DEBUG’ trap string is saved and restored around the + call to ‘.’, and ‘.’ unsets the ‘DEBUG’ trap while it executes. If + ‘-T’ is not set, and the sourced file changes the ‘DEBUG’ trap, the + new value persists after ‘.’ completes. The return status is the + exit status of the last command executed from FILENAME, or zero if + no commands are executed. If FILENAME is not found, or cannot be + read, the return status is non-zero. This builtin is equivalent to + ‘source’. + +‘break’ break [N] - Exit from a 'for', 'while', 'until', or 'select' loop. If N is - supplied, the Nth enclosing loop is exited. N must be greater than - or equal to 1. The return status is zero unless N is not greater - than or equal to 1. + Exit from a ‘for’, ‘while’, ‘until’, or ‘select’ loop. If N is + supplied, ‘break’ exits the Nth enclosing loop. N must be greater + than or equal to 1. The return status is zero unless N is not + greater than or equal to 1. -'cd' - cd [-L|[-P [-e]] [-@] [DIRECTORY] +‘cd’ + cd [-L] [-@] [DIRECTORY] + cd -P [-e] [-@] [DIRECTORY] Change the current working directory to DIRECTORY. If DIRECTORY is - not supplied, the value of the 'HOME' shell variable is used. If - the shell variable 'CDPATH' exists, it is used as a search path: - each directory name in 'CDPATH' is searched for DIRECTORY, with - alternative directory names in 'CDPATH' separated by a colon (':'). - If DIRECTORY begins with a slash, 'CDPATH' is not used. - - The '-P' option means to not follow symbolic links: symbolic links - are resolved while 'cd' is traversing DIRECTORY and before - processing an instance of '..' in DIRECTORY. - - By default, or when the '-L' option is supplied, symbolic links in - DIRECTORY are resolved after 'cd' processes an instance of '..' in + not supplied, the value of the ‘HOME’ shell variable is used as + DIRECTORY. If the shell variable ‘CDPATH’ exists, and DIRECTORY + does not begin with a slash, ‘cd’ uses it as a search path: ‘cd’ + searches each directory name in ‘CDPATH’ for DIRECTORY, with + alternative directory names in ‘CDPATH’ separated by a colon (‘:’). + A null directory name in ‘CDPATH’ means the same thing as the + current directory. + + The ‘-P’ option means not to follow symbolic links: symbolic links + are resolved while ‘cd’ is traversing DIRECTORY and before + processing an instance of ‘..’ in DIRECTORY. + + By default, or when the ‘-L’ option is supplied, symbolic links in + DIRECTORY are resolved after ‘cd’ processes an instance of ‘..’ in DIRECTORY. - If '..' appears in DIRECTORY, it is processed by removing the + If ‘..’ appears in DIRECTORY, ‘cd’ processes it by removing the immediately preceding pathname component, back to a slash or the - beginning of DIRECTORY. + beginning of DIRECTORY, and verifying that the portion of DIRECTORY + it has processed to that point is still a valid directory name + after removing the pathname component. If it is not a valid + directory name, ‘cd’ returns a non-zero status. - If the '-e' option is supplied with '-P' and the current working - directory cannot be successfully determined after a successful - directory change, 'cd' will return an unsuccessful status. + If the ‘-e’ option is supplied with ‘-P’ and ‘cd’ cannot + successfully determine the current working directory after a + successful directory change, it returns a non-zero status. - On systems that support it, the '-@' option presents the extended + On systems that support it, the ‘-@’ option presents the extended attributes associated with a file as a directory. - If DIRECTORY is '-', it is converted to '$OLDPWD' before the - directory change is attempted. + If DIRECTORY is ‘-’, it is converted to ‘$OLDPWD’ before attempting + the directory change. - If a non-empty directory name from 'CDPATH' is used, or if '-' is - the first argument, and the directory change is successful, the - absolute pathname of the new working directory is written to the + If ‘cd’ uses a non-empty directory name from ‘CDPATH’, or if ‘-’ is + the first argument, and the directory change is successful, ‘cd’ + writes the absolute pathname of the new working directory to the standard output. - If the directory change is successful, 'cd' sets the value of the - 'PWD' environment variable to the new directory name, and sets the - 'OLDPWD' environment variable to the value of the current working + If the directory change is successful, ‘cd’ sets the value of the + ‘PWD’ environment variable to the new directory name, and sets the + ‘OLDPWD’ environment variable to the value of the current working directory before the change. The return status is zero if the directory is successfully changed, non-zero otherwise. -'continue' +‘continue’ continue [N] - Resume the next iteration of an enclosing 'for', 'while', 'until', - or 'select' loop. If N is supplied, the execution of the Nth - enclosing loop is resumed. N must be greater than or equal to 1. - The return status is zero unless N is not greater than or equal to - 1. + ‘continue’ resumes the next iteration of an enclosing ‘for’, + ‘while’, ‘until’, or ‘select’ loop. If N is supplied, Bash resumes + the execution of the Nth enclosing loop. N must be greater than or + equal to 1. The return status is zero unless N is not greater than + or equal to 1. -'eval' +‘eval’ eval [ARGUMENTS] - The arguments are concatenated together into a single command, - which is then read and executed, and its exit status returned as - the exit status of 'eval'. If there are no arguments or only empty - arguments, the return status is zero. + The ARGUMENTS are concatenated together into a single command, + separated by spaces. Bash then reads and executes this command and + returns its exit status as the exit status of ‘eval’. If there are + no arguments or only empty arguments, the return status is zero. -'exec' +‘exec’ exec [-cl] [-a NAME] [COMMAND [ARGUMENTS]] If COMMAND is supplied, it replaces the shell without creating a - new process. If the '-l' option is supplied, the shell places a - dash at the beginning of the zeroth argument passed to COMMAND. - This is what the 'login' program does. The '-c' option causes - COMMAND to be executed with an empty environment. If '-a' is - supplied, the shell passes NAME as the zeroth argument to COMMAND. + new process. COMMAND cannot be a shell builtin or function. The + ARGUMENTS become the arguments to COMMAND If the ‘-l’ option is + supplied, the shell places a dash at the beginning of the zeroth + argument passed to COMMAND. This is what the ‘login’ program does. + The ‘-c’ option causes COMMAND to be executed with an empty + environment. If ‘-a’ is supplied, the shell passes NAME as the + zeroth argument to COMMAND. + If COMMAND cannot be executed for some reason, a non-interactive - shell exits, unless the 'execfail' shell option is enabled. In - that case, it returns failure. An interactive shell returns - failure if the file cannot be executed. A subshell exits - unconditionally if 'exec' fails. If no COMMAND is specified, - redirections may be used to affect the current shell environment. - If there are no redirection errors, the return status is zero; - otherwise the return status is non-zero. - -'exit' + shell exits, unless the ‘execfail’ shell option is enabled. In + that case, it returns a non-zero status. An interactive shell + returns a non-zero status if the file cannot be executed. A + subshell exits unconditionally if ‘exec’ fails. + + If COMMAND is not specified, redirections may be used to affect the + current shell environment. If there are no redirection errors, the + return status is zero; otherwise the return status is non-zero. + +‘exit’ exit [N] Exit the shell, returning a status of N to the shell's parent. If N is omitted, the exit status is that of the last command executed. - Any trap on 'EXIT' is executed before the shell terminates. + Any trap on ‘EXIT’ is executed before the shell terminates. -'export' +‘export’ export [-fn] [-p] [NAME[=VALUE]] - Mark each NAME to be passed to child processes in the environment. - If the '-f' option is supplied, the NAMEs refer to shell functions; - otherwise the names refer to shell variables. The '-n' option - means to no longer mark each NAME for export. If no NAMEs are - supplied, or if the '-p' option is given, a list of names of all - exported variables is displayed. The '-p' option displays output - in a form that may be reused as input. If a variable name is - followed by =VALUE, the value of the variable is set to VALUE. + Mark each NAME to be passed to subsequently executed commands in + the environment. If the ‘-f’ option is supplied, the NAMEs refer + to shell functions; otherwise the names refer to shell variables. + + The ‘-n’ option means to unexport each name: no longer mark it for + export. If no NAMEs are supplied, or if only the ‘-p’ option is + given, ‘export’ displays a list of names of all exported variables + on the standard output. Using ‘-p’ and ‘-f’ together displays + exported functions. The ‘-p’ option displays output in a form that + may be reused as input. + + ‘export’ allows the value of a variable to be set at the same time + it is exported or unexported by following the variable name with + =VALUE. This sets the value of the variable is to VALUE while + modifying the export attribute. The return status is zero unless an invalid option is supplied, one - of the names is not a valid shell variable name, or '-f' is + of the names is not a valid shell variable name, or ‘-f’ is supplied with a name that is not a shell function. -'getopts' +‘false’ + false + + Does nothing; returns a non-zero status. + +‘getopts’ getopts OPTSTRING NAME [ARG ...] - 'getopts' is used by shell scripts to parse positional parameters. - OPTSTRING contains the option characters to be recognized; if a - character is followed by a colon, the option is expected to have an - argument, which should be separated from it by whitespace. The - colon (':') and question mark ('?') may not be used as option - characters. Each time it is invoked, 'getopts' places the next - option in the shell variable NAME, initializing NAME if it does not - exist, and the index of the next argument to be processed into the - variable 'OPTIND'. 'OPTIND' is initialized to 1 each time the - shell or a shell script is invoked. When an option requires an - argument, 'getopts' places that argument into the variable - 'OPTARG'. The shell does not reset 'OPTIND' automatically; it must - be manually reset between multiple calls to 'getopts' within the - same shell invocation if a new set of parameters is to be used. - - When the end of options is encountered, 'getopts' exits with a - return value greater than zero. 'OPTIND' is set to the index of - the first non-option argument, and NAME is set to '?'. - - 'getopts' normally parses the positional parameters, but if more - arguments are supplied as ARG values, 'getopts' parses those + ‘getopts’ is used by shell scripts or functions to parse positional + parameters and obtain options and their arguments. OPTSTRING + contains the option characters to be recognized; if a character is + followed by a colon, the option is expected to have an argument, + which should be separated from it by whitespace. The colon (‘:’) + and question mark (‘?’) may not be used as option characters. + + Each time it is invoked, ‘getopts’ places the next option in the + shell variable NAME, initializing NAME if it does not exist, and + the index of the next argument to be processed into the variable + ‘OPTIND’. ‘OPTIND’ is initialized to 1 each time the shell or a + shell script is invoked. When an option requires an argument, + ‘getopts’ places that argument into the variable ‘OPTARG’. + + The shell does not reset ‘OPTIND’ automatically; it must be + manually reset between multiple calls to ‘getopts’ within the same + shell invocation to use a new set of parameters. + + When it reaches the end of options, ‘getopts’ exits with a return + value greater than zero. ‘OPTIND’ is set to the index of the first + non-option argument, and NAME is set to ‘?’. + + ‘getopts’ normally parses the positional parameters, but if more + arguments are supplied as ARG values, ‘getopts’ parses those instead. - 'getopts' can report errors in two ways. If the first character of - OPTSTRING is a colon, SILENT error reporting is used. In normal - operation, diagnostic messages are printed when invalid options or - missing option arguments are encountered. If the variable 'OPTERR' - is set to 0, no error messages will be displayed, even if the first - character of 'optstring' is not a colon. - - If an invalid option is seen, 'getopts' places '?' into NAME and, - if not silent, prints an error message and unsets 'OPTARG'. If - 'getopts' is silent, the option character found is placed in - 'OPTARG' and no diagnostic message is printed. - - If a required argument is not found, and 'getopts' is not silent, a - question mark ('?') is placed in NAME, 'OPTARG' is unset, and a - diagnostic message is printed. If 'getopts' is silent, then a - colon (':') is placed in NAME and 'OPTARG' is set to the option - character found. - -'hash' + ‘getopts’ can report errors in two ways. If the first character of + OPTSTRING is a colon, ‘getopts’ uses _silent_ error reporting. In + normal operation, ‘getopts’ prints diagnostic messages when it + encounters invalid options or missing option arguments. If the + variable ‘OPTERR’ is set to 0, ‘getopts’ does not display any error + messages, even if the first character of ‘optstring’ is not a + colon. + + If ‘getopts’ detects an invalid option, it places ‘?’ into NAME + and, if not silent, prints an error message and unsets ‘OPTARG’. + If ‘getopts’ is silent, it assigns the option character found to + ‘OPTARG’ and does not print a diagnostic message. + + If a required argument is not found, and ‘getopts’ is not silent, + it sets the value of NAME to a question mark (‘?’), unsets + ‘OPTARG’, and prints a diagnostic message. If ‘getopts’ is silent, + it sets the value of NAME to a colon (‘:’), and sets ‘OPTARG’ to + the option character found. + + ‘getopts’ returns true if an option, specified or unspecified, is + found. It returns false when it encounters the end of options or + if an error occurs. + +‘hash’ hash [-r] [-p FILENAME] [-dt] [NAME] - Each time 'hash' is invoked, it remembers the full pathnames of the + Each time ‘hash’ is invoked, it remembers the full filenames of the commands specified as NAME arguments, so they need not be searched for on subsequent invocations. The commands are found by searching - through the directories listed in '$PATH'. Any - previously-remembered pathname is discarded. The '-p' option - inhibits the path search, and FILENAME is used as the location of - NAME. The '-r' option causes the shell to forget all remembered - locations. The '-d' option causes the shell to forget the - remembered location of each NAME. If the '-t' option is supplied, - the full pathname to which each NAME corresponds is printed. If - multiple NAME arguments are supplied with '-t', the NAME is printed - before the hashed full pathname. The '-l' option causes output to - be displayed in a format that may be reused as input. If no - arguments are given, or if only '-l' is supplied, information about - remembered commands is printed. The return status is zero unless a - NAME is not found or an invalid option is supplied. - -'pwd' + through the directories listed in ‘$PATH’. Any + previously-remembered filename associated with NAME is discarded. + The ‘-p’ option inhibits the path search, and ‘hash’ uses FILENAME + as the location of NAME. + + The ‘-r’ option causes the shell to forget all remembered + locations. Assigning to the ‘PATH’ variable also clears all hashed + filenames. The ‘-d’ option causes the shell to forget the + remembered location of each NAME. + + If the ‘-t’ option is supplied, ‘hash’ prints the full pathname + corresponding to each NAME. If multiple NAME arguments are + supplied with ‘-t’, ‘hash’ prints each NAME before the + corresponding hashed full path. The ‘-l’ option displays output in + a format that may be reused as input. + + If no arguments are given, or if only ‘-l’ is supplied, ‘hash’ + prints information about remembered commands. The ‘-t’, ‘-d’, and + ‘-p’ options (the options that act on the NAME arguments) are + mutually exclusive. Only one will be active. If more than one is + supplied, ‘-t’ has higher priority than ‘-p’, and both have higher + priority than ‘-d’. + + The return status is zero unless a NAME is not found or an invalid + option is supplied. + +‘pwd’ pwd [-LP] Print the absolute pathname of the current working directory. If - the '-P' option is supplied, the pathname printed will not contain - symbolic links. If the '-L' option is supplied, the pathname - printed may contain symbolic links. The return status is zero - unless an error is encountered while determining the name of the - current directory or an invalid option is supplied. - -'readonly' + the ‘-P’ option is supplied, or the ‘-o physical’ option to the + ‘set’ builtin (*note The Set Builtin::) is enabled, the pathname + printed will not contain symbolic links. If the ‘-L’ option is + supplied, the pathname printed may contain symbolic links. The + return status is zero unless an error is encountered while + determining the name of the current directory or an invalid option + is supplied. + +‘readonly’ readonly [-aAf] [-p] [NAME[=VALUE]] ... Mark each NAME as readonly. The values of these names may not be - changed by subsequent assignment. If the '-f' option is supplied, - each NAME refers to a shell function. The '-a' option means each - NAME refers to an indexed array variable; the '-A' option means - each NAME refers to an associative array variable. If both options - are supplied, '-A' takes precedence. If no NAME arguments are - given, or if the '-p' option is supplied, a list of all readonly - names is printed. The other options may be used to restrict the - output to a subset of the set of readonly names. The '-p' option - causes output to be displayed in a format that may be reused as - input. If a variable name is followed by =VALUE, the value of the - variable is set to VALUE. The return status is zero unless an - invalid option is supplied, one of the NAME arguments is not a - valid shell variable or function name, or the '-f' option is - supplied with a name that is not a shell function. + changed by subsequent assignment or unset. If the ‘-f’ option is + supplied, each NAME refers to a shell function. The ‘-a’ option + means each NAME refers to an indexed array variable; the ‘-A’ + option means each NAME refers to an associative array variable. If + both options are supplied, ‘-A’ takes precedence. If no NAME + arguments are supplied, or if the ‘-p’ option is supplied, print a + list of all readonly names. The other options may be used to + restrict the output to a subset of the set of readonly names. The + ‘-p’ option displays output in a format that may be reused as + input. + + ‘readonly’ allows the value of a variable to be set at the same + time the readonly attribute is changed by following the variable + name with =VALUE. This sets the value of the variable is to VALUE + while modifying the readonly attribute. + + The return status is zero unless an invalid option is supplied, one + of the NAME arguments is not a valid shell variable or function + name, or the ‘-f’ option is supplied with a name that is not a + shell function. -'return' +‘return’ return [N] - Cause a shell function to stop executing and return the value N to - its caller. If N is not supplied, the return value is the exit - status of the last command executed in the function. If 'return' - is executed by a trap handler, the last command used to determine - the status is the last command executed before the trap handler. - If 'return' is executed during a 'DEBUG' trap, the last command - used to determine the status is the last command executed by the - trap handler before 'return' was invoked. 'return' may also be - used to terminate execution of a script being executed with the '.' - ('source') builtin, returning either N or the exit status of the - last command executed within the script as the exit status of the - script. If N is supplied, the return value is its least - significant 8 bits. Any command associated with the 'RETURN' trap - is executed before execution resumes after the function or script. - The return status is non-zero if 'return' is supplied a non-numeric + Stop executing a shell function or sourced file and return the + value N to its caller. If N is not supplied, the return value is + the exit status of the last command executed. If ‘return’ is + executed by a trap handler, the last command used to determine the + status is the last command executed before the trap handler. If + ‘return’ is executed during a ‘DEBUG’ trap, the last command used + to determine the status is the last command executed by the trap + handler before ‘return’ was invoked. + + When ‘return’ is used to terminate execution of a script being + executed with the ‘.’ (‘source’) builtin, it returns either N or + the exit status of the last command executed within the script as + the exit status of the script. If N is supplied, the return value + is its least significant 8 bits. + + Any command associated with the ‘RETURN’ trap is executed before + execution resumes after the function or script. + + The return status is non-zero if ‘return’ is supplied a non-numeric argument or is used outside a function and not during the execution - of a script by '.' or 'source'. + of a script by ‘.’ or ‘source’. -'shift' +‘shift’ shift [N] - Shift the positional parameters to the left by N. The positional - parameters from N+1 ... '$#' are renamed to '$1' ... '$#'-N. - Parameters represented by the numbers '$#' down to '$#'-N+1 are - unset. N must be a non-negative number less than or equal to '$#'. - If N is zero or greater than '$#', the positional parameters are - not changed. If N is not supplied, it is assumed to be 1. The - return status is zero unless N is greater than '$#' or less than + Shift the positional parameters to the left by N: the positional + parameters from N+1 ... ‘$#’ are renamed to ‘$1’ ... ‘$#’-N. + Parameters represented by the numbers ‘$#’ down to ‘$#’-N+1 are + unset. N must be a non-negative number less than or equal to ‘$#’. + If N is not supplied, it is assumed to be 1. If N is zero or + greater than ‘$#’, the positional parameters are not changed. The + return status is zero unless N is greater than ‘$#’ or less than zero, non-zero otherwise. -'test' -'[' +‘test’ +‘[’ test EXPR Evaluate a conditional expression EXPR and return a status of 0 (true) or 1 (false). Each operator and operand must be a separate argument. Expressions are composed of the primaries described - below in *note Bash Conditional Expressions::. 'test' does not + below in *note Bash Conditional Expressions::. ‘test’ does not accept any options, nor does it accept and ignore an argument of - '--' as signifying the end of options. - - When the '[' form is used, the last argument to the command must be - a ']'. + ‘--’ as signifying the end of options. When using the ‘[’ form, + the last argument to the command must be a ‘]’. Expressions may be combined using the following operators, listed in decreasing order of precedence. The evaluation depends on the - number of arguments; see below. Operator precedence is used when - there are five or more arguments. + number of arguments; see below. ‘test’ uses operator precedence + when there are five or more arguments. - '! EXPR' + ‘! EXPR’ True if EXPR is false. - '( EXPR )' - Returns the value of EXPR. This may be used to override the - normal precedence of operators. + ‘( EXPR )’ + Returns the value of EXPR. This may be used to override + normal operator precedence. - 'EXPR1 -a EXPR2' + ‘EXPR1 -a EXPR2’ True if both EXPR1 and EXPR2 are true. - 'EXPR1 -o EXPR2' + ‘EXPR1 -o EXPR2’ True if either EXPR1 or EXPR2 is true. - The 'test' and '[' builtins evaluate conditional expressions using + The ‘test’ and ‘[’ builtins evaluate conditional expressions using a set of rules based on the number of arguments. 0 arguments @@ -3513,7 +3816,7 @@ standard. null. 2 arguments - If the first argument is '!', the expression is true if and + If the first argument is ‘!’, the expression is true if and only if the second argument is null. If the first argument is one of the unary conditional operators (*note Bash Conditional Expressions::), the expression is true if the unary test is @@ -3527,24 +3830,24 @@ standard. operators (*note Bash Conditional Expressions::), the result of the expression is the result of the binary test using the first and third arguments as operands. The - '-a' and '-o' operators are considered binary operators + ‘-a’ and ‘-o’ operators are considered binary operators when there are three arguments. - 2. If the first argument is '!', the value is the negation + 2. If the first argument is ‘!’, the value is the negation of the two-argument test using the second and third arguments. - 3. If the first argument is exactly '(' and the third - argument is exactly ')', the result is the one-argument + 3. If the first argument is exactly ‘(’ and the third + argument is exactly ‘)’, the result is the one-argument test of the second argument. 4. Otherwise, the expression is false. 4 arguments The following conditions are applied in the order listed. - 1. If the first argument is '!', the result is the negation + 1. If the first argument is ‘!’, the result is the negation of the three-argument expression composed of the remaining arguments. - 2. If the first argument is exactly '(' and the fourth - argument is exactly ')', the result is the two-argument + 2. If the first argument is exactly ‘(’ and the fourth + argument is exactly ‘)’, the result is the two-argument test of the second and third arguments. 3. Otherwise, the expression is parsed and evaluated according to precedence using the rules listed above. @@ -3553,99 +3856,140 @@ standard. The expression is parsed and evaluated according to precedence using the rules listed above. - When used with 'test' or '[', the '<' and '>' operators sort - lexicographically using ASCII ordering. + If the shell is in POSIX mode, or if the expression is part of the + ‘[[’ command, the ‘<’ and ‘>’ operators sort using the current + locale. If the shell is not in POSIX mode, the ‘test’ and ‘[’ + commands sort lexicographically using ASCII ordering. + + The historical operator-precedence parsing with 4 or more arguments + can lead to ambiguities when it encounters strings that look like + primaries. The POSIX standard has deprecated the ‘-a’ and ‘-o’ + primaries and enclosing expressions within parentheses. Scripts + should no longer use them. It's much more reliable to restrict + test invocations to a single primary, and to replace uses of ‘-a’ + and ‘-o’ with the shell's ‘&&’ and ‘||’ list operators. For + example, use + + test -n string1 && test -n string2 -'times' + instead of + + test -n string1 -a -n string2 + +‘times’ times Print out the user and system times used by the shell and its children. The return status is zero. -'trap' - trap [-lp] [ARG] [SIGSPEC ...] - - The commands in ARG are to be read and executed when the shell - receives signal SIGSPEC. If ARG is absent (and there is a single - SIGSPEC) or equal to '-', each specified signal's disposition is - reset to the value it had when the shell was started. If ARG is - the null string, then the signal specified by each SIGSPEC is - ignored by the shell and commands it invokes. If ARG is not - present and '-p' has been supplied, the shell displays the trap - commands associated with each SIGSPEC. If no arguments are - supplied, or only '-p' is given, 'trap' prints the list of commands - associated with each signal number in a form that may be reused as - shell input. The '-l' option causes the shell to print a list of - signal names and their corresponding numbers. Each SIGSPEC is - either a signal name or a signal number. Signal names are case - insensitive and the 'SIG' prefix is optional. - - If a SIGSPEC is '0' or 'EXIT', ARG is executed when the shell - exits. If a SIGSPEC is 'DEBUG', the command ARG is executed before - every simple command, 'for' command, 'case' command, 'select' - command, every arithmetic 'for' command, and before the first - command executes in a shell function. Refer to the description of - the 'extdebug' option to the 'shopt' builtin (*note The Shopt - Builtin::) for details of its effect on the 'DEBUG' trap. If a - SIGSPEC is 'RETURN', the command ARG is executed each time a shell - function or a script executed with the '.' or 'source' builtins +‘trap’ + trap [-lpP] [ACTION] [SIGSPEC ...] + + The ACTION is a command that is read and executed when the shell + receives any of the signals SIGSPEC. If ACTION is absent (and + there is a single SIGSPEC) or equal to ‘-’, each specified + SIGSPEC's disposition is reset to the value it had when the shell + was started. If ACTION is the null string, then the signal + specified by each SIGSPEC is ignored by the shell and commands it + invokes. + + If no arguments are supplied, ‘trap’ prints the actions associated + with each trapped signal as a set of ‘trap’ commands that can be + reused as shell input to restore the current signal dispositions. + + If ACTION is not present and ‘-p’ has been supplied, ‘trap’ + displays the trap commands associated with each SIGSPEC, or, if no + SIGSPECs are supplied, for all trapped signals, as a set of ‘trap’ + commands that can be reused as shell input to restore the current + signal dispositions. The ‘-P’ option behaves similarly, but + displays only the actions associated with each SIGSPEC argument. + ‘-P’ requires at least one SIGSPEC argument. The ‘-P’ or ‘-p’ + options may be used in a subshell environment (e.g., command + substitution) and, as long as they are used before ‘trap’ is used + to change a signal's handling, will display the state of its + parent's traps. + + The ‘-l’ option prints a list of signal names and their + corresponding numbers. Each SIGSPEC is either a signal name or a + signal number. Signal names are case insensitive and the ‘SIG’ + prefix is optional. If ‘-l’ is supplied with no SIGSPEC arguments, + it prints a list of valid signal names. + + If a SIGSPEC is ‘0’ or ‘EXIT’, ACTION is executed when the shell + exits. If a SIGSPEC is ‘DEBUG’, ACTION is executed before every + simple command, ‘for’ command, ‘case’ command, ‘select’ command, (( + arithmetic command, [[ conditional command, arithmetic ‘for’ + command, and before the first command executes in a shell function. + Refer to the description of the ‘extdebug’ shell option (*note The + Shopt Builtin::) for details of its effect on the ‘DEBUG’ trap. If + a SIGSPEC is ‘RETURN’, ACTION is executed each time a shell + function or a script executed with the ‘.’ or ‘source’ builtins finishes executing. - If a SIGSPEC is 'ERR', the command ARG is executed whenever a - pipeline (which may consist of a single simple command), a list, or - a compound command returns a non-zero exit status, subject to the - following conditions. The 'ERR' trap is not executed if the failed + If a SIGSPEC is ‘ERR’, ACTION is executed whenever a pipeline + (which may consist of a single simple command), a list, or a + compound command returns a non-zero exit status, subject to the + following conditions. The ‘ERR’ trap is not executed if the failed command is part of the command list immediately following an - 'until' or 'while' keyword, part of the test following the 'if' or - 'elif' reserved words, part of a command executed in a '&&' or '||' - list except the command following the final '&&' or '||', any - command in a pipeline but the last, or if the command's return - status is being inverted using '!'. These are the same conditions - obeyed by the 'errexit' ('-e') option. - - Signals ignored upon entry to the shell cannot be trapped or reset. - Trapped signals that are not being ignored are reset to their - original values in a subshell or subshell environment when one is - created. + ‘until’ or ‘while’ reserved word, part of the test following the + ‘if’ or ‘elif’ reserved words, part of a command executed in a ‘&&’ + or ‘||’ list except the command following the final ‘&&’ or ‘||’, + any command in a pipeline but the last, (subject to the state of + the ‘pipefail’ shell option), or if the command's return status is + being inverted using ‘!’. These are the same conditions obeyed by + the ‘errexit’ (‘-e’) option. + + When the shell is not interactive, signals ignored upon entry to a + non-interactive shell cannot be trapped or reset. Interactive + shells permit trapping signals ignored on entry. Trapped signals + that are not being ignored are reset to their original values in a + subshell or subshell environment when one is created. The return status is zero unless a SIGSPEC does not specify a valid - signal. + signal; non-zero otherwise. + +‘true’ + true -'umask' + Does nothing, returns a 0 status. + +‘umask’ umask [-p] [-S] [MODE] Set the shell process's file creation mask to MODE. If MODE begins with a digit, it is interpreted as an octal number; if not, it is interpreted as a symbolic mode mask similar to that accepted by the - 'chmod' command. If MODE is omitted, the current value of the mask - is printed. If the '-S' option is supplied without a MODE - argument, the mask is printed in a symbolic format. If the '-p' - option is supplied, and MODE is omitted, the output is in a form - that may be reused as input. The return status is zero if the mode - is successfully changed or if no MODE argument is supplied, and - non-zero otherwise. + ‘chmod’ command. If MODE is omitted, ‘umask’ prints the current + value of the mask. If the ‘-S’ option is supplied without a MODE + argument, ‘umask’ prints the mask in a symbolic format; the default + output is an octal number. If the ‘-p’ option is supplied, and + MODE is omitted, the output is in a form that may be reused as + input. The return status is zero if the mode is successfully + changed or if no MODE argument is supplied, and non-zero otherwise. Note that when the mode is interpreted as an octal number, each - number of the umask is subtracted from '7'. Thus, a umask of '022' - results in permissions of '755'. + number of the umask is subtracted from ‘7’. Thus, a umask of ‘022’ + results in permissions of ‘755’. -'unset' +‘unset’ unset [-fnv] [NAME] - Remove each variable or function NAME. If the '-v' option is + Remove each variable or function NAME. If the ‘-v’ option is given, each NAME refers to a shell variable and that variable is - removed. If the '-f' option is given, the NAMEs refer to shell - functions, and the function definition is removed. If the '-n' - option is supplied, and NAME is a variable with the 'nameref' + removed. If the ‘-f’ option is given, the NAMEs refer to shell + functions, and the function definition is removed. If the ‘-n’ + option is supplied, and NAME is a variable with the ‘nameref’ attribute, NAME will be unset rather than the variable it - references. '-n' has no effect if the '-f' option is supplied. If + references. ‘-n’ has no effect if the ‘-f’ option is supplied. If no options are supplied, each NAME refers to a variable; if there is no variable by that name, a function with that name, if any, is - unset. Readonly variables and functions may not be unset. Some - shell variables lose their special behavior if they are unset; such - behavior is noted in the description of the individual variables. - The return status is zero unless a NAME is readonly or may not be - unset. + unset. Readonly variables and functions may not be unset. When + variables or functions are removed, they are also removed from the + environment passed to subsequent commands. Some shell variables + may not be unset. Some shell variables lose their special behavior + if they are unset; such behavior is noted in the description of the + individual variables. The return status is zero unless a NAME is + readonly or may not be unset.  File: bash.info, Node: Bash Builtins, Next: Modifying Shell Behavior, Prev: Bourne Shell Builtins, Up: Shell Builtin Commands @@ -3657,121 +4001,146 @@ This section describes builtin commands which are unique to or have been extended in Bash. Some of these commands are specified in the POSIX standard. -'alias' +‘alias’ alias [-p] [NAME[=VALUE] ...] - Without arguments or with the '-p' option, 'alias' prints the list + Without arguments or with the ‘-p’ option, ‘alias’ prints the list of aliases on the standard output in a form that allows them to be - reused as input. If arguments are supplied, an alias is defined - for each NAME whose VALUE is given. If no VALUE is given, the name - and value of the alias is printed. Aliases are described in *note - Aliases::. - -'bind' - bind [-m KEYMAP] [-lpsvPSVX] + reused as input. If arguments are supplied, define an alias for + each NAME whose VALUE is given. If no VALUE is given, print the + name and value of the alias NAME. A trailing space in VALUE causes + the next word to be checked for alias substitution when the alias + is expanded during command parsing. ‘alias’ returns true unless a + NAME is given (without a corresponding =VALUE) for which no alias + has been defined. Aliases are described in *note Aliases::. + +‘bind’ + bind [-m KEYMAP] [-lsvSVX] bind [-m KEYMAP] [-q FUNCTION] [-u FUNCTION] [-r KEYSEQ] bind [-m KEYMAP] -f FILENAME - bind [-m KEYMAP] -x KEYSEQ:SHELL-COMMAND + bind [-m KEYMAP] -x KEYSEQ[: ]SHELL-COMMAND bind [-m KEYMAP] KEYSEQ:FUNCTION-NAME bind [-m KEYMAP] KEYSEQ:READLINE-COMMAND + bind [-m KEYMAP] -p|-P [READLINE-COMMAND] bind READLINE-COMMAND-LINE Display current Readline (*note Command Line Editing::) key and function bindings, bind a key sequence to a Readline function or - macro, or set a Readline variable. Each non-option argument is a - command as it would appear in a Readline initialization file (*note - Readline Init File::), but each binding or command must be passed - as a separate argument; e.g., '"\C-x\C-r":re-read-init-file'. + macro or to a shell command, or set a Readline variable. Each + non-option argument is a key binding or command as it would appear + in a Readline initialization file (*note Readline Init File::), but + each binding or command must be passed as a separate argument; + e.g., ‘"\C-x\C-r":re-read-init-file’. + + In the following descriptions, options that display output in a + form available to be re-read format their output as commands that + would appear in a Readline initialization file or that would be + supplied as individual arguments to a ‘bind’ command. Options, if supplied, have the following meanings: - '-m KEYMAP' + ‘-m KEYMAP’ Use KEYMAP as the keymap to be affected by the subsequent - bindings. Acceptable KEYMAP names are 'emacs', - 'emacs-standard', 'emacs-meta', 'emacs-ctlx', 'vi', 'vi-move', - 'vi-command', and 'vi-insert'. 'vi' is equivalent to - 'vi-command' ('vi-move' is also a synonym); 'emacs' is - equivalent to 'emacs-standard'. + bindings. Acceptable KEYMAP names are ‘emacs’, + ‘emacs-standard’, ‘emacs-meta’, ‘emacs-ctlx’, ‘vi’, ‘vi-move’, + ‘vi-command’, and ‘vi-insert’. ‘vi’ is equivalent to + ‘vi-command’ (‘vi-move’ is also a synonym); ‘emacs’ is + equivalent to ‘emacs-standard’. - '-l' + ‘-l’ List the names of all Readline functions. - '-p' + ‘-p’ Display Readline function names and bindings in such a way - that they can be used as input or in a Readline initialization - file. - - '-P' - List current Readline function names and bindings. + that they can be used as an argument to a subsequent ‘bind’ + command or in a Readline initialization file. If arguments + remain after option processing, ‘bind’ treats them as readline + command names and restricts output to those names. - '-v' - Display Readline variable names and values in such a way that - they can be used as input or in a Readline initialization - file. - - '-V' - List current Readline variable names and values. + ‘-P’ + List current Readline function names and bindings. If + arguments remain after option processing, ‘bind’ treats them + as readline command names and restricts output to those names. - '-s' + ‘-s’ Display Readline key sequences bound to macros and the strings - they output in such a way that they can be used as input or in - a Readline initialization file. + they output in such a way that they can be used as an argument + to a subsequent ‘bind’ command or in a Readline initialization + file. - '-S' + ‘-S’ Display Readline key sequences bound to macros and the strings they output. - '-f FILENAME' + ‘-v’ + Display Readline variable names and values in such a way that + they can be used as an argument to a subsequent ‘bind’ command + or in a Readline initialization file. + + ‘-V’ + List current Readline variable names and values. + + ‘-f FILENAME’ Read key bindings from FILENAME. - '-q FUNCTION' - Query about which keys invoke the named FUNCTION. + ‘-q FUNCTION’ + Display key sequences that invoke the named Readline FUNCTION. - '-u FUNCTION' - Unbind all keys bound to the named FUNCTION. + ‘-u FUNCTION’ + Unbind all key sequences bound to the named Readline FUNCTION. - '-r KEYSEQ' + ‘-r KEYSEQ’ Remove any current binding for KEYSEQ. - '-x KEYSEQ:SHELL-COMMAND' + ‘-x KEYSEQ:SHELL-COMMAND’ Cause SHELL-COMMAND to be executed whenever KEYSEQ is entered. - When SHELL-COMMAND is executed, the shell sets the - 'READLINE_LINE' variable to the contents of the Readline line - buffer and the 'READLINE_POINT' and 'READLINE_MARK' variables + The separator between KEYSEQ and SHELL-COMMAND is either + whitespace or a colon optionally followed by whitespace. If + the separator is whitespace, SHELL-COMMAND must be enclosed in + double quotes and Readline expands any of its special + backslash-escapes in SHELL-COMMAND before saving it. If the + separator is a colon, any enclosing double quotes are + optional, and Readline does not expand the command string + before saving it. Since the entire key binding expression + must be a single argument, it should be enclosed in single + quotes. When SHELL-COMMAND is executed, the shell sets the + ‘READLINE_LINE’ variable to the contents of the Readline line + buffer and the ‘READLINE_POINT’ and ‘READLINE_MARK’ variables to the current location of the insertion point and the saved insertion point (the MARK), respectively. The shell assigns any numeric argument the user supplied to the - 'READLINE_ARGUMENT' variable. If there was no argument, that + ‘READLINE_ARGUMENT’ variable. If there was no argument, that variable is not set. If the executed command changes the - value of any of 'READLINE_LINE', 'READLINE_POINT', or - 'READLINE_MARK', those new values will be reflected in the + value of any of ‘READLINE_LINE’, ‘READLINE_POINT’, or + ‘READLINE_MARK’, those new values will be reflected in the editing state. - '-X' + ‘-X’ List all key sequences bound to shell commands and the - associated commands in a format that can be reused as input. + associated commands in a format that can be reused as an + argument to a subsequent ‘bind’ command. The return status is zero unless an invalid option is supplied or an error occurs. -'builtin' +‘builtin’ builtin [SHELL-BUILTIN [ARGS]] - Run a shell builtin, passing it ARGS, and return its exit status. - This is useful when defining a shell function with the same name as - a shell builtin, retaining the functionality of the builtin within - the function. The return status is non-zero if SHELL-BUILTIN is - not a shell builtin command. + Execute the specified shell builtin SHELL-BUILTIN, passing it ARGS, + and return its exit status. This is useful when defining a shell + function with the same name as a shell builtin, retaining the + functionality of the builtin within the function. The return + status is non-zero if SHELL-BUILTIN is not a shell builtin command. -'caller' +‘caller’ caller [EXPR] Returns the context of any active subroutine call (a shell function - or a script executed with the '.' or 'source' builtins). + or a script executed with the ‘.’ or ‘source’ builtins). - Without EXPR, 'caller' displays the line number and source filename + Without EXPR, ‘caller’ displays the line number and source filename of the current subroutine call. If a non-negative integer is - supplied as EXPR, 'caller' displays the line number, subroutine + supplied as EXPR, ‘caller’ displays the line number, subroutine name, and source file corresponding to that position in the current execution call stack. This extra information may be used, for example, to print a stack trace. The current frame is frame 0. @@ -3780,620 +4149,688 @@ standard. subroutine call or EXPR does not correspond to a valid position in the call stack. -'command' +‘command’ command [-pVv] COMMAND [ARGUMENTS ...] - Runs COMMAND with ARGUMENTS ignoring any shell function named - COMMAND. Only shell builtin commands or commands found by - searching the 'PATH' are executed. If there is a shell function - named 'ls', running 'command ls' within the function will execute - the external command 'ls' instead of calling the function - recursively. The '-p' option means to use a default value for - 'PATH' that is guaranteed to find all of the standard utilities. - The return status in this case is 127 if COMMAND cannot be found or - an error occurred, and the exit status of COMMAND otherwise. - - If either the '-V' or '-v' option is supplied, a description of - COMMAND is printed. The '-v' option causes a single word - indicating the command or file name used to invoke COMMAND to be - displayed; the '-V' option produces a more verbose description. In - this case, the return status is zero if COMMAND is found, and - non-zero if not. - -'declare' + The ‘command’ builtin runs COMMAND with ARGUMENTS ignoring any + shell function named COMMAND. Only shell builtin commands or + commands found by searching the ‘PATH’ are executed. If there is a + shell function named ‘ls’, running ‘command ls’ within the function + will execute the external command ‘ls’ instead of calling the + function recursively. The ‘-p’ option means to use a default value + for ‘PATH’ that is guaranteed to find all of the standard + utilities. The return status in this case is 127 if COMMAND cannot + be found or an error occurred, and the exit status of COMMAND + otherwise. + + If either the ‘-V’ or ‘-v’ option is supplied, ‘command’ prints a + description of COMMAND. The ‘-v’ option displays a single word + indicating the command or file name used to invoke COMMAND; the + ‘-V’ option produces a more verbose description. In this case, the + return status is zero if COMMAND is found, and non-zero if not. + +‘declare’ declare [-aAfFgiIlnrtux] [-p] [NAME[=VALUE] ...] Declare variables and give them attributes. If no NAMEs are given, - then display the values of variables instead. + then display the values of variables or shell functions instead. - The '-p' option will display the attributes and values of each - NAME. When '-p' is used with NAME arguments, additional options, - other than '-f' and '-F', are ignored. + The ‘-p’ option will display the attributes and values of each + NAME. When ‘-p’ is used with NAME arguments, additional options, + other than ‘-f’ and ‘-F’, are ignored. - When '-p' is supplied without NAME arguments, 'declare' will + When ‘-p’ is supplied without NAME arguments, ‘declare’ will display the attributes and values of all variables having the attributes specified by the additional options. If no other - options are supplied with '-p', 'declare' will display the - attributes and values of all shell variables. The '-f' option will - restrict the display to shell functions. + options are supplied with ‘-p’, ‘declare’ will display the + attributes and values of all shell variables. The ‘-f’ option + restricts the display to shell functions. - The '-F' option inhibits the display of function definitions; only - the function name and attributes are printed. If the 'extdebug' - shell option is enabled using 'shopt' (*note The Shopt Builtin::), + The ‘-F’ option inhibits the display of function definitions; only + the function name and attributes are printed. If the ‘extdebug’ + shell option is enabled using ‘shopt’ (*note The Shopt Builtin::), the source file name and line number where each NAME is defined are - displayed as well. '-F' implies '-f'. + displayed as well. ‘-F’ implies ‘-f’. - The '-g' option forces variables to be created or modified at the - global scope, even when 'declare' is executed in a shell function. - It is ignored in all other cases. + The ‘-g’ option forces variables to be created or modified at the + global scope, even when ‘declare’ is executed in a shell function. + It is ignored in when ‘declare’ is not executed in a shell + function. - The '-I' option causes local variables to inherit the attributes - (except the 'nameref' attribute) and value of any existing variable + The ‘-I’ option causes local variables to inherit the attributes + (except the ‘nameref’ attribute) and value of any existing variable with the same NAME at a surrounding scope. If there is no existing variable, the local variable is initially unset. The following options can be used to restrict output to variables with the specified attributes or to give variables attributes: - '-a' + ‘-a’ Each NAME is an indexed array variable (*note Arrays::). - '-A' + ‘-A’ Each NAME is an associative array variable (*note Arrays::). - '-f' - Use function names only. + ‘-f’ + Each NAME refers to a shell function. - '-i' + ‘-i’ The variable is to be treated as an integer; arithmetic evaluation (*note Shell Arithmetic::) is performed when the variable is assigned a value. - '-l' + ‘-l’ When the variable is assigned a value, all upper-case characters are converted to lower-case. The upper-case attribute is disabled. - '-n' - Give each NAME the 'nameref' attribute, making it a name + ‘-n’ + Give each NAME the ‘nameref’ attribute, making it a name reference to another variable. That other variable is defined by the value of NAME. All references, assignments, and attribute modifications to NAME, except for those using or - changing the '-n' attribute itself, are performed on the + changing the ‘-n’ attribute itself, are performed on the variable referenced by NAME's value. The nameref attribute cannot be applied to array variables. - '-r' + ‘-r’ Make NAMEs readonly. These names cannot then be assigned values by subsequent assignment statements or unset. - '-t' - Give each NAME the 'trace' attribute. Traced functions - inherit the 'DEBUG' and 'RETURN' traps from the calling shell. + ‘-t’ + Give each NAME the ‘trace’ attribute. Traced functions + inherit the ‘DEBUG’ and ‘RETURN’ traps from the calling shell. The trace attribute has no special meaning for variables. - '-u' + ‘-u’ When the variable is assigned a value, all lower-case characters are converted to upper-case. The lower-case attribute is disabled. - '-x' + ‘-x’ Mark each NAME for export to subsequent commands via the environment. - Using '+' instead of '-' turns off the attribute instead, with the - exceptions that '+a' and '+A' may not be used to destroy array - variables and '+r' will not remove the readonly attribute. When - used in a function, 'declare' makes each NAME local, as with the - 'local' command, unless the '-g' option is used. If a variable - name is followed by =VALUE, the value of the variable is set to - VALUE. + Using ‘+’ instead of ‘-’ turns off the specified attribute instead, + with the exceptions that ‘+a’ and ‘+A’ may not be used to destroy + array variables and ‘+r’ will not remove the readonly attribute. + + When used in a function, ‘declare’ makes each NAME local, as with + the ‘local’ command, unless the ‘-g’ option is supplied. If a + variable name is followed by =VALUE, the value of the variable is + set to VALUE. - When using '-a' or '-A' and the compound assignment syntax to + When using ‘-a’ or ‘-A’ and the compound assignment syntax to create array variables, additional attributes do not take effect until subsequent assignments. The return status is zero unless an invalid option is encountered, - an attempt is made to define a function using '-f foo=bar', an + an attempt is made to define a function using ‘-f foo=bar’, an attempt is made to assign a value to a readonly variable, an attempt is made to assign a value to an array variable without using the compound assignment syntax (*note Arrays::), one of the NAMEs is not a valid shell variable name, an attempt is made to turn off readonly status for a readonly variable, an attempt is made to turn off array status for an array variable, or an attempt - is made to display a non-existent function with '-f'. + is made to display a non-existent function with ‘-f’. -'echo' +‘echo’ echo [-neE] [ARG ...] Output the ARGs, separated by spaces, terminated with a newline. - The return status is 0 unless a write error occurs. If '-n' is - specified, the trailing newline is suppressed. If the '-e' option - is given, interpretation of the following backslash-escaped - characters is enabled. The '-E' option disables the interpretation - of these escape characters, even on systems where they are - interpreted by default. The 'xpg_echo' shell option may be used to - dynamically determine whether or not 'echo' expands these escape - characters by default. 'echo' does not interpret '--' to mean the - end of options. - - 'echo' interprets the following escape sequences: - '\a' + The return status is 0 unless a write error occurs. If ‘-n’ is + specified, the trailing newline is not printed. + + If the ‘-e’ option is given, ‘echo’ interprets the following + backslash-escaped characters. The ‘-E’ option disables + interpretation of these escape characters, even on systems where + they are interpreted by default. The ‘xpg_echo’ shell option + determines whether or not ‘echo’ interprets any options and expands + these escape characters. ‘echo’ does not interpret ‘--’ to mean + the end of options. + + ‘echo’ interprets the following escape sequences: + ‘\a’ alert (bell) - '\b' + ‘\b’ backspace - '\c' + ‘\c’ suppress further output - '\e' - '\E' + ‘\e’ + ‘\E’ escape - '\f' + ‘\f’ form feed - '\n' + ‘\n’ new line - '\r' + ‘\r’ carriage return - '\t' + ‘\t’ horizontal tab - '\v' + ‘\v’ vertical tab - '\\' + ‘\\’ backslash - '\0NNN' - the eight-bit character whose value is the octal value NNN - (zero to three octal digits) - '\xHH' - the eight-bit character whose value is the hexadecimal value - HH (one or two hex digits) - '\uHHHH' - the Unicode (ISO/IEC 10646) character whose value is the - hexadecimal value HHHH (one to four hex digits) - '\UHHHHHHHH' - the Unicode (ISO/IEC 10646) character whose value is the - hexadecimal value HHHHHHHH (one to eight hex digits) - -'enable' + ‘\0NNN’ + The eight-bit character whose value is the octal value NNN + (zero to three octal digits). + ‘\xHH’ + The eight-bit character whose value is the hexadecimal value + HH (one or two hex digits). + ‘\uHHHH’ + The Unicode (ISO/IEC 10646) character whose value is the + hexadecimal value HHHH (one to four hex digits). + ‘\UHHHHHHHH’ + The Unicode (ISO/IEC 10646) character whose value is the + hexadecimal value HHHHHHHH (one to eight hex digits). + + ‘echo’ writes any unrecognized backslash-escaped characters + unchanged. + +‘enable’ enable [-a] [-dnps] [-f FILENAME] [NAME ...] Enable and disable builtin shell commands. Disabling a builtin - allows a disk command which has the same name as a shell builtin to - be executed without specifying a full pathname, even though the - shell normally searches for builtins before disk commands. If '-n' - is used, the NAMEs become disabled. Otherwise NAMEs are enabled. - For example, to use the 'test' binary found via '$PATH' instead of - the shell builtin version, type 'enable -n test'. - - If the '-p' option is supplied, or no NAME arguments appear, a list - of shell builtins is printed. With no other arguments, the list - consists of all enabled shell builtins. The '-a' option means to - list each builtin with an indication of whether or not it is - enabled. - - The '-f' option means to load the new builtin command NAME from - shared object FILENAME, on systems that support dynamic loading. - Bash will use the value of the 'BASH_LOADABLES_PATH' variable as a - colon-separated list of directories in which to search for - FILENAME. The default is system-dependent. The '-d' option will - delete a builtin loaded with '-f'. + allows an executable file which has the same name as a shell + builtin to be executed without specifying a full pathname, even + though the shell normally searches for builtins before files. + + If ‘-n’ is supplied, the NAMEs are disabled. Otherwise NAMEs are + enabled. For example, to use the ‘test’ binary found using ‘$PATH’ + instead of the shell builtin version, type ‘enable -n test’. + + If the ‘-p’ option is supplied, or no NAME arguments are supplied, + print a list of shell builtins. With no other arguments, the list + consists of all enabled shell builtins. The ‘-n’ option means to + print only disabled builtins. The ‘-a’ option means to list each + builtin with an indication of whether or not it is enabled. The + ‘-s’ option means to restrict ‘enable’ to the POSIX special + builtins. - If there are no options, a list of the shell builtins is displayed. - The '-s' option restricts 'enable' to the POSIX special builtins. - If '-s' is used with '-f', the new builtin becomes a special - builtin (*note Special Builtins::). + The ‘-f’ option means to load the new builtin command NAME from + shared object FILENAME, on systems that support dynamic loading. + If FILENAME does not contain a slash. Bash will use the value of + the ‘BASH_LOADABLES_PATH’ variable as a colon-separated list of + directories in which to search for FILENAME. The default for + ‘BASH_LOADABLES_PATH’ is system-dependent, and may include "." to + force a search of the current directory. The ‘-d’ option will + delete a builtin loaded with ‘-f’. If ‘-s’ is used with ‘-f’, the + new builtin becomes a POSIX special builtin (*note Special + Builtins::). If no options are supplied and a NAME is not a shell builtin, - 'enable' will attempt to load NAME from a shared object named NAME, - as if the command were 'enable -f NAME NAME'. + ‘enable’ will attempt to load NAME from a shared object named NAME, + as if the command were ‘enable -f NAME NAME’. The return status is zero unless a NAME is not a shell builtin or there is an error loading a new builtin from a shared object. -'help' +‘help’ help [-dms] [PATTERN] Display helpful information about builtin commands. If PATTERN is - specified, 'help' gives detailed help on all commands matching - PATTERN, otherwise a list of the builtins is printed. + specified, ‘help’ gives detailed help on all commands matching + PATTERN as described below; otherwise it displays a list of all + builtins and shell compound commands. Options, if supplied, have the following meanings: - '-d' + ‘-d’ Display a short description of each PATTERN - '-m' + ‘-m’ Display the description of each PATTERN in a manpage-like format - '-s' + ‘-s’ Display only a short usage synopsis for each PATTERN + If PATTERN contains pattern matching characters (*note Pattern + Matching::) it's treated as a shell pattern and ‘help’ prints the + description of each help topic matching PATTERN. + + If not, and PATTERN exactly matches the name of a help topic, + ‘help’ prints the description associated with that topic. + Otherwise, ‘help’ performs prefix matching and prints the + descriptions of all matching help topics. + The return status is zero unless no command matches PATTERN. -'let' +‘let’ let EXPRESSION [EXPRESSION ...] - The 'let' builtin allows arithmetic to be performed on shell - variables. Each EXPRESSION is evaluated according to the rules - given below in *note Shell Arithmetic::. If the last EXPRESSION - evaluates to 0, 'let' returns 1; otherwise 0 is returned. + The ‘let’ builtin allows arithmetic to be performed on shell + variables. Each EXPRESSION is evaluated as an arithmetic + expression according to the rules given below in *note Shell + Arithmetic::. If the last EXPRESSION evaluates to 0, ‘let’ returns + 1; otherwise ‘let’ returns 0. -'local' +‘local’ local [OPTION] NAME[=VALUE] ... - For each argument, a local variable named NAME is created, and - assigned VALUE. The OPTION can be any of the options accepted by - 'declare'. 'local' can only be used within a function; it makes + For each argument, create a local variable named NAME, and assign + it VALUE. The OPTION can be any of the options accepted by + ‘declare’. ‘local’ can only be used within a function; it makes the variable NAME have a visible scope restricted to that function - and its children. If NAME is '-', the set of shell options is made - local to the function in which 'local' is invoked: shell options - changed using the 'set' builtin inside the function are restored to - their original values when the function returns. The restore is - effected as if a series of 'set' commands were executed to restore - the values that were in place before the function. The return - status is zero unless 'local' is used outside a function, an - invalid NAME is supplied, or NAME is a readonly variable. - -'logout' + and its children. It is an error to use ‘local’ when not within a + function. + + If NAME is ‘-’, it makes the set of shell options local to the + function in which ‘local’ is invoked: any shell options changed + using the ‘set’ builtin inside the function after the call to + ‘local’ are restored to their original values when the function + returns. The restore is performed as if a series of ‘set’ commands + were executed to restore the values that were in place before the + function. + + With no operands, ‘local’ writes a list of local variables to the + standard output. + + The return status is zero unless ‘local’ is used outside a + function, an invalid NAME is supplied, or NAME is a readonly + variable. + +‘logout’ logout [N] Exit a login shell, returning a status of N to the shell's parent. -'mapfile' +‘mapfile’ mapfile [-d DELIM] [-n COUNT] [-O ORIGIN] [-s COUNT] [-t] [-u FD] [-C CALLBACK] [-c QUANTUM] [ARRAY] - Read lines from the standard input into the indexed array variable - ARRAY, or from file descriptor FD if the '-u' option is supplied. - The variable 'MAPFILE' is the default ARRAY. Options, if supplied, + Read lines from the standard input, or from file descriptor FD if + the ‘-u’ option is supplied, into the indexed array variable ARRAY. + The variable ‘MAPFILE’ is the default ARRAY. Options, if supplied, have the following meanings: - '-d' - The first character of DELIM is used to terminate each input - line, rather than newline. If DELIM is the empty string, - 'mapfile' will terminate a line when it reads a NUL character. - '-n' - Copy at most COUNT lines. If COUNT is 0, all lines are - copied. - '-O' + ‘-d’ + Use the first character of DELIM to terminate each input line, + rather than newline. If DELIM is the empty string, ‘mapfile’ + will terminate a line when it reads a NUL character. + ‘-n’ + Copy at most COUNT lines. If COUNT is 0, copy all lines. + ‘-O’ Begin assigning to ARRAY at index ORIGIN. The default index is 0. - '-s' + ‘-s’ Discard the first COUNT lines read. - '-t' + ‘-t’ Remove a trailing DELIM (default newline) from each line read. - '-u' + ‘-u’ Read lines from file descriptor FD instead of the standard input. - '-C' - Evaluate CALLBACK each time QUANTUM lines are read. The '-c' + ‘-C’ + Evaluate CALLBACK each time QUANTUM lines are read. The ‘-c’ option specifies QUANTUM. - '-c' + ‘-c’ Specify the number of lines read between each call to CALLBACK. - If '-C' is specified without '-c', the default quantum is 5000. + If ‘-C’ is specified without ‘-c’, the default quantum is 5000. When CALLBACK is evaluated, it is supplied the index of the next array element to be assigned and the line to be assigned to that element as additional arguments. CALLBACK is evaluated after the line is read but before the array element is assigned. - If not supplied with an explicit origin, 'mapfile' will clear ARRAY + If not supplied with an explicit origin, ‘mapfile’ will clear ARRAY before assigning to it. - 'mapfile' returns successfully unless an invalid option or option - argument is supplied, ARRAY is invalid or unassignable, or ARRAY is - not an indexed array. + ‘mapfile’ returns zero unless an invalid option or option argument + is supplied, ARRAY is invalid or unassignable, or if ARRAY is not + an indexed array. -'printf' +‘printf’ printf [-v VAR] FORMAT [ARGUMENTS] Write the formatted ARGUMENTS to the standard output under the - control of the FORMAT. The '-v' option causes the output to be - assigned to the variable VAR rather than being printed to the - standard output. + control of the FORMAT. The ‘-v’ option assigns the output to the + variable VAR rather than printing it to the standard output. The FORMAT is a character string which contains three types of objects: plain characters, which are simply copied to standard output, character escape sequences, which are converted and copied to the standard output, and format specifications, each of which causes printing of the next successive ARGUMENT. In addition to - the standard 'printf(1)' formats, 'printf' interprets the following - extensions: + the standard ‘printf(3)’ format characters ‘cCsSndiouxXeEfFgGaA’, + ‘printf’ interprets the following additional format specifiers: - '%b' - Causes 'printf' to expand backslash escape sequences in the - corresponding ARGUMENT in the same way as 'echo -e' (*note + ‘%b’ + Causes ‘printf’ to expand backslash escape sequences in the + corresponding ARGUMENT in the same way as ‘echo -e’ (*note Bash Builtins::). - '%q' - Causes 'printf' to output the corresponding ARGUMENT in a - format that can be reused as shell input. - '%Q' - like '%q', but applies any supplied precision to the ARGUMENT + ‘%q’ + Causes ‘printf’ to output the corresponding ARGUMENT in a + format that can be reused as shell input. ‘%q’ and ‘%Q’P use + the ANSI-C quoting style (*note ANSI-C Quoting::) if any + characters in the argument string require it, and backslash + quoting otherwise. If the format string uses the ‘printf’ + _alternate form_, these two formats quote the argument string + using single quotes. + + ‘%Q’ + like ‘%q’, but applies any supplied precision to the ARGUMENT before quoting it. - '%(DATEFMT)T' - Causes 'printf' to output the date-time string resulting from - using DATEFMT as a format string for 'strftime'(3). The - corresponding ARGUMENT is an integer representing the number - of seconds since the epoch. Two special argument values may - be used: -1 represents the current time, and -2 represents the - time the shell was invoked. If no argument is specified, - conversion behaves as if -1 had been given. This is an - exception to the usual 'printf' behavior. - The %b, %q, and %T directives all use the field width and precision - arguments from the format specification and write that many bytes - from (or use that wide a field for) the expanded argument, which - usually contains more characters than the original. + ‘%(DATEFMT)T’ + Causes ‘printf’ to output the date-time string resulting from + using DATEFMT as a format string for ‘strftime’(3). The + corresponding ARGUMENT is an integer representing the number + of seconds since the epoch. This format specifier recognizes + Two special argument values: -1 represents the current time, + and -2 represents the time the shell was invoked. If no + argument is specified, conversion behaves as if -1 had been + supplied. This is an exception to the usual ‘printf’ + behavior. + + The %b, %q, and %T format specifiers all use the field width and + precision arguments from the format specification and write that + many bytes from (or use that wide a field for) the expanded + argument, which usually contains more characters than the original. + + The %n format specifier accepts a corresponding argument that is + treated as a shell variable name. + + The %s and %c format specifiers accept an l (long) modifier, which + forces them to convert the argument string to a wide-character + string and apply any supplied field width and precision in terms of + characters, not bytes. The %S and %C format specifiers are + equivalent to %ls and %lc, respectively. Arguments to non-string format specifiers are treated as C language constants, except that a leading plus or minus sign is allowed, and if the leading character is a single or double quote, the value is - the ASCII value of the following character. + the numeric value of the following character, using the current + locale. The FORMAT is reused as necessary to consume all of the ARGUMENTS. If the FORMAT requires more ARGUMENTS than are supplied, the extra format specifications behave as if a zero value or null string, as appropriate, had been supplied. The return value is zero on - success, non-zero on failure. + success, non-zero if an invalid option is supplied or a write or + assignment error occurs. -'read' - read [-ers] [-a ANAME] [-d DELIM] [-i TEXT] [-n NCHARS] +‘read’ + read [-Eers] [-a ANAME] [-d DELIM] [-i TEXT] [-n NCHARS] [-N NCHARS] [-p PROMPT] [-t TIMEOUT] [-u FD] [NAME ...] - One line is read from the standard input, or from the file - descriptor FD supplied as an argument to the '-u' option, split - into words as described above in *note Word Splitting::, and the - first word is assigned to the first NAME, the second word to the - second NAME, and so on. If there are more words than names, the - remaining words and their intervening delimiters are assigned to - the last NAME. If there are fewer words read from the input stream - than names, the remaining names are assigned empty values. The - characters in the value of the 'IFS' variable are used to split the - line into words using the same rules the shell uses for expansion - (described above in *note Word Splitting::). The backslash - character '\' may be used to remove any special meaning for the - next character read and for line continuation. + Read one line from the standard input, or from the file descriptor + FD supplied as an argument to the ‘-u’ option, split it into words + as described above in *note Word Splitting::, and assign the first + word to the first NAME, the second word to the second NAME, and so + on. If there are more words than names, the remaining words and + their intervening delimiters are assigned to the last NAME. If + there are fewer words read from the input stream than names, the + remaining names are assigned empty values. The characters in the + value of the ‘IFS’ variable are used to split the line into words + using the same rules the shell uses for expansion (described above + in *note Word Splitting::). The backslash character ‘\’ removes + any special meaning for the next character read and is used for + line continuation. Options, if supplied, have the following meanings: - '-a ANAME' + ‘-a ANAME’ The words are assigned to sequential indices of the array variable ANAME, starting at 0. All elements are removed from ANAME before the assignment. Other NAME arguments are ignored. - '-d DELIM' - The first character of DELIM is used to terminate the input - line, rather than newline. If DELIM is the empty string, - 'read' will terminate a line when it reads a NUL character. - - '-e' - Readline (*note Command Line Editing::) is used to obtain the - line. Readline uses the current (or default, if line editing - was not previously active) editing settings, but uses - Readline's default filename completion. - - '-i TEXT' - If Readline is being used to read the line, TEXT is placed + ‘-d DELIM’ + The first character of DELIM terminates the input line, rather + than newline. If DELIM is the empty string, ‘read’ will + terminate a line when it reads a NUL character. + + ‘-e’ + If the standard input is coming from a terminal, ‘read’ uses + Readline (*note Command Line Editing::) to obtain the line. + Readline uses the current (or default, if line editing was not + previously active) editing settings, but uses Readline's + default filename completion. + + ‘-E’ + If the standard input is coming from a terminal, ‘read’ uses + Readline (*note Command Line Editing::) to obtain the line. + Readline uses the current (or default, if line editing was not + previously active) editing settings, but uses Bash's default + completion, including programmable completion. + + ‘-i TEXT’ + If Readline is being used to read the line, ‘read’ places TEXT into the editing buffer before editing begins. - '-n NCHARS' - 'read' returns after reading NCHARS characters rather than - waiting for a complete line of input, but honors a delimiter - if fewer than NCHARS characters are read before the delimiter. - - '-N NCHARS' - 'read' returns after reading exactly NCHARS characters rather - than waiting for a complete line of input, unless EOF is - encountered or 'read' times out. Delimiter characters - encountered in the input are not treated specially and do not - cause 'read' to return until NCHARS characters are read. The - result is not split on the characters in 'IFS'; the intent is - that the variable is assigned exactly the characters read - (with the exception of backslash; see the '-r' option below). - - '-p PROMPT' + ‘-n NCHARS’ + ‘read’ returns after reading NCHARS characters rather than + waiting for a complete line of input, unless it encounters EOF + or ‘read’ times out, but honors a delimiter if it reads fewer + than NCHARS characters before the delimiter. + + ‘-N NCHARS’ + ‘read’ returns after reading exactly NCHARS characters rather + than waiting for a complete line of input, unless it + encounters EOF or ‘read’ times out. Delimiter characters in + the input are not treated specially and do not cause ‘read’ to + return until it has read NCHARS characters. The result is not + split on the characters in ‘IFS’; the intent is that the + variable is assigned exactly the characters read (with the + exception of backslash; see the ‘-r’ option below). + + ‘-p PROMPT’ Display PROMPT, without a trailing newline, before attempting - to read any input. The prompt is displayed only if input is - coming from a terminal. + to read any input, but only if input is coming from a + terminal. - '-r' + ‘-r’ If this option is given, backslash does not act as an escape character. The backslash is considered to be part of the line. In particular, a backslash-newline pair may not then be used as a line continuation. - '-s' + ‘-s’ Silent mode. If input is coming from a terminal, characters are not echoed. - '-t TIMEOUT' - Cause 'read' to time out and return failure if a complete line - of input (or a specified number of characters) is not read - within TIMEOUT seconds. TIMEOUT may be a decimal number with - a fractional portion following the decimal point. This option - is only effective if 'read' is reading input from a terminal, - pipe, or other special file; it has no effect when reading - from regular files. If 'read' times out, 'read' saves any - partial input read into the specified variable NAME. If - TIMEOUT is 0, 'read' returns immediately, without trying to - read any data. The exit status is 0 if input is available on - the specified file descriptor, or the read will return EOF, - non-zero otherwise. The exit status is greater than 128 if - the timeout is exceeded. - - '-u FD' - Read input from file descriptor FD. - - If no NAMEs are supplied, the line read, without the ending - delimiter but otherwise unmodified, is assigned to the variable - 'REPLY'. The exit status is zero, unless end-of-file is - encountered, 'read' times out (in which case the status is greater - than 128), a variable assignment error (such as assigning to a - readonly variable) occurs, or an invalid file descriptor is - supplied as the argument to '-u'. - -'readarray' + ‘-t TIMEOUT’ + Cause ‘read’ to time out and return failure if it does not + read a complete line of input (or a specified number of + characters) within TIMEOUT seconds. TIMEOUT may be a decimal + number with a fractional portion following the decimal point. + This option is only effective if ‘read’ is reading input from + a terminal, pipe, or other special file; it has no effect when + reading from regular files. If ‘read’ times out, it saves any + partial input read into the specified variable NAME, and + returns a status greater than 128. If TIMEOUT is 0, ‘read’ + returns immediately, without trying to read any data. In this + case, the exit status is 0 if input is available on the + specified file descriptor, or the read will return EOF, + non-zero otherwise. + + ‘-u FD’ + Read input from file descriptor FD instead of the standard + input. + + Other than the case where DELIM is the empty string, ‘read’ ignores + any NUL characters in the input. + + If no NAMEs are supplied, ‘read’ assigns the line read, without the + ending delimiter but otherwise unmodified, to the variable ‘REPLY’. + + The exit status is zero, unless end-of-file is encountered, ‘read’ + times out (in which case the status is greater than 128), a + variable assignment error (such as assigning to a readonly + variable) occurs, or an invalid file descriptor is supplied as the + argument to ‘-u’. + +‘readarray’ readarray [-d DELIM] [-n COUNT] [-O ORIGIN] [-s COUNT] [-t] [-u FD] [-C CALLBACK] [-c QUANTUM] [ARRAY] Read lines from the standard input into the indexed array variable - ARRAY, or from file descriptor FD if the '-u' option is supplied. + ARRAY, or from file descriptor FD if the ‘-u’ option is supplied. - A synonym for 'mapfile'. + A synonym for ‘mapfile’. -'source' - source FILENAME +‘source’ + source [-p PATH] FILENAME [ARGUMENTS] - A synonym for '.' (*note Bourne Shell Builtins::). + A synonym for ‘.’ (*note Bourne Shell Builtins::). -'type' +‘type’ type [-afptP] [NAME ...] - For each NAME, indicate how it would be interpreted if used as a - command name. + Indicate how each NAME would be interpreted if used as a command + name. - If the '-t' option is used, 'type' prints a single word which is - one of 'alias', 'function', 'builtin', 'file' or 'keyword', if NAME - is an alias, shell function, shell builtin, disk file, or shell - reserved word, respectively. If the NAME is not found, then - nothing is printed, and 'type' returns a failure status. + If the ‘-t’ option is used, ‘type’ prints a single word which is + one of ‘alias’, ‘keyword’, ‘function’, ‘builtin’, or ‘file’, if + NAME is an alias, shell reserved word, shell function, shell + builtin, or executable file, respectively. If the NAME is not + found, ‘type’ prints nothing and returns a failure status. - If the '-p' option is used, 'type' either returns the name of the - disk file that would be executed, or nothing if '-t' would not - return 'file'. + If the ‘-p’ option is used, ‘type’ either returns the name of the + executable file that would be found by searching ‘$PATH’ for + ‘name’, or nothing if ‘-t’ would not return ‘file’. - The '-P' option forces a path search for each NAME, even if '-t' - would not return 'file'. + The ‘-P’ option forces a path search for each NAME, even if ‘-t’ + would not return ‘file’. - If a command is hashed, '-p' and '-P' print the hashed value, which - is not necessarily the file that appears first in '$PATH'. + If a NAME is present in the table of hashed commands, options ‘-p’ + and ‘-P’ print the hashed value, which is not necessarily the file + that appears first in ‘$PATH’. - If the '-a' option is used, 'type' returns all of the places that - contain an executable named FILE. This includes aliases and - functions, if and only if the '-p' option is not also used. + If the ‘-a’ option is used, ‘type’ returns all of the places that + contain a command named NAME. This includes aliases, reserved + words, functions, and builtins, but the path search options (‘-p’ + and ‘-P’) can be supplied to restrict the output to executable + files. If ‘-a’ is supplied with ‘-p’, ‘type’ does not look in the + table of hashed commands, and only performs a ‘PATH’ search for + NAME. - If the '-f' option is used, 'type' does not attempt to find shell - functions, as with the 'command' builtin. + If the ‘-f’ option is used, ‘type’ does not attempt to find shell + functions, as with the ‘command’ builtin. The return status is zero if all of the NAMEs are found, non-zero if any are not found. -'typeset' +‘typeset’ typeset [-afFgrxilnrtux] [-p] [NAME[=VALUE] ...] - The 'typeset' command is supplied for compatibility with the Korn - shell. It is a synonym for the 'declare' builtin command. + The ‘typeset’ command is supplied for compatibility with the Korn + shell. It is a synonym for the ‘declare’ builtin command. -'ulimit' +‘ulimit’ ulimit [-HS] -a ulimit [-HS] [-bcdefiklmnpqrstuvxPRT] [LIMIT] - 'ulimit' provides control over the resources available to processes - started by the shell, on systems that allow such control. If an - option is given, it is interpreted as follows: + ‘ulimit’ provides control over the resources available to the shell + and to processes it starts, on systems that allow such control. If + an option is given, it is interpreted as follows: - '-S' + ‘-S’ Change and report the soft limit associated with a resource. - '-H' + ‘-H’ Change and report the hard limit associated with a resource. - '-a' - All current limits are reported; no limits are set. + ‘-a’ + Report all current limits; no limits are set. - '-b' + ‘-b’ The maximum socket buffer size. - '-c' + ‘-c’ The maximum size of core files created. - '-d' + ‘-d’ The maximum size of a process's data segment. - '-e' + ‘-e’ The maximum scheduling priority ("nice"). - '-f' + ‘-f’ The maximum size of files written by the shell and its children. - '-i' + ‘-i’ The maximum number of pending signals. - '-k' + ‘-k’ The maximum number of kqueues that may be allocated. - '-l' + ‘-l’ The maximum size that may be locked into memory. - '-m' + ‘-m’ The maximum resident set size (many systems do not honor this limit). - '-n' + ‘-n’ The maximum number of open file descriptors (most systems do not allow this value to be set). - '-p' + ‘-p’ The pipe buffer size. - '-q' + ‘-q’ The maximum number of bytes in POSIX message queues. - '-r' + ‘-r’ The maximum real-time scheduling priority. - '-s' + ‘-s’ The maximum stack size. - '-t' + ‘-t’ The maximum amount of cpu time in seconds. - '-u' + ‘-u’ The maximum number of processes available to a single user. - '-v' + ‘-v’ The maximum amount of virtual memory available to the shell, and, on some systems, to its children. - '-x' + ‘-x’ The maximum number of file locks. - '-P' + ‘-P’ The maximum number of pseudoterminals. - '-R' + ‘-R’ The maximum time a real-time process can run before blocking, in microseconds. - '-T' + ‘-T’ The maximum number of threads. - If LIMIT is given, and the '-a' option is not used, LIMIT is the + If LIMIT is supplied, and the ‘-a’ option is not used, LIMIT is the new value of the specified resource. The special LIMIT values - 'hard', 'soft', and 'unlimited' stand for the current hard limit, + ‘hard’, ‘soft’, and ‘unlimited’ stand for the current hard limit, the current soft limit, and no limit, respectively. A hard limit cannot be increased by a non-root user once it is set; a soft limit - may be increased up to the value of the hard limit. Otherwise, the - current value of the soft limit for the specified resource is - printed, unless the '-H' option is supplied. When more than one - resource is specified, the limit name and unit, if appropriate, are - printed before the value. When setting new limits, if neither '-H' - nor '-S' is supplied, both the hard and soft limits are set. If no - option is given, then '-f' is assumed. Values are in 1024-byte - increments, except for '-t', which is in seconds; '-R', which is in - microseconds; '-p', which is in units of 512-byte blocks; '-P', - '-T', '-b', '-k', '-n' and '-u', which are unscaled values; and, - when in POSIX Mode (*note Bash POSIX Mode::), '-c' and '-f', which - are in 512-byte increments. + may be increased up to the value of the hard limit. Otherwise, + ‘ulimit’ prints the current value of the soft limit for the + specified resource, unless the ‘-H’ option is supplied. When more + than one resource is specified, the limit name and unit, if + appropriate, are printed before the value. When setting new + limits, if neither ‘-H’ nor ‘-S’ is supplied, ‘ulimit’ sets both + the hard and soft limits. If no option is supplied, then ‘-f’ is + assumed. + + Values are in 1024-byte increments, except for ‘-t’, which is in + seconds; ‘-R’, which is in microseconds; ‘-p’, which is in units of + 512-byte blocks; ‘-P’, ‘-T’, ‘-b’, ‘-k’, ‘-n’ and ‘-u’, which are + unscaled values; and, when in POSIX mode (*note Bash POSIX Mode::), + ‘-c’ and ‘-f’, which are in 512-byte increments. The return status is zero unless an invalid option or argument is supplied, or an error occurs while setting a new limit. -'unalias' +‘unalias’ unalias [-a] [NAME ... ] - Remove each NAME from the list of aliases. If '-a' is supplied, - all aliases are removed. Aliases are described in *note Aliases::. + Remove each NAME from the list of aliases. If ‘-a’ is supplied, + remove all aliases. The return value is true unless a supplied + NAME is not a defined alias. Aliases are described in *note + Aliases::.  File: bash.info, Node: Modifying Shell Behavior, Next: Special Builtins, Prev: Bash Builtins, Up: Shell Builtin Commands @@ -4413,48 +4850,55 @@ File: bash.info, Node: The Set Builtin, Next: The Shopt Builtin, Up: Modifyin 4.3.1 The Set Builtin --------------------- -This builtin is so complicated that it deserves its own section. 'set' +This builtin is so complicated that it deserves its own section. ‘set’ allows you to change the values of shell options and set the positional parameters, or to display the names and values of shell variables. -'set' +‘set’ set [-abefhkmnptuvxBCEHPT] [-o OPTION-NAME] [--] [-] [ARGUMENT ...] set [+abefhkmnptuvxBCEHPT] [+o OPTION-NAME] [--] [-] [ARGUMENT ...] + set -o + set +o - If no options or arguments are supplied, 'set' displays the names + If no options or arguments are supplied, ‘set’ displays the names and values of all shell variables and functions, sorted according to the current locale, in a format that may be reused as input for setting or resetting the currently-set variables. Read-only variables cannot be reset. In POSIX mode, only shell variables are listed. - When options are supplied, they set or unset shell attributes. + When options are supplied, they set or unset shell attributes. Any + arguments remaining after option processing replace the positional + parameters. + Options, if specified, have the following meanings: - '-a' + ‘-a’ Each variable or function that is created or modified is given the export attribute and marked for export to the environment of subsequent commands. - '-b' + ‘-b’ Cause the status of terminated background jobs to be reported immediately, rather than before printing the next primary - prompt. + prompt or, under some circumstances, when a foreground command + exits. This is effective only when job control is enabled. - '-e' + ‘-e’ Exit immediately if a pipeline (*note Pipelines::), which may consist of a single simple command (*note Simple Commands::), a list (*note Lists::), or a compound command (*note Compound Commands::) returns a non-zero status. The shell does not exit if the command that fails is part of the command list - immediately following a 'while' or 'until' keyword, part of - the test in an 'if' statement, part of any command executed in - a '&&' or '||' list except the command following the final - '&&' or '||', any command in a pipeline but the last, or if - the command's return status is being inverted with '!'. If a + immediately following a ‘while’ or ‘until’ reserved word, part + of the test in an ‘if’ statement, part of any command executed + in a ‘&&’ or ‘||’ list except the command following the final + ‘&&’ or ‘||’, any command in a pipeline but the last (subject + to the state of the ‘pipefail’ shell option), or if the + command's return status is being inverted with ‘!’. If a compound command other than a subshell returns a non-zero - status because a command failed while '-e' was being ignored, - the shell does not exit. A trap on 'ERR', if set, is executed + status because a command failed while ‘-e’ was being ignored, + the shell does not exit. A trap on ‘ERR’, if set, is executed before the shell exits. This option applies to the shell environment and each subshell @@ -4463,232 +4907,239 @@ parameters, or to display the names and values of shell variables. executing all the commands in the subshell. If a compound command or shell function executes in a context - where '-e' is being ignored, none of the commands executed + where ‘-e’ is being ignored, none of the commands executed within the compound command or function body will be affected - by the '-e' setting, even if '-e' is set and a command returns + by the ‘-e’ setting, even if ‘-e’ is set and a command returns a failure status. If a compound command or shell function - sets '-e' while executing in a context where '-e' is ignored, + sets ‘-e’ while executing in a context where ‘-e’ is ignored, that setting will not have any effect until the compound command or the command containing the function call completes. - '-f' + ‘-f’ Disable filename expansion (globbing). - '-h' + ‘-h’ Locate and remember (hash) commands as they are looked up for execution. This option is enabled by default. - '-k' + ‘-k’ All arguments in the form of assignment statements are placed in the environment for a command, not just those that precede the command name. - '-m' + ‘-m’ Job control is enabled (*note Job Control::). All processes run in a separate process group. When a background job completes, the shell prints a line containing its exit status. - '-n' + ‘-n’ Read commands but do not execute them. This may be used to check a script for syntax errors. This option is ignored by interactive shells. - '-o OPTION-NAME' + ‘-o OPTION-NAME’ - Set the option corresponding to OPTION-NAME: + Set the option corresponding to OPTION-NAME. If ‘-o’ is + supplied with no OPTION-NAME, ‘set’ prints the current shell + options settings. If ‘+o’ is supplied with no OPTION-NAME, + ‘set’ prints a series of ‘set’ commands to recreate the + current option settings on the standard output. Valid option + names are: - 'allexport' - Same as '-a'. + ‘allexport’ + Same as ‘-a’. - 'braceexpand' - Same as '-B'. + ‘braceexpand’ + Same as ‘-B’. - 'emacs' - Use an 'emacs'-style line editing interface (*note + ‘emacs’ + Use an ‘emacs’-style line editing interface (*note Command Line Editing::). This also affects the editing - interface used for 'read -e'. + interface used for ‘read -e’. - 'errexit' - Same as '-e'. + ‘errexit’ + Same as ‘-e’. - 'errtrace' - Same as '-E'. + ‘errtrace’ + Same as ‘-E’. - 'functrace' - Same as '-T'. + ‘functrace’ + Same as ‘-T’. - 'hashall' - Same as '-h'. + ‘hashall’ + Same as ‘-h’. - 'histexpand' - Same as '-H'. + ‘histexpand’ + Same as ‘-H’. - 'history' + ‘history’ Enable command history, as described in *note Bash History Facilities::. This option is on by default in interactive shells. - 'ignoreeof' + ‘ignoreeof’ An interactive shell will not exit upon reading EOF. - 'keyword' - Same as '-k'. + ‘keyword’ + Same as ‘-k’. - 'monitor' - Same as '-m'. + ‘monitor’ + Same as ‘-m’. - 'noclobber' - Same as '-C'. + ‘noclobber’ + Same as ‘-C’. - 'noexec' - Same as '-n'. + ‘noexec’ + Same as ‘-n’. - 'noglob' - Same as '-f'. + ‘noglob’ + Same as ‘-f’. - 'nolog' + ‘nolog’ Currently ignored. - 'notify' - Same as '-b'. + ‘notify’ + Same as ‘-b’. - 'nounset' - Same as '-u'. + ‘nounset’ + Same as ‘-u’. - 'onecmd' - Same as '-t'. + ‘onecmd’ + Same as ‘-t’. - 'physical' - Same as '-P'. + ‘physical’ + Same as ‘-P’. - 'pipefail' + ‘pipefail’ If set, the return value of a pipeline is the value of the last (rightmost) command to exit with a non-zero status, or zero if all commands in the pipeline exit successfully. This option is disabled by default. - 'posix' - Change the behavior of Bash where the default operation - differs from the POSIX standard to match the standard - (*note Bash POSIX Mode::). This is intended to make Bash - behave as a strict superset of that standard. + ‘posix’ + Enable POSIX mode; change the behavior of Bash where the + default operation differs from the POSIX standard to + match the standard (*note Bash POSIX Mode::). This is + intended to make Bash behave as a strict superset of that + standard. - 'privileged' - Same as '-p'. + ‘privileged’ + Same as ‘-p’. - 'verbose' - Same as '-v'. + ‘verbose’ + Same as ‘-v’. - 'vi' - Use a 'vi'-style line editing interface. This also - affects the editing interface used for 'read -e'. + ‘vi’ + Use a ‘vi’-style line editing interface. This also + affects the editing interface used for ‘read -e’. - 'xtrace' - Same as '-x'. + ‘xtrace’ + Same as ‘-x’. - '-p' - Turn on privileged mode. In this mode, the '$BASH_ENV' and - '$ENV' files are not processed, shell functions are not - inherited from the environment, and the 'SHELLOPTS', - 'BASHOPTS', 'CDPATH' and 'GLOBIGNORE' variables, if they + ‘-p’ + Turn on privileged mode. In this mode, the ‘$BASH_ENV’ and + ‘$ENV’ files are not processed, shell functions are not + inherited from the environment, and the ‘SHELLOPTS’, + ‘BASHOPTS’, ‘CDPATH’ and ‘GLOBIGNORE’ variables, if they appear in the environment, are ignored. If the shell is started with the effective user (group) id not equal to the - real user (group) id, and the '-p' option is not supplied, + real user (group) id, and the ‘-p’ option is not supplied, these actions are taken and the effective user id is set to - the real user id. If the '-p' option is supplied at startup, + the real user id. If the ‘-p’ option is supplied at startup, the effective user id is not reset. Turning this option off causes the effective user and group ids to be set to the real user and group ids. - '-r' - Enable restricted shell mode. This option cannot be unset - once it has been set. + ‘-r’ + Enable restricted shell mode (*note The Restricted Shell::). + This option cannot be unset once it has been set. - '-t' + ‘-t’ Exit after reading and executing one command. - '-u' + ‘-u’ Treat unset variables and parameters other than the special - parameters '@' or '*', or array variables subscripted with '@' - or '*', as an error when performing parameter expansion. An + parameters ‘@’ or ‘*’, or array variables subscripted with ‘@’ + or ‘*’, as an error when performing parameter expansion. An error message will be written to the standard error, and a non-interactive shell will exit. - '-v' - Print shell input lines as they are read. + ‘-v’ + Print shell input lines to standard error as they are read. - '-x' - Print a trace of simple commands, 'for' commands, 'case' - commands, 'select' commands, and arithmetic 'for' commands and - their arguments or associated word lists after they are - expanded and before they are executed. The value of the 'PS4' - variable is expanded and the resultant value is printed before + ‘-x’ + Print a trace of simple commands, ‘for’ commands, ‘case’ + commands, ‘select’ commands, and arithmetic ‘for’ commands and + their arguments or associated word lists to the standard error + after they are expanded and before they are executed. The + shell prints the expanded value of the ‘PS4’ variable before the command and its expanded arguments. - '-B' + ‘-B’ The shell will perform brace expansion (*note Brace Expansion::). This option is on by default. - '-C' - Prevent output redirection using '>', '>&', and '<>' from - overwriting existing files. + ‘-C’ + Prevent output redirection using ‘>’, ‘>&’, and ‘<>’ from + overwriting existing files. Using the redirection operator + ‘>|’ instead of ‘>’ will override this and force the creation + of an output file. - '-E' - If set, any trap on 'ERR' is inherited by shell functions, + ‘-E’ + If set, any trap on ‘ERR’ is inherited by shell functions, command substitutions, and commands executed in a subshell - environment. The 'ERR' trap is normally not inherited in such + environment. The ‘ERR’ trap is normally not inherited in such cases. - '-H' - Enable '!' style history substitution (*note History + ‘-H’ + Enable ‘!’ style history substitution (*note History Interaction::). This option is on by default for interactive shells. - '-P' - If set, do not resolve symbolic links when performing commands - such as 'cd' which change the current directory. The physical - directory is used instead. By default, Bash follows the - logical chain of directories when performing commands which - change the current directory. + ‘-P’ + If set, Bash does not resolve symbolic links when executing + commands such as ‘cd’ which change the current directory. It + uses the physical directory structure instead. By default, + Bash follows the logical chain of directories when performing + commands which change the current directory. - For example, if '/usr/sys' is a symbolic link to - '/usr/local/sys' then: + For example, if ‘/usr/sys’ is a symbolic link to + ‘/usr/local/sys’ then: $ cd /usr/sys; echo $PWD /usr/sys $ cd ..; pwd /usr - If 'set -P' is on, then: + If ‘set -P’ is on, then: $ cd /usr/sys; echo $PWD /usr/local/sys $ cd ..; pwd /usr/local - '-T' - If set, any trap on 'DEBUG' and 'RETURN' are inherited by + ‘-T’ + If set, any traps on ‘DEBUG’ and ‘RETURN’ are inherited by shell functions, command substitutions, and commands executed - in a subshell environment. The 'DEBUG' and 'RETURN' traps are + in a subshell environment. The ‘DEBUG’ and ‘RETURN’ traps are normally not inherited in such cases. - '--' - If no arguments follow this option, then the positional - parameters are unset. Otherwise, the positional parameters - are set to the ARGUMENTS, even if some of them begin with a - '-'. + ‘--’ + If no arguments follow this option, unset the positional + parameters. Otherwise, the positional parameters are set to + the ARGUMENTS, even if some of them begin with a ‘-’. - '-' - Signal the end of options, cause all remaining ARGUMENTS to be - assigned to the positional parameters. The '-x' and '-v' - options are turned off. If there are no arguments, the - positional parameters remain unchanged. + ‘-’ + Signal the end of options, and assign all remaining ARGUMENTS + to the positional parameters. The ‘-x’ and ‘-v’ options are + turned off. If there are no arguments, the positional + parameters remain unchanged. - Using '+' rather than '-' causes these options to be turned off. + Using ‘+’ rather than ‘-’ causes these options to be turned off. The options can also be used upon invocation of the shell. The - current set of options may be found in '$-'. + current set of options may be found in ‘$-’. The remaining N ARGUMENTS are positional parameters and are - assigned, in order, to '$1', '$2', ... '$N'. The special parameter - '#' is set to N. + assigned, in order, to ‘$1’, ‘$2’, ... ‘$N’. The special parameter + ‘#’ is set to N. The return status is always zero unless an invalid option is supplied. @@ -4699,41 +5150,44 @@ File: bash.info, Node: The Shopt Builtin, Prev: The Set Builtin, Up: Modifyin 4.3.2 The Shopt Builtin ----------------------- -This builtin allows you to change additional shell optional behavior. +This builtin allows you to change additional optional shell behavior. -'shopt' +‘shopt’ shopt [-pqsu] [-o] [OPTNAME ...] Toggle the values of settings controlling optional shell behavior. - The settings can be either those listed below, or, if the '-o' - option is used, those available with the '-o' option to the 'set' - builtin command (*note The Set Builtin::). With no options, or - with the '-p' option, a list of all settable options is displayed, - with an indication of whether or not each is set; if OPTNAMEs are - supplied, the output is restricted to those options. The '-p' - option causes output to be displayed in a form that may be reused - as input. Other options have the following meanings: - - '-s' + The settings can be either those listed below, or, if the ‘-o’ + option is used, those available with the ‘-o’ option to the ‘set’ + builtin command (*note The Set Builtin::). + + With no options, or with the ‘-p’ option, display a list of all + settable options, with an indication of whether or not each is set; + if any OPTNAMEs are supplied, the output is restricted to those + options. The ‘-p’ option displays output in a form that may be + reused as input. + + Other options have the following meanings: + + ‘-s’ Enable (set) each OPTNAME. - '-u' + ‘-u’ Disable (unset) each OPTNAME. - '-q' + ‘-q’ Suppresses normal output; the return status indicates whether the OPTNAME is set or unset. If multiple OPTNAME arguments - are given with '-q', the return status is zero if all OPTNAMEs - are enabled; non-zero otherwise. + are supplied with ‘-q’, the return status is zero if all + OPTNAMEs are enabled; non-zero otherwise. - '-o' + ‘-o’ Restricts the values of OPTNAME to be those defined for the - '-o' option to the 'set' builtin (*note The Set Builtin::). + ‘-o’ option to the ‘set’ builtin (*note The Set Builtin::). - If either '-s' or '-u' is used with no OPTNAME arguments, 'shopt' + If either ‘-s’ or ‘-u’ is used with no OPTNAME arguments, ‘shopt’ shows only those options which are set or unset, respectively. - Unless otherwise noted, the 'shopt' options are disabled (off) by + Unless otherwise noted, the ‘shopt’ options are disabled (off) by default. The return status when listing options is zero if all OPTNAMEs are @@ -4741,69 +5195,77 @@ This builtin allows you to change additional shell optional behavior. the return status is zero unless an OPTNAME is not a valid shell option. - The list of 'shopt' options is: + The list of ‘shopt’ options is: - 'assoc_expand_once' + ‘array_expand_once’ If set, the shell suppresses multiple evaluation of - associative array subscripts during arithmetic expression - evaluation, while executing builtins that can perform variable - assignments, and while executing builtins that perform array - dereferencing. + associative and indexed array subscripts during arithmetic + expression evaluation, while executing builtins that can + perform variable assignments, and while executing builtins + that perform array dereferencing. - 'autocd' + ‘assoc_expand_once’ + Deprecated; a synonym for ‘array_expand_once’. + + ‘autocd’ If set, a command name that is the name of a directory is - executed as if it were the argument to the 'cd' command. This + executed as if it were the argument to the ‘cd’ command. This option is only used by interactive shells. - 'cdable_vars' - If this is set, an argument to the 'cd' builtin command that + ‘bash_source_fullpath’ + If set, filenames added to the ‘BASH_SOURCE’ array variable + are converted to full pathnames (*note Bash Variables::). + + ‘cdable_vars’ + If this is set, an argument to the ‘cd’ builtin command that is not a directory is assumed to be the name of a variable whose value is the directory to change to. - 'cdspell' - If set, minor errors in the spelling of a directory component - in a 'cd' command will be corrected. The errors checked for - are transposed characters, a missing character, and a - character too many. If a correction is found, the corrected - path is printed, and the command proceeds. This option is + ‘cdspell’ + If set, the ‘cd’ command attempts to correct minor errors in + the spelling of a directory component. Minor errors include + transposed characters, a missing character, and one extra + character. If ‘cd’ corrects the directory name, it prints the + corrected filename, and the command proceeds. This option is only used by interactive shells. - 'checkhash' + ‘checkhash’ If this is set, Bash checks that a command found in the hash table exists before trying to execute it. If a hashed command - no longer exists, a normal path search is performed. + no longer exists, Bash performs a normal path search. - 'checkjobs' + ‘checkjobs’ If set, Bash lists the status of any stopped and running jobs before exiting an interactive shell. If any jobs are running, - this causes the exit to be deferred until a second exit is - attempted without an intervening command (*note Job - Control::). The shell always postpones exiting if any jobs - are stopped. + Bash defers the exit until a second exit is attempted without + an intervening command (*note Job Control::). The shell + always postpones exiting if any jobs are stopped. - 'checkwinsize' + ‘checkwinsize’ If set, Bash checks the window size after each external (non-builtin) command and, if necessary, updates the values of - 'LINES' and 'COLUMNS'. This option is enabled by default. + ‘LINES’ and ‘COLUMNS’, using the file descriptor associated + with stderr if it is a terminal. This option is enabled by + default. - 'cmdhist' + ‘cmdhist’ If set, Bash attempts to save all lines of a multiple-line command in the same history entry. This allows easy re-editing of multi-line commands. This option is enabled by default, but only has an effect if command history is enabled (*note Bash History Facilities::). - 'compat31' - 'compat32' - 'compat40' - 'compat41' - 'compat42' - 'compat43' - 'compat44' + ‘compat31’ + ‘compat32’ + ‘compat40’ + ‘compat41’ + ‘compat42’ + ‘compat43’ + ‘compat44’ These control aspects of the shell's compatibility mode (*note Shell Compatibility Mode::). - 'complete_fullquote' + ‘complete_fullquote’ If set, Bash quotes all shell metacharacters in filenames and directory names when performing completion. If not set, Bash removes metacharacters such as the dollar sign from the set of @@ -4812,257 +5274,261 @@ This builtin allows you to change additional shell optional behavior. words to be completed. This means that dollar signs in variable names that expand to directories will not be quoted; however, any dollar signs appearing in filenames will not be - quoted, either. This is active only when bash is using + quoted, either. This is active only when Bash is using backslashes to quote completed filenames. This variable is set by default, which is the default Bash behavior in versions through 4.2. - 'direxpand' + ‘direxpand’ If set, Bash replaces directory names with the results of word expansion when performing filename completion. This changes the contents of the Readline editing buffer. If not set, Bash attempts to preserve what the user typed. - 'dirspell' + ‘dirspell’ If set, Bash attempts spelling correction on directory names during word completion if the directory name initially supplied does not exist. - 'dotglob' - If set, Bash includes filenames beginning with a '.' in the - results of filename expansion. The filenames '.' and '..' - must always be matched explicitly, even if 'dotglob' is set. + ‘dotglob’ + If set, Bash includes filenames beginning with a ‘.’ in the + results of filename expansion. The filenames ‘.’ and ‘..’ + must always be matched explicitly, even if ‘dotglob’ is set. - 'execfail' + ‘execfail’ If this is set, a non-interactive shell will not exit if it - cannot execute the file specified as an argument to the 'exec' - builtin command. An interactive shell does not exit if 'exec' - fails. + cannot execute the file specified as an argument to the ‘exec’ + builtin. An interactive shell does not exit if ‘exec’ fails. - 'expand_aliases' + ‘expand_aliases’ If set, aliases are expanded as described below under Aliases, *note Aliases::. This option is enabled by default for interactive shells. - 'extdebug' + ‘extdebug’ If set at shell invocation, or in a shell startup file, arrange to execute the debugger profile before the shell - starts, identical to the '--debugger' option. If set after + starts, identical to the ‘--debugger’ option. If set after invocation, behavior intended for use by debuggers is enabled: - 1. The '-F' option to the 'declare' builtin (*note Bash + 1. The ‘-F’ option to the ‘declare’ builtin (*note Bash Builtins::) displays the source file name and line number corresponding to each function name supplied as an argument. - 2. If the command run by the 'DEBUG' trap returns a non-zero + 2. If the command run by the ‘DEBUG’ trap returns a non-zero value, the next command is skipped and not executed. - 3. If the command run by the 'DEBUG' trap returns a value of + 3. If the command run by the ‘DEBUG’ trap returns a value of 2, and the shell is executing in a subroutine (a shell - function or a shell script executed by the '.' or - 'source' builtins), the shell simulates a call to - 'return'. + function or a shell script executed by the ‘.’ or + ‘source’ builtins), the shell simulates a call to + ‘return’. - 4. 'BASH_ARGC' and 'BASH_ARGV' are updated as described in + 4. ‘BASH_ARGC’ and ‘BASH_ARGV’ are updated as described in their descriptions (*note Bash Variables::). 5. Function tracing is enabled: command substitution, shell - functions, and subshells invoked with '( COMMAND )' - inherit the 'DEBUG' and 'RETURN' traps. + functions, and subshells invoked with ‘( COMMAND )’ + inherit the ‘DEBUG’ and ‘RETURN’ traps. 6. Error tracing is enabled: command substitution, shell - functions, and subshells invoked with '( COMMAND )' - inherit the 'ERR' trap. + functions, and subshells invoked with ‘( COMMAND )’ + inherit the ‘ERR’ trap. - 'extglob' - If set, the extended pattern matching features described above - (*note Pattern Matching::) are enabled. + ‘extglob’ + If set, enable the extended pattern matching features + described above (*note Pattern Matching::). - 'extquote' - If set, '$'STRING'' and '$"STRING"' quoting is performed - within '${PARAMETER}' expansions enclosed in double quotes. + ‘extquote’ + If set, ‘$'STRING'’ and ‘$"STRING"’ quoting is performed + within ‘${PARAMETER}’ expansions enclosed in double quotes. This option is enabled by default. - 'failglob' + ‘failglob’ If set, patterns which fail to match filenames during filename expansion result in an expansion error. - 'force_fignore' - If set, the suffixes specified by the 'FIGNORE' shell variable + ‘force_fignore’ + If set, the suffixes specified by the ‘FIGNORE’ shell variable cause words to be ignored when performing word completion even if the ignored words are the only possible completions. *Note - Bash Variables::, for a description of 'FIGNORE'. This option + Bash Variables::, for a description of ‘FIGNORE’. This option is enabled by default. - 'globasciiranges' + ‘globasciiranges’ If set, range expressions used in pattern matching bracket expressions (*note Pattern Matching::) behave as if in the traditional C locale when performing comparisons. That is, - the current locale's collating sequence is not taken into - account, so 'b' will not collate between 'A' and 'B', and - upper-case and lower-case ASCII characters will collate - together. - - 'globskipdots' - If set, filename expansion will never match the filenames '.' - and '..', even if the pattern begins with a '.'. This option + pattern matching does not take the current locale's collating + sequence into account, so ‘b’ will not collate between ‘A’ and + ‘B’, and upper-case and lower-case ASCII characters will + collate together. + + ‘globskipdots’ + If set, filename expansion will never match the filenames ‘.’ + and ‘..’, even if the pattern begins with a ‘.’. This option is enabled by default. - 'globstar' - If set, the pattern '**' used in a filename expansion context + ‘globstar’ + If set, the pattern ‘**’ used in a filename expansion context will match all files and zero or more directories and - subdirectories. If the pattern is followed by a '/', only + subdirectories. If the pattern is followed by a ‘/’, only directories and subdirectories match. - 'gnu_errfmt' + ‘gnu_errfmt’ If set, shell error messages are written in the standard GNU error message format. - 'histappend' + ‘histappend’ If set, the history list is appended to the file named by the - value of the 'HISTFILE' variable when the shell exits, rather + value of the ‘HISTFILE’ variable when the shell exits, rather than overwriting the file. - 'histreedit' - If set, and Readline is being used, a user is given the + ‘histreedit’ + If set, and Readline is being used, the user is given the opportunity to re-edit a failed history substitution. - 'histverify' + ‘histverify’ If set, and Readline is being used, the results of history substitution are not immediately passed to the shell parser. Instead, the resulting line is loaded into the Readline editing buffer, allowing further modification. - 'hostcomplete' + ‘hostcomplete’ If set, and Readline is being used, Bash will attempt to - perform hostname completion when a word containing a '@' is + perform hostname completion when a word containing a ‘@’ is being completed (*note Commands For Completion::). This option is enabled by default. - 'huponexit' - If set, Bash will send 'SIGHUP' to all jobs when an + ‘huponexit’ + If set, Bash will send ‘SIGHUP’ to all jobs when an interactive login shell exits (*note Signals::). - 'inherit_errexit' + ‘inherit_errexit’ If set, command substitution inherits the value of the - 'errexit' option, instead of unsetting it in the subshell + ‘errexit’ option, instead of unsetting it in the subshell environment. This option is enabled when POSIX mode is enabled. - 'interactive_comments' - Allow a word beginning with '#' to cause that word and all - remaining characters on that line to be ignored in an - interactive shell. This option is enabled by default. + ‘interactive_comments’ + In an interactive shell, a word beginning with ‘#’ causes that + word and all remaining characters on that line to be ignored, + as in a non-interactive shell. This option is enabled by + default. - 'lastpipe' + ‘lastpipe’ If set, and job control is not active, the shell runs the last command of a pipeline not executed in the background in the current shell environment. - 'lithist' - If enabled, and the 'cmdhist' option is enabled, multi-line + ‘lithist’ + If enabled, and the ‘cmdhist’ option is enabled, multi-line commands are saved to the history with embedded newlines rather than using semicolon separators where possible. - 'localvar_inherit' + ‘localvar_inherit’ If set, local variables inherit the value and attributes of a variable of the same name that exists at a previous scope - before any new value is assigned. The 'nameref' attribute is + before any new value is assigned. The ‘nameref’ attribute is not inherited. - 'localvar_unset' - If set, calling 'unset' on local variables in previous + ‘localvar_unset’ + If set, calling ‘unset’ on local variables in previous function scopes marks them so subsequent lookups find them unset until that function returns. This is identical to the behavior of unsetting local variables at the current function scope. - 'login_shell' + ‘login_shell’ The shell sets this option if it is started as a login shell (*note Invoking Bash::). The value may not be changed. - 'mailwarn' + ‘mailwarn’ If set, and a file that Bash is checking for mail has been - accessed since the last time it was checked, the message '"The - mail in MAILFILE has been read"' is displayed. + accessed since the last time it was checked, Bash displays the + message ‘"The mail in MAILFILE has been read"’. - 'no_empty_cmd_completion' - If set, and Readline is being used, Bash will not attempt to - search the 'PATH' for possible completions when completion is - attempted on an empty line. + ‘no_empty_cmd_completion’ + If set, and Readline is being used, Bash does not search the + ‘PATH’ for possible completions when completion is attempted + on an empty line. - 'nocaseglob' + ‘nocaseglob’ If set, Bash matches filenames in a case-insensitive fashion when performing filename expansion. - 'nocasematch' + ‘nocasematch’ If set, Bash matches patterns in a case-insensitive fashion - when performing matching while executing 'case' or '[[' + when performing matching while executing ‘case’ or ‘[[’ conditional commands (*note Conditional Constructs::, when performing pattern substitution word expansions, or when filtering possible completions as part of programmable completion. - 'noexpand_translation' - If set, Bash encloses the translated results of $"..." - quoting in single quotes instead of double quotes. If the - string is not translated, this has no effect. + ‘noexpand_translation’ + If set, Bash encloses the translated results of $"..." quoting + in single quotes instead of double quotes. If the string is + not translated, this has no effect. - 'nullglob' - If set, Bash allows filename patterns which match no files to - expand to a null string, rather than themselves. + ‘nullglob’ + If set, filename expansion patterns which match no files + (*note Filename Expansion::) expand to nothing and are + removed, rather than expanding to themselves. - 'patsub_replacement' - If set, Bash expands occurrences of '&' in the replacement + ‘patsub_replacement’ + If set, Bash expands occurrences of ‘&’ in the replacement string of pattern substitution to the text matched by the pattern, as described above (*note Shell Parameter Expansion::). This option is enabled by default. - 'progcomp' - If set, the programmable completion facilities (*note - Programmable Completion::) are enabled. This option is - enabled by default. + ‘progcomp’ + If set, enable the programmable completion facilities (*note + Programmable Completion::). This option is enabled by + default. - 'progcomp_alias' + ‘progcomp_alias’ If set, and programmable completion is enabled, Bash treats a command name that doesn't have any completions as a possible alias and attempts alias expansion. If it has an alias, Bash attempts programmable completion using the command word resulting from the expanded alias. - 'promptvars' + ‘promptvars’ If set, prompt strings undergo parameter expansion, command substitution, arithmetic expansion, and quote removal after being expanded as described below (*note Controlling the Prompt::). This option is enabled by default. - 'restricted_shell' + ‘restricted_shell’ The shell sets this option if it is started in restricted mode (*note The Restricted Shell::). The value may not be changed. This is not reset when the startup files are executed, allowing the startup files to discover whether or not a shell is restricted. - 'shift_verbose' - If this is set, the 'shift' builtin prints an error message + ‘shift_verbose’ + If this is set, the ‘shift’ builtin prints an error message when the shift count exceeds the number of positional parameters. - 'sourcepath' - If set, the '.' ('source') builtin uses the value of 'PATH' to - find the directory containing the file supplied as an - argument. This option is enabled by default. + ‘sourcepath’ + If set, the ‘.’ (‘source’) builtin uses the value of ‘PATH’ to + find the directory containing the file supplied as an argument + when the ‘-p’ option is not supplied. This option is enabled + by default. - 'varredir_close' + ‘varredir_close’ If set, the shell automatically closes file descriptors - assigned using the '{varname}' redirection syntax (*note + assigned using the ‘{varname}’ redirection syntax (*note Redirections::) instead of leaving them open when the command completes. - 'xpg_echo' - If set, the 'echo' builtin expands backslash-escape sequences - by default. + ‘xpg_echo’ + If set, the ‘echo’ builtin expands backslash-escape sequences + by default. If the ‘posix’ shell option (*note The Set + Builtin::) is also enabled, ‘echo’ does not interpret any + options.  File: bash.info, Node: Special Builtins, Prev: Modifying Shell Behavior, Up: Shell Builtin Commands @@ -5089,8 +5555,8 @@ differently than the rest of the Bash builtin commands. The Bash POSIX mode is described in *note Bash POSIX Mode::. These are the POSIX special builtins: - break : . continue eval exec exit export readonly return set - shift trap unset + break : . source continue eval exec exit export readonly return set + shift times trap unset  File: bash.info, Node: Shell Variables, Next: Bash Features, Prev: Shell Builtin Commands, Up: Top @@ -5116,53 +5582,58 @@ File: bash.info, Node: Bourne Shell Variables, Next: Bash Variables, Up: Shel Bash uses certain shell variables in the same way as the Bourne shell. In some cases, Bash assigns a default value to the variable. -'CDPATH' +‘CDPATH’ A colon-separated list of directories used as a search path for the - 'cd' builtin command. + ‘cd’ builtin command. -'HOME' - The current user's home directory; the default for the 'cd' builtin +‘HOME’ + The current user's home directory; the default for the ‘cd’ builtin command. The value of this variable is also used by tilde expansion (*note Tilde Expansion::). -'IFS' +‘IFS’ A list of characters that separate fields; used when the shell - splits words as part of expansion. + splits words as part of expansion and by the ‘read’ builtin to + split lines into words. *Note Word Splitting::, for a description + of word splitting. -'MAIL' - If this parameter is set to a filename or directory name and the - 'MAILPATH' variable is not set, Bash informs the user of the +‘MAIL’ + If the value is set to a filename or directory name and the + ‘MAILPATH’ variable is not set, Bash informs the user of the arrival of mail in the specified file or Maildir-format directory. -'MAILPATH' +‘MAILPATH’ A colon-separated list of filenames which the shell periodically checks for new mail. Each list entry can specify the message that is printed when new mail arrives in the mail file by separating the - filename from the message with a '?'. When used in the text of the - message, '$_' expands to the name of the current mail file. + filename from the message with a ‘?’. When used in the text of the + message, ‘$_’ expands to the name of the current mail file. -'OPTARG' - The value of the last option argument processed by the 'getopts' +‘OPTARG’ + The value of the last option argument processed by the ‘getopts’ builtin. -'OPTIND' - The index of the last option argument processed by the 'getopts' +‘OPTIND’ + The index of the next argument to be processed by the ‘getopts’ builtin. -'PATH' +‘PATH’ A colon-separated list of directories in which the shell looks for commands. A zero-length (null) directory name in the value of - 'PATH' indicates the current directory. A null directory name may + ‘PATH’ indicates the current directory. A null directory name may appear as two adjacent colons, or as an initial or trailing colon. + The default path is system-dependent, and is set by the + administrator who installs ‘bash’. A common value is + "/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin". -'PS1' - The primary prompt string. The default value is '\s-\v\$ '. *Note +‘PS1’ + The primary prompt string. The default value is ‘\s-\v\$ ’. *Note Controlling the Prompt::, for the complete list of escape sequences - that are expanded before 'PS1' is displayed. + that are expanded before ‘PS1’ is displayed. -'PS2' - The secondary prompt string. The default value is '> '. 'PS2' is - expanded in the same way as 'PS1' before being displayed. +‘PS2’ + The secondary prompt string. The default value is ‘> ’. ‘PS2’ is + expanded in the same way as ‘PS1’ before being displayed.  File: bash.info, Node: Bash Variables, Prev: Bourne Shell Variables, Up: Shell Variables @@ -5177,718 +5648,804 @@ normally treat them specially. variables for controlling the job control facilities (*note Job Control Variables::). -'_' - ($_, an underscore.) At shell startup, set to the pathname used to - invoke the shell or shell script being executed as passed in the - environment or argument list. Subsequently, expands to the last +‘_’ + ($_, an underscore.) This has a number of meanings depending on + context. At shell startup, $_ set to the pathname used to invoke + the shell or shell script being executed as passed in the + environment or argument list. Subsequently, it expands to the last argument to the previous simple command executed in the foreground, - after expansion. Also set to the full pathname used to invoke each - command executed and placed in the environment exported to that - command. When checking mail, this parameter holds the name of the + after expansion. It is also set to the full pathname used to + invoke each command executed and placed in the environment exported + to that command. When checking mail, $_ expands to the name of the mail file. -'BASH' +‘BASH’ The full pathname used to execute the current instance of Bash. -'BASHOPTS' +‘BASHOPTS’ A colon-separated list of enabled shell options. Each word in the - list is a valid argument for the '-s' option to the 'shopt' builtin + list is a valid argument for the ‘-s’ option to the ‘shopt’ builtin command (*note The Shopt Builtin::). The options appearing in - 'BASHOPTS' are those reported as 'on' by 'shopt'. If this variable - is in the environment when Bash starts up, each shell option in the - list will be enabled before reading any startup files. This - variable is readonly. + ‘BASHOPTS’ are those reported as ‘on’ by ‘shopt’. If this variable + is in the environment when Bash starts up, the shell enables each + option in the list before reading any startup files. If this + variable is exported, child shells will enable each option in the + list. This variable is readonly. -'BASHPID' +‘BASHPID’ Expands to the process ID of the current Bash process. This - differs from '$$' under certain circumstances, such as subshells + differs from ‘$$’ under certain circumstances, such as subshells that do not require Bash to be re-initialized. Assignments to - 'BASHPID' have no effect. If 'BASHPID' is unset, it loses its + ‘BASHPID’ have no effect. If ‘BASHPID’ is unset, it loses its special properties, even if it is subsequently reset. -'BASH_ALIASES' +‘BASH_ALIASES’ An associative array variable whose members correspond to the - internal list of aliases as maintained by the 'alias' builtin. + internal list of aliases as maintained by the ‘alias’ builtin. (*note Bourne Shell Builtins::). Elements added to this array appear in the alias list; however, unsetting array elements currently does not cause aliases to be removed from the alias list. - If 'BASH_ALIASES' is unset, it loses its special properties, even + If ‘BASH_ALIASES’ is unset, it loses its special properties, even if it is subsequently reset. -'BASH_ARGC' +‘BASH_ARGC’ An array variable whose values are the number of parameters in each - frame of the current bash execution call stack. The number of + frame of the current Bash execution call stack. The number of parameters to the current subroutine (shell function or script - executed with '.' or 'source') is at the top of the stack. When a + executed with ‘.’ or ‘source’) is at the top of the stack. When a subroutine is executed, the number of parameters passed is pushed - onto 'BASH_ARGC'. The shell sets 'BASH_ARGC' only when in extended + onto ‘BASH_ARGC’. The shell sets ‘BASH_ARGC’ only when in extended debugging mode (see *note The Shopt Builtin:: for a description of - the 'extdebug' option to the 'shopt' builtin). Setting 'extdebug' - after the shell has started to execute a script, or referencing - this variable when 'extdebug' is not set, may result in - inconsistent values. + the ‘extdebug’ option to the ‘shopt’ builtin). Setting ‘extdebug’ + after the shell has started to execute a subroutine, or referencing + this variable when ‘extdebug’ is not set, may result in + inconsistent values. Assignments to ‘BASH_ARGC’ have no effect, + and it may not be unset. -'BASH_ARGV' +‘BASH_ARGV’ An array variable containing all of the parameters in the current - bash execution call stack. The final parameter of the last + Bash execution call stack. The final parameter of the last subroutine call is at the top of the stack; the first parameter of the initial call is at the bottom. When a subroutine is executed, - the parameters supplied are pushed onto 'BASH_ARGV'. The shell - sets 'BASH_ARGV' only when in extended debugging mode (see *note - The Shopt Builtin:: for a description of the 'extdebug' option to - the 'shopt' builtin). Setting 'extdebug' after the shell has - started to execute a script, or referencing this variable when - 'extdebug' is not set, may result in inconsistent values. - -'BASH_ARGV0' + the shell pushes the supplied parameters onto ‘BASH_ARGV’. The + shell sets ‘BASH_ARGV’ only when in extended debugging mode (see + *note The Shopt Builtin:: for a description of the ‘extdebug’ + option to the ‘shopt’ builtin). Setting ‘extdebug’ after the shell + has started to execute a script, or referencing this variable when + ‘extdebug’ is not set, may result in inconsistent values. + Assignments to ‘BASH_ARGV’ have no effect, and it may not be unset. + +‘BASH_ARGV0’ When referenced, this variable expands to the name of the shell or - shell script (identical to '$0'; *Note Special Parameters::, for - the description of special parameter 0). Assignment to - 'BASH_ARGV0' causes the value assigned to also be assigned to '$0'. - If 'BASH_ARGV0' is unset, it loses its special properties, even if - it is subsequently reset. + shell script (identical to ‘$0’; *Note Special Parameters::, for + the description of special parameter 0). Assigning a value to + ‘BASH_ARGV0’ sets ‘$0’ to the same value. If ‘BASH_ARGV0’ is + unset, it loses its special properties, even if it is subsequently + reset. -'BASH_CMDS' +‘BASH_CMDS’ An associative array variable whose members correspond to the - internal hash table of commands as maintained by the 'hash' builtin - (*note Bourne Shell Builtins::). Elements added to this array - appear in the hash table; however, unsetting array elements - currently does not cause command names to be removed from the hash - table. If 'BASH_CMDS' is unset, it loses its special properties, + internal hash table of commands as maintained by the ‘hash’ builtin + (*note Bourne Shell Builtins::). Adding elements to this array + makes them appear in the hash table; however, unsetting array + elements currently does not remove command names from the hash + table. If ‘BASH_CMDS’ is unset, it loses its special properties, even if it is subsequently reset. -'BASH_COMMAND' - The command currently being executed or about to be executed, - unless the shell is executing a command as the result of a trap, in - which case it is the command executing at the time of the trap. If - 'BASH_COMMAND' is unset, it loses its special properties, even if - it is subsequently reset. +‘BASH_COMMAND’ + Expands to the command currently being executed or about to be + executed, unless the shell is executing a command as the result of + a trap, in which case it is the command executing at the time of + the trap. If ‘BASH_COMMAND’ is unset, it loses its special + properties, even if it is subsequently reset. -'BASH_COMPAT' +‘BASH_COMPAT’ The value is used to set the shell's compatibility level. *Note Shell Compatibility Mode::, for a description of the various compatibility levels and their effects. The value may be a decimal number (e.g., 4.2) or an integer (e.g., 42) corresponding to the - desired compatibility level. If 'BASH_COMPAT' is unset or set to + desired compatibility level. If ‘BASH_COMPAT’ is unset or set to the empty string, the compatibility level is set to the default for - the current version. If 'BASH_COMPAT' is set to a value that is + the current version. If ‘BASH_COMPAT’ is set to a value that is not one of the valid compatibility levels, the shell prints an error message and sets the compatibility level to the default for - the current version. The valid values correspond to the - compatibility levels described below (*note Shell Compatibility + the current version. A subset of the valid values correspond to + the compatibility levels described below (*note Shell Compatibility Mode::). For example, 4.2 and 42 are valid values that correspond - to the 'compat42' 'shopt' option and set the compatibility level to + to the ‘compat42’ ‘shopt’ option and set the compatibility level to 42. The current version is also a valid value. -'BASH_ENV' +‘BASH_ENV’ If this variable is set when Bash is invoked to execute a shell script, its value is expanded and used as the name of a startup - file to read before executing the script. *Note Bash Startup - Files::. + file to read before executing the script. Bash does not use ‘PATH’ + to search for the resultant filename. *Note Bash Startup Files::. -'BASH_EXECUTION_STRING' - The command argument to the '-c' invocation option. +‘BASH_EXECUTION_STRING’ + The command argument to the ‘-c’ invocation option. -'BASH_LINENO' +‘BASH_LINENO’ An array variable whose members are the line numbers in source - files where each corresponding member of 'FUNCNAME' was invoked. - '${BASH_LINENO[$i]}' is the line number in the source file - ('${BASH_SOURCE[$i+1]}') where '${FUNCNAME[$i]}' was called (or - '${BASH_LINENO[$i-1]}' if referenced within another shell - function). Use 'LINENO' to obtain the current line number. + files where each corresponding member of ‘FUNCNAME’ was invoked. + ‘${BASH_LINENO[$i]}’ is the line number in the source file + (‘${BASH_SOURCE[$i+1]}’) where ‘${FUNCNAME[$i]}’ was called (or + ‘${BASH_LINENO[$i-1]}’ if referenced within another shell + function). Use ‘LINENO’ to obtain the current line number. + Assignments to ‘BASH_LINENO’ have no effect, and it may not be + unset. -'BASH_LOADABLES_PATH' - A colon-separated list of directories in which the shell looks for - dynamically loadable builtins specified by the 'enable' command. +‘BASH_LOADABLES_PATH’ + A colon-separated list of directories in which the ‘enable’ command + looks for dynamically loadable builtins. + +‘BASH_MONOSECONDS’ + Each time this variable is referenced, it expands to the value + returned by the system's monotonic clock, if one is available. If + there is no monotonic clock, this is equivalent to ‘EPOCHSECONDS’. + If ‘BASH_MONOSECONDS’ is unset, it loses its special properties, + even if it is subsequently reset. -'BASH_REMATCH' - An array variable whose members are assigned by the '=~' binary - operator to the '[[' conditional command (*note Conditional +‘BASH_REMATCH’ + An array variable whose members are assigned by the ‘=~’ binary + operator to the ‘[[’ conditional command (*note Conditional Constructs::). The element with index 0 is the portion of the string matching the entire regular expression. The element with index N is the portion of the string matching the Nth parenthesized subexpression. -'BASH_SOURCE' +‘BASH_SOURCE’ An array variable whose members are the source filenames where the - corresponding shell function names in the 'FUNCNAME' array variable - are defined. The shell function '${FUNCNAME[$i]}' is defined in - the file '${BASH_SOURCE[$i]}' and called from - '${BASH_SOURCE[$i+1]}' + corresponding shell function names in the ‘FUNCNAME’ array variable + are defined. The shell function ‘${FUNCNAME[$i]}’ is defined in + the file ‘${BASH_SOURCE[$i]}’ and called from + ‘${BASH_SOURCE[$i+1]}’ Assignments to ‘BASH_SOURCE’ have no effect, + and it may not be unset. -'BASH_SUBSHELL' +‘BASH_SUBSHELL’ Incremented by one within each subshell or subshell environment when the shell begins executing in that environment. The initial - value is 0. If 'BASH_SUBSHELL' is unset, it loses its special + value is 0. If ‘BASH_SUBSHELL’ is unset, it loses its special properties, even if it is subsequently reset. -'BASH_VERSINFO' +‘BASH_TRAPSIG’ + Set to the signal number corresponding to the trap action being + executed during its execution. See the description of ‘trap’ + (*note Bourne Shell Builtins::) for information about signal + numbers and trap execution. + +‘BASH_VERSINFO’ A readonly array variable (*note Arrays::) whose members hold version information for this instance of Bash. The values assigned to the array members are as follows: - 'BASH_VERSINFO[0]' - The major version number (the "release"). + ‘BASH_VERSINFO[0]’ + The major version number (the “release”). - 'BASH_VERSINFO[1]' - The minor version number (the "version"). + ‘BASH_VERSINFO[1]’ + The minor version number (the “version”). - 'BASH_VERSINFO[2]' + ‘BASH_VERSINFO[2]’ The patch level. - 'BASH_VERSINFO[3]' + ‘BASH_VERSINFO[3]’ The build version. - 'BASH_VERSINFO[4]' - The release status (e.g., 'beta1'). + ‘BASH_VERSINFO[4]’ + The release status (e.g., ‘beta’). - 'BASH_VERSINFO[5]' - The value of 'MACHTYPE'. + ‘BASH_VERSINFO[5]’ + The value of ‘MACHTYPE’. -'BASH_VERSION' - The version number of the current instance of Bash. +‘BASH_VERSION’ + Expands to a string describing the version of this instance of Bash + (e.g., 5.2.37(3)-release). -'BASH_XTRACEFD' +‘BASH_XTRACEFD’ If set to an integer corresponding to a valid file descriptor, Bash - will write the trace output generated when 'set -x' is enabled to - that file descriptor. This allows tracing output to be separated - from diagnostic and error messages. The file descriptor is closed - when 'BASH_XTRACEFD' is unset or assigned a new value. Unsetting - 'BASH_XTRACEFD' or assigning it the empty string causes the trace - output to be sent to the standard error. Note that setting - 'BASH_XTRACEFD' to 2 (the standard error file descriptor) and then - unsetting it will result in the standard error being closed. - -'CHILD_MAX' + writes the trace output generated when ‘set -x’ is enabled to that + file descriptor, instead of the standard error. This allows + tracing output to be separated from diagnostic and error messages. + The file descriptor is closed when ‘BASH_XTRACEFD’ is unset or + assigned a new value. Unsetting ‘BASH_XTRACEFD’ or assigning it + the empty string causes the trace output to be sent to the standard + error. Note that setting ‘BASH_XTRACEFD’ to 2 (the standard error + file descriptor) and then unsetting it will result in the standard + error being closed. + +‘CHILD_MAX’ Set the number of exited child status values for the shell to remember. Bash will not allow this value to be decreased below a POSIX-mandated minimum, and there is a maximum value (currently 8192) that this may not exceed. The minimum value is system-dependent. -'COLUMNS' - Used by the 'select' command to determine the terminal width when - printing selection lists. Automatically set if the 'checkwinsize' +‘COLUMNS’ + Used by the ‘select’ command to determine the terminal width when + printing selection lists. Automatically set if the ‘checkwinsize’ option is enabled (*note The Shopt Builtin::), or in an interactive - shell upon receipt of a 'SIGWINCH'. + shell upon receipt of a ‘SIGWINCH’. -'COMP_CWORD' - An index into '${COMP_WORDS}' of the word containing the current +‘COMP_CWORD’ + An index into ‘${COMP_WORDS}’ of the word containing the current cursor position. This variable is available only in shell functions invoked by the programmable completion facilities (*note Programmable Completion::). -'COMP_LINE' +‘COMP_KEY’ + The key (or final key of a key sequence) used to invoke the current + completion function. This variable is available only in shell + functions and external commands invoked by the programmable + completion facilities (*note Programmable Completion::). + +‘COMP_LINE’ The current command line. This variable is available only in shell functions and external commands invoked by the programmable completion facilities (*note Programmable Completion::). -'COMP_POINT' +‘COMP_POINT’ The index of the current cursor position relative to the beginning of the current command. If the current cursor position is at the end of the current command, the value of this variable is equal to - '${#COMP_LINE}'. This variable is available only in shell + ‘${#COMP_LINE}’. This variable is available only in shell functions and external commands invoked by the programmable completion facilities (*note Programmable Completion::). -'COMP_TYPE' - Set to an integer value corresponding to the type of completion - attempted that caused a completion function to be called: , - for normal completion, '?', for listing completions after - successive tabs, '!', for listing alternatives on partial word - completion, '@', to list completions if the word is not unmodified, - or '%', for menu completion. This variable is available only in +‘COMP_TYPE’ + Set to an integer value corresponding to the type of attempted + completion that caused a completion function to be called: , + for normal completion, ‘?’, for listing completions after + successive tabs, ‘!’, for listing alternatives on partial word + completion, ‘@’, to list completions if the word is not unmodified, + or ‘%’, for menu completion. This variable is available only in shell functions and external commands invoked by the programmable completion facilities (*note Programmable Completion::). -'COMP_KEY' - The key (or final key of a key sequence) used to invoke the current - completion function. - -'COMP_WORDBREAKS' +‘COMP_WORDBREAKS’ The set of characters that the Readline library treats as word - separators when performing word completion. If 'COMP_WORDBREAKS' + separators when performing word completion. If ‘COMP_WORDBREAKS’ is unset, it loses its special properties, even if it is subsequently reset. -'COMP_WORDS' +‘COMP_WORDS’ An array variable consisting of the individual words in the current command line. The line is split into words as Readline would split - it, using 'COMP_WORDBREAKS' as described above. This variable is + it, using ‘COMP_WORDBREAKS’ as described above. This variable is available only in shell functions invoked by the programmable completion facilities (*note Programmable Completion::). -'COMPREPLY' +‘COMPREPLY’ An array variable from which Bash reads the possible completions generated by a shell function invoked by the programmable completion facility (*note Programmable Completion::). Each array element contains one possible completion. -'COPROC' +‘COPROC’ An array variable created to hold the file descriptors for output from and input to an unnamed coprocess (*note Coprocesses::). -'DIRSTACK' +‘DIRSTACK’ An array variable containing the current contents of the directory stack. Directories appear in the stack in the order they are - displayed by the 'dirs' builtin. Assigning to members of this + displayed by the ‘dirs’ builtin. Assigning to members of this array variable may be used to modify directories already in the - stack, but the 'pushd' and 'popd' builtins must be used to add and - remove directories. Assignment to this variable will not change - the current directory. If 'DIRSTACK' is unset, it loses its - special properties, even if it is subsequently reset. + stack, but the ‘pushd’ and ‘popd’ builtins must be used to add and + remove directories. Assigning to this variable does not change the + current directory. If ‘DIRSTACK’ is unset, it loses its special + properties, even if it is subsequently reset. -'EMACS' +‘EMACS’ If Bash finds this variable in the environment when the shell - starts with value 't', it assumes that the shell is running in an - Emacs shell buffer and disables line editing. + starts, and its value is ‘t’, Bash assumes that the shell is + running in an Emacs shell buffer and disables line editing. -'ENV' - Expanded and executed similarly to 'BASH_ENV' (*note Bash Startup - Files::) when an interactive shell is invoked in POSIX Mode (*note +‘ENV’ + Expanded and executed similarly to ‘BASH_ENV’ (*note Bash Startup + Files::) when an interactive shell is invoked in POSIX mode (*note Bash POSIX Mode::). -'EPOCHREALTIME' +‘EPOCHREALTIME’ Each time this parameter is referenced, it expands to the number of - seconds since the Unix Epoch as a floating point value with + seconds since the Unix Epoch as a floating-point value with micro-second granularity (see the documentation for the C library - function 'time' for the definition of Epoch). Assignments to - 'EPOCHREALTIME' are ignored. If 'EPOCHREALTIME' is unset, it loses + function ‘time’ for the definition of Epoch). Assignments to + ‘EPOCHREALTIME’ are ignored. If ‘EPOCHREALTIME’ is unset, it loses its special properties, even if it is subsequently reset. -'EPOCHSECONDS' +‘EPOCHSECONDS’ Each time this parameter is referenced, it expands to the number of seconds since the Unix Epoch (see the documentation for the C - library function 'time' for the definition of Epoch). Assignments - to 'EPOCHSECONDS' are ignored. If 'EPOCHSECONDS' is unset, it + library function ‘time’ for the definition of Epoch). Assignments + to ‘EPOCHSECONDS’ are ignored. If ‘EPOCHSECONDS’ is unset, it loses its special properties, even if it is subsequently reset. -'EUID' +‘EUID’ The numeric effective user id of the current user. This variable is readonly. -'EXECIGNORE' +‘EXECIGNORE’ A colon-separated list of shell patterns (*note Pattern Matching::) - defining the list of filenames to be ignored by command search - using 'PATH'. Files whose full pathnames match one of these - patterns are not considered executable files for the purposes of - completion and command execution via 'PATH' lookup. This does not - affect the behavior of the '[', 'test', and '[[' commands. Full - pathnames in the command hash table are not subject to - 'EXECIGNORE'. Use this variable to ignore shared library files - that have the executable bit set, but are not executable files. - The pattern matching honors the setting of the 'extglob' shell - option. - -'FCEDIT' - The editor used as a default by the '-e' option to the 'fc' builtin - command. - -'FIGNORE' + defining the set of filenames to be ignored by command search using + ‘PATH’. Files whose full pathnames match one of these patterns are + not considered executable files for the purposes of completion and + command execution via ‘PATH’ lookup. This does not affect the + behavior of the ‘[’, ‘test’, and ‘[[’ commands. Full pathnames in + the command hash table are not subject to ‘EXECIGNORE’. Use this + variable to ignore shared library files that have the executable + bit set, but are not executable files. The pattern matching honors + the setting of the ‘extglob’ shell option. + +‘FCEDIT’ + The editor used as a default by the ‘fc’ builtin command. + +‘FIGNORE’ A colon-separated list of suffixes to ignore when performing filename completion. A filename whose suffix matches one of the - entries in 'FIGNORE' is excluded from the list of matched - filenames. A sample value is '.o:~' + entries in ‘FIGNORE’ is excluded from the list of matched + filenames. A sample value is ‘.o:~’ -'FUNCNAME' +‘FUNCNAME’ An array variable containing the names of all shell functions currently in the execution call stack. The element with index 0 is the name of any currently-executing shell function. The - bottom-most element (the one with the highest index) is '"main"'. + bottom-most element (the one with the highest index) is ‘"main"’. This variable exists only when a shell function is executing. - Assignments to 'FUNCNAME' have no effect. If 'FUNCNAME' is unset, + Assignments to ‘FUNCNAME’ have no effect. If ‘FUNCNAME’ is unset, it loses its special properties, even if it is subsequently reset. - This variable can be used with 'BASH_LINENO' and 'BASH_SOURCE'. - Each element of 'FUNCNAME' has corresponding elements in - 'BASH_LINENO' and 'BASH_SOURCE' to describe the call stack. For - instance, '${FUNCNAME[$i]}' was called from the file - '${BASH_SOURCE[$i+1]}' at line number '${BASH_LINENO[$i]}'. The - 'caller' builtin displays the current call stack using this + This variable can be used with ‘BASH_LINENO’ and ‘BASH_SOURCE’. + Each element of ‘FUNCNAME’ has corresponding elements in + ‘BASH_LINENO’ and ‘BASH_SOURCE’ to describe the call stack. For + instance, ‘${FUNCNAME[$i]}’ was called from the file + ‘${BASH_SOURCE[$i+1]}’ at line number ‘${BASH_LINENO[$i]}’. The + ‘caller’ builtin displays the current call stack using this information. -'FUNCNEST' - If set to a numeric value greater than 0, defines a maximum - function nesting level. Function invocations that exceed this - nesting level will cause the current command to abort. +‘FUNCNEST’ + A numeric value greater than 0 defines a maximum function nesting + level. Function invocations that exceed this nesting level cause + the current command to abort. -'GLOBIGNORE' +‘GLOBIGNORE’ A colon-separated list of patterns defining the set of file names to be ignored by filename expansion. If a file name matched by a filename expansion pattern also matches one of the patterns in - 'GLOBIGNORE', it is removed from the list of matches. The pattern - matching honors the setting of the 'extglob' shell option. - -'GROUPS' + ‘GLOBIGNORE’, it is removed from the list of matches. The pattern + matching honors the setting of the ‘extglob’ shell option. + +‘GLOBSORT’ + Controls how the results of filename expansion are sorted. The + value of this variable specifies the sort criteria and sort order + for the results of filename expansion. If this variable is unset + or set to the null string, filename expansion uses the historical + behavior of sorting by name, in ascending lexicographic order as + determined by the ‘LC_COLLATE’ shell variable. + + If set, a valid value begins with an optional ‘+’, which is + ignored, or ‘-’, which reverses the sort order from ascending to + descending, followed by a sort specifier. The valid sort + specifiers are ‘name’, ‘numeric’, ‘size’, ‘mtime’, ‘atime’, + ‘ctime’, and ‘blocks’, which sort the files on name, names in + numeric rather than lexicographic order, file size, modification + time, access time, inode change time, and number of blocks, + respectively. If any of the non-name keys compare as equal (e.g., + if two files are the same size), sorting uses the name as a + secondary sort key. + + For example, a value of ‘-mtime’ sorts the results in descending + order by modification time (newest first). + + The ‘numeric’ specifier treats names consisting solely of digits as + numbers and sorts them using their numeric value (so "2" sorts + before "10", for example). When using ‘numeric’, names containing + non-digits sort after all the all-digit names and are sorted by + name using the traditional behavior. + + A sort specifier of ‘nosort’ disables sorting completely; Bash + returns the results in the order they are read from the file + system, ignoring any leading ‘-’. + + If the sort specifier is missing, it defaults to NAME, so a value + of ‘+’ is equivalent to the null string, and a value of ‘-’ sorts + by name in descending order. + + Any invalid value restores the historical sorting behavior. + +‘GROUPS’ An array variable containing the list of groups of which the - current user is a member. Assignments to 'GROUPS' have no effect. - If 'GROUPS' is unset, it loses its special properties, even if it + current user is a member. Assignments to ‘GROUPS’ have no effect. + If ‘GROUPS’ is unset, it loses its special properties, even if it is subsequently reset. -'histchars' - Up to three characters which control history expansion, quick +‘histchars’ + The two or three characters which control history expansion, quick substitution, and tokenization (*note History Interaction::). The - first character is the "history expansion" character, that is, the - character which signifies the start of a history expansion, - normally '!'. The second character is the character which - signifies 'quick substitution' when seen as the first character on - a line, normally '^'. The optional third character is the - character which indicates that the remainder of the line is a - comment when found as the first character of a word, usually '#'. - The history comment character causes history substitution to be - skipped for the remaining words on the line. It does not - necessarily cause the shell parser to treat the rest of the line as - a comment. - -'HISTCMD' + first character is the “history expansion” character, the character + which begins a history expansion, normally ‘!’. The second + character is the “quick substitution” character, normally ‘^’. + When it appears as the first character on the line, history + substitution repeats the previous command, replacing one string + with another. The optional third character is the “history + comment” character, normally ‘#’, which indicates that the + remainder of the line is a comment when it appears as the first + character of a word. The history comment character disables + history substitution for the remaining words on the line. It does + not necessarily cause the shell parser to treat the rest of the + line as a comment. + +‘HISTCMD’ The history number, or index in the history list, of the current - command. Assignments to 'HISTCMD' are ignored. If 'HISTCMD' is + command. Assignments to ‘HISTCMD’ have no effect. If ‘HISTCMD’ is unset, it loses its special properties, even if it is subsequently reset. -'HISTCONTROL' +‘HISTCONTROL’ A colon-separated list of values controlling how commands are saved - on the history list. If the list of values includes 'ignorespace', + on the history list. If the list of values includes ‘ignorespace’, lines which begin with a space character are not saved in the - history list. A value of 'ignoredups' causes lines which match the - previous history entry to not be saved. A value of 'ignoreboth' is - shorthand for 'ignorespace' and 'ignoredups'. A value of - 'erasedups' causes all previous lines matching the current line to + history list. A value of ‘ignoredups’ causes lines which match the + previous history entry not to be saved. A value of ‘ignoreboth’ is + shorthand for ‘ignorespace’ and ‘ignoredups’. A value of + ‘erasedups’ causes all previous lines matching the current line to be removed from the history list before that line is saved. Any - value not in the above list is ignored. If 'HISTCONTROL' is unset, - or does not include a valid value, all lines read by the shell - parser are saved on the history list, subject to the value of - 'HISTIGNORE'. The second and subsequent lines of a multi-line - compound command are not tested, and are added to the history - regardless of the value of 'HISTCONTROL'. - -'HISTFILE' - The name of the file to which the command history is saved. The - default value is '~/.bash_history'. - -'HISTFILESIZE' + value not in the above list is ignored. If ‘HISTCONTROL’ is unset, + or does not include a valid value, Bash saves all lines read by the + shell parser on the history list, subject to the value of + ‘HISTIGNORE’. If the first line of a multi-line compound command + was saved, the second and subsequent lines are not tested, and are + added to the history regardless of the value of ‘HISTCONTROL’. If + the first line was not saved, the second and subsequent lines of + the command are not saved either. + +‘HISTFILE’ + The name of the file to which the command history is saved. Bash + assigns a default value of ‘~/.bash_history’. If ‘HISTFILE’ is + unset or null, the shell does not save the command history when it + exits. + +‘HISTFILESIZE’ The maximum number of lines contained in the history file. When this variable is assigned a value, the history file is truncated, - if necessary, to contain no more than that number of lines by - removing the oldest entries. The history file is also truncated to - this size after writing it when a shell exits. If the value is 0, - the history file is truncated to zero size. Non-numeric values and - numeric values less than zero inhibit truncation. The shell sets - the default value to the value of 'HISTSIZE' after reading any - startup files. - -'HISTIGNORE' + if necessary, to contain no more than the number of history entries + that total no more than that number of lines by removing the oldest + entries. If the history list contains multi-line entries, the + history file may contain more lines than this maximum to avoid + leaving partial history entries. The history file is also + truncated to this size after writing it when a shell exits or by + the ‘history’ builtin. If the value is 0, the history file is + truncated to zero size. Non-numeric values and numeric values less + than zero inhibit truncation. The shell sets the default value to + the value of ‘HISTSIZE’ after reading any startup files. + +‘HISTIGNORE’ A colon-separated list of patterns used to decide which command - lines should be saved on the history list. Each pattern is - anchored at the beginning of the line and must match the complete - line (no implicit '*' is appended). Each pattern is tested against - the line after the checks specified by 'HISTCONTROL' are applied. - In addition to the normal shell pattern matching characters, '&' - matches the previous history line. '&' may be escaped using a - backslash; the backslash is removed before attempting a match. The - second and subsequent lines of a multi-line compound command are - not tested, and are added to the history regardless of the value of - 'HISTIGNORE'. The pattern matching honors the setting of the - 'extglob' shell option. - - 'HISTIGNORE' subsumes the function of 'HISTCONTROL'. A pattern of - '&' is identical to 'ignoredups', and a pattern of '[ ]*' is - identical to 'ignorespace'. Combining these two patterns, + lines should be saved on the history list. If a command line + matches one of the patterns in the value of ‘HISTIGNORE’, it is not + saved on the history list. Each pattern is anchored at the + beginning of the line and must match the complete line (Bash does + not implicitly append a ‘*’). Each pattern is tested against the + line after the checks specified by ‘HISTCONTROL’ are applied. In + addition to the normal shell pattern matching characters, ‘&’ + matches the previous history line. A backslash escapes the ‘&’; + the backslash is removed before attempting a match. If the first + line of a multi-line compound command was saved, the second and + subsequent lines are not tested, and are added to the history + regardless of the value of ‘HISTIGNORE’. If the first line was not + saved, the second and subsequent lines of the command are not saved + either. The pattern matching honors the setting of the ‘extglob’ + shell option. + + ‘HISTIGNORE’ subsumes some of the function of ‘HISTCONTROL’. A + pattern of ‘&’ is identical to ‘ignoredups’, and a pattern of ‘[ + ]*’ is identical to ‘ignorespace’. Combining these two patterns, separating them with a colon, provides the functionality of - 'ignoreboth'. + ‘ignoreboth’. -'HISTSIZE' +‘HISTSIZE’ The maximum number of commands to remember on the history list. If the value is 0, commands are not saved in the history list. Numeric values less than zero result in every command being saved on the history list (there is no limit). The shell sets the default value to 500 after reading any startup files. -'HISTTIMEFORMAT' +‘HISTTIMEFORMAT’ If this variable is set and not null, its value is used as a format - string for 'strftime' to print the time stamp associated with each - history entry displayed by the 'history' builtin. If this variable - is set, time stamps are written to the history file so they may be - preserved across shell sessions. This uses the history comment - character to distinguish timestamps from other history lines. - -'HOSTFILE' - Contains the name of a file in the same format as '/etc/hosts' that + string for ‘strftime’(3) to print the time stamp associated with + each history entry displayed by the ‘history’ builtin. If this + variable is set, the shell writes time stamps to the history file + so they may be preserved across shell sessions. This uses the + history comment character to distinguish timestamps from other + history lines. + +‘HOSTFILE’ + Contains the name of a file in the same format as ‘/etc/hosts’ that should be read when the shell needs to complete a hostname. The list of possible hostname completions may be changed while the shell is running; the next time hostname completion is attempted after the value is changed, Bash adds the contents of the new file - to the existing list. If 'HOSTFILE' is set, but has no value, or - does not name a readable file, Bash attempts to read '/etc/hosts' + to the existing list. If ‘HOSTFILE’ is set, but has no value, or + does not name a readable file, Bash attempts to read ‘/etc/hosts’ to obtain the list of possible hostname completions. When - 'HOSTFILE' is unset, the hostname list is cleared. + ‘HOSTFILE’ is unset, Bash clears the hostname list. -'HOSTNAME' +‘HOSTNAME’ The name of the current host. -'HOSTTYPE' +‘HOSTTYPE’ A string describing the machine Bash is running on. -'IGNOREEOF' - Controls the action of the shell on receipt of an 'EOF' character - as the sole input. If set, the value denotes the number of - consecutive 'EOF' characters that can be read as the first - character on an input line before the shell will exit. If the - variable exists but does not have a numeric value, or has no value, - then the default is 10. If the variable does not exist, then 'EOF' - signifies the end of input to the shell. This is only in effect - for interactive shells. - -'INPUTRC' +‘IGNOREEOF’ + Controls the action of the shell on receipt of an ‘EOF’ character + as the sole input. If set, the value is the number of consecutive + ‘EOF’ characters that can be read as the first character on an + input line before Bash exits. If the variable is set but does not + have a numeric value, or the value is null, then the default is 10. + If the variable is unset, then ‘EOF’ signifies the end of input to + the shell. This is only in effect for interactive shells. + +‘INPUTRC’ The name of the Readline initialization file, overriding the - default of '~/.inputrc'. + default of ‘~/.inputrc’. -'INSIDE_EMACS' +‘INSIDE_EMACS’ If Bash finds this variable in the environment when the shell starts, it assumes that the shell is running in an Emacs shell buffer and may disable line editing depending on the value of - 'TERM'. + ‘TERM’. -'LANG' +‘LANG’ Used to determine the locale category for any category not - specifically selected with a variable starting with 'LC_'. + specifically selected with a variable starting with ‘LC_’. -'LC_ALL' - This variable overrides the value of 'LANG' and any other 'LC_' +‘LC_ALL’ + This variable overrides the value of ‘LANG’ and any other ‘LC_’ variable specifying a locale category. -'LC_COLLATE' +‘LC_COLLATE’ This variable determines the collation order used when sorting the results of filename expansion, and determines the behavior of range expressions, equivalence classes, and collating sequences within filename expansion and pattern matching (*note Filename Expansion::). -'LC_CTYPE' +‘LC_CTYPE’ This variable determines the interpretation of characters and the behavior of character classes within filename expansion and pattern matching (*note Filename Expansion::). -'LC_MESSAGES' +‘LC_MESSAGES’ This variable determines the locale used to translate double-quoted - strings preceded by a '$' (*note Locale Translation::). + strings preceded by a ‘$’ (*note Locale Translation::). -'LC_NUMERIC' +‘LC_NUMERIC’ This variable determines the locale category used for number formatting. -'LC_TIME' +‘LC_TIME’ This variable determines the locale category used for data and time formatting. -'LINENO' +‘LINENO’ The line number in the script or shell function currently - executing. If 'LINENO' is unset, it loses its special properties, - even if it is subsequently reset. + executing. Line numbers start with 1. When not in a script or + function, the value is not guaranteed to be meaningful. If + ‘LINENO’ is unset, it loses its special properties, even if it is + subsequently reset. -'LINES' - Used by the 'select' command to determine the column length for - printing selection lists. Automatically set if the 'checkwinsize' +‘LINES’ + Used by the ‘select’ command to determine the column length for + printing selection lists. Automatically set if the ‘checkwinsize’ option is enabled (*note The Shopt Builtin::), or in an interactive - shell upon receipt of a 'SIGWINCH'. + shell upon receipt of a ‘SIGWINCH’. -'MACHTYPE' +‘MACHTYPE’ A string that fully describes the system type on which Bash is executing, in the standard GNU CPU-COMPANY-SYSTEM format. -'MAILCHECK' +‘MAILCHECK’ How often (in seconds) that the shell should check for mail in the - files specified in the 'MAILPATH' or 'MAIL' variables. The default + files specified in the ‘MAILPATH’ or ‘MAIL’ variables. The default is 60 seconds. When it is time to check for mail, the shell does so before displaying the primary prompt. If this variable is unset, or set to a value that is not a number greater than or equal to zero, the shell disables mail checking. -'MAPFILE' - An array variable created to hold the text read by the 'mapfile' +‘MAPFILE’ + An array variable created to hold the text read by the ‘mapfile’ builtin when no variable name is supplied. -'OLDPWD' - The previous working directory as set by the 'cd' builtin. +‘OLDPWD’ + The previous working directory as set by the ‘cd’ builtin. -'OPTERR' +‘OPTERR’ If set to the value 1, Bash displays error messages generated by - the 'getopts' builtin command. + the ‘getopts’ builtin command. ‘OPTERR’ is initialized to 1 each + time the shell is invoked. -'OSTYPE' +‘OSTYPE’ A string describing the operating system Bash is running on. -'PIPESTATUS' +‘PIPESTATUS’ An array variable (*note Arrays::) containing a list of exit status - values from the processes in the most-recently-executed foreground - pipeline (which may contain only a single command). - -'POSIXLY_CORRECT' + values from the commands in the most-recently-executed foreground + pipeline, which may consist of only a simple command (*note Shell + Commands::). Bash sets ‘PIPESTATUS’ after executing multi-element + pipelines, timed and negated pipelines, simple commands, subshells + created with the ‘(’ operator, the ‘[[’ and ‘((’ compound commands, + and after error conditions that result in the shell aborting + command execution. + +‘POSIXLY_CORRECT’ If this variable is in the environment when Bash starts, the shell enters POSIX mode (*note Bash POSIX Mode::) before reading the - startup files, as if the '--posix' invocation option had been + startup files, as if the ‘--posix’ invocation option had been supplied. If it is set while the shell is running, Bash enables POSIX mode, as if the command set -o posix had been executed. When the shell enters POSIX mode, it sets this variable if it was not already set. -'PPID' +‘PPID’ The process ID of the shell's parent process. This variable is readonly. -'PROMPT_COMMAND' +‘PROMPT_COMMAND’ If this variable is set, and is an array, the value of each set element is interpreted as a command to execute before printing the - primary prompt ('$PS1'). If this is set but not an array variable, + primary prompt (‘$PS1’). If this is set but not an array variable, its value is used as a command to execute instead. -'PROMPT_DIRTRIM' +‘PROMPT_DIRTRIM’ If set to a number greater than zero, the value is used as the number of trailing directory components to retain when expanding - the '\w' and '\W' prompt string escapes (*note Controlling the + the ‘\w’ and ‘\W’ prompt string escapes (*note Controlling the Prompt::). Characters removed are replaced with an ellipsis. -'PS0' - The value of this parameter is expanded like 'PS1' and displayed by +‘PS0’ + The value of this parameter is expanded like ‘PS1’ and displayed by interactive shells after reading a command and before the command is executed. -'PS3' - The value of this variable is used as the prompt for the 'select' - command. If this variable is not set, the 'select' command prompts - with '#? ' +‘PS3’ + The value of this variable is used as the prompt for the ‘select’ + command. If this variable is not set, the ‘select’ command prompts + with ‘#? ’ -'PS4' - The value of this parameter is expanded like 'PS1' and the expanded +‘PS4’ + The value of this parameter is expanded like ‘PS1’ and the expanded value is the prompt printed before the command line is echoed when - the '-x' option is set (*note The Set Builtin::). The first + the ‘-x’ option is set (*note The Set Builtin::). The first character of the expanded value is replicated multiple times, as necessary, to indicate multiple levels of indirection. The default - is '+ '. + is ‘+ ’. -'PWD' - The current working directory as set by the 'cd' builtin. +‘PWD’ + The current working directory as set by the ‘cd’ builtin. -'RANDOM' +‘RANDOM’ Each time this parameter is referenced, it expands to a random - integer between 0 and 32767. Assigning a value to this variable - seeds the random number generator. If 'RANDOM' is unset, it loses - its special properties, even if it is subsequently reset. + integer between 0 and 32767. Assigning a value to ‘RANDOM’ + initializes (seeds) the sequence of random numbers. Seeding the + random number generator with the same constant value produces the + same sequence of values. If ‘RANDOM’ is unset, it loses its + special properties, even if it is subsequently reset. -'READLINE_ARGUMENT' +‘READLINE_ARGUMENT’ Any numeric argument given to a Readline command that was defined - using 'bind -x' (*note Bash Builtins:: when it was invoked. + using ‘bind -x’ (*note Bash Builtins:: when it was invoked. -'READLINE_LINE' - The contents of the Readline line buffer, for use with 'bind -x' +‘READLINE_LINE’ + The contents of the Readline line buffer, for use with ‘bind -x’ (*note Bash Builtins::). -'READLINE_MARK' - The position of the "mark" (saved insertion point) in the Readline - line buffer, for use with 'bind -x' (*note Bash Builtins::). The +‘READLINE_MARK’ + The position of the “mark” (saved insertion point) in the Readline + line buffer, for use with ‘bind -x’ (*note Bash Builtins::). The characters between the insertion point and the mark are often - called the "region". + called the “region”. -'READLINE_POINT' +‘READLINE_POINT’ The position of the insertion point in the Readline line buffer, - for use with 'bind -x' (*note Bash Builtins::). + for use with ‘bind -x’ (*note Bash Builtins::). -'REPLY' - The default variable for the 'read' builtin. +‘REPLY’ + The default variable for the ‘read’ builtin; set to the line read + when ‘read’ is not supplied a variable name argument. -'SECONDS' +‘SECONDS’ This variable expands to the number of seconds since the shell was started. Assignment to this variable resets the count to the value assigned, and the expanded value becomes the value assigned plus the number of seconds since the assignment. The number of seconds at shell invocation and the current time are always determined by - querying the system clock. If 'SECONDS' is unset, it loses its - special properties, even if it is subsequently reset. + querying the system clock at one-second resolution. If ‘SECONDS’ + is unset, it loses its special properties, even if it is + subsequently reset. -'SHELL' +‘SHELL’ This environment variable expands to the full pathname to the shell. If it is not set when the shell starts, Bash assigns to it the full pathname of the current user's login shell. -'SHELLOPTS' +‘SHELLOPTS’ A colon-separated list of enabled shell options. Each word in the - list is a valid argument for the '-o' option to the 'set' builtin + list is a valid argument for the ‘-o’ option to the ‘set’ builtin command (*note The Set Builtin::). The options appearing in - 'SHELLOPTS' are those reported as 'on' by 'set -o'. If this - variable is in the environment when Bash starts up, each shell - option in the list will be enabled before reading any startup - files. This variable is readonly. + ‘SHELLOPTS’ are those reported as ‘on’ by ‘set -o’. If this + variable is in the environment when Bash starts up, the shell + enables each option in the list before reading any startup files. + If this variable is exported, child shells will enable each option + in the list. This variable is readonly. -'SHLVL' +‘SHLVL’ Incremented by one each time a new instance of Bash is started. This is intended to be a count of how deeply your Bash shells are nested. -'SRANDOM' +‘SRANDOM’ This variable expands to a 32-bit pseudo-random number each time it is referenced. The random number generator is not linear on - systems that support '/dev/urandom' or 'arc4random', so each + systems that support ‘/dev/urandom’ or ‘arc4random’, so each returned number has no relationship to the numbers preceding it. The random number generator cannot be seeded, so assignments to - this variable have no effect. If 'SRANDOM' is unset, it loses its + this variable have no effect. If ‘SRANDOM’ is unset, it loses its special properties, even if it is subsequently reset. -'TIMEFORMAT' +‘TIMEFORMAT’ The value of this parameter is used as a format string specifying - how the timing information for pipelines prefixed with the 'time' - reserved word should be displayed. The '%' character introduces an + how the timing information for pipelines prefixed with the ‘time’ + reserved word should be displayed. The ‘%’ character introduces an escape sequence that is expanded to a time value or other information. The escape sequences and their meanings are as - follows; the braces denote optional portions. + follows; the brackets denote optional portions. - '%%' - A literal '%'. + ‘%%’ + A literal ‘%’. - '%[P][l]R' + ‘%[P][l]R’ The elapsed time in seconds. - '%[P][l]U' + ‘%[P][l]U’ The number of CPU seconds spent in user mode. - '%[P][l]S' + ‘%[P][l]S’ The number of CPU seconds spent in system mode. - '%P' + ‘%P’ The CPU percentage, computed as (%U + %S) / %R. The optional P is a digit specifying the precision, the number of fractional digits after a decimal point. A value of 0 causes no - decimal point or fraction to be output. At most three places after - the decimal point may be specified; values of P greater than 3 are - changed to 3. If P is not specified, the value 3 is used. + decimal point or fraction to be output. ‘time’ prints at most six + digits after the decimal point; values of P greater than 6 are + changed to 6. If P is not specified, ‘time’ prints three digits + after the decimal point. - The optional 'l' specifies a longer format, including minutes, of + The optional ‘l’ specifies a longer format, including minutes, of the form MMmSS.FFs. The value of P determines whether or not the fraction is included. If this variable is not set, Bash acts as if it had the value $'\nreal\t%3lR\nuser\t%3lU\nsys\t%3lS' - If the value is null, no timing information is displayed. A - trailing newline is added when the format string is displayed. + If the value is null, Bash does not display any timing information. + A trailing newline is added when the format string is displayed. -'TMOUT' - If set to a value greater than zero, 'TMOUT' is treated as the - default timeout for the 'read' builtin (*note Bash Builtins::). - The 'select' command (*note Conditional Constructs::) terminates if - input does not arrive after 'TMOUT' seconds when input is coming - from a terminal. +‘TMOUT’ + If set to a value greater than zero, the ‘read’ builtin uses the + value as its default timeout (*note Bash Builtins::). The ‘select’ + command (*note Conditional Constructs::) terminates if input does + not arrive after ‘TMOUT’ seconds when input is coming from a + terminal. In an interactive shell, the value is interpreted as the number of seconds to wait for a line of input after issuing the primary prompt. Bash terminates after waiting for that number of seconds if a complete line of input does not arrive. -'TMPDIR' +‘TMPDIR’ If set, Bash uses its value as the name of a directory in which Bash creates temporary files for the shell's use. -'UID' +‘UID’ The numeric real user id of the current user. This variable is readonly. @@ -5907,7 +6464,7 @@ This chapter describes features unique to Bash. * Bash Startup Files:: When and how Bash executes scripts. * Interactive Shells:: What an interactive shell is. * Bash Conditional Expressions:: Primitives used in composing expressions for - the 'test' builtin. + the ‘test’ builtin. * Shell Arithmetic:: Arithmetic on shell variables. * Aliases:: Substituting one command for another. * Arrays:: Array Variables. @@ -5932,138 +6489,146 @@ File: bash.info, Node: Invoking Bash, Next: Bash Startup Files, Up: Bash Feat bash [long-opt] -s [-abefhkmnptuvxdBCDHP] [-o OPTION] [-O SHOPT_OPTION] [ARGUMENT ...] - All of the single-character options used with the 'set' builtin + All of the single-character options used with the ‘set’ builtin (*note The Set Builtin::) can be used as options when the shell is invoked. In addition, there are several multi-character options that you can use. These options must appear on the command line before the single-character options to be recognized. -'--debugger' +‘--debugger’ Arrange for the debugger profile to be executed before the shell starts. Turns on extended debugging mode (see *note The Shopt - Builtin:: for a description of the 'extdebug' option to the 'shopt' + Builtin:: for a description of the ‘extdebug’ option to the ‘shopt’ builtin). -'--dump-po-strings' - A list of all double-quoted strings preceded by '$' is printed on - the standard output in the GNU 'gettext' PO (portable object) file - format. Equivalent to '-D' except for the output format. +‘--dump-po-strings’ + Print a list of all double-quoted strings preceded by ‘$’ on the + standard output in the GNU ‘gettext’ PO (portable object) file + format. Equivalent to ‘-D’ except for the output format. -'--dump-strings' - Equivalent to '-D'. +‘--dump-strings’ + Equivalent to ‘-D’. -'--help' +‘--help’ Display a usage message on standard output and exit successfully. -'--init-file FILENAME' -'--rcfile FILENAME' - Execute commands from FILENAME (instead of '~/.bashrc') in an +‘--init-file FILENAME’ +‘--rcfile FILENAME’ + Execute commands from FILENAME (instead of ‘~/.bashrc’) in an interactive shell. -'--login' - Equivalent to '-l'. +‘--login’ + Equivalent to ‘-l’. -'--noediting' +‘--noediting’ Do not use the GNU Readline library (*note Command Line Editing::) to read command lines when the shell is interactive. -'--noprofile' - Don't load the system-wide startup file '/etc/profile' or any of - the personal initialization files '~/.bash_profile', - '~/.bash_login', or '~/.profile' when Bash is invoked as a login +‘--noprofile’ + Don't load the system-wide startup file ‘/etc/profile’ or any of + the personal initialization files ‘~/.bash_profile’, + ‘~/.bash_login’, or ‘~/.profile’ when Bash is invoked as a login shell. -'--norc' - Don't read the '~/.bashrc' initialization file in an interactive - shell. This is on by default if the shell is invoked as 'sh'. +‘--norc’ + Don't read the ‘~/.bashrc’ initialization file in an interactive + shell. This is on by default if the shell is invoked as ‘sh’. -'--posix' - Change the behavior of Bash where the default operation differs - from the POSIX standard to match the standard. This is intended to - make Bash behave as a strict superset of that standard. *Note Bash - POSIX Mode::, for a description of the Bash POSIX mode. +‘--posix’ + Enable POSIX mode; change the behavior of Bash where the default + operation differs from the POSIX standard to match the standard. + This is intended to make Bash behave as a strict superset of that + standard. *Note Bash POSIX Mode::, for a description of the Bash + POSIX mode. -'--restricted' - Make the shell a restricted shell (*note The Restricted Shell::). +‘--restricted’ + Equivalent to ‘-r’. Make the shell a restricted shell (*note The + Restricted Shell::). -'--verbose' - Equivalent to '-v'. Print shell input lines as they're read. +‘--verbose’ + Equivalent to ‘-v’. Print shell input lines as they're read. -'--version' +‘--version’ Show version information for this instance of Bash on the standard output and exit successfully. There are several single-character options that may be supplied at -invocation which are not available with the 'set' builtin. +invocation which are not available with the ‘set’ builtin. -'-c' +‘-c’ Read and execute commands from the first non-option argument COMMAND_STRING, then exit. If there are arguments after the - COMMAND_STRING, the first argument is assigned to '$0' and any + COMMAND_STRING, the first argument is assigned to ‘$0’ and any remaining arguments are assigned to the positional parameters. The - assignment to '$0' sets the name of the shell, which is used in + assignment to ‘$0’ sets the name of the shell, which is used in warning and error messages. -'-i' +‘-i’ Force the shell to run interactively. Interactive shells are described in *note Interactive Shells::. -'-l' +‘-l’ Make this shell act as if it had been directly invoked by login. When the shell is interactive, this is equivalent to starting a - login shell with 'exec -l bash'. When the shell is not - interactive, the login shell startup files will be executed. 'exec - bash -l' or 'exec bash --login' will replace the current shell with - a Bash login shell. *Note Bash Startup Files::, for a description - of the special behavior of a login shell. + login shell with ‘exec -l bash’. When the shell is not + interactive, it will read and execute the login shell startup + files. ‘exec bash -l’ or ‘exec bash --login’ will replace the + current shell with a Bash login shell. *Note Bash Startup Files::, + for a description of the special behavior of a login shell. -'-r' +‘-r’ Make the shell a restricted shell (*note The Restricted Shell::). -'-s' +‘-s’ If this option is present, or if no arguments remain after option - processing, then commands are read from the standard input. This + processing, then Bash reads commands from the standard input. This option allows the positional parameters to be set when invoking an interactive shell or when reading input through a pipe. -'-D' - A list of all double-quoted strings preceded by '$' is printed on - the standard output. These are the strings that are subject to - language translation when the current locale is not 'C' or 'POSIX' - (*note Locale Translation::). This implies the '-n' option; no +‘-D’ + Print a list of all double-quoted strings preceded by ‘$’ on the + standard output. These are the strings that are subject to + language translation when the current locale is not ‘C’ or ‘POSIX’ + (*note Locale Translation::). This implies the ‘-n’ option; no commands will be executed. -'[-+]O [SHOPT_OPTION]' - SHOPT_OPTION is one of the shell options accepted by the 'shopt' +‘[-+]O [SHOPT_OPTION]’ + SHOPT_OPTION is one of the shell options accepted by the ‘shopt’ builtin (*note The Shopt Builtin::). If SHOPT_OPTION is present, - '-O' sets the value of that option; '+O' unsets it. If - SHOPT_OPTION is not supplied, the names and values of the shell - options accepted by 'shopt' are printed on the standard output. If - the invocation option is '+O', the output is displayed in a format + ‘-O’ sets the value of that option; ‘+O’ unsets it. If + SHOPT_OPTION is not supplied, Bash prints the names and values of + the shell options accepted by ‘shopt’ on the standard output. If + the invocation option is ‘+O’, the output is displayed in a format that may be reused as input. -'--' - A '--' signals the end of options and disables further option - processing. Any arguments after the '--' are treated as filenames - and arguments. +‘--’ + A ‘--’ signals the end of options and disables further option + processing. Any arguments after the ‘--’ are treated as a shell + script filename (*note Shell Scripts::) and arguments passed to + that script. - A _login_ shell is one whose first character of argument zero is '-', -or one invoked with the '--login' option. +‘-’ + Equivalent to ‘--’. - An _interactive_ shell is one started without non-option arguments, -unless '-s' is specified, without specifying the '-c' option, and whose -input and output are both connected to terminals (as determined by -'isatty(3)'), or one started with the '-i' option. *Note Interactive -Shells::, for more information. + A “login shell” is one whose first character of argument zero is ‘-’, +or one invoked with the ‘--login’ option. - If arguments remain after option processing, and neither the '-c' nor -the '-s' option has been supplied, the first argument is assumed to be -the name of a file containing shell commands (*note Shell Scripts::). -When Bash is invoked in this fashion, '$0' is set to the name of the -file, and the positional parameters are set to the remaining arguments. -Bash reads and executes commands from this file, then exits. Bash's -exit status is the exit status of the last command executed in the -script. If no commands are executed, the exit status is 0. + An “interactive shell” is one started without non-option arguments, +unless ‘-s’ is specified, without specifying the ‘-c’ option, and whose +standard input and standard error are both connected to terminals (as +determined by isatty(3)), or one started with the ‘-i’ option. *Note +Interactive Shells::, for more information. + + If arguments remain after option processing, and neither the ‘-c’ nor +the ‘-s’ option has been supplied, the first argument is treated as the +name of a file containing shell commands (*note Shell Scripts::). When +Bash is invoked in this fashion, ‘$0’ is set to the name of the file, +and the positional parameters are set to the remaining arguments. Bash +reads and executes commands from this file, then exits. Bash's exit +status is the exit status of the last command executed in the script. +If no commands are executed, the exit status is 0. Bash first attempts +to open the file in the current directory, and, if no file is found, +searches the directories in ‘PATH’ for the script.  File: bash.info, Node: Bash Startup Files, Next: Interactive Shells, Prev: Invoking Bash, Up: Bash Features @@ -6078,32 +6643,30 @@ Tilde Expansion::). Interactive shells are described in *note Interactive Shells::. -Invoked as an interactive login shell, or with '--login' +Invoked as an interactive login shell, or with ‘--login’ ........................................................ When Bash is invoked as an interactive login shell, or as a -non-interactive shell with the '--login' option, it first reads and -executes commands from the file '/etc/profile', if that file exists. -After reading that file, it looks for '~/.bash_profile', -'~/.bash_login', and '~/.profile', in that order, and reads and executes +non-interactive shell with the ‘--login’ option, it first reads and +executes commands from the file ‘/etc/profile’, if that file exists. +After reading that file, it looks for ‘~/.bash_profile’, +‘~/.bash_login’, and ‘~/.profile’, in that order, and reads and executes commands from the first one that exists and is readable. The -'--noprofile' option may be used when the shell is started to inhibit -this behavior. +‘--noprofile’ option inhibits this behavior. When an interactive login shell exits, or a non-interactive login -shell executes the 'exit' builtin command, Bash reads and executes -commands from the file '~/.bash_logout', if it exists. +shell executes the ‘exit’ builtin command, Bash reads and executes +commands from the file ‘~/.bash_logout’, if it exists. Invoked as an interactive non-login shell ......................................... -When an interactive shell that is not a login shell is started, Bash -reads and executes commands from '~/.bashrc', if that file exists. This -may be inhibited by using the '--norc' option. The '--rcfile FILE' -option will force Bash to read and execute commands from FILE instead of -'~/.bashrc'. +When Bash runs as an interactive shell that is not a login shell, it +reads and executes commands from ‘~/.bashrc’, if that file exists. The +‘--norc’ option inhibits this behavior. The ‘--rcfile FILE’ option +causes Bash to use FILE instead of ‘~/.bashrc’. - So, typically, your '~/.bash_profile' contains the line + So, typically, your ‘~/.bash_profile’ contains the line if [ -f ~/.bashrc ]; then . ~/.bashrc; fi after (or before) any login-specific initializations. @@ -6111,47 +6674,49 @@ Invoked non-interactively ......................... When Bash is started non-interactively, to run a shell script, for -example, it looks for the variable 'BASH_ENV' in the environment, +example, it looks for the variable ‘BASH_ENV’ in the environment, expands its value if it appears there, and uses the expanded value as the name of a file to read and execute. Bash behaves as if the following command were executed: if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi -but the value of the 'PATH' variable is not used to search for the +but does not the value of the ‘PATH’ variable to search for the filename. As noted above, if a non-interactive shell is invoked with the -'--login' option, Bash attempts to read and execute commands from the +‘--login’ option, Bash attempts to read and execute commands from the login shell startup files. -Invoked with name 'sh' +Invoked with name ‘sh’ ...................... -If Bash is invoked with the name 'sh', it tries to mimic the startup -behavior of historical versions of 'sh' as closely as possible, while +If Bash is invoked with the name ‘sh’, it tries to mimic the startup +behavior of historical versions of ‘sh’ as closely as possible, while conforming to the POSIX standard as well. When invoked as an interactive login shell, or as a non-interactive -shell with the '--login' option, it first attempts to read and execute -commands from '/etc/profile' and '~/.profile', in that order. The -'--noprofile' option may be used to inhibit this behavior. When invoked -as an interactive shell with the name 'sh', Bash looks for the variable -'ENV', expands its value if it is defined, and uses the expanded value -as the name of a file to read and execute. Since a shell invoked as -'sh' does not attempt to read and execute commands from any other -startup files, the '--rcfile' option has no effect. A non-interactive -shell invoked with the name 'sh' does not attempt to read any other -startup files. +shell with the ‘--login’ option, it first attempts to read and execute +commands from ‘/etc/profile’ and ‘~/.profile’, in that order. The +‘--noprofile’ option inhibits this behavior. + + When invoked as an interactive shell with the name ‘sh’, Bash looks +for the variable ‘ENV’, expands its value if it is defined, and uses the +expanded value as the name of a file to read and execute. Since a shell +invoked as ‘sh’ does not attempt to read and execute commands from any +other startup files, the ‘--rcfile’ option has no effect. + + A non-interactive shell invoked with the name ‘sh’ does not attempt +to read any other startup files. - When invoked as 'sh', Bash enters POSIX mode after the startup files -are read. + When invoked as ‘sh’, Bash enters POSIX mode after reading the +startup files. Invoked in POSIX mode ..................... -When Bash is started in POSIX mode, as with the '--posix' command line +When Bash is started in POSIX mode, as with the ‘--posix’ command line option, it follows the POSIX standard for startup files. In this mode, -interactive shells expand the 'ENV' variable and commands are read and -executed from the file whose name is the expanded value. No other +interactive shells expand the ‘ENV’ variable and read and execute +commands from the file whose name is the expanded value. No other startup files are read. Invoked by remote shell daemon @@ -6159,24 +6724,24 @@ Invoked by remote shell daemon Bash attempts to determine when it is being run with its standard input connected to a network connection, as when executed by the historical -remote shell daemon, usually 'rshd', or the secure shell daemon 'sshd'. -If Bash determines it is being run non-interactively in this fashion, it -reads and executes commands from '~/.bashrc', if that file exists and is -readable. It will not do this if invoked as 'sh'. The '--norc' option -may be used to inhibit this behavior, and the '--rcfile' option may be -used to force another file to be read, but neither 'rshd' nor 'sshd' -generally invoke the shell with those options or allow them to be -specified. +and rarely-seen remote shell daemon, usually ‘rshd’, or the secure shell +daemon ‘sshd’. If Bash determines it is being run non-interactively in +this fashion, it reads and executes commands from ‘~/.bashrc’, if that +file exists and is readable. Bash does not read this file if invoked as +‘sh’. The ‘--norc’ option inhibits this behavior, and the ‘--rcfile’ +option makes Bash use a different file instead of ‘~/.bashrc’, but +neither ‘rshd’ nor ‘sshd’ generally invoke the shell with those options +or allow them to be specified. Invoked with unequal effective and real UID/GIDs ................................................ If Bash is started with the effective user (group) id not equal to the -real user (group) id, and the '-p' option is not supplied, no startup +real user (group) id, and the ‘-p’ option is not supplied, no startup files are read, shell functions are not inherited from the environment, -the 'SHELLOPTS', 'BASHOPTS', 'CDPATH', and 'GLOBIGNORE' variables, if +the ‘SHELLOPTS’, ‘BASHOPTS’, ‘CDPATH’, and ‘GLOBIGNORE’ variables, if they appear in the environment, are ignored, and the effective user id -is set to the real user id. If the '-p' option is supplied at +is set to the real user id. If the ‘-p’ option is supplied at invocation, the startup behavior is the same, but the effective user id is not reset. @@ -6199,15 +6764,15 @@ File: bash.info, Node: What is an Interactive Shell?, Next: Is this Shell Inte ----------------------------------- An interactive shell is one started without non-option arguments (unless -'-s' is specified) and without specifying the '-c' option, whose input +‘-s’ is specified) and without specifying the ‘-c’ option, whose input and error output are both connected to terminals (as determined by -'isatty(3)'), or one started with the '-i' option. +‘isatty(3)’), or one started with the ‘-i’ option. An interactive shell generally reads from and writes to a user's terminal. - The '-s' invocation option may be used to set the positional -parameters when an interactive shell is started. + The ‘-s’ invocation option may be used to set the positional +parameters when an interactive shell starts.  File: bash.info, Node: Is this Shell Interactive?, Next: Interactive Shell Behavior, Prev: What is an Interactive Shell?, Up: Interactive Shells @@ -6216,15 +6781,15 @@ File: bash.info, Node: Is this Shell Interactive?, Next: Interactive Shell Beh -------------------------------- To determine within a startup script whether or not Bash is running -interactively, test the value of the '-' special parameter. It contains -'i' when the shell is interactive. For example: +interactively, test the value of the ‘-’ special parameter. It contains +‘i’ when the shell is interactive. For example: case "$-" in *i*) echo This shell is interactive ;; *) echo This shell is not interactive ;; esac - Alternatively, startup scripts may examine the variable 'PS1'; it is + Alternatively, startup scripts may examine the variable ‘PS1’; it is unset in non-interactive shells, and set in interactive shells. Thus: if [ -z "$PS1" ]; then @@ -6242,60 +6807,60 @@ File: bash.info, Node: Interactive Shell Behavior, Prev: Is this Shell Interac When the shell is running interactively, it changes its behavior in several ways. - 1. Startup files are read and executed as described in *note Bash + 1. Bash reads and executes startup files as described in *note Bash Startup Files::. 2. Job Control (*note Job Control::) is enabled by default. When job control is in effect, Bash ignores the keyboard-generated job - control signals 'SIGTTIN', 'SIGTTOU', and 'SIGTSTP'. + control signals ‘SIGTTIN’, ‘SIGTTOU’, and ‘SIGTSTP’. + + 3. Bash executes the values of the set elements of the + ‘PROMPT_COMMAND’ array variable as commands before printing the + primary prompt, ‘$PS1’ (*note Bash Variables::). - 3. Bash expands and displays 'PS1' before reading the first line of a - command, and expands and displays 'PS2' before reading the second + 4. Bash expands and displays ‘PS1’ before reading the first line of a + command, and expands and displays ‘PS2’ before reading the second and subsequent lines of a multi-line command. Bash expands and - displays 'PS0' after it reads a command but before executing it. + displays ‘PS0’ after it reads a command but before executing it. See *note Controlling the Prompt::, for a complete list of prompt string escape sequences. - 4. Bash executes the values of the set elements of the - 'PROMPT_COMMAND' array variable as commands before printing the - primary prompt, '$PS1' (*note Bash Variables::). - - 5. Readline (*note Command Line Editing::) is used to read commands + 5. Bash uses Readline (*note Command Line Editing::) to read commands from the user's terminal. - 6. Bash inspects the value of the 'ignoreeof' option to 'set -o' - instead of exiting immediately when it receives an 'EOF' on its + 6. Bash inspects the value of the ‘ignoreeof’ option to ‘set -o’ + instead of exiting immediately when it receives an ‘EOF’ on its standard input when reading a command (*note The Set Builtin::). - 7. Command history (*note Bash History Facilities::) and history - expansion (*note History Interaction::) are enabled by default. - Bash will save the command history to the file named by '$HISTFILE' - when a shell with history enabled exits. + 7. Bash enables Command history (*note Bash History Facilities::) and + history expansion (*note History Interaction::) by default. When a + shell with history enabled exits, Bash saves the command history to + the file named by ‘$HISTFILE’. 8. Alias expansion (*note Aliases::) is performed by default. - 9. In the absence of any traps, Bash ignores 'SIGTERM' (*note + 9. In the absence of any traps, Bash ignores ‘SIGTERM’ (*note Signals::). - 10. In the absence of any traps, 'SIGINT' is caught and handled (*note - Signals::). 'SIGINT' will interrupt some shell builtins. + 10. In the absence of any traps, ‘SIGINT’ is caught and handled (*note + Signals::). ‘SIGINT’ will interrupt some shell builtins. - 11. An interactive login shell sends a 'SIGHUP' to all jobs on exit if - the 'huponexit' shell option has been enabled (*note Signals::). + 11. An interactive login shell sends a ‘SIGHUP’ to all jobs on exit if + the ‘huponexit’ shell option has been enabled (*note Signals::). - 12. The '-n' invocation option is ignored, and 'set -n' has no effect - (*note The Set Builtin::). + 12. The ‘-n’ option has no effect, whether at invocation or when using + ‘set -n’ (*note The Set Builtin::). 13. Bash will check for mail periodically, depending on the values of - the 'MAIL', 'MAILPATH', and 'MAILCHECK' shell variables (*note Bash + the ‘MAIL’, ‘MAILPATH’, and ‘MAILCHECK’ shell variables (*note Bash Variables::). - 14. Expansion errors due to references to unbound shell variables - after 'set -u' has been enabled will not cause the shell to exit - (*note The Set Builtin::). + 14. The shell will not exit on expansion errors due to references to + unbound shell variables after ‘set -u’ has been enabled (*note The + Set Builtin::). 15. The shell will not exit on expansion errors caused by VAR being - unset or null in '${VAR:?WORD}' expansions (*note Shell Parameter + unset or null in ‘${VAR:?WORD}’ expansions (*note Shell Parameter Expansion::). 16. Redirection errors encountered by shell builtins will not cause @@ -6304,20 +6869,20 @@ several ways. 17. When running in POSIX mode, a special builtin returning an error status will not cause the shell to exit (*note Bash POSIX Mode::). - 18. A failed 'exec' will not cause the shell to exit (*note Bourne + 18. A failed ‘exec’ will not cause the shell to exit (*note Bourne Shell Builtins::). 19. Parser syntax errors will not cause the shell to exit. - 20. If the 'cdspell' shell option is enabled, the shell will attempt - simple spelling correction for directory arguments to the 'cd' - builtin (see the description of the 'cdspell' option to the 'shopt' - builtin in *note The Shopt Builtin::). The 'cdspell' option is + 20. If the ‘cdspell’ shell option is enabled, the shell will attempt + simple spelling correction for directory arguments to the ‘cd’ + builtin (see the description of the ‘cdspell’ option to the ‘shopt’ + builtin in *note The Shopt Builtin::). The ‘cdspell’ option is only effective in interactive shells. - 21. The shell will check the value of the 'TMOUT' variable and exit if + 21. The shell will check the value of the ‘TMOUT’ variable and exit if a command is not read within the specified number of seconds after - printing '$PS1' (*note Bash Variables::). + printing ‘$PS1’ (*note Bash Variables::).  File: bash.info, Node: Bash Conditional Expressions, Next: Shell Arithmetic, Prev: Interactive Shells, Up: Bash Features @@ -6325,149 +6890,158 @@ File: bash.info, Node: Bash Conditional Expressions, Next: Shell Arithmetic, 6.4 Bash Conditional Expressions ================================ -Conditional expressions are used by the '[[' compound command (*note -Conditional Constructs::) and the 'test' and '[' builtin commands (*note -Bourne Shell Builtins::). The 'test' and '[' commands determine their +Conditional expressions are used by the ‘[[’ compound command (*note +Conditional Constructs::) and the ‘test’ and ‘[’ builtin commands (*note +Bourne Shell Builtins::). The ‘test’ and ‘[’ commands determine their behavior based on the number of arguments; see the descriptions of those commands for any other command-specific actions. - Expressions may be unary or binary, and are formed from the following -primaries. Unary expressions are often used to examine the status of a -file. There are string operators and numeric comparison operators as -well. Bash handles several filenames specially when they are used in + Expressions may be unary or binary, and are formed from the primaries +listed below. Unary expressions are often used to examine the status of +a file or shell variable. Binary operators are used for string, +numeric, and file attribute comparisons. + + Bash handles several filenames specially when they are used in expressions. If the operating system on which Bash is running provides -these special files, Bash will use them; otherwise it will emulate them +these special files, Bash uses them; otherwise it emulates them internally with this behavior: If the FILE argument to one of the -primaries is of the form '/dev/fd/N', then file descriptor N is checked. -If the FILE argument to one of the primaries is one of '/dev/stdin', -'/dev/stdout', or '/dev/stderr', file descriptor 0, 1, or 2, -respectively, is checked. +primaries is of the form ‘/dev/fd/N’, then Bash checks file descriptor +N. If the FILE argument to one of the primaries is one of ‘/dev/stdin’, +‘/dev/stdout’, or ‘/dev/stderr’, Bash checks file descriptor 0, 1, or 2, +respectively. - When used with '[[', the '<' and '>' operators sort lexicographically -using the current locale. The 'test' command uses ASCII ordering. + When used with ‘[[’, the ‘<’ and ‘>’ operators sort lexicographically +using the current locale. The ‘test’ command uses ASCII ordering. Unless otherwise specified, primaries that operate on files follow symbolic links and operate on the target of the link, rather than the link itself. -'-a FILE' +‘-a FILE’ True if FILE exists. -'-b FILE' +‘-b FILE’ True if FILE exists and is a block special file. -'-c FILE' +‘-c FILE’ True if FILE exists and is a character special file. -'-d FILE' +‘-d FILE’ True if FILE exists and is a directory. -'-e FILE' +‘-e FILE’ True if FILE exists. -'-f FILE' +‘-f FILE’ True if FILE exists and is a regular file. -'-g FILE' +‘-g FILE’ True if FILE exists and its set-group-id bit is set. -'-h FILE' +‘-h FILE’ True if FILE exists and is a symbolic link. -'-k FILE' +‘-k FILE’ True if FILE exists and its "sticky" bit is set. -'-p FILE' +‘-p FILE’ True if FILE exists and is a named pipe (FIFO). -'-r FILE' +‘-r FILE’ True if FILE exists and is readable. -'-s FILE' +‘-s FILE’ True if FILE exists and has a size greater than zero. -'-t FD' +‘-t FD’ True if file descriptor FD is open and refers to a terminal. -'-u FILE' +‘-u FILE’ True if FILE exists and its set-user-id bit is set. -'-w FILE' +‘-w FILE’ True if FILE exists and is writable. -'-x FILE' +‘-x FILE’ True if FILE exists and is executable. -'-G FILE' +‘-G FILE’ True if FILE exists and is owned by the effective group id. -'-L FILE' +‘-L FILE’ True if FILE exists and is a symbolic link. -'-N FILE' - True if FILE exists and has been modified since it was last read. +‘-N FILE’ + True if FILE exists and has been modified since it was last + accessed. -'-O FILE' +‘-O FILE’ True if FILE exists and is owned by the effective user id. -'-S FILE' +‘-S FILE’ True if FILE exists and is a socket. -'FILE1 -ef FILE2' +‘FILE1 -ef FILE2’ True if FILE1 and FILE2 refer to the same device and inode numbers. -'FILE1 -nt FILE2' +‘FILE1 -nt FILE2’ True if FILE1 is newer (according to modification date) than FILE2, or if FILE1 exists and FILE2 does not. -'FILE1 -ot FILE2' +‘FILE1 -ot FILE2’ True if FILE1 is older than FILE2, or if FILE2 exists and FILE1 does not. -'-o OPTNAME' +‘-o OPTNAME’ True if the shell option OPTNAME is enabled. The list of options - appears in the description of the '-o' option to the 'set' builtin + appears in the description of the ‘-o’ option to the ‘set’ builtin (*note The Set Builtin::). -'-v VARNAME' +‘-v VARNAME’ True if the shell variable VARNAME is set (has been assigned a - value). + value). If VARNAME is an indexed array variable name subscripted + by ‘@’ or ‘*’, this returns true if the array has any set elements. + If VARNAME is an associative array variable name subscripted by ‘@’ + or ‘*’, this returns true if an element with that key is set. -'-R VARNAME' +‘-R VARNAME’ True if the shell variable VARNAME is set and is a name reference. -'-z STRING' +‘-z STRING’ True if the length of STRING is zero. -'-n STRING' -'STRING' +‘-n STRING’ +‘STRING’ True if the length of STRING is non-zero. -'STRING1 == STRING2' -'STRING1 = STRING2' - True if the strings are equal. When used with the '[[' command, +‘STRING1 == STRING2’ +‘STRING1 = STRING2’ + True if the strings are equal. When used with the ‘[[’ command, this performs pattern matching as described above (*note Conditional Constructs::). - '=' should be used with the 'test' command for POSIX conformance. + ‘=’ should be used with the ‘test’ command for POSIX conformance. -'STRING1 != STRING2' +‘STRING1 != STRING2’ True if the strings are not equal. -'STRING1 < STRING2' +‘STRING1 < STRING2’ True if STRING1 sorts before STRING2 lexicographically. -'STRING1 > STRING2' +‘STRING1 > STRING2’ True if STRING1 sorts after STRING2 lexicographically. -'ARG1 OP ARG2' - 'OP' is one of '-eq', '-ne', '-lt', '-le', '-gt', or '-ge'. These +‘ARG1 OP ARG2’ + ‘OP’ is one of ‘-eq’, ‘-ne’, ‘-lt’, ‘-le’, ‘-gt’, or ‘-ge’. These arithmetic binary operators return true if ARG1 is equal to, not equal to, less than, less than or equal to, greater than, or greater than or equal to ARG2, respectively. ARG1 and ARG2 may be - positive or negative integers. When used with the '[[' command, + positive or negative integers. When used with the ‘[[’ command, ARG1 and ARG2 are evaluated as arithmetic expressions (*note Shell - Arithmetic::). + Arithmetic::). Since the expansions the ‘[[’ command performs on + ARG1 and ARG2 can potentially result in empty strings, arithmetic + expression evaluation treats those as expressions that evaluate to + 0.  File: bash.info, Node: Shell Arithmetic, Next: Aliases, Prev: Bash Conditional Expressions, Up: Bash Features @@ -6476,94 +7050,99 @@ File: bash.info, Node: Shell Arithmetic, Next: Aliases, Prev: Bash Conditiona ==================== The shell allows arithmetic expressions to be evaluated, as one of the -shell expansions or by using the '((' compound command, the 'let' -builtin, or the '-i' option to the 'declare' builtin. - - Evaluation is done in fixed-width integers with no check for -overflow, though division by 0 is trapped and flagged as an error. The -operators and their precedence, associativity, and values are the same -as in the C language. The following list of operators is grouped into -levels of equal-precedence operators. The levels are listed in order of -decreasing precedence. - -'ID++ ID--' +shell expansions or by using the ‘((’ compound command, the ‘let’ and +‘declare’ builtins, the arithmetic ‘for’ command, the ‘[[’ conditional +command, or the ‘-i’ option to the ‘declare’ builtin. + + Evaluation is done in the largest fixed-width integers available, +with no check for overflow, though division by 0 is trapped and flagged +as an error. The operators and their precedence, associativity, and +values are the same as in the C language. The following list of +operators is grouped into levels of equal-precedence operators. The +levels are listed in order of decreasing precedence. + +‘ID++ ID--’ variable post-increment and post-decrement -'++ID --ID' +‘++ID --ID’ variable pre-increment and pre-decrement -'- +' +‘- +’ unary minus and plus -'! ~' +‘! ~’ logical and bitwise negation -'**' +‘**’ exponentiation -'* / %' +‘* / %’ multiplication, division, remainder -'+ -' +‘+ -’ addition, subtraction -'<< >>' +‘<< >>’ left and right bitwise shifts -'<= >= < >' +‘<= >= < >’ comparison -'== !=' +‘== !=’ equality and inequality -'&' +‘&’ bitwise AND -'^' +‘^’ bitwise exclusive OR -'|' +‘|’ bitwise OR -'&&' +‘&&’ logical AND -'||' +‘||’ logical OR -'expr ? expr : expr' +‘expr ? if-true-expr : if-false-expr’ conditional operator -'= *= /= %= += -= <<= >>= &= ^= |=' +‘= *= /= %= += -= <<= >>= &= ^= |=’ assignment -'expr1 , expr2' +‘expr1 , expr2’ comma Shell variables are allowed as operands; parameter expansion is performed before the expression is evaluated. Within an expression, shell variables may also be referenced by name without using the -parameter expansion syntax. A shell variable that is null or unset -evaluates to 0 when referenced by name without using the parameter -expansion syntax. The value of a variable is evaluated as an arithmetic -expression when it is referenced, or when a variable which has been -given the 'integer' attribute using 'declare -i' is assigned a value. A -null value evaluates to 0. A shell variable need not have its 'integer' -attribute turned on to be used in an expression. +parameter expansion syntax. This means you can use X, where X is a +shell variable name, in an arithmetic expression, and the shell will +evaluate its value as an expression and use the result. A shell +variable that is null or unset evaluates to 0 when referenced by name in +an expression. + + The value of a variable is evaluated as an arithmetic expression when +it is referenced, or when a variable which has been given the ‘integer’ +attribute using ‘declare -i’ is assigned a value. A null value +evaluates to 0. A shell variable need not have its ‘integer’ attribute +turned on to be used in an expression. Integer constants follow the C language definition, without suffixes or character constants. Constants with a leading 0 are interpreted as -octal numbers. A leading '0x' or '0X' denotes hexadecimal. Otherwise, -numbers take the form [BASE'#']N, where the optional BASE is a decimal +octal numbers. A leading ‘0x’ or ‘0X’ denotes hexadecimal. Otherwise, +numbers take the form [BASE‘#’]N, where the optional BASE is a decimal number between 2 and 64 representing the arithmetic base, and N is a -number in that base. If BASE'#' is omitted, then base 10 is used. When +number in that base. If BASE‘#’ is omitted, then base 10 is used. When specifying N, if a non-digit is required, the digits greater than 9 are -represented by the lowercase letters, the uppercase letters, '@', and -'_', in that order. If BASE is less than or equal to 36, lowercase and +represented by the lowercase letters, the uppercase letters, ‘@’, and +‘_’, in that order. If BASE is less than or equal to 36, lowercase and uppercase letters may be used interchangeably to represent numbers between 10 and 35. - Operators are evaluated in order of precedence. Sub-expressions in + Operators are evaluated in precedence order. Sub-expressions in parentheses are evaluated first and may override the precedence rules above. @@ -6573,33 +7152,39 @@ File: bash.info, Node: Aliases, Next: Arrays, Prev: Shell Arithmetic, Up: Ba 6.6 Aliases =========== -"Aliases" allow a string to be substituted for a word when it is used as -the first word of a simple command. The shell maintains a list of -aliases that may be set and unset with the 'alias' and 'unalias' builtin -commands. - - The first word of each simple command, if unquoted, is checked to see -if it has an alias. If so, that word is replaced by the text of the -alias. The characters '/', '$', '`', '=' and any of the shell -metacharacters or quoting characters listed above may not appear in an -alias name. The replacement text may contain any valid shell input, -including shell metacharacters. The first word of the replacement text -is tested for aliases, but a word that is identical to an alias being -expanded is not expanded a second time. This means that one may alias -'ls' to '"ls -F"', for instance, and Bash does not try to recursively -expand the replacement text. If the last character of the alias value -is a 'blank', then the next command word following the alias is also -checked for alias expansion. - - Aliases are created and listed with the 'alias' command, and removed -with the 'unalias' command. +“Aliases” allow a string to be substituted for a word that is in a +position in the input where it can be the first word of a simple +command. Aliases have names and corresponding values that are set and +unset using the ‘alias’ and ‘unalias’ builtin commands (*note Shell +Builtin Commands::). + + If the shell reads an unquoted word in the right position, it checks +the word to see if it matches an alias name. If it matches, the shell +replaces the word with the alias value, and reads that value as if it +had been read instead of the word. The shell doesn't look at any +characters following the word before attempting alias substitution. + + The characters ‘/’, ‘$’, ‘`’, ‘=’ and any of the shell metacharacters +or quoting characters listed above may not appear in an alias name. The +replacement text may contain any valid shell input, including shell +metacharacters. The first word of the replacement text is tested for +aliases, but a word that is identical to an alias being expanded is not +expanded a second time. This means that one may alias ‘ls’ to ‘"ls +-F"’, for instance, and Bash does not try to recursively expand the +replacement text. + + If the last character of the alias value is a ‘blank’, then the shell +checks the next command word following the alias for alias expansion. + + Aliases are created and listed with the ‘alias’ command, and removed +with the ‘unalias’ command. There is no mechanism for using arguments in the replacement text, as -in 'csh'. If arguments are needed, use a shell function (*note Shell -Functions::). +in ‘csh’. If arguments are needed, use a shell function (*note Shell +Functions::) instead. Aliases are not expanded when the shell is not interactive, unless -the 'expand_aliases' shell option is set using 'shopt' (*note The Shopt +the ‘expand_aliases’ shell option is set using ‘shopt’ (*note The Shopt Builtin::). The rules concerning the definition and use of aliases are somewhat @@ -6608,16 +7193,19 @@ all lines that make up a compound command, before executing any of the commands on that line or the compound command. Aliases are expanded when a command is read, not when it is executed. Therefore, an alias definition appearing on the same line as another command does not take -effect until the next line of input is read. The commands following the -alias definition on that line are not affected by the new alias. This -behavior is also an issue when functions are executed. Aliases are -expanded when a function definition is read, not when the function is -executed, because a function definition is itself a command. As a -consequence, aliases defined in a function are not available until after -that function is executed. To be safe, always put alias definitions on -a separate line, and do not use 'alias' in compound commands. +effect until the shell reads the next line of input, and an alias +definition in a compound command does not take effect until the shell +parses and executes the entire compound command. The commands following +the alias definition on that line, or in the rest of a compound command, +are not affected by the new alias. This behavior is also an issue when +functions are executed. Aliases are expanded when a function definition +is read, not when the function is executed, because a function +definition is itself a command. As a consequence, aliases defined in a +function are not available until after that function is executed. To be +safe, always put alias definitions on a separate line, and do not use +‘alias’ in compound commands. - For almost every purpose, shell functions are preferred over aliases. + For almost every purpose, shell functions are preferable to aliases.  File: bash.info, Node: Arrays, Next: The Directory Stack, Prev: Aliases, Up: Bash Features @@ -6626,42 +7214,57 @@ File: bash.info, Node: Arrays, Next: The Directory Stack, Prev: Aliases, Up: ========== Bash provides one-dimensional indexed and associative array variables. -Any variable may be used as an indexed array; the 'declare' builtin will -explicitly declare an array. There is no maximum limit on the size of +Any variable may be used as an indexed array; the ‘declare’ builtin +explicitly declares an array. There is no maximum limit on the size of an array, nor any requirement that members be indexed or assigned -contiguously. Indexed arrays are referenced using integers (including -arithmetic expressions (*note Shell Arithmetic::)) and are zero-based; -associative arrays use arbitrary strings. Unless otherwise noted, -indexed array indices must be non-negative integers. - - An indexed array is created automatically if any variable is assigned -to using the syntax +contiguously. Indexed arrays are referenced using arithmetic +expressions that must expand to an integer (*note Shell Arithmetic::)) +and are zero-based; associative arrays use arbitrary strings. Unless +otherwise noted, indexed array indices must be non-negative integers. + + The shell performs parameter and variable expansion, arithmetic +expansion, command substitution, and quote removal on indexed array +subscripts. Since this can potentially result in empty strings, +subscript indexing treats those as expressions that evaluate to 0. + + The shell performs tilde expansion, parameter and variable expansion, +arithmetic expansion, command substitution, and quote removal on +associative array subscripts. Empty strings cannot be used as +associative array keys. + + Bash automatically creates an indexed array if any variable is +assigned to using the syntax NAME[SUBSCRIPT]=VALUE The SUBSCRIPT is treated as an arithmetic expression that must evaluate -to a number. To explicitly declare an array, use +to a number greater than or equal to zero. To explicitly declare an +indexed array, use declare -a NAME -The syntax +(*note Bash Builtins::). The syntax declare -a NAME[SUBSCRIPT] is also accepted; the SUBSCRIPT is ignored. Associative arrays are created using declare -A NAME - Attributes may be specified for an array variable using the 'declare' -and 'readonly' builtins. Each attribute applies to all members of an + Attributes may be specified for an array variable using the ‘declare’ +and ‘readonly’ builtins. Each attribute applies to all members of an array. - Arrays are assigned to using compound assignments of the form + Arrays are assigned using compound assignments of the form NAME=(VALUE1 VALUE2 ... ) -where each VALUE may be of the form '[SUBSCRIPT]='STRING. Indexed array -assignments do not require anything but STRING. When assigning to -indexed arrays, if the optional subscript is supplied, that index is -assigned to; otherwise the index of the element assigned is the last -index assigned to by the statement plus one. Indexing starts at zero. +where each VALUE may be of the form ‘[SUBSCRIPT]=’STRING. Indexed array +assignments do not require anything but STRING. - Each VALUE in the list undergoes all the shell expansions described -above (*note Shell Expansions::). + Each VALUE in the list undergoes the shell expansions described above +(*note Shell Expansions::), but VALUEs that are valid variable +assignments including the brackets and subscript do not undergo brace +expansion and word splitting, as with individual variable assignments. + + When assigning to indexed arrays, if the optional subscript is +supplied, that index is assigned to; otherwise the index of the element +assigned is the last index assigned to by the statement plus one. +Indexing starts at zero. When assigning to an associative array, the words in a compound assignment may be either assignment statements, for which the subscript @@ -6673,8 +7276,8 @@ interpreted; all assignments in a list must be of the same type. When using key/value pairs, the keys may not be missing or empty; a final missing value is treated like the empty string. - This syntax is also accepted by the 'declare' builtin. Individual -array elements may be assigned to using the 'NAME[SUBSCRIPT]=VALUE' + This syntax is also accepted by the ‘declare’ builtin. Individual +array elements may be assigned to using the ‘NAME[SUBSCRIPT]=VALUE’ syntax introduced above. When assigning to an indexed array, if NAME is subscripted by a @@ -6682,34 +7285,38 @@ negative number, that number is interpreted as relative to one greater than the maximum index of NAME, so negative indices count back from the end of the array, and an index of -1 references the last element. - The '+=' operator will append to an array variable when assigning -using the compound assignment syntax; see *note Shell Parameters:: -above. - - Any element of an array may be referenced using '${NAME[SUBSCRIPT]}'. -The braces are required to avoid conflicts with the shell's filename -expansion operators. If the SUBSCRIPT is '@' or '*', the word expands -to all members of the array NAME. These subscripts differ only when the -word appears within double quotes. If the word is double-quoted, -'${NAME[*]}' expands to a single word with the value of each array -member separated by the first character of the 'IFS' variable, and -'${NAME[@]}' expands each element of NAME to a separate word. When -there are no array members, '${NAME[@]}' expands to nothing. If the -double-quoted expansion occurs within a word, the expansion of the first -parameter is joined with the beginning part of the original word, and -the expansion of the last parameter is joined with the last part of the -original word. This is analogous to the expansion of the special -parameters '@' and '*'. '${#NAME[SUBSCRIPT]}' expands to the length of -'${NAME[SUBSCRIPT]}'. If SUBSCRIPT is '@' or '*', the expansion is the -number of elements in the array. If the SUBSCRIPT used to reference an -element of an indexed array evaluates to a number less than zero, it is -interpreted as relative to one greater than the maximum index of the -array, so negative indices count back from the end of the array, and an -index of -1 refers to the last element. + The ‘+=’ operator appends to an array variable when assigning using +the compound assignment syntax; see *note Shell Parameters:: above. + + An array element is referenced using ‘${NAME[SUBSCRIPT]}’. The +braces are required to avoid conflicts with the shell's filename +expansion operators. If the SUBSCRIPT is ‘@’ or ‘*’, the word expands +to all members of the array NAME, unless otherwise noted in the +description of a builtin or word expansion. These subscripts differ +only when the word appears within double quotes. If the word is +double-quoted, ‘${NAME[*]}’ expands to a single word with the value of +each array member separated by the first character of the ‘IFS’ +variable, and ‘${NAME[@]}’ expands each element of NAME to a separate +word. When there are no array members, ‘${NAME[@]}’ expands to nothing. +If the double-quoted expansion occurs within a word, the expansion of +the first parameter is joined with the beginning part of the expansion +of the original word, and the expansion of the last parameter is joined +with the last part of the expansion of the original word. This is +analogous to the expansion of the special parameters ‘@’ and ‘*’. + + ‘${#NAME[SUBSCRIPT]}’ expands to the length of ‘${NAME[SUBSCRIPT]}’. +If SUBSCRIPT is ‘@’ or ‘*’, the expansion is the number of elements in +the array. + + If the SUBSCRIPT used to reference an element of an indexed array +evaluates to a number less than zero, it is interpreted as relative to +one greater than the maximum index of the array, so negative indices +count back from the end of the array, and an index of -1 refers to the +last element. Referencing an array variable without a subscript is equivalent to referencing with a subscript of 0. Any reference to a variable using a -valid subscript is legal, and 'bash' will create an array if necessary. +valid subscript is valid; Bash creates an array if necessary. An array variable is considered set if a subscript has been assigned a value. The null string is a valid value. @@ -6717,34 +7324,36 @@ a value. The null string is a valid value. It is possible to obtain the keys (indices) of an array as well as the values. ${!NAME[@]} and ${!NAME[*]} expand to the indices assigned in array variable NAME. The treatment when in double quotes is similar -to the expansion of the special parameters '@' and '*' within double +to the expansion of the special parameters ‘@’ and ‘*’ within double quotes. - The 'unset' builtin is used to destroy arrays. 'unset -NAME[SUBSCRIPT]' destroys the array element at index SUBSCRIPT. -Negative subscripts to indexed arrays are interpreted as described -above. Unsetting the last element of an array variable does not unset -the variable. 'unset NAME', where NAME is an array, removes the entire -array. 'unset NAME[SUBSCRIPT]' behaves differently depending on the -array type when given a subscript of '*' or '@'. When NAME is an -associative array, it removes the element with key '*' or '@'. If NAME -is an indexed array, 'unset' removes all of the elements, but does not -remove the array itself. + The ‘unset’ builtin is used to destroy arrays. ‘unset +NAME[SUBSCRIPT]’ unsets the array element at index SUBSCRIPT. Negative +subscripts to indexed arrays are interpreted as described above. +Unsetting the last element of an array variable does not unset the +variable. ‘unset NAME’, where NAME is an array, removes the entire +array. ‘unset NAME[SUBSCRIPT]’ behaves differently depending on the +array type when SUBSCRIPT is ‘*’ or ‘@’. When NAME is an associative +array, it removes the element with key ‘*’ or ‘@’. If NAME is an +indexed array, ‘unset’ removes all of the elements, but does not remove +the array itself. When using a variable name with a subscript as an argument to a -command, such as with 'unset', without using the word expansion syntax -described above, the argument is subject to the shell's filename -expansion. If filename expansion is not desired, the argument should be -quoted. - - The 'declare', 'local', and 'readonly' builtins each accept a '-a' -option to specify an indexed array and a '-A' option to specify an -associative array. If both options are supplied, '-A' takes precedence. -The 'read' builtin accepts a '-a' option to assign a list of words read +command, such as with ‘unset’, without using the word expansion syntax +described above (e.g., unset a[4]), the argument is subject to the +shell's filename expansion. Quote the argument if pathname expansion is +not desired (e.g., unset 'a[4]'). + + The ‘declare’, ‘local’, and ‘readonly’ builtins each accept a ‘-a’ +option to specify an indexed array and a ‘-A’ option to specify an +associative array. If both options are supplied, ‘-A’ takes precedence. +The ‘read’ builtin accepts a ‘-a’ option to assign a list of words read from the standard input to an array, and can read values from the -standard input into individual array elements. The 'set' and 'declare' +standard input into individual array elements. The ‘set’ and ‘declare’ builtins display array values in a way that allows them to be reused as -input. +input. Other builtins accept array name arguments as well (e.g., +‘mapfile’); see the descriptions of individual builtins for details. +The shell provides a number of builtin array variables.  File: bash.info, Node: The Directory Stack, Next: Controlling the Prompt, Prev: Arrays, Up: Bash Features @@ -6758,14 +7367,14 @@ File: bash.info, Node: The Directory Stack, Next: Controlling the Prompt, Pre the directory stack. The directory stack is a list of recently-visited directories. The -'pushd' builtin adds directories to the stack as it changes the current -directory, and the 'popd' builtin removes specified directories from the +‘pushd’ builtin adds directories to the stack as it changes the current +directory, and the ‘popd’ builtin removes specified directories from the stack and changes the current directory to the directory removed. The -'dirs' builtin displays the contents of the directory stack. The +‘dirs’ builtin displays the contents of the directory stack. The current directory is always the "top" of the directory stack. The contents of the directory stack are also visible as the value of -the 'DIRSTACK' shell variable. +the ‘DIRSTACK’ shell variable.  File: bash.info, Node: Directory Stack Builtins, Up: The Directory Stack @@ -6773,105 +7382,105 @@ File: bash.info, Node: Directory Stack Builtins, Up: The Directory Stack 6.8.1 Directory Stack Builtins ------------------------------ -'dirs' +‘dirs’ dirs [-clpv] [+N | -N] - Display the list of currently remembered directories. Directories - are added to the list with the 'pushd' command; the 'popd' command - removes directories from the list. The current directory is always - the first directory in the stack. + Without options, display the list of currently remembered + directories. Directories are added to the list with the ‘pushd’ + command; the ‘popd’ command removes directories from the list. The + current directory is always the first directory in the stack. + + Options, if supplied, have the following meanings: - '-c' + ‘-c’ Clears the directory stack by deleting all of the elements. - '-l' + ‘-l’ Produces a listing using full pathnames; the default listing format uses a tilde to denote the home directory. - '-p' - Causes 'dirs' to print the directory stack with one entry per + ‘-p’ + Causes ‘dirs’ to print the directory stack with one entry per line. - '-v' - Causes 'dirs' to print the directory stack with one entry per + ‘-v’ + Causes ‘dirs’ to print the directory stack with one entry per line, prefixing each entry with its index in the stack. - '+N' + ‘+N’ Displays the Nth directory (counting from the left of the list - printed by 'dirs' when invoked without options), starting with + printed by ‘dirs’ when invoked without options), starting with zero. - '-N' + ‘-N’ Displays the Nth directory (counting from the right of the - list printed by 'dirs' when invoked without options), starting + list printed by ‘dirs’ when invoked without options), starting with zero. -'popd' +‘popd’ popd [-n] [+N | -N] - Removes elements from the directory stack. The elements are - numbered from 0 starting at the first directory listed by 'dirs'; - that is, 'popd' is equivalent to 'popd +0'. + Remove elements from the directory stack. The elements are + numbered from 0 starting at the first directory listed by ‘dirs’; + that is, ‘popd’ is equivalent to ‘popd +0’. - When no arguments are given, 'popd' removes the top directory from + When no arguments are given, ‘popd’ removes the top directory from the stack and changes to the new top directory. Arguments, if supplied, have the following meanings: - '-n' - Suppresses the normal change of directory when removing - directories from the stack, so that only the stack is - manipulated. - '+N' - Removes the Nth directory (counting from the left of the list - printed by 'dirs'), starting with zero, from the stack. - '-N' - Removes the Nth directory (counting from the right of the list - printed by 'dirs'), starting with zero, from the stack. - - If the top element of the directory stack is modified, and the '-n' - option was not supplied, 'popd' uses the 'cd' builtin to change to - the directory at the top of the stack. If the 'cd' fails, 'popd' + ‘-n’ + Suppress the normal change of directory when removing + directories from the stack, only manipulate the stack. + ‘+N’ + Remove the Nth directory (counting from the left of the list + printed by ‘dirs’), starting with zero, from the stack. + ‘-N’ + Remove the Nth directory (counting from the right of the list + printed by ‘dirs’), starting with zero, from the stack. + + If the top element of the directory stack is modified, and the ‘-n’ + option was not supplied, ‘popd’ uses the ‘cd’ builtin to change to + the directory at the top of the stack. If the ‘cd’ fails, ‘popd’ returns a non-zero value. - Otherwise, 'popd' returns an unsuccessful status if an invalid - option is encountered, the directory stack is empty, or a - non-existent directory stack entry is specified. + Otherwise, ‘popd’ returns an unsuccessful status if an invalid + option is specified, the directory stack is empty, or N specifies a + non-existent directory stack entry. - If the 'popd' command is successful, Bash runs 'dirs' to show the + If the ‘popd’ command is successful, Bash runs ‘dirs’ to show the final contents of the directory stack, and the return status is 0. -'pushd' +‘pushd’ pushd [-n] [+N | -N | DIR] - Adds a directory to the top of the directory stack, or rotates the + Add a directory to the top of the directory stack, or rotate the stack, making the new top of the stack the current working - directory. With no arguments, 'pushd' exchanges the top two + directory. With no arguments, ‘pushd’ exchanges the top two elements of the directory stack. Arguments, if supplied, have the following meanings: - '-n' - Suppresses the normal change of directory when rotating or - adding directories to the stack, so that only the stack is - manipulated. - '+N' - Brings the Nth directory (counting from the left of the list - printed by 'dirs', starting with zero) to the top of the list - by rotating the stack. - '-N' - Brings the Nth directory (counting from the right of the list - printed by 'dirs', starting with zero) to the top of the list - by rotating the stack. - 'DIR' - Makes DIR be the top of the stack. - - After the stack has been modified, if the '-n' option was not - supplied, 'pushd' uses the 'cd' builtin to change to the directory - at the top of the stack. If the 'cd' fails, 'pushd' returns a + ‘-n’ + Suppress the normal change of directory when rotating or + adding directories to the stack, only manipulate the stack. + ‘+N’ + Rotate the stack so that the Nth directory (counting from the + left of the list printed by ‘dirs’, starting with zero) is at + the top. + ‘-N’ + Rotate the stack so that the Nth directory (counting from the + right of the list printed by ‘dirs’, starting with zero) is at + the top. + ‘DIR’ + Make DIR be the top of the stack. + + After the stack has been modified, if the ‘-n’ option was not + supplied, ‘pushd’ uses the ‘cd’ builtin to change to the directory + at the top of the stack. If the ‘cd’ fails, ‘pushd’ returns a non-zero value. - Otherwise, if no arguments are supplied, 'pushd' returns 0 unless - the directory stack is empty. When rotating the directory stack, - 'pushd' returns 0 unless the directory stack is empty or a - non-existent directory stack element is specified. + Otherwise, if no arguments are supplied, ‘pushd’ returns zero + unless the directory stack is empty. When rotating the directory + stack, ‘pushd’ returns zero unless the directory stack is empty or + N specifies a non-existent directory stack element. - If the 'pushd' command is successful, Bash runs 'dirs' to show the + If the ‘pushd’ command is successful, Bash runs ‘dirs’ to show the final contents of the directory stack.  @@ -6880,72 +7489,67 @@ File: bash.info, Node: Controlling the Prompt, Next: The Restricted Shell, Pr 6.9 Controlling the Prompt ========================== -Bash examines the value of the array variable 'PROMPT_COMMAND' just -before printing each primary prompt. If any elements in -'PROMPT_COMMAND' are set and non-null, Bash executes each value, in -numeric order, just as if it had been typed on the command line. - - In addition, the following table describes the special characters -which can appear in the prompt variables 'PS0', 'PS1', 'PS2', and 'PS4': +In addition, the following table describes the special characters which +can appear in the prompt variables ‘PS0’, ‘PS1’, ‘PS2’, and ‘PS4’: -'\a' +‘\a’ A bell character. -'\d' +‘\d’ The date, in "Weekday Month Date" format (e.g., "Tue May 26"). -'\D{FORMAT}' - The FORMAT is passed to 'strftime'(3) and the result is inserted +‘\D{FORMAT}’ + The FORMAT is passed to ‘strftime’(3) and the result is inserted into the prompt string; an empty FORMAT results in a locale-specific time representation. The braces are required. -'\e' +‘\e’ An escape character. -'\h' - The hostname, up to the first '.'. -'\H' +‘\h’ + The hostname, up to the first ‘.’. +‘\H’ The hostname. -'\j' +‘\j’ The number of jobs currently managed by the shell. -'\l' - The basename of the shell's terminal device name. -'\n' +‘\l’ + The basename of the shell's terminal device name (e.g., "ttys0"). +‘\n’ A newline. -'\r' +‘\r’ A carriage return. -'\s' - The name of the shell, the basename of '$0' (the portion following +‘\s’ + The name of the shell: the basename of ‘$0’ (the portion following the final slash). -'\t' +‘\t’ The time, in 24-hour HH:MM:SS format. -'\T' +‘\T’ The time, in 12-hour HH:MM:SS format. -'\@' +‘\@’ The time, in 12-hour am/pm format. -'\A' +‘\A’ The time, in 24-hour HH:MM format. -'\u' +‘\u’ The username of the current user. -'\v' - The version of Bash (e.g., 2.00) -'\V' - The release of Bash, version + patchlevel (e.g., 2.00.0) -'\w' - The value of the 'PWD' shell variable ('$PWD'), with '$HOME' - abbreviated with a tilde (uses the '$PROMPT_DIRTRIM' variable). -'\W' - The basename of '$PWD', with '$HOME' abbreviated with a tilde. -'\!' +‘\v’ + The Bash version (e.g., 2.00). +‘\V’ + The Bash release, version + patchlevel (e.g., 2.00.0). +‘\w’ + The value of the ‘PWD’ shell variable (‘$PWD’), with ‘$HOME’ + abbreviated with a tilde (uses the ‘$PROMPT_DIRTRIM’ variable). +‘\W’ + The basename of ‘$PWD’, with ‘$HOME’ abbreviated with a tilde. +‘\!’ The history number of this command. -'\#' +‘\#’ The command number of this command. -'\$' - If the effective uid is 0, '#', otherwise '$'. -'\NNN' +‘\$’ + If the effective uid is 0, ‘#’, otherwise ‘$’. +‘\NNN’ The character whose ASCII code is the octal value NNN. -'\\' +‘\\’ A backslash. -'\[' - Begin a sequence of non-printing characters. This could be used to - embed a terminal control sequence into the prompt. -'\]' +‘\[’ + Begin a sequence of non-printing characters. Thiss could be used + to embed a terminal control sequence into the prompt. +‘\]’ End a sequence of non-printing characters. The command number and the history number are usually different: the @@ -6956,7 +7560,7 @@ of commands executed during the current shell session. After the string is decoded, it is expanded via parameter expansion, command substitution, arithmetic expansion, and quote removal, subject -to the value of the 'promptvars' shell option (*note The Shopt +to the value of the ‘promptvars’ shell option (*note The Shopt Builtin::). This can have unwanted side effects if escaped portions of the string appear within command substitution or contain characters special to word expansion. @@ -6967,167 +7571,262 @@ File: bash.info, Node: The Restricted Shell, Next: Bash POSIX Mode, Prev: Con 6.10 The Restricted Shell ========================= -If Bash is started with the name 'rbash', or the '--restricted' or '-r' -option is supplied at invocation, the shell becomes restricted. A +If Bash is started with the name ‘rbash’, or the ‘--restricted’ or ‘-r’ +option is supplied at invocation, the shell becomes RESTRICTED. A restricted shell is used to set up an environment more controlled than -the standard shell. A restricted shell behaves identically to 'bash' +the standard shell. A restricted shell behaves identically to ‘bash’ with the exception that the following are disallowed or not performed: - * Changing directories with the 'cd' builtin. - * Setting or unsetting the values of the 'SHELL', 'PATH', 'HISTFILE', - 'ENV', or 'BASH_ENV' variables. - * Specifying command names containing slashes. - * Specifying a filename containing a slash as an argument to the '.' + • Changing directories with the ‘cd’ builtin. + • Setting or unsetting the values of the ‘SHELL’, ‘PATH’, ‘HISTFILE’, + ‘ENV’, or ‘BASH_ENV’ variables. + • Specifying command names containing slashes. + • Specifying a filename containing a slash as an argument to the ‘.’ builtin command. - * Specifying a filename containing a slash as an argument to the - 'history' builtin command. - * Specifying a filename containing a slash as an argument to the '-p' - option to the 'hash' builtin command. - * Importing function definitions from the shell environment at + • Using the ‘-p’ option to the ‘.’ builtin command to specify a + search path. + • Specifying a filename containing a slash as an argument to the + ‘history’ builtin command. + • Specifying a filename containing a slash as an argument to the ‘-p’ + option to the ‘hash’ builtin command. + • Importing function definitions from the shell environment at startup. - * Parsing the value of 'SHELLOPTS' from the shell environment at + • Parsing the value of ‘SHELLOPTS’ from the shell environment at startup. - * Redirecting output using the '>', '>|', '<>', '>&', '&>', and '>>' + • Redirecting output using the ‘>’, ‘>|’, ‘<>’, ‘>&’, ‘&>’, and ‘>>’ redirection operators. - * Using the 'exec' builtin to replace the shell with another command. - * Adding or deleting builtin commands with the '-f' and '-d' options - to the 'enable' builtin. - * Using the 'enable' builtin command to enable disabled shell + • Using the ‘exec’ builtin to replace the shell with another command. + • Adding or deleting builtin commands with the ‘-f’ and ‘-d’ options + to the ‘enable’ builtin. + • Using the ‘enable’ builtin command to enable disabled shell builtins. - * Specifying the '-p' option to the 'command' builtin. - * Turning off restricted mode with 'set +r' or 'shopt -u - restricted_shell'. + • Specifying the ‘-p’ option to the ‘command’ builtin. + • Turning off restricted mode with ‘set +r’ or ‘shopt -u + restricted_shell’. These restrictions are enforced after any startup files are read. When a command that is found to be a shell script is executed (*note -Shell Scripts::), 'rbash' turns off any restrictions in the shell +Shell Scripts::), ‘rbash’ turns off any restrictions in the shell spawned to execute the script. The restricted shell mode is only one component of a useful -restricted environment. It should be accompanied by setting 'PATH' to a +restricted environment. It should be accompanied by setting ‘PATH’ to a value that allows execution of only a few verified commands (commands that allow shell escapes are particularly vulnerable), changing the -current directory to a non-writable directory other than '$HOME' after +current directory to a non-writable directory other than ‘$HOME’ after login, not allowing the restricted shell to execute shell scripts, and cleaning the environment of variables that cause some commands to modify -their behavior (e.g., 'VISUAL' or 'PAGER'). +their behavior (e.g., ‘VISUAL’ or ‘PAGER’). Modern systems provide more secure ways to implement a restricted -environment, such as 'jails', 'zones', or 'containers'. +environment, such as ‘jails’, ‘zones’, or ‘containers’.  File: bash.info, Node: Bash POSIX Mode, Next: Shell Compatibility Mode, Prev: The Restricted Shell, Up: Bash Features -6.11 Bash POSIX Mode -==================== +6.11 Bash and POSIX +=================== -Starting Bash with the '--posix' command-line option or executing 'set --o posix' while Bash is running will cause Bash to conform more closely -to the POSIX standard by changing the behavior to match that specified -by POSIX in areas where the Bash default differs. +6.11.1 What is POSIX? +--------------------- - When invoked as 'sh', Bash enters POSIX mode after reading the -startup files. +POSIX is the name for a family of standards based on Unix. A number of +Unix services, tools, and functions are part of the standard, ranging +from the basic system calls and C library functions to common +applications and tools to system administration and management. + + The POSIX Shell and Utilities standard was originally developed by +IEEE Working Group 1003.2 (POSIX.2). The first edition of the 1003.2 +standard was published in 1992. It was merged with the original IEEE +1003.1 Working Group and is currently maintained by the Austin Group (a +joint working group of the IEEE, The Open Group and ISO/IEC SC22/WG15). +Today the Shell and Utilities are a volume within the set of documents +that make up IEEE Std 1003.1-2024, and thus the former POSIX.2 (from +1992) is now part of the current unified POSIX standard. + + The Shell and Utilities volume concentrates on the command +interpreter interface and utility programs commonly executed from the +command line or by other programs. The standard is freely available on +the web at +. + + Bash is concerned with the aspects of the shell's behavior defined by +the POSIX Shell and Utilities volume. The shell command language has of +course been standardized, including the basic flow control and program +execution constructs, I/O redirection and pipelines, argument handling, +variable expansion, and quoting. + + The special builtins, which must be implemented as part of the shell +to provide the desired functionality, are specified as being part of the +shell; examples of these are ‘eval’ and ‘export’. Other utilities +appear in the sections of POSIX not devoted to the shell which are +commonly (and in some cases must be) implemented as builtin commands, +such as ‘read’ and ‘test’. POSIX also specifies aspects of the shell's +interactive behavior, including job control and command line editing. +Only vi-style line editing commands have been standardized; emacs +editing commands were left out due to objections. + +6.11.2 Bash POSIX Mode +---------------------- - The following list is what's changed when 'POSIX mode' is in effect: +Although Bash is an implementation of the POSIX shell specification, +there are areas where the Bash default behavior differs from the +specification. The Bash “posix mode” changes the Bash behavior in these +areas so that it conforms more strictly to the standard. - 1. Bash ensures that the 'POSIXLY_CORRECT' variable is set. + Starting Bash with the ‘--posix’ command-line option or executing +‘set -o posix’ while Bash is running will cause Bash to conform more +closely to the POSIX standard by changing the behavior to match that +specified by POSIX in areas where the Bash default differs. - 2. When a command in the hash table no longer exists, Bash will - re-search '$PATH' to find the new location. This is also available - with 'shopt -s checkhash'. + When invoked as ‘sh’, Bash enters POSIX mode after reading the +startup files. - 3. Bash will not insert a command without the execute bit set into the - command hash table, even if it returns it as a (last-ditch) result - from a '$PATH' search. + The following list is what's changed when POSIX mode is in effect: - 4. The message printed by the job control code and builtins when a job - exits with a non-zero status is 'Done(status)'. + 1. Bash ensures that the ‘POSIXLY_CORRECT’ variable is set. - 5. The message printed by the job control code and builtins when a job - is stopped is 'Stopped(SIGNAME)', where SIGNAME is, for example, - 'SIGTSTP'. + 2. Bash reads and executes the POSIX startup files (‘$ENV’) rather + than the normal Bash files (*note Bash Startup Files::. - 6. Alias expansion is always enabled, even in non-interactive shells. + 3. Alias expansion is always enabled, even in non-interactive shells. - 7. Reserved words appearing in a context where reserved words are + 4. Reserved words appearing in a context where reserved words are recognized do not undergo alias expansion. - 8. Alias expansion is performed when initially parsing a command - substitution. The default mode generally defers it, when enabled, - until the command substitution is executed. This means that - command substitution will not expand aliases that are defined after - the command substitution is initially parsed (e.g., as part of a - function definition). + 5. Alias expansion is performed when initially parsing a command + substitution. The default (non-posix) mode generally defers it, + when enabled, until the command substitution is executed. This + means that command substitution will not expand aliases that are + defined after the command substitution is initially parsed (e.g., + as part of a function definition). - 9. The POSIX 'PS1' and 'PS2' expansions of '!' to the history number - and '!!' to '!' are enabled, and parameter expansion is performed - on the values of 'PS1' and 'PS2' regardless of the setting of the - 'promptvars' option. + 6. The ‘time’ reserved word may be used by itself as a simple command. + When used in this way, it displays timing statistics for the shell + and its completed children. The ‘TIMEFORMAT’ variable controls the + format of the timing information. - 10. The POSIX startup files are executed ('$ENV') rather than the - normal Bash files. + 7. The parser does not recognize ‘time’ as a reserved word if the next + token begins with a ‘-’. - 11. Tilde expansion is only performed on assignments preceding a - command name, rather than on all assignment statements on the line. + 8. When parsing and expanding a ${...} expansion that appears within + double quotes, single quotes are no longer special and cannot be + used to quote a closing brace or other special character, unless + the operator is one of those defined to perform pattern removal. + In this case, they do not have to appear as matched pairs. - 12. The default history file is '~/.sh_history' (this is the default - value of '$HISTFILE'). + 9. Redirection operators do not perform filename expansion on the word + in a redirection unless the shell is interactive. - 13. Redirection operators do not perform filename expansion on the - word in the redirection unless the shell is interactive. + 10. Redirection operators do not perform word splitting on the word in + a redirection. - 14. Redirection operators do not perform word splitting on the word in - the redirection. + 11. Function names may not be the same as one of the POSIX special + builtins. + + 12. Tilde expansion is only performed on assignments preceding a + command name, rather than on all assignment statements on the line. + + 13. While variable indirection is available, it may not be applied to + the ‘#’ and ‘?’ special parameters. - 15. Function names must be valid shell 'name's. That is, they may not - contain characters other than letters, digits, and underscores, and - may not start with a digit. Declaring a function with an invalid - name causes a fatal syntax error in non-interactive shells. + 14. Expanding the ‘*’ special parameter in a pattern context where the + expansion is double-quoted does not treat the ‘$*’ as if it were + double-quoted. + + 15. A double quote character (‘"’) is treated specially when it + appears in a backquoted command substitution in the body of a + here-document that undergoes expansion. That means, for example, + that a backslash preceding a double quote character will escape it + and the backslash will be removed. + + 16. Command substitutions don't set the ‘?’ special parameter. The + exit status of a simple command without a command word is still the + exit status of the last command substitution that occurred while + evaluating the variable assignments and redirections in that + command, but that does not happen until after all of the + assignments and redirections. + + 17. Literal tildes that appear as the first character in elements of + the ‘PATH’ variable are not expanded as described above under *note + Tilde Expansion::. - 16. Function names may not be the same as one of the POSIX special + 18. Command lookup finds POSIX special builtins before shell + functions, including output printed by the ‘type’ and ‘command’ builtins. - 17. POSIX special builtins are found before shell functions during - command lookup. + 19. Even if a shell function whose name contains a slash was defined + before entering POSIX mode, the shell will not execute a function + whose name contains one or more slashes. - 18. When printing shell function definitions (e.g., by 'type'), Bash - does not print the 'function' keyword. + 20. When a command in the hash table no longer exists, Bash will + re-search ‘$PATH’ to find the new location. This is also available + with ‘shopt -s checkhash’. - 19. Literal tildes that appear as the first character in elements of - the 'PATH' variable are not expanded as described above under *note - Tilde Expansion::. + 21. Bash will not insert a command without the execute bit set into + the command hash table, even if it returns it as a (last-ditch) + result from a ‘$PATH’ search. - 20. The 'time' reserved word may be used by itself as a command. When - used in this way, it displays timing statistics for the shell and - its completed children. The 'TIMEFORMAT' variable controls the - format of the timing information. + 22. The message printed by the job control code and builtins when a + job exits with a non-zero status is 'Done(status)'. - 21. When parsing and expanding a ${...} expansion that appears within - double quotes, single quotes are no longer special and cannot be - used to quote a closing brace or other special character, unless - the operator is one of those defined to perform pattern removal. - In this case, they do not have to appear as matched pairs. + 23. The message printed by the job control code and builtins when a + job is stopped is 'Stopped(SIGNAME)', where SIGNAME is, for + example, ‘SIGTSTP’. + + 24. If the shell is interactive, Bash does not perform job + notifications between executing commands in lists separated by ‘;’ + or newline. Non-interactive shells print status messages after a + foreground job in a list completes. + + 25. If the shell is interactive, Bash waits until the next prompt + before printing the status of a background job that changes status + or a foreground job that terminates due to a signal. + Non-interactive shells print status messages after a foreground job + completes. + + 26. Bash permanently removes jobs from the jobs table after notifying + the user of their termination via the ‘wait’ or ‘jobs’ builtins. + It removes the job from the jobs list after notifying the user of + its termination, but the status is still available via ‘wait’, as + long as ‘wait’ is supplied a PID argument. - 22. The parser does not recognize 'time' as a reserved word if the - next token begins with a '-'. + 27. The ‘vi’ editing mode will invoke the ‘vi’ editor directly when + the ‘v’ command is run, instead of checking ‘$VISUAL’ and + ‘$EDITOR’. - 23. The '!' character does not introduce history expansion within a - double-quoted string, even if the 'histexpand' option is enabled. + 28. Prompt expansion enables the POSIX ‘PS1’ and ‘PS2’ expansions of + ‘!’ to the history number and ‘!!’ to ‘!’, and Bash performs + parameter expansion on the values of ‘PS1’ and ‘PS2’ regardless of + the setting of the ‘promptvars’ option. - 24. If a POSIX special builtin returns an error status, a + 29. The default history file is ‘~/.sh_history’ (this is the default + value the shell assigns to ‘$HISTFILE’). + + 30. The ‘!’ character does not introduce history expansion within a + double-quoted string, even if the ‘histexpand’ option is enabled. + + 31. When printing shell function definitions (e.g., by ‘type’), Bash + does not print the ‘function’ reserved word unless necessary. + + 32. Non-interactive shells exit if a syntax error in an arithmetic + expansion results in an invalid expression. + + 33. Non-interactive shells exit if a parameter expansion error occurs. + + 34. If a POSIX special builtin returns an error status, a non-interactive shell exits. The fatal errors are those listed in the POSIX standard, and include things like passing incorrect options, redirection errors, variable assignment errors for assignments preceding the command name, and so on. - 25. A non-interactive shell exits with an error status if a variable + 35. A non-interactive shell exits with an error status if a variable assignment error occurs when no command name follows the assignment statements. A variable assignment error occurs, for example, when trying to assign a value to a readonly variable. - 26. A non-interactive shell exits with an error status if a variable + 36. A non-interactive shell exits with an error status if a variable assignment error occurs in an assignment statement preceding a special builtin, but not with any other simple command. For any other simple command, the shell aborts execution of that command, @@ -7135,152 +7834,183 @@ startup files. perform any further processing of the command in which the error occurred"). - 27. A non-interactive shell exits with an error status if the - iteration variable in a 'for' statement or the selection variable - in a 'select' statement is a readonly variable. + 37. A non-interactive shell exits with an error status if the + iteration variable in a ‘for’ statement or the selection variable + in a ‘select’ statement is a readonly variable or has an invalid + name. - 28. Non-interactive shells exit if FILENAME in '.' FILENAME is not + 38. Non-interactive shells exit if FILENAME in ‘.’ FILENAME is not found. - 29. Non-interactive shells exit if a syntax error in an arithmetic - expansion results in an invalid expression. - - 30. Non-interactive shells exit if a parameter expansion error occurs. + 39. Non-interactive shells exit if there is a syntax error in a script + read with the ‘.’ or ‘source’ builtins, or in a string processed by + the ‘eval’ builtin. - 31. Non-interactive shells exit if there is a syntax error in a script - read with the '.' or 'source' builtins, or in a string processed by - the 'eval' builtin. + 40. Non-interactive shells exit if the ‘export’, ‘readonly’ or ‘unset’ + builtin commands get an argument that is not a valid identifier, + and they are not operating on shell functions. These errors force + an exit because these are special builtins. - 32. While variable indirection is available, it may not be applied to - the '#' and '?' special parameters. - - 33. Expanding the '*' special parameter in a pattern context where the - expansion is double-quoted does not treat the '$*' as if it were - double-quoted. - - 34. Assignment statements preceding POSIX special builtins persist in + 41. Assignment statements preceding POSIX special builtins persist in the shell environment after the builtin completes. - 35. The 'command' builtin does not prevent builtins that take + 42. The ‘command’ builtin does not prevent builtins that take assignment statements as arguments from expanding them as - assignment statements; when not in POSIX mode, assignment builtins + assignment statements; when not in POSIX mode, declaration commands lose their assignment statement expansion properties when preceded - by 'command'. + by ‘command’. - 36. The 'bg' builtin uses the required format to describe each job - placed in the background, which does not include an indication of - whether the job is the current or previous job. + 43. Enabling POSIX mode has the effect of setting the + ‘inherit_errexit’ option, so subshells spawned to execute command + substitutions inherit the value of the ‘-e’ option from the parent + shell. When the ‘inherit_errexit’ option is not enabled, Bash + clears the ‘-e’ option in such subshells. - 37. The output of 'kill -l' prints all the signal names on a single - line, separated by spaces, without the 'SIG' prefix. + 44. Enabling POSIX mode has the effect of setting the ‘shift_verbose’ + option, so numeric arguments to ‘shift’ that exceed the number of + positional parameters will result in an error message. - 38. The 'kill' builtin does not accept signal names with a 'SIG' - prefix. + 45. Enabling POSIX mode has the effect of setting the + ‘interactive_comments’ option (*note Comments::). - 39. The 'export' and 'readonly' builtin commands display their output - in the format required by POSIX. + 46. The ‘.’ and ‘source’ builtins do not search the current directory + for the filename argument if it is not found by searching ‘PATH’. - 40. The 'trap' builtin displays signal names without the leading - 'SIG'. + 47. When the ‘alias’ builtin displays alias definitions, it does not + display them with a leading ‘alias ’ unless the ‘-p’ option is + supplied. - 41. The 'trap' builtin doesn't check the first argument for a possible - signal specification and revert the signal handling to the original - disposition if it is, unless that argument consists solely of - digits and is a valid signal number. If users want to reset the - handler for a given signal to the original disposition, they should - use '-' as the first argument. + 48. The ‘bg’ builtin uses the required format to describe each job + placed in the background, which does not include an indication of + whether the job is the current or previous job. - 42. 'trap -p' displays signals whose dispositions are set to SIG_DFL - and those that were ignored when the shell started. + 49. When the ‘cd’ builtin is invoked in logical mode, and the pathname + constructed from ‘$PWD’ and the directory name supplied as an + argument does not refer to an existing directory, ‘cd’ will fail + instead of falling back to physical mode. - 43. The '.' and 'source' builtins do not search the current directory - for the filename argument if it is not found by searching 'PATH'. + 50. When the ‘cd’ builtin cannot change a directory because the length + of the pathname constructed from ‘$PWD’ and the directory name + supplied as an argument exceeds ‘PATH_MAX’ when canonicalized, ‘cd’ + will attempt to use the supplied directory name. - 44. Enabling POSIX mode has the effect of setting the - 'inherit_errexit' option, so subshells spawned to execute command - substitutions inherit the value of the '-e' option from the parent - shell. When the 'inherit_errexit' option is not enabled, Bash - clears the '-e' option in such subshells. + 51. When the ‘xpg_echo’ option is enabled, Bash does not attempt to + interpret any arguments to ‘echo’ as options. ‘echo’ displays each + argument after converting escape sequences. - 45. Enabling POSIX mode has the effect of setting the 'shift_verbose' - option, so numeric arguments to 'shift' that exceed the number of - positional parameters will result in an error message. + 52. The ‘export’ and ‘readonly’ builtin commands display their output + in the format required by POSIX. - 46. When the 'alias' builtin displays alias definitions, it does not - display them with a leading 'alias ' unless the '-p' option is - supplied. + 53. When listing the history, the ‘fc’ builtin does not include an + indication of whether or not a history entry has been modified. - 47. When the 'set' builtin is invoked without options, it does not - display shell function names and definitions. + 54. The default editor used by ‘fc’ is ‘ed’. - 48. When the 'set' builtin is invoked without options, it displays - variable values without quotes, unless they contain shell - metacharacters, even if the result contains nonprinting characters. + 55. ‘fc’ treats extra arguments as an error instead of ignoring them. - 49. When the 'cd' builtin is invoked in logical mode, and the pathname - constructed from '$PWD' and the directory name supplied as an - argument does not refer to an existing directory, 'cd' will fail - instead of falling back to physical mode. + 56. If there are too many arguments supplied to ‘fc -s’, ‘fc’ prints + an error message and returns failure. - 50. When the 'cd' builtin cannot change a directory because the length - of the pathname constructed from '$PWD' and the directory name - supplied as an argument exceeds 'PATH_MAX' when all symbolic links - are expanded, 'cd' will fail instead of attempting to use only the - supplied directory name. + 57. The output of ‘kill -l’ prints all the signal names on a single + line, separated by spaces, without the ‘SIG’ prefix. - 51. The 'pwd' builtin verifies that the value it prints is the same as + 58. The ‘kill’ builtin does not accept signal names with a ‘SIG’ + prefix. + + 59. The ‘kill’ builtin returns a failure status if any of the pid or + job arguments are invalid or if sending the specified signal to any + of them fails. In default mode, ‘kill’ returns success if the + signal was successfully sent to any of the specified processes. + + 60. The ‘printf’ builtin uses ‘double’ (via ‘strtod’) to convert + arguments corresponding to floating point conversion specifiers, + instead of ‘long double’ if it's available. The ‘L’ length + modifier forces ‘printf’ to use ‘long double’ if it's available. + + 61. The ‘pwd’ builtin verifies that the value it prints is the same as the current directory, even if it is not asked to check the file - system with the '-P' option. + system with the ‘-P’ option. - 52. When listing the history, the 'fc' builtin does not include an - indication of whether or not a history entry has been modified. + 62. The ‘read’ builtin may be interrupted by a signal for which a trap + has been set. If Bash receives a trapped signal while executing + ‘read’, the trap handler executes and ‘read’ returns an exit status + greater than 128. + + 63. When the ‘set’ builtin is invoked without options, it does not + display shell function names and definitions. + + 64. When the ‘set’ builtin is invoked without options, it displays + variable values without quotes, unless they contain shell + metacharacters, even if the result contains nonprinting characters. + + 65. The ‘test’ builtin compares strings using the current locale when + evaluating the ‘<’ and ‘>’ binary operators. - 53. The default editor used by 'fc' is 'ed'. + 66. The ‘test’ builtin's ‘-t’ unary primary requires an argument. + Historical versions of ‘test’ made the argument optional in certain + cases, and Bash attempts to accommodate those for backwards + compatibility. - 54. The 'type' and 'command' builtins will not report a non-executable + 67. The ‘trap’ builtin displays signal names without the leading + ‘SIG’. + + 68. The ‘trap’ builtin doesn't check the first argument for a possible + signal specification and revert the signal handling to the original + disposition if it is, unless that argument consists solely of + digits and is a valid signal number. If users want to reset the + handler for a given signal to the original disposition, they should + use ‘-’ as the first argument. + + 69. ‘trap -p’ without arguments displays signals whose dispositions + are set to SIG_DFL and those that were ignored when the shell + started, not just trapped signals. + + 70. The ‘type’ and ‘command’ builtins will not report a non-executable file as having been found, though the shell will attempt to execute - such a file if it is the only so-named file found in '$PATH'. + such a file if it is the only so-named file found in ‘$PATH’. - 55. The 'vi' editing mode will invoke the 'vi' editor directly when - the 'v' command is run, instead of checking '$VISUAL' and - '$EDITOR'. + 71. The ‘ulimit’ builtin uses a block size of 512 bytes for the ‘-c’ + and ‘-f’ options. - 56. When the 'xpg_echo' option is enabled, Bash does not attempt to - interpret any arguments to 'echo' as options. Each argument is - displayed, after escape characters are converted. + 72. The ‘unset’ builtin with the ‘-v’ option specified returns a fatal + error if it attempts to unset a ‘readonly’ or ‘non-unsettable’ + variable, which causes a non-interactive shell to exit. - 57. The 'ulimit' builtin uses a block size of 512 bytes for the '-c' - and '-f' options. + 73. When asked to unset a variable that appears in an assignment + statement preceding the command, the ‘unset’ builtin attempts to + unset a variable of the same name in the current or previous scope + as well. This implements the required "if an assigned variable is + further modified by the utility, the modifications made by the + utility shall persist" behavior. - 58. The arrival of 'SIGCHLD' when a trap is set on 'SIGCHLD' does not - interrupt the 'wait' builtin and cause it to return immediately. + 74. The arrival of ‘SIGCHLD’ when a trap is set on ‘SIGCHLD’ does not + interrupt the ‘wait’ builtin and cause it to return immediately. The trap command is run once for each child that exits. - 59. The 'read' builtin may be interrupted by a signal for which a trap - has been set. If Bash receives a trapped signal while executing - 'read', the trap handler executes and 'read' returns an exit status - greater than 128. + 75. Bash removes an exited background process's status from the list + of such statuses after the ‘wait’ builtin returns it. - 60. The 'printf' builtin uses 'double' (via 'strtod') to convert - arguments corresponding to floating point conversion specifiers, - instead of 'long double' if it's available. The 'L' length - modifier forces 'printf' to use 'long double' if it's available. - - 61. Bash removes an exited background process's status from the list - of such statuses after the 'wait' builtin is used to obtain it. + There is additional POSIX behavior that Bash does not implement by +default even when in POSIX mode. Specifically: - There is other POSIX behavior that Bash does not implement by default -even when in POSIX mode. Specifically: + 1. POSIX requires that word splitting be byte-oriented. That is, each + _byte_ in the value of ‘IFS’ potentially splits a word, even if + that byte is part of a multibyte character in ‘IFS’ or part of + multibyte character in the word. Bash allows multibyte characters + in the value of ‘IFS’, treating a valid multibyte character as a + single delimiter, and will not split a valid multibyte character + even if one of the bytes composing that character appears in ‘IFS’. + This is POSIX interpretation 1560, further modified by issue 1924. - 1. The 'fc' builtin checks '$EDITOR' as a program to edit history - entries if 'FCEDIT' is unset, rather than defaulting directly to - 'ed'. 'fc' uses 'ed' if 'EDITOR' is unset. + 2. The ‘fc’ builtin checks ‘$EDITOR’ as a program to edit history + entries if ‘FCEDIT’ is unset, rather than defaulting directly to + ‘ed’. ‘fc’ uses ‘ed’ if ‘EDITOR’ is unset. - 2. As noted above, Bash requires the 'xpg_echo' option to be enabled - for the 'echo' builtin to be fully conformant. + 3. As noted above, Bash requires the ‘xpg_echo’ option to be enabled + for the ‘echo’ builtin to be fully conformant. Bash can be configured to be POSIX-conformant by default, by -specifying the '--enable-strict-posix-default' to 'configure' when +specifying the ‘--enable-strict-posix-default’ to ‘configure’ when building (*note Optional Features::).  @@ -7289,9 +8019,9 @@ File: bash.info, Node: Shell Compatibility Mode, Prev: Bash POSIX Mode, Up: B 6.12 Shell Compatibility Mode ============================= -Bash-4.0 introduced the concept of a "shell compatibility level", -specified as a set of options to the shopt builtin ('compat31', -'compat32', 'compat40', 'compat41', and so on). There is only one +Bash-4.0 introduced the concept of a “shell compatibility level”, +specified as a set of options to the shopt builtin (‘compat31’, +‘compat32’, ‘compat40’, ‘compat41’, and so on). There is only one current compatibility level - each option is mutually exclusive. The compatibility level is intended to allow users to select behavior from previous versions that is incompatible with newer versions while they @@ -7299,152 +8029,156 @@ migrate scripts to use current features and behavior. It's intended to be a temporary solution. This section does not mention behavior that is standard for a -particular version (e.g., setting 'compat32' means that quoting the rhs -of the regexp matching operator quotes special regexp characters in the -word, which is default behavior in bash-3.2 and subsequent versions). +particular version (e.g., setting ‘compat32’ means that quoting the +right hand side of the regexp matching operator quotes special regexp +characters in the word, which is default behavior in bash-3.2 and +subsequent versions). - If a user enables, say, 'compat32', it may affect the behavior of + If a user enables, say, ‘compat32’, it may affect the behavior of other compatibility levels up to and including the current compatibility level. The idea is that each compatibility level controls behavior that changed in that version of Bash, but that behavior may have been present in earlier versions. For instance, the change to use locale-based -comparisons with the '[[' command came in bash-4.1, and earlier versions -used ASCII-based comparisons, so enabling 'compat32' will enable +comparisons with the ‘[[’ command came in bash-4.1, and earlier versions +used ASCII-based comparisons, so enabling ‘compat32’ will enable ASCII-based comparisons as well. That granularity may not be sufficient for all uses, and as a result users should employ compatibility levels carefully. Read the documentation for a particular feature to find out the current behavior. - Bash-4.3 introduced a new shell variable: 'BASH_COMPAT'. The value + Bash-4.3 introduced a new shell variable: ‘BASH_COMPAT’. The value assigned to this variable (a decimal version number like 4.2, or an -integer corresponding to the 'compat'NN option, like 42) determines the +integer corresponding to the ‘compat’NN option, like 42) determines the compatibility level. - Starting with bash-4.4, Bash has begun deprecating older -compatibility levels. Eventually, the options will be removed in favor -of 'BASH_COMPAT'. + Starting with bash-4.4, Bash began deprecating older compatibility +levels. Eventually, the options will be removed in favor of +‘BASH_COMPAT’. - Bash-5.0 is the final version for which there will be an individual -shopt option for the previous version. Users should use 'BASH_COMPAT' -on bash-5.0 and later versions. + Bash-5.0 was the final version for which there was an individual +shopt option for the previous version. ‘BASH_COMPAT’ is the only +mechanism to control the compatibility level in versions newer than +bash-5.0. The following table describes the behavior changes controlled by each -compatibility level setting. The 'compat'NN tag is used as shorthand +compatibility level setting. The ‘compat’NN tag is used as shorthand for setting the compatibility level to NN using one of the following mechanisms. For versions prior to bash-5.0, the compatibility level may -be set using the corresponding 'compat'NN shopt option. For bash-4.3 -and later versions, the 'BASH_COMPAT' variable is preferred, and it is +be set using the corresponding ‘compat’NN shopt option. For bash-4.3 +and later versions, the ‘BASH_COMPAT’ variable is preferred, and it is required for bash-5.1 and later versions. -'compat31' - * quoting the rhs of the '[[' command's regexp matching operator +‘compat31’ + • Quoting the rhs of the ‘[[’ command's regexp matching operator (=~) has no special effect -'compat32' - * interrupting a command list such as "a ; b ; c" causes the - execution of the next command in the list (in bash-4.0 and - later versions, the shell acts as if it received the - interrupt, so interrupting one command in a list aborts the - execution of the entire list) - -'compat40' - * the '<' and '>' operators to the '[[' command do not consider +‘compat40’ + • The ‘<’ and ‘>’ operators to the ‘[[’ command do not consider the current locale when comparing strings; they use ASCII ordering. Bash versions prior to bash-4.1 use ASCII collation and strcmp(3); bash-4.1 and later use the current locale's collation sequence and strcoll(3). -'compat41' - * in posix mode, 'time' may be followed by options and still be +‘compat41’ + • In POSIX mode, ‘time’ may be followed by options and still be recognized as a reserved word (this is POSIX interpretation - 267) - * in posix mode, the parser requires that an even number of + 267). + • In POSIX mode, the parser requires that an even number of single quotes occur in the WORD portion of a double-quoted ${...} parameter expansion and treats them specially, so that characters within the single quotes are considered quoted - (this is POSIX interpretation 221) + (this is POSIX interpretation 221). -'compat42' - * the replacement string in double-quoted pattern substitution +‘compat42’ + • The replacement string in double-quoted pattern substitution does not undergo quote removal, as it does in versions after - bash-4.2 - * in posix mode, single quotes are considered special when + bash-4.2. + • In POSIX mode, single quotes are considered special when expanding the WORD portion of a double-quoted ${...} parameter expansion and can be used to quote a closing brace or other special character (this is part of POSIX interpretation 221); in later versions, single quotes are not special within - double-quoted word expansions - -'compat43' - * the shell does not print a warning message if an attempt is - made to use a quoted compound assignment as an argument to - declare (e.g., declare -a foo='(1 2)'). Later versions warn - that this usage is deprecated - * word expansion errors are considered non-fatal errors that - cause the current command to fail, even in posix mode (the + double-quoted word expansions. + +‘compat43’ + • Word expansion errors are considered non-fatal errors that + cause the current command to fail, even in POSIX mode (the default behavior is to make them fatal errors that cause the - shell to exit) - * when executing a shell function, the loop state - (while/until/etc.) is not reset, so 'break' or 'continue' in + shell to exit). + • When executing a shell function, the loop state + (while/until/etc.) is not reset, so ‘break’ or ‘continue’ in that function will break or continue loops in the calling context. Bash-4.4 and later reset the loop state to prevent - this - -'compat44' - * the shell sets up the values used by 'BASH_ARGV' and - 'BASH_ARGC' so they can expand to the shell's positional - parameters even if extended debugging mode is not enabled - * a subshell inherits loops from its parent context, so 'break' - or 'continue' will cause the subshell to exit. Bash-5.0 and - later reset the loop state to prevent the exit - * variable assignments preceding builtins like 'export' and - 'readonly' that set attributes continue to affect variables + this. + +‘compat44’ + • The shell sets up the values used by ‘BASH_ARGV’ and + ‘BASH_ARGC’ so they can expand to the shell's positional + parameters even if extended debugging mode is not enabled. + • A subshell inherits loops from its parent context, so ‘break’ + or ‘continue’ will cause the subshell to exit. Bash-5.0 and + later reset the loop state to prevent the exit. + • Variable assignments preceding builtins like ‘export’ and + ‘readonly’ that set attributes continue to affect variables with the same name in the calling environment even if the - shell is not in posix mode + shell is not in POSIX mode. -'compat50 (set using BASH_COMPAT)' - * Bash-5.1 changed the way '$RANDOM' is generated to introduce +‘compat50 (set using BASH_COMPAT)’ + • Bash-5.1 changed the way ‘$RANDOM’ is generated to introduce slightly more randomness. If the shell compatibility level is set to 50 or lower, it reverts to the method from bash-5.0 and previous versions, so seeding the random number generator by - assigning a value to 'RANDOM' will produce the same sequence - as in bash-5.0 - * If the command hash table is empty, Bash versions prior to + assigning a value to ‘RANDOM’ will produce the same sequence + as in bash-5.0. + • If the command hash table is empty, Bash versions prior to bash-5.1 printed an informational message to that effect, even when producing output that can be reused as input. Bash-5.1 - suppresses that message when the '-l' option is supplied. + suppresses that message when the ‘-l’ option is supplied. -'compat51 (set using BASH_COMPAT)' - * The 'unset' builtin will unset the array 'a' given an argument - like 'a[@]'. Bash-5.2 will unset an element with key '@' +‘compat51 (set using BASH_COMPAT)’ + • The ‘unset’ builtin will unset the array ‘a’ given an argument + like ‘a[@]’. Bash-5.2 will unset an element with key ‘@’ (associative arrays) or remove all the elements without - unsetting the array (indexed arrays) - * arithmetic commands ( ((...)) ) and the expressions in an - arithmetic for statement can be expanded more than once - * expressions used as arguments to arithmetic operators in the - '[[' conditional command can be expanded more than once - * the expressions in substring parameter brace expansion can be - expanded more than once - * the expressions in the $(( ... )) word expansion can be - expanded more than once - * arithmetic expressions used as indexed array subscripts can be - expanded more than once - * 'test -v', when given an argument of 'A[@]', where A is an + unsetting the array (indexed arrays). + • Arithmetic commands ( ((...)) ) and the expressions in an + arithmetic for statement can be expanded more than once. + • Expressions used as arguments to arithmetic operators in the + ‘[[’ conditional command can be expanded more than once. + • The expressions in substring parameter brace expansion can be + expanded more than once. + • The expressions in the $(( ... )) word expansion can be + expanded more than once. + • Arithmetic expressions used as indexed array subscripts can be + expanded more than once. + • ‘test -v’, when given an argument of ‘A[@]’, where A is an existing associative array, will return true if the array has any set elements. Bash-5.2 will look for and report on a key - named '@' - * the ${PARAMETER[:]=VALUE} word expansion will return VALUE, + named ‘@’. + • the ${PARAMETER[:]=VALUE} word expansion will return VALUE, before any variable-specific transformations have been performed (e.g., converting to lowercase). Bash-5.2 will return the final value assigned to the variable. - * Parsing command substitutions will behave as if extended glob - (*note The Shopt Builtin::) is enabled, so that parsing a - command substitution containing an extglob pattern (say, as - part of a shell function) will not fail. This assumes the - intent is to enable extglob before the command is executed and - word expansions are performed. It will fail at word expansion - time if extglob hasn't been enabled by the time the command is - executed. + • Parsing command substitutions will behave as if extended + globbing (*note The Shopt Builtin::) is enabled, so that + parsing a command substitution containing an extglob pattern + (say, as part of a shell function) will not fail. This + assumes the intent is to enable extglob before the command is + executed and word expansions are performed. It will fail at + word expansion time if extglob hasn't been enabled by the time + the command is executed. + +‘compat52 (set using BASH_COMPAT)’ + • The ‘test’ builtin uses its historical algorithm to parse + parenthesized subexpressions when given five or more + arguments. + • If the ‘-p’ or ‘-P’ option is supplied to the ‘bind’ builtin, + ‘bind’ treats any arguments remaining after option processing + as bindable command names, and displays any key sequences + bound to those commands, instead of treating the arguments as + key sequences to bind. + • Interactive shells will notify the user of completed jobs + while sourcing a script. Newer versions defer notification + until script execution completes.  File: bash.info, Node: Job Control, Next: Command Line Editing, Prev: Bash Features, Up: Top @@ -7476,8 +8210,10 @@ interface supplied jointly by the operating system kernel's terminal driver and Bash. The shell associates a JOB with each pipeline. It keeps a table of -currently executing jobs, which may be listed with the 'jobs' command. -When Bash starts a job asynchronously, it prints a line that looks like: +currently executing jobs, which the ‘jobs’ command will display. Each +job has a “job number”, which ‘jobs’ displays between brackets. Job +numbers start at 1. When Bash starts a job asynchronously, it prints a +line that looks like: [1] 25647 indicating that this job is job number 1 and that the process ID of the last process in the pipeline associated with this job is 25647. All of @@ -7485,74 +8221,92 @@ the processes in a single pipeline are members of the same job. Bash uses the JOB abstraction as the basis for job control. To facilitate the implementation of the user interface to job -control, the operating system maintains the notion of a current terminal -process group ID. Members of this process group (processes whose -process group ID is equal to the current terminal process group ID) -receive keyboard-generated signals such as 'SIGINT'. These processes -are said to be in the foreground. Background processes are those whose -process group ID differs from the terminal's; such processes are immune -to keyboard-generated signals. Only foreground processes are allowed to -read from or, if the user so specifies with 'stty tostop', write to the -terminal. Background processes which attempt to read from (write to -when 'stty tostop' is in effect) the terminal are sent a 'SIGTTIN' -('SIGTTOU') signal by the kernel's terminal driver, which, unless -caught, suspends the process. +control, each process has a “process group ID”, and the operating system +maintains the notion of a current terminal process group ID. This +terminal process group ID is associated with the “controlling terminal”. + + Processes that have the same process group ID are said to be part of +the same “process group”. Members of the foreground process group +(processes whose process group ID is equal to the current terminal +process group ID) receive keyboard-generated signals such as ‘SIGINT’. +Processes in the foreground process group are said to be foreground +processes. Background processes are those whose process group ID +differs from the controlling terminal's; such processes are immune to +keyboard-generated signals. Only foreground processes are allowed to +read from or, if the user so specifies with ‘stty tostop’, write to the +controlling terminal. The system sends a ‘SIGTTIN’ (‘SIGTTOU’) signal +to background processes which attempt to read from (write to when +‘tostop’ is in effect) the terminal, which, unless caught, suspends the +process. If the operating system on which Bash is running supports job -control, Bash contains facilities to use it. Typing the "suspend" -character (typically '^Z', Control-Z) while a process is running causes -that process to be stopped and returns control to Bash. Typing the -"delayed suspend" character (typically '^Y', Control-Y) causes the -process to be stopped when it attempts to read input from the terminal, -and control to be returned to Bash. The user then manipulates the state -of this job, using the 'bg' command to continue it in the background, -the 'fg' command to continue it in the foreground, or the 'kill' command -to kill it. A '^Z' takes effect immediately, and has the additional -side effect of causing pending output and typeahead to be discarded. - - There are a number of ways to refer to a job in the shell. The -character '%' introduces a job specification ("jobspec"). - - Job number 'n' may be referred to as '%n'. The symbols '%%' and '%+' -refer to the shell's notion of the current job, which is the last job -stopped while it was in the foreground or started in the background. A -single '%' (with no accompanying job specification) also refers to the -current job. The previous job may be referenced using '%-'. If there -is only a single job, '%+' and '%-' can both be used to refer to that -job. In output pertaining to jobs (e.g., the output of the 'jobs' -command), the current job is always flagged with a '+', and the previous -job with a '-'. - - A job may also be referred to using a prefix of the name used to -start it, or using a substring that appears in its command line. For -example, '%ce' refers to a stopped job whose command name begins with -'ce'. Using '%?ce', on the other hand, refers to any job containing the -string 'ce' in its command line. If the prefix or substring matches -more than one job, Bash reports an error. - - Simply naming a job can be used to bring it into the foreground: '%1' -is a synonym for 'fg %1', bringing job 1 from the background into the -foreground. Similarly, '%1 &' resumes job 1 in the background, -equivalent to 'bg %1' +control, Bash contains facilities to use it. Typing the “suspend” +character (typically ‘^Z’, Control-Z) while a process is running stops +that process and returns control to Bash. Typing the “delayed suspend” +character (typically ‘^Y’, Control-Y) causes the process to stop when it +attempts to read input from the terminal, and returns control to Bash. +The user then manipulates the state of this job, using the ‘bg’ command +to continue it in the background, the ‘fg’ command to continue it in the +foreground, or the ‘kill’ command to kill it. The suspend character +takes effect immediately, and has the additional side effect of +discarding any pending output and typeahead. If you want to force a +background process to stop, or stop a process that's not associated with +your terminal session, send it the ‘SIGSTOP’ signal using ‘kill’. + + There are a number of ways to refer to a job in the shell. The ‘%’ +character introduces a “job specification” (jobspec). + + Job number ‘n’ may be referred to as ‘%n’. A job may also be +referred to using a prefix of the name used to start it, or using a +substring that appears in its command line. For example, ‘%ce’ refers +to a job whose command name begins with ‘ce’. Using ‘%?ce’, on the +other hand, refers to any job containing the string ‘ce’ in its command +line. If the prefix or substring matches more than one job, Bash +reports an error. + + The symbols ‘%%’ and ‘%+’ refer to the shell's notion of the “current +job”. A single ‘%’ (with no accompanying job specification) also refers +to the current job. ‘%-’ refers to the “previous job”. When a job +starts in the background, a job stops while in the foreground, or a job +is resumed in the background, it becomes the current job. The job that +was the current job becomes the previous job. When the current job +terminates, the previous job becomes the current job. If there is only +a single job, ‘%+’ and ‘%-’ can both be used to refer to that job. In +output pertaining to jobs (e.g., the output of the ‘jobs’ command), the +current job is always marked with a ‘+’, and the previous job with a +‘-’. + + Simply naming a job can be used to bring it into the foreground: ‘%1’ +is a synonym for ‘fg %1’, bringing job 1 from the background into the +foreground. Similarly, ‘%1 &’ resumes job 1 in the background, +equivalent to ‘bg %1’. The shell learns immediately whenever a job changes state. Normally, -Bash waits until it is about to print a prompt before reporting changes -in a job's status so as to not interrupt any other output. If the '-b' -option to the 'set' builtin is enabled, Bash reports such changes -immediately (*note The Set Builtin::). Any trap on 'SIGCHLD' is -executed for each child process that exits. - - If an attempt to exit Bash is made while jobs are stopped, (or -running, if the 'checkjobs' option is enabled - see *note The Shopt -Builtin::), the shell prints a warning message, and if the 'checkjobs' -option is enabled, lists the jobs and their statuses. The 'jobs' -command may then be used to inspect their status. If a second attempt -to exit is made without an intervening command, Bash does not print -another warning, and any stopped jobs are terminated. - - When the shell is waiting for a job or process using the 'wait' -builtin, and job control is enabled, 'wait' will return when the job -changes state. The '-f' option causes 'wait' to wait until the job or +Bash waits until it is about to print a prompt before notifying the user +about changes in a job's status so as to not interrupt any other output, +though it will notify of changes in a job's status after a foreground +command in a list completes, before executing the next command in the +list. If the ‘-b’ option to the ‘set’ builtin is enabled, Bash reports +status changes immediately (*note The Set Builtin::). Bash executes any +trap on ‘SIGCHLD’ for each child process that terminates. + + When a job terminates and Bash notifies the user about it, Bash +removes the job from the jobs table. It will not appear in ‘jobs’ +output, but ‘wait’ will report its exit status, as long as it's supplied +the process ID associated with the job as an argument. When the table +is empty, job numbers start over at 1. + + If a user attempts to exit Bash while jobs are stopped, (or running, +if the ‘checkjobs’ option is enabled - see *note The Shopt Builtin::), +the shell prints a warning message, and if the ‘checkjobs’ option is +enabled, lists the jobs and their statuses. The ‘jobs’ command may then +be used to inspect their status. If the user immediately attempts to +exit again, without an intervening command, Bash does not print another +warning, and terminates any stopped jobs. + + When the shell is waiting for a job or process using the ‘wait’ +builtin, and job control is enabled, ‘wait’ will return when the job +changes state. The ‘-f’ option causes ‘wait’ to wait until the job or process terminates before returning.  @@ -7561,126 +8315,148 @@ File: bash.info, Node: Job Control Builtins, Next: Job Control Variables, Pre 7.2 Job Control Builtins ======================== -'bg' +‘bg’ bg [JOBSPEC ...] Resume each suspended job JOBSPEC in the background, as if it had - been started with '&'. If JOBSPEC is not supplied, the current job - is used. The return status is zero unless it is run when job - control is not enabled, or, when run with job control enabled, any - JOBSPEC was not found or specifies a job that was started without - job control. + been started with ‘&’. If JOBSPEC is not supplied, the shell uses + its notion of the current job. ‘bg’ returns zero unless it is run + when job control is not enabled, or, when run with job control + enabled, any JOBSPEC was not found or specifies a job that was + started without job control. -'fg' +‘fg’ fg [JOBSPEC] Resume the job JOBSPEC in the foreground and make it the current - job. If JOBSPEC is not supplied, the current job is used. The - return status is that of the command placed into the foreground, or - non-zero if run when job control is disabled or, when run with job - control enabled, JOBSPEC does not specify a valid job or JOBSPEC - specifies a job that was started without job control. - -'jobs' + job. If JOBSPEC is not supplied, ‘fg’ resumes the current job. + The return status is that of the command placed into the + foreground, or non-zero if run when job control is disabled or, + when run with job control enabled, JOBSPEC does not specify a valid + job or JOBSPEC specifies a job that was started without job + control. + +‘jobs’ jobs [-lnprs] [JOBSPEC] jobs -x COMMAND [ARGUMENTS] The first form lists the active jobs. The options have the following meanings: - '-l' + ‘-l’ List process IDs in addition to the normal information. - '-n' + ‘-n’ Display information only about jobs that have changed status since the user was last notified of their status. - '-p' + ‘-p’ List only the process ID of the job's process group leader. - '-r' + ‘-r’ Display only running jobs. - '-s' + ‘-s’ Display only stopped jobs. - If JOBSPEC is given, output is restricted to information about that - job. If JOBSPEC is not supplied, the status of all jobs is listed. + If JOBSPEC is supplied, ‘jobs’ restricts output to information + about that job. If JOBSPEC is not supplied, ‘jobs’ lists the + status of all jobs. The return status is zero unless an invalid + option is encountered or an invalid JOBSPEC is supplied. - If the '-x' option is supplied, 'jobs' replaces any JOBSPEC found + If the ‘-x’ option is supplied, ‘jobs’ replaces any JOBSPEC found in COMMAND or ARGUMENTS with the corresponding process group ID, and executes COMMAND, passing it ARGUMENTs, returning its exit status. -'kill' - kill [-s SIGSPEC] [-n SIGNUM] [-SIGSPEC] JOBSPEC or PID +‘kill’ + kill [-s SIGSPEC] [-n SIGNUM] [-SIGSPEC] ID [...] kill -l|-L [EXIT_STATUS] - Send a signal specified by SIGSPEC or SIGNUM to the process named - by job specification JOBSPEC or process ID PID. SIGSPEC is either - a case-insensitive signal name such as 'SIGINT' (with or without - the 'SIG' prefix) or a signal number; SIGNUM is a signal number. - If SIGSPEC and SIGNUM are not present, 'SIGTERM' is used. The '-l' - option lists the signal names. If any arguments are supplied when - '-l' is given, the names of the signals corresponding to the - arguments are listed, and the return status is zero. EXIT_STATUS - is a number specifying a signal number or the exit status of a - process terminated by a signal. The '-L' option is equivalent to - '-l'. The return status is zero if at least one signal was - successfully sent, or non-zero if an error occurs or an invalid - option is encountered. - -'wait' - wait [-fn] [-p VARNAME] [JOBSPEC or PID ...] - - Wait until the child process specified by each process ID PID or - job specification JOBSPEC exits and return the exit status of the - last command waited for. If a job spec is given, all processes in - the job are waited for. If no arguments are given, 'wait' waits - for all running background jobs and the last-executed process - substitution, if its process id is the same as $!, and the return - status is zero. If the '-n' option is supplied, 'wait' waits for a - single job from the list of PIDs or JOBSPECs or, if no arguments - are supplied, any job, to complete and returns its exit status. If - none of the supplied arguments is a child of the shell, or if no - arguments are supplied and the shell has no unwaited-for children, - the exit status is 127. If the '-p' option is supplied, the - process or job identifier of the job for which the exit status is - returned is assigned to the variable VARNAME named by the option - argument. The variable will be unset initially, before any - assignment. This is useful only when the '-n' option is supplied. - Supplying the '-f' option, when job control is enabled, forces - 'wait' to wait for each PID or JOBSPEC to terminate before - returning its status, instead of returning when it changes status. - If neither JOBSPEC nor PID specifies an active child process of the - shell, the return status is 127. If 'wait' is interrupted by a - signal, the return status will be greater than 128, as described - above (*note Signals::). Otherwise, the return status is the exit - status of the last process or job waited for. - -'disown' - disown [-ar] [-h] [JOBSPEC ... | PID ... ] - - Without options, remove each JOBSPEC from the table of active jobs. - If the '-h' option is given, the job is not removed from the table, - but is marked so that 'SIGHUP' is not sent to the job if the shell - receives a 'SIGHUP'. If JOBSPEC is not present, and neither the - '-a' nor the '-r' option is supplied, the current job is used. If - no JOBSPEC is supplied, the '-a' option means to remove or mark all - jobs; the '-r' option without a JOBSPEC argument restricts - operation to running jobs. - -'suspend' + Send a signal specified by SIGSPEC or SIGNUM to the processes named + by each ID. Each ID may be a job specification JOBSPEC or process + ID PID. SIGSPEC is either a case-insensitive signal name such as + ‘SIGINT’ (with or without the ‘SIG’ prefix) or a signal number; + SIGNUM is a signal number. If SIGSPEC and SIGNUM are not present, + ‘kill’ sends ‘SIGTERM’. + + The ‘-l’ option lists the signal names. If any arguments are + supplied when ‘-l’ is supplied, ‘kill’ lists the names of the + signals corresponding to the arguments, and the return status is + zero. EXIT_STATUS is a number specifying a signal number or the + exit status of a process terminated by a signal; if it is supplied, + ‘kill’ prints the name of the signal that caused the process to + terminate. ‘kill’ assumes that process exit statuses are greater + than 128; anything less than that is a signal number. The ‘-L’ + option is equivalent to ‘-l’. + + The return status is zero if at least one signal was successfully + sent, or non-zero if an error occurs or an invalid option is + encountered. + +‘wait’ + wait [-fn] [-p VARNAME] [ID ...] + + Wait until the child process specified by each ID exits and return + the exit status of the last ID. Each ID may be a process ID PID or + a job specification JOBSPEC; if a jobspec is supplied, ‘wait’ waits + for all processes in the job. + + If no options or IDs are supplied, ‘wait’ waits for all running + background jobs and the last-executed process substitution, if its + process id is the same as $!, and the return status is zero. + + If the ‘-n’ option is supplied, ‘wait’ waits for any one of the IDs + or, if no IDs are supplied, any job or process substitution, to + complete and returns its exit status. If none of the supplied IDs + is a child of the shell, or if no arguments are supplied and the + shell has no unwaited-for children, the exit status is 127. + + If the ‘-p’ option is supplied, ‘wait’ assigns the process or job + identifier of the job for which the exit status is returned to the + variable VARNAME named by the option argument. The variable, which + cannot be readonly, will be unset initially, before any assignment. + This is useful only when used with the ‘-n’ option. + + Supplying the ‘-f’ option, when job control is enabled, forces + ‘wait’ to wait for each ID to terminate before returning its + status, instead of returning when it changes status. + + If none of the IDs specify one of the shell's an active child + processes, the return status is 127. If ‘wait’ is interrupted by a + signal, any VARNAME will remain unset, and the return status will + be greater than 128, as described above (*note Signals::). + Otherwise, the return status is the exit status of the last ID. + +‘disown’ + disown [-ar] [-h] [ID ...] + + Without options, remove each ID from the table of active jobs. + Each ID may be a job specification JOBSPEC or a process ID PID; if + ID is a PID, ‘disown’ uses the job containing PID as JOBSPEC. + + If the ‘-h’ option is supplied, ‘disown’ does not remove the jobs + corresponding to each ‘id’ from the jobs table, but rather marks + them so the shell does not send ‘SIGHUP’ to the job if the shell + receives a ‘SIGHUP’. + + If no ID is supplied, the ‘-a’ option means to remove or mark all + jobs; the ‘-r’ option without an ID argument removes or marks + running jobs. If no ID is supplied, and neither the ‘-a’ nor the + ‘-r’ option is supplied, ‘disown’ removes or marks the current job. + + The return value is 0 unless an ID does not specify a valid job. + +‘suspend’ suspend [-f] - Suspend the execution of this shell until it receives a 'SIGCONT' + Suspend the execution of this shell until it receives a ‘SIGCONT’ signal. A login shell, or a shell without job control enabled, - cannot be suspended; the '-f' option can be used to override this - and force the suspension. The return status is 0 unless the shell - is a login shell or job control is not enabled and '-f' is not - supplied. + cannot be suspended; the ‘-f’ option will override this and force + the suspension. The return status is 0 unless the shell is a login + shell or job control is not enabled and ‘-f’ is not supplied. - When job control is not active, the 'kill' and 'wait' builtins do not + When job control is not active, the ‘kill’ and ‘wait’ builtins do not accept JOBSPEC arguments. They must be supplied process IDs.  @@ -7689,22 +8465,22 @@ File: bash.info, Node: Job Control Variables, Prev: Job Control Builtins, Up: 7.3 Job Control Variables ========================= -'auto_resume' +‘auto_resume’ This variable controls how the shell interacts with the user and - job control. If this variable exists then single word simple - commands without redirections are treated as candidates for - resumption of an existing job. There is no ambiguity allowed; if - there is more than one job beginning with the string typed, then - the most recently accessed job will be selected. The name of a - stopped job, in this context, is the command line used to start it. - If this variable is set to the value 'exact', the string supplied - must match the name of a stopped job exactly; if set to - 'substring', the string supplied needs to match a substring of the - name of a stopped job. The 'substring' value provides - functionality analogous to the '%?' job ID (*note Job Control - Basics::). If set to any other value, the supplied string must be - a prefix of a stopped job's name; this provides functionality - analogous to the '%' job ID. + job control. If this variable exists then simple commands + consisting of only a single word, without redirections, are treated + as candidates for resumption of an existing job. There is no + ambiguity allowed; if there is more than one job beginning with or + containing the word, then this selects the most recently accessed + job. The name of a stopped job, in this context, is the command + line used to start it, as displayed by ‘jobs’. If this variable is + set to the value ‘exact’, the word must match the name of a stopped + job exactly; if set to ‘substring’, the word needs to match a + substring of the name of a stopped job. The ‘substring’ value + provides functionality analogous to the ‘%?string’ job ID (*note + Job Control Basics::). If set to any other value (e.g., ‘prefix’), + the word must be a prefix of a stopped job's name; this provides + functionality analogous to the ‘%string’ job ID.  File: bash.info, Node: Command Line Editing, Next: Using History Interactively, Prev: Job Control, Up: Top @@ -7716,14 +8492,14 @@ This chapter describes the basic features of the GNU command line editing interface. Command line editing is provided by the Readline library, which is used by several different programs, including Bash. Command line editing is enabled by default when using an interactive -shell, unless the '--noediting' option is supplied at shell invocation. -Line editing is also used when using the '-e' option to the 'read' +shell, unless the ‘--noediting’ option is supplied at shell invocation. +Line editing is also used when using the ‘-e’ option to the ‘read’ builtin command (*note Bash Builtins::). By default, the line editing -commands are similar to those of Emacs. A vi-style line editing +commands are similar to those of Emacs; a vi-style line editing interface is also available. Line editing can be enabled at any time -using the '-o emacs' or '-o vi' options to the 'set' builtin command -(*note The Set Builtin::), or disabled using the '+o emacs' or '+o vi' -options to 'set'. +using the ‘-o emacs’ or ‘-o vi’ options to the ‘set’ builtin command +(*note The Set Builtin::), or disabled using the ‘+o emacs’ or ‘+o vi’ +options to ‘set’. * Menu: @@ -7747,33 +8523,46 @@ File: bash.info, Node: Introduction and Notation, Next: Readline Interaction, 8.1 Introduction to Line Editing ================================ -The following paragraphs describe the notation used to represent -keystrokes. +The following paragraphs use Emacs style to describe the notation used +to represent keystrokes. - The text 'C-k' is read as 'Control-K' and describes the character + The text ‘C-k’ is read as 'Control-K' and describes the character produced when the key is pressed while the Control key is depressed. - The text 'M-k' is read as 'Meta-K' and describes the character + The text ‘M-k’ is read as 'Meta-K' and describes the character produced when the Meta key (if you have one) is depressed, and the -key is pressed. The Meta key is labeled on many keyboards. On -keyboards with two keys labeled (usually to either side of the -space bar), the on the left side is generally set to work as a -Meta key. The key on the right may also be configured to work as -a Meta key or may be configured as some other modifier, such as a +key is pressed (a “meta character”), then both are released. The Meta +key is labeled or