| Bytes | Lang | Time | Link |
|---|---|---|---|
| 070 | Bespoke | 250826T104225Z | Josiah W |
| 020 | Julia | 250825T195259Z | MarcMush |
| 009 | Uiua | 250824T202440Z | Joao-3 |
| 043 | Scratch | 250823T082203Z | Rhaixer |
| 024 | C clang | 170507T170206Z | jdt |
| 014 | ><> Fish | 250821T132549Z | mousetai |
| nan | Piet + asciipiet | 250821T120120Z | Themooni |
| 005 | APL Dyalog Unicode | 250821T070842Z | Adá |
| 033 | Acc!! | 211209T235923Z | DLosc |
| 004 | Pip | 211209T231751Z | DLosc |
| 007 | APOL | 211209T201407Z | Ginger |
| 031 | Batch | 211209T194025Z | T3RR0R |
| 026 | Python 3 | 211209T184746Z | Alan Bag |
| 010 | APL Dyalog Unicode | 201220T123021Z | Kamila S |
| 017 | JavaScript | 170504T050003Z | Arjun |
| 022 | R | 170504T080351Z | rturnbul |
| 026 | VBScript | 170507T171648Z | jdt |
| 060 | Java | 170504T210145Z | AAM111 |
| 079 | Java | 170507T164213Z | Khaled.K |
| 083 | C | 170507T162634Z | Khaled.K |
| 004 | Aceto | 170507T154201Z | L3viatha |
| 013 | x86 machine code on DOS | 170507T144017Z | Matteo I |
| 016 | Red | 170504T162103Z | Geeky I |
| 017 | Javascript | 170506T230012Z | RuteNL |
| 227 | x86 Assembler NASM Linux | 170506T152651Z | reachC |
| 022 | HTML5 | 170504T061817Z | Arjun |
| 002 | Pyke | 170506T114453Z | Blue |
| 002 | TIBASIC | 170504T154714Z | Scott Mi |
| 019 | Pure Bash | 170505T180046Z | Yeti |
| 016 | Bash + line | 170505T180546Z | Yeti |
| 021 | Pure Bash | 170505T180254Z | Yeti |
| 016 | Bash + line | 170505T100445Z | Yeti |
| 025 | Excel VBA | 170505T172525Z | Stupid_I |
| 026 | Tcl | 170505T160010Z | sergiol |
| 024 | REXX | 170505T154739Z | idrougge |
| 017 | Haskell | 170504T151322Z | nimi |
| 020 | Mathematica | 170504T114858Z | A Simmon |
| 020 | Mathematica | 170505T075406Z | numberma |
| 020 | ZX81 BASIC | 170505T075042Z | Neil |
| 087 | Ruby | 170505T072000Z | G B |
| 005 | QBIC | 170504T163559Z | steenber |
| 021 | Scala | 170504T225634Z | puhlen |
| 013 | Ruby | 170504T192750Z | histocra |
| 019 | Ruby | 170504T191108Z | anna328p |
| 004 | MATL | 170504T105404Z | Luis Men |
| 015 | QBasic 4.5 | 170504T162852Z | steenber |
| 019 | AHK | 170504T155003Z | Engineer |
| 032 | Clojure | 170504T151702Z | mark |
| 1211 | Perl | 170504T070406Z | user6883 |
| 066 | C# .NET Core | 170504T050534Z | Pavel |
| 034 | SpecBAS | 170504T143221Z | Brian |
| 011 | AWK | 170504T130520Z | Max Mikh |
| 005 | CJam | 170504T132753Z | Business |
| 022 | Swift | 170504T131010Z | Caleb Kl |
| 029 | Kotlin | 170504T115447Z | Justinw |
| 090 | Lithp | 170504T120319Z | Andrakis |
| 5139 | Bash | 170504T081907Z | Nicolas |
| 003 | Jelly | 170504T044841Z | Dennis |
| 029 | C | 170504T055058Z | egonr |
| 020 | PowerShell | 170504T082120Z | colsw |
| 035 | Batch | 170504T081136Z | Neil |
| 036 | C# | 170504T080315Z | TheLetha |
| 005 | 05AB1E | 170504T075927Z | Okx |
| 081 | Perl 5 | 170504T070616Z | Chris |
| 126 | Java | 170504T055012Z | Leaky Nu |
| 004 | Charcoal | 170504T070211Z | ASCII-on |
| 055 | Java | 170504T065145Z | Justin |
| 018 | PHP | 170504T060923Z | egonr |
| 026 | brainfuck | 170504T055835Z | Leaky Nu |
| 003 | Pyth | 170504T055204Z | Leaky Nu |
| 034 | QBasic | 170504T045846Z | Arjun |
| 004 | sed | 170504T051035Z | Digital |
| 018 | Python 3 | 170504T045754Z | Dennis |
Bespoke, 70 bytes
program prompts input
if all NL,a repetition
anything other conclude-s
Loops while the inputted character minus 10 is zero.
Uiua, 9 bytes
⍢⋅&sc≍∩""
I wrote this code in such a way that it would require the least parentheses:
- push two empty strings
- replace the string on top with a line from input
- repeat until they don't match
><> (Fish), 14 bytes
Hover over any symbol to see what it does
Loops until it finds a non-line break, then loops until it finds a line break
Unformatted version if the above does not display properly:
\,
\ia-?
\ia=?
Piet + ascii-piet, 40 bytes (6×8=48 codels)
tttttuuU d uU d emmEs d LsddkkkkFs
Loops until it reads a character that isn't a LF, at which point the program terminates.
APL (Dyalog Unicode), 5 bytes
Full program.
→''≡⍞
→ go to line…
''≡ the empty string matches…
⍞ get line of input
If the empty string matches, the comparison gives 1, and we go to line 1, which is the current line, causing a loop. If the empty string doesn't match, the comparison gives 0, and going to line 0 means quitting.
Acc!!, 33 bytes
N
Count i while _/10*(10/_) {
N
}
(Don't) Try it online!
Explanation
N reads a character into the accumulator. If it is 10 (newline), we want to keep looping, otherwise halt. The loop condition _/10*(10/_) accomplishes this: _/10 is 0 if _ is less than 10, and 10/_ is 0 if _ is greater than 10. The only way their product can be truthy (nonzero) is if _ is exactly 10.
(The algorithm halts after the first character of the non-empty input line, but since the Acc!! interpreter reads input one line at a time, the entire line will be read.)
If the input is guaranteed to be printable ASCII (and not contain, for example, the tab character), the loop condition could be just 10/_ for -7 bytes.
Pip, 4 bytes
T#q0
(Don't) Attempt This Online!
For best results, download Pip and run the program from your local command-line with the command ./pip.py -e 'T#q0' (Linux) or pip.py -e 'T#q0' (Windows).
Explanation
T Loop till
# length of
q read a line of stdin
is truthy (nonzero):
0 No-op
The shorter Tq0 doesn't work because an input like 0 will still be falsey and fail to terminate the loop.
Batch 31 bytes
@Set $=&Set/p$=&Set $ 2>nul||%0
APL (Dyalog Unicode), 10 bytes
Doesn't seem to work in TIO, works for me in Dyalog APL 18.0
{0=≢⍞:∇0}0
JavaScript, 37 22 17 bytes
while(!prompt());
while(!prompt());
Explanation
The while keyword starts the while loop. In the condition of the loop, !prompt() asks for input and checks whether it is given or not. If it isn't given, the body of the loop is executed, which in our case is empty, then the interpreter goes back to the loop condition. The same process happens over and over again until the user gives the input.
R, 27 24 23 22 bytes
while(!sum(scan()^0))t
Takes input from stdin, and repeat as long as input is of length 0. Cut off some bytes due to Jarko Dubbeldam and MickyT. Replaced the {} with t to save another byte.
VBScript, 26 bytes
while InputBox("")=""
wend
This one is sort of fun because the only way to stop the programs asking for an answer is either giving one or killing 'wscript.exe' in the task manager.
Java, 66 64 60 bytes
int a(){return!System.console().readLine().isEmpty()?0:a();}
My first Java answer, would love some tips!
Java, 79 bytes
boolean f(){System.console().readLine().replaceAll("\\t| ","").isEmpty()&&f();}
The above answer will read full lines, and check if the read line has content beside spaces\tabs.
shorter non-conforming version, 38 bytes
void f(){if(System.in.read()==10)f();}
C, 83 bytes
e(char*t){*t>32?1+e(t+1):0;}
f(){size_t l;char*t;getline(&t,&l,stdin)+1&&e(t)&&f();}
The above answer will read full lines, and check if the read line has content beside spaces\tabs.
shorter non-conforming version, 23 bytes
f(){getchar()-10?:f();}
Aceto, 9 5 4 bytes
read a value, negate it (!; implicitly casting to a boolean), and mirror horizontally if the value is truthy (|).
!
r|
x86 machine code on DOS, 13 bytes
00000000 43 b4 01 cd 21 3c 0d 75 f7 4b 74 f4 c3 |C...!<.u.Kt..|
0000000d
Commented assembly:
org 100h
section .text
; notice: on virtually every DOS bx starts at 0 at program start
; see http://www.fysnet.net/yourhelp.htm
start:
inc bx ; bx counts the number of read characters; increment it
mov ah,1
int 21h ; read a character into al
cmp al,0dh ; check if it's a newline
jne start ; repeat if it's not
dec bx ; got a newline; decrement the counter
jz start ; if the counter became 0, it means that we only read the
; newline; restart (with bx being 0, as on startup)
ret ; otherwise quit
Red, 20 16 Bytes
until[""<>ask""]
Explanation:
until does the code that's inside the [blocks] until it's true
<> checks empty string "" isn't returned by rest of code
ask "" prompts with "" (empty msg), returns user input
Thanks to @endo64 for the code
-4 bytes thanks to @sqlab
Javascript, 17 bytes
for(;!prompt(););
A for alternative to the while answer already here
x86 Assembler (NASM - Linux), 227 bytes
SECTION .bss
i: resb 5
SECTION .text
global _start
_start:
mov edx, 5
mov ecx, i
mov ebx, 0
mov eax, 3
int 80h
cmp byte [ecx], 0xa
je _start
mov eax, 1
int 80h
HTML5, 33 22 bytes
<form><input required>
<form><input required>
Explanation
The required attribute on the <input> causes the browser to inform the user "this field is required"-sort-of-message, if they do not enter a value. However, when they enter a value, the value is sent to the URL of the action attribute of the <form> (which in our case is the current file itself, since we haven't specified any value explicitly).
This was tested on the latest version of Google Chrome (version 55.0). May work in other browsers and versions.
Pyke, 2 bytes
W!
See the debug output to show it's actually reading input
W - do v
! - not(input())
- while ^
TI-BASIC, 2 bytes
:Prompt X
TI-BASIC does this automatically. Once input is given, it will quit.
Here is a GIF:
Watch the count on the enter key in the Key Press History. Created with TI-SmartView CE and ezgif.com.
Pure Bash, 19 bytes
A pure Bash solution using recursion in which a line is read into the variable $a (19 bytes):
read a;[ "$a" ]||$0
Notes
In all cases I tested for empty lines, which behaves accordingly. And the following special inputs that may break the behavior (but did not ;) ):
-xaoeu aoeu aoeu!
The only thing that breaks it is escaping the newline with \, or using a character. But how to handle these special characters is not mentioned in the original question.
Bash + line, 16 bytes
Another approach using recursion with parameter (16 bytes), using shift:
shift||$0 `line`
shift shifts the arguments (and defaults to shifting 1). Which fails if there is no argument, upon which it will try to execute itself again with the next read line as the first argument.
Notes
Instead of line you can also use head -n1, which is more common (but also longer).
In all cases I tested for empty lines, which behaves accordingly. And the following special inputs that may break the behavior (but did not ;) ):
-xaoeu aoeu aoeu!
The only thing that breaks it is escaping the newline with \, or using a character. But how to handle these special characters is not mentioned in the original question.
Pure Bash, 21 bytes
A pure Bash solution using shift and recursion with parameter (21 bytes):
shift||(read a;$0 $a)
shift shifts the arguments (and defaults to shifting 1). Which fails if there is no argument, upon which it will try to execute itself again with the next read line as the first argument.
Note that double quotes are here not needed if the line contains spaces, because it does not matter if it's just one word or multiple.
Notes
In all cases I tested for empty lines, which behaves accordingly. And the following special inputs that may break the behavior (but did not ;) ):
-xaoeu aoeu aoeu!
The only thing that breaks it is escaping the newline with \, or using a character. But how to handle these special characters is not mentioned in the original question.
Bash + line, 16 bytes
[ "`line`" ]||$0
Backticks are short for $(), to execute a command. line reads a line. If line is empty, then [ will return false, and thus $0 will be executed - the 0th argument which refers to itself. If there is any non-zero string, [ will return true and because of lazy evaluation $0 won't be executed (|| is a logical OR).
Notes
Instead of line you can also use head -n1, which is more common (but also longer).
In all cases I tested for empty lines, which behaves accordingly. And the following special inputs that may break the behavior (but did not ;) ):
-xaoeu aoeu aoeu!
The only thing that breaks it is escaping the newline with \, or using a character. But how to handle these special characters is not mentioned in the original question.
Excel VBA 25 bytes
while Inputbox(0)="":wend
You can run it via immediate window. It's a simple while loop with inputbox.
REXX, 24 bytes
do until n>''
pull n
end
Haskell, 19 17 bytes
f=do""<-getLine;f
Defines a function f that if it reads the empty line calls itself again. When reading a non-empty line an exception is raised and the recursion is stopped.
Edit: @Laikoni replaced the parameter with a pattern match and saved 2 bytes. Thanks!
Mathematica, 26 20 bytes
For[,Input[]==Null,]
Mathematica, 20 bytes
While[Input[]==Null]
ZX81 BASIC, 20 bytes
10 INPUT A$
20 IF NOT LEN A$ THEN RUN
Because ZX81 BASIC is tokenised, NOT LEN A$ is a byte shorter then A$<>"". Program lines count 5 bytes each including the line number.
QBIC, 7 5 bytes
≈A|_?
Saved 2 bytes because empty string is falsy.
Explanation:
≈ | WHILE <condition>
A A$ gets set by _? below. Empty string is false, so it stays in the WHILE
_? Ask the user for input, implicitly assign to A$
Scala, 21 bytes
while(readLine==""){}
Scala can run code as a script without the need for a class/main method so this is a complete program.
readLine is deprecated since Scala 2.11 but it's still available in 2.12
Ruby, 13 bytes
gets until/./
I wish gets took a Regexp argument.
Ruby, 19 bytes
while gets==?\n;end
MATL, 4 bytes
`jn~
This needs to be executed with the MATL interpreter running in Octave (not in Matlab). The reason is that in Matlab, unlike in Octave, the underlying function input('','s') (unevaluated input) interprets an input consisting of only spaces as empty input.
Gif or it didn't happen:
Explanation
` % Do...while loop
j % Take input as a string
n % Number of elements
~ % Negate. Gives true if number of elements was zero, and false otherwise
% End loop (implicit). If top of the stack is true: next iteration. Else: Exit
QBasic 4.5, 15 bytes
INPUT a$:IF a$=""THEN RUN
Asks for input, then checks if any was given. If not, RUN restarts the program.
Clojure, 32 bytes
(some seq(repeatedly read-line))
some returns the first true value of (seq x).
seq gives a sequence for a collection (e.g. a String) or nil if the collection is empty.
nil counts as false for some, so it will ignore any empty input, completing when a non-empty string is entered.
Perl, 15 12 bytes (11 + -n flag)
-3 bytes thanks to manatwork
1/0if$/ne$_
Explanation:
The -n flag places a read loop around the program, turning it into:
LINE:
while (<>) {
1/0 if $/ ne $_ # Spaces added for clarity.
}
Where "<>" reads a line from stdin to the variable $_. If the line contained more than the ending newline (ne is string inequality, $/ is the input record separator which defaults to newline), a division by zero is performed which causes the program to output an error message and terminate.
C# (.NET Core), 66 bytes
class C{static void Main(){for(;System.Console.ReadLine()!="";);}}
-6 bytes thanks to raznagul.
SpecBAS - 34 bytes
1 DO : INPUT a$: LOOP UNTIL a$<>""
Just loops until non-empty string is entered.
AWK, 8 11 bytes
NF{exit}
Wait for input. If the number of fields in input is more than 0, exit.
EDIT:
I've just realized that this doesn't work for input containing whitespace characters only. IFS needs to be set to empty string using -F "" command line option. Therefore +3 bytes.
CJam, 5 bytes
{l!}g
Try it online! (TIO doesn't really show the proper behaviour)
Explanation
{ e# Do:
l e# Read next line of input
! e# Boolean negate (empty strings are falsy)
}g e# Pop the top of stack, if truthy, repeat.
Swift, 22 bytes
while readLine()==""{}
Kotlin, 38 35 29 bytes
-3 bytes by negating any() rather than calling isEmpty()
-6 bytes thanks to Adám pointing out the function doesn't need to be named to be called
{while(!readLine()!!.any());}
called like so:
{while(!readLine()!!.any());}()
Lithp, 90 bytes
((import readline)(readline "?" #A::((f A)))(def f #A::(if(== "" A)((readline "?"(get f/1)
Try it online! (Also works on command line in node)
A side effect of the current parser is that not all trailing ) brackets are required. The very last one is, but the rest can be omitted saving quite a few bytes.
The readline module works in browser and via command line, and uses a callback. We exploit this to call readline before defining f, and save many bytes not needed all the closing brackets to invoke f after it's defined.
Bash, 51 bytes (39 without "#!/bin/bash")
It's my first time participating in PPCG, so dont be to rude ;D
#!/bin/bash
read a
while [ -z "$a" ]
do
read a
done
Jelly, 3 bytes
ɠṆ¿
Not much to look at on TIO, I'm afraid.
How it works
This is a niladic program, meaning that it takes no input arguments. The implicit argument and return value are both 0 in this case.
¿ (while) is a quick that pops two links from the link stack: a condition (Ṇ) and a body.
Ṇ is a monadic atom: flat logical NOT. If the previous return value is falsy (here, 0 or an empty string), it returns 1 and the body is called.
ɠ is a niladic atom; it reads a raw line from STDIN and returns the result.
Once ɠ reads a non-empty line, Ṇ returns 0 and we break out of the loop.
C, 52 bytes, 33 bytes, 29 bytes
-19 bytes thanks to Justin
-4 bytes thanks to Christoph
main(){while(getchar()==10);}
10 is equal to '\n' - In case this isn't obvious.
PowerShell, 20 Bytes
for(;!(read-host)){}
runs a for loop,
read-host prompts for input
if read-host returns nothing it evals to false, so we invert that !(...) and use that as the loop end check.
much shorter than any do{$a=read-host}while($a-eq"") type solution involving variables.
Batch, 35 bytes
@set s=
@set/ps=
@if "%s%"=="" %0
Rather unfortunately, Batch doesn't clear the variable if you don't enter anything.
C#, 36 bytes
_=>while(System.Console.Read()==13);
Compiles to a Action<int>.
Or if a full program is required, 62 bytes.
class P{static void Main(){while(System.Console.Read()==13);}}
05AB1E, 5 bytes
[IõÊ#
Explanation:
[ Start infinite loop
I One line of input
Ê Not equal to
õ Empty string
# Break if true
Perl 5, 8+1 (-p or -n flag) bytes
/./&&die
Takes input from stdin and dies as soon as the regex matches anything except a newline.
Java, 128 126 bytes
2 bytes thanks to Kevin Cruijssen.
import java.util.*;class a{public static void main(String[]a){for(Scanner s=new Scanner(System.in);s.nextLine().isEmpty(););}}
Java, 55 bytes
void f()throws Exception{while(System.in.read()==10);}}
If I remember correctly (it's been a while since I've been active on PPCG), my program can just be a function.
This is system specific; it only works on systems where the end-of-line character is a single newline. If the end-of-line character is instead a carriage return, replace the 10 with 13. On Windows, this doesn't work, as end-of-line on windows is \r\n.
This makes use of the fact that I can read directly from System.in.
PHP, 18 bytes
while(!readline())
QBasic, 34 bytes
INPUT A$
WHILE A$=""
INPUT A$
WEND
I think nothing can be more self-explanatory than that. To test, go to this website and copy-paste the following code in their text-editor :
10 INPUT A$
20 WHILE A$=""
30 INPUT A$
40 WEND
The reason why line numbers are required is that their website only supports unstructured BASIC.
sed, 4
/./q
Waits for a line of input that has 1 or more characters, then quits.
Try it online. But it works better on a live shell:
sed '/./q'


