summaryrefslogtreecommitdiff
path: root/lib/readline/histexpand.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/readline/histexpand.c')
-rw-r--r--lib/readline/histexpand.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/lib/readline/histexpand.c b/lib/readline/histexpand.c
index fdecebcb..46a99aa6 100644
--- a/lib/readline/histexpand.c
+++ b/lib/readline/histexpand.c
@@ -1220,7 +1220,7 @@ history_expand (hstring, output)
ADD_STRING (temp);
xfree (temp);
}
- only_printing = r == 1;
+ only_printing += r == 1;
i = eindex;
}
break;
@@ -1421,7 +1421,7 @@ history_tokenize_word (string, ind)
const char *string;
int ind;
{
- register int i;
+ register int i, j;
int delimiter, nestdelim, delimopen;
i = ind;
@@ -1433,6 +1433,22 @@ history_tokenize_word (string, ind)
return i;
}
+ if (isdigit (string[i]))
+ {
+ j = i;
+ while (string[j] && isdigit (string[j]))
+ j++;
+ if (string[j] == 0)
+ return (j);
+ if (string[j] == '<' || string[j] == '>')
+ i = j; /* digit sequence is a file descriptor */
+ else
+ {
+ i = j;
+ goto get_word; /* digit sequence is part of a word */
+ }
+ }
+
if (member (string[i], "<>;&|$"))
{
int peek = string[i + 1];
@@ -1446,8 +1462,16 @@ history_tokenize_word (string, ind)
i += 2;
return i;
}
- else if ((peek == '&' && (string[i] == '>' || string[i] == '<')) ||
- (peek == '>' && string[i] == '&'))
+ else if (peek == '&' && (string[i] == '>' || string[i] == '<'))
+ {
+ j = i + 2;
+ while (string[j] && isdigit (string[j])) /* file descriptor */
+ j++;
+ if (string[j] =='-') /* <&[digits]-, >&[digits]- */
+ j++;
+ return j;
+ }
+ else if ((peek == '>' && string[i] == '&') || (peek == '|' && string[i] == '>'))
{
i += 2;
return i;