mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-29 05:21:00 +01:00
more careful with checking index of $history (10614)
This commit is contained in:
parent
0713dfcd1a
commit
724b065397
2 changed files with 16 additions and 1 deletions
|
|
@ -1020,6 +1020,8 @@ getpmhistory(HashTable ht, char *name)
|
|||
{
|
||||
Param pm = NULL;
|
||||
Histent he;
|
||||
char *p;
|
||||
int ok = 1;
|
||||
|
||||
pm = (Param) zhalloc(sizeof(struct param));
|
||||
pm->nam = dupstring(name);
|
||||
|
|
@ -1032,7 +1034,17 @@ getpmhistory(HashTable ht, char *name)
|
|||
pm->ename = NULL;
|
||||
pm->old = NULL;
|
||||
pm->level = 0;
|
||||
if ((he = quietgethist(atoi(name))))
|
||||
|
||||
if (*name != '0' || name[1]) {
|
||||
if (*name == '0')
|
||||
ok = 0;
|
||||
else {
|
||||
for (p = name; *p && idigit(*p); p++);
|
||||
if (*p)
|
||||
ok = 0;
|
||||
}
|
||||
}
|
||||
if (ok && (he = quietgethist(atoi(name))))
|
||||
pm->u.str = dupstring(he->text);
|
||||
else {
|
||||
pm->u.str = dupstring("");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue