Support for &> and &| as convenience redirections

This adds support for &> and &| syntax, which both redirect stdout, and
also apply a redirection of stderr to stdout.
This commit is contained in:
ridiculousfish
2019-10-14 15:45:40 -07:00
parent 756e9826bc
commit 2a92e66902
8 changed files with 107 additions and 11 deletions

View File

@@ -0,0 +1,27 @@
#RUN: %fish %s
function outnerr
command echo out $argv
command echo err $argv 1>&2
end
outnerr 0 &| count
#CHECK: 2
set -l tmpdir (mktemp -d)
outnerr overwrite &> $tmpdir/file.txt
cat $tmpdir/file.txt
#CHECK: out overwrite
#CHECK: err overwrite
outnerr append &>> $tmpdir/file.txt
cat $tmpdir/file.txt
#CHECK: out overwrite
#CHECK: err overwrite
#CHECK: out append
#CHECK: err append
echo noclobber &>>? $tmpdir/file.txt
#CHECKERR: {{.*}} The file {{.*}} already exists
rm -Rf $tmpdir