将定制shell脚本移动到/ usr / bin有问题吗?(Is moving custom shell script to /usr/bin problematic?)

编程入门 行业动态 更新时间:2024-10-27 04:35:05
将定制shell脚本移动到/ usr / bin有问题吗?(Is moving custom shell script to /usr/bin problematic?)

对于任何其他原因,将自定义shell脚本放到/ usr / bin并将/ usr / bin添加到$ PATH以便在不带./和/文件扩展名?

奖金问题:我可以将自定义图标分配给自定义可执行脚本吗?

Is it dangerous, insecure or not-so-smart for any other reason to put a custom shell script to /usr/bin and add /usr/bin to $PATH in order to make a custom script executable from everywhere without ./ and the file extension?

Bonus question: can I assign custom icons to custom executable scripts?

最满意答案

传统上,/ usr / bin是存储操作系统二进制文件的地方之一。 对于自定义脚本,您可以使用/ usr / local / bin。 如你所说,你必须创建自己,如果它不存在并添加到$ PATH。

图标是GUI的事情,shell脚本是CLI的一件事。 他们生活在不同的宇宙中。 没有什么能阻止你创建一座桥。 例如,您可以创建一个shell脚本并将其命名为foo.command。 从GUI中打开它将启动终端并运行脚本。 由于您在Finder中看到该文件,因此可以通过“信息”窗格为其分配一个新图标。

此外,你可能想看看免费的Platypus应用程序。 它允许您围绕脚本创建一个完整的应用程序包。 该包将包含脚本,因此您不必将其放在一些不明确的目录中并修改$ PATH。 如果您还需要CLI访问,则此选项不太理想。

Traditionally, /usr/bin is one of the places where operating system binaries are stored. For custom scripts, you'd use /usr/local/bin. This you have to create yourself if it does not exist and add to $PATH, as you mentioned.

Icons are a GUI thing, shell scripts are a CLI thing. They live in separate universes. Nothing prevents you from creating a bridge though. For instance, you can make a shell script and call it foo.command. Opening this from the GUI starts Terminal and runs the script. Since you see the file in the Finder, you can assign it a new icon through the Info pane.

Also, you may want to take a look at the free Platypus application. It allows you to create a full-blown application bundle around a script. The bundle will contain the script, so you won't have to put it in some obscure directory and modify $PATH. If you also need CLI access, this option is less desirable.

更多推荐

本文发布于:2023-08-06 00:47:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1442120.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:脚本   bin   usr   shell   script

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!