Root/tools/ant-txt/pick

1#!/bin/sh
2#
3# tools/ant-txt/pick - Run ant-txt on a message selected by number
4#
5# Written 2012 by Werner Almesberger
6# Copyright 2012 Werner Almesberger
7#
8# This program is free software; you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation; either version 2 of the License, or
11# (at your option) any later version.
12#
13
14#
15# File format (on stdin):
16#
17# - message blocks are separated by one or more empty lines
18# - lines beginning with # are ignored before or after a message block
19# (or between empty lines)
20#
21# Message blocks are selected by number. The first block is 1.
22#
23#
24
25opt=
26if [ "${1#-}" != "$1" ]; then
27    opt=$1
28    shift
29fi
30
31sel=$1
32skip=true
33n=0
34while read s; do
35    [ "$s" = "${s#\#}" ] || continue
36        if [ ! "$s" ]; then
37        skip=true
38        continue
39    fi
40    $skip && n=`expr $n + 1`
41    skip=false
42    [ "$sel" ] || continue
43    [ $sel = $n ] && break
44done
45
46if [ ! "$sel" ]; then
47    echo $n
48    exit
49fi
50
51msg=
52while true; do
53    msg="$msg '$s'"
54    read t || break
55    [ -z "$t" -o "$t" != "${t#\#}" ] && break
56    s=$t
57done
58
59dir=${0%/*}
60eval $dir/ant-txt $opt -F $dir/../fonts $msg
61

Archive Download this file

Branches:
master
tornado-v1



interactive