关于shell:mac-shell-脚本执行报错-Operation-not-permitted

mac上你从网页、QQ或微信等下载一个sh脚本,不要忙焦急着去执行,要不然会报上面的谬误

sudo: unable to execute ./sh/ijiami-clang-install.sh: Operation not permitted

遇到这个问题该咋办,别着急咱们来分析一下是为什么起因,ls -l一下
失去上面列表,都有执行权限,等等前面为啥有个@,百度可知这是个暗藏属性.

ijm@172-10-20-151 sh % ls -l
total 64
-rw-r--r--@ 1 ijm  staff  2437  4 14 14:36 Fastfile
-rwxr-xr-x@ 1 ijm  staff  6312  4 16 10:33 ijiami-clang-install.sh
-rwxr-xr-x@ 1 ijm  staff   830  4 16 10:33 ijiami-clang-uninstall.sh
-rwxr-xr-x@ 1 ijm  staff  9337  4 14 14:34 ijiami-config.sh
-rwxr-xr-x@ 1 ijm  staff   588  4 16 10:33 ijiami-version.sh
drwxr-xr-x@ 5 ijm  staff   160  4 16 10:34 pbx_config

为了一探到底,咱们用ls -l@看一下有哪些暗藏属性

total 40
-rwxr-xr-x@ 1 ijm  staff  2658  3  4 18:46 ijiami-build.sh
    com.apple.lastuseddate#PS      16 
    com.apple.macl      72 
    com.apple.quarantine      21 
-rwxr-xr-x@ 1 ijm  staff  6029  2  2 15:02 ijiami-clang-install.sh
    com.apple.lastuseddate#PS      16 
    com.apple.macl      72 
    com.apple.quarantine      21 
-rwxr-xr-x@ 1 ijm  staff   830  1 28 17:37 ijiami-clang-uninstall.sh
    com.apple.macl      72 
    com.apple.quarantine      21 
-rwxr-xr-x@ 1 ijm  staff   588  1 28 17:37 ijiami-version.sh
    com.apple.macl      72 
    com.apple.quarantine      21 
drwxr-xr-x@ 5 ijm  staff   160  1 19 19:12 pbx_config
    com.apple.quarantine      21 

有暗藏属性com.apple.quarantine,这个是啥玩意,咱们一探到底.搜寻得悉
macOS Catalina 退出了一项名为 GateKeeper 的爱护机制,从互联网上下载来的文件,会被零碎打上 com.apple.quarantine 标记,也就是免疫隔离,本意是为了防止利用威逼,从而增强零碎安全性。
坑爹啊只能把这个暗藏属性给干掉啊

sudo xattr -r -d com.apple.quarantine +目录门路

参考文章:https://juejin.cn/post/684490…

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理