https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3d4af223283e19eb308a5…
commit 3d4af223283e19eb308a5c4d24e7f42887ce5ee5
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Sun Jul 12 20:45:59 2020 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Wed Aug 19 21:39:21 2020 +0200
[CMD] CHDIR: Some features are available only when extensions are enabled. Update the SetRootPath() as well.
---
base/shell/cmd/internal.c | 44 ++++++++++++++++++++++++++++++++++++--------
1 file changed, 36 insertions(+), 8 deletions(-)
diff --git a/base/shell/cmd/internal.c b/base/shell/cmd/internal.c
index 7e8a7367c02..87fe7df9d81 100644
--- a/base/shell/cmd/internal.c
+++ b/base/shell/cmd/internal.c
@@ -194,9 +194,22 @@ BOOL SetRootPath(TCHAR *oldpath, TCHAR *InPath)
goto Fail;
}
- /* Convert the full path to its correct case.
- * Example: c:\windows\SYSTEM32 => C:\WINDOWS\System32 */
- GetPathCase(OutPathTemp, OutPath);
+ if (bEnableExtensions)
+ {
+ /*
+ * Convert the full path to its correct case, and
+ * resolve any wilcard present as well in the path
+ * and retrieve the first result.
+ * Example: c:\windows\SYSTEM32 => C:\WINDOWS\System32
+ * Example: C:\WINDOWS\S* => C:\WINDOWS\System,
+ * or C:\WINDOWS\System32, depending on the user's OS.
+ */
+ GetPathCase(OutPathTemp, OutPath);
+ }
+ else
+ {
+ _tcscpy(OutPath, OutPathTemp);
+ }
/* Use _tchdir(), since unlike SetCurrentDirectory() it updates
* the current-directory-on-drive environment variables. */
@@ -239,12 +252,27 @@ INT cmd_chdir(LPTSTR param)
return 0;
}
- /* Remove extra quotes and strip trailing whitespace */
+ //
+ // FIXME: Use the split() tokenizer if bEnableExtensions == FALSE,
+ // so as to cut the parameter at the first separator (space, ',', ';'):
+ // - When bEnableExtensions == FALSE, doing
+ // CD system32;winsxs
+ // will go into system32, (but: CD "system32;winsxs" will fail as below), while
+ // - When bEnableExtensions == TRUE, it will fail because the "system32;winsxs"
+ // directory does not exist.
+ //
+
+ /* Remove extra quotes */
StripQuotes(param);
- tmp = param + _tcslen(param) - 1;
- while (tmp > param && _istspace(*tmp))
- --tmp;
- *(tmp + 1) = _T('\0');
+
+ if (bEnableExtensions)
+ {
+ /* Strip trailing whitespace */
+ tmp = param + _tcslen(param) - 1;
+ while (tmp > param && _istspace(*tmp))
+ --tmp;
+ *(tmp + 1) = _T('\0');
+ }
/* Reset the error level */
nErrorLevel = 0;
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=fe9aa42d5f61fdd2fd450…
commit fe9aa42d5f61fdd2fd4501aa7541e09e98207cb7
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Sun Jul 12 17:03:45 2020 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Wed Aug 19 21:39:18 2020 +0200
[CMD] SET: Fix displaying the environment variables with a given prefix.
- Restore any truncated space in the name prefix, before displaying
any error message.
- When trimming the name prefix from "special" characters (spaces, comma
and semicolon), so that e.g. "set ,; ,;FOO" displays all the variables
starting by "FOO", save also a pointer to the original name prefix, that
we will use for variables lookup as well.
This is done, because the SET command allows setting an environment variable
whose name actually contains these characters (e.g. "set ,; ,;FOO=42"),
however, by trimming the characters, doing "set ,; ,;FOO" would not allow
seeing such variables.
With the fix, it is now possible to show them.
---
base/shell/cmd/set.c | 30 ++++++++++++++++++++++++++----
1 file changed, 26 insertions(+), 4 deletions(-)
diff --git a/base/shell/cmd/set.c b/base/shell/cmd/set.c
index f63de691a2f..0128314ca57 100644
--- a/base/shell/cmd/set.c
+++ b/base/shell/cmd/set.c
@@ -168,12 +168,27 @@ INT cmd_set(LPTSTR param)
else
{
/* Display all the environment variables with the given prefix */
- BOOL bFound = FALSE;
-
+ LPTSTR pOrgParam = param;
+ BOOLEAN bFound = FALSE;
+ BOOLEAN bRestoreSpace;
+
+ /*
+ * Trim the prefix from "special" characters (only when displaying the
+ * environment variables), so that e.g. "SET ,; ,;FOO" will display all
+ * the variables starting by "FOO".
+ * The SET command allows as well to set an environment variable whose name
+ * actually contains these characters (e.g. "SET ,; ,;FOO=42"); however,
+ * by trimming the characters, doing "SET ,; ,;FOO" would not allow seeing
+ * such variables.
+ * Thus, we also save a pointer to the original variable name prefix, that
+ * we will look it up as well below.
+ */
while (_istspace(*param) || *param == _T(',') || *param == _T(';'))
- param++;
+ ++param;
+ /* Just remove the very last space, if present */
p = _tcsrchr(param, _T(' '));
+ bRestoreSpace = (p != NULL);
if (!p)
p = param + _tcslen(param);
*p = _T('\0');
@@ -184,7 +199,9 @@ INT cmd_set(LPTSTR param)
lpOutput = lpEnv;
while (*lpOutput)
{
- if (!_tcsnicmp(lpOutput, param, p - param))
+ /* Look up for both the original and truncated variable name prefix */
+ if (!_tcsnicmp(lpOutput, pOrgParam, p - pOrgParam) ||
+ !_tcsnicmp(lpOutput, param, p - param))
{
ConOutPuts(lpOutput);
ConOutChar(_T('\n'));
@@ -195,6 +212,11 @@ INT cmd_set(LPTSTR param)
FreeEnvironmentStrings(lpEnv);
}
+ /* Restore the truncated space for correctly
+ * displaying the error message, if any. */
+ if (bRestoreSpace)
+ *p = _T(' ');
+
if (!bFound)
{
ConErrResPrintf(STRING_SET_ENV_ERROR, param);
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=90159e1e518483481ff70…
commit 90159e1e518483481ff700ff1456f603090f3008
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Sun Jul 12 23:37:50 2020 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Wed Aug 19 20:36:12 2020 +0200
[CMD] Implement provisional support for the HIGHESTNUMANODENUMBER environment-like variable.
This variable is available only in Win7+, even if the underlying API
GetNumaHighestNodeNumber() is available in Win2003+
---
base/shell/cmd/cmd.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/base/shell/cmd/cmd.c b/base/shell/cmd/cmd.c
index 1cc0a0663f5..fbc12154d1b 100644
--- a/base/shell/cmd/cmd.c
+++ b/base/shell/cmd/cmd.c
@@ -948,6 +948,17 @@ GetEnvVarOrSpecial(LPCTSTR varName)
_itot(nErrorLevel, ret, 10);
return ret;
}
+#if (NTDDI_VERSION >= NTDDI_WIN7)
+ /* Available in Win7+, even if the underlying API is available in Win2003+ */
+ /* %HIGHESTNUMANODENUMBER% */
+ else if (_tcsicmp(varName, _T("HIGHESTNUMANODENUMBER")) == 0)
+ {
+ ULONG NumaNodeNumber = 0;
+ GetNumaHighestNodeNumber(&NumaNodeNumber);
+ _itot(NumaNodeNumber, ret, 10);
+ return ret;
+ }
+#endif
return NULL;
}