#!/bin/sh # Interface to Google Suggest - not very useful, but a nice demo of # how to combine Sindre with other programs through shell script. code=$(cat <lines(lines) { if (clear) { list.clear(); clear = 0; } } input->changed(from, to) { clear=1; print to; next; } function quit() { print; exit } EOF ) dir=$(mktemp -p "${TMPDIR:-/tmp}" -d dir-XXXX) || exit 1 fifo=$dir/fifo mkfifo "$fifo" || { rmdir "$dir"; exit 1; } googlesuggest() { python - "$@" <&3 # Due to Python nonsense, we have to reencode the output. googlesuggest "$line" | iconv -f latin1 -t utf8 & done 3>&1 1>$fifo | tail -n 1 | sed '/^$/d' rm $fifo rmdir $dir