mirror of
git://projects.qi-hardware.com/antorcha.git
synced 2024-11-22 13:57:10 +02:00
tools/ant-txt/pick: shell script to pick a message from a file
This commit is contained in:
parent
80a2bf3796
commit
af047755b9
60
tools/ant-txt/pick
Executable file
60
tools/ant-txt/pick
Executable file
@ -0,0 +1,60 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# tools/ant-txt/pick - Run ant-txt on a message selected by number
|
||||
#
|
||||
# Written 2012 by Werner Almesberger
|
||||
# Copyright 2012 Werner Almesberger
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
|
||||
#
|
||||
# File format (on stdin):
|
||||
#
|
||||
# - message blocks are separated by one or more empty lines
|
||||
# - lines beginning with # are ignored before or after a message block
|
||||
# (or between empty lines)
|
||||
#
|
||||
# Message blocks are selected by number. The first block is 1.
|
||||
#
|
||||
#
|
||||
|
||||
opt=
|
||||
if [ "${1#-}" != "$1" ]; then
|
||||
opt=$1
|
||||
shift
|
||||
fi
|
||||
|
||||
sel=$1
|
||||
skip=true
|
||||
n=0
|
||||
while read s; do
|
||||
[ "$s" = "${s#\#}" ] || continue
|
||||
if [ ! "$s" ]; then
|
||||
skip=true
|
||||
continue
|
||||
fi
|
||||
$skip && n=`expr $n + 1`
|
||||
skip=false
|
||||
[ "$sel" ] || continue
|
||||
[ $sel = $n ] && break
|
||||
done
|
||||
|
||||
if [ ! "$sel" ]; then
|
||||
echo $n
|
||||
exit
|
||||
fi
|
||||
|
||||
msg=
|
||||
while true; do
|
||||
msg="$msg '$s'"
|
||||
read t || break
|
||||
[ -z "$t" -o "$t" != "${t#\#}" ] && break
|
||||
s=$t
|
||||
done
|
||||
|
||||
dir=${0%/*}
|
||||
eval $dir/ant-txt $opt -F $dir/../fonts $msg
|
Loading…
Reference in New Issue
Block a user