www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Re: std.path.getName(): Screwy by design?

reply Kagamin <spam here.lot> writes:
Jérôme M. Berger Wrote:

 
 ??????
 It ALWAYS makes a difference. For example, only .exe and .com files are 
 executable.
 On unix, the filename is just a name. Nothing more. By contrast, the 
 Windows extension actually matters. They're completely different.

What do you mean? You can run .js and .vbs files as well.

No you cannot. What happens is that you *open* them with the default application, which just happens to be an interpreter whose default action is to run the script.

I think, the same happens on unix. Is the script to be flagged executable to be run, just like any other runnable file?
Mar 04 2011
parent reply Jonathan M Davis <jmdavisProg gmx.com> writes:
On Friday 04 March 2011 00:08:25 Kagamin wrote:
 J=C3=A9r=C3=B4me M. Berger Wrote:
 ??????
 It ALWAYS makes a difference. For example, only .exe and .com files
 are executable.
 On unix, the filename is just a name. Nothing more. By contrast, the
 Windows extension actually matters. They're completely different.

What do you mean? You can run .js and .vbs files as well.

No you cannot. What happens is that you *open* them with the =20 default application, which just happens to be an interpreter whose default action is to run the script.

I think, the same happens on unix. Is the script to be flagged executable to be run, just like any other runnable file?

The only way _anything_ is executable in *nix is if its executable flag is = set.=20 Extensions mean _nothing_ as far as executability goes. =2D Jonathan M Davis
Mar 04 2011
next sibling parent reply Kagamin <spam here.lot> writes:
Jonathan M Davis Wrote:

 On Friday 04 March 2011 00:08:25 Kagamin wrote:
 Jérôme M. Berger Wrote:
 ??????
 It ALWAYS makes a difference. For example, only .exe and .com files
 are executable.
 On unix, the filename is just a name. Nothing more. By contrast, the
 Windows extension actually matters. They're completely different.

What do you mean? You can run .js and .vbs files as well.

No you cannot. What happens is that you *open* them with the default application, which just happens to be an interpreter whose default action is to run the script.

I think, the same happens on unix. Is the script to be flagged executable to be run, just like any other runnable file?

The only way _anything_ is executable in *nix is if its executable flag is set. Extensions mean _nothing_ as far as executability goes.

As you can see, there's an ambiguity here: script is not executed directly in the same sense as machine code, so it may be not called an execution and not require executable flag to be interpreted. Actual application beign executed is interpreter. So the question is whether a script have to be flagged executable in order to run interpreter on it.
Mar 04 2011
parent reply Daniel Gibson <metalcaedes gmail.com> writes:
Am 04.03.2011 09:56, schrieb Kagamin:
 Jonathan M Davis Wrote:
 
 On Friday 04 March 2011 00:08:25 Kagamin wrote:
 Jérôme M. Berger Wrote:
 ??????
 It ALWAYS makes a difference. For example, only .exe and .com files
 are executable.
 On unix, the filename is just a name. Nothing more. By contrast, the
 Windows extension actually matters. They're completely different.

What do you mean? You can run .js and .vbs files as well.

No you cannot. What happens is that you *open* them with the default application, which just happens to be an interpreter whose default action is to run the script.

I think, the same happens on unix. Is the script to be flagged executable to be run, just like any other runnable file?

The only way _anything_ is executable in *nix is if its executable flag is set. Extensions mean _nothing_ as far as executability goes.

As you can see, there's an ambiguity here: script is not executed directly in the same sense as machine code, so it may be not called an execution and not require executable flag to be interpreted. Actual application beign executed is interpreter. So the question is whether a script have to be flagged executable in order to run interpreter on it.

On *nix: Yes. Scripts have to be flagged executable. (Of course you can start a non-executable script with e.g. bash foo.sh)
Mar 04 2011
next sibling parent reply Kagamin <spam here.lot> writes:
Daniel Gibson Wrote:

 The only way _anything_ is executable in *nix is if its executable flag is
set. 
 Extensions mean _nothing_ as far as executability goes.

