File tree Expand file tree Collapse file tree 1 file changed +10
-11
lines changed Expand file tree Collapse file tree 1 file changed +10
-11
lines changed Original file line number Diff line number Diff line change 8888parser .add_option (
8989 "--from" ,
9090 dest = "from_spec" , # prevent name collision with the `from` keyword
91- metavar = "[CURRENT_OWNER][:CURRENT_GROUP]" ,
91+ metavar = "[CURRENT_OWNER][:[ CURRENT_GROUP] ]" ,
9292 help = "only affect files with CURRENT_OWNER and CURRENT_GROUP"
9393 " (either is optional and only checked if given)" ,
9494)
@@ -226,16 +226,6 @@ def chown(file: Path) -> None:
226226 if opts .recursive :
227227
228228 def traverse (file : Path ) -> None :
229- nonlocal failed
230-
231- if opts .preserve_root and file .root == str (file ):
232- print (
233- f"recursive operation on '{ file } ' prevented; use --no-preserve-root to override" ,
234- file = sys .stderr ,
235- )
236- failed = True
237- return
238-
239229 for child in file .iterdir ():
240230 if child .is_dir (follow_symlinks = opts .recurse_mode == "L" ):
241231 traverse (child )
@@ -245,6 +235,15 @@ def traverse(file: Path) -> None:
245235 if file .is_dir (
246236 follow_symlinks = opts .recurse_mode == "H" or opts .recurse_mode == "L"
247237 ):
238+ if opts .preserve_root and file .root == str (file ):
239+ failed = True
240+ print (
241+ f"recursive operation on '{ file } ' prevented;"
242+ " use --no-preserve-root to override" ,
243+ file = sys .stderr ,
244+ )
245+ continue
246+
248247 traverse (file )
249248 else :
250249 chown (file )
You can’t perform that action at this time.
0 commit comments