If you write a Bash
case statement, can you get the current match without explicitly assigning it to a variable ?
case $(some subshell command sequence) in one) stuff ;; *) stuff "$case_match";; esac
I know that I can do the below but wanted to be more succinct.
case_match=$(some subshell command sequence) case "$case_match" in ...
Is there a special variable representing
Following comment from @Hauke Laging another contrived example. You can do this:
today=$(date '+%A') case "$today" in *) echo "It's $today" ;; esac
But it would be nice to do this - the question asked if this was possible (but it isn't):
case $(date '+%A') in *) echo "It's $case_match" ;; esac
case_match is the golden variable that eludes us)