example source config
[ambros.git] / src / constants.sh
blob0db14d0c422948b6421319a67080d7bf28046b68
1 #!/bin/sh
2 # functions, strings and other constants for shell scripts
4 # for relation between dit unit and speed in words/min
5 # VVVVV=64, CODEX=60, PARIS=50
6 SPEEDBASE=50
7 # default speed [words/minute]
8 DEFAULTWPM=23
10 # timeout [sec] for fetch operations
11 FETCHTIMEOUT=50
13 # directory for temporary files
14 TMP=/tmp
15 TMP=/dev/shm
17 # directory for text sources
18 SOURCEDIR=textsources
20 # configfiles
21 CHANNELCONFIG=config
22 SOURCECONFIG=config
24 # function to read config value by name
25 # arguments: configfile name [separators]
26 # value in stdout, exit nonzero if error
27 # if separators are given, will be replaced by SPC in output
28 # (e.g ',;' will result in returning "a,b;c" as "a b c")
29 # WARNING: DO NOT USE '`' in values or separators!
30 configread () {
31 local retline retval separators
32 # check if config file readable, else fail
33 test -r "$1" || return 2
34 # get last line with name (possibly surrounded by whitespace)
35 retline=`grep -i "^[ ]*$2[ ]" "$1"|tail -n 1`
36 # fail if nothing found
37 test "$retline" != "" || return 1
38 # if no separators given, replace ' ' with ' ' ie NOP
39 separators=${3:-' '}
40 # return second word from read line and substitute separators by SPC
41 echo $retline | { read _ retval _ ; echo $retval ; } |
42 sed -e "s\`[$separators]\` \`g"