mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
sh_exec(): do not turn off editors for path-bound builtins
Here's another one from the "question everything" department. Every time ksh executes a built-in, it checks whether it is bound to a path (the name contains a '/') and if so, it turns off the vi, emacs and gmacs shell options before executing it. After executing the built-ins, those shell options are restored again. The comment is: "turn off editors for built-in versions of commands on PATH". But why? Commands do not and cannot ever use the command line editors. They are only ever executed on an interactive shell *between* running commands. So turning them off during the execution of a command makes no difference. The only possible effect is that these commands cannot check if a user has the vi, emacs or gmacs option on, or change these options itself. But what purpose could that limitation possibly serve? And what sense does it make to do this for path-bound built-ins only and not for other commands? And what sense does it make to have this limitation only for the editor shell options and not others? This waste of CPU cycles has been there since the beginning of the ksh93-history repo (1995) so if there was ever any good reason for it, it has been lost in the mist of history. I'm 99.999% sure that nothing will happen after deleting this.
This commit is contained in:
parent
b93216ce88
commit
f51e54828e
1 changed files with 0 additions and 34 deletions
|
@ -1231,34 +1231,11 @@ int sh_exec(register const Shnode_t *t, int flags)
|
|||
int save_prompt;
|
||||
int was_nofork = execflg?sh_isstate(SH_NOFORK):0;
|
||||
struct checkpt *buffp = (struct checkpt*)stkalloc(sh.stk,sizeof(struct checkpt));
|
||||
#if SHOPT_VSH
|
||||
volatile unsigned long was_vi=0;
|
||||
#endif
|
||||
#if SHOPT_ESH
|
||||
volatile unsigned long was_emacs=0, was_gmacs=0;
|
||||
#endif
|
||||
struct stat statb;
|
||||
bp = &sh.bltindata;
|
||||
save_ptr = bp->ptr;
|
||||
save_data = bp->data;
|
||||
memset(&statb, 0, sizeof(struct stat));
|
||||
if(strchr(nv_name(np),'/'))
|
||||
{
|
||||
/*
|
||||
* disable editors for built-in
|
||||
* versions of commands on PATH
|
||||
*/
|
||||
#if SHOPT_VSH
|
||||
was_vi = sh_isoption(SH_VI);
|
||||
sh_offoption(SH_VI);
|
||||
#endif
|
||||
#if SHOPT_ESH
|
||||
was_emacs = sh_isoption(SH_EMACS);
|
||||
was_gmacs = sh_isoption(SH_GMACS);
|
||||
sh_offoption(SH_EMACS);
|
||||
sh_offoption(SH_GMACS);
|
||||
#endif
|
||||
}
|
||||
if(execflg)
|
||||
sh_onstate(SH_NOFORK);
|
||||
sh_pushcontext(buffp,SH_JMPCMD);
|
||||
|
@ -1417,17 +1394,6 @@ int sh_exec(register const Shnode_t *t, int flags)
|
|||
sh.bltinfun = 0;
|
||||
if(buffp->olist)
|
||||
free_list(buffp->olist);
|
||||
#if SHOPT_VSH
|
||||
if(was_vi)
|
||||
sh_onoption(SH_VI);
|
||||
else
|
||||
#endif
|
||||
#if SHOPT_ESH
|
||||
if(was_emacs)
|
||||
sh_onoption(SH_EMACS);
|
||||
else if(was_gmacs)
|
||||
sh_onoption(SH_GMACS);
|
||||
#endif
|
||||
if(scope)
|
||||
sh_unscope();
|
||||
bp->ptr = (void*)save_ptr;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue