mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
fix "$-" expansion for posix option (re: 921bbcae
)
In the SHOPT_BASH code, the -o posix option was given a '\374' (0xFC, 252) single-letter option character. Reasons unclear. The 'set' builtin doesn't accept it. It can be omitted and the option still works. And it caused the "$-" expansion (listing active short-form options) to include that invalid high-bit character if the -o posix option is active, which is clearly wrong. src/cmd/ksh93/sh/args.c: optksh[], flagval[]: - Remove '\374' one-letter option equivalent for SH_POSIX. src/cmd/ksh93/tests/options.sh: - Add test verifying that '-o posix' does not affect "$-".
This commit is contained in:
parent
bec6556236
commit
3ede73aa33
2 changed files with 12 additions and 2 deletions
|
@ -54,13 +54,12 @@
|
||||||
static char *null;
|
static char *null;
|
||||||
|
|
||||||
/* The following order is determined by sh_optset */
|
/* The following order is determined by sh_optset */
|
||||||
static const char optksh[] = PFSHOPT "\374" "DircabefhkmnpstuvxBCGEl" HFLAG;
|
static const char optksh[] = PFSHOPT "DircabefhkmnpstuvxBCGEl" HFLAG;
|
||||||
static const int flagval[] =
|
static const int flagval[] =
|
||||||
{
|
{
|
||||||
#if SHOPT_PFSH
|
#if SHOPT_PFSH
|
||||||
SH_PFSH,
|
SH_PFSH,
|
||||||
#endif
|
#endif
|
||||||
SH_POSIX,
|
|
||||||
SH_DICTIONARY, SH_INTERACTIVE, SH_RESTRICTED, SH_CFLAG,
|
SH_DICTIONARY, SH_INTERACTIVE, SH_RESTRICTED, SH_CFLAG,
|
||||||
SH_ALLEXPORT, SH_NOTIFY, SH_ERREXIT, SH_NOGLOB, SH_TRACKALL,
|
SH_ALLEXPORT, SH_NOTIFY, SH_ERREXIT, SH_NOGLOB, SH_TRACKALL,
|
||||||
SH_KEYWORD, SH_MONITOR, SH_NOEXEC, SH_PRIVILEGED, SH_SFLAG, SH_TFLAG,
|
SH_KEYWORD, SH_MONITOR, SH_NOEXEC, SH_PRIVILEGED, SH_SFLAG, SH_TFLAG,
|
||||||
|
|
|
@ -531,4 +531,15 @@ print '. ./dotfile' > envfile
|
||||||
print $'alias print=:\nprint foobar' > dotfile
|
print $'alias print=:\nprint foobar' > dotfile
|
||||||
[[ $(ENV=/.$PWD/envfile $SHELL -i -c : 2>/dev/null) == foobar ]] && err_exit 'files source from profile does not process aliases correctly'
|
[[ $(ENV=/.$PWD/envfile $SHELL -i -c : 2>/dev/null) == foobar ]] && err_exit 'files source from profile does not process aliases correctly'
|
||||||
|
|
||||||
|
# ======
|
||||||
|
# test that '-o posix' option (not having a letter) does not affect "$-" expansion
|
||||||
|
(
|
||||||
|
command set +o posix 2>/dev/null
|
||||||
|
opt1=$-
|
||||||
|
command set -o posix 2>/dev/null
|
||||||
|
opt2=$-
|
||||||
|
[[ $opt1 == "$opt2" ]]
|
||||||
|
) || err_exit '-o posix option affects $- expansion'
|
||||||
|
|
||||||
|
# ======
|
||||||
exit $((Errors<125?Errors:125))
|
exit $((Errors<125?Errors:125))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue