Context:
- M1 MacBook
- macOS Ventura 13.5.2
- zsh as default shell
- GNU coreutils installed by homebrew
/opt/homebrew/opt/coreutils/libexec/gnubin
added to path in~/.bashrc
,~/.bash_profile
, and~/.bash_login
I have bash scripts that
- start with
#!/usr/bin/env bash
- invoke
date
with parameters that work with GNU date (/opt/homebrew/opt/coreutils/libexec/gnubin
) but not macOS date (/bin/date
) - fail when invoked interactively from zsh because the wrong
date
is invoked- this isn’t a guess, I checked with
which date
andecho $PATH
and so on - it works if I run bash interactively first, and then invoke the script from bash rather than zsh
- this isn’t a guess, I checked with
This looks like the path changes in ~/.bash*
are not being loaded when zsh launches my scripts.
To confirm that, I added lines like echo ".bashrc"
to each of ~/.bash*
, and none of those messages appear when I run my scripts.
In zsh, which bash
gives /opt/homebrew/bin/bash
, and bash --version
starts with GNU bash, version 5.2.15(1)-release (aarch64-apple-darwin22.1.0)
How do I get bash to load its configuration for scripts?