[Question]
  [
**This question already has answers here**:
 
 
[Write the shortest self-identifying program (a quine variant)](/questions/11370/write-the-shortest-self-identifying-program-a-quine-variant)
 (48 answers)
 
Closed 3 years ago.
Write a program/method that:
* Becomes a quine when the input matches the source code;
* Doesn't halt otherwise.
This is code-golf, so shortest solution wins. Avoid any standard loopholes.
  
[Answer]
# [Python 3.8 (pre-release)](https://docs.python.org/3.8/), ~~67~~ ~~60~~ 56 bytes
```
exec(a:='print(s:=input())\nwhile s!="exec(a:=%r)"%a:1')
```
[Try it online!](https://tio.run/##K6gsycjPM7YoKPr/P7UiNVkj0cpWvaAoM69Eo9jKNjOvoLREQ1MzJq88IzMnVaFY0VYJpkq1SFNJNdHKUF2TfJ0A "Python 3.8 (pre-release) – Try It Online")
---
# [Python 2](https://docs.python.org/2/), 56 bytes
```
a='s=input();print s\nwhile s!="a=%r;exec a"%a:1';exec a
```
[Try it online!](https://tio.run/##K6gsycjPM/r/P9FWvdg2M6@gtERD07qgKDOvRKE4Jq88IzMnVaFY0VYp0Va1yDq1IjVZIVFJNdHKUB3K@f@/SElJiVzdQK0A "Python 2 – Try It Online")
[Answer]
# [GolfScript](http://www.golfscript.com/golfscript/), 20 bytes
```
{`".~"+{.2$=}do\;}.~
```
[Try it online!](https://tio.run/##S8/PSStOLsosKPn/vzpBSa9OSbtaz0jFtjYlP8a6Vq8OhygA "GolfScript – Try It Online")
## Explanation
```
{                }.~ # Evaluate the following string as GolfScript code, using the string itself as argument:
 `                   # - Uneval (effectively wrap the string in ""
  ".~"+              # - Append .~
       {.2$=}do      # - Do While not equal to the original program argument:
                     #   - (Basically do nothing)
               \;    # - If this loop ends, discard the extra copy of the input
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 14 bytes
```
“Ṿ;⁾v`¹⁻³$¿”v`
```
[Try it online!](https://tio.run/##y0rNyan8//9Rw5yHO/dZP2rcV5ZwaOejxt2HNqsc2v@oYW5Zwn@8sgA "Jelly – Try It Online")
A program taking a single string argument and either printing its source if the string matches its source, or looping indefinitely if not. 
## Explanation
```
“          ”v` | Evaluate the following string as Jelly code, using the string itself as argument:
 Ṿ             | - Uneval (effectively wrap the string in “”
  ;⁾v`         | - Append v`
       ⁻³$¿    | - While not equal to the original program argument:
      ¹        |   - Call the identity function
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 20 bytes
```
"34çìD«Êi["34çìD«Êi[
```
[Try it online!](https://tio.run/##yy9OTMpM/f9fydjk8PLDa1wOrT7clRmNysMtCwA "05AB1E – Try It Online")
---
# Explanation
```
"34çìD«Êi["           - string literal
           34ç        - push the character "
              ì       - prepend to the string literal
               D«     - duplicate the string (producing the code)
                 Êi[  - loop if it's not the same as the input
                      - else implicitly output
                    
```
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 15 bytes
```
QWnjN B"QWnjN B
```
[Try it online!](https://tio.run/##K6gsyfj/PzA8L8tPwUkJSv//r6SkhCYGFPmXX1CSmZ9X/F83BQA "Pyth – Try It Online")
## Explanation
```
QWnjN B"QWnjN B
Q                 implicit print input
      B"QWnjN B   evaluates to ["QWnjN B", "QWnjN B"]
   jN             join elements in list with '"' as separator (will be source code)
 Wn               keep looping while input does not equal source code
```
[Answer]
# [PHP](https://php.net/), 89 bytes
```
eval($s='$a=chr(39);$b="eval(\$s=$a";$c="$a);";$b.$s.$c!=$argn?:die($b.$s.$c);for(;;);');
```
[Try it online!](https://tio.run/##K8go@G9jXwAkU8sSczRUim3VVRJtkzOKNIwtNa1VkmyVwOIxQAmVRCVrlWRbJZVETWsgK0lPpVhPJVkRKF6UnmdvlZKZqgET1LROyy/SsLbWtFbXtP5PO6P/5ReUZObnFf/XdQMA "PHP – Try It Online")
This is the best I have found so far, at the beginning it wasn't a port of @Mukundan's answer, but it pretty much ends like it. I will try to improve it later..
EDIT: saved a byte with `!=` instead of `==` so I can remove the `1`
EDIT2: saved 16 bytes using vars for repeated strings
[Answer]
# [RProgN 2](https://github.com/TehFlaminTaco/RProgN-2), 17 bytes
```
«•.x=xe²xw³1#1:? 
```
# Explanation
```
«•.x=xe²xw³1#1:?<SPACE> #
«                       # Push the following function to the stack and execute
 •.                     # Append a space (A non-function character) and stringify
   x=                   # Assign the stringified function to x
     xe                 # Is x equal to the top of the stack?
       ²                # "Double Function" to execute if true
        x               # Push x to the stack
         w              # Output
          ³             # "Tripple Function" to execute if false
           1            # Push a truthy value to the stack
            #1          # A function that just repeatedly pushes true
              :         # While the top of the stack is true. Thus, loop forever
               ?        # If a, than b, else c
                <SPACE> # Used to ensure the function qualifies as a quine.
```
[Try it online!](https://tio.run/##Kyooyk/P0zX6///Q6kcNi/QqbCtSD22qKD@02VDZ0Mpe4T8uCQA "RProgN 2 – Try It Online")
[Answer]
# [Funky](https://github.com/TehFlaminTaco/Funky), 36 bytes
```
f=s=>{x=`f=[f]`ifx==s x elsewhile1z}
```
[Try it online!](https://tio.run/##SyvNy678/z/NttjWrrrCNiHNNjotNiEzrcLWtlihQiE1pzi1PCMzJ9WwqvZ/QVFmXokGF2caEHMqEaNFiYtTk0vzPwA "Funky – Try It Online")
[Answer]
# [JavaScript (V8)](https://v8.dev/), ~~33~~ ~~32~~ 31 bytes
*-1 byte thanks to [Jo King](https://codegolf.stackexchange.com/users/76162/jo-king)*
```
f=x=>eval(`while(x!='f='+f);x`)
```
[Try it online!](https://tio.run/##y0osSyxOLsosKNEts/j/P822wtYutSwxRyOhPCMzJ1WjQtFWPc1WXTtN07oiQfN/QVFmXolGmoYSAYVKmpr/AQ "JavaScript (V8) – Try It Online")
[Answer]
# [Perl 5](https://www.perl.org/), 50 bytes
```
$_=q($_='$'."_=q($_);eval";<>eq$_?print:eval);eval
```
[Try it online!](https://tio.run/##K0gtyjH9/18l3rZQA0ioq6jrKUHYmtapZYk5StY2dqmFKvH2BUWZeSVWICGIBDl6AA "Perl 5 – Try It Online")
[Answer]
# [Japt](https://github.com/ETHproductions/japt), ~~29~~ 21 bytes
```
OvA="Us@¶`OvA=`+Q+A}a
```
[Try it online!](https://tio.run/##y0osKPn/37/M0VYptNjh0LYEEDNBO1DbsTbx/3917BLqAA "Japt – Try It Online")
## Explanation
```
OvA="Us@¶`OvA=`+Q+A}a
  A="Us@¶`OvA=`+Q+A}a // Set A to string literal
Ov                    // Evaluate A as japt code
       @              // Function
        ¶`OvA=`+Q+A   //   Check if input equals "OvA" + '"' + A (Q is '"')
                   }  // End Function
                    a // Call function repeatedly until it returns a truthy value
     Us               // Slice off first 0 chars of input
                      // Implicit Output
```
]