semicolon pausing in bash

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












Why does this shell script:



$ curl -d "asd" 0.0.0.0/abc & echo "abc";


results in me having to press enter before it enters the shell again. The curl is just a post request to a simple web server which returns abc.



However, this script does not require me to press enter before entering the shell again



$ echo "abc" & echo "abc"






share|improve this question

















  • 1




    I cannot reproduce the problem you're seeing.
    – Andy Dalton
    Jul 3 at 13:40






  • 1




    It doesn't require you to press enter. Only if you'd like to have a new prompt. Try giving another command instead of pressing just enter. It has nothing to do with the semicolon, but more to do with the single ampersand.
    – Kusalananda
    Jul 3 at 13:44







  • 1




    is it a timing issue where you have a shell prompt but don't see it ahead of the abc echo result? Try entering date when you appear not to have a shell prompt...
    – Jeff Schaller
    Jul 3 at 13:45










  • Try sleep 0.2; echo "abc"; & echo "abc" to have the same effect. You maybe want && instead of & ?
    – RoVo
    Jul 3 at 14:00















up vote
0
down vote

favorite












Why does this shell script:



$ curl -d "asd" 0.0.0.0/abc & echo "abc";


results in me having to press enter before it enters the shell again. The curl is just a post request to a simple web server which returns abc.



However, this script does not require me to press enter before entering the shell again



$ echo "abc" & echo "abc"






share|improve this question

















  • 1




    I cannot reproduce the problem you're seeing.
    – Andy Dalton
    Jul 3 at 13:40






  • 1




    It doesn't require you to press enter. Only if you'd like to have a new prompt. Try giving another command instead of pressing just enter. It has nothing to do with the semicolon, but more to do with the single ampersand.
    – Kusalananda
    Jul 3 at 13:44







  • 1




    is it a timing issue where you have a shell prompt but don't see it ahead of the abc echo result? Try entering date when you appear not to have a shell prompt...
    – Jeff Schaller
    Jul 3 at 13:45










  • Try sleep 0.2; echo "abc"; & echo "abc" to have the same effect. You maybe want && instead of & ?
    – RoVo
    Jul 3 at 14:00













up vote
0
down vote

favorite









up vote
0
down vote

favorite











Why does this shell script:



$ curl -d "asd" 0.0.0.0/abc & echo "abc";


results in me having to press enter before it enters the shell again. The curl is just a post request to a simple web server which returns abc.



However, this script does not require me to press enter before entering the shell again



$ echo "abc" & echo "abc"






share|improve this question













Why does this shell script:



$ curl -d "asd" 0.0.0.0/abc & echo "abc";


results in me having to press enter before it enters the shell again. The curl is just a post request to a simple web server which returns abc.



However, this script does not require me to press enter before entering the shell again



$ echo "abc" & echo "abc"








share|improve this question












share|improve this question




share|improve this question








edited Jul 3 at 14:22









slm♦

233k65479651




233k65479651









asked Jul 3 at 13:29









aceminer

1034




1034







  • 1




    I cannot reproduce the problem you're seeing.
    – Andy Dalton
    Jul 3 at 13:40






  • 1




    It doesn't require you to press enter. Only if you'd like to have a new prompt. Try giving another command instead of pressing just enter. It has nothing to do with the semicolon, but more to do with the single ampersand.
    – Kusalananda
    Jul 3 at 13:44







  • 1




    is it a timing issue where you have a shell prompt but don't see it ahead of the abc echo result? Try entering date when you appear not to have a shell prompt...
    – Jeff Schaller
    Jul 3 at 13:45










  • Try sleep 0.2; echo "abc"; & echo "abc" to have the same effect. You maybe want && instead of & ?
    – RoVo
    Jul 3 at 14:00













  • 1




    I cannot reproduce the problem you're seeing.
    – Andy Dalton
    Jul 3 at 13:40






  • 1




    It doesn't require you to press enter. Only if you'd like to have a new prompt. Try giving another command instead of pressing just enter. It has nothing to do with the semicolon, but more to do with the single ampersand.
    – Kusalananda
    Jul 3 at 13:44







  • 1




    is it a timing issue where you have a shell prompt but don't see it ahead of the abc echo result? Try entering date when you appear not to have a shell prompt...
    – Jeff Schaller
    Jul 3 at 13:45










  • Try sleep 0.2; echo "abc"; & echo "abc" to have the same effect. You maybe want && instead of & ?
    – RoVo
    Jul 3 at 14:00








