1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

Merge pull request #1 from JohnoKing/fix-builtin-delete

`builtin -d` should not delete special builtins
This commit is contained in:
Martijn Dekker 2020-06-12 12:36:42 +01:00 committed by GitHub
commit e500479ede
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 0 deletions

4
NEWS
View file

@ -6,6 +6,10 @@ Any uppercase BUG_* names are modernish shell bug IDs.
2020-06-11: 2020-06-11:
- Fixed a bug that caused running 'builtin -d' on a special builtin to
delete it. The man page for the 'builtin' command documents that special
builtins cannot be deleted.
- POSIX compliance fix: It is now possible to set shell functions named - POSIX compliance fix: It is now possible to set shell functions named
'alias' or 'unalias', overriding the commands by the same names. In 'alias' or 'unalias', overriding the commands by the same names. In
technical terms, they are now regular builtins, not special builtins. technical terms, they are now regular builtins, not special builtins.

View file

@ -1203,6 +1203,8 @@ Namval_t *sh_addbuiltin(const char *path, Shbltin_f bltin, void *extra)
stakseek(offset); stakseek(offset);
if(extra == (void*)1) if(extra == (void*)1)
{ {
if(nv_isattr(np,BLT_SPC))
errormsg(SH_DICT,ERROR_exit(1),"cannot delete: %s%s",name,is_spcbuiltin);
if(np->nvfun && !nv_isattr(np,NV_NOFREE)) if(np->nvfun && !nv_isattr(np,NV_NOFREE))
free((void*)np->nvfun); free((void*)np->nvfun);
dtdelete(sh.bltin_tree,np); dtdelete(sh.bltin_tree,np);

View file

@ -686,5 +686,11 @@ PATH=$tmp:$PATH $SHELL <<-\EOF || err_exit "'whence' gets wrong path on init"
[[ -x $wc ]] [[ -x $wc ]]
EOF EOF
# ======
# `builtin -d` should not delete special builtins
(builtin -d export 2> /dev/null
PATH=/dev/null
whence -q export) || err_exit '`builtin -d` deletes special builtins'
# ====== # ======
exit $((Errors<125?Errors:125)) exit $((Errors<125?Errors:125))