diff --git a/NEWS b/NEWS index f19c82761bbe..7f2ad657ce20 100644 --- a/NEWS +++ b/NEWS @@ -4,7 +4,7 @@ Uppercase BUG_* IDs are shell bug IDs as used by the Modernish shell library. 2024-07-21: -- Fixed a long-stnading parsing bug: a '((' that was unmatched by +- Fixed a long-standing parsing bug: a '((' that was unmatched by corresponding closing parentheses and enclosed within a compound command failed to throw a syntax error and could cause the shell to crash. diff --git a/bin/package b/bin/package index be54c68c41c8..8d2d4666abd5 100755 --- a/bin/package +++ b/bin/package @@ -2633,7 +2633,6 @@ do_install() # dir [ command ... ] if test -d "dyn/lib" then trace mkdir -p "$libdir" "$man3dir" "$includedir" # install libraries - # note: to copy symlinks with BSD cp, we need to specify -R as well as -P, contra POSIX set +o noglob for f in dyn/lib/* do set -o noglob diff --git a/src/cmd/INIT/mkdeps.sh b/src/cmd/INIT/mkdeps.sh index 1c444640297b..a4d5d7d6c878 100755 --- a/src/cmd/INIT/mkdeps.sh +++ b/src/cmd/INIT/mkdeps.sh @@ -115,14 +115,6 @@ do case $opt in done shift $((OPTIND - 1)) -# Process library header dependencies. -for f in $libdeps -do test -f "$INSTALLROOT/lib/mam/$f" || error_out "$f: header dependencies not found" - # assign state_NAME=made for each dependency header, so only prev commands are generated - f=$(sed -n 's|.*make \${INCLUDE_AST}/\([A-Za-z0-9_]*\)\.h.*|state_\1=made|p' "$INSTALLROOT/lib/mam/$f") || exit - eval "$f" -done - # Init state. ast=include/ast root=${INSTALLROOT?AST environment not initialised}/$ast @@ -131,6 +123,14 @@ prefix="\${$prevar}/" cd "$root" || error_out "cd '$root' failed" indent=1 +# Process library header dependencies. +for f in $libdeps +do test -f "$INSTALLROOT/lib/mam/$f" || error_out "$f: header dependencies not found" + # assign state_NAME=made for each dependency header, so only prev commands are generated + f=$(sed -n "s|.*make \\$prefix\([A-Za-z0-9_]*\)\.h.*|state_\1=made|p" "$INSTALLROOT/lib/mam/$f") || exit + eval "$f" +done + # Validate for 'eval' safety: header file names minus $root and .h must be valid variable name components. for f do test -f "$f" || error_out "$f: not found" diff --git a/src/cmd/ksh93/data/builtins.c b/src/cmd/ksh93/data/builtins.c index 3d7d7950fff5..f74c79bc90b1 100644 --- a/src/cmd/ksh93/data/builtins.c +++ b/src/cmd/ksh93/data/builtins.c @@ -1845,10 +1845,10 @@ const char sh_opttypeset[] = "[+NAME?typeset - declare or display variables with attributes]" "[+DESCRIPTION?Without the \b-f\b option, \btypeset\b sets, unsets, " "or displays attributes of variables as specified with the " - "options. If the first option is specified with a \b-\b " + "options. If the first option is specified with a \b-\b, " "then the attributes are set for each of the given \aname\as. " "If the first option is specified with a \b+\b, then the specified " - "attributes are unset. If \b=\b\avalue\a is specified value is " + "attributes are unset. If \b=\b\avalue\a is specified, \avalue\a is " "assigned before the attributes are set.]" "[+?When \btypeset\b is called inside a function defined with the " "\bfunction\b reserved word, and \aname\a does not contain a " @@ -1865,9 +1865,9 @@ const char sh_opttypeset[] = "[+integer?\btypeset -li\b]" "[+nameref?\btypeset -n\b]" "}" -"[+?If no \aname\as are specified then variables that have the specified " +"[+?If no \aname\as are specified, then variables that have the specified " "options are displayed. If the first option is specified with " - "a leading \b-\b then the name and value of each variable is " + "a leading \b-\b, then the name and value of each variable is " "written to standard output. Otherwise, only the names are " "written. If no options are specified or just \b-p\b is " "specified, then the names and attributes of all variables that have " @@ -1937,14 +1937,14 @@ const char sh_opttypeset[] = "UNIX format pathname will cause it to be converted to a pathname " "suitable for the current host. This has no effect when the " "native system is UNIX.]" -"[L]#?[n?Left justify. If \an\a is given it represents the field width. If " +"[L]#?[n?Left justify. If \an\a is given, it represents the field width. If " "the \b-Z\b attribute is also specified, then leading zeros are " "stripped.]" "[M]:?[mapping?\amapping\a is the name of a character mapping known by " "\bwctrans\b(3) such as \btolower\b or \btoupper\b. When the option " "value \bmapping\b is omitted and there are no operands, all mapped " "variables are displayed.]" -"[R]#?[n?Right justify. If \an\a is given it represents the field width. If " +"[R]#?[n?Right justify. If \an\a is given, it represents the field width. If " "the \b-Z\b attribute is also specified, then zeros will " "be used as the fill character. Otherwise, spaces are used.]" "[X]#?[n:=2*sizeof(long long)?Floating point number represented in hexadecimal " @@ -1958,7 +1958,7 @@ const char sh_opttypeset[] = "will have function static scope. Otherwise, the variable is " "unset prior to processing the assignment list.]" "[T]:?[tname?\atname\a is the name of a type name given to each \aname\a.]" -"[Z]#?[n?Zero fill. If \an\a is given it represents the field width.]" +"[Z]#?[n?Zero fill. If \an\a is given, it represents the field width.]" "\n" "\n[name[=value]...]\n" " -f [-tu] [name...]\n" diff --git a/src/cmd/ksh93/edit/hexpand.c b/src/cmd/ksh93/edit/hexpand.c index 9b9886dc629c..a84fa3c678ca 100644 --- a/src/cmd/ksh93/edit/hexpand.c +++ b/src/cmd/ksh93/edit/hexpand.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1982-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2023 Contributors to ksh 93u+m * +* Copyright (c) 2020-2024 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 2.0 * * * diff --git a/src/cmd/ksh93/sh.1 b/src/cmd/ksh93/sh.1 index 038378b2939d..ba9cea89fa8a 100644 --- a/src/cmd/ksh93/sh.1 +++ b/src/cmd/ksh93/sh.1 @@ -4342,9 +4342,7 @@ like: indicating that the job which was started asynchronously was job number 1 and had one (top-level) process, whose process ID was 1234. .PP -This paragraph and the next require features that are -not in all versions of UNIX and may not apply. -If you are running a job and wish to do something else you may hit the key +If you are running a job and wish to do something else, you may hit the key \fB^Z\fR (control-Z) which sends a STOP signal to the current job. The shell will then normally indicate that the job has been `Stopped', and print another prompt. @@ -4409,6 +4407,9 @@ option of the command causes the shell to print these job change messages as soon as they occur. +If this happens while you are typing a command with one of the +built-in line editors active, the job change message appears +above your input without disturbing your command entry. .PP When the .B monitor diff --git a/src/cmd/ksh93/sh/init.c b/src/cmd/ksh93/sh/init.c index 17d665cea245..bfbd1adbf4db 100644 --- a/src/cmd/ksh93/sh/init.c +++ b/src/cmd/ksh93/sh/init.c @@ -1660,7 +1660,6 @@ void sh_reinit(void) freeup_tree(sh.var_tree); #if SHOPT_STATS free(sh.stats); - sh.stats = NULL; #endif /* Re-init variables, functions and built-ins */ free(sh.bltin_cmds); @@ -1915,8 +1914,7 @@ static Init_t *nv_init(void) nv_onattr(VERSIONNOD,NV_REF); math_init(); #if SHOPT_STATS - if(!sh.stats) - stat_init(); + stat_init(); #endif return ip; } diff --git a/src/cmd/ksh93/tests/arith.sh b/src/cmd/ksh93/tests/arith.sh index 6134854aa39b..cfafe2a191d8 100755 --- a/src/cmd/ksh93/tests/arith.sh +++ b/src/cmd/ksh93/tests/arith.sh @@ -1099,23 +1099,23 @@ got=$(let '016#F' 2>&1) exp=": \`(' unmatched" got=$( ( ulimit -c 0; set +x; eval '{ (( $(( 1 )); }' ) 2>&1 ) [[ e=$? -eq 3 && $got == *"$exp" ]] || err_exit "unmatched '((', test 1" \ - "(expected status 1 and match of *'$exp'," \ + "(expected status 1 and match of *$(printf %q "$exp")," \ "got status $e$( ((e>128)) && print -n /SIG && kill -l "$e") and $(printf %q "$got"))" got=$( ( ulimit -c 0; set +x; eval 'x=$(( }; echo end' ) 2>&1 ) [[ e=$? -eq 3 && $got == *"$exp" ]] || err_exit "unmatched '((', test 2" \ - "(expected status 1 and match of *'$exp'," \ + "(expected status 1 and match of *$(printf %q "$exp")," \ "got status $e$( ((e>128)) && print -n /SIG && kill -l "$e") and $(printf %q "$got"))" got=$( ( ulimit -c 0; set +x; eval '{ x=$(( }; echo end; }' ) 2>&1 ) [[ e=$? -eq 3 && $got == *"$exp" ]] || err_exit "unmatched '((', test 3" \ - "(expected status 1 and match of *'$exp'," \ + "(expected status 1 and match of *$(printf %q "$exp")," \ "got status $e$( ((e>128)) && print -n /SIG && kill -l "$e") and $(printf %q "$got"))" got=$( ( ulimit -c 0; set +x; eval '(( }; echo end' ) 2>&1 ) [[ e=$? -eq 3 && $got == *"$exp" ]] || err_exit "unmatched '((', test 4" \ - "(expected status 1 and match of *'$exp'," \ + "(expected status 1 and match of *$(printf %q "$exp")," \ "got status $e$( ((e>128)) && print -n /SIG && kill -l "$e") and $(printf %q "$got"))" got=$( ( ulimit -c 0; set +x; eval '{ (( }; echo end; }' ) 2>&1 ) [[ e=$? -eq 3 && $got == *"$exp" ]] || err_exit "unmatched '((', test 5" \ - "(expected status 1 and match of *'$exp'," \ + "(expected status 1 and match of *$(printf %q "$exp")," \ "got status $e$( ((e>128)) && print -n /SIG && kill -l "$e") and $(printf %q "$got"))" got=$( ( ulimit -c 0; set +x; eval '{ (( $(( 1 )) )); }' ) 2>&1 ) diff --git a/src/lib/libast/Mamfile b/src/lib/libast/Mamfile index dc7eeac1195f..0ebfa24e4ef1 100644 --- a/src/lib/libast/Mamfile +++ b/src/lib/libast/Mamfile @@ -4811,6 +4811,13 @@ make install virtual done done + note * install releaseflags.h outside the lib/ast/mam block below, so the mkdeps action is not triggered when + note * releaseflags.h changes every time that the git commit changes (it doesn't contain #includes anyway) + make ${INCLUDE_AST}/releaseflags.h + prev releaseflags.h + exec - cp -f ${<} ${@} + done + note * #include headers make ${INSTALLROOT}/lib/mam/ast note * ...main AST headers @@ -4835,14 +4842,14 @@ make install virtual done done note * ...generated headers - loop HDR releaseflags ast_standards ast_common ast_lib ast_sys lc align sig tmx tv ast_api ast_ccode ast_fcntl ast_float ast_fs ast_map ast_mmap ast_mode ast_ndbm ast_param ast_time ast_tty ast_wait ast_limits ast_sizeof ast_dirent ast_iconv ast_nl_types ast_stdio ast_wchar ast_wctype + loop HDR ast_standards ast_common ast_lib ast_sys lc align sig tmx tv ast_api ast_ccode ast_fcntl ast_float ast_fs ast_map ast_mmap ast_mode ast_ndbm ast_param ast_time ast_tty ast_wait ast_limits ast_sizeof ast_dirent ast_iconv ast_nl_types ast_stdio ast_wchar ast_wctype make ${INCLUDE_AST}/${HDR}.h prev ${HDR}.h exec - cp -f ${<} ${@} done done note * generate header dependency rules - exec - mkdeps -last ${^} > ${@} + exec - mkdeps -last ${INCLUDE_AST}/releaseflags.h ${^} > ${@} prev ${INSTALLROOT}/bin/mkdeps done ${INSTALLROOT}/lib/mam/ast diff --git a/src/lib/libast/features/fcntl.c b/src/lib/libast/features/fcntl.c index 65677f068b3a..79d345664ecb 100644 --- a/src/lib/libast/features/fcntl.c +++ b/src/lib/libast/features/fcntl.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2012 AT&T Intellectual Property * -* Copyright (c) 2020-2023 Contributors to ksh 93u+m * +* Copyright (c) 2020-2024 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 2.0 * * * @@ -308,8 +308,5 @@ main(void) printf("extern int open(const char*, int, ...);\n"); #endif #endif - printf("\n"); - printf("#include \n"); - return 0; } diff --git a/src/lib/libast/man/path.3 b/src/lib/libast/man/path.3 index ac3dcc5b8e5e..f44142fea220 100644 --- a/src/lib/libast/man/path.3 +++ b/src/lib/libast/man/path.3 @@ -68,7 +68,7 @@ Path buffers are assumed to be of size always defines .LR PATH_MAX , even if it's indeterminate on the local system. -Yes, this was probably a bad choice, but it was made about 10 years ago. +Yes, this was probably a bad choice, but it was made in the 1980s. We will probably move to a based implementation. .PP .L pathaccess diff --git a/src/lib/libast/man/sig.3 b/src/lib/libast/man/sig.3 index 1f3986969f07..9e863bb3ed89 100644 --- a/src/lib/libast/man/sig.3 +++ b/src/lib/libast/man/sig.3 @@ -49,7 +49,7 @@ sig \- signal interface routines .SH DESCRIPTION .B sigunblock is called to -unblocks the signal +unblock the signal .B sig from within a handler currently servicing .BR sig .