A quine?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
spatters
Posts: 4
Joined: 25 Sep 2012 00:00

A quine?

#1 Post by spatters » 25 Sep 2012 00:04

Is this cheating?:

Code: Select all

@type %0

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: A quine?

#2 Post by foxidrive » 25 Sep 2012 00:09

When you launch a batch file by typing the name then %0 only contains what you typed.

This is more robust:

Code: Select all

@echo off
echo "%~f0"
type "%~f0"

spatters
Posts: 4
Joined: 25 Sep 2012 00:00

Re: A quine?

#3 Post by spatters » 25 Sep 2012 01:20

Sure. But if you type the full name of the batch file this works. Apparently it is okay to specify how the batch file should be called, judging by the quine page. Also judging by that page, brevity matters. If robustness is a goal you could do this:

Code: Select all

@type "%~dfx0"

spatters
Posts: 4
Joined: 25 Sep 2012 00:00

Re: A quine?

#4 Post by spatters » 03 Oct 2013 14:56

According to Wikipedia it is indeed cheating:

http://en.wikipedia.org/wiki/Quine_(computing)

Thanks to DigitalSnow answering this on another thread

Post Reply