Skip to content

fix(@angular/cli): only load autocompletion in interactive shells - #34401

Open
clydin wants to merge 2 commits into
angular:mainfrom
clydin:fix/completion-interactive-shells
Open

clydin wants to merge 2 commits into
angular:mainfrom
clydin:fix/completion-interactive-shells

Conversation

@clydin

@clydin clydin commented Oct 19, 2026

Copy link
Copy Markdown
Member

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 #34307

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
@clydin clydin added the target: patch This PR is targeted for the next patch release label Oct 19, 2026
@clydin
clydin requested a review from dgp1130 October 19, 2026 14:12
@clydin
clydin marked this pull request as ready for review October 19, 2026 14:33

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread packages/angular/cli/src/utilities/completion.ts Outdated
Comment thread packages/angular/cli/src/commands/completion/long-description.md
Comment thread tests/e2e/tests/commands/completion/completion.ts
@alan-agius4 alan-agius4 added the action: merge The PR is ready for merge by the caretaker label Oct 19, 2026
@alan-agius4
alan-agius4 removed the request for review from dgp1130 October 19, 2026 18:07
Comment thread packages/angular/cli/src/utilities/completion.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: @angular/cli target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ng completion should apply to interactive shells only

3 participants