semicolon pausing in bash
Clash 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"
linux bash shell
add a comment |Â
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"
linux bash shell
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 theabc
echo result? Try enteringdate
when you appear not to have a shell prompt...
â Jeff Schaller
Jul 3 at 13:45
Trysleep 0.2; echo "abc"; & echo "abc"
to have the same effect. You maybe want&&
instead of&
?
â RoVo
Jul 3 at 14:00
add a comment |Â
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"
linux bash shell
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"
linux bash shell
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 theabc
echo result? Try enteringdate
when you appear not to have a shell prompt...
â Jeff Schaller
Jul 3 at 13:45
Trysleep 0.2; echo "abc"; & echo "abc"
to have the same effect. You maybe want&&
instead of&
?
â RoVo
Jul 3 at 14:00
add a comment |Â
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 theabc
echo result? Try enteringdate
when you appear not to have a shell prompt...
â Jeff Schaller
Jul 3 at 13:45
Trysleep 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
add a comment |Â
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.
add a comment |Â
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.
add a comment |Â
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.
add a comment |Â
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.
&
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.
answered Jul 3 at 13:53
ilkkachu
47.3k668130
47.3k668130
add a comment |Â
add a comment |Â
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%2f453223%2fsemicolon-pausing-in-bash%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
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 enteringdate
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