From 10490ec499fff7b932f92a0b19c7e5343a24761d Mon Sep 17 00:00:00 2001 From: Sven Wischnowsky Date: Fri, 1 Mar 2002 10:41:59 +0000 Subject: add $redirections array to completion system parameters, containing information about all redirections on the line; make this and compstate[redirect] contain the file descriptor number (16751) --- Src/Zle/zle_tricky.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'Src/Zle/zle_tricky.c') diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c index 6ecfaa885..788f5f8ec 100644 --- a/Src/Zle/zle_tricky.c +++ b/Src/Zle/zle_tricky.c @@ -346,6 +346,13 @@ mod_export int lincmd, linredir, linarr; /**/ mod_export char *rdstr; +static char rdstrbuf[20]; + +/* The list of redirections on the line. */ + +/**/ +mod_export LinkList rdstrs; + /* This holds the name of the current command (used to find the right * * compctl). */ @@ -978,7 +985,7 @@ get_comp_string(void) { int t0, tt0, i, j, k, cp, rd, sl, ocs, ins, oins, ia, parct, varq = 0; int ona = noaliases; - char *s = NULL, *linptr, *tmp, *p, *tt = NULL; + char *s = NULL, *linptr, *tmp, *p, *tt = NULL, rdop[20]; freebrinfo(brbeg); freebrinfo(brend); @@ -987,6 +994,11 @@ get_comp_string(void) zsfree(lastprebr); zsfree(lastpostbr); lastprebr = lastpostbr = NULL; + if (rdstrs) + freelinklist(rdstrs, freestr); + rdstrs = znewlinklist(); + rdop[0] = '\0'; + rdstr = NULL; /* This global flag is used to signal the lexer code if it should * * expand aliases or not. */ @@ -1074,8 +1086,14 @@ get_comp_string(void) else linarr = 0; } - if (inredir) - rdstr = tokstrings[tok]; + if (inredir) { + rdstr = rdstrbuf; + if (tokfd >= 0) + sprintf(rdop, "%d%s", tokfd, tokstrings[tok]); + else + strcpy(rdop, tokstrings[tok]); + strcpy(rdstr, rdop); + } if (tok == DINPAR) tokstr = NULL; @@ -1118,8 +1136,11 @@ get_comp_string(void) ia = linarr; if (inwhat == IN_NOTHING && incond) inwhat = IN_COND; - } else if (linredir) + } else if (linredir) { + if (rdop[0] && tokstr) + zaddlinknode(rdstrs, tricat(rdop, ":", tokstr)); continue; + } if (incond) { if (tok == DBAR) tokstr = "||"; -- cgit 1.4.1