don't munge "=> ?!"
[gemrepl.git] / examples / multiline.sh
blob928dd40e6fc5c5001d2570428446d652cb86a080
1 #!/bin/sh
2 # Showing one possible way of doing multiline input
4 function readline {
5 echo -n '<' >&3
6 read line
7 ret=$?
8 echo -n '>' >&3
9 echo "$line"
10 return $ret
13 while readline; do true; done | (
14 echo "Enter your message, ending with a line consisting of a single dot."
15 # dot-stuff as in RFC 5321: to input a line starting with a literal dot,
16 # use two dots.
17 message="$(sed -n '/^\.$/q;s/^\.//;p')"
18 echo "You wrote the following $(echo "$message"|wc -l) line(s):"
19 echo "$message"