Skip to content

default bash environment setup only configures interactive shells #1447

@dsheets

Description

@dsheets

Right now, opam init -a --bash (well, not exactly, --bash doesn't exist) writes to ~/.bashrc if ~/.bash_profile doesn't exist. If the shell is unknown, ~/.profile is used.

The fundamental difference between ~/.bashrc and ~/.bash_profile/~/.profile is that the latter are run for all login shells whereas the former is run for interactive shells. The profile files usually execute ~/.bashrc but ~/.bashrc contains

# If not running interactively, don't do anything
[ -z "$PS1" ] && return

usually near the top. Because opam appends its session configuration to the end of the interactive shell initialization, only interactive sessions are configured for opam.

This is painful when trying to use opam binaries via ssh like

ssh host "bash -l -c \"ocamlfind list\""

If ~/.bash_profile does not exist, should opam just create it? If ~/.profile exists, should opam just append its configuration to that?

Configuring for only interactive shells by default seems a little broken.

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