所有文件都可以在cygwin中执行?


1

似乎cygwin认为所有文件都是可执行的:

/tmp> echo "echo abc" > a
/tmp> ls -l a
-rw-r--r-- 1 I063510 Domain Users 9 Apr  9 15:39 a
/tmp> ./a
abc
/tmp> cygcheck -c base-cygwin
Cygwin Package Information
Package              Version        Status
base-cygwin          3.8-1          OK

我很确定这种行为最近发生了变化。它是可配置的,以便我这样的文件不执行?

我甚至似乎记得必须更改在cygwin中创建的.bat文件的权限,以便它可以从Windows命令提示符执行,但我可能错了。

Answers:


0

问题是缺乏she-bang,所以文件由shell本身加载。
https://en.wikipedia.org/wiki/Shebang_%28Unix%29

$  echo 'echo abc' > a
$ ls -l a
-rw-r--r-- 1 marco Administrators 9 Apr 10 13:28 a
$ ./a
abc

$  echo '#!/bin/bash\recho abc' > a
$ ls -l a
-rw-r--r-- 1 marco Administrators 22 Apr 10 13:29 a
$ ./a
-bash: ./a: Permission denied
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.