2024-04-12 18:19:32 +08:00
|
|
|
#RUN: %fish %s
|
2017-07-18 05:33:51 +08:00
|
|
|
set -l filename (echo foo | psub --testing)
|
|
|
|
test -f $filename
|
|
|
|
or echo 'psub is not a regular file' >&2
|
|
|
|
rm $filename
|
|
|
|
|
|
|
|
set -l filename (echo foo | psub --testing --file)
|
|
|
|
test -f $filename
|
|
|
|
or echo 'psub is not a regular file' >&2
|
|
|
|
rm $filename
|
|
|
|
|
|
|
|
set -l filename (echo foo | psub --testing --fifo)
|
|
|
|
test -p $filename
|
|
|
|
or echo 'psub is not a fifo' >&2
|
2017-12-22 07:47:09 +08:00
|
|
|
# hack: the background write that psub peforms may block
|
|
|
|
# until someone opens the fifo for reading. So make sure we
|
|
|
|
# actually read it.
|
2020-03-10 02:36:12 +08:00
|
|
|
cat $filename >/dev/null
|
2017-07-18 05:33:51 +08:00
|
|
|
rm $filename
|
|
|
|
|
|
|
|
cat (echo foo | psub)
|
|
|
|
cat (echo bar | psub --fifo)
|
|
|
|
cat (echo baz | psub)
|
2020-02-08 05:10:55 +08:00
|
|
|
#CHECK: foo
|
|
|
|
#CHECK: bar
|
|
|
|
#CHECK: baz
|
2017-07-18 05:33:51 +08:00
|
|
|
|
|
|
|
set -l filename (echo foo | psub)
|
|
|
|
if test -e $filename
|
|
|
|
echo 'psub file was not deleted'
|
|
|
|
else
|
|
|
|
echo 'psub file was deleted'
|
|
|
|
end
|
2020-02-08 05:10:55 +08:00
|
|
|
#CHECK: psub file was deleted
|
2017-07-18 05:33:51 +08:00
|
|
|
|
|
|
|
# The --file flag is the default behavior.
|
2019-01-03 03:54:14 +08:00
|
|
|
if count (echo foo | psub -s .cc | string match -r '\.cc$') >/dev/null
|
2017-07-18 05:33:51 +08:00
|
|
|
echo 'psub filename ends with .cc'
|
|
|
|
else
|
|
|
|
echo 'psub filename does not end with .cc'
|
|
|
|
end
|
2020-02-08 05:10:55 +08:00
|
|
|
#CHECK: psub filename ends with .cc
|
2017-07-18 05:33:51 +08:00
|
|
|
|
|
|
|
# Make sure we get the same result if we explicitly ask for a temp file.
|
2019-01-03 03:54:14 +08:00
|
|
|
if count (echo foo | psub -f -s .cc | string match -r '\.cc$') >/dev/null
|
2017-07-18 05:33:51 +08:00
|
|
|
echo 'psub filename ends with .cc'
|
|
|
|
else
|
|
|
|
echo 'psub filename does not end with .cc'
|
|
|
|
end
|
2020-02-08 05:10:55 +08:00
|
|
|
#CHECK: psub filename ends with .cc
|
2017-07-18 05:33:51 +08:00
|
|
|
|
|
|
|
set -l filename (echo foo | psub -s .fish)
|
|
|
|
if test -e (dirname $filename)
|
|
|
|
echo 'psub directory was not deleted'
|
|
|
|
else
|
|
|
|
echo 'psub directory was deleted'
|
|
|
|
end
|
2020-02-08 05:10:55 +08:00
|
|
|
#CHECK: psub directory was deleted
|
2017-07-18 05:33:51 +08:00
|
|
|
|
2019-01-03 03:54:14 +08:00
|
|
|
set -l diffs (comm -3 (__fish_print_help psub | psub) (psub -hs banana | psub))
|
|
|
|
test -z "$diffs"
|