mosh icon indicating copy to clipboard operation
mosh copied to clipboard

win32: Consider how `isExecutable` treated

Open okuoku opened this issue 2 years ago • 3 comments

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

https://github.com/higepon/mosh/blob/935355556adfec7fcacc0f478132c72a352097bb/src/OSCompat.cpp#L680-L688

(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

okuoku avatar Sep 11 '22 14:09 okuoku

What's the use case for an isExecutable procedure?

lassik avatar Sep 11 '22 15:09 lassik

(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 :-)

lassik avatar Sep 11 '22 15:09 lassik

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.

okuoku avatar Sep 11 '22 16:09 okuoku