Checks whether a specific shell command is available
in the system.

@param cmd the command to check against

@return true, if the command is availble, false otherwise
199800
public static boolean checkExistence(String cmd) {
    StringBuffer sb = runCommand("which " + cmd);
    if (sb.length() > 1)
      return true;

    return false;
  }
205801
function parseSubCommand(cmd) {
	const parseDetails = parseLine(cmd.rest, cmd.lineno);
	if (parseDetails.command) {
		cmd.args = parseDetails.command;
		return true;
	}
	cmd.error = 'Unhandled onbuild command: ' + cmd.rest;
	return false;
}
649685
def has(cmd):
    
    helps = ["--help", "-h", "--version"]
    if "nt" == os.name:
        helps.insert(0, "/?")
    fakecmd = "fakecmd"
    cmderr = strerr(fakecmd).replace(fakecmd, cmd)
    for h in helps:
        hcmd = "%s %s" % (cmd, h)
        if 0 == silent(hcmd):
            return True
        if len(listout(hcmd)) > 0:
            return True
        if strerr(hcmd) != cmderr:
            return True
    return False
531662
public boolean isCommandAllowed(String classname, String cmd) throws DevFailed {
		return databaseDAO.isCommandAllowed(this, classname, cmd);
	}
373787
protected boolean handleCmdLineSessionArgsSynchronously(Control control) {
        if (getArgs().isEnabled(CommandLine.SESSION) && getArgs().isEnabled(CommandLine.NEW_SESSION)) {
            System.err.println(
                    "Error: Invalid command line options: option '" + CommandLine.SESSION + "' not allowed with option '"
                            + CommandLine.NEW_SESSION + "'");

            return false;
        }

        if (getArgs().isEnabled(CommandLine.SESSION)) {
            Path sessionPath = SessionUtils.getSessionPath(getArgs().getArgument(CommandLine.SESSION));

            String absolutePath = sessionPath.toAbsolutePath().toString();
            try {
                control.runCommandLineOpenSession(absolutePath);

            } catch (Exception e) {
                getLogger().error(e.getMessage(), e);
                System.err.println("Failed to open session: " + absolutePath);
                e.printStackTrace(System.err);
                return false;
            }

        } else if (getArgs().isEnabled(CommandLine.NEW_SESSION)) {
            Path sessionPath = SessionUtils.getSessionPath(getArgs().getArgument(CommandLine.NEW_SESSION));

            String absolutePath = sessionPath.toAbsolutePath().toString();
            if (Files.exists(sessionPath)) {
                System.err.println("Failed to create a new session, file already exists: " + absolutePath);
                return false;
            }

            try {
                control.runCommandLineNewSession(absolutePath);

            } catch (Exception e) {
                getLogger().error(e.getMessage(), e);
                System.err.println("Failed to create a new session: " + absolutePath);
                e.printStackTrace(System.err);
                return false;
            }
        }

        return true;
    }
828396
@Nullable
  private String[] getReplacementCmd(String cmd) {
    if (mCommandAlias == null || !mCommandAlias.containsKey(cmd)) {
      return null;
    }
    return mCommandAlias.get(cmd);
  }
1271380
@Override
    public boolean isAllowCompound ( String command ) {
        if ( this.disallowCompound == null ) {
            return true;
        }
        return !this.disallowCompound.contains(command);
    }
178028
public boolean isCommandAllowed(Database database, String classname, String cmd)
            throws DevFailed {
        if (database.getAccess_proxy()==null) {
            if (!database.isAccess_checked())
                checkAccess(database);
            return !database.check_access;
        } else
            return database.getAccess_proxy().isCommandAllowed(classname, cmd);
    }
559821
protected function findExecutable($cmd)
    {
        $pathToCmd = $this->searchForExecutable($cmd);
        if ($pathToCmd) {
            return $this->useCallOnWindows($pathToCmd);
        }
        return false;
    }
1003094
public String is(final String command) {
		LOG.info("Obtain result from  | " + command + " |");
		return is(command, new String[]{});
	}
469753
def is_command_callable(command, name=""):
    

    # Use `command` to see if command is callable, store exit code
    code = os.system(
        "command -v {0} >/dev/null 2>&1 || {{ exit 1; }}".format(command))

    if code != 0:
        alias_value = " ('{}') ".format(name) if name else " "
        _LOGGER.debug("Command '{0}' is not callable: {1}".
                      format(alias_value, command))
    return not bool(code)
590386
public static boolean isAlive(String pid) {
    ShellCommandExecutor shexec = null;
    try {
      String[] args = { "kill", "-0", pid };
      shexec = new ShellCommandExecutor(args);
      shexec.execute();
    } catch (ExitCodeException ee) {
      return false;
    } catch (IOException ioe) {
      LOG.warn("Error executing shell command "
          + Arrays.toString(shexec.getExecString()) + ioe);
      return false;
    }
    return (shexec.getExitCode() == 0 ? true : false);
  }
573079
@Override
  public boolean isDisplayed() {
    WebDriverLikeRequest request = buildRequest(WebDriverLikeCommand.DISPLAYED);
    return (Boolean) commandExecutor.execute(request);
  }
28220
public static void runUninterruptibly(final Try.Runnable<InterruptedException> cmd) {
        N.checkArgNotNull(cmd);

        boolean interrupted = false;

        try {
            while (true) {
                try {
                    cmd.run();
                    return;
                } catch (InterruptedException e) {
                    interrupted = true;
                }
            }
        } finally {
            if (interrupted) {
                Thread.currentThread().interrupt();
            }
        }
    }
347692
public boolean assist() {
        // Read the command line and provide assistance for the command line before the caret.
        final String commandLine = commandLineManager.getCommandLine();
        final int caret = commandLineManager.getCaret();
        final String commandLineToAssist = commandLine.substring(0, caret);
        final Opt<String> autoCompletedSuffix = shell.assist(commandLineToAssist);
        if (!autoCompletedSuffix.isPresent()) {
            return false;
        }

        // Don't overwrite any extra characters on the command line that came after the caret.
        final String extraCommandLine = commandLine.substring(caret);
        final String autoCompletedCommandLine = commandLineToAssist + autoCompletedSuffix.get();
        commandLineManager.setCommandLine(autoCompletedCommandLine + extraCommandLine);
        commandLineManager.setCaret(autoCompletedCommandLine.length());
        return true;
    }
422452
public static StringBuffer runCommand(String[] cmd) {
    StringBuffer retval = new StringBuffer(MAX_OUTPUT_LENGTH);
    Process p;
    try {
      p = Runtime.getRuntime().exec(cmd);
      InputStream tmp = p.getInputStream();
      p.waitFor();
      int c;
      while ((c = tmp.read()) != -1)
        retval.append((char) c);
    } catch (IOException e) {
      e.printStackTrace();
    } catch (InterruptedException e) {
      e.printStackTrace();
    }

    return retval;
  }
1094074
public static boolean isAvailable() {
    try {
      String osName = System.getProperty("os.name");
      if (!osName.startsWith("Linux")) {
        LOG.info("ProcfsBasedProcessTree currently is supported only on "
            + "Linux.");
        return false;
      }
    } catch (SecurityException se) {
      LOG.warn("Failed to get Operating System name. " + se);
      return false;
    }
    return true;
  }