2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-22 09:58:09 +00:00
criu/scripts/protobuf-gen.sh
Kir Kolyshkin 0a872ccf16 scripts/protobuf-gen.sh: fix (not ignore) shellcheck warnings
This basically replaces

	for x in $(sed ...); do

with

	sed ... | while IFS= read -r x; do

The only caveat is, sed program was amended to remove empty lines
(there was one right above the PB_AUTOGEN_STOP).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2023-04-15 21:17:21 -07:00

24 lines
483 B
Bash

#!/bin/bash
TR="y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/"
sed -n '/PB_AUTOGEN_START/,/PB_AUTOGEN_STOP/ {
/PB_AUTOGEN_ST/d;
/^[ \t]*$/d;
s/,.*$//;
s/\tPB_//;
p;
}' criu/include/protobuf-desc.h | \
while IFS= read -r x; do
x_la=$(echo "$x" | sed $TR)
x_uf=$(echo "$x" | sed -nr 's/^./&#\\\
/;
s/_(.)/\\\
\1#\\\
/g;
p;' | \
sed -r "/^[A-Z]#\\\\\$/!{ $TR; }" | \
sed -r ':loop; N; s/#?\\\n//; t loop')
echo "CR_PB_DESC($x, $x_uf, $x_la);"
done