rebar3 icon indicating copy to clipboard operation
rebar3 copied to clipboard

Evaluating expressions: {ok, Result} term is not unwrapped when Result includes new line character \n

Open bsnote opened this issue 8 months ago • 0 comments

Replicating the issue:

$ rebar3 new release foo
===> Writing foo/apps/foo/src/foo_app.erl
===> Writing foo/apps/foo/src/foo_sup.erl
===> Writing foo/apps/foo/src/foo.app.src
===> Writing foo/rebar.config
===> Writing foo/config/sys.config
===> Writing foo/config/vm.args
===> Writing foo/.gitignore
===> Writing foo/LICENSE.md
===> Writing foo/README.md
$ cd foo
$ rebar3 release
===> Verifying dependencies...
===> Analyzing applications...
===> Compiling foo
===> Assembling release foo-0.1.0...
===> Release successfully assembled: _build/default/rel/foo
$ _build/default/rel/foo/bin/foo daemon
$ _build/default/rel/foo/bin/foo eval "\"hello there\"."
"hello there"
$ _build/default/rel/foo/bin/foo eval "\"hello\\nthere\"."
{ok, "hello
there"}

As it can be seen, the result of executing _build/default/rel/foo/bin/foo eval "\"hello there\"." is

"hello there"

and the result of executing _build/default/rel/foo/bin/foo eval "\"hello\\nthere\"." is

{ok, "hello
there"}

In the second case the {ok, Result} term is not unwrapped because the following sed in the generated script does not match multiline input:

echo "$result" | sed 's/^{ok, \(.*\)}$/\1/'

bsnote avatar Apr 24 '25 09:04 bsnote