Fix copy for implicit relative paths (#35016)

copy currently fails if you specify a destination without any directory
component.  This is because we take the dirname of the destination for
some processing and no dirname causes issues.

This corrects that by prepending "./" if there is no directory component
in dest.
This commit is contained in:
Toshio Kuratomi 2018-02-08 00:12:32 -08:00 committed by GitHub
commit 8a22b51755
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 58 additions and 0 deletions

View file

@ -218,6 +218,7 @@ state:
'''
import os
import os.path
import shutil
import tempfile
import traceback
@ -279,6 +280,9 @@ def main():
src = module.params['src']
b_src = to_bytes(src, errors='surrogate_or_strict')
dest = module.params['dest']
# Make sure we always have a directory component for later processing
if os.path.sep not in dest:
dest = '.{0}{1}'.format(os.path.sep, dest)
b_dest = to_bytes(dest, errors='surrogate_or_strict')
backup = module.params['backup']
force = module.params['force']