mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-30 14:24:35 +08:00
Don't allow specifying an fd with a caret redirection
For example, an argument 12345^ is a real argument, not a redirection There's no reason to use ^ here instead of >, and it's annoying to git users. Fixes #1873
This commit is contained in:
parent
0ee03cbf98
commit
3a7719015d
|
@ -385,8 +385,9 @@ static size_t read_redirection_or_fd_pipe(const wchar_t *buff,
|
|||
}
|
||||
|
||||
// Either way we should have ended on the redirection character itself like '>'.
|
||||
// Don't allow an fd with a caret redirection - see #1873
|
||||
wchar_t redirect_char = buff[idx++]; // note increment of idx
|
||||
if (redirect_char == L'>' || redirect_char == L'^') {
|
||||
if (redirect_char == L'>' || (redirect_char == L'^' && idx == 1)) {
|
||||
redirection_mode = TOK_REDIRECT_OUT;
|
||||
if (buff[idx] == redirect_char) {
|
||||
// Doubled up like ^^ or >>. That means append.
|
||||
|
|
|
@ -104,6 +104,9 @@ echo Test 5 $sta
|
|||
echo Test redirections
|
||||
begin ; echo output ; echo errput 1>&2 ; end 2>&1 | tee ../test/temp/tee_test.txt ; cat ../test/temp/tee_test.txt
|
||||
|
||||
# Test that trailing ^ doesn't trigger redirection, see #1873
|
||||
echo caret_no_redirect 12345^
|
||||
|
||||
# Verify that we can pipe something other than stdout
|
||||
# The first line should be printed, since we output to stdout but pipe stderr to /dev/null
|
||||
# The second line should not be printed, since we output to stderr and pipe it to /dev/null
|
||||
|
|
|
@ -25,6 +25,7 @@ errput
|
|||
output
|
||||
errput
|
||||
output
|
||||
caret_no_redirect 12345^
|
||||
is_stdout
|
||||
abc\ndef
|
||||
abc
|
||||
|
|
Loading…
Reference in New Issue
Block a user