Skip to content

use ^D as stdin separator #17

@dolmen

Description

@dolmen

When the program code comes from stdin, allow to use ^D (EOT, \u0004, ^V^D when entered in an interactive Unix terminal) as a separator character defining the end of the program and the beginning of stdin as input to the program.

$ printf 'Hello' | goeval 'b,_:=io.ReadAll(os.Stdin);fmt.Printf("[%s]\n", b)'
[Hello]
$ printf 'b,_:=io.ReadAll(os.Stdin);fmt.Printf("[%%s]\\n", b)\004Hello' | goeval -
[Hello]

Implementation note: this requires to do either unbuffered read (to not read beyond ^D) or to feed the child program with the remaining buffered data.

$ stty -g | sed 's/.*:\(lnext=[^:]*\):.*/\1/'   # ^V definition in terminal settings allowing to use it to escape ^D
lnext=16

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions