Skip to content

Slow shell initialization for Bash because of trap DEBUG instruction #643

@RickWong

Description

@RickWong

Added these lines to my .bashrc (btw macOS uses .profile instead) and afterwards my shell init took 2+ seconds :

eval "$(/opt/homebrew/bin/rv shell init bash)"
eval "$(/opt/homebrew/bin/rv shell completions bash)"

Found the culprit to be the first line, it's caused by the trap instruction inside:

_rv_autoload_hook() {
    eval "$(/opt/homebrew/bin/rv shell env bash)"
}
trap '[[ "$BASH_COMMAND" != "$PROMPT_COMMAND" ]] && _rv_autoload_hook' DEBUG
_rv_autoload_hook

By inlining eval "$(/opt/homebrew/bin/rv shell env bash)" directly in my .bashrc the slowness goes away. I'm not entirely sure what the trap instruction is used for.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions