noweave_backend.sh (1704B)
1 #!/bin/sh 2 3 # Copyright (C) 2021-2023 Centre National de la Recherche Scientifique 4 # Copyright (C) 2021-2023 INSA Lyon 5 # Copyright (C) 2021-2023 Institut Mines Télécom Albi-Carmaux 6 # Copyright (C) 2021-2023 |Méso|Star> (contact@meso-star.com) 7 # Copyright (C) 2021-2023 Institut Pascal 8 # Copyright (C) 2021-2023 PhotonLyX (info@photonlyx.com) 9 # Copyright (C) 2021-2023 Université de Lorraine 10 # Copyright (C) 2021-2023 Université Paul Sabatier 11 # Copyright (C) 2021-2023 Université Toulouse - Jean Jaurès 12 # 13 # This program is free software: you can redistribute it and/or modify 14 # it under the terms of the GNU General Public License as published by 15 # the Free Software Foundation, either version 3 of the License, or 16 # (at your option) any later version. 17 # 18 # This program is distributed in the hope that it will be useful, 19 # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 # GNU General Public License for more details. 22 # 23 # You should have received a copy of the GNU General Public License 24 # along with this program. If not, see <http://www.gnu.org/licenses/>. 25 26 set -e 27 cd "$(dirname "$0")" 28 29 noweave=$(command -v noweave) 30 nolib_path=$(sed -n 's/^LIB=\(.*\)$/\1/1p' "${noweave}") 31 32 cat - > weave.all 33 count=$(grep -c '^@file ' weave.all) 34 35 if [ "${count}" -le 1 ]; then 36 csplit -s -f weave -n 1 weave.all %^@file\ % 37 else 38 # shellcheck disable=SC1083 39 csplit -s -f weave -n 1 weave.all %^@file\ % /^@file\ / {$((count - 2))} 40 fi 41 42 i=0 43 while [ "${i}" -lt "${count}" ]; do 44 tex=$(head -1 "weave${i}" | sed -n 's/@file\ \(.*\).nw/\1.tex/p') 45 "${nolib_path}/totex" -delay < "weave${i}" | cpif "src/${tex##*/}" 46 i=$((i + 1)) 47 done