mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-31 03:51:14 -03:00
return to psub --file being the default
The recent change to switch `psub` to use `argparse` caused it to use a fifo by default because it inadvertently fixed a long standing bug in the fish script. This changes the behavior back to `psub --file` being the default behavior and introduces a `--fifo` flag. It also updates the documentation to make it clearer when and why `--fifo` mode should not be used. Fixes #4222
This commit is contained in:
@@ -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 'h/help' 'f/file' 's/suffix='
|
||||
set -l options -x 'f,F' -x 'F,s' 'h/help' 'f/file' 'F/fifo' 's/suffix=' 'T-testing'
|
||||
argparse -n psub --max-args=0 $options -- $argv
|
||||
or return
|
||||
|
||||
@@ -21,10 +21,10 @@ function psub --description "Read from stdin into a file and output the filename
|
||||
set -q TMPDIR
|
||||
and set tmpdir $TMPDIR
|
||||
|
||||
if not set -q _flag_file
|
||||
if set -q _flag_fifo
|
||||
# Write output to pipe. This needs to be done in the background so
|
||||
# that the command substitution exits without needing to wait for
|
||||
# all the commands to exit
|
||||
# all the commands to exit.
|
||||
set dirname (mktemp -d $tmpdir/.psub.XXXXXXXXXX)
|
||||
or return
|
||||
set filename $dirname/psub.fifo"$_flag_suffix"
|
||||
@@ -35,13 +35,18 @@ function psub --description "Read from stdin into a file and output the filename
|
||||
cat >$filename
|
||||
else
|
||||
set dirname (mktemp -d $tmpdir/.psub.XXXXXXXXXX)
|
||||
set filename $dirname/psub"$_flag_suffix"
|
||||
set filename "$dirname/psub$_flag_suffix"
|
||||
cat >$filename
|
||||
end
|
||||
|
||||
# Write filename to stdout
|
||||
echo $filename
|
||||
|
||||
# This flag isn't documented. It's strictly for our unit tests.
|
||||
if set -q _flag_testing
|
||||
return
|
||||
end
|
||||
|
||||
# Find unique function name
|
||||
while true
|
||||
set funcname __fish_psub_(random)
|
||||
@@ -53,7 +58,7 @@ function psub --description "Read from stdin into a file and output the filename
|
||||
# Make sure we erase file when caller exits
|
||||
function $funcname --on-job-exit caller --inherit-variable filename --inherit-variable dirname --inherit-variable funcname
|
||||
command rm $filename
|
||||
if count $dirname >/dev/null
|
||||
if test -n "$dirname"
|
||||
command rmdir $dirname
|
||||
end
|
||||
functions -e $funcname
|
||||
|
||||
Reference in New Issue
Block a user