As you can see, there's an ambiguity here: script is not executed directly in the same sense as machine code, so it may be not called an execution and not require executable flag to be interpreted. Actual application beign executed is interpreter. So the question is whether a script have to be flagged executable in order to run interpreter on it.

On *nix: Yes. Scripts have to be flagged executable. (Of course you can start a non-executable script with e.g. bash foo.sh)

I suppose, the flag on a script is checked "manually" by the shell, and on a binary - by the OS.
Mar 04 2011
parent Kagamin <spam here.lot> writes:
Jonathan M Davis Wrote:

 I suppose, the flag on a script is checked "manually" by the shell, and on
 a binary - by the OS.

The "OS" means next to nothing in unix land. What's the OS? The kernel? The set of common utilities?

Oh, looking at execve(2), I see, shebang is processed by the kernel. Wow.
 file must be the owner of the file. If it is executable for that user, then
the 
 shell will attempt execute it. If not, they're not allowed to. Another program 
 could attempt to read it and do something with it assuming that the user has 
 read permissions for the file, but it can't be directly executed.

Well, no script can be directly executed, it's just a text after all. What execve does is not really a direct execution.
Mar 04 2011
prev sibling parent Jonathan M Davis <jmdavisProg gmx.com> writes:
On Friday 04 March 2011 02:02:45 Kagamin wrote:
 Daniel Gibson Wrote:
 The only way _anything_ is executable in *nix is if its executable
 flag is set. Extensions mean _nothing_ as far as executability goes.

As you can see, there's an ambiguity here: script is not executed directly in the same sense as machine code, so it may be not called an execution and not require executable flag to be interpreted. Actual application beign executed is interpreter. So the question is whether a script have to be flagged executable in order to run interpreter on it.

On *nix: Yes. Scripts have to be flagged executable. (Of course you can start a non-executable script with e.g. bash foo.sh)

I suppose, the flag on a script is checked "manually" by the shell, and on a binary - by the OS.

The "OS" means next to nothing in unix land. What's the OS? The kernel? The set of common utilities? The whole environment? What matters is how the command line shell is implemented and how file permissions work. Per how file permissions work, a file must have the executable flag set either for all or for the group that the user is in, or it must be set for the owner of the file and the user running the file must be the owner of the file. If it is executable for that user, then the shell will attempt execute it. If not, they're not allowed to. Another program could attempt to read it and do something with it assuming that the user has read permissions for the file, but it can't be directly executed. So, in the case of a shell script, you have to have permission to execute the file if you wish to execute it, and you have to have permission to read it if you want to pass it to some other sort of executable (such as a command to start a new shell) in order to run it that way. But ultimately, whether an executable file is a binary or not is irrelevant. - Jonathan M Davis
Mar 04 2011
prev sibling parent spir <denis.spir gmail.com> writes:
On 03/04/2011 09:56 AM, Kagamin wrote:
 Jonathan M Davis Wrote:

 On Friday 04 March 2011 00:08:25 Kagamin wrote:
 Jérôme M. Berger Wrote:
 ??????
 It ALWAYS makes a difference. For example, only .exe and .com files
 are executable.
 On unix, the filename is just a name. Nothing more. By contrast, the
 Windows extension actually matters. They're completely different.

What do you mean? You can run .js and .vbs files as well.

No you cannot. What happens is that you *open* them with the default application, which just happens to be an interpreter whose default action is to run the script.

I think, the same happens on unix. Is the script to be flagged executable to be run, just like any other runnable file?

The only way _anything_ is executable in *nix is if its executable flag is set. Extensions mean _nothing_ as far as executability goes.

As you can see, there's an ambiguity here: script is not executed directly in the same sense as machine code, so it may be not called an execution and not require executable flag to be interpreted. Actual application beign executed is interpreter. So the question is whether a script have to be flagged executable in order to run interpreter on it.

What do you expect? *nixWorld is HackLand, in all senses of 'hack' ;-) Denis -- _________________ vita es estrany spir.wikidot.com
Mar 04 2011