diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c index 22f05805c92..a444330d80c 100644 --- a/programs/cmd/builtins.c +++ b/programs/cmd/builtins.c @@ -1410,10 +1410,8 @@ BOOL WCMD_delete (WCHAR *args) { argsProcessed = TRUE; found = WCMD_delete_one(thisArg); - if (!found) { - errorlevel = 1; + if (!found) WCMD_output_stderr(WCMD_LoadMessage(WCMD_FILENOTFOUND), thisArg); - } foundAny |= found; } diff --git a/programs/cmd/tests/test_builtins.cmd b/programs/cmd/tests/test_builtins.cmd index 0a8a4f47131..db286dbbffb 100644 --- a/programs/cmd/tests/test_builtins.cmd +++ b/programs/cmd/tests/test_builtins.cmd @@ -1493,6 +1493,28 @@ for /f "tokens=3,2,3*" %%i in ("a b c d e f g") do echo h=%%h i=%%i j=%%j k=%%k cd .. rd /s/q foobar +echo ------------ Testing del ------------ +echo abc > file +echo deleting 'file' +del file +if errorlevel 0 ( + echo errorlevel is 0, good +) else ( + echo unexpected errorlevel, got %errorlevel% +) +if not exist file ( + echo successfully deleted 'file' +) else ( + echo error deleting 'file' +) +echo attempting to delete 'file', even though it is not present +del file +if errorlevel 0 ( + echo errorlevel is 0, good +) else ( + echo unexpected errorlevel, got %errorlevel% +) + echo ------------ Testing del /a ------------ del /f/q *.test > nul echo r > r.test diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp index b2221588c3b..c2879d677a7 100644 --- a/programs/cmd/tests/test_builtins.cmd.exp +++ b/programs/cmd/tests/test_builtins.cmd.exp @@ -1009,6 +1009,12 @@ h=%h i=a j=b k=c l=d e f g m=%m n=%n o=%o@or_broken@h=%h i=a j=b k=c l=d e f g m h=%h i=a j=c k= l= m=%m n=%n o=%o@or_broken@h=%h i=a j=c k= l= m= n=%n o=%o h=%h i=b j=c k= l= m=%m n=%n o=%o@or_broken@h=%h i=b j=c k= l= m= n=%n o=%o h=%h i=b j=c k= l= m=%m n=%n o=%o@or_broken@h=%h i=b j=c k= l= m= n=%n o=%o +------------ Testing del ------------ +deleting 'file' +errorlevel is 0, good +successfully deleted 'file' +attempting to delete 'file', even though it is not present +errorlevel is 0, good ------------ Testing del /a ------------ not-r.test not found after delete, good r.test found before delete, good