Re: Review Request 65144: Ported `os::which` to Windows.

2018-01-16 Thread Joseph Wu

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


Ship it!




Ship It!

- Joseph Wu


On Jan. 16, 2018, 12:05 p.m., Andrew Schwartzmeyer wrote:
> 
> ---
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/65144/
> ---
> 
> (Updated Jan. 16, 2018, 12:05 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/2/
> 
> 
> 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
> 
>



Re: Review Request 65144: Ported `os::which` to Windows.

2018-01-16 Thread Andrew Schwartzmeyer

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

(Updated Jan. 16, 2018, 12:05 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 (updated)
-

  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/2/

Changes: https://reviews.apache.org/r/65144/diff/1-2/


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



Re: Review Request 65144: Ported `os::which` to Windows.

2018-01-16 Thread Andrew Schwartzmeyer


> On Jan. 16, 2018, 10:58 a.m., Joseph Wu wrote:
> > 3rdparty/stout/include/stout/os/windows/which.hpp
> > Lines 53-56 (patched)
> > 
> >
> > 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) {
> > ...
> >   }
> > }
> > ```
> 
> Andrew Schwartzmeyer wrote:
> 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`.

Nevermind. That was the intent, but that's not how it works because we search 
folders first. I see.


- 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
> 
>



Re: Review Request 65144: Ported `os::which` to Windows.

2018-01-16 Thread Andrew Schwartzmeyer


> On Jan. 16, 2018, 10:58 a.m., Joseph Wu wrote:
> > 3rdparty/stout/include/stout/os/windows/which.hpp
> > Lines 53-56 (patched)
> > 
> >
> > 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)
> > 
> >
> > ```
> > 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)
> > 
> >
> > 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
> 
>



Re: Review Request 65144: Ported `os::which` to Windows.

2018-01-16 Thread Joseph Wu

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




3rdparty/stout/include/stout/os/windows/which.hpp
Lines 53-56 (patched)


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) {
...
  }
}
```



3rdparty/stout/include/stout/os/windows/which.hpp
Lines 58 (patched)


```
This is how `where` works on Windows.
```

Do you mean "`which`" above?



3rdparty/stout/include/stout/os/windows/which.hpp
Lines 62 (patched)


I wonder if we should note the non-case-sensitivity of the search 
somewhere...


- Joseph Wu


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
> 
>



Re: Review Request 65144: Ported `os::which` to Windows.

2018-01-16 Thread Jie Yu

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


Ship it!




Ship It!

- Jie Yu


On Jan. 14, 2018, 2:01 a.m., Andrew Schwartzmeyer wrote:
> 
> ---
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/65144/
> ---
> 
> (Updated Jan. 14, 2018, 2:01 a.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
> 
>



Review Request 65144: Ported `os::which` to Windows.

2018-01-12 Thread Andrew Schwartzmeyer

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

Review request for mesos, Akash Gupta, 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
---


Thanks,

Andrew Schwartzmeyer