blob: 373c5b36933c50f5a7e66935451bc0bdbbaa6f78 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
[ ! -z "${BASHRC_PGN+x}" ] && return || readonly BASHRC_PGN=1
source .bashrc_text || return
alias strip_pgn_clk='sed --binary --in-place '"'"'s/ {\[%clk [[:digit:]]\+:[[:digit:]]\+\(:[[:digit:]]\+\)*\]}//g'"'"
alias slice_pgn_moves='sed --binary --in-place '"'"'s/ \([[:digit:]]\+\.\)/\n\1/g'"'"
normalize_pgn() {
dos2eol "$@" \
&& lint "$@" \
&& strip_pgn_clk "$@" \
&& slice_pgn_moves "$@" \
&& eol2dos "$@"
}
append_pgn() {
if [ "$#" -ne 2 ]; then
echo "$FUNCNAME: usage: $FUNCNAME DEST_PGN SRC_PGN" >&2
return 1
fi
printf '\r\n' >> "$1" \
&& cat "$2" >> "$1"
}
join_pgns() (
[ "$#" -eq 0 ] && return
set -o errexit
cat "$1"
local i
for i in "${@:2}"; do
printf '\r\n'
cat "$i"
done
)
|