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:
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")
Return
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")
Return
end if
TempBinary.Write("#!/bin/sh" + EndOfLine.UNIX + “launchctl load /Users/” + SystemInformationMBS.ShortUsername + “/Library/LaunchAgents/” + bundleID + “-helper.launchd.plist”)
TempBinary.Close
'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))
Return
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
else
globals.theErrorLog.DialogErrorProceed(kErrorAddScheduler + Str(theAuthorisation.LastError))
end if[/code]
@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.