Backwards and forwards polyglot quine!

Batch / bash + tac, 39 bytes

:;tac -r -s '.\|'$'\n' $0;exit
@type %0

Outputs forwards in Batch. Explanation: Batch sees the first line as a label and ignores it, while the second line simply copies the source file to STDOUT. (Note that you need to invoke the file including extension, or change %0 to %~f0.) bash sees four commands:

  • : does nothing (same as true)
  • tac -r -s '.\|'$'\n' $0
    • -r puts tac into regex mode
    • -s specifies a regex
    • '.\|'$'\n' is the regex, composed of
      • . any character except newline
      • \| or
      • $'\n' a newline
    • The upshot is that tac splits the file into characters rather than lines.
  • exit stops the script, ignoring the fourth command
  • @type %0 (ignored)

Python 2 / Python 3, 71 bytes

lambda _='lambda _=%r:(_%%_)[::int(1-(1/2)*4)]':(_%_)[::int(1-(1/2)*4)]

Does not use any quine builtins.

Thanks to ovs for generally awakening me.


PHP & GolfScript, 2 bytes

1

i.e. a newline and the digit 1.

This is a reverse quine in GolfScript, contributed on this site by Justin. PHP hasn't triggered that it's a programming language so it prints its input.