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.
I like the default behavior of Bash <= 4.1 that expands
cd $SOMEPATH into
cd /the/actual/path when pressing the Tab key. This is just one example, though;
complete_fullquote (though I don't know exactly what it does) may have also changed default behavior at v4.2.
direxpand which switches on this non-default behavior in Bash 4.2 and above is not recognized by earlier versions, and 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 (i.e., not just redirecting the error output to