Repository navigation
fix(@angular/cli): only load autocompletion in interactive shells - #34401
Conversation
Previously, `ng completion` appended an unconditional `source <(ng completion script)` statement to the user's shell configuration file. When non-interactive shells (such as those spawned by scripts, automation tools, or coding agents) sourced the configuration file, they still paid the overhead of starting Node.js and generating the completion script despite tab completion not being used. This change wraps the `source <(ng completion script)` command in an `if [[ $- == *i* ]]; then` check so that autocompletion is only loaded when the shell is interactive, and updates the manual setup documentation accordingly. Closes angular#34307
There was a problem hiding this comment.
Code Review
This pull request wraps the Angular CLI autocompletion script loading in an interactive shell check (if [[ $- == *i* ]]; then ... fi) across the documentation, utility script, and E2E tests. The reviewer pointed out that using [[ and process substitution <(...) directly in startup files like .profile will cause syntax errors in POSIX-compliant shells (e.g., dash). To resolve this, the reviewer suggested a more robust, POSIX-compliant shell check using standard [, eval, and guards for BASH_VERSION or ZSH_VERSION across the utility script, documentation, and tests.
|
This pull request has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Previously,
ng completionappended an unconditionalsource <(ng completion script)statement to the user's shell configuration file. When non-interactive shells (such as those spawned by scripts, automation tools, or coding agents) sourced the configuration file, they still paid the overhead of starting Node.js and generating the completion script despite tab completion not being used.This change wraps the
source <(ng completion script)command in anif [[ $- == *i* ]]; thencheck so that autocompletion is only loaded when the shell is interactive, and updates the manual setup documentation accordingly.Closes #34307