ca is very BASH specific, and Debian specific. Should work on Debian based distributions like Ubuntu, and Linux Mint.
The command resolution engine from my h function became the basis for ca.
ca is a shell-command introspection tool that tells you what a command really is. Instead of relying on multiple tools (type, which, command -V, declare, alias, etc.), ca unifies all resolution logic into a single command analysis engine.
π Overview: Modern shells resolve commands through a layered chain: Alias β Function β Builtin β keyword β File in $PATH (Script / Binary). ca tries to walk this chain recursively, determining the true implementation of any command while providing relevent information.
π§ͺ Use Cases Understand what actually runs when you type a command. Audit scripts and wrappers in toolchains. Debug $PATH problems. Identify missing dependencies. Identify SUID / capability-based escalation paths. Identify aliases and functions that override other commands. Identify disabled builtins that have been overridden by executables.
β¨ Key Features
πCommand Resolution: For any given command, ca identifies: aliases, functions, builtins, keywords, external binaries, wrapper scripts, interpreted scripts and follows symlinks to find the exact thing that Bash will execute.
π§ PATH Inspection: Displays the full resolved path and alerts you of symlinks. Can help you identify $PATH ordering issues, and overridden commands.
π Recursive Analysis: (work in progress) Depth-limited to avoid infinite loops.
π Alias Introspection: If a command resolves to an alias, ca shows: alias definition, source file & line number (when available), recursive expansion and can alert you of aliases that shadow other files, etc.
π Function Introspection: ca extracts full function definition with a syntax-highlighted preview, and source file & line number (when available). Can alert you of Functions that shadow other files, builtins, etc.
π Script Introspection: ca identifies shebang interpreter, real file location (follows symlinks), shows syntax-highlighted preview. Supports: bash, sh, python, perl, ruby, node, awk, sed, and any #! file.
π Builtin Introspection Shows: whether the builtin is enabled, whether it is a core builtin or loadable.
βοΈ ELF Binary Analysis Displays: architecture, dynamic vs static linking, ELF interpreter, (ld-linux) capabilities, SUID/SGID bits, owner & permissions, resolved real path (follows symlinks), List all dependencies and identify missing dependencies.
π¦ Package Lookup On Debian/Ubuntu/linux-Mint systems: uses dpkg to display the package name, version, maintainer info, and package description.
π οΈ Installation: Source .bash_ca
π οΈ Usage Basic:
ca without an argument uses history to lookup the last command ran.
ca <command> gives you info about a specific command.
Examples:
ca grep
ca which
ca awk
ca then
ca 'sudo cp' # output can get long, i might change this
Analyze history references:
ca !42
π‘ Tips Use ca when a command behaves unexpectedly. Use it to debug PATH issues or command conflicts. Use it when aliases or functions override global tools. Use it to audit your environment for security problems Or simply use it to explore Bash internals
| Feature / Scope | h (Bash help) |
ca (Command Analyzer) |
|---|---|---|
| Type detection | β Keywords, builtins, aliases, functions | β Keywords, builtins, aliases, functions |
| External commands | Path + --help, man, info alert | β Path, symbolic links, binary type, ELF headers, dependencies, permissions |
| Scripts / Functions | β Shows content with syntax highlighting | β Shows content with syntax highlighting |
| Permissions / Ownership | β | β Includes SUID/SGID, owner/group, octal permissions |
| Shadow / Overrides | β | β Detects overridden commands, shadowing |
| Dependencies / Environment | β | β Checks missing deps, sourced files hierarchy |
| Package info | β | β Version, maintainer, description |
| Interactive search | β fzf | β fzf |
| Ease of use | β Tab Completion | β Tab Completion |
| Focus / Use case | Shell-level explanation | Deep system/binary inspection |