• @[email protected]
        link
        fedilink
        3810 months ago

        And on a modern Linux system, there’s a limit to how many can run simultaneously, so while it will bog down your system, it won’t crash it. (I’m running it right now)

      • @[email protected]
        link
        fedilink
        710 months ago

        does this constitute a quine? I wrote a couple quines using bash but nothing as elegant as this

      • @[email protected]
        link
        fedilink
        210 months ago

        Thanks friend. One question, is it necessary to pipe to itself? Wouldnt : & in the function body work with the same results?

        • @[email protected]
          link
          fedilink
          2
          edit-2
          10 months ago

          That would only add one extra process instance with each call. The pipe makes it add 2 extra processes with each call, making the number of processes grow exponentially instead of only linearly.

          Edit: Also, Im not at a computer to test this, but since the child is forked in the background (due to &), the parent is free to exit at that point, so your version would probably just effectively have 1-2 processes at a time, although the last one would have a new pid each time, so it would be impossible to get the pid and then kill it before it has already replaced itself. The original has the same “feature”, but with exponentially more to catch on each recursion. Each child would be reparented by pid 1, so you could kill them by killing pid 1 i guess (although you dont want to do that… and there would be a few you wouldn’t catch because they weren’t reparented yet)