mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-02-13 19:52:20 +00:00
Reinstate 'r' and 'history' as preset aliases for interactive ksh
Following a community discussion, it became clear that 'r' is particularly problematic as a regular builtin, as the name can and does conflict with at least one legit external command by that name. There was a consensus against removing it altogether and letting users set the alias in their login scripts. However, aliases are easier to bypass, remove or rename than builtins are. My compromise is to reinstate 'r' as a preset alias on interactive shells only, along with 'history', as was done in17f81ebe
before they were converted to builtins in03224ae3
. So this reintroduces the notion of predefined aliases to ksh 93u+m, but only for interactive shells that are not initialised in POSIX mode. src/cmd/ksh93/Makefile, src/cmd/ksh93/Mamfile, src/cmd/ksh93/include/shtable.h, src/cmd/ksh93/data/aliases.c: - Restore aliases.c containing shtab_aliases[], a table specifying the preset aliases. src/cmd/ksh93/include/shtable.h, src/cmd/ksh93/sh/init.c: - Rename inittree() to sh_inittree() and make it extern, because we need to use it in main.c (sh_main()). src/cmd/ksh93/sh/main.c: sh_main(): - Init preset aliases from shtab_aliases[] only if the shell is interactive and not in POSIX mode. src/cmd/ksh93/bltins/typeset.c, src/cmd/ksh93/tests/alias.sh: - unall(): When unsetting an alias, pass on the NV_NOFREE attribute to nv_delete() to avoid an erroneous attempt to free a preset alias from read-only memory. See:5d50f825
src/cmd/ksh93/data/builtins.c: - Remove "history" and "r" entries from shtab_builtins[]. - Revert changes to inline fc/hist docs in sh_opthist[]. src/cmd/ksh93/bltins/hist.c: b_hist(): - Remove handling for 'history' and 'r' as builtins. src/cmd/ksh93/sh.1: - Update accordingly. Resolves: https://github.com/ksh93/ksh/issues/125
This commit is contained in:
parent
777dfa3e59
commit
ddaa145b3d
12 changed files with 90 additions and 37 deletions
5
NEWS
5
NEWS
|
@ -17,6 +17,11 @@ Any uppercase BUG_* names are modernish shell bug IDs.
|
||||||
b. 'command' can now stop the shell from exiting if a command that it
|
b. 'command' can now stop the shell from exiting if a command that it
|
||||||
invokes tries to modify a readonly variable (fixing BUG_CMDSPEXIT).
|
invokes tries to modify a readonly variable (fixing BUG_CMDSPEXIT).
|
||||||
|
|
||||||
|
- The 'history' (== 'hist -l') and 'r' (== 'hist -s') interactive shell
|
||||||
|
history commands have reverted to preset aliases and are now only loaded if
|
||||||
|
the shell is interactive and not initialised in POSIX mode. This avoids
|
||||||
|
unneeded conflicts with external commands by these names, particularly 'r'.
|
||||||
|
|
||||||
2020-09-09:
|
2020-09-09:
|
||||||
|
|
||||||
- Fixed BUG_LOOPRET2 and related bugs. The 'exit' and 'return' commands without
|
- Fixed BUG_LOOPRET2 and related bugs. The 'exit' and 'return' commands without
|
||||||
|
|
|
@ -145,7 +145,7 @@ end
|
||||||
$(SH) :: sh.1 pmain.c $(LIBS_req)
|
$(SH) :: sh.1 pmain.c $(LIBS_req)
|
||||||
|
|
||||||
DATAFILES = limits.c msg.c strdata.c testops.c keywords.c options.c \
|
DATAFILES = limits.c msg.c strdata.c testops.c keywords.c options.c \
|
||||||
signals.c builtins.c variables.c lexstates.c
|
signals.c aliases.c builtins.c variables.c lexstates.c
|
||||||
|
|
||||||
shell$(RELEASE) $(VERSION) id=shell :LIBRARY: shell.3 nval.3 alarm.c cd_pwd.c cflow.c deparse.c \
|
shell$(RELEASE) $(VERSION) id=shell :LIBRARY: shell.3 nval.3 alarm.c cd_pwd.c cflow.c deparse.c \
|
||||||
enum.c getopts.c hist.c misc.c print.c read.c sleep.c trap.c test.c \
|
enum.c getopts.c hist.c misc.c print.c read.c sleep.c trap.c test.c \
|
||||||
|
|
|
@ -1217,6 +1217,16 @@ meta signals.o %.c>%.o data/signals.c signals
|
||||||
prev data/signals.c
|
prev data/signals.c
|
||||||
exec - ${CC} ${mam_cc_FLAGS} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE} -DSHOPT_STATS -DSHOPT_NAMESPACE -DSHOPT_PFSH -DSHOPT_HISTEXPAND -D_BLD_shell -D_API_ast=20100309 -D_PACKAGE_ast -DERROR_CONTEXT_T=Error_context_t -DSHOPT_FIXEDARRAY -DSHOPT_ESH -DSHOPT_MULTIBYTE -c data/signals.c
|
exec - ${CC} ${mam_cc_FLAGS} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE} -DSHOPT_STATS -DSHOPT_NAMESPACE -DSHOPT_PFSH -DSHOPT_HISTEXPAND -D_BLD_shell -D_API_ast=20100309 -D_PACKAGE_ast -DERROR_CONTEXT_T=Error_context_t -DSHOPT_FIXEDARRAY -DSHOPT_ESH -DSHOPT_MULTIBYTE -c data/signals.c
|
||||||
done signals.o generated
|
done signals.o generated
|
||||||
|
make aliases.o
|
||||||
|
make data/aliases.c
|
||||||
|
prev FEATURE/dynamic implicit
|
||||||
|
prev FEATURE/options implicit
|
||||||
|
prev include/defs.h implicit
|
||||||
|
done data/aliases.c
|
||||||
|
meta aliases.o %.c>%.o data/aliases.c aliases
|
||||||
|
prev data/aliases.c
|
||||||
|
exec - ${CC} ${mam_cc_FLAGS} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE} -DSHOPT_DYNAMIC -DSHOPT_MULTIBYTE -D_PACKAGE_ast -DSHOPT_PFSH -DSHOPT_STATS -DSHOPT_NAMESPACE -DSHOPT_COSHELL -DSHOPT_HISTEXPAND -D_BLD_shell -D_API_ast=20100309 -DERROR_CONTEXT_T=Error_context_t -DSHOPT_FIXEDARRAY -DSHOPT_ESH -c data/aliases.c
|
||||||
|
done aliases.o generated
|
||||||
make builtins.o
|
make builtins.o
|
||||||
make data/builtins.c
|
make data/builtins.c
|
||||||
prev FEATURE/cmds implicit
|
prev FEATURE/cmds implicit
|
||||||
|
@ -1298,7 +1308,7 @@ prev edit/hexpand.c
|
||||||
exec - ${CC} ${mam_cc_FLAGS} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE} -DSHOPT_HISTEXPAND -DSHOPT_EDPREDICT -DSHOPT_MULTIBYTE -DKSHELL -DSHOPT_ESH -DSHOPT_VSH -D_PACKAGE_ast -DSHOPT_PFSH -DSHOPT_STATS -DSHOPT_NAMESPACE -D_BLD_shell -D_API_ast=20100309 -DERROR_CONTEXT_T=Error_context_t -DSHOPT_FIXEDARRAY -c edit/hexpand.c
|
exec - ${CC} ${mam_cc_FLAGS} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE} -DSHOPT_HISTEXPAND -DSHOPT_EDPREDICT -DSHOPT_MULTIBYTE -DKSHELL -DSHOPT_ESH -DSHOPT_VSH -D_PACKAGE_ast -DSHOPT_PFSH -DSHOPT_STATS -DSHOPT_NAMESPACE -D_BLD_shell -D_API_ast=20100309 -DERROR_CONTEXT_T=Error_context_t -DSHOPT_FIXEDARRAY -c edit/hexpand.c
|
||||||
done hexpand.o generated
|
done hexpand.o generated
|
||||||
exec - ${AR} rc libshell.a alarm.o cd_pwd.o cflow.o deparse.o enum.o getopts.o hist.o misc.o print.o read.o sleep.o trap.o test.o typeset.o ulimit.o umask.o whence.o main.o nvdisc.o nvtype.o arith.o args.o array.o completion.o defs.o edit.o expand.o regress.o fault.o fcin.o
|
exec - ${AR} rc libshell.a alarm.o cd_pwd.o cflow.o deparse.o enum.o getopts.o hist.o misc.o print.o read.o sleep.o trap.o test.o typeset.o ulimit.o umask.o whence.o main.o nvdisc.o nvtype.o arith.o args.o array.o completion.o defs.o edit.o expand.o regress.o fault.o fcin.o
|
||||||
exec - ${AR} rc libshell.a history.o init.o io.o jobs.o lex.o macro.o name.o nvtree.o parse.o path.o string.o streval.o subshell.o tdump.o timers.o trestore.o waitevent.o xec.o limits.o msg.o strdata.o testops.o keywords.o options.o signals.o builtins.o variables.o lexstates.o emacs.o vi.o hexpand.o
|
exec - ${AR} rc libshell.a history.o init.o io.o jobs.o lex.o macro.o name.o nvtree.o parse.o path.o string.o streval.o subshell.o tdump.o timers.o trestore.o waitevent.o xec.o limits.o msg.o strdata.o testops.o keywords.o options.o signals.o aliases.o builtins.o variables.o lexstates.o emacs.o vi.o hexpand.o
|
||||||
exec - (ranlib libshell.a) >/dev/null 2>&1 || true
|
exec - (ranlib libshell.a) >/dev/null 2>&1 || true
|
||||||
done libshell.a generated
|
done libshell.a generated
|
||||||
bind -lshell
|
bind -lshell
|
||||||
|
|
|
@ -58,13 +58,6 @@ int b_hist(int argc,char *argv[], Shbltin_t *context)
|
||||||
NOT_USED(argc);
|
NOT_USED(argc);
|
||||||
if(!sh_histinit((void*)shp))
|
if(!sh_histinit((void*)shp))
|
||||||
errormsg(SH_DICT,ERROR_system(1),e_histopen);
|
errormsg(SH_DICT,ERROR_system(1),e_histopen);
|
||||||
|
|
||||||
/* 'history' and 'r' builtins */
|
|
||||||
if(argv[0][0] == 'r') /* <r> */
|
|
||||||
edit = "-";
|
|
||||||
else if(argv[0][0] == 'h' && argv[0][4] == 'o') /* hist<o>ry (argv[0][4] is zero when called as 'hist') */
|
|
||||||
lflag = 1;
|
|
||||||
|
|
||||||
hp = shp->gd->hist_ptr;
|
hp = shp->gd->hist_ptr;
|
||||||
while((flag = optget(argv,sh_opthist))) switch(flag)
|
while((flag = optget(argv,sh_opthist))) switch(flag)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1311,7 +1311,7 @@ static int unall(int argc, char **argv, register Dt_t *troot, Shell_t* shp)
|
||||||
}
|
}
|
||||||
/* The alias has been unset by call to _nv_unset, remove it from the tree */
|
/* The alias has been unset by call to _nv_unset, remove it from the tree */
|
||||||
else if(troot==shp->alias_tree)
|
else if(troot==shp->alias_tree)
|
||||||
nv_delete(np,troot,0);
|
nv_delete(np,troot,nv_isattr(np,NV_NOFREE));
|
||||||
#if 0
|
#if 0
|
||||||
/* causes unsetting local variable to expose global */
|
/* causes unsetting local variable to expose global */
|
||||||
else if(shp->var_tree==troot && shp->var_tree!=shp->var_base && nv_search((char*)np,shp->var_tree,HASH_BUCKET|HASH_NOSCOPE))
|
else if(shp->var_tree==troot && shp->var_tree!=shp->var_base && nv_search((char*)np,shp->var_tree,HASH_BUCKET|HASH_NOSCOPE))
|
||||||
|
|
35
src/cmd/ksh93/data/aliases.c
Normal file
35
src/cmd/ksh93/data/aliases.c
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/***********************************************************************
|
||||||
|
* *
|
||||||
|
* This software is part of the ast package *
|
||||||
|
* Copyright (c) 1982-2012 AT&T Intellectual Property *
|
||||||
|
* and is licensed under the *
|
||||||
|
* Eclipse Public License, Version 1.0 *
|
||||||
|
* by AT&T Intellectual Property *
|
||||||
|
* *
|
||||||
|
* A copy of the License is available at *
|
||||||
|
* http://www.eclipse.org/org/documents/epl-v10.html *
|
||||||
|
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
|
||||||
|
* *
|
||||||
|
* Information and Software Systems Research *
|
||||||
|
* AT&T Research *
|
||||||
|
* Florham Park NJ *
|
||||||
|
* *
|
||||||
|
* David Korn <dgk@research.att.com> *
|
||||||
|
* *
|
||||||
|
***********************************************************************/
|
||||||
|
#pragma prototyped
|
||||||
|
#include "defs.h"
|
||||||
|
#include <signal.h>
|
||||||
|
#include "FEATURE/options"
|
||||||
|
#include "FEATURE/dynamic"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Table of built-in aliases for interactive shells.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const struct shtable2 shtab_aliases[] =
|
||||||
|
{
|
||||||
|
"history", NV_NOFREE, "hist -l",
|
||||||
|
"r", NV_NOFREE, "hist -s",
|
||||||
|
"", 0, (char*)0
|
||||||
|
};
|
|
@ -90,8 +90,6 @@ const struct shtable3 shtab_builtins[] =
|
||||||
"exit", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(return),
|
"exit", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(return),
|
||||||
"fc", NV_BLTIN|BLT_ENV|BLT_EXIT, bltin(hist),
|
"fc", NV_BLTIN|BLT_ENV|BLT_EXIT, bltin(hist),
|
||||||
"hist", NV_BLTIN|BLT_ENV|BLT_EXIT, bltin(hist),
|
"hist", NV_BLTIN|BLT_ENV|BLT_EXIT, bltin(hist),
|
||||||
"history", NV_BLTIN|BLT_ENV|BLT_EXIT, bltin(hist),
|
|
||||||
"r", NV_BLTIN|BLT_ENV|BLT_EXIT, bltin(hist),
|
|
||||||
"readonly", NV_BLTIN|BLT_ENV|BLT_SPC|BLT_DCL,bltin(readonly),
|
"readonly", NV_BLTIN|BLT_ENV|BLT_SPC|BLT_DCL,bltin(readonly),
|
||||||
"shift", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(shift),
|
"shift", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(shift),
|
||||||
"trap", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(trap),
|
"trap", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(trap),
|
||||||
|
@ -925,15 +923,11 @@ const char sh_opthash[] =
|
||||||
;
|
;
|
||||||
|
|
||||||
const char sh_opthist[] =
|
const char sh_opthist[] =
|
||||||
"[-1cn?@(#)$Id: hist (AT&T Research/ksh93) 2020-07-16 $\n]"
|
"[-1cn?@(#)$Id: hist (AT&T Research) 2000-04-02 $\n]"
|
||||||
USAGE_LICENSE
|
USAGE_LICENSE
|
||||||
"[+NAME?fc, hist, history, r - process command history list]"
|
"[+NAME?\f?\f - process command history list]"
|
||||||
"[+DESCRIPTION?\bhist\b lists, edits, or re-executes commands "
|
"[+DESCRIPTION?\b\f?\f\b lists, edits, or re-executes, commands "
|
||||||
"previously entered into the current shell environment.]"
|
"previously entered into the current shell environment.]"
|
||||||
"[+?The following command equivalents exist: "
|
|
||||||
"\bfc\b is \bhist\b; "
|
|
||||||
"\bhistory\b is \bhist -l\b (list history); "
|
|
||||||
"and \br\b is \bhist -s\b (reexecute command).]"
|
|
||||||
"[+?The command history list references commands by number. The first number "
|
"[+?The command history list references commands by number. The first number "
|
||||||
"in the list is selected arbitrarily. The relationship of a number "
|
"in the list is selected arbitrarily. The relationship of a number "
|
||||||
"to its command does not change during a login session. When the "
|
"to its command does not change during a login session. When the "
|
||||||
|
@ -941,11 +935,11 @@ USAGE_LICENSE
|
||||||
"maintains the ordering.]"
|
"maintains the ordering.]"
|
||||||
"[+?When commands are edited (when the \b-l\b option is not specified), the "
|
"[+?When commands are edited (when the \b-l\b option is not specified), the "
|
||||||
"resulting lines will be entered at the end of the history list and "
|
"resulting lines will be entered at the end of the history list and "
|
||||||
"then reexecuted by the current shell. The \bhist\b command that "
|
"then reexecuted by the current shell. The \b\f?\f\b command that "
|
||||||
"caused the editing will not be entered into the history list. If the "
|
"caused the editing will not be entered into the history list. If the "
|
||||||
"editor returns a non-zero exit status, this will suppress the "
|
"editor returns a non-zero exit status, this will suppress the "
|
||||||
"entry into the history list and the command reexecution. Command "
|
"entry into the history list and the command reexecution. Command "
|
||||||
"line variable assignments and redirections affect both the \bhist\b "
|
"line variable assignments and redirections affect both the \f?\f "
|
||||||
"command and the commands that are reexecuted.]"
|
"command and the commands that are reexecuted.]"
|
||||||
"[+?\afirst\a and \alast\a define the range of commands. \afirst\a and "
|
"[+?\afirst\a and \alast\a define the range of commands. \afirst\a and "
|
||||||
"\alast\a can be one of the following:]{"
|
"\alast\a can be one of the following:]{"
|
||||||
|
|
|
@ -55,10 +55,12 @@ extern const Shtable_t shtab_testops[];
|
||||||
extern const Shtable_t shtab_options[];
|
extern const Shtable_t shtab_options[];
|
||||||
extern const Shtable_t shtab_attributes[];
|
extern const Shtable_t shtab_attributes[];
|
||||||
extern const struct shtable2 shtab_variables[];
|
extern const struct shtable2 shtab_variables[];
|
||||||
|
extern const struct shtable2 shtab_aliases[];
|
||||||
extern const struct shtable2 shtab_signals[];
|
extern const struct shtable2 shtab_signals[];
|
||||||
extern const struct shtable3 shtab_builtins[];
|
extern const struct shtable3 shtab_builtins[];
|
||||||
extern const Shtable_t shtab_reserved[];
|
extern const Shtable_t shtab_reserved[];
|
||||||
extern const Shtable_t *sh_locate(const char*, const Shtable_t*, int);
|
extern const Shtable_t *sh_locate(const char*, const Shtable_t*, int);
|
||||||
extern int sh_lookopt(const char*, int*);
|
extern int sh_lookopt(const char*, int*);
|
||||||
|
extern Dt_t *sh_inittree(Shell_t*, const struct shtable2*);
|
||||||
|
|
||||||
#endif /* SH_TABLE_H */
|
#endif /* SH_TABLE_H */
|
||||||
|
|
|
@ -782,6 +782,20 @@ the
|
||||||
.B alias
|
.B alias
|
||||||
definition command has to be executed before
|
definition command has to be executed before
|
||||||
the command which references the alias is read.
|
the command which references the alias is read.
|
||||||
|
.PP
|
||||||
|
The following aliases are automatically preset
|
||||||
|
when the shell is invoked as an interactive shell,
|
||||||
|
unless invoked in POSIX compliance mode
|
||||||
|
(see
|
||||||
|
.I Invocation\^
|
||||||
|
below).
|
||||||
|
Preset aliases can be unset or redefined.
|
||||||
|
.RS 20
|
||||||
|
.PD 0
|
||||||
|
.TP
|
||||||
|
.B "history=\(fmhist \-l\(fm"
|
||||||
|
.TP
|
||||||
|
.B "r=\(fmhist \-s\(fm"
|
||||||
.PD
|
.PD
|
||||||
.RE
|
.RE
|
||||||
.SS Tilde Substitution.
|
.SS Tilde Substitution.
|
||||||
|
@ -4370,9 +4384,9 @@ to re-execute the command.
|
||||||
In this case a substitution parameter of the form
|
In this case a substitution parameter of the form
|
||||||
\f2old\fP\f3=\fP\f2new\fP
|
\f2old\fP\f3=\fP\f2new\fP
|
||||||
can be used to modify the command before execution.
|
can be used to modify the command before execution.
|
||||||
For example, with the builtin
|
For example, with the preset alias
|
||||||
.BR r ,
|
.BR r ,
|
||||||
which is functionally equivalent to
|
which is aliased to
|
||||||
.BR "\(fmhist \-s\(fm" ,
|
.BR "\(fmhist \-s\(fm" ,
|
||||||
typing
|
typing
|
||||||
`\f3r bad=good c\fP'
|
`\f3r bad=good c\fP'
|
||||||
|
@ -6239,11 +6253,6 @@ to start
|
||||||
.I num
|
.I num
|
||||||
commands back.
|
commands back.
|
||||||
.TP
|
.TP
|
||||||
\f3history\fP \*(OK \f3\-N\fP \f2num\^\fP \*(CK \*(OK \f3\-nr\^\fP \*(CK \*(OK \f2first\^\fP \*(OK \f2last\^\fP \*(CK \*(CK
|
|
||||||
Lists commands in the history file.
|
|
||||||
The same as
|
|
||||||
.BR hist\ \-l .
|
|
||||||
.TP
|
|
||||||
\(dd \f3integer\fP \f2vname\fP\*(OK\f3=\fP\f2value\^\fP\*(CK .\|.\|.
|
\(dd \f3integer\fP \f2vname\fP\*(OK\f3=\fP\f2value\^\fP\*(CK .\|.\|.
|
||||||
Declares each \f2vname\fP to be a long integer number.
|
Declares each \f2vname\fP to be a long integer number.
|
||||||
The same as
|
The same as
|
||||||
|
@ -6659,11 +6668,6 @@ or
|
||||||
on the command line
|
on the command line
|
||||||
determines which method is used.
|
determines which method is used.
|
||||||
.TP
|
.TP
|
||||||
\f3r\fP \*(OK \f2old\fP\f3\=\fP\f2new\^\fP \*(CK \*(OK \f2command\^\fP \*(CK
|
|
||||||
Reexecutes a command in the history file.
|
|
||||||
The same as
|
|
||||||
.BR hist\ \-s .
|
|
||||||
.TP
|
|
||||||
\f3read\fP \*(OK \f3\-ACSprsv\^\fP \*(CK \*(OK \f3\-d\fP \f2delim \^\fP\*(CK \*(OK \f3\-n\fP \f2n \^\fP\*(CK \*(OK \*(OK \f3\-N\fP \f2n \^\fP\*(CK \*(OK \f3\-t\fP \f2timeout \^\fP\*(CK \*(OK \f3\-u\fP \f2unit \^\fP\*(CK \*(OK \f2vname\f3?\f2prompt\^\f1 \*(CK \*(OK \f2vname\^\fP .\|.\|. \*(CK
|
\f3read\fP \*(OK \f3\-ACSprsv\^\fP \*(CK \*(OK \f3\-d\fP \f2delim \^\fP\*(CK \*(OK \f3\-n\fP \f2n \^\fP\*(CK \*(OK \*(OK \f3\-N\fP \f2n \^\fP\*(CK \*(OK \f3\-t\fP \f2timeout \^\fP\*(CK \*(OK \f3\-u\fP \f2unit \^\fP\*(CK \*(OK \f2vname\f3?\f2prompt\^\f1 \*(CK \*(OK \f2vname\^\fP .\|.\|. \*(CK
|
||||||
The shell input mechanism.
|
The shell input mechanism.
|
||||||
One line is read and
|
One line is read and
|
||||||
|
@ -7059,6 +7063,7 @@ disables passing exported variables' attributes (such as integer or readonly) to
|
||||||
causes file descriptors > 2 to be left open when invoking another program,
|
causes file descriptors > 2 to be left open when invoking another program,
|
||||||
makes the \fB<>\fR redirection operator default to standard input,
|
makes the \fB<>\fR redirection operator default to standard input,
|
||||||
causes the \fBcommand\fR utility to disable declaration command properties of any declaration commands it invokes,
|
causes the \fBcommand\fR utility to disable declaration command properties of any declaration commands it invokes,
|
||||||
|
skips the initialization of preset aliases upon invoking an interactive shell,
|
||||||
disables a hack that makes \fBtest -t\fR (\fB[ -t ]\fR) equivalent to \fBtest -t 1\fR (\fB[ -t 1 ]\fR),
|
disables a hack that makes \fBtest -t\fR (\fB[ -t ]\fR) equivalent to \fBtest -t 1\fR (\fB[ -t 1 ]\fR),
|
||||||
enables octal numbers in \fBlet\fR shell arithmetic (see \fBletoctal\fR), and
|
enables octal numbers in \fBlet\fR shell arithmetic (see \fBletoctal\fR), and
|
||||||
disables the \fB&>\fR redirection shorthand.
|
disables the \fB&>\fR redirection shorthand.
|
||||||
|
|
|
@ -201,7 +201,6 @@ static int lctype;
|
||||||
static int nbltins;
|
static int nbltins;
|
||||||
static void env_init(Shell_t*,int);
|
static void env_init(Shell_t*,int);
|
||||||
static Init_t *nv_init(Shell_t*);
|
static Init_t *nv_init(Shell_t*);
|
||||||
static Dt_t *inittree(Shell_t*,const struct shtable2*);
|
|
||||||
static int shlvl;
|
static int shlvl;
|
||||||
|
|
||||||
#ifdef _WINIX
|
#ifdef _WINIX
|
||||||
|
@ -1709,7 +1708,7 @@ static Init_t *nv_init(Shell_t *shp)
|
||||||
shp->nvfun.last = (char*)shp;
|
shp->nvfun.last = (char*)shp;
|
||||||
shp->nvfun.nofree = 1;
|
shp->nvfun.nofree = 1;
|
||||||
ip->sh = shp;
|
ip->sh = shp;
|
||||||
shp->var_base = shp->var_tree = inittree(shp,shtab_variables);
|
shp->var_base = shp->var_tree = sh_inittree(shp,shtab_variables);
|
||||||
SHLVL->nvalue.ip = &shlvl;
|
SHLVL->nvalue.ip = &shlvl;
|
||||||
ip->IFS_init.hdr.disc = &IFS_disc;
|
ip->IFS_init.hdr.disc = &IFS_disc;
|
||||||
ip->PATH_init.disc = &RESTRICTED_disc;
|
ip->PATH_init.disc = &RESTRICTED_disc;
|
||||||
|
@ -1800,7 +1799,7 @@ static Init_t *nv_init(Shell_t *shp)
|
||||||
/* set up the seconds clock */
|
/* set up the seconds clock */
|
||||||
shp->alias_tree = dtopen(&_Nvdisc,Dtoset);
|
shp->alias_tree = dtopen(&_Nvdisc,Dtoset);
|
||||||
shp->track_tree = dtopen(&_Nvdisc,Dtset);
|
shp->track_tree = dtopen(&_Nvdisc,Dtset);
|
||||||
shp->bltin_tree = inittree(shp,(const struct shtable2*)shtab_builtins);
|
shp->bltin_tree = sh_inittree(shp,(const struct shtable2*)shtab_builtins);
|
||||||
shp->fun_tree = dtopen(&_Nvdisc,Dtoset);
|
shp->fun_tree = dtopen(&_Nvdisc,Dtoset);
|
||||||
dtview(shp->fun_tree,shp->bltin_tree);
|
dtview(shp->fun_tree,shp->bltin_tree);
|
||||||
nv_mount(DOTSHNOD, "type", shp->typedict=dtopen(&_Nvdisc,Dtoset));
|
nv_mount(DOTSHNOD, "type", shp->typedict=dtopen(&_Nvdisc,Dtoset));
|
||||||
|
@ -1823,7 +1822,7 @@ static Init_t *nv_init(Shell_t *shp)
|
||||||
* initialize name-value pairs
|
* initialize name-value pairs
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static Dt_t *inittree(Shell_t *shp,const struct shtable2 *name_vals)
|
Dt_t *sh_inittree(Shell_t *shp,const struct shtable2 *name_vals)
|
||||||
{
|
{
|
||||||
register Namval_t *np;
|
register Namval_t *np;
|
||||||
register const struct shtable2 *tp;
|
register const struct shtable2 *tp;
|
||||||
|
|
|
@ -175,6 +175,12 @@ int sh_main(int ac, char *av[], Shinit_f userinit)
|
||||||
{
|
{
|
||||||
sh_onoption(SH_BGNICE);
|
sh_onoption(SH_BGNICE);
|
||||||
sh_onoption(SH_RC);
|
sh_onoption(SH_RC);
|
||||||
|
if(!sh_isoption(SH_POSIX))
|
||||||
|
{
|
||||||
|
/* preset aliases for interactive non-POSIX ksh */
|
||||||
|
dtclose(shp->alias_tree);
|
||||||
|
shp->alias_tree = sh_inittree(shp,shtab_aliases);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#if SHOPT_REMOTE
|
#if SHOPT_REMOTE
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -109,5 +109,9 @@ alias foo=bar
|
||||||
unalias foo
|
unalias foo
|
||||||
unalias foo && err_exit 'unalias should return non-zero when a previously set alias is unaliased twice'
|
unalias foo && err_exit 'unalias should return non-zero when a previously set alias is unaliased twice'
|
||||||
|
|
||||||
|
# Removing a preset alias should work without an error from free(3)
|
||||||
|
err=$(set +x; { "$SHELL" -i -c 'unalias history'; } 2>&1) && [[ -z $err ]] \
|
||||||
|
|| err_exit "removing a preset alias does not work (got $(printf %q "$err"))"
|
||||||
|
|
||||||
# ======
|
# ======
|
||||||
exit $((Errors<125?Errors:125))
|
exit $((Errors<125?Errors:125))
|
||||||
|
|
Loading…
Reference in a new issue