irctk

libircclient binding for scripts
git clone https://a3nm.net/git/irctk/
Log | Files | Refs | README

unique.sh (702B)


      1 #!/bin/bash
      2 
      3 trap 'kill $(jobs -p)' EXIT
      4 
      5 mkdir -p unique
      6 cd unique
      7 
      8 cat >a<<EOF
      9 a1
     10 a2
     11 a3
     12 a4
     13 a5
     14 /nick uniqueb
     15 a6
     16 a7
     17 EOF
     18 cat >b<<EOF
     19 b1
     20 /nick uniquec
     21 b2
     22 /nick uniqued
     23 b3
     24 b4
     25 b5
     26 EOF
     27 cat >c<<EOF
     28 c1
     29 c2
     30 c3
     31 c4
     32 EOF
     33 
     34 tail -f /dev/null | ../../irctk -u uniquel@localhost \#unique_test 2>/dev/null \
     35   > heard &
     36 PIDA=$!
     37 sleep 1
     38 cat a| ../../irctk uniquea@localhost \#unique_test > /dev/null &
     39 PID1=$!
     40 sleep 1
     41 cat b| ../../irctk uniqueb@localhost \#unique_test > /dev/null
     42 cat c| ../../irctk uniquec@localhost \#unique_test > /dev/null &
     43 PID3=$!
     44 sleep 1
     45 wait $PID1
     46 wait $PID3
     47 sleep 1
     48 kill $PIDA
     49 
     50 cat a b c | grep -v nick | sed s'/^./<unique&> &/' | sort> ref
     51 cut -d' ' -f2- heard | sort > heard2
     52 
     53 diff ref heard2
     54