Skip to content

Commit 6a1744c

Browse files
authored
join: fix crash for '(' delimiter (#1057)
* As per commit b345448 for cut(1) * The -t option expects a literal character to use as a delimiter for reading input files, but it was interpreted as a regex in split() * Apply the same \Q & \E fix in the match as * Small re-factor to avoid calling split() in both branches of ternary-operator
1 parent 9240f69 commit 6a1744c

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

bin/join

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,10 @@ sub get_a_line {
155155
my $not_eof = defined(my $line = <$fh>);
156156
if ($not_eof) {
157157
chomp $line;
158-
push (@$aref,
159-
defined $delimiter ?
160-
[split $delimiter, $line, -1] : [split ' ', $line, -1]);
158+
my $d = $delimiter;
159+
$d = ' ' unless defined $d;
160+
my @parts = split /\Q$d\E/, $line, -1;
161+
push @{ $aref }, [ @parts ];
161162
}
162163
else { push @$aref, undef }
163164
return $not_eof;

0 commit comments

Comments
 (0)