26763: fix problem on failed cd -s to relative path
[zsh.git] / Test / D03procsubst.ztst
blob37a67630f75187ca01c2459a0117e90fb6a8f57c
1 # Tests for process substitution: <(...), >(...) and =(...).
3 %prep
4   if grep '#define PATH_DEV_FD' $ZTST_testdir/../config.h > /dev/null 2>&1 ||
5      grep '#define HAVE_FIFOS' $ZTST_testdir/../config.h > /dev/null 2>&1; then
6     mkdir procsubst.tmp
7     cd procsubst.tmp
8     print 'First\tSecond\tThird\tFourth' >FILE1
9     print 'Erste\tZweite\tDritte\tVierte' >FILE2
10   else
11     ZTST_unimplemented="process substitution is not supported"
12     true
13   fi
15   function copycat { cat "$@" }
17 %test
18   paste <(cut -f1 FILE1) <(cut -f3 FILE2)
19 0:<(...) substitution
20 >First  Dritte
22 # slightly desperate hack to force >(...) to be synchronous
23   { paste <(cut -f2 FILE1) <(cut -f4 FILE2) } > >(sed 's/e/E/g' >OUTFILE)
24   cat OUTFILE
25 0:>(...) substitution
26 >SEcond ViErtE
28   diff =(cat FILE1) =(cat FILE2)
29 1:=(...) substituion
30 >1c1
31 >< First        Second  Third   Fourth
32 >---
33 >> Erste        Zweite  Dritte  Vierte
35   copycat <(print First) <(print Zweite)
36 0:FDs remain open for external commands called from functions
37 >First
38 >Zweite
40   catfield2() {
41     local -a args
42     args=(${(s.,.)1})
43     print $args[1]
44     cat $args[2]
45     print $args[3]
46   }
47   catfield2 up,<(print $'\x64'own),sideways
48 0:<(...) when embedded within an argument
49 >up
50 >down
51 >sideways
53   outputfield2() {
54     local -a args
55     args=(${(s.,.)1})
56     print $args[1]
57     echo 'How sweet the moonlight sits upon the bank' >$args[2]
58     print $args[3]
59   }
60   outputfield2 muddy,>(sed -e s/s/th/g >outputfield2.txt),vesture
61   # yuk
62   while [[ ! -e outputfield2.txt || ! -s outputfield2.txt ]]; do :; done
63   cat outputfield2.txt
64 0:>(...) when embedded within an argument
65 >muddy
66 >vesture
67 >How thweet the moonlight thitth upon the bank
69   catfield1() {
70     local -a args
71     args=(${(s.,.)1})
72     cat $args[1]
73     print $args[2]
74   }
75   catfield1 =(echo s$'\x69't),jessica
76 0:=(...) followed by something else without a break
77 >sit
78 >jessica
80   (
81   setopt nonomatch
82   # er... why is this treated as a glob?
83   print everything,=(here is left),alone
84   )
85 0:=(...) preceded by other stuff has no special effect
86 >everything,=(here is left),alone