mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-09 12:11:20 -03:00
committed by
Johannes Altmanninger
parent
6701b7f6c8
commit
27fb4d6731
@@ -1,4 +1,4 @@
|
||||
# RUN: %fish -C "set helper %fish_test_helper" %s
|
||||
# RUN: fish=%fish %fish -C "set helper %fish_test_helper" %s
|
||||
#REQUIRES: command -v %fish_test_helper
|
||||
|
||||
# Check that we don't leave stray FDs.
|
||||
@@ -89,3 +89,39 @@ $helper print_fds 19</dev/null
|
||||
|
||||
$helper print_fds 20</dev/null
|
||||
# CHECK: 0 1 2 20
|
||||
|
||||
# Check heightenization of the redirection file descriptors
|
||||
#
|
||||
# If heightenization does NOT work, ">$tmpfile" creates a temporary fd on a fd n
|
||||
# (n being the first free descriptor) during parsing, then "n>&1" redirects fd n
|
||||
# to fd 1 (still stdout at this stage), lastly, ">$tmpfile" redirects fd 1 is
|
||||
# redirected to the "temporary" fd n (which is now stdout instead of $tmpfile).
|
||||
#
|
||||
# If heightenization does work, ">$tmpfile" creates a temporary fd on 10+,
|
||||
# then fd n is redirected to fd 1 (still stdout), the fd 1 is redirect to
|
||||
# the "temporary" fd 10+ (still $tmpfile)
|
||||
#
|
||||
# Since we don't know what `n` will be, we need to redirect all the descriptors
|
||||
# reserved for the user
|
||||
set -l tmpfile (mktemp)
|
||||
printf 'stdout: %s\n' "$($fish -c "$helper print_fds 3>&1 4>&1 5>&1 6>&1 7>&1 8>&1 9>&1 >$tmpfile")"
|
||||
printf "tmp file: %s\n" $(cat $tmpfile)
|
||||
# CHECK: stdout:
|
||||
# CHECK: tmp file: 0 1 2 3 4 5 6 7 8 9
|
||||
|
||||
# Check heightenization of the file descriptors when sourcing
|
||||
echo '
|
||||
path filter /proc/$fish_pid/fd/{3,4,5,6,7,8,9}
|
||||
' >"$tmpfile"
|
||||
echo start source
|
||||
$fish -c "source '$tmpfile'"
|
||||
echo end source
|
||||
# CHECK: start source
|
||||
# CHECK: end source
|
||||
|
||||
# Check heightenization of descriptors for script files passed to fish
|
||||
echo start fish
|
||||
$fish "$tmpfile"
|
||||
echo end fish
|
||||
# CHECK: start fish
|
||||
# CHECK: end fish
|
||||
|
||||
Reference in New Issue
Block a user