Pasting into terminal including comments issue

The name of the pictureThe name of the pictureThe name of the pictureClash 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.







share|improve this question

















  • 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. zsh will 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
















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.







share|improve this question

















  • 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. zsh will 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












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.







share|improve this question













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.









share|improve this question












share|improve this question




share|improve this question








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. zsh will 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




    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. zsh will 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















active

oldest

votes











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















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



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes










 

draft saved


draft discarded


























 


draft saved


draft discarded














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













































































Popular posts from this blog

Peggy Mitchell

Palaiologos

The Forum (Inglewood, California)