You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
no error about wrong >>? redirection operator #8380
Fish version: 3.3.0 (built from source)
OS version: Linux Mint 20.2 Cinnamon
Documentation lists only the following redirection operators (with arbitrary FD too):
To read standard input from a file, use <SOURCE_FILE.
To write standard output to a file, use >DESTINATION.
To write standard error to a file, use 2>DESTINATION. 1
To append standard output to a file, use >>DESTINATION_FILE.
To append standard error to a file, use 2>>DESTINATION_FILE.
To not overwrite ("clobber") an existing file, use >?DESTINATION or 2>?DESTINATION. This is known as the "noclobber" redirection.
As a convenience, the redirection &> can be used to direct both stdout and stderr to the same destination.
But when I run code with:
echo 1 >>?test.txt
I obtain warning: The file 'test.txt' already exists instead smth like Wrong redirection operator used. Of course maybe 1 > is redirected instead of 1 but I think it is unclear even if it's right because no space between first > and second one persists. What about to warn user about this (add this as a feature can be disabled)?
It may have escaped the docs but but we do specifically test that it works as intended in our test suite, which is that it appends and also enables the noclobber feature to avoid appending to a file which we don't want to have exist.. which is kind of a strange thing to do but there ya go. This behavior documented in tokenizer.cpp.
Activity
floam commentedon Oct 24, 2021
It may have escaped the docs but but we do specifically test that it works as intended in our test suite, which is that it appends and also enables the noclobber feature to avoid appending to a file which we don't want to have exist.. which is kind of a strange thing to do but there ya go. This behavior documented in tokenizer.cpp.
fish-shell/src/tokenizer.cpp
Lines 417 to 419 in a2b3005
EmilyGraceSeville7cf commentedon Oct 27, 2021
@floam, please add note about it to docs not to confuse newcomers. :)
ridiculousfish commentedon Nov 6, 2021
I added a mention of append and noclobber combined. I tried to simplify the rest a bit to compensate. Thanks for filing.
CHANGELOG updates for 3.4.0