0

I have the below osascript in bash.

This has worked fine for me for quite some time however recently I used HomeBrew to upgrade my version of bash on my Apple machine from 3.x to 5.x. This works fine in all cases (except osascript) such as clicking on the Terminal app icon or using sudo and I always get version 5.x of bash. However, when the below script runs it opens a window with the old 3.x version of bash.

Does anyone know how to get osascript to also use my new default upgraded version of bash? Or if not the new default then to just force it to use the version I want?

I did try replacing:

tell application "Terminal"

with

tell application "/usr/local/bin/bash"

which didn't bring up a window at all.

Here is the script:

      if [ "$APPLE_WINDOW_TYPE" == "window" ]; then
        osascript<<EOF
          tell application "Terminal"
            do script "cd \"`pwd`\"; echo; echo; $1 $2 $3 $4 $5 $6 $7 $8 $9"
          end tell
EOF
      elif [ "$APPLE_WINDOW_TYPE" == "tab" ]; then
        osascript<<EOF
          tell application "Terminal"
            activate
            delay 0.5
            tell application "System Events" to keystroke "t" using command down
            repeat while contents of selected tab of window 1 starts with linefeed
              delay 0.01
            end repeat
            do script "cd \"`pwd`\"; echo; echo; $1 $2 $3 $4 $5 $6 $7 $8 $9" in window 1
          end tell
EOF
        sleep 2
      fi

Basically I'm using oascript to bring up a new bash window to run various processes in separate windows.

user5429087
  • 139
  • 2
  • 10

1 Answers1

0

So I figured this out, it's not a great solution but it works.

You can't change what Apple puts at /bin/sh (or /bin/bash) so brew puts a newer bash at /usr/local/bin/bash so what you need to do is change the header of your .sh files to #!/usr/local/bin/bash and then the newer shell will open up through osascript.

user5429087
  • 139
  • 2
  • 10