Skip to content

Commit

Permalink
Merge branch 'dev' into dyn
Browse files Browse the repository at this point in the history
  • Loading branch information
McDutchie committed Mar 22, 2024
2 parents 047f249 + 0af4dc9 commit 4570a92
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 6 deletions.
5 changes: 5 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ This documents significant changes in the dev branch of ksh 93u+m.
For full details, see the git log at: https://github.com/ksh93/ksh
Uppercase BUG_* IDs are shell bug IDs as used by the Modernish shell library.

2024-03-22:

- Fixed a crash in the getconf built-in that could occur after the 'builtin'
command was used to bind it to the same path as the external getconf command.

2024-03-20:

- Android with Termux is now a supported environment for ksh 93u+m. Testing
Expand Down
9 changes: 9 additions & 0 deletions bin/package
Original file line number Diff line number Diff line change
Expand Up @@ -1727,6 +1727,15 @@ DEFPATH=$(
$CC $CCFLAGS $LDFLAGS -o "$t.exe" "$t.c" 2>/dev/null && "$t.exe"
}
) || DEFPATH=/bin:/usr/bin:/sbin:/usr/sbin
# Fix for Android/Termux. The /bin directory exists with standard
# utilities (sh, Toybox utils) but it is not included in _PATH_DEFPATH.
# It should come first because /bin is read-only.
if test -d /data/data/com.termux && test "$(/bin/uname -o 2>/dev/null)" = Android
then case ":$DEFPATH:" in
*:/bin:* ) ;;
* ) DEFPATH=/bin:$DEFPATH ;;
esac
fi
# Fix for NixOS. Not all POSIX standard utilities come with the default system,
# e.g. 'bc', 'file', 'vi'. The command that NixOS recommends to get missing
# utilities, e.g. 'nix-env -iA nixos.bc', installs them in a default profile
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/ksh93/include/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#define SH_RELEASE_FORK "93u+m" /* only change if you develop a new ksh93 fork */
#define SH_RELEASE_SVER "1.1.0-alpha" /* semantic version number: https://semver.org */
#define SH_RELEASE_DATE "2024-03-20" /* must be in this format for $((.sh.version)) */
#define SH_RELEASE_DATE "2024-03-22" /* must be in this format for $((.sh.version)) */
#define SH_RELEASE_CPYR "(c) 2020-2024 Contributors to ksh " SH_RELEASE_FORK

/* Scripts sometimes field-split ${.sh.version}, so don't change amount of whitespace. */
Expand Down
15 changes: 15 additions & 0 deletions src/cmd/ksh93/tests/path.sh
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ if builtin getconf 2> /dev/null; then
fi

PATH=$path
builtin -d /bin/getconf

scr=$tmp/script
exp=126
Expand Down Expand Up @@ -1022,5 +1023,19 @@ got=${ whence -t whence_t_test 2>&1; }
got=${ type -t whence_t_test 2>&1; }
[[ $got == "$exp" ]] || err_exit "incorrect 'type -t' output for undefined function (expected '$exp', got '$got')"

# ======
(
builtin getconf 2>/dev/null || exit 1
p=$(getconf GETCONF)
[[ $p == /*/getconf ]] || exit 2
builtin -d getconf
builtin "$p"
PATH=${p%/getconf}
getconf some_nonexistent_config_variable # be sure to trigger fallback to external command
exit 0
) >/dev/null 2>&1
(((e = $?) > 1)) && err_exit 'getconf builtin fails when on same path as external getconf' \
"(got status $e$( ((e>128)) && print -n /SIG && kill -l "$e"))"

# ======
exit $((Errors<125?Errors:125))
6 changes: 3 additions & 3 deletions src/lib/libast/port/astconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -790,9 +790,9 @@ feature(Feature_t* fp, const char* name, const char* path, const char* value, un
static int
lookup(Lookup_t* look, const char* name, unsigned int flags)
{
Conf_t* mid = (Conf_t*)conf;
Conf_t* lo = mid;
Conf_t* hi = mid + conf_elements;
Conf_t* lo = (Conf_t*)conf;
Conf_t* mid = lo;
Conf_t* hi = lo + conf_elements - 1;
int v = 0;
int c;
char* e;
Expand Down
9 changes: 7 additions & 2 deletions src/lib/libcmd/getconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ b_getconf(int argc, char** argv, Shbltin_t* context)
int flags;
int n;
char** oargv;
char** new_argv;
static const char empty[] = "-";

cmdinit(argc, argv, context, ERROR_CATALOG, 0);
Expand Down Expand Up @@ -274,8 +275,12 @@ b_getconf(int argc, char** argv, Shbltin_t* context)
/*
* Run the external getconf command
*/
oargv[0] = native;
if ((n = sh_run(context, argc, oargv)) >= EXIT_NOEXEC)
new_argv = stkalloc(stkstd, (argc + 3) * sizeof(char*));
new_argv[0] = "command";
new_argv[1] = "-x";
new_argv[2] = native;
memcpy(new_argv + 3, oargv + 1, argc * sizeof(char*));
if ((n = sh_run(context, argc + 2, new_argv)) >= EXIT_NOEXEC)
error(ERROR_SYSTEM|2, "%s: exec error [%d]", native, n);
return n;
}

0 comments on commit 4570a92

Please sign in to comment.