> On Jan. 16, 2018, 10:58 a.m., Joseph Wu wrote:
> > 3rdparty/stout/include/stout/os/windows/which.hpp
> > Lines 53-56 (patched)
> > <https://reviews.apache.org/r/65144/diff/1/?file=1939868#file1939868line53>
> >
> >     I think the reason for allowing the caller to specify the extension is 
> > to disambiguate in cases where multiple executables of the same name, but 
> > differing extension, exist.  i.e. `foo.exe` and `foo.cmd`.
> >     
> >     But with how the loops below are laid out, we may end up prioritizing 
> > double-extensions.  For example, suppose:
> >     
> >     ```
> >     PATH = C:/;C:/path
> >     PATHEXT = .EXE;.CMD
> >     
> >     Directory structure:
> >     C:/
> >       |-- foo.cmd.exe
> >       |-- path
> >           |-- foo.cmd
> >           
> >     os::which("foo.cmd") // Would return "C:/foo.cmd.exe"
> >     ```
> >     
> >     We could either loop over extensions first (especially because files 
> > with double extensions are valid filenames, if confusing) :
> >     ```
> >     foreach (const std::string& ext, exts) {
> >       foreach (const std::string& token, tokens) {
> >         ...
> >       }
> >     }
> >     ```

I think this would return `foo.cmd`, because we insert the search with no 
extension to the _beginning_ of the list. So we search first for `foo.cmd`, and 
then next for `foo.cmd.EXE`, then `foo.cmd.CMD`.


> On Jan. 16, 2018, 10:58 a.m., Joseph Wu wrote:
> > 3rdparty/stout/include/stout/os/windows/which.hpp
> > Lines 58 (patched)
> > <https://reviews.apache.org/r/65144/diff/1/?file=1939868#file1939868line58>
> >
> >     ```
> >     This is how `where` works on Windows.
> >     ```
> >     
> >     Do you mean "`which`" above?

Nope, the equivalent shell command on Windows is `where`.


> On Jan. 16, 2018, 10:58 a.m., Joseph Wu wrote:
> > 3rdparty/stout/include/stout/os/windows/which.hpp
> > Lines 62 (patched)
> > <https://reviews.apache.org/r/65144/diff/1/?file=1939868#file1939868line62>
> >
> >     I wonder if we should note the non-case-sensitivity of the search 
> > somewhere...

Ehh maybe, maybe not. It's not that the search is case-sensitive, it's that 
Windows in general isn't case sensitive. Ergo it's not a special case here on 
Windows.


- Andrew


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/65144/#review195480
-----------------------------------------------------------


On Jan. 13, 2018, 6:01 p.m., Andrew Schwartzmeyer wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/65144/
> -----------------------------------------------------------
> 
> (Updated Jan. 13, 2018, 6:01 p.m.)
> 
> 
> Review request for mesos, Akash Gupta, Gilbert Song, Jie Yu, and Joseph Wu.
> 
> 
> Bugs: MESOS-8225
>     https://issues.apache.org/jira/browse/MESOS-8225
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> Because `os::which` still lived in `posix/os.hpp`, it was refactored
> into its own `os/which.hpp` (which the respective `os/posix/which.hpp`
> and `os/windows/which.hpp`. Consumers of this will need additionally
> include the new header, instead of just `os.hpp`.
> 
> The differences in implementation from POSIX to Windows are:
> 
> * Split the `PATH` on `;` not `:`.
> * Also loop over `PATHEXT` because executables on Windows end with one
>   of a set of extensions.
> * Removed the permissions check because it is not applicable on
>   Windows (instead, an executable ends with an extension in `PATHEXT`,
>   see above).
> 
> 
> Diffs
> -----
> 
>   3rdparty/stout/include/Makefile.am e5f11048af4ced8e8312d5c77fc3dde94f8e7012 
>   3rdparty/stout/include/stout/os/posix/which.hpp PRE-CREATION 
>   3rdparty/stout/include/stout/os/which.hpp PRE-CREATION 
>   3rdparty/stout/include/stout/os/windows/which.hpp PRE-CREATION 
>   3rdparty/stout/include/stout/posix/os.hpp 
> 7427bd792368fbacafb23593dfb9213618fdcddf 
>   3rdparty/stout/tests/os_tests.cpp de4107718cfa45f3275693a7dd59b2f52b0ced7d 
> 
> 
> Diff: https://reviews.apache.org/r/65144/diff/1/
> 
> 
> Testing
> -------
> 
> This looks bigger than it is because the implementation was moved 
> (cut/paste/clang-format) out of `posix/os.hpp` into `os/posix/which.hpp`, 
> next patch adds header to all files using `os::which`.
> 
> 
> Thanks,
> 
> Andrew Schwartzmeyer
> 
>

Reply via email to