Running this in bash in my Homestead box works: symbRefHead=$(git symbolic-ref -q HEAD) && echo $symbRefHead && branch_name="${symbRefHead//refs\/heads\/}" && echo $branch_name
So why does running it via runLocally fail?
$options = ['tty' => true];
runLocally('symbRefHead=$(git symbolic-ref -q HEAD) && echo $symbRefHead && branch_name="${symbRefHead//refs\/heads\/}" && echo $branch_name', $options);
I get this error:
sh: 1: Bad substitution
In Process.php line 250:
The command "symbRefHead=$(git symbolic-ref -q HEAD) && echo $symbRefHead && branch_name="${symbRefHead//refs\/heads\/}" && echo $branch_name" failed.
Exit Code: 2(Misuse of shell builtins)
Similarly this version works in Bash but not in runLocally: symbRefHead=$(git symbolic-ref -q HEAD) && echo $symbRefHead && to_be_removed="refs/heads/" && branch_name="${symbRefHead/$to_be_removed/}" && echo $branch_name
I'm obviously trying to remove a substring from a string variable (search and replace with nothing) as mentioned here: https://unix.stackexchange.com/questions/104881/remove-particular-characters-from-a-variable-using-bash#comment437753_104887
P.S. Ultimately I'll want to be able to get the branch name into a variable so I can echo it here: https://stackoverflow.com/a/59689871/470749