Skip to content

Commit

Permalink
Fixup rmtree on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
SylvainCorlay committed Nov 27, 2019
1 parent f5d5ca1 commit d546f18
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
5 changes: 5 additions & 0 deletions news/fixup-rmtree-windows.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
**Fixed:**

* Using rmtree on windows no longer attempts to use invalid ``rm`` command
and uses ``del`` instead.

16 changes: 7 additions & 9 deletions xonsh/lib/os.xsh
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,11 @@ def rmtree(dirname, force=False):
force : bool
If True force removal, defaults to False
"""
cmd_args = '-r'
if force:
cmd_args += 'f'
try:
if sys.platform == "win32":
cmd_args = '/S/Q'
![rmdir @(cmd_args) @(dirname)]
else:
cmd_args = '-r'
if force:
cmd_args += 'f'
![rm @(cmd_args) @(dirname)]
except PermissionError:
if sys.platform == "win32":
![del /F/S/Q @(dirname)]
else:
raise

0 comments on commit d546f18

Please sign in to comment.