<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body>
<div dir="auto">Wow, I think I unwittingly invoked Cunningham's Law with my initial post...</div>
<div dir="auto"><br>
</div>
<div dir="auto">Thank you to everyone for the hints, tips, and alternate approaches - I've learned a few new things through this!</div>
<div dir="auto"><br>
</div>
<div dir="auto">-Adam</div>
<div><br>
</div>
<div id="ms-outlook-mobile-signature" dir="auto">Get <a href="https://aka.ms/AAb9ysg">
Outlook for Android</a></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Trevor Cordes <trevor@tecnopolis.ca><br>
<b>Sent:</b> Tuesday, February 28, 2023 12:42:55 AM<br>
<b>To:</b> Gilbert Detillieux <Gilbert.Detillieux@umanitoba.ca><br>
<b>Cc:</b> Continuation of Round Table discussion <roundtable@muug.ca>; Adam Thompson <athompso@athompso.net><br>
<b>Subject:</b> Re: [RndTbl] shell quoting inside $( )?</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Perl version.  Cleaner?  No eval.  No >().  One line.  Relies on<br>
read to fill the bash vars.  Uses Gilbert's just-one-filter-pass<br>
idea.  Does the date transform at the very end in perl: would be<br>
a sec hole if $e is injected with bad things.  Could easily fix<br>
with setting the $e regex from . to [-.a-zA-Z0-9].  Could also<br>
die in the END if !$e.<br>
<br>
$ read SUBJ EXPD <<<$(openssl x509 -noout -text -in /etc/pki/tls/certs/tecnopolis.ca.crt | perl -ne '($e)=/^.*Not After : (.*)/ if !$e; ($s)=/^.*Subject: .*CN = (.*)/ if !$s; END { print $s." ".`date -d"$e" +%Y%b%d`}')<br>
$ echo s=$SUBJ e=$EXPD<br>
s=tecnopolis.ca e=2024Feb22<br>
<br>
I like the perl approach because it has the least # of forks, and<br>
really the sky is the limit for taint cleaning and sanity checks.<br>
Plus I find it more readable than bash, and perl is highly<br>
optimized for PCRE so should be pretty fast.  I also understand<br>
perl's quoting intimately vs my general haze with bash.<br>
</div>
</span></font></div>
</body>
</html>