Merge pull request #2427 from akohlmey/lammps-shell-tweaks
A few more tweaks for the LAMMPS Shell
This commit is contained in:
@ -25,8 +25,9 @@
|
|||||||
#endif
|
#endif
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#define isatty(x) _isatty(x)
|
#define chdir(x) _chdir(x)
|
||||||
#define getcwd(buf, len) _getcwd(buf, len)
|
#define getcwd(buf, len) _getcwd(buf, len)
|
||||||
|
#define isatty(x) _isatty(x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(_WIN32)
|
#if !defined(_WIN32)
|
||||||
@ -560,8 +561,9 @@ static int help_cmd()
|
|||||||
"- Use the '!' character for bash-like history epansion. (Example: '!run)\n\n"
|
"- Use the '!' character for bash-like history epansion. (Example: '!run)\n\n"
|
||||||
"A history of the session will be written to the a file '.lammps_history'\n"
|
"A history of the session will be written to the a file '.lammps_history'\n"
|
||||||
"in the current working directory and - if present - this file will be\n"
|
"in the current working directory and - if present - this file will be\n"
|
||||||
"read at the beginning of the next session of the LAMMPS shell.\n\n";
|
"read at the beginning of the next session of the LAMMPS shell.\n\n"
|
||||||
return 0;
|
"Additional information is at https://packages.lammps.org/lammps-shell.html\n\n";
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int shell_end()
|
static int shell_end()
|
||||||
@ -673,6 +675,29 @@ int main(int argc, char **argv)
|
|||||||
char *line;
|
char *line;
|
||||||
std::string trimmed;
|
std::string trimmed;
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
// Special hack for Windows: if the current working directory is
|
||||||
|
// the "system folder" (because that is where cmd.exe lives)
|
||||||
|
// switch to the user's documents directory. Avoid buffer overflow
|
||||||
|
// and skip this step if the path is too long for our buffer.
|
||||||
|
if (getcwd(buf, buflen)) {
|
||||||
|
if ((strstr(buf, "System32") || strstr(buf, "system32")) {
|
||||||
|
char *drive = getenv("HOMEDRIVE");
|
||||||
|
char *path = getenv("HOMEPATH");
|
||||||
|
buf[0] = '\0';
|
||||||
|
int len = strlen("\\Documents");
|
||||||
|
if (drive) len += strlen(drive);
|
||||||
|
if (path) len += strlen(path);
|
||||||
|
if (len < buflen) {
|
||||||
|
if (drive) strcat(buf, drive);
|
||||||
|
if (path) strcat(buf, path);
|
||||||
|
strcat(buf, "\\Documents");
|
||||||
|
chdir(buf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
lammps_get_os_info(buf, buflen);
|
lammps_get_os_info(buf, buflen);
|
||||||
std::cout << "LAMMPS Shell version 1.1 OS: " << buf;
|
std::cout << "LAMMPS Shell version 1.1 OS: " << buf;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user