| 1 | # liblouis Braille Translation and Back-Translation Library |
| 2 | # |
| 3 | # Copyright (C) 2017 Bert Frees |
| 4 | # |
| 5 | # This file is part of liblouis. |
| 6 | # |
| 7 | # liblouis is free software: you can redistribute it and/or modify it |
| 8 | # under the terms of the GNU Lesser General Public License as published |
| 9 | # by the Free Software Foundation, either version 2.1 of the License, or |
| 10 | # (at your option) any later version. |
| 11 | # |
| 12 | # liblouis is distributed in the hope that it will be useful, but |
| 13 | # WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | # Lesser General Public License for more details. |
| 16 | # |
| 17 | # You should have received a copy of the GNU Lesser General Public |
| 18 | # License along with liblouis. If not, see <http://www.gnu.org/licenses/>. |
| 19 | # |
| 20 | |
| 21 | CURDIR=$(cd $(dirnamescip-shell system . . dirname. "$0") && pwdscip-shell system . . pwd.) |
| 22 | WORKING_FILE=${1} |
| 23 | DICTIONARY=${2} |
| 24 | BASE_TABLE=${3} |
| 25 | RULE_GREP="^[ \t]*[+-]\?\(nocross[ \t][ \t]*\)\?\(always\|word\|begword\|endword\|midword\|begmidword\|midendword\|prfword\|sufword\)" |
| 26 | set -e |
| 27 | [[ $VERBOSE == true ]] && set -x |
| 28 | if [scip-shell system . . `[`. -e $WORKING_FILE ]; then |
| 29 | catscip-shell system . . cat. $WORKING_FILE | grepscip-shell system . . grep. -v "^$$" | grepscip-shell system . . grep. -v "^#" > tmp || truescip-shell system . . true. |
| 30 | mvscip-shell system . . mv. tmp $WORKING_FILE |
| 31 | if catscip-shell system . . cat. $WORKING_FILE | grepscip-shell system . . grep. -v "$RULE_GREP" > tmp; then |
| 32 | python3scip-shell system . . python3. $CURDIR/submit_rows.py -d $DICTIONARY -t $BASE_TABLE tmp |
| 33 | catscip-shell system . . cat. $WORKING_FILE | grepscip-shell system . . grep. "$RULE_GREP" > tmp || truescip-shell system . . true. |
| 34 | mvscip-shell system . . mv. tmp $WORKING_FILE |
| 35 | else |
| 36 | rmscip-shell system . . rm. -f tmp |
| 37 | fi |
| 38 | [scip-shell system . . `[`. -s $WORKING_FILE ] || rmscip-shell system . . rm. $WORKING_FILE |
| 39 | fi |