Skip to content

Commit

Permalink
Recognize history searches in expansion (requested by mrg)
Browse files Browse the repository at this point in the history
  • Loading branch information
zoulasc committed Sep 8, 2024
1 parent df06d8e commit d9e82b8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions Fixes
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
38. Recognize history searches in history expansion !?foo<tab> (christos)
37. V6.24.13 - 2024-06-12
36. Fix !^:h and !^:t failing when no / found (Kimmo Suominen)
35. Add cross-build support for gethost (josefs10)
Expand Down
10 changes: 10 additions & 0 deletions ed.chared.c
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,16 @@ c_expand(Char *p)
buf = expand_lex(&h->Hlex, 1, INT_MAX);
break;

case '?':
h = findev(p + 2, 1);
if (h == NULL)
goto excl_err;
buf = expand_lex(&h->Hlex, 0, INT_MAX);
while (*q)
q++;
q--;
break;

default:
if (been_once) { /* unknown argument */
/* assume it's a modifier, e.g. !foo:h, and get whole cmd */
Expand Down
1 change: 1 addition & 0 deletions sh.decls.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ extern void btoeof (void);
extern void copylex (struct wordent *, struct wordent *);
extern Char *domod (Char *, Char);
extern void initlex (struct wordent *);
struct Hist *findev (Char *, int);
extern void freelex (struct wordent *);
extern int lex (struct wordent *);
extern void lex_cleanup (void *);
Expand Down
3 changes: 1 addition & 2 deletions sh.lex.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ static Char *word (int);
static eChar getC1 (int);
static void getdol (void);
static void getexcl (Char);
static struct Hist *findev (Char *, int);
static void setexclp (Char *);
static eChar bgetc (void);
static void balloc (int);
Expand Down Expand Up @@ -1313,7 +1312,7 @@ gethent(Char sc)
return (0);
}

static struct Hist *
struct Hist *
findev(Char *cp, int anyarg)
{
struct Hist *hp;
Expand Down

0 comments on commit d9e82b8

Please sign in to comment.