diff options
author | Richard Levitte <levitte@openssl.org> | 2016-02-11 23:47:30 +0300 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2016-02-12 00:11:48 +0300 |
commit | 9ba96fbb2523cb12747c559c704c58bd8f9e7982 (patch) | |
tree | c93cfeeea0efd2e65b513c1fd8caf7acaf259a7c /apps/CA.pl.in | |
parent | c15e95a61dacfc326cf9cdf05935ae8c6c97bcf6 (diff) |
Perl's chop / chomp considered bad, use a regexp instead
Once upon a time, there was chop, which somply chopped off the last
character of $_ or a given variable, and it was used to take off the
EOL character (\n) of strings.
... but then, you had to check for the presence of such character.
So came chomp, the better chop which checks for \n before chopping it
off. And this worked well, as long as Perl made internally sure that
all EOLs were converted to \n.
These days, though, there seems to be a mixture of perls, so lines
from files in the "wrong" environment might have \r\n as EOL, or just
\r (Mac OS, unless I'm misinformed).
So it's time we went for the more generic variant and use s|\R$||, the
better chomp which recognises all kinds of known EOLs and chops them
off.
A few chops were left alone, as they are use as surgical tools to
remove one last slash or one last comma.
NOTE: \R came with perl 5.10.0. It means that from now on, our
scripts will fail with any older version.
Reviewed-by: Rich Salz <rsalz@openssl.org>
Diffstat (limited to 'apps/CA.pl.in')
-rw-r--r-- | apps/CA.pl.in | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/apps/CA.pl.in b/apps/CA.pl.in index 52a97d7345..fbba457646 100644 --- a/apps/CA.pl.in +++ b/apps/CA.pl.in @@ -121,7 +121,7 @@ if ($WHAT eq '-newcert' ) { # ask user for existing CA certificate print "CA certificate filename (or enter to create)\n"; $FILE = <STDIN>; - chop $FILE if $FILE; + $FILE = s|\R$|| if $FILE; if ($FILE) { copy_pemfile($FILE,"${CATOP}/private/$CAKEY", "PRIVATE"); copy_pemfile($FILE,"${CATOP}/$CACERT", "CERTIFICATE"); |