g | x | w | all
Bytes Lang Time Link
070Bespoke250826T104225ZJosiah W
020Julia250825T195259ZMarcMush
009Uiua250824T202440ZJoao-3
043Scratch250823T082203ZRhaixer
024C clang170507T170206Zjdt
014><> Fish250821T132549Zmousetai
nanPiet + asciipiet250821T120120ZThemooni
005APL Dyalog Unicode250821T070842ZAdá
033Acc!!211209T235923ZDLosc
004Pip211209T231751ZDLosc
007APOL211209T201407ZGinger
031Batch211209T194025ZT3RR0R
026Python 3211209T184746ZAlan Bag
010APL Dyalog Unicode201220T123021ZKamila S
017JavaScript170504T050003ZArjun
022R170504T080351Zrturnbul
026VBScript170507T171648Zjdt
060Java170504T210145ZAAM111
079Java170507T164213ZKhaled.K
083C170507T162634ZKhaled.K
004Aceto170507T154201ZL3viatha
013x86 machine code on DOS170507T144017ZMatteo I
016Red170504T162103ZGeeky I
017Javascript170506T230012ZRuteNL
227x86 Assembler NASM Linux170506T152651ZreachC
022HTML5170504T061817ZArjun
002Pyke170506T114453ZBlue
002TIBASIC170504T154714ZScott Mi
019Pure Bash170505T180046ZYeti
016Bash + line170505T180546ZYeti
021Pure Bash170505T180254ZYeti
016Bash + line170505T100445ZYeti
025Excel VBA170505T172525ZStupid_I
026Tcl170505T160010Zsergiol
024REXX170505T154739Zidrougge
017Haskell170504T151322Znimi
020Mathematica170504T114858ZA Simmon
020Mathematica170505T075406Znumberma
020ZX81 BASIC170505T075042ZNeil
087Ruby170505T072000ZG B
005QBIC170504T163559Zsteenber
021Scala170504T225634Zpuhlen
013Ruby170504T192750Zhistocra
019Ruby170504T191108Zanna328p
004MATL170504T105404ZLuis Men
015QBasic 4.5170504T162852Zsteenber
019AHK170504T155003ZEngineer
032Clojure170504T151702Zmark
1211Perl170504T070406Zuser6883
066C# .NET Core170504T050534ZPavel
034SpecBAS170504T143221ZBrian
011AWK170504T130520ZMax Mikh
005CJam170504T132753ZBusiness
022Swift170504T131010ZCaleb Kl
029Kotlin170504T115447ZJustinw
090Lithp170504T120319ZAndrakis
5139Bash170504T081907ZNicolas
003Jelly170504T044841ZDennis
029C170504T055058Zegonr
020PowerShell170504T082120Zcolsw
035Batch170504T081136ZNeil
036C#170504T080315ZTheLetha
00505AB1E170504T075927ZOkx
081Perl 5170504T070616ZChris
126Java170504T055012ZLeaky Nu
004Charcoal170504T070211ZASCII-on
055Java170504T065145ZJustin
018PHP170504T060923Zegonr
026brainfuck170504T055835ZLeaky Nu
003Pyth170504T055204ZLeaky Nu
034QBasic170504T045846ZArjun
004sed170504T051035ZDigital
018Python 3170504T045754ZDennis

Bespoke, 70 bytes

program prompts input
if all NL,a repetition
anything other conclude-s

Loops while the inputted character minus 10 is zero.

Julia, 20 bytes

!_=readline()>""||!0

Attempt This Online!

verify

Uiua, 9 bytes

⍢⋅&sc≍∩""

Try it in the pad!

I wrote this code in such a way that it would require the least parentheses:

Scratch, 43 bytes

define(
ask()and wait
if<(answer)=()>then
(

enter image description here

C (clang), 24 bytes

f(*i){gets(i);*i||f(i);}

Try it online!

><> (Fish), 14 bytes

\,
\ia-?
\ia=?

Hover over any symbol to see what it does

Try it

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

Try Piet online!

Loops until it reads a character that isn't a LF, at which point the program terminates.

APL (Dyalog Unicode), 5 bytes

Full program.

→''≡⍞

Try it online!

 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.

APOL, 7 bytes

w(!(i))

This simply repeats until i returns a non-empty string.

Batch 31 bytes

@Set $=&Set/p$=&Set $ 2>nul||%0

Python 3, 26 bytes

a=""
while not a:a=input()

Try it online!

APL (Dyalog Unicode), 10 bytes

Doesn't seem to work in TIO, works for me in Dyalog APL 18.0

{0=≢⍞:∇0}0

Try it online!

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!

Try it online!

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:

enter image description here

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 ;) ):

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 ;) ):

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 ;) ):

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 ;) ):

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.

Tcl, 26

while {![gets stdin t]} {}

demo

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.

Ruby, 8 bytes (7 + '-n' flag)

~/./&&a

Try it online!

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:

enter image description here

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.

AHK, 19 bytes

While !a
InputBox,a

Not very interesting, I'm afraid.

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()!="";);}}

Try it online!

-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.

Try it online!

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());}()

Try it online!

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.

Try it online!

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

Try it online!

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(););}}

Try it online!

Charcoal, 4 bytes

W¬Sω

Explanation

W      While
  ¬S   Logical not of string input
     ω  Print ""

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())

brainfuck, 26 bytes

+[>,----------[[-]<[-]>]<]

Try it online!

Pyth, 3 bytes

W!w

Try it online!

Translated to Python:

while Pnot(input()):
 pass

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'

Python 3, 18 bytes

while''==input():0

Try it online!