Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

win32: Consider how isExecutable treated #65

Open
okuoku opened this issue Sep 11, 2022 · 3 comments
Open

win32: Consider how isExecutable treated #65

okuoku opened this issue Sep 11, 2022 · 3 comments
Labels

Comments

@okuoku
Copy link
Collaborator

okuoku commented Sep 11, 2022

I'm going to temporarily comment-out Win32 isExecutable implementation since it doesn't compile on the latest source.

mosh/src/OSCompat.cpp

Lines 680 to 688 in 9353555

if (isExist(path)) {
const ucs4char* extensions[] = { UC(".COM"), UC(".EXE"), UC(".BAT"), UC(".VBS"), UC("VBE"),
UC(".JS"), UC(".JSE"), UC(".WSF"), UC(".WSH"), UC(".MSC")};
for (unsigned int i = 0; i < sizeof(extensions); i++) {
if (endsWith(path, extensions[i])) {
return true;
}
}
}

(Since ucs4string is now explicit, we cannot instantiate them in this way.)

Win32 do not have "executable" bit on its filesystem so ultimately we cannot implement this. We can consider multiple implementations and need to choose one:

  • a) Decide on file extension (Previous implementation)
    • consider "double-click-to-execute" files as executable.
    • Previous implementation is incomplete; use PATHEXT to get precise result
    • Pros:
      • ????
    • Cons:
  • b) Always false (My preference)
    • Same as Git -- On (Native-)Windows, it always consider file is not executable
    • Pros:
      • Reflects filesystem attributes precisely -- Windows' filesystem do not have one
    • Cons:
      • Even .exe evaluated as false
  • c) Always true
    • Same as Cygwin -- On Cygwin, any files on foreign filesystem is treated as Executable
@lassik
Copy link
Contributor

lassik commented Sep 11, 2022

What's the use case for an isExecutable procedure?

@lassik
Copy link
Contributor

lassik commented Sep 11, 2022

(I once tried writing a procedure to get the filename of the running executable, and faced similar difficulties. The solution was to remove the whole procedure :-)

@okuoku
Copy link
Collaborator Author

okuoku commented Sep 11, 2022

What's the use case for an isExecutable procedure?

Mosh(-scheme) has been originally developed to implement Scheme-shell -- if we wanted to implement TAB completion for a command line, we'd need one to pick-up executable from PATH.

On Windows, I think it's for completeness; world's being dominated by POSIX. Even WASI -- which is intended to be write-once-run-anywhere -- have executable bit for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants