如何在 MacOS 上不使用终端的情况下向 .arm64 可执行文件添加启动选项

发布于 2025-01-14 00:13:36 字数 128 浏览 2 评论 0原文

我想知道是否有人知道如何在不使用终端的情况下使用启动选项(在本例中为“+set fs_game ...”)启动 .arm64 可执行文件? 我知道您可以在 Windows 中配置 .exe 来执行此操作,但我没有找到 MacOS 的替代方案。

I would like to know if someone know how to launch an .arm64 executable with a launch option (in this case "+set fs_game ...") without using a terminal ?
I know that you can do that in windows configuring the .exe but I don't find an alternative for MacOS.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

独夜无伴 2025-01-21 00:13:37

有一些解决方法,但没有实际的功能可以使这变得干净或简单。


如果您有 .app 包,则可以通过附加一些参数的 shell 脚本进行重定向。如果您有一个包含以下内容的 Info.plist:

<key>CFBundleExecutable</key>
<string>binary</string>

那么您需要将其更改为:

<key>CFBundleExecutable</key>
<string>binary_</string>

并创建一个 Contents/MacOS/binary_ 像这样:

#!/bin/bash
"$(dirname "$0")/binary" +set fs_game "$@";

并给它一个 chmod +x代码>.

无论您如何启动应用程序,这都会起作用,但它会使任何现有的代码签名无效,因此如果您的应用程序已签名,则必须重新签名。


如果您有一个独立的二进制文件,或者如果您无法破坏代码签名,那么基本上唯一的选择就是制作一个单独的东西,以您想要的方式调用它。像这样编写一个 bash 脚本:

#!/bin/bash
open -a path/to/your.app --args +set fs_game;

给它 chmod +x 并将其变成一个单独的应用程序。显然,这仅在通过该单独的应用程序调用时才有效,但它适用于任何类型的二进制文件,并且不需要重新签名任何内容(并且单独的应用程序应该只在您的扩展坞中显示一瞬间,然后再次消失)。

There's a few workarounds, but no actual feature that'd make this clean or easy.


If you have a .app bundle, you can redirect through a shell script that appends some arguments. If you have an Info.plist with this:

<key>CFBundleExecutable</key>
<string>binary</string>

Then you'll want to change it to:

<key>CFBundleExecutable</key>
<string>binary_</string>

And create a Contents/MacOS/binary_ like so:

#!/bin/bash
"$(dirname "$0")/binary" +set fs_game "$@";

And give it a chmod +x.

That'll work no matter how you launch the app, but it will invalidate any existing code signature, so if your app was signed, you'll have to re-sign it.


If you have a standalone binary or if you can't afford to break the code signature, then basically the only option is to make a separate thing that invokes it the way you want. Write a bash script like so:

#!/bin/bash
open -a path/to/your.app --args +set fs_game;

Give it chmod +x and turn it into a separate app. This will obviously only work when invoked via that separate app, but it works with any kind of binary, and without the need to re-sign anything (and the separate app should only show up in your dock for a split second, then vanish again).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文