3 ms·
that is so cool, my god! Bash is this awesome underrated thing (relative to how I perceive it being used). It's so cool that there's basically a virtual filesys
by keepamovin 3y ago
that is so cool, my god! Bash is this awesome underrated thing (relative to how I perceive it being used). It's so cool that there's basically a virtual filesystem that maps the internet to your disk...haha.
This even works on my Mac.
But one issue I encountered was timeout. I just tried:
: < /dev/tcp/google.com/8080 && echo OK || echo ERROR
and it hung. So I asked ChatGPT and it suggested
timeout 5 bash -c ': < /dev/tcp/google.com/8080' && echo OK || echo ERROR
- BenjiWiebe 3y agoThere isn't a virtual filesystem; bash just pretends there is. You can't use the /dev/tcp path in your own program as it doesn't exist.
- keepamovin 3y agoUnless...I program in bash! ^^ haha :) Yeah, I didn't know that. I definitely had a suspicion it was how you say, and "basically" was my fudge word, because I didn't know. I hadn't thought much about it, but I did not know for sure. Thanks for tellin me. I've thought about this idea: mapping the internet to the Unix filesystem, a la proc. I know TabFS, but I think the mapping could be better. I think it's an interesting problem to consider what a good mapping would be. But it's all tradeoffs I guess. I haven't thought that much about it. But it did seem interesting. Maybe not interesting enough to really commit to, because it seemed kinda like a big project. But definitely interesting to consider. What do you think? What kind of mapping would you do?