code: public void execute() throws BuildException {
      if (null == cmd)
        throw new BuildException("Missing command (cmd) argument");
      argv.add(0, cmd);
  
      if (null == confloader) {
        setConf(getProject().getProperty("hadoop.conf.dir"));
      }
  
      int exit_code = 0;
      try {
        pushContext();
  
        Configuration conf = new Configuration();
        conf.setClassLoader(confloader);
        exit_code = ToolRunner.run(conf, shell,
            argv.toArray(new String[argv.size()]));
        exit_code = postCmd(exit_code);
  
        if (0 > exit_code) {
          StringBuilder msg = new StringBuilder();
          for (String s : argv)
            msg.append(s + " ");
          msg.append("failed: " + exit_code);
          throw new Exception(msg.toString());
        }
      } catch (Exception e) {
        if (failonerror)
            throw new BuildException(e);
      } finally {
        popContext();
      }
    }
docs: Invoke {@link org.apache.hadoop.fs.FsShell#doMain FsShell.doMain} after a
  few cursory checks of the configuration.