Cmd

cmd_check

Check whether one or more commands exist in PATH. With -v/--verbose, prints the resolved path of each found command and an error for each missing one. Without -v, suppresses all output and simply returns 0 or 1.

Example

cmd_check git curl jq
cmd_check --verbose git curl jq

Arguments

  • $1 (string): Optional: '-v' or '--verbose' to print paths and missing-command errors
  • ... (string): One or more command names to check

Exit codes

  • 0: All specified commands were found
  • 1: One or more commands were not found

Output on stdout

  • (verbose only) Path of each found command; error message for each missing one

cmd_list

List all commands available in the current shell environment, optionally filtered by one or more search strings. Multiple patterns are OR-joined into a single ERE pass over compgen -c output.

Example

cmd_list
cmd_list git aws

Arguments

  • ... (string): Optional: one or more substrings or ERE patterns to filter by

Exit codes

  • 0: Always

Output on stdout

  • Matching command names, one per line

cmd_exec

Execute a command while logging its timestamp, output and exit code. Uses colour when stdout is a terminal. Pass -e/--exit-on-fail to abort on error.

Arguments

  • $1 (string): Optional: -e or --exit-on-fail to exit on non-zero return
  • ... (string): The command and its arguments to execute

Exit codes

  • 0: Command succeeded
  • 1: Command failed and -e/--exit-on-fail was given

Output on stdout

  • Formatted execution log with timestamp, command output and exit code