# \`read(stdin, Char)\` in REPL vs script

**URL:** <https://discourse.julialang.org/t/read-stdin-char-in-repl-vs-script/119014>\
**Category:** General Usage\
**Created:** [September 4, 2024, 12:07am UTC](https://discourse.julialang.org/t/read-stdin-char-in-repl-vs-script/119014 "2024-09-04T00:07:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sadish-d](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sadish-d/32/48058_2.png) [@sadish-d](https://discourse.julialang.org/u/sadish-d)\
**Post date:** [September 4, 2024, 12:07am UTC](https://discourse.julialang.org/t/read-stdin-char-in-repl-vs-script/119014/1 "2024-09-04T00:07:38Z")

</div>

I have a .jl file with one line script:

```julia
i = read(stdin, Char)

```

If I run it, and type `ab` in the REPL (without pressing the return key), I get:

```julia
a'b': ASCII/Unicode U+0062 (category Ll: Letter, lowercase)

julia> i
'b': ASCII/Unicode U+0062 (category Ll: Letter, lowercase)

```

`i` takes the second character entered (`b`).

Here is the behavior in REPL (need to press the return key after typing `ab`)

```julia
julia> i = read(stdin, Char)
ab
'a': ASCII/Unicode U+0061 (category Ll: Letter, lowercase)

julia> b
ERROR: UndefVarError: `b` not defined

julia> i
'a': ASCII/Unicode U+0061 (category Ll: Letter, lowercase)

```

`i` takes the first character entered (`a`).

So `read` is reading different values depending on whether it is run in a script vs in REPL, and it sometimes requires pressing the return key while other times it doesn’t.

How do I make sense of this?

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [September 4, 2024, 12:18am UTC](https://discourse.julialang.org/t/read-stdin-char-in-repl-vs-script/119014/2 "2024-09-04T00:18:14Z")

</div>

> [@sadish-d](#):
>
> If I run it, and type `ab` in the REPL

How are you running the script in the REPL? `include`?

---

<div class="post-metadata">

**Author:** ![sadish-d](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sadish-d/32/48058_2.png) [@sadish-d](https://discourse.julialang.org/u/sadish-d)\
**Post date:** [September 4, 2024, 12:30am UTC](https://discourse.julialang.org/t/read-stdin-char-in-repl-vs-script/119014/3 "2024-09-04T00:30:09Z")

</div>

I’m hitting the play button on VScode.

If I use `include`, I get the same behavior as entering the line directly in the REPL.

---

<div class="post-metadata">

**Author:** ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)\
**Post date:** [September 4, 2024, 6:02am UTC](https://discourse.julialang.org/t/read-stdin-char-in-repl-vs-script/119014/4 "2024-09-04T06:02:41Z")

</div>

Wonder if this stems from the same problem as this: [Inline evaluation: readline() is broken · Issue #785 · julia-vscode/julia-vscode · GitHub](https://github.com/julia-vscode/julia-vscode/issues/785)

---

<div class="post-metadata">

**Author:** ![sadish-d](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sadish-d/32/48058_2.png) [@sadish-d](https://discourse.julialang.org/u/sadish-d)\
**Post date:** [September 5, 2024, 2:26am UTC](https://discourse.julialang.org/t/read-stdin-char-in-repl-vs-script/119014/5 "2024-09-05T02:26:21Z")

</div>

submitted an issue [read(stdin, Char) behaves differently in REPL vs when run as a script in VSCode · Issue #55692 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues/55692)
