D03procsubst.ztst   [plain text]

# Tests for process substitution: <(...), >(...) and =(...).

  if grep '#define PATH_DEV_FD' $ZTST_testdir/../config.h > /dev/null 2>&1 ||
     grep '#define HAVE_FIFOS' $ZTST_testdir/../config.h > /dev/null 2>&1; then
    mkdir procsubst.tmp
    cd procsubst.tmp
    print 'First\tSecond\tThird\tFourth' >FILE1
    print 'Erste\tZweite\tDritte\tVierte' >FILE2
    ZTST_unimplemented="process substitution is not supported"

  function copycat { cat "$@" }

  paste <(cut -f1 FILE1) <(cut -f3 FILE2)
0:<(...) substitution
>First	Dritte

# slightly desperate hack to force >(...) to be synchronous
  { paste <(cut -f2 FILE1) <(cut -f4 FILE2) } > >(sed 's/e/E/g' >OUTFILE)
0:>(...) substitution
>SEcond	ViErtE

  diff =(cat FILE1) =(cat FILE2)
1:=(...) substituion
>< First	Second	Third	Fourth
>> Erste	Zweite	Dritte	Vierte

  copycat <(print First) <(print Zweite)
0:FDs remain open for external commands called from functions

  catfield2() {
    local -a args
    print $args[1]
    cat $args[2]
    print $args[3]
  catfield2 up,<(print $'\x64'own),sideways
0:<(...) when embedded within an argument

  outputfield2() {
    local -a args
    print $args[1]
    echo 'How sweet the moonlight sits upon the bank' >$args[2]
    print $args[3]
  outputfield2 muddy,>(sed -e s/s/th/g >outputfield2.txt),vesture
  # yuk
  while [[ ! -e outputfield2.txt || ! -s outputfield2.txt ]]; do :; done
  cat outputfield2.txt
0:>(...) when embedded within an argument
>How thweet the moonlight thitth upon the bank

  catfield1() {
    local -a args
    cat $args[1]
    print $args[2]
  catfield1 =(echo s$'\x69't),jessica
0:=(...) followed by something else without a break

  setopt nonomatch
  # er... why is this treated as a glob?
  print everything,=(here is left),alone
0:=(...) preceded by other stuff has no special effect
>everything,=(here is left),alone