2019-10-15 06:45:40 +08:00
|
|
|
#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)
|
2019-12-21 06:40:57 +08:00
|
|
|
outnerr overwrite &>$tmpdir/file.txt
|
2019-10-15 06:45:40 +08:00
|
|
|
cat $tmpdir/file.txt
|
|
|
|
#CHECK: out overwrite
|
|
|
|
#CHECK: err overwrite
|
|
|
|
|
2019-12-21 06:40:57 +08:00
|
|
|
outnerr append &>>$tmpdir/file.txt
|
2019-10-15 06:45:40 +08:00
|
|
|
cat $tmpdir/file.txt
|
|
|
|
#CHECK: out overwrite
|
|
|
|
#CHECK: err overwrite
|
|
|
|
#CHECK: out append
|
|
|
|
#CHECK: err append
|
|
|
|
|
2019-12-21 06:40:57 +08:00
|
|
|
echo noclobber &>>?$tmpdir/file.txt
|
2019-10-15 06:45:40 +08:00
|
|
|
#CHECKERR: {{.*}} The file {{.*}} already exists
|
|
|
|
|
2019-10-28 05:35:14 +08:00
|
|
|
eval "echo foo |& false"
|
|
|
|
#CHECKERR: {{.*}} |& is not valid. In fish, use &| to pipe both stdout and stderr.
|
|
|
|
#CHECKERR: echo foo |& false
|
|
|
|
#CHECKERR: ^
|
|
|
|
|
2019-12-21 06:40:57 +08:00
|
|
|
# Ensure that redirection empty data still creates the file.
|
|
|
|
rm -f $tmpdir/file.txt
|
|
|
|
test -f $tmpdir/file.txt && echo "File exists" || echo "File does not exist"
|
|
|
|
#CHECK: File does not exist
|
|
|
|
|
|
|
|
echo -n >$tmpdir/file.txt
|
|
|
|
test -f $tmpdir/file.txt && echo "File exists" || echo "File does not exist"
|
|
|
|
#CHECK: File exists
|
|
|
|
|
|
|
|
rm $tmpdir/file.txt
|
|
|
|
echo -n 2>$tmpdir/file.txt
|
|
|
|
test -f $tmpdir/file.txt && echo "File exists" || echo "File does not exist"
|
|
|
|
#CHECK: File exists
|
|
|
|
|
2019-10-15 06:45:40 +08:00
|
|
|
rm -Rf $tmpdir
|