Login
You're viewing the m.mtlynch.io public feed.

Replies

  • May 2, 2025, 5:18 PM

    @b0rk Never 1>&2? I regularly use
    echo "WARNING: foo bar baz" 1>&2
    to echo stuff to stderr. Am I missing an obvious echo_to_stderr command?

    💬 1🔄 0⭐ 0
  • May 2, 2025, 5:21 PM

    @baeuchle heh this is something that comes up a lot with shell stuff where "using a shell interactively" and “using a shell for scripting" are very separate in my mind and I always forget about scripting when I'm writing about interactive use and vice versa

    using 1>&2 in a scripting context does make sense (maybe I've done it!) but I would never do it interactively

    💬 1🔄 0⭐ 0
  • 💬 0🔄 0⭐ 0
  • May 2, 2025, 5:24 PM

    @b0rk always love these! There's a tiny typo in the second panel, "proram" instead of "program" fyi. But you've probably noticed that already

    💬 1🔄 0⭐ 0
  • 💬 0🔄 0⭐ 0
  • 💬 0🔄 0⭐ 0
  • 💬 0🔄 0⭐ 0
  • May 2, 2025, 5:49 PM

    @b0rk It blew my mind when I figured out that standard IO is nothing more than a user-space convention enabled by dup(2) guaranteeing that it will always return the lowest numbered unused filehandle.

    💬 0🔄 0⭐ 0
  • 💬 0🔄 0⭐ 0
  • May 2, 2025, 6:46 PM

    @b0rk My personal mnemonic for shell redirection (to combat my dyslexia):

    2>&1

    if the ">" is an "arrow" and the ampersand is "and", then my brain can reason that "2 goes to the same place as 1"

    💬 0🔄 0⭐ 0
  • May 2, 2025, 7:50 PM

    @b0rk Random fun fact, maybe someone finds it useful: The first one is how I always imagined things, too. So I was really surprised when I learnt that you can actually read from stderr, too. Ever wondered why you can pipe something into less and still use your keyboard to control it? 🙂

    💬 1🔄 0⭐ 0
  • May 2, 2025, 8:19 PM

    @caoimhin huh i never wondered that but suddenly i see that i’m about to learn something when I get to a computer and can strace less

    💬 1🔄 0⭐ 0
  • May 2, 2025, 8:32 PM

    @b0rk And of course I had to experiment with it again, too, and I just learnt two more new things (or the second one probably just forgotten from when I first discovered this):

    In practice, you even seem to get all of stdin, stdout and stderr opened read-write on Linux.

    And less actually has some fallbacks, so if you pass it /dev/null as its stderr, it still works, it just opens /dev/tty instead. But it does prefer stderr as long as it's a terminal. If not, /dev/tty is preferred anyway.

    💬 1🔄 0⭐ 0
  • 💬 0🔄 0⭐ 0
  • May 2, 2025, 9:12 PM

    @b0rk oh I never knew that gotcha, makes sense why I see errors don't pop out in order with the output now..

    💬 0🔄 0⭐ 0
  • May 3, 2025, 12:12 AM

    @b0rk I don't love being a pedant so I hope this doesn't come across as nitpicking, but I think in the second text box there's a typo: "proram" instead of "program"?

    💬 1🔄 0⭐ 0
  • 💬 0🔄 0⭐ 0