Maja changed the topic of ##bash-crimes to: we bash back | club of folks preoccupied in whether they could, not whether they should | logs https://libera.irclog.whitequark.org/~h~bash-crimes
<sdomi> cursed: `a=1; b=asdfasdf; echo "${b:c:c}"`
<sdomi> you can even do array accesses in there, i.e. `echo "${b:arr[1]:1}"`
<sdomi> s/:c:c/:a:a/ my bad
<sdomi> unfortunately, you can't do a string slice within a string slice, beyond "${b:${a:1:1}:1}" (but that requires the dollar for expansion, it's boring)
<sdomi> another cool hack: `${b::1}` implies the 0th letter
<sdomi> `${b:0:5}` -> asdfa
<sdomi> `${b:-1:5}` -> asdfasdf
<sdomi> `${b:0-2:2}` -> df (the last one)
<sdomi> anyways i'm semi-surprised that this is yet another place where you can do math
<isabella> ${b:-1:5} is expanded as ${var:-fallback}
<isabella> you want ${b: -1:5}
<isabella> ${var:-fallback} == $var if it's not empty, otherwise fallback
<isabella> so in your case it just expanded $var
<sdomi> isabella: oh, indeed
<sdomi> tbh i prefer the `${b:0-1:5}` syntax, looks less like a typo XD
dakkar has joined ##bash-crimes
dakkar has quit [Ping timeout: 248 seconds]