Pasting into terminal including comments issue

Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
3
down vote
favorite
This is somehow a follow-up to my last question: Pasting multiple commands into terminal stops at user input
Pasting the following to the terminal works as expected:
(
echo test1
# some comment
echo test2
)
But pressing arrow up to repeat that command gives the following obviously wrong command:
( echo test1 echo test2; )
Pasting the same without the comment and pressing arrow up gives the expected command:
(echo test1; echo test2)
An easy workaround is to add ; before each line with a comment.
But why is this the case ? Is it a bug ?
I use bash. Same behavior in gnome-terminal and tilix.
bash terminal clipboard
 |Â
show 4 more comments
up vote
3
down vote
favorite
This is somehow a follow-up to my last question: Pasting multiple commands into terminal stops at user input
Pasting the following to the terminal works as expected:
(
echo test1
# some comment
echo test2
)
But pressing arrow up to repeat that command gives the following obviously wrong command:
( echo test1 echo test2; )
Pasting the same without the comment and pressing arrow up gives the expected command:
(echo test1; echo test2)
An easy workaround is to add ; before each line with a comment.
But why is this the case ? Is it a bug ?
I use bash. Same behavior in gnome-terminal and tilix.
bash terminal clipboard
1
As I commented on your previous question, don't past shell code inte the terminal. If you have a workflow that depends on you pasting shell code into a terminal, then you really seriously have to reconsider that workflow.
â Kusalananda
Jul 20 at 9:42
Please edit your question and tell us what shell you are using and what terminal emulator.
â terdonâ¦
Jul 20 at 9:46
Using bracketed paste as suggested in JoL's answer handles this better.
â muru
Jul 20 at 9:46
This depends on the shell you are using. Using e.g.zshwill work as expected.
â Anderson
Jul 20 at 9:47
1
@Kusalananda that doesn't change the fact that this is an interesting behavior though. Why would the comments change things? And we often paste a few lines of code into a terminal, that isn't always a bad thing.
â terdonâ¦
Jul 20 at 9:48
 |Â
show 4 more comments
up vote
3
down vote
favorite
up vote
3
down vote
favorite
This is somehow a follow-up to my last question: Pasting multiple commands into terminal stops at user input
Pasting the following to the terminal works as expected:
(
echo test1
# some comment
echo test2
)
But pressing arrow up to repeat that command gives the following obviously wrong command:
( echo test1 echo test2; )
Pasting the same without the comment and pressing arrow up gives the expected command:
(echo test1; echo test2)
An easy workaround is to add ; before each line with a comment.
But why is this the case ? Is it a bug ?
I use bash. Same behavior in gnome-terminal and tilix.
bash terminal clipboard
This is somehow a follow-up to my last question: Pasting multiple commands into terminal stops at user input
Pasting the following to the terminal works as expected:
(
echo test1
# some comment
echo test2
)
But pressing arrow up to repeat that command gives the following obviously wrong command:
( echo test1 echo test2; )
Pasting the same without the comment and pressing arrow up gives the expected command:
(echo test1; echo test2)
An easy workaround is to add ; before each line with a comment.
But why is this the case ? Is it a bug ?
I use bash. Same behavior in gnome-terminal and tilix.
bash terminal clipboard
edited Jul 20 at 9:54
terdonâ¦
121k28226398
121k28226398
asked Jul 20 at 9:39
RoVo
76219
76219
1
As I commented on your previous question, don't past shell code inte the terminal. If you have a workflow that depends on you pasting shell code into a terminal, then you really seriously have to reconsider that workflow.
â Kusalananda
Jul 20 at 9:42
Please edit your question and tell us what shell you are using and what terminal emulator.
â terdonâ¦
Jul 20 at 9:46
Using bracketed paste as suggested in JoL's answer handles this better.
â muru
Jul 20 at 9:46
This depends on the shell you are using. Using e.g.zshwill work as expected.
â Anderson
Jul 20 at 9:47
1
@Kusalananda that doesn't change the fact that this is an interesting behavior though. Why would the comments change things? And we often paste a few lines of code into a terminal, that isn't always a bad thing.
â terdonâ¦
Jul 20 at 9:48
 |Â
show 4 more comments
1
As I commented on your previous question, don't past shell code inte the terminal. If you have a workflow that depends on you pasting shell code into a terminal, then you really seriously have to reconsider that workflow.
â Kusalananda
Jul 20 at 9:42
Please edit your question and tell us what shell you are using and what terminal emulator.
â terdonâ¦
Jul 20 at 9:46
Using bracketed paste as suggested in JoL's answer handles this better.
â muru
Jul 20 at 9:46
This depends on the shell you are using. Using e.g.zshwill work as expected.
â Anderson
Jul 20 at 9:47
1
@Kusalananda that doesn't change the fact that this is an interesting behavior though. Why would the comments change things? And we often paste a few lines of code into a terminal, that isn't always a bad thing.
â terdonâ¦
Jul 20 at 9:48
1
1
As I commented on your previous question, don't past shell code inte the terminal. If you have a workflow that depends on you pasting shell code into a terminal, then you really seriously have to reconsider that workflow.
â Kusalananda
Jul 20 at 9:42
As I commented on your previous question, don't past shell code inte the terminal. If you have a workflow that depends on you pasting shell code into a terminal, then you really seriously have to reconsider that workflow.
â Kusalananda
Jul 20 at 9:42
Please edit your question and tell us what shell you are using and what terminal emulator.
â terdonâ¦
Jul 20 at 9:46
Please edit your question and tell us what shell you are using and what terminal emulator.
â terdonâ¦
Jul 20 at 9:46
Using bracketed paste as suggested in JoL's answer handles this better.
â muru
Jul 20 at 9:46
Using bracketed paste as suggested in JoL's answer handles this better.
â muru
Jul 20 at 9:46
This depends on the shell you are using. Using e.g.
zsh will work as expected.â Anderson
Jul 20 at 9:47
This depends on the shell you are using. Using e.g.
zsh will work as expected.â Anderson
Jul 20 at 9:47
1
1
@Kusalananda that doesn't change the fact that this is an interesting behavior though. Why would the comments change things? And we often paste a few lines of code into a terminal, that isn't always a bad thing.
â terdonâ¦
Jul 20 at 9:48
@Kusalananda that doesn't change the fact that this is an interesting behavior though. Why would the comments change things? And we often paste a few lines of code into a terminal, that isn't always a bad thing.
â terdonâ¦
Jul 20 at 9:48
 |Â
show 4 more comments
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f457395%2fpasting-into-terminal-including-comments-issue%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
As I commented on your previous question, don't past shell code inte the terminal. If you have a workflow that depends on you pasting shell code into a terminal, then you really seriously have to reconsider that workflow.
â Kusalananda
Jul 20 at 9:42
Please edit your question and tell us what shell you are using and what terminal emulator.
â terdonâ¦
Jul 20 at 9:46
Using bracketed paste as suggested in JoL's answer handles this better.
â muru
Jul 20 at 9:46
This depends on the shell you are using. Using e.g.
zshwill work as expected.â Anderson
Jul 20 at 9:47
1
@Kusalananda that doesn't change the fact that this is an interesting behavior though. Why would the comments change things? And we often paste a few lines of code into a terminal, that isn't always a bad thing.
â terdonâ¦
Jul 20 at 9:48