我想为一个使脚本全局可执行的shell脚本创建一个--setup标志,所以1. sudo chmod +x $0和2. sudo cp $0 /usr/local/bin。
问题显然是,脚本只有在它是可执行的时候才能运行。也许有人可以称之为sudo bash ./script --setup
有什么最佳实践吗?还是让脚本更像官方存储库中安装的cl工具?
发布于 2017-05-18 17:15:03
您可以使用install
Usage: install [OPTION]... [-T] SOURCE DEST
or: install [OPTION]... SOURCE... DIRECTORY
or: install [OPTION]... -t DIRECTORY SOURCE...
or: install [OPTION]... -d DIRECTORY...
This install program copies files (often just compiled) into destination
locations you choose. If you want to download and install a ready-to-use
package on a GNU/Linux system, you should instead be using a package manager
like yum(1) or apt-get(1).或者,如文档所述,为发行版或万向节构建一个包。
https://stackoverflow.com/questions/44053879
复制相似问题