Moving to zsh

Because Catalina now uses zsh instead of bash I thought I’d have a look at my incredibly complex shell scripts with their few lines of code. For instance:

TempBinary.Write("#!/bin/sh" + EndOfLine.UNIX + "launchctl load /Users/" + SystemInformationMBS.ShortUsername + "/Library/LaunchAgents/" + bundleID + "-helper.launchd.plist")

If I understand the shell stuff correctly the script uses the default shell anyways so that I don’t have to do anything, correct?

theoretical the script interpreter executable is mentioned in the remark, the first line.
but how do you start this script? by a xojo app or desktop via mouse?

Practically, the script interpreter is just “sh” which makes it ambiguous as I understand shell. The code does a LaunchAgent:

[code]'write shell script to temp file
dim TempFile as FolderItem = Folderitem.TemporaryFile
if TempFile = Nil then
globals.theErrorLog.DialogErrorProceed(kErrorAddScheduler + “xxx”)
globals.theErrorLog.LogItem(CurrentMethodName + " no temp file")
end if
dim TempBinary as BinaryStream = BinaryStream.Open(TempFile, True)
if TempBinary = Nil then
globals.theErrorLog.DialogErrorProceed(kErrorAddScheduler + “xxx”)
globals.theErrorLog.LogItem(CurrentMethodName + " temp file no open")
end if
TempBinary.Write("#!/bin/sh" + EndOfLine.UNIX + “launchctl load /Users/” + SystemInformationMBS.ShortUsername + “/Library/LaunchAgents/” + bundleID + “-helper.launchd.plist”)

'set permissions for shell script
dim theShell as new Shell
theShell.Execute("chmod 777 " + TempFile.ShellPath)
if theShell.ExitCode <> 0 then
globals.theErrorLog.DialogErrorProceed(kErrorAddScheduler + “xxx”)
globals.theErrorLog.LogItem(CurrentMethodName + " error chmod " + str(theShell.ExitCode))
end if

'do Authorization
if theAuthorisation = nil then
theAuthorisation = new AuthorizationMBS
theAuthorisation.KeepRights = true
if not theAuthorisation.SimpleNewAuthorization then Return
end if

dim s(-1) as string
theAuthorisation.Execute(TempFile.UnixpathMBS, s, true)
if theAuthorisation.LastError = 0 then
dim theResult as Integer = theAuthorisation.Wait
globals.theErrorLog.DialogErrorProceed(kErrorAddScheduler + Str(theAuthorisation.LastError))
end if[/code]

The backend should still be bash by default, it’s still in macos as far as i know.
You can change that property and then just do your commands en the Shell.Execute method as normal.

@Derk Jochems : thanks, that’s what I was missing. I fell into the usual trap thinking that shell and Terminal are the same. Would it make sense to have a Feedback case to change the default backend to zsh on Catalina?

I’m not sure as apple is not removing bash and/or sh as far as i know. Perhaps it’s worth a try, xojo can always set it to “closed by design” if they choose to do so. As it “may” break other projects.