1




1




I cannot reproduce the problem you're seeing.
– Andy Dalton
Jul 3 at 13:40




I cannot reproduce the problem you're seeing.
– Andy Dalton
Jul 3 at 13:40




1




1




It doesn't require you to press enter. Only if you'd like to have a new prompt. Try giving another command instead of pressing just enter. It has nothing to do with the semicolon, but more to do with the single ampersand.
– Kusalananda
Jul 3 at 13:44





It doesn't require you to press enter. Only if you'd like to have a new prompt. Try giving another command instead of pressing just enter. It has nothing to do with the semicolon, but more to do with the single ampersand.
– Kusalananda
Jul 3 at 13:44





1




1




is it a timing issue where you have a shell prompt but don't see it ahead of the abc echo result? Try entering date when you appear not to have a shell prompt...
– Jeff Schaller
Jul 3 at 13:45




is it a timing issue where you have a shell prompt but don't see it ahead of the abc echo result? Try entering date when you appear not to have a shell prompt...
– Jeff Schaller
Jul 3 at 13:45












Try sleep 0.2; echo "abc"; & echo "abc" to have the same effect. You maybe want && instead of & ?
– RoVo
Jul 3 at 14:00





Try sleep 0.2; echo "abc"; & echo "abc" to have the same effect. You maybe want && instead of & ?
– RoVo
Jul 3 at 14:00











1 Answer
1






active

oldest

votes

















up vote
6
down vote



accepted










& sends the curl command to the background, where it will run whenever it runs, the shell will not wait for it (it does print the job number and PID). Instead the shell goes on to run echo, which, since it's builtin, may well run faster than curl, so the shell finishes with echo and prints the prompt before curl gets to produce any output.



E.g. the output I get with Bash:



bash ~ $ curl -d "asd" 0.0.0.0/abc & echo "abc";
[1] 26757
abc
bash ~ $ curl: (7) Failed to connect to 0.0.0.0 port 80: Connection refused


There's the prompt on the start of the last line.



Hitting Enter here has the shell print another prompt, at which point it also checks if the background job has completed, and prints a note about that:



[1]+ Exit 7 curl -d "asd" 0.0.0.0/abc
bash ~ $


Now, I'm not sure what exactly it is you're doing, but having background jobs that print to the terminal is a bit awkward because of this, so you might want to redirect the output of curl elsewhere, or run it in the foreground. E.g. curl something; echo curl done would run curl first, then echo, and curl something && echo curl done would only run echo if curl doesn't fail.






share|improve this answer





















    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%2f453223%2fsemicolon-pausing-in-bash%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    6
    down vote



    accepted










    & sends the curl command to the background, where it will run whenever it runs, the shell will not wait for it (it does print the job number and PID). Instead the shell goes on to run echo, which, since it's builtin, may well run faster than curl, so the shell finishes with echo and prints the prompt before curl gets to produce any output.



    E.g. the output I get with Bash:



    bash ~ $ curl -d "asd" 0.0.0.0/abc & echo "abc";
    [1] 26757
    abc
    bash ~ $ curl: (7) Failed to connect to 0.0.0.0 port 80: Connection refused


    There's the prompt on the start of the last line.



    Hitting Enter here has the shell print another prompt, at which point it also checks if the background job has completed, and prints a note about that:



    [1]+ Exit 7 curl -d "asd" 0.0.0.0/abc
    bash ~ $


    Now, I'm not sure what exactly it is you're doing, but having background jobs that print to the terminal is a bit awkward because of this, so you might want to redirect the output of curl elsewhere, or run it in the foreground. E.g. curl something; echo curl done would run curl first, then echo, and curl something && echo curl done would only run echo if curl doesn't fail.






    share|improve this answer

























      up vote
      6
      down vote



      accepted










      & sends the curl command to the background, where it will run whenever it runs, the shell will not wait for it (it does print the job number and PID). Instead the shell goes on to run echo, which, since it's builtin, may well run faster than curl, so the shell finishes with echo and prints the prompt before curl gets to produce any output.



      E.g. the output I get with Bash:



      bash ~ $ curl -d "asd" 0.0.0.0/abc & echo "abc";
      [1] 26757
      abc
      bash ~ $ curl: (7) Failed to connect to 0.0.0.0 port 80: Connection refused


      There's the prompt on the start of the last line.



      Hitting Enter here has the shell print another prompt, at which point it also checks if the background job has completed, and prints a note about that:



      [1]+ Exit 7 curl -d "asd" 0.0.0.0/abc
      bash ~ $


      Now, I'm not sure what exactly it is you're doing, but having background jobs that print to the terminal is a bit awkward because of this, so you might want to redirect the output of curl elsewhere, or run it in the foreground. E.g. curl something; echo curl done would run curl first, then echo, and curl something && echo curl done would only run echo if curl doesn't fail.






      share|improve this answer























        up vote
        6
        down vote



        accepted







        up vote
        6
        down vote



        accepted






        & sends the curl command to the background, where it will run whenever it runs, the shell will not wait for it (it does print the job number and PID). Instead the shell goes on to run echo, which, since it's builtin, may well run faster than curl, so the shell finishes with echo and prints the prompt before curl gets to produce any output.



        E.g. the output I get with Bash:



        bash ~ $ curl -d "asd" 0.0.0.0/abc & echo "abc";
        [1] 26757
        abc
        bash ~ $ curl: (7) Failed to connect to 0.0.0.0 port 80: Connection refused


        There's the prompt on the start of the last line.



        Hitting Enter here has the shell print another prompt, at which point it also checks if the background job has completed, and prints a note about that:



        [1]+ Exit 7 curl -d "asd" 0.0.0.0/abc
        bash ~ $


        Now, I'm not sure what exactly it is you're doing, but having background jobs that print to the terminal is a bit awkward because of this, so you might want to redirect the output of curl elsewhere, or run it in the foreground. E.g. curl something; echo curl done would run curl first, then echo, and curl something && echo curl done would only run echo if curl doesn't fail.






        share|improve this answer













        & sends the curl command to the background, where it will run whenever it runs, the shell will not wait for it (it does print the job number and PID). Instead the shell goes on to run echo, which, since it's builtin, may well run faster than curl, so the shell finishes with echo and prints the prompt before curl gets to produce any output.



        E.g. the output I get with Bash:



        bash ~ $ curl -d "asd" 0.0.0.0/abc & echo "abc";
        [1] 26757
        abc
        bash ~ $ curl: (7) Failed to connect to 0.0.0.0 port 80: Connection refused


        There's the prompt on the start of the last line.



        Hitting Enter here has the shell print another prompt, at which point it also checks if the background job has completed, and prints a note about that:



        [1]+ Exit 7 curl -d "asd" 0.0.0.0/abc
        bash ~ $


        Now, I'm not sure what exactly it is you're doing, but having background jobs that print to the terminal is a bit awkward because of this, so you might want to redirect the output of curl elsewhere, or run it in the foreground. E.g. curl something; echo curl done would run curl first, then echo, and curl something && echo curl done would only run echo if curl doesn't fail.







        share|improve this answer













        share|improve this answer



        share|improve this answer











        answered Jul 3 at 13:53









        ilkkachu

        47.3k668130




        47.3k668130






















             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f453223%2fsemicolon-pausing-in-bash%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Displaying single band from multi-band raster using QGIS

            How many registers does an x86_64 CPU actually have?