aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Aaron Gyes <me@aaron.gy>2016-06-25 00:31:46 -0700
committerGravatar Aaron Gyes <me@aaron.gy>2016-06-25 00:31:46 -0700
commit6ec83568b5ac5684200a0466831c1717318cbe7a (patch)
treee902a846c14e19b7515d3d1b9352590927e48a9e
parentb2a2705df4b17480a0983db9a1748bded0324007 (diff)
Check for "Windows-3.4.0" as per MS's suggestion.
https://github.com/Microsoft/BashOnWindows/issues/545 Just looking for "Mirosoft" is rather general - we don't want to enforce this strange behavior for Windows 12 (or the next beta.)
-rw-r--r--src/fish.cpp26
1 files changed, 10 insertions, 16 deletions
diff --git a/src/fish.cpp b/src/fish.cpp
index 12688cee..b50a79b7 100644
--- a/src/fish.cpp
+++ b/src/fish.cpp
@@ -410,29 +410,23 @@ static int fish_parse_opt(int argc, char **argv, std::vector<std::string> *cmds)
/// routines.
static void misc_init() {
#ifdef OS_IS_CYGWIN
- // MS Windows tty devices do not have either a read or write timestamp. Those respective fields
+ if (cmdfile) fclose(cmdfile)
+ // MS Windows tty devices do not currently have either a read or write timestamp. Those respective fields
// of `struct stat` are always the current time. Which means we can't use them. So we assume no
// external program has written to the terminal behind our back. This makes multiline prompts
- // usable. See issue #2859.
+ // usable. See issue #2859 and https://github.com/Microsoft/BashOnWindows/issues/545
has_working_tty_timestamps = false;
#else
- // This covers Windows Subsystem for Linux (WSL).
- int fd = open("/proc/sys/kernel/osrelease", O_RDONLY);
- if (fd != -1) {
- const char *magic_suffix = "Microsoft";
- int len_magic_suffix = strlen(magic_suffix);
- char osrelease[128] = {0};
- int len_osrelease = read(fd, osrelease, sizeof(osrelease) - 1);
- if (osrelease[len_osrelease - 1] == '\n') {
- osrelease[len_osrelease - 1] = '\0';
- len_osrelease--;
- }
- if (len_osrelease >= len_magic_suffix &&
- strcmp(magic_suffix, osrelease + len_osrelease - len_magic_suffix) == 0) {
+ // This covers preview builds of Windows Subsystem for Linux (WSL).
+ FILE *procsyskosrel;
+ if ((procsyskosrel = wfopen(L"/proc/sys/kernel/osrelease", "r"))) {
+ wcstring osrelease;
+ fgetws2(&osrelease, procsyskosrel);
+ if (osrelease.find(L"3.4.0-Microsoft") != wcstring::npos) {
has_working_tty_timestamps = false;
}
- close(fd);
}
+ if (procsyskosrel) { fclose(procsyskosrel); }
#endif // OS_IS_MS_WINDOWS
}