:blobfoxconfused:
bash-5.2$ if [[ 'Python 3.12.8' =~ '^Python 3\.12' ]]; then echo foo; fi bash-5.2$ % if [[ 'Python 3.12.8' =~ '^Python 3\.12' ]]; then echo foo; fi foo %Conversation
Notices
-
Embed this notice
Doughnut Lollipop 【記録係】:blobfoxgooglymlem: (tk@bbs.kawa-kun.com)'s status on Friday, 25-Apr-2025 00:51:46 JST Doughnut Lollipop 【記録係】:blobfoxgooglymlem:
-
Embed this notice
Doughnut Lollipop 【記録係】:blobfoxgooglymlem: (tk@bbs.kawa-kun.com)'s status on Friday, 25-Apr-2025 00:59:09 JST Doughnut Lollipop 【記録係】:blobfoxgooglymlem:
Turns out Bash wanted it to be like this instead:
bash-5.2$ if [[ 'Python 3.12.8' =~ ^'Python 3.12' ]]; then echo foo; fi foo bash-5.2$Yes, . matches only a literal period.
-
Embed this notice
Steven Sandoval (baltakatei@twit.social)'s status on Friday, 25-Apr-2025 01:20:19 JST Steven Sandoval
@tk I have a mental sticky note that says “Don't put quotes of any kind around the regular expression in a `[[ =~ ]]` test”. My go-to template is to instead store the regex in a variable and then call it without quotes: `re='^foo'; if [[ "$myvar" =~ $re ]]`
No idea how the black magic works. Ooga booga.
Doughnut Lollipop 【記録係】:blobfoxgooglymlem: likes this. -
Embed this notice
purple 👊✊💨 (purple@nya.social)'s status on Friday, 25-Apr-2025 01:22:16 JST purple 👊✊💨
@tk@bbs.kawa-kun.com correct, [[ is very much a bashism <3 <3 but youre using it right. man 7 regex lists all the special rules for matching literals... awful stuff...
Doughnut Lollipop 【記録係】:blobfoxgooglymlem: likes this. -
Embed this notice
Doughnut Lollipop 【記録係】:blobfoxgooglymlem: (tk@bbs.kawa-kun.com)'s status on Friday, 25-Apr-2025 01:23:05 JST Doughnut Lollipop 【記録係】:blobfoxgooglymlem:
@purple Still considering just using grep -P . :blobfoxthinkgoogly:
-
Embed this notice
purple 👊✊💨 (purple@nya.social)'s status on Friday, 25-Apr-2025 01:30:24 JST purple 👊✊💨
@tk@bbs.kawa-kun.com sed or perl are my gotos -- look, no matter what you have to call some program to check what it is, why use a butter knife when we have lightsabers?
-
Embed this notice
purple 👊✊💨 (purple@nya.social)'s status on Friday, 25-Apr-2025 01:32:10 JST purple 👊✊💨
@tk@bbs.kawa-kun.com also when it comes to shit like semantic versions (and checking for which is which), perl has modules for that shiz already.
-
Embed this notice
purple 👊✊💨 (purple@nya.social)'s status on Friday, 25-Apr-2025 01:39:07 JST purple 👊✊💨
@tk@bbs.kawa-kun.com (not to shit on grep, ofc, i'm sure it's also fine for this specific task)
Doughnut Lollipop 【記録係】:blobfoxgooglymlem: likes this. -
Embed this notice
Haelwenn /элвэн/ :triskell: (lanodan@queer.hacktivis.me)'s status on Friday, 25-Apr-2025 01:46:29 JST Haelwenn /элвэн/ :triskell:
@tk @purple Well there's expr string : regex if you want to portably regex on a string and so avoid the bashim of [[…]].
Doughnut Lollipop 【記録係】:blobfoxgooglymlem: likes this. -
Embed this notice
Haelwenn /элвэн/ :triskell: (lanodan@queer.hacktivis.me)'s status on Friday, 25-Apr-2025 01:51:16 JST Haelwenn /элвэн/ :triskell:
@tk @purple Although must say I love the idea of grabbing Perl to deal with (Python) versions, could easily end up the kind of thing I'd pull :D Doughnut Lollipop 【記録係】:blobfoxgooglymlem: likes this. -
Embed this notice
purple 👊✊💨 (purple@nya.social)'s status on Friday, 25-Apr-2025 02:26:54 JST purple 👊✊💨
@lanodan@queer.hacktivis.me @tk@bbs.kawa-kun.com containers were a mistake
Doughnut Lollipop 【記録係】:blobfoxgooglymlem: likes this. -
Embed this notice
Haelwenn /элвэн/ :triskell: (lanodan@queer.hacktivis.me)'s status on Friday, 25-Apr-2025 02:27:06 JST Haelwenn /элвэн/ :triskell:
@purple @tk how so? Typical systems in there being too minimalist?
-
Embed this notice