Here is a v2 that handles the Windows case that I seemingly missed in myfirst readthrough of this code.
-- Tristan PartinNeon (https://neon.tech)