Testing for Valid Arguments

This practical modifies the bet_vol script again to check that valid arguments are supplied. Note that the previous version gave errors if no argument was specified.
  1. Checking the number of arguments Take the bet_vol script and check to see if an argument is actually specified by testing whether $# is equal to zero.
    Print out a warning message (with usage information) if the test succeeds and stop the script using: exit -1

  2. Checking for valid files
    Inside the script test whether ${1}.nii.gz exists and is a readable file (see help test). If not, write out an error message and exit.

  3. Testing the script
    Test whether the script works by specifying an existing file and then a non-existent file.

    Look here for the cheat.