home.social

Jeffrey04

Software engineer / writer / blogger / amateur podcaster / homo sapiens

Posts
166
Followers
25
Following
73
Joined 2023-04-13 · View on hachyderm.io →
  1. kitfucoda.medium.com/orchestra

    Why do we always assume a simple shell script is enough to fix a flaky command-line tool? It starts as a quick automation experiment. But as the feature wishlist inevitably grows, so does the complexity of your code. Before you know it, you are asking a basic scripting language to handle time-sensitive guards, conditional retry loops, and external user interactions.

    That is how my humble Bash script ended up spawning subshells, tracking process IDs, and trapping SIGTERM just to handle a 2FA prompt timeout on my phone. The script spent half its lines deciding how to exit gracefully, quickly devolving into cryptic gibberish that even my LLM chatbot couldn't comprehend. That was the breaking point where I realized: I need a proper programming language.

    Rebuilding the script in Python with asyncio turned out to be an absolute breeze. Thanks to asyncio’s non-blocking event loop, managing timeouts, cleanly forwarding data to stdin during authentication, and gracefully catching shutdown signals became elegant, simple, and incredibly readable. It completely bypassed the need to fiddle with complex cross-process message passing.

    Sometimes, keeping personal scripts intentionally crude and un-tested is perfectly fine—so long as they remain structurally sound and readable. If you have been wrestling with complex, brittle process orchestration in Bash, this is your sign to let asyncio save your sanity. Read the full article for a breakdown of the code snippets!