mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-01 13:01:21 -03:00
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:
27
tests/checks/redirect.fish
Normal file
27
tests/checks/redirect.fish
Normal 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
|
||||
Reference in New Issue
Block a user