Do shell script in AppleScript

How to enable brew in ‘do shell script’ ?

In particular, after Catalina zsh upgrade, don’t want to use bash & perlbrew command I used in past:

do shell script “~/perl5/perlbrew/bin/perlbrew exec --with perl-5.28.1”

Please don’t tell me what to do as a workaround, just answer the question

relevant reference

Any application launched from the Finder gets the same default environment: a working directory of / and the environment variables HOME, LANG, PATH, SHELL, and USER. Most applications do not change their environment, but relying on this is a maintenance risk.

I’m going to assume you didn’t intend for this to sound rude, but you should know that “just answer the question” definitely comes across as rude, and might make some people be less inclined to help.

I’m not entirely sure what you mean by “enable brew”. Do you mean installing brew or just using it by running some brew command?

Without more specific information, here is what I can tell you:

  1. The change in Catalina only means that new accounts will have zsh as their default shell. Brew scripts tend to declare which shell they want to use, so the default shell should not change anything.

  2. If you are calling a script in AppleScript, it will still use the declared shell (look for something like #!/bin/bash at the first line of the script that you are calling).

  3. I always recommend using $HOME instead of ~ when referring to something in your home directory. It works more reliably in more places, in my experience.

1 Like