1

For example I am opening an interactive command line window.

docker exec -it container rails c

When I paste a multiple-line command, it evaluate every line instead of pasting a block. How can I configure it as not to evaluate?

Order.last
     .user
     .id
1
  • This is not really specific to docker, it's a common challenge with all ruby REPL instances (irb / pry / are-there-any-other?) Commented Sep 27, 2021 at 8:49

1 Answer 1

2

Ah, simple trick here: type begin + enter, paste the code, type end:

begin
  Order.last
       .user
       .id
end

It cannot and should not be configurable. The reason is that the console cannot posisible know when you have finished typing the whole command, as the first line is a completely valid ruby statement. Things are slightly different if you adapt different coding style:

Order.last.
      user.
      id

The code above will work once copied to console (but gosh, I really hate that style!) because it is clear to the interpreter that the statement is not completed yet - similarly to missing closing bracket or quote. Wrapping the code in begin/end have the same effect - it tells the interpreter that the code is not yet completed, so it awaits for the final end.

Sign up to request clarification or add additional context in comments.

1 Comment

Nice workaround. I can paste code block locally, which give me a sense its possible with Docker.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.