Open gdevenyi opened 7 years ago
If you're interested in this, you're certainly welcome to test it and propose a relevant commit.
Sure. Can you point out which scripts you consider "maintained"?
Does there exist any small test data for these scripts so I can confirm functionality without rolling my own?
I'm guessing anything with ants*.sh constitutes a subset of "maintained" scripts.
Some of these scripts are exercised with various github examples (including data) that are linked to on the main ANTs github page.
Some scripts have a logCmd
function, eg in antsCorticalThickness.sh
logCmd ${ANTSPATH}/ImageMath ${DIMENSION} ${EXTRACTED_SEGMENTATION_BRAIN} m \
${ANATOMICAL_IMAGES[0]} ${BRAIN_EXTRACTION_MASK}
This should exit the script if ImageMath
returns a non-zero value.
In practice, not every call gets logged, intentionally or otherwise. Sometimes it's because steps are deemed trivial, and we only want to log things like calls to antsRegistration
that might need to be tested or optimized offline.
But feasibly we might not want to check exit status of every command. In strict mode, can we maintain this flexibility?
For example, let's say we want to grep, and it's OK if the number of matches is 0. This will make grep return 1 and quit the script.
@cookpa In the case of calls such as grep where there might not be a match, there is a workaround described at http://redsymbol.net/articles/unofficial-bash-strict-mode/#issues-and-solutions
Essentially, || true
handles those cases.
It's a bit of a flip in coding style, where you explicitly catch known "might fails" instead of explicitly checking return codes.
Gabriel,
Thank you for taking this on. I have been using this type of scripting approach for many years, and it certainly does make more robust and easier to use scripts.
Hans
From: "Gabriel A. Devenyi" notifications@github.com Reply-To: stnava/ANTs reply@reply.github.com Date: Thursday, January 5, 2017 at 2:09 PM To: stnava/ANTs ANTs@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: Re: [stnava/ANTs] bash scripts don't catch errors (#397)
@cookpa In the case of calls such as grep where there might not be a match, there is a workaround described at http://redsymbol.net/articles/unofficial-bash-strict-mode/#issues-and-solutions
Essentially, || true handles those cases.
It's a bit of a flip in coding style, where you explicitly catch known "might fails" instead of explicitly checking return codes.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.
Closed by #1771 for antsMultivariateTemplateConstruction2.sh
If any of the commands in the bash scripts fail, currently the scripts continue on as if things were successful.
It would be beneificial to enable "unofficial bash strict mode" http://redsymbol.net/articles/unofficial-bash-strict-mode/ on the scripts to catch/error out on problems.
This may cause scripts to stop due to certain bash programming anti-patterns (which would need to be adjust) so it needs to be tested before being committed.