File tree 1 file changed +10
-11
lines changed
1 file changed +10
-11
lines changed Original file line number Diff line number Diff line change 88
88
parser .add_option (
89
89
"--from" ,
90
90
dest = "from_spec" , # prevent name collision with the `from` keyword
91
- metavar = "[CURRENT_OWNER][:CURRENT_GROUP]" ,
91
+ metavar = "[CURRENT_OWNER][:[ CURRENT_GROUP] ]" ,
92
92
help = "only affect files with CURRENT_OWNER and CURRENT_GROUP"
93
93
" (either is optional and only checked if given)" ,
94
94
)
@@ -226,16 +226,6 @@ def chown(file: Path) -> None:
226
226
if opts .recursive :
227
227
228
228
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
-
239
229
for child in file .iterdir ():
240
230
if child .is_dir (follow_symlinks = opts .recurse_mode == "L" ):
241
231
traverse (child )
@@ -245,6 +235,15 @@ def traverse(file: Path) -> None:
245
235
if file .is_dir (
246
236
follow_symlinks = opts .recurse_mode == "H" or opts .recurse_mode == "L"
247
237
):
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
+
248
247
traverse (file )
249
248
else :
250
249
chown (file )
You can’t perform that action at this time.
0 commit comments