Shell .app 包中的脚本出错
Shell script within .app bundle errors out
我使用名为 myapp.command 的 shell 脚本来打开应用程序,例如 Microsoft PowerShell 应用程序:
#!/bin/sh
exec /usr/local/microsoft/powershell/7/pwsh
脚本运行良好。但是,当我将相同的脚本放入 macOS 包(称为 myapp.app)时,它不起作用。我收到的错误消息是,myapp.app 意外退出。
错误报告显示错误发生在/Applications/myapp.app/Contents/MacOS/myapp.command.
异常类型:EXC_CRASH (SIGABRT)
例外说明:EXC_CORPSE_NOTIFY
应用程序特定信息:已调用 abort()
Info.plist内容如下:
<?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>
我怎么能fix/troubleshoot这个?
pwsh
崩溃,因为它没有连接到任何 tty
一个work-around是告诉终端应用启动它:
#!/bin/sh
osascript -e '
tell app "Terminal"
do script "/usr/local/microsoft/powershell/7/pwsh; exit $?"
activate
end tell
'
我使用名为 myapp.command 的 shell 脚本来打开应用程序,例如 Microsoft PowerShell 应用程序:
#!/bin/sh
exec /usr/local/microsoft/powershell/7/pwsh
脚本运行良好。但是,当我将相同的脚本放入 macOS 包(称为 myapp.app)时,它不起作用。我收到的错误消息是,myapp.app 意外退出。
错误报告显示错误发生在/Applications/myapp.app/Contents/MacOS/myapp.command.
异常类型:EXC_CRASH (SIGABRT)
例外说明:EXC_CORPSE_NOTIFY
应用程序特定信息:已调用 abort()
Info.plist内容如下:
<?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>
我怎么能fix/troubleshoot这个?
pwsh
崩溃,因为它没有连接到任何 tty
一个work-around是告诉终端应用启动它:
#!/bin/sh
osascript -e '
tell app "Terminal"
do script "/usr/local/microsoft/powershell/7/pwsh; exit $?"
activate
end tell
'