Skip to content

Commit d61ea02

Browse files
demerphqrjbs
authored andcommitted
t/op/glob.t - defend against ls with colors enabled
Disable any ENV vars with the word "color", "ls" or "cli" in them (case insensitively) before running ls. This appears to mostly be a BSD/darwin issue, but we do it on all platforms where we call ls in an abundance of caution. Fixes #21156.
1 parent b9d30b3 commit d61ea02

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

t/op/glob.t

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,16 @@ elsif ($^O eq 'VMS') {
1919
map { s/;.*$//; delete $files{lc($_)}; } split /[\n]/, `directory/noheading/notrailing/versions=1 [.op]`,
2020
}
2121
else {
22+
local %ENV = %ENV;
23+
# disable any env vars that might cause ls or dir to add colors or
24+
# otherwise modify the output.
25+
/COLOR|LS|CLI/i and delete $ENV{$_} for keys %ENV;
26+
2227
map { $files{$_}++ } <op/*>;
2328
map { delete $files{"op/$_"} } split /\n/, `ls op/ | cat`;
2429
}
25-
ok( !(keys(%files)),'leftover op/* files' ) or diag(join(' ',sort keys %files));
30+
ok( !(keys(%files)),'glob and directory listing agree' )
31+
or diag(join(' ',sort keys %files));
2632

2733
cmp_ok($/,'eq',"\n",'sane input record separator');
2834

0 commit comments

Comments
 (0)