You're spawning a coprocess the first time you call tput for the color code 196 (for Red) and not closing the pipe to it so somethings getting hung up the next 2 times you try to use that same pipe to that same process (for Syp and Code` and Code). As I've mentioned a couple of times now:
- don't use coprocesses for this as you don't need to,
- do test for getline failing (had you done that your code would have reported this problem to you), and
- do close the pipes you open as you go.
Also - you don't need to use 3 separate variables for this:
ka = "Wht 15 Grn 34 Blu 39 Ylw 11 Red 196 Amb 214"
kb = "Cyn 51 Mgn 201 Syp 196 Code 196"
ks = sprintf("%s %s", ka, kb)
you could just do:
ks = "Wht 15 Grn 34 Blu 39 Ylw 11 Red 196 Amb 214 " \
"Cyn 51 Mgn 201 Syp 196 Code 196"
Also, this:
kl { printf("%s%s%s\n", tseq[ctp], $0, rst) }
!kl { printf("%s\n", $0) }
is just:
kl { print tseq[ctp] $0 rst }
!kl { print }
you're complicating your code unnecessarily with all those [s]printfs.