ct (Command Trace) is a Bash command analysis tool that explains:
- how Bash resolves a command
- what the kernel ultimately executes
It provides visibility into shell behavior, including resolution order, shadowing, and filesystem execution details.
ct operates in two distinct modes:
ct <command>Analyzes a single command and reports:
- Bash resolution path (alias, function, keyword, builtin, PATH)
- Full
$PATHscan (including shadowed and unreachable entries) - Shadowed commands and overrides
- Kernel execution target (actual executable)
- Filesystem execution details:
- canonical paths
- symlink chains (including
/etc/alternatives) - ELF interpreters (for binaries)
- shebangs (for scripts)
Clear separation of:
- Bash Resolution Target
- Kernel Execution Target
ct -cScans the current shell environment and reports command name collisions across:
- aliases
- functions
- builtins
- keywords
Also checks whether those names exist as external commands in $PATH.
- Focuses on name collisions, not full resolution tracing
- External commands are reported only as presence indicators
- Does not perform a full
$PATHscan- avoids excessive noise
- avoids misleading conflicts caused by PATH precedence
- Reflects actual Bash resolution rules
- Bash command resolution tracing
- Environment-wide conflict detection (
-c) - Accurate shadowing detection
- Full
$PATHvisibility (trace mode only) - Separation of Bash vs kernel execution
- Filesystem introspection:
- canonical paths
- symlink chains
/etc/alternatives- ELF interpreter detection
- shebang parsing
- Builtin state detection (enabled/disabled)
- Automatic and manual
$PATHextension - JSON output for scripting (
-j) - Colorized human-readable output
- Tab completion support
- Safe environment handling (restores
$PATH, shell options)
JSON mode is intended for scripting and inspection.
ct -j ls
ct -c --json- Fields may change across versions
- Do not assume strict schema stability
null= not applicable- Booleans are always
true/false
- resolution type (
alias,function,builtin,keyword,path) - PATH scan results
- kernel execution details
- shadowing indicators
- command name
- resolution winner
- alternate definitions
- shadowed status
grep,file,cut,head,readlink,readelf,awk
tput(color output)
- Bash ≥ 4.4
git clone https://github.com/JB63134/bash_ct.git /usr/local/bin/bash_ct
echo "source /usr/local/bin/bash_ct/.bash_ct" >> ~/.bashrc
source ~/.bashrcct [options] command
ct -c [options]
| Option | Description |
|---|---|
-h, --help |
Show usage information |
-v, --version |
Show version and license |
-j, --json |
Emit JSON output |
-x, --extend |
Extend $PATH for discovery |
-c, --conflict |
Run environment conflict analysis |
ct ls
ct python
ct -j bashct -c
ct -c --json- Commands must be bare names only
- ❌
/bin/ls - ❌
./script
- ❌
$PATHmay be temporarily extended (auto or-x)- Environment is restored after execution
ct <cmd>→ deep resolution +$PATH+ kernel executionct -c→ shell conflict analysis (aliases, functions, builtins, keywords)
This separation keeps output focused and avoids misleading noise from normal $PATH behavior.





