Why does macOS set xattr com.apple.quarantine, when saving a shell script on a usb stick
This solved it for me

Q: Is there a file with the quarantine flag set, on the USB stick?
mount is adding a quarantine flag, causing: /bin/bash: bad interpreter: Operation not permitted - but not the usual suspects

A: Yes, there were many. 

Howto do it

List xattributes of all files on the stick

xattr -r /Volumes/stick128/


Remove the xattribute com.apple.quarantine from all files on the USB stick

sudo xattr -r -d com.apple.quarantine /Volumes/stick128


Try provoking the error again, by editing and saving the myScript.sh file

Result


No error
The xattr com.apple.quarantine is not beeing added to myScript.sh