Arg grep

arg_grep

Scan a list of arguments for a given flag or word. Returns 0 if found, 1 if not found. Handles short flags (-v), long flags (--verbose), and plain words.

Example

arg_grep --verbose "$@"
arg_grep -v "$@"
arg_grep debug "$@"

Arguments

  • $1 (string): The flag or word to search for
  • ... (string): The arguments to scan (pass "$@" from the caller)

Exit codes

  • 0: Flag/word found
  • 1: Flag/word not found