Пример #1
0
  @Override
  public void execute() throws Exception {
    final PrintWriter err = getError().getPrintWriter();
    final File file = argFile.getValue();

    Shell shell = null;
    try {
      shell = ShellUtils.getShellManager().getCurrentShell();
    } catch (NameNotFoundException e) {
      e.printStackTrace(err);
      exit(2);
    }

    if (shell == null) {
      err.println(err_null);
      exit(2);
    }

    String[] args = argArgs.getValues();

    int rc = shell.runCommandFile(file, null, args);
    if (rc != 0) {
      exit(rc);
    }
  }
Пример #2
0
  @Override
  public void execute() throws Exception {
    PrintWriter out = getOutput().getPrintWriter();
    if (argLanguage.isSet()) {
      final String language = argLanguage.getValue();

      String country = (argCountry.isSet()) ? argCountry.getValue() : "";
      String variant = (argVariant.isSet()) ? argVariant.getValue() : "";

      Locale locale = findLocale(language, country, variant);
      if (locale == null) {
        getError().getPrintWriter().format(err_no_locale, language, country, variant);
        exit(1);
      }
      out.format(fmt_set, formatLocale(locale));
      Locale.setDefault(locale);
    } else if (argList.isSet()) {
      listLocales(out);
    } else {
      out.format(fmt_get, formatLocale(Locale.getDefault()));
    }
  }
Пример #3
0
 public void execute() throws Exception {
   getOutput().getPrintWriter().print(arg.getValue());
 }
Пример #4
0
  // TODO Allow working directory to be changed
  public void execute() {
    super.execute("tar");
    if (!checkMode()) {
      fatal(err_options, 1);
    }

    if (Archive.isSet()) archive = Archive.getValue();
    if (Suffix.isSet()) suffix = Suffix.getValue();
    if (Exclude.isSet()) exclude = Exclude.getValue();
    if (ExcludeFile.isSet()) excludeFile = ExcludeFile.getValue();
    if (FileList.isSet()) fileList = FileList.getValue();

    backup = Backup.isSet();
    bzip = UseBzip.isSet();
    gzip = UseGzip.isSet();
    interact = Interact.isSet();
    verify = Verify.isSet();
    showTotals = ShowTotals.isSet();
    keepOld = KeepOld.isSet();
    keepNew = KeepNew.isSet();
    recurse = !NoRecurse.isSet();
    unlink = Unlink.isSet();

    try {
      if ((mode & TAR_REQ_ARCH) != 0 && archive == null) {
        fatal("Archive required for -Acdtru", 1);
      }

      if ((mode & TAR_DECOMPRESS) != 0 && archive != null) {
        if (checkCompressed(archive) == -1) {
          // happens when -j or -z were specified, but the archive is not
          // in the given format.
          if (bzip) {
            fatal("Archive is not compressed with bzip2.", 1);
          }
          if (gzip) {
            fatal("Archive is not compressed with gzip.", 1);
          }
          fatal("Internal Error: checkCompressed() returned -1", -1);
        }
      }

      if ((mode & TAR_COMPRESS) != 0) {
        if (bzip) {
          compress = USE_BZIP;
        } else if (gzip) {
          compress = USE_GZIP;
        } else {
          compress = decompress;
        }
      }

      if ((mode & TAR_VERIFY) != 0 && verify) {
        // backup original archive
      }

      if ((mode & TAR_CREATE) != 0 && compress == 0) {
        compress = checkSuffix(archive);
      }

      if ((mode & TAR_INSERT) != 0) {
        insert(processFiles(Paths.getValues(), recurse));
      }

      if ((mode & TAR_UPDATE) != 0) {
        update(processFiles(Paths.getValues(), recurse));
      }

      if ((mode & TAR_CONCAT) != 0) {
        concat(processArchives(Paths.getValues()));
      }

      if ((mode & TAR_DELETE) != 0) {
        // delete();
      }

      if ((mode & TAR_EXTRACT) != 0) {
        if (decompress == 0 && archive == null) {
          if (bzip) {
            decompress = USE_BZIP;
          } else if (gzip) {
            decompress = USE_GZIP;
          }
        }
        extract();
      }

      if ((mode & TAR_LIST) != 0) {
        list();
      }

      if ((mode & TAR_DIFF) != 0) {
        diff();
      }
    } catch (Exception e) {
      e.printStackTrace();
      fatal(err_exception_uncaught, 1);
    }
  }