diff options
author | Nobuyoshi Nakada <[email protected]> | 2024-12-31 14:53:07 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2024-12-31 14:53:07 +0900 |
commit | 3cd809deb5cc3a534151078166148b9ff5e1c8ef (patch) | |
tree | 4fb39a536c17f37368575542bab12a3e650ff8ad /win32/rm.bat | |
parent | 5fec9308320e8b377681ef19b0cd46d53f94e8ac (diff) |
Win32: Fix rm.bat
- `if exist` and `del` ignore directories matching the wildcard,
remove both separately.
- `rd /s` ignores wildcards, while `del` removes ordinary files by the
wildcard, iterate over matching directories by `for /D`.
Diffstat (limited to 'win32/rm.bat')
-rwxr-xr-x | win32/rm.bat | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/win32/rm.bat b/win32/rm.bat index 7f0336c202..fefc030545 100755 --- a/win32/rm.bat +++ b/win32/rm.bat @@ -4,12 +4,15 @@ set recursive= :optloop
if "%1" == "-f" shift
if "%1" == "-r" (shift & set "recursive=1" & goto :optloop)
+if "%1" == "--debug" (shift & set PROMPT=$E[34m+$E[m$S & echo on & goto :optloop)
:begin
if "%1" == "" goto :end
set p=%1
-if exist "%p:/=\%" for %%I in ("%p:/=\%") do (
- del /q "%%I" || if "%recursive%" == "1" rd /s /q "%%I"
-) 2> nul
+set p=%p:/=\%
+if exist "%p%" del /q "%p%" > nul
+if "%recursive%" == "1" for /D %%I in (%p%) do (
+ rd /s /q %%I
+)
shift
goto :begin
:end
|