Skip to content

Commit 26521fd

Browse files
committed
Robustify getting summary
1 parent 64cc4d7 commit 26521fd

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

bin/reproin

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ function debug() {
2727
:
2828
}
2929

30+
function wc_hits() {
31+
{ grep "$1" "$2" || : ; } | wc -l
32+
}
33+
3034

3135
function setup_containers() {
3236
if [ -e code/containers ]; then
@@ -303,17 +307,17 @@ study-show-save)
303307
studyshow="$studydir/.git/study-show"
304308
$0 study-show "$study" >| "$studyshow.sh" 2>| "$studyshow.stderr"
305309
[ -s "$studyshow.stderr" ] || rm -f "$studyshow.stderr"
306-
$0 study-show-summary "$study"
310+
$0 study-show-summary "$study" || echo "study-show-summary $study errored out, continuing" >&2
307311
fi
308312
exit 0
309313
;;
310314
study-show-summary)
311315
# to be used in conjunction with lists-update-summary-shows or just by itself
312316
studyshow="$bidsdir/$2/.git/study-show"
313-
todo=$(grep '^heudiconv ' "$studyshow.sh" | wc -l)
314-
warnings=$(grep 'WARNING: ' "$studyshow.sh" | wc -l)
315-
fixups=$(grep '!!!' "$studyshow.sh" | wc -l)
316-
don=$(grep '#.* done ' "$studyshow.sh" | wc -l)
317+
todo=$(wc_hits '^heudiconv ' "$studyshow.sh")
318+
warnings=$(wc_hits 'WARNING: ' "$studyshow.sh")
319+
fixups=$(wc_hits '!!!' "$studyshow.sh")
320+
don=$(wc_hits '#.* done ' "$studyshow.sh")
317321
echo -n "todo=$todo done=$don"
318322
if [ $fixups -gt 0 ]; then
319323
echo -n " fixups=$fixups"

0 commit comments

Comments
 (0)