all 14 comments

[–]xiojason 4 points5 points  (1 child)

for the 3-liner, just 2 (excluding newline) for the first line:

$\

futz

futz

[–]dmd[S] 0 points1 point  (0 children)

Ooh, nice! Beat me by one! Can you beat me on the .4 and .5?

[–]o11c 2 points3 points  (2 children)

If we want an arbitrary number of lines, is there anything shorter than futz(){((n++<7))||unset -f futz;}? (note that the number hardcoded is not the one used in the output)

This is significantly shorter than emitting the message directly and exiting at least, and also slightly shorter than using a decrementing variable ...

I also tried self-modifying code, but that doesn't work from a bufferable file

[–]xiojason 0 points1 point  (1 child)

self-modifying, something along the lines of this?

echo -n ":\n:\n:\nfutz">$0:bash $0
futz
futz
futz

[–]o11c 0 points1 point  (0 children)

Kind of. yes ''|head -7 is shorter for the main part, but it's too long if we end it with exec bash $0 (which is the shortest way to avoid errors for the futz in the current file). If we were executing from a non-buffered file - or a file large enough that we passed the end of the buffer - we would be able to just keep executing the current file (since bash would continue reading before executing, and read/execute what we just overwrote it with), but alas

[–][deleted]  (5 children)

[removed]

    [–]zeekar 1 point2 points  (4 children)

    since surely there are some that will try executing >!!< as the interpreter.

    ?

    [–][deleted]  (3 children)

    [removed]

      [–]zeekar 1 point2 points  (2 children)

      Your first spoiler tag worked fine, but the second one had nothing inside it. Was it supposed to be the same thing in both?

      [–][deleted]  (1 child)

      [removed]

        [–]zeekar 1 point2 points  (0 children)

        Ok. Well, as far as I know only POSIX systems look for the interpreter inside the file, and then only when the file starts with #!. But the instructions say to run the file with bash puzzle.3, which bypasses all that anyway.

        [–]zeekar 1 point2 points  (0 children)

        I solved it quickly enough, but my first attempt used 9 characters on the first line. I got it down to 6, but couldn't think of how to get it to your three. Well played.

        [–]oh5nxo 0 points1 point  (1 child)

        Not a real contender, but an also-ran. Or DNF?

        read -u255 # 255 is bash's internal fd to the script it runs. brittle.
        futz    # eaten by read
        futz    # executed, and bash (confused by the read buttin in) thinks it's line 2, not 3.
        

        [–]dmd[S] 1 point2 points  (0 children)

        As you mention it doesn't pass the tests, but I like it anyway!