Giter VIP home page Giter VIP logo

Comments (4)

KrisThielemans avatar KrisThielemans commented on August 15, 2024

easy thing is to use set -e at the start. It does make the script stop whenever there's an error (that isn't inside a pipeline, etc). It does exit abruptly though without any message. We can switch it to bash and then do something like this
https://github.com/UCL/STIR/blob/7b4c27470ad175a80f29e9aabe945b6831a4f159/scripts/estimate_scatter.sh#L104-L105

set -e # exit on error
trap "echo ERROR in $0" ERR

Obviously better is to do

if apply_normfactors3D $OutputFilename $factors ones.hs 1 1 $eff_iters
then
  : #OK
else
  echo "Error over here" >2;exit 1
fi

but it's much more verbose. In nearly all Bourne shells implementations you can shorten this to

if ! apply_normfactors3D $OutputFilename $factors ones.hs 1 1 $eff_iters
then
  echo "Error over here" >2;exit 1
fi

but apparently it isn't 100% portable 😢 (although I cannot immediately find a link to that info anymore)

from stir-gate-connection.

robbietuk avatar robbietuk commented on August 15, 2024

Is there anything wrong with

apply_normfactors3D $OutputFilename $factors ones.hs 1 1 $eff_iters
if [ $? -eq 0 ]; then
    echo "apply_normfactors3D OK"
else
    echo "apply_normfactors3D FAIL"
    exit 1
fi

besides it being verbose?

e: The first option seems to work nicely.

from stir-gate-connection.

KrisThielemans avatar KrisThielemans commented on August 15, 2024

sure, that's fine and even more verbose 😄

from stir-gate-connection.

robbietuk avatar robbietuk commented on August 15, 2024

Resolved with 3fef6c4

from stir-gate-connection.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.