A “quine” is a self-replicating program — its output is a copy of its own source code.
Here is an example I wrote in Python:
c = """
c = {1}{0}{1}
print(c.format(c, '"'*3))
"""
print(c.format(c, '"'*3))Shell script quines without "%s"
This shell script prints an exact copy of itself. This means that cat quine.sh and ./quine.sh are equivalent:
Lines 1 to 23 in f1a460d
It's therefore also equivalent to running e.g. sh <(sh <(./quine.sh)).
I did not want to use printf %s for this quine. The trick was to get the quoting right on the "recursion line", #14 (which has to match #9), I found the solution here.
In quine2.sh I wanted to avoid variable assignments and minimize string interpretation (no % and $) and just use simple printf and zero-argument functions/procedures.