Conversation
Notices
-
Embed this notice
aliss (aliss@outerheaven.club)'s status on Monday, 19-Sep-2022 08:35:36 JST aliss @tost it also works! -
Embed this notice
Hélène (helene@p.helene.moe)'s status on Monday, 19-Sep-2022 08:35:34 JST Hélène @tost @aliss is it possible or good to do "$pattern"{debian,fedora}"
-
Embed this notice
Tosti ? (tost@mk.toast.cafe)'s status on Monday, 19-Sep-2022 08:35:35 JST Tosti ? @aliss@outerheaven.club pro tip try
"$pattern"debian -
Embed this notice
Tosti ? (tost@mk.toast.cafe)'s status on Monday, 19-Sep-2022 08:37:07 JST Tosti ? @helene@p.helene.moe @aliss@outerheaven.club shell-dependent, not generally a good idea unless you're targetting a specific one
Hélène likes this. -
Embed this notice
Tosti ? (tost@mk.toast.cafe)'s status on Monday, 19-Sep-2022 08:38:33 JST Tosti ? @aliss@outerheaven.club @helene@p.helene.moe yes, you could
I do still think my plain "debian" grep is better fwiw
"robustness" is fake newsHélène likes this. -
Embed this notice
aliss (aliss@outerheaven.club)'s status on Monday, 19-Sep-2022 08:38:34 JST aliss @tost @helene if only we had those shiny things in shell-land..
u could do "$pattern"debian|"$pattern"fedora) in the switch case right tosti?
-
Embed this notice
Hélène (helene@p.helene.moe)'s status on Monday, 19-Sep-2022 08:39:20 JST Hélène @tost @aliss and even then why put the ^ID= in the iterated items instead of in the grep? unless i’m missing something
-
Embed this notice
Tosti ? (tost@mk.toast.cafe)'s status on Monday, 19-Sep-2022 08:39:42 JST Tosti ? @helene@p.helene.moe @aliss@outerheaven.club you have to for this to ork
Hélène likes this. -
Embed this notice
Hélène (helene@p.helene.moe)'s status on Monday, 19-Sep-2022 08:40:08 JST Hélène @aliss @tost (i think rust is anything but robust... :cirno_peek: -
Embed this notice
aliss (aliss@outerheaven.club)'s status on Monday, 19-Sep-2022 08:40:09 JST aliss @tost @helene except in rust land uwu -
Embed this notice
aliss (aliss@outerheaven.club)'s status on Monday, 19-Sep-2022 08:40:23 JST aliss @tost @helene
> I do still think my plain "debian" grep is better fwiw
we know you're very talented
and smart
and kind
:celsilvercrystalheart:Hélène likes this. -
Embed this notice
Hélène (helene@p.helene.moe)'s status on Monday, 19-Sep-2022 08:40:40 JST Hélène @tost @aliss so i am missing something -
Embed this notice
Hélène (helene@p.helene.moe)'s status on Monday, 19-Sep-2022 08:45:20 JST Hélène @tost @aliss why does it do that, i don't get it still :acat_chew: -
Embed this notice
Tosti ? (tost@mk.toast.cafe)'s status on Monday, 19-Sep-2022 08:45:21 JST Tosti ? @helene@p.helene.moe @aliss@outerheaven.club let me make this a bit simpler to demonstrate the mechanismfor i in fake news fedora-logo-icon tm; do grep -qe "$i" /etc/os-release && break done echo "$i" # fedora-logo-icon on my machine
-
Embed this notice
Tosti ? (tost@mk.toast.cafe)'s status on Monday, 19-Sep-2022 08:45:40 JST Tosti ? @helene@p.helene.moe @aliss@outerheaven.club the output is the pattern you put in, which means the pattern is what needs to go into the case-pattern (or something that'll match against it)
Hélène likes this. -
Embed this notice
aliss (aliss@outerheaven.club)'s status on Monday, 19-Sep-2022 08:45:41 JST aliss @tost @helene i made it work.. somehow? https://outerheaven.club/notice/ANhjEhfR4Mvx6qifSq Hélène likes this. -
Embed this notice
Tosti ? (tost@mk.toast.cafe)'s status on Monday, 19-Sep-2022 08:45:44 JST Tosti ? @aliss@outerheaven.club @helene@p.helene.moe shell dependent :^)
In conversation permalink Hélène likes this. -
Embed this notice
aliss (aliss@outerheaven.club)'s status on Monday, 19-Sep-2022 08:46:57 JST aliss @tost @helene oh so is not guaranteed ic, in which ones can it work like that, in which ones cant? In conversation permalink Hélène likes this. -
Embed this notice
aliss (aliss@outerheaven.club)'s status on Monday, 19-Sep-2022 08:46:58 JST aliss @tost @helene helene if you're running bash you probably can put the ^ID= just in the grep yes <3<3333 In conversation permalink Hélène likes this. -
Embed this notice
Hélène (helene@p.helene.moe)'s status on Monday, 19-Sep-2022 08:53:45 JST Hélène @aliss @tost ikr In conversation permalink -
Embed this notice
aliss (aliss@outerheaven.club)'s status on Monday, 19-Sep-2022 08:53:46 JST aliss how case(1b) functions apparently shellcheck people didn’t catch it :hehecat:
im not sure what POSIX says on case’s patterns behavior, i’ll have to read btw i didn’t find info about the desync pattern thing
some shells have unqualified entries work as wildcards or terminators and it’s wild you should generally presume them to be “flat” strings icic thx lots for the explaining and all your time tonight <3 u always make me learn and i feel grateful
helene: ur girl hot ngl
In conversation permalink Hélène likes this. -
Embed this notice
Tosti ? (tost@mk.toast.cafe)'s status on Monday, 19-Sep-2022 08:53:47 JST Tosti ? @aliss@outerheaven.club @helene@p.helene.moe it depends on how case(1b) functions
some shells have unqualified entries work as wildcards or terminators and it's wild
you should generally presume them to be "flat" stringsIn conversation permalink -
Embed this notice
Tosti ? (tost@mk.toast.cafe)'s status on Monday, 19-Sep-2022 08:59:17 JST Tosti ? @aliss@outerheaven.club @helene@p.helene.moe im not sure what POSIX says on case’s patterns behaviorokay, so
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_04_05see Pattern Matching Notation
that is matched by the string resulting from the tilde expansion, parameter expansion, command substitution, arithmetic expansion, and quote removal of the given wordLet's go to Pattern Matching Notation: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_13If any character (ordinary, shell special, or pattern special) is quoted, that pattern shall match the character itself. The shell special characters always require quoting.
When unquoted and outside a bracket expression, the following three characters shall have special meaning in the specification of patternsthis raises the question of what happens when you have a quoted variable expansion - is the expanded output considered quoted or not?
let's look at https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_02
which sends us to https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_02
. . . which has nothing to say on the matter
POSIX is ultimately an "unfinished" (or rather, incomplete - open to interpretation) specification, especially when it comes to shell
and this is where the potential differnence lies
welcome to hellIn conversation permalink Attachments
Hélène likes this. -
Embed this notice
Tosti ? (tost@mk.toast.cafe)'s status on Monday, 19-Sep-2022 08:59:32 JST Tosti ? @helene@p.helene.moe @aliss@outerheaven.club ;jnergwnegr;woengowg
In conversation permalink Hélène likes this. -
Embed this notice
aliss (aliss@outerheaven.club)'s status on Monday, 19-Sep-2022 09:00:25 JST aliss @helene @tost love how the markdown formatting is printed totally cursed In conversation permalink Hélène likes this. -
Embed this notice
Tosti ? (tost@mk.toast.cafe)'s status on Monday, 19-Sep-2022 09:02:18 JST Tosti ? @aliss@outerheaven.club @helene@p.helene.moe also yes shellcheck is really bad and I hate it and cannot recommend anyone use it ever
In conversation permalink Hélène likes this. -
Embed this notice
aliss (aliss@outerheaven.club)'s status on Monday, 19-Sep-2022 09:04:22 JST aliss @helene @tost explain.. <3 In conversation permalink Hélène likes this. -
Embed this notice
aliss (aliss@outerheaven.club)'s status on Monday, 19-Sep-2022 09:15:49 JST aliss @tost @helene woa thx! so undefined behavior then, ic
im a bit impressed with how fast u found everything
when i grow up i want to be like tosti
also: welcome to (s)hell (pic)In conversation permalink Attachments
Hélène likes this. -
Embed this notice
Tosti ? (tost@mk.toast.cafe)'s status on Monday, 19-Sep-2022 09:16:01 JST Tosti ? @aliss@outerheaven.club @helene@p.helene.moe tosti shell book :apensive:
In conversation permalink Hélène likes this. -
Embed this notice
aliss (aliss@outerheaven.club)'s status on Monday, 19-Sep-2022 09:19:47 JST aliss @tost @helene new need :sparkles_trans: unlocked :sparkles_trans: In conversation permalink Hélène likes this. -
Embed this notice
Tosti ? (tost@mk.toast.cafe)'s status on Monday, 19-Sep-2022 09:19:48 JST Tosti ? @aliss@outerheaven.club @helene@p.helene.moe I should be working on it right now tbh :apensive:
In conversation permalink Hélène likes this. -
Embed this notice
Tosti ? (tost@mk.toast.cafe)'s status on Monday, 19-Sep-2022 09:19:49 JST Tosti ? @aliss@outerheaven.club @helene@p.helene.moe it's "been" coming on and off for 3 years or so :totodile_laugh:
the short version is
"if I get off my ass, it is"In conversation permalink Hélène likes this. -
Embed this notice
aliss (aliss@outerheaven.club)'s status on Monday, 19-Sep-2022 09:19:50 JST aliss @tost @helene oh is coming this year? In conversation permalink Hélène likes this. -
Embed this notice
Tosti ? (tost@mk.toast.cafe)'s status on Monday, 19-Sep-2022 09:21:14 JST Tosti ? @aliss@outerheaven.club absolutely
if you go for strict POSIX compatibility, \e will NOT work, for instance
octals still should though
see https://www.mankier.com/1p/printfIn conversation permalink Attachments
Hélène likes this. -
Embed this notice
aliss (aliss@outerheaven.club)'s status on Monday, 19-Sep-2022 09:21:15 JST aliss @tost i have it without %b in my profile
like
```
export LESS_TERMCAP_md="$(printf '\e[1;36m')"
```
i know %b is used for escapes and love the correctness but is there any chance without it printf would explode?In conversation permalink -
Embed this notice
Tosti ? (tost@mk.toast.cafe)'s status on Monday, 19-Sep-2022 09:21:16 JST Tosti ? @aliss@outerheaven.club the correct way is using printf with %b
namely:
myvar=$(printf '%b' 'my\eescape')In conversation permalink -
Embed this notice
aliss (aliss@outerheaven.club)'s status on Monday, 19-Sep-2022 09:21:17 JST aliss @tost this is very sensible yes, i generally put doubles because sometimes variables get tossed into another variable’s values at a later time, but if you’re strict with the quoting you know you will only get literals and not variable expansions so you reduce the places where to look into for debugging..
where you should also use $’’
yes, i had to do this $'' when i was defining LESS_TERMCAP for coloring it (export LESS_TERMCAP_mb=$'\e[1;31m'); the other route was to use command substitution with $(printf <escape>) (becuse apparently $'' is not defined by POSIX or so shellcheck says
finally, there’s the cursed route of using $(tput <something>) i’ve seen it in the wild but i know tput is way slower than printf escapes so i was wary of using it
In conversation permalink -
Embed this notice
Tosti ? (tost@mk.toast.cafe)'s status on Monday, 19-Sep-2022 09:21:18 JST Tosti ? @aliss@outerheaven.club another pro tip
use single quotes unless you're planning to have variable expansion
except in bash, where you should also use $'' sometimesIn conversation permalink -
Embed this notice
aliss (aliss@outerheaven.club)'s status on Monday, 19-Sep-2022 09:21:19 JST aliss @tost it's certainly a way to not write a long-sed-pattern (see above: pls don't print the other non-replaced lines + pls capture this thing + pls insert escape sequence + pls have ID and ID_FAMILY)
and is a good way to make your one "more robust" in the case that another 'debian' words appeared other than ID/IDFAM lines, u have to repeat the pattern a bit but is also nice and with more rigour :shibaheart:In conversation permalink Attachments
-
Embed this notice