I use a shell script named myapp.command to open an app such as the Microsoft PowerShell app:
#!/bin/sh
exec /usr/local/microsoft/powershell/7/pwsh
The script works fine. However, when I put the same script inside a macOS bundle (called myapp.app), it does not work. The error message I get is, myapp.app quit unexpectedly.
Error report reveals that the error occurs in /Applications/myapp.app/Contents/MacOS/myapp.command.
Exception type: EXC_CRASH (SIGABRT)
Exception Note: EXC_CORPSE_NOTIFY
Application Specific Information: abort() called
The contents of Info.plist are as follows:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleGetInfoString</key>
<string>1.0, Copyright © 2019 MyCompany, All Rights Reserved</string>
<key>CFBundleIdentifier</key>
<string>com.mycompany.MyApp</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>mycompany.myapp</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2019 MyCompany, All Rights Reserved.</string>
<key>NSPrincipalClass</key>
<string>ShellScript</string>
<key>CFBundleExecutable</key>
<string>myapp.command</string>
<key>CFBundleIconFile</key>
<string>MyCompany</string>
<key>NSMainNibFile</key>
<string>main.nib</string>
</dict>
</plist>
How can I fix/troubleshoot this?
CodePudding user response:
pwsh
crashes because it is not connected to any tty
A work-around is to tell the Terminal App to launch it:
#!/bin/sh
osascript -e '
tell app "Terminal"
do script "/usr/local/microsoft/powershell/7/pwsh; exit $?"
activate
end tell
'