Skip to content

Commit

Permalink
ivy: remove extra blank line in print (#178)
Browse files Browse the repository at this point in the history
The blank line kind of matches interactive mode,
but it is annoying in a long list of debug prints.

This seems wrong:

	% {echo 1; echo 2} >x; ivy x
	1
	2
	% {echo print 1; echo print 2} > x; ivy x
	1

	1
	2

	2
	%

After this CL, there are no blank lines in the second output.

Interactively, before:

	% {echo 1; echo 2} | ivy
	1

	2

	% {echo print 1; echo print 2} | ivy
	1

	1

	2

	2

	%

After:

	% {echo print 1; echo print 2} | ivy
	1
	1

	2
	2

	%

Fixes #177.
  • Loading branch information
rsc authored Dec 13, 2024
1 parent 9933fa4 commit eeeab92
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions testdata/unary_int.ivy
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,10 @@ box 3

first 3
3

print 1; print 2
1
2
1 2


2 changes: 1 addition & 1 deletion value/unary.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ var IvyEval func(context Context, s string) Value
var UnaryOps = make(map[string]UnaryOp)

func printValue(c Context, v Value) Value {
fmt.Printf("%s\n\n", v.Sprint(c.Config()))
fmt.Fprintln(c.Config().Output(), v.Sprint(c.Config()))
return v
}

Expand Down

0 comments on commit eeeab92

Please sign in to comment.