#soylent | Logs for 2025-08-29

« return
[01:00:12] -!- bender has quit [Remote host closed the connection]
[01:00:22] -!- bender [bender!bot@Soylent/Bot/Bender] has joined #soylent
[01:01:45] -!- Loggie [Loggie!Loggie@Soylent/BotArmy] has joined #soylent
[03:05:17] -!- lld has quit [Quit: Lost terminal]
[03:25:21] -!- lld [lld!~lld@llvm.link.editor] has joined #soylent
[06:17:00] <chromas> clapter
[06:41:23] -!- c0lo [c0lo!~c0lo@120.158.tz.gjv] has joined #soylent
[06:41:36] <c0lo> https://www.youtube.com
[06:41:38] <Clippit> ^ 03When D&D decides who does the dishes
[06:54:47] <halibut> echo $((RANDOM % 20)) for initiative ...
[06:55:11] <halibut> (Slightly biased assuming RANDOM is perfectly uniform, but arguably good enough here.)
[06:55:35] <ted-ious> I think that will give from 0 to 19.
[06:55:59] <halibut> That's right. A D20 is 1 to 20.
[06:56:07] <halibut> Give me $10k and I'll fix it for you.
[06:56:16] <ted-ious> And I tested it once and it was uniform enough that I decided it was good enough for anything besides real crypto security.
[06:56:19] <halibut> Give me $20k, and I'll have it go to 21.
[06:56:38] <ted-ious> Also you need $RANDOM not RANDOM. :)
[06:57:37] <halibut> Try it. You do not need the $ in $(( ... )).
[06:58:07] <ted-ious> Oh that's weird.
[06:58:16] <ted-ious> When did that happen?
[06:59:14] <halibut> In any of bash's arithmetic operators ( ((...)), $((...)), let ... ), variable names do not need to be prefixed by a dollar sign, as there are no bare word strings.
[06:59:39] <ted-ious> I'm sure that hasn't always been the case.
[06:59:40] <halibut> Of course, you can do that, and in some cases, it is necessary (like using ${#strg} for string length).
[07:00:18] <ted-ious> What's that?
[07:00:21] <halibut> I cannot say when that happened, but it has been that way for as long as I have known about arithmetic substitution in bash.
[07:01:09] <halibut> What's what?
[07:01:26] <halibut> ... or is this the start of a Who's on first skit?
[07:01:56] <ted-ious> Oh I mistook your {}'s for ()'s.
[07:02:17] <ted-ious> string=foo ; echo ${#string} is 3
[07:02:45] <halibut> Yes. Punctuation in shell scripts is ... interesting.
[07:05:08] <ted-ious> But string=foo ; echo ${string#f} is oo
[07:05:23] <ted-ious> Bash is a mess. :)
[07:06:11] <halibut> The Parameter Expansion section of the bash man page is something I find myself referencing a lot. There are a lot of interesting things you can do there.
[07:06:50] <ted-ious> I just wish there weren't so many gotcha's.
[07:07:28] <halibut> I still think this one is gold: :(){:|:;};:
[07:07:53] <halibut> I remember trying to improve upon it by adding some backgrounding, with varying success.
[07:07:59] <ted-ious> Like # have 4 or 5 very different meanings.
[07:09:09] <halibut> Indicates a comment normally, the character in a quoted string, a number in parameter expansion, or prefix stripping in a different parameter expansion (with # and ## variants) ... yep. I guess that is up there.
[07:09:37] <halibut> Kind of makes you yearn for Perl's consistent puncuta... nope. Can't say it with a straight face.
[07:09:47] <ted-ious> LOL
[07:12:27] <halibut> With practice, they all actually make their own kind of sense, but whenever I try to explain either to others ... I am reminded of how difficult it is when you are new to it.
[07:12:45] <halibut> Regexes, too. Those are made much more complicated because there are so many different dialects.
[07:13:37] <halibut> Even sed and grep differ in how they treat certain characters, unless you use -E (and grep supports -P to be more compatible with Perl) ...
[09:09:04] -!- halibut_ [halibut_!~halibut@CanHazVHOST/halibut] has joined #soylent
[09:10:14] -!- halibut has quit [Ping timeout: 240 seconds]