allow psub --fifo --suffix ...

This commit is contained in:
Bryce Berger
2025-08-15 14:50:54 -04:00
parent 79135c6c82
commit 9273f352a0
2 changed files with 12 additions and 1 deletions

View File

@@ -1,5 +1,5 @@
function psub --description "Read from stdin into a file and output the filename. Remove the file when the command that called psub exits."
set -l options -x 'f,F' -x 'F,s' h/help f/file F/fifo 's/suffix=' T-testing
set -l options -x 'f,F' h/help f/file F/fifo 's/suffix=' T-testing
argparse -n psub --max-args=0 $options -- $argv
or return

View File

@@ -49,6 +49,17 @@ else
end
#CHECK: psub filename ends with .cc
# Fifo is allowed to have a suffix as well
# hack: the background write that psub performs may block
# until someone opens the fifo for reading. So make sure we
# actually read it.
if cat (echo foo | psub -F -s .cc | string match -e -r '\.fifo\.cc$') >/dev/null
echo 'psub pipe name ends with .cc'
else
echo 'psub pipe name does not end with .cc'
end
#CHECK: psub pipe name ends with .cc
set -l filename (echo foo | psub -s .fish)
if test -e (dirname $filename)
echo 'psub directory was not deleted'