Add support for specifying event handler for calling job in command supstitution. Add psub shellscript function for process substitution

darcs-hash:20051015005126-ac50b-d2aedca3a50a78362502f3fa9dd8bf25cb7dc6e1.gz
This commit is contained in:
axel
2005-10-15 10:51:26 +10:00
parent 638df31ca4
commit 9298f610f6
14 changed files with 178 additions and 52 deletions

View File

@@ -711,6 +711,36 @@ function type -d "Print the type of a command"
return $status
end
function psub -d "Read from stdin into a file and output the filename. Remove the file when the command that calles psub exits."
if not status --is-command-substitution
echo psub: Not inside of command substitution
end
# Find unique file name
while true
set filename /tmp/.psub.(echo %self).(random);
if not test -e $filename
break;
end
end
cat >$filename
# Find unique function name
while true
set funcname __fish_psub_(random);
if not functions $funcname >/dev/null ^/dev/null
break;
end
end
eval function $funcname --on-job-exit caller\; rm $filename\; functions -e $funcname\; end
echo $filename
end
if status --is-interactive