Get AppleScript's "do shell script" to use the latest Bash

do shell script always uses /bin/sh, even if your default shell, shebang, or $PATH variable is set to something else.

To force it to use a different shell, you will need to call that shell. To run a command in bash, use the argument -c:

/usr/local/bin/bash -c 'echo $BASH_VERSION'

If you only want to run a single bash script, you can omit the -c with: /usr/local/bin/bash /path/to/script.bash


In AppleScript:

do shell script "/usr/local/bin/bash -c 'echo $BASH_VERSION'"

The man page entry for bash -c:

-c command_string

If the -c option is present, then commands are read from the first non-option argument command_string.