I work in a relatively heterogeneous environment where I may be running different versions of Bash on different HPC nodes, VMs, or my personal workstation. Because I put my login scripts in a Git repo, I would like use the same(ish)
.bashrc across the board, without a lot of "if this host, then..."-type messiness.
I like the default behavior of Bash ≤ 4.1 that expands
cd $SOMEPATH into
cd /the/actual/path when pressing the Tab key. In Bash 4.2 and above, you would need to
shopt -s direxpand to re-enable this behavior, and that didn't become available until 4.2.29. This is just one example, though; another, possibly related
complete_fullquote (though I don't know exactly what it does) may have also changed default behavior at v4.2.
direxpand is not recognized by earlier versions of Bash, and if I try to
shopt -s direxpand in my
.bashrc, that results in an error message being printed to the console every time I log in to a node with an older Bash:
-bash: shopt: direxpand: invalid shell option name
What I'd like to do is wrap a conditional around
shop -s direxpand to enable that option on Bash > 4.1 in a robust way, without chafing the older versions of Bash (i.e., not just redirecting the error output to