1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-06-10 18:58:03 +02:00

unposted: "typeset -p" has problems with special parameters having NULL values

This commit is contained in:
Bart Schaefer 2024-03-12 18:02:38 -07:00
parent 7c875adb09
commit 8adfbfc1f0
2 changed files with 11 additions and 7 deletions
ChangeLog
Src/Modules

View file

@ -1,5 +1,8 @@
2024-03-12 Bart Schaefer <schaefer@zsh.org> 2024-03-12 Bart Schaefer <schaefer@zsh.org>
* unposted: Src/Modules/ksh93.c: "typeset -p" has problems with
special parameters having NULL values, use a dummy static instead.
* 52742: Src/builtin.c: fix bad interactions of "typeset -p" with * 52742: Src/builtin.c: fix bad interactions of "typeset -p" with
GLOBAL_EXPORT, plus some other inconsistencies. GLOBAL_EXPORT, plus some other inconsistencies.

View file

@ -102,9 +102,10 @@ static const struct gsu_scalar sh_name_gsu =
static const struct gsu_scalar sh_subscript_gsu = static const struct gsu_scalar sh_subscript_gsu =
{ strvargetfn, nullstrsetfn, nullunsetfn }; { strvargetfn, nullstrsetfn, nullunsetfn };
static char *sh_name; static char sh_unsetval[2]; /* Dummy to treat as NULL */
static char *sh_subscript; static char *sh_name = sh_unsetval;
static char *sh_edchar; static char *sh_subscript = sh_unsetval;
static char *sh_edchar = sh_unsetval;
static char sh_edmode[2]; static char sh_edmode[2];
/* /*
@ -193,7 +194,7 @@ ksh93_wrapper(Eprog prog, FuncWrap w, char *name)
strcpy(sh_edmode, "\033"); strcpy(sh_edmode, "\033");
else else
strcpy(sh_edmode, ""); strcpy(sh_edmode, "");
if (!sh_edchar) if (sh_edchar == sh_unsetval)
sh_edchar = dupstring(getsparam("KEYS")); sh_edchar = dupstring(getsparam("KEYS"));
if (varedarg) { if (varedarg) {
char *ie = itype_end((sh_name = dupstring(varedarg)), INAMESPC, 0); char *ie = itype_end((sh_name = dupstring(varedarg)), INAMESPC, 0);
@ -204,16 +205,16 @@ ksh93_wrapper(Eprog prog, FuncWrap w, char *name)
ie = sh_subscript + strlen(sh_subscript); ie = sh_subscript + strlen(sh_subscript);
*--ie = '\0'; *--ie = '\0';
} else } else
sh_subscript = NULL; sh_subscript = sh_unsetval;
if ((pm = createparam(".sh.value", LOCAL_NAMEREF))) { if ((pm = createparam(".sh.value", LOCAL_NAMEREF))) {
pm->level = locallevel; pm->level = locallevel;
setloopvar(".sh.value", "BUFFER"); /* Hack */ setloopvar(".sh.value", "BUFFER"); /* Hack */
pm->node.flags |= PM_READONLY; pm->node.flags |= PM_READONLY;
} }
} else } else
sh_name = sh_subscript = NULL; sh_name = sh_subscript = sh_unsetval;
} else { } else {
sh_edchar = sh_name = sh_subscript = NULL; sh_edchar = sh_name = sh_subscript = sh_unsetval;
strcpy(sh_edmode, ""); strcpy(sh_edmode, "");
/* TODO: /* TODO:
* - disciplines * - disciplines