From 7ee590086aabe26fdca5a65a0b2d29fb521d6367 Mon Sep 17 00:00:00 2001 From: Magnus Olsen Date: Wed, 6 Jul 2005 20:15:36 +0000 Subject: [PATCH] set right errorlevel for cd / chdir, left to do we do not have /d param that are new in win2k maby in older windows also svn path=/trunk/; revision=16463 --- reactos/subsys/system/cmd/internal.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/reactos/subsys/system/cmd/internal.c b/reactos/subsys/system/cmd/internal.c index cc3f0290231..1ebeed745b7 100644 --- a/reactos/subsys/system/cmd/internal.c +++ b/reactos/subsys/system/cmd/internal.c @@ -172,6 +172,8 @@ INT cmd_chdir (LPTSTR cmd, LPTSTR param) return 0; } + nErrorLevel = 0; + /* The whole param string is our parameter these days. The only thing we do is eliminating every quotation mark */ /* Is it safe to change the characters param is pointing to? I presume it is, as there doesn't seem to be any post-processing of it after the function call (what would that accomplish?) */ @@ -258,13 +260,14 @@ INT cmd_chdir (LPTSTR cmd, LPTSTR param) { hSearch = FindFirstFile(dir, &FileData); - if (hSearch == INVALID_HANDLE_VALUE) - { + if (hSearch == INVALID_HANDLE_VALUE) + { ConOutFormatMessage(GetLastError()); - free (lpOldPath); - lpOldPath = NULL; - return 1; - } + free (lpOldPath); + lpOldPath = NULL; + nErrorLevel = 1; + return 1; + } while (!fFinished) @@ -282,6 +285,7 @@ INT cmd_chdir (LPTSTR cmd, LPTSTR param) ConOutFormatMessage(GetLastError()); free (lpOldPath); lpOldPath = NULL; + nErrorLevel = 1; return 1; } @@ -293,6 +297,7 @@ INT cmd_chdir (LPTSTR cmd, LPTSTR param) { FindClose(hSearch); ConOutFormatMessage(GetLastError()); + nErrorLevel = 1; free (lpOldPath); lpOldPath = NULL; return 1; @@ -301,6 +306,7 @@ INT cmd_chdir (LPTSTR cmd, LPTSTR param) //ErrorMessage (GetLastError(), _T("CD")); ConOutFormatMessage(GetLastError()); + nErrorLevel = 1; /* throw away current directory */ free (lpOldPath);