https://git.reactos.org/?p=reactos.git;a=commitdiff;h=9871becced0b05812b3c7…
commit 9871becced0b05812b3c750c2aa43fe4a20a2985
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Sun Jul 12 00:03:23 2020 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Wed Aug 19 20:36:08 2020 +0200
[CMD] It is not the job of ErrorMessage() to set the errorlevel! It is set only by the commands that want it.
---
base/shell/cmd/error.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/base/shell/cmd/error.c b/base/shell/cmd/error.c
index be422f33cf4..6995f188d89 100644
--- a/base/shell/cmd/error.c
+++ b/base/shell/cmd/error.c
@@ -36,8 +36,6 @@ ErrorMessage(
if (dwErrorCode == ERROR_SUCCESS)
return;
- nErrorLevel = 1;
-
*szMessage = 0;
if (szFormat)
{
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ae649656dbc174358cb87…
commit ae649656dbc174358cb87b1b1e63b9e72fc58f93
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Sat Jul 11 23:15:20 2020 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Wed Aug 19 20:36:07 2020 +0200
[CMD] RMDIR: Improve some aspects of the /S option.
- First, the option and the APIs called by it can work directly on
paths relative to the current directory. So there is no need to
call GetFullPathName(), with the risk of going over MAX_PATH if the
current path is quite long (or nested) but the RMDIR is called on a
(short-length) relative sub-directory.
- Append a path-separator (backslash), only if the specified directory
does not have one already, and, that it does not specify a current
directory via the "drive-root" method, e.g. "C:" without any trailing
backslash.
- In case there are errors during deletion of sub-directories or
sub-files, print the error but continue deleting the other sub-dirs
or files.
- Monitor the Ctrl-C breaker as well, and stop deleting if it has been
triggered.
- When removing file/directory read-only attribute, just remove this
attribute, but keep the other ones.
- When deleting the directory, first try to do it directly; if it fails
with access denied, check whether it was read-only, and if so, remove
this attribute and retry deletion, otherwise fails.
- When recursively deleting a drive root directory, ultimately resolve
the dir pattern and check whether it's indeed a drive root, e.g.
"C:\\", and if so, just return success. Indeed, calling
RemoveDirectory() on such drive roots will return ERROR_ACCESS_DENIED
otherwise, but we want to succeed even if, of course, we won't
actually "delete" the drive root.
---
base/shell/cmd/internal.c | 108 +++++++++++++++++++++++++++++++++-------------
1 file changed, 79 insertions(+), 29 deletions(-)
diff --git a/base/shell/cmd/internal.c b/base/shell/cmd/internal.c
index 3de6368583f..3f2c1b6b233 100644
--- a/base/shell/cmd/internal.c
+++ b/base/shell/cmd/internal.c
@@ -377,43 +377,68 @@ INT cmd_mkdir (LPTSTR param)
/*
* RD / RMDIR
*/
-BOOL DeleteFolder(LPTSTR FileName)
+BOOL DeleteFolder(LPTSTR Directory)
{
- TCHAR Base[MAX_PATH];
- TCHAR TempFileName[MAX_PATH];
+ LPTSTR pFileName;
HANDLE hFile;
WIN32_FIND_DATA f;
+ DWORD dwAttribs;
+ TCHAR szFullPath[MAX_PATH];
- _tcscpy(Base, FileName);
- _tcscat(Base, _T("\\*"));
-
- hFile = FindFirstFile(Base, &f);
- Base[_tcslen(Base) - 1] = _T('\0');
+ _tcscpy(szFullPath, Directory);
+ pFileName = &szFullPath[_tcslen(szFullPath)];
+ /*
+ * Append a path separator if we don't have one already, and if this a drive root
+ * path is not specified (paths like "C:" mean the current directory on drive C:).
+ */
+ if (*szFullPath && *(pFileName - 1) != _T(':') && *(pFileName - 1) != _T('\\'))
+ *pFileName++ = _T('\\');
+ _tcscpy(pFileName, _T("*"));
+
+ hFile = FindFirstFile(szFullPath, &f);
if (hFile != INVALID_HANDLE_VALUE)
{
do
{
+ /* Check Breaker */
+ if (bCtrlBreak)
+ break;
+
if (!_tcscmp(f.cFileName, _T(".")) ||
!_tcscmp(f.cFileName, _T("..")))
{
continue;
}
- _tcscpy(TempFileName, Base);
- _tcscat(TempFileName, f.cFileName);
+ _tcscpy(pFileName, f.cFileName);
- if (f.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+ dwAttribs = f.dwFileAttributes;
+
+ if (dwAttribs & FILE_ATTRIBUTE_DIRECTORY)
{
- DeleteFolder(TempFileName);
+ if (!DeleteFolder(szFullPath))
+ {
+ /* Couldn't delete the file, print out the error */
+ ErrorMessage(GetLastError(), szFullPath);
+
+ /* Continue deleting files/subfolders */
+ }
}
else
{
- /* Force file deletion */
- SetFileAttributes(TempFileName, FILE_ATTRIBUTE_NORMAL);
- if (!DeleteFile(TempFileName))
+ /* Force file deletion even if it's read-only */
+ if (dwAttribs & FILE_ATTRIBUTE_READONLY)
+ SetFileAttributes(szFullPath, dwAttribs & ~FILE_ATTRIBUTE_READONLY);
+
+ if (!DeleteFile(szFullPath))
{
- FindClose(hFile);
- return 0;
+ /* Couldn't delete the file, print out the error */
+ ErrorMessage(GetLastError(), szFullPath);
+
+ /* Restore file attributes */
+ SetFileAttributes(szFullPath, dwAttribs);
+
+ /* Continue deleting files/subfolders */
}
}
@@ -421,9 +446,42 @@ BOOL DeleteFolder(LPTSTR FileName)
FindClose(hFile);
}
- /* Force directory deletion even if it's read-only */
- SetFileAttributes(FileName, FILE_ATTRIBUTE_NORMAL);
- return RemoveDirectory(FileName);
+ /* Ignore directory deletion if the user pressed Ctrl-C */
+ if (bCtrlBreak)
+ return TRUE;
+
+ /*
+ * Detect whether we are trying to delete a pure root drive (e.g. "C:\\", but not "C:");
+ * if so, just return success. Otherwise the RemoveDirectory() call below would fail
+ * and return ERROR_ACCESS_DENIED.
+ */
+ if (GetFullPathName(Directory, ARRAYSIZE(szFullPath), szFullPath, NULL) == 3 &&
+ szFullPath[1] == _T(':') && szFullPath[2] == _T('\\'))
+ {
+ return TRUE;
+ }
+
+ /* First attempt to delete the directory */
+ if (RemoveDirectory(Directory))
+ return TRUE;
+
+ /*
+ * It failed; if it was due to an denied access, check whether it was
+ * due to the directory being read-only. If so, remove its attribute
+ * and retry deletion.
+ */
+ if (GetLastError() == ERROR_ACCESS_DENIED)
+ {
+ /* Force directory deletion even if it's read-only */
+ dwAttribs = GetFileAttributes(Directory);
+ if (dwAttribs & FILE_ATTRIBUTE_READONLY)
+ {
+ SetFileAttributes(Directory, dwAttribs & ~FILE_ATTRIBUTE_READONLY);
+ return RemoveDirectory(Directory);
+ }
+ }
+
+ return FALSE;
}
INT cmd_rmdir(LPTSTR param)
@@ -437,7 +495,6 @@ INT cmd_rmdir(LPTSTR param)
TCHAR ch;
BOOL bRecurseDir = FALSE;
BOOL bQuiet = FALSE;
- TCHAR szFullPath[MAX_PATH];
if (!_tcsncmp(param, _T("/?"), 2))
{
@@ -498,14 +555,7 @@ INT cmd_rmdir(LPTSTR param)
bQuiet = TRUE;
}
- /* Get the folder name */
- GetFullPathName(arg[i], ARRAYSIZE(szFullPath), szFullPath, NULL);
-
- /* Remove trailing \ if any, but ONLY if dir is not the root dir */
- if (_tcslen(szFullPath) >= 2 && szFullPath[_tcslen(szFullPath) - 1] == _T('\\'))
- szFullPath[_tcslen(szFullPath) - 1] = _T('\0');
-
- res = DeleteFolder(szFullPath);
+ res = DeleteFolder(arg[i]);
}
else
{
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7c175d4999fb66d86111e…
commit 7c175d4999fb66d86111e45d694f934d2735a61f
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Sun Jul 5 23:39:06 2020 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Wed Aug 19 20:36:06 2020 +0200
[CMD] PATH, SET: Fix the returned error message when an environment variable does not exist.
Translators, please update the translations!
---
base/shell/cmd/lang/cs-CZ.rc | 2 +-
base/shell/cmd/lang/de-DE.rc | 2 +-
base/shell/cmd/lang/el-GR.rc | 2 +-
base/shell/cmd/lang/en-US.rc | 2 +-
base/shell/cmd/lang/es-ES.rc | 2 +-
base/shell/cmd/lang/fr-FR.rc | 2 +-
base/shell/cmd/lang/hu-HU.rc | 2 +-
base/shell/cmd/lang/id-ID.rc | 2 +-
base/shell/cmd/lang/it-IT.rc | 2 +-
base/shell/cmd/lang/ja-JP.rc | 2 +-
base/shell/cmd/lang/no-NO.rc | 2 +-
base/shell/cmd/lang/pl-PL.rc | 2 +-
base/shell/cmd/lang/ro-RO.rc | 2 +-
base/shell/cmd/lang/ru-RU.rc | 2 +-
base/shell/cmd/lang/sk-SK.rc | 2 +-
base/shell/cmd/lang/sq-AL.rc | 2 +-
base/shell/cmd/lang/sv-SE.rc | 2 +-
base/shell/cmd/lang/tr-TR.rc | 2 +-
base/shell/cmd/lang/uk-UA.rc | 2 +-
base/shell/cmd/lang/zh-CN.rc | 2 +-
base/shell/cmd/lang/zh-TW.rc | 2 +-
base/shell/cmd/path.c | 2 +-
base/shell/cmd/resource.h | 2 +-
base/shell/cmd/set.c | 2 +-
24 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/base/shell/cmd/lang/cs-CZ.rc b/base/shell/cmd/lang/cs-CZ.rc
index 3499a2641a9..0f788899104 100644
--- a/base/shell/cmd/lang/cs-CZ.rc
+++ b/base/shell/cmd/lang/cs-CZ.rc
@@ -523,7 +523,7 @@ title new title\n"
STRING_ERROR_CANNOTPIPE "Chyba! Nelze vytvořit rouru! Nelze vytvořit dočasný soubor!\n"
STRING_ERROR_D_PAUSEMSG "Pokračujte stisknutím libovolné klávesy . . . "
STRING_ERROR_DRIVER_NOT_READY "Jednotka není připravena"
- STRING_PATH_ERROR "CMD: Ne v prostředí '%s'\n"
+ STRING_SET_ENV_ERROR "Environment variable '%s' is not defined\n"
STRING_REPLACE_ERROR1 "Neplatný přepínač - %s\n"
STRING_REPLACE_ERROR2 "Cesta nenalezena - %s\n"
STRING_REPLACE_ERROR3 "Název souboru, adresáře nebo popisek svazku je neplatný.\n"
diff --git a/base/shell/cmd/lang/de-DE.rc b/base/shell/cmd/lang/de-DE.rc
index 94cb49924e3..e9afa7eefb3 100644
--- a/base/shell/cmd/lang/de-DE.rc
+++ b/base/shell/cmd/lang/de-DE.rc
@@ -519,7 +519,7 @@ Titel neuer Titel"
STRING_ERROR_CANNOTPIPE "Fehler: Pipen nicht möglich! Temporäre Datei kann nicht geöffnet werden!\n"
STRING_ERROR_D_PAUSEMSG "Drücken Sie eine beliebige Taste . . . "
STRING_ERROR_DRIVER_NOT_READY "Laufwerk ist nicht bereit"
- STRING_PATH_ERROR "CMD: Nicht in Umgebung '%s'\n"
+ STRING_SET_ENV_ERROR "Environment variable '%s' is not defined\n"
STRING_REPLACE_ERROR1 "Ungültiger Parameter - %s\n"
STRING_REPLACE_ERROR2 "Pfad wurde nicht gefunden - %s\n"
STRING_REPLACE_ERROR3 "Der Dateiname, Ordnername oder die Syntax der Volumenbezeichung sind inkorrekt.\n"
diff --git a/base/shell/cmd/lang/el-GR.rc b/base/shell/cmd/lang/el-GR.rc
index 10a48f409e1..1714f763af1 100644
--- a/base/shell/cmd/lang/el-GR.rc
+++ b/base/shell/cmd/lang/el-GR.rc
@@ -522,7 +522,7 @@ title new title\n"
STRING_ERROR_CANNOTPIPE "Σφάλμα! Cannot pipe! Cannot open temporary file!\n"
STRING_ERROR_D_PAUSEMSG "Πατήστε οποιοδήποτε πλήκτρο για συνέχεια . . . "
STRING_ERROR_DRIVER_NOT_READY "Ο δίσκος δεν είναι έτοιμος"
- STRING_PATH_ERROR "CMD: Not in environment '%s'\n"
+ STRING_SET_ENV_ERROR "Environment variable '%s' is not defined\n"
STRING_REPLACE_ERROR1 "Invalid switch - %s\n"
STRING_REPLACE_ERROR2 "Δε βρέθηκε το μονοπάτι - %s\n"
STRING_REPLACE_ERROR3 "The filename, directory name, or volume label syntax is incorrect.\n"
diff --git a/base/shell/cmd/lang/en-US.rc b/base/shell/cmd/lang/en-US.rc
index e5d0ea5056a..2286203a633 100644
--- a/base/shell/cmd/lang/en-US.rc
+++ b/base/shell/cmd/lang/en-US.rc
@@ -518,7 +518,7 @@ title new title\n"
STRING_ERROR_CANNOTPIPE "Error! Cannot pipe! Cannot open temporary file!\n"
STRING_ERROR_D_PAUSEMSG "Press any key to continue . . . "
STRING_ERROR_DRIVER_NOT_READY "Drive not ready"
- STRING_PATH_ERROR "CMD: Not in environment '%s'\n"
+ STRING_SET_ENV_ERROR "Environment variable '%s' is not defined\n"
STRING_REPLACE_ERROR1 "Invalid switch - %s\n"
STRING_REPLACE_ERROR2 "Path not found - %s\n"
STRING_REPLACE_ERROR3 "The filename, directory name, or volume label syntax is incorrect.\n"
diff --git a/base/shell/cmd/lang/es-ES.rc b/base/shell/cmd/lang/es-ES.rc
index 786b5f7e974..cf18bec6044 100644
--- a/base/shell/cmd/lang/es-ES.rc
+++ b/base/shell/cmd/lang/es-ES.rc
@@ -524,7 +524,7 @@ title Nuevo título\n"
STRING_ERROR_CANNOTPIPE "¡Error! ¡No se puede apilar! ¡No se puede abrir el archivo temporal!\n"
STRING_ERROR_D_PAUSEMSG "Pulse una tecla para continuar ... "
STRING_ERROR_DRIVER_NOT_READY "La unidad no está lista"
- STRING_PATH_ERROR "CMD: No está en el entorno '%s'\n"
+ STRING_SET_ENV_ERROR "Environment variable '%s' is not defined\n"
STRING_REPLACE_ERROR1 "Argumento no válido - %s\n"
STRING_REPLACE_ERROR2 "Ruta no encontrada - %s\n"
STRING_REPLACE_ERROR3 "La sintaxis del nombre de archivo, carpeta o volúmen es incorrecta.\n"
diff --git a/base/shell/cmd/lang/fr-FR.rc b/base/shell/cmd/lang/fr-FR.rc
index 7a681fdf5b3..92a32cf1fa2 100644
--- a/base/shell/cmd/lang/fr-FR.rc
+++ b/base/shell/cmd/lang/fr-FR.rc
@@ -534,7 +534,7 @@ titre titre de la fenêtre"
STRING_ERROR_CANNOTPIPE "Erreur ! Impossible de chaîner ! Échec à l'ouverture du fichier temporaire!\n"
STRING_ERROR_D_PAUSEMSG "Appuyez sur une touche pour continuer . . . "
STRING_ERROR_DRIVER_NOT_READY "Lecteur non prêt"
- STRING_PATH_ERROR "CMD : Pas dans l'environnement '%s'\n"
+ STRING_SET_ENV_ERROR "Variable d'environnement '%s' non définie\n"
STRING_REPLACE_ERROR1 "Commutateur invalide - %s\n"
STRING_REPLACE_ERROR2 "Chemin introuvable - %s\n"
STRING_REPLACE_ERROR3 "La syntaxe du nom de fichier, du répertoire, ou du nom de volume est incorrecte.\n"
diff --git a/base/shell/cmd/lang/hu-HU.rc b/base/shell/cmd/lang/hu-HU.rc
index d73faa7c2cc..003cf0d6c96 100644
--- a/base/shell/cmd/lang/hu-HU.rc
+++ b/base/shell/cmd/lang/hu-HU.rc
@@ -503,7 +503,7 @@ title new title\n"
STRING_ERROR_CANNOTPIPE "Error! Cannot pipe! Cannot open temporary állomány!\n"
STRING_ERROR_D_PAUSEMSG "A folytatáshoz nyomj meg egy billentyût . . . "
STRING_ERROR_DRIVER_NOT_READY "A meghajtó nem áll készen"
- STRING_PATH_ERROR "CMD: Not in environment '%s'\n"
+ STRING_SET_ENV_ERROR "Environment variable '%s' is not defined\n"
STRING_REPLACE_ERROR1 "Invalid switch - %s\n"
STRING_REPLACE_ERROR2 "Path not found - %s\n"
STRING_REPLACE_ERROR3 "The filename, directory name, or volume label syntax is incorrect.\n"
diff --git a/base/shell/cmd/lang/id-ID.rc b/base/shell/cmd/lang/id-ID.rc
index 2f7ce290d59..befdb9a16a2 100644
--- a/base/shell/cmd/lang/id-ID.rc
+++ b/base/shell/cmd/lang/id-ID.rc
@@ -517,7 +517,7 @@ title judul baru\n"
STRING_ERROR_CANNOTPIPE "Salah! Tidak bisa melakukan pipe! Tidak bisa membuka file temporal!\n"
STRING_ERROR_D_PAUSEMSG "Tekan tombol untuk melanjutkan . . . "
STRING_ERROR_DRIVER_NOT_READY "Drive tidak siap"
- STRING_PATH_ERROR "CMD: Tidak dalam lingkungan '%s'\n"
+ STRING_SET_ENV_ERROR "Environment variable '%s' is not defined\n"
STRING_REPLACE_ERROR1 "Invalid switch - %s\n"
STRING_REPLACE_ERROR2 "Path not found - %s\n"
STRING_REPLACE_ERROR3 "The filename, directory name, or volume label syntax is incorrect.\n"
diff --git a/base/shell/cmd/lang/it-IT.rc b/base/shell/cmd/lang/it-IT.rc
index e3485640449..e02ad50cbd0 100644
--- a/base/shell/cmd/lang/it-IT.rc
+++ b/base/shell/cmd/lang/it-IT.rc
@@ -527,7 +527,7 @@ titolo il nuovo titolo\n"
STRING_ERROR_CANNOTPIPE "Errore! Impossibile ridirigere! Impossibile aprire un file temporaneo!\n"
STRING_ERROR_D_PAUSEMSG "Premi un tasto per continuare . . . "
STRING_ERROR_DRIVER_NOT_READY "Disco non pronto"
- STRING_PATH_ERROR "CMD: Non nell'ambiente '%s'\n"
+ STRING_SET_ENV_ERROR "Environment variable '%s' is not defined\n"
STRING_REPLACE_ERROR1 "Parametro non valido - %s\n"
STRING_REPLACE_ERROR2 "Percorso non trovato - %s\n"
STRING_REPLACE_ERROR3 "Il nome del file, della cartella o della etichetta di volume è errato.\n"
diff --git a/base/shell/cmd/lang/ja-JP.rc b/base/shell/cmd/lang/ja-JP.rc
index a0581742431..3bd1a7ea396 100644
--- a/base/shell/cmd/lang/ja-JP.rc
+++ b/base/shell/cmd/lang/ja-JP.rc
@@ -525,7 +525,7 @@ RESTORE ウィンドウを元のサイズに戻します。\n\
STRING_ERROR_CANNOTPIPE "エラー! パイプできません! 一時ファイルを開けません!\n"
STRING_ERROR_D_PAUSEMSG "続行するには何かキーを押してください . . . "
STRING_ERROR_DRIVER_NOT_READY "ドライブの準備ができていません。"
- STRING_PATH_ERROR "CMD: Not in environment '%s'\n"
+ STRING_SET_ENV_ERROR "Environment variable '%s' is not defined\n"
STRING_REPLACE_ERROR1 "Invalid switch - %s\n"
STRING_REPLACE_ERROR2 "Path not found - %s\n"
STRING_REPLACE_ERROR3 "The filename, directory name, or volume label syntax is incorrect.\n"
diff --git a/base/shell/cmd/lang/no-NO.rc b/base/shell/cmd/lang/no-NO.rc
index 7cb1bb65431..c8577d88c55 100644
--- a/base/shell/cmd/lang/no-NO.rc
+++ b/base/shell/cmd/lang/no-NO.rc
@@ -516,7 +516,7 @@ tittel ny tittel\n"
STRING_ERROR_CANNOTPIPE "Feil! Kan ikke bruke datakanal! Kan ikke åpne midlertidig fil!\n"
STRING_ERROR_D_PAUSEMSG "Trykk en tast for å fortsette . . . "
STRING_ERROR_DRIVER_NOT_READY "Stasjonen er ikke klar"
- STRING_PATH_ERROR "CMD: Ikke i miljøet '%s'\n"
+ STRING_SET_ENV_ERROR "Environment variable '%s' is not defined\n"
STRING_REPLACE_ERROR1 "Invalid switch - %s\n"
STRING_REPLACE_ERROR2 "Mappen ble ikke funnet - %s\n"
STRING_REPLACE_ERROR3 "The filename, directory name, or volume label syntax is incorrect.\n"
diff --git a/base/shell/cmd/lang/pl-PL.rc b/base/shell/cmd/lang/pl-PL.rc
index 49d89386170..626696c546b 100644
--- a/base/shell/cmd/lang/pl-PL.rc
+++ b/base/shell/cmd/lang/pl-PL.rc
@@ -523,7 +523,7 @@ title nowy tytuł okna\n"
STRING_ERROR_CANNOTPIPE "Błąd potoków! Nie można otworzyć pliku tymczasowego.\n"
STRING_ERROR_D_PAUSEMSG "Naciśnij dowolny klawisz, aby kontynuować . . . "
STRING_ERROR_DRIVER_NOT_READY "Napęd nie jest gotowy"
- STRING_PATH_ERROR "CMD: Poza środowiskiem '%s'\n"
+ STRING_SET_ENV_ERROR "Environment variable '%s' is not defined\n"
STRING_REPLACE_ERROR1 "Nieprawidłowy parametr - %s\n"
STRING_REPLACE_ERROR2 "Ścieżka nie została odnaleziona - %s\n"
STRING_REPLACE_ERROR3 "Nazwa pliku, katalogu lub napędu nie jest prawidłowa.\n"
diff --git a/base/shell/cmd/lang/ro-RO.rc b/base/shell/cmd/lang/ro-RO.rc
index a9349427dc8..2013f65d8d8 100644
--- a/base/shell/cmd/lang/ro-RO.rc
+++ b/base/shell/cmd/lang/ro-RO.rc
@@ -551,7 +551,7 @@ titlu Noul titlu.\n"
STRING_ERROR_CANNOTPIPE "Eroare! Nu datele nu pot fi canalizate! Nu fișierul temporar nu a putut fi deschis!\n"
STRING_ERROR_D_PAUSEMSG "Tastați pentru a continua... "
STRING_ERROR_DRIVER_NOT_READY "Unitatea de stocare nu e utilizabilă"
- STRING_PATH_ERROR "CMD: «%s» inexistentă în mediu\n"
+ STRING_SET_ENV_ERROR "Environment variable '%s' is not defined\n"
STRING_REPLACE_ERROR1 "Argument eronat - %s\n"
STRING_REPLACE_ERROR2 "Calea nu este găsită - %s\n"
STRING_REPLACE_ERROR3 "Numele fișierului, directorului sau eticheta volumului este incorectă.\n"
diff --git a/base/shell/cmd/lang/ru-RU.rc b/base/shell/cmd/lang/ru-RU.rc
index 64c217e547d..554b7e028ef 100644
--- a/base/shell/cmd/lang/ru-RU.rc
+++ b/base/shell/cmd/lang/ru-RU.rc
@@ -528,7 +528,7 @@ RESTORE восстанавливает окно\n\
STRING_ERROR_CANNOTPIPE "Ошибка! Невозможно использовать pipe! Невозможно создать временный файл!\n"
STRING_ERROR_D_PAUSEMSG "Для продолжения нажмите любую клавишу . . . "
STRING_ERROR_DRIVER_NOT_READY "Устройство не готово"
- STRING_PATH_ERROR "CMD: Не в среде окружения '%s'\n"
+ STRING_SET_ENV_ERROR "Environment variable '%s' is not defined\n"
STRING_REPLACE_ERROR1 "Неверный ключ - %s\n"
STRING_REPLACE_ERROR2 "Путь не найден - %s\n"
STRING_REPLACE_ERROR3 "Имя файла, папки или метка диска неверная.\n"
diff --git a/base/shell/cmd/lang/sk-SK.rc b/base/shell/cmd/lang/sk-SK.rc
index 3bb33e7c01a..c0a5673bd44 100644
--- a/base/shell/cmd/lang/sk-SK.rc
+++ b/base/shell/cmd/lang/sk-SK.rc
@@ -524,7 +524,7 @@ title new title\n"
STRING_ERROR_CANNOTPIPE "Chyba! Cannot pipe! Cannot open temporary file!\n"
STRING_ERROR_D_PAUSEMSG "Pokračujte stlačením ľubovoľného klávesu ... "
STRING_ERROR_DRIVER_NOT_READY "Jednotka nie je pripravená"
- STRING_PATH_ERROR "CMD: Not in environment '%s'\n"
+ STRING_SET_ENV_ERROR "Environment variable '%s' is not defined\n"
STRING_REPLACE_ERROR1 "Neplatný prepínač - %s\n"
STRING_REPLACE_ERROR2 "Cesta sa nenašla - %s\n"
STRING_REPLACE_ERROR3 "The filename, directory name, or volume label syntax is incorrect.\n"
diff --git a/base/shell/cmd/lang/sq-AL.rc b/base/shell/cmd/lang/sq-AL.rc
index f31217025f0..42e2d5736f5 100644
--- a/base/shell/cmd/lang/sq-AL.rc
+++ b/base/shell/cmd/lang/sq-AL.rc
@@ -522,7 +522,7 @@ title titull i ri\n"
STRING_ERROR_CANNOTPIPE "Error! Nuk mund të pipoj! Nuk mund të hape dokumentet e perkohshem!\n"
STRING_ERROR_D_PAUSEMSG "Shtypni një buton për të vazhduar . . . "
STRING_ERROR_DRIVER_NOT_READY "Drive nuk është gati"
- STRING_PATH_ERROR "CMD: Jo në mjedis '%s'\n"
+ STRING_SET_ENV_ERROR "Environment variable '%s' is not defined\n"
STRING_REPLACE_ERROR1 "Qeles invalid - %s\n"
STRING_REPLACE_ERROR2 "Rruga nuk u gjet - %s\n"
STRING_REPLACE_ERROR3 "Dokumenti, emri i direktorise, ose syntaksi i etiketes volumetrike eshte gabim.\n"
diff --git a/base/shell/cmd/lang/sv-SE.rc b/base/shell/cmd/lang/sv-SE.rc
index 41c5131f015..b9d857299f5 100644
--- a/base/shell/cmd/lang/sv-SE.rc
+++ b/base/shell/cmd/lang/sv-SE.rc
@@ -516,7 +516,7 @@ tittel ny tittel\n"
STRING_ERROR_CANNOTPIPE "Fel! Kan inte bruke datakanal! Kan inte åpne midlertidig fil!\n"
STRING_ERROR_D_PAUSEMSG "Tryck på valfri tangent för att fortsätta . . . "
STRING_ERROR_DRIVER_NOT_READY "enheten är inte klar"
- STRING_PATH_ERROR "CMD: Inte i miljön '%s'\n"
+ STRING_SET_ENV_ERROR "Environment variable '%s' is not defined\n"
STRING_REPLACE_ERROR1 "Felaktig växel - %s\n"
STRING_REPLACE_ERROR2 "Mappen ble inte funnet - %s\n"
STRING_REPLACE_ERROR3 "The filename, directory name, or volume label syntax is incorrect.\n"
diff --git a/base/shell/cmd/lang/tr-TR.rc b/base/shell/cmd/lang/tr-TR.rc
index 44810d8fef2..326bc16e907 100644
--- a/base/shell/cmd/lang/tr-TR.rc
+++ b/base/shell/cmd/lang/tr-TR.rc
@@ -523,7 +523,7 @@ başlık Yeni başlık\n"
STRING_ERROR_CANNOTPIPE "Yanlışlık! Borulanamıyor! Geçici kütük açılamıyor!\n"
STRING_ERROR_D_PAUSEMSG "Sürdürmek için bir düğmeye basınız . . . "
STRING_ERROR_DRIVER_NOT_READY "Sürücü anık değil."
- STRING_PATH_ERROR "CMD: ""%s"" ortamda yok.\n"
+ STRING_SET_ENV_ERROR "Environment variable '%s' is not defined\n"
STRING_REPLACE_ERROR1 "Geçersiz seçenek - %s\n"
STRING_REPLACE_ERROR2 "Yol bulunamadı - %s\n"
STRING_REPLACE_ERROR3 "Kütük adı, dizin adı ya da birim etiketi yazımı yanlış.\n"
diff --git a/base/shell/cmd/lang/uk-UA.rc b/base/shell/cmd/lang/uk-UA.rc
index 2b6a6e85348..4b34f727177 100644
--- a/base/shell/cmd/lang/uk-UA.rc
+++ b/base/shell/cmd/lang/uk-UA.rc
@@ -528,7 +528,7 @@ title новий заголовок\n"
STRING_ERROR_CANNOTPIPE "Помилка! Неможливо використати pipe! Неможливо вiдкрити тимчасовий файл!\n"
STRING_ERROR_D_PAUSEMSG "Натиснiть будь-яку клавiшу для продовження . . . "
STRING_ERROR_DRIVER_NOT_READY "Пристрій не готовий"
- STRING_PATH_ERROR "CMD: Не в середовищi '%s'\n"
+ STRING_SET_ENV_ERROR "Environment variable '%s' is not defined\n"
STRING_REPLACE_ERROR1 "Невiрний ключ - %s\n"
STRING_REPLACE_ERROR2 "Шлях не знайдено - %s\n"
STRING_REPLACE_ERROR3 "Синтаксис iменi файлу, теки чи мiтки диску некоректнi.\n"
diff --git a/base/shell/cmd/lang/zh-CN.rc b/base/shell/cmd/lang/zh-CN.rc
index 724459ca8f4..7562413928b 100644
--- a/base/shell/cmd/lang/zh-CN.rc
+++ b/base/shell/cmd/lang/zh-CN.rc
@@ -488,7 +488,7 @@ RESTORE 恢复窗口\n\
STRING_ERROR_CANNOTPIPE "错误!无法创建管道!不能打开临时文件!\n"
STRING_ERROR_D_PAUSEMSG "按任意键继续... "
STRING_ERROR_DRIVER_NOT_READY "驱动器未就绪"
- STRING_PATH_ERROR "CMD: 不在环境 '%s' 中\n"
+ STRING_SET_ENV_ERROR "Environment variable '%s' is not defined\n"
STRING_REPLACE_ERROR1 "无效开关 - %s\n"
STRING_REPLACE_ERROR2 "路径未找到 - %s\n"
STRING_REPLACE_ERROR3 "文件名、目录名或卷标语法不正确。\n"
diff --git a/base/shell/cmd/lang/zh-TW.rc b/base/shell/cmd/lang/zh-TW.rc
index d4e37356d5b..4d59c824948 100644
--- a/base/shell/cmd/lang/zh-TW.rc
+++ b/base/shell/cmd/lang/zh-TW.rc
@@ -489,7 +489,7 @@ RESTORE 恢復視窗\n\
STRING_ERROR_CANNOTPIPE "錯誤!無法創建管道!不能開啟臨時檔案!\n"
STRING_ERROR_D_PAUSEMSG "按任意鍵繼續... "
STRING_ERROR_DRIVER_NOT_READY "驅動器未就緒"
- STRING_PATH_ERROR "CMD: 不在環境 '%s' 中\n"
+ STRING_SET_ENV_ERROR "Environment variable '%s' is not defined\n"
STRING_REPLACE_ERROR1 "無效開關 - %s\n"
STRING_REPLACE_ERROR2 "路徑未找到 - %s\n"
STRING_REPLACE_ERROR3 "檔名、目錄名或卷標語法不正確。\n"
diff --git a/base/shell/cmd/path.c b/base/shell/cmd/path.c
index c00851dae40..1faed8ea29c 100644
--- a/base/shell/cmd/path.c
+++ b/base/shell/cmd/path.c
@@ -60,7 +60,7 @@ INT cmd_path (LPTSTR param)
if (dwBuffer == 0)
{
cmd_free(pszBuffer);
- ConOutResPrintf(STRING_VOL_HELP2, _T("PATH"));
+ ConErrResPrintf(STRING_SET_ENV_ERROR, _T("PATH"));
return 0;
}
else if (dwBuffer > ENV_BUFFER_SIZE)
diff --git a/base/shell/cmd/resource.h b/base/shell/cmd/resource.h
index 933d5677408..7836cfb96b8 100644
--- a/base/shell/cmd/resource.h
+++ b/base/shell/cmd/resource.h
@@ -52,7 +52,7 @@
#define STRING_GOTO_ERROR2 341
#define STRING_MOVE_ERROR1 342
#define STRING_MOVE_ERROR2 343
-#define STRING_PATH_ERROR 345
+#define STRING_SET_ENV_ERROR 345
#define STRING_REN_ERROR1 346
#define STRING_TIME_ERROR1 348
#define STRING_TYPE_ERROR1 349
diff --git a/base/shell/cmd/set.c b/base/shell/cmd/set.c
index 7a4a5d4c408..f63de691a2f 100644
--- a/base/shell/cmd/set.c
+++ b/base/shell/cmd/set.c
@@ -197,7 +197,7 @@ INT cmd_set(LPTSTR param)
if (!bFound)
{
- ConErrResPrintf(STRING_PATH_ERROR, param);
+ ConErrResPrintf(STRING_SET_ENV_ERROR, param);
nErrorLevel = 1;
return 1;
}
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=6e09a6a3ffd92c565e206…
commit 6e09a6a3ffd92c565e20664a023add74eaa55ecf
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Wed Jul 1 02:42:04 2020 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Wed Aug 19 20:36:05 2020 +0200
[CMD] Use kernel32!lstrcmp(i) when comparing strings with the IF command.
Use kernel32!lstrcmp(i) instead of CRT!_tcs(i)cmp, so as to use the correct
current thread locale information when comparing user-specific strings.
As a result, the following comparison: 'b LSS B' will return TRUE,
instead of FALSE as it would be by using the CRT functions (and by
naively considering the lexicographical order in ANSI).
This behaviour has been introduced in Windows 2000 onwards.
---
base/shell/cmd/if.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/base/shell/cmd/if.c b/base/shell/cmd/if.c
index 830ec459c8a..c7882ad2fec 100644
--- a/base/shell/cmd/if.c
+++ b/base/shell/cmd/if.c
@@ -32,7 +32,7 @@
#include "precomp.h"
-static INT GenericCmp(INT (*StringCmp)(LPCTSTR, LPCTSTR),
+static INT GenericCmp(INT (WINAPI *StringCmp)(LPCTSTR, LPCTSTR),
LPCTSTR Left, LPCTSTR Right)
{
TCHAR *end;
@@ -152,14 +152,20 @@ INT ExecuteIf(PARSED_COMMAND *Cmd)
}
else
{
- /* Do case-insensitive string comparisons if /I specified */
- INT (*StringCmp)(LPCTSTR, LPCTSTR) =
- (Cmd->If.Flags & IFFLAG_IGNORECASE) ? _tcsicmp : _tcscmp;
+ /*
+ * Do case-insensitive string comparisons if /I specified.
+ *
+ * Since both strings are user-specific, use kernel32!lstrcmp(i)
+ * instead of CRT!_tcs(i)cmp, so as to use the correct
+ * current thread locale information.
+ */
+ INT (WINAPI *StringCmp)(LPCTSTR, LPCTSTR) =
+ (Cmd->If.Flags & IFFLAG_IGNORECASE) ? lstrcmpi : lstrcmp;
if (Cmd->If.Operator == IF_STRINGEQ)
{
/* IF str1 == str2 */
- result = StringCmp(Left, Right) == 0;
+ result = (StringCmp(Left, Right) == 0);
}
else
{
@@ -168,9 +174,9 @@ INT ExecuteIf(PARSED_COMMAND *Cmd)
{
case IF_EQU: result = (result == 0); break;
case IF_NEQ: result = (result != 0); break;
- case IF_LSS: result = (result < 0); break;
+ case IF_LSS: result = (result < 0); break;
case IF_LEQ: result = (result <= 0); break;
- case IF_GTR: result = (result > 0); break;
+ case IF_GTR: result = (result > 0); break;
case IF_GEQ: result = (result >= 0); break;
}
}