Bash

-bash:: /bin/bash: 錯誤的解釋器:不允許操作

  • September 30, 2021

我最近將採用openjdk-13 替換為採用openjdk-16。我有一個按名稱使用該工具的腳本文件,因此我將其從 13 更改為 16。它的新內容:

#!/bin/bash
if [ -z ${JAVA_OPTS+x} ]
then
 # Set some defaults
 JAVA_OPTS=""
fi
/Library/Java/JavaVirtualMachines/adoptopenjdk-16.jdk/Contents/Home/bin/java $JAVA_OPTS -jar $CROMWELL_HOME/womtool.jar "$@"

me $  which bash
/bin/bash
me $  ll /usr/local/cromwell
total 16
drwxr-xr-x   6 root  wheel   192B Sep 27 12:43 ./
drwxr-xr-x  23 root  wheel   736B Nov 10  2020 ../
-rwxr-xr-x@  1 root  wheel   210B Sep 27 12:42 cromwell*
lrwxr-xr-x   1 root  wheel    39B Jul 14 15:14 cromwell.jar
-rwxr-xr-x@  1 root  wheel   208B Sep 27 12:41 womtool*
lrwxr-xr-x   1 root  wheel    38B Jul 14 15:14 womtool.jar
m082166@me $ $CROMWELL_HOME/womtool validate MyWDL.wdl
-bash: /usr/local/cromwell/womtool: /bin/bash: bad interpreter: Operation not permitted
me $  /Library/Java/JavaVirtualMachines/adoptopenjdk-16.jdk/Contents/Home/bin/java $JAVA_OPTS -jar $CROMWELL_HOME/womtool.jar validate MyWDL.wdl
Success!

當執行腳本的內容完全沒問題時,為什麼 bash 拒絕讓我執行腳本?在我更新腳本文件以指向正確的工具後,這實際上就壞了

感謝 elfshift 這就是答案。顯然 MacOS 決定將這些文件放入“隔離區”,因此不讓我執行這些文件

sudo xattr -d com.apple.quarantine /usr/local/cromwell/*

解決了這個問題

引用自:https://unix.stackexchange.com/questions/670894