This document describes the exit codes used by the Ably CLI, particularly in interactive mode.
- Normal successful completion of a command
- Clean exit after user types
exitcommand (in non-wrapper mode)
- Special exit code used when user types
exitin interactive mode with wrapper - Signals to the wrapper script (
bin/ably-interactive) to terminate the loop - Defined as
Interactive.EXIT_CODE_USER_EXIT
- Standard Unix exit code for SIGINT (128 + 2)
- Used when:
- Double Ctrl+C (force quit) in interactive mode
- Single Ctrl+C in non-interactive mode
- Any SIGINT that causes process termination
- Standard Unix exit code for SIGTERM (128 + 15)
- Used when process receives SIGTERM signal
- Generic error exit code
- Used for initialization failures or unexpected errors
- At empty prompt: Shows "^C" and message about typing 'exit' to quit
- During command execution: Interrupts the command and returns to prompt
- With partial command typed: Clears the line and returns to prompt
- Force quit: Immediately exits with code 130
- Shows "⚠ Force quit" message
- Bypasses normal cleanup
The bin/ably-interactive wrapper script uses these exit codes to determine whether to restart the interactive shell:
- Exit code 42: User typed 'exit' - terminate the wrapper loop
- Exit code 130: SIGINT - restart the shell (unless double Ctrl+C)
- Exit code 0: Normal exit - terminate the wrapper loop
- Other codes: Show error message and restart after delay
Exit codes are handled in:
src/commands/interactive.ts: Sets exit code 42 for user exitsrc/utils/sigint-exit.ts: Handles SIGINT behavior and exit code 130bin/ably-interactive: Wrapper script that interprets exit codes
- Interactive-REPL.md — Architecture and wrapper script design
- Troubleshooting.md — Common interactive mode issues