I paste a code in WSL but I get only part of it
up vote
1
down vote
favorite
I use Ubuntu 16.04 (xenial) via WSL.
I copy this code
#!/bin/bash
read -p "Have you created db credentials already?" yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit;;
esac
When I paste it in Ubuntu I get only part of it:
read -p "Have you created db credentials already?" yn
Have you created db credentials already?
Why when it is pasted, it is pasted partially?
Update
I copy the code from GitHub, when the case
conditions are indented with tabs and when the code is without a line break in the last line (no extra empty note after the last line).
16.04 command-line windows-subsystem-for-linux paste
add a comment |
up vote
1
down vote
favorite
I use Ubuntu 16.04 (xenial) via WSL.
I copy this code
#!/bin/bash
read -p "Have you created db credentials already?" yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit;;
esac
When I paste it in Ubuntu I get only part of it:
read -p "Have you created db credentials already?" yn
Have you created db credentials already?
Why when it is pasted, it is pasted partially?
Update
I copy the code from GitHub, when the case
conditions are indented with tabs and when the code is without a line break in the last line (no extra empty note after the last line).
16.04 command-line windows-subsystem-for-linux paste
Can't understand why this was down voted.
– JohnDoea
Nov 18 at 6:02
This usage is incorrect. Use shell script file instead of copying and pasting into terminal.
– Alvin Liang
Nov 18 at 19:28
@AlvinLiang I see no reason why it's necessarily incorrect, I have good experience with copy-pasting (when I find it elegant) or executing a script directly from GitHub without downloading it withgit
which is even more elegant: askubuntu.com/questions/992448/… but yes, indeed the usual way is to download a program with git and execute locally, it's just not something I want to do here.
– JohnDoea
Nov 18 at 22:41
1
It's incorrect because paste is an input behavior, and read -p expects user input. Even if it does not stop your paste the behavior will not be correct.
– Alvin Liang
2 days ago
1
@AlvinLiang seems what you write indicated it can only be run as part of a script and not as a command-set pasted in the terminal. This should be an answer IMO.
– JohnDoea
2 days ago
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I use Ubuntu 16.04 (xenial) via WSL.
I copy this code
#!/bin/bash
read -p "Have you created db credentials already?" yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit;;
esac
When I paste it in Ubuntu I get only part of it:
read -p "Have you created db credentials already?" yn
Have you created db credentials already?
Why when it is pasted, it is pasted partially?
Update
I copy the code from GitHub, when the case
conditions are indented with tabs and when the code is without a line break in the last line (no extra empty note after the last line).
16.04 command-line windows-subsystem-for-linux paste
I use Ubuntu 16.04 (xenial) via WSL.
I copy this code
#!/bin/bash
read -p "Have you created db credentials already?" yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit;;
esac
When I paste it in Ubuntu I get only part of it:
read -p "Have you created db credentials already?" yn
Have you created db credentials already?
Why when it is pasted, it is pasted partially?
Update
I copy the code from GitHub, when the case
conditions are indented with tabs and when the code is without a line break in the last line (no extra empty note after the last line).
16.04 command-line windows-subsystem-for-linux paste
16.04 command-line windows-subsystem-for-linux paste
edited 2 days ago
asked Nov 17 at 9:23
JohnDoea
11592157
11592157
Can't understand why this was down voted.
– JohnDoea
Nov 18 at 6:02
This usage is incorrect. Use shell script file instead of copying and pasting into terminal.
– Alvin Liang
Nov 18 at 19:28
@AlvinLiang I see no reason why it's necessarily incorrect, I have good experience with copy-pasting (when I find it elegant) or executing a script directly from GitHub without downloading it withgit
which is even more elegant: askubuntu.com/questions/992448/… but yes, indeed the usual way is to download a program with git and execute locally, it's just not something I want to do here.
– JohnDoea
Nov 18 at 22:41
1
It's incorrect because paste is an input behavior, and read -p expects user input. Even if it does not stop your paste the behavior will not be correct.
– Alvin Liang
2 days ago
1
@AlvinLiang seems what you write indicated it can only be run as part of a script and not as a command-set pasted in the terminal. This should be an answer IMO.
– JohnDoea
2 days ago
add a comment |
Can't understand why this was down voted.
– JohnDoea
Nov 18 at 6:02
This usage is incorrect. Use shell script file instead of copying and pasting into terminal.
– Alvin Liang
Nov 18 at 19:28
@AlvinLiang I see no reason why it's necessarily incorrect, I have good experience with copy-pasting (when I find it elegant) or executing a script directly from GitHub without downloading it withgit
which is even more elegant: askubuntu.com/questions/992448/… but yes, indeed the usual way is to download a program with git and execute locally, it's just not something I want to do here.
– JohnDoea
Nov 18 at 22:41
1
It's incorrect because paste is an input behavior, and read -p expects user input. Even if it does not stop your paste the behavior will not be correct.
– Alvin Liang
2 days ago
1
@AlvinLiang seems what you write indicated it can only be run as part of a script and not as a command-set pasted in the terminal. This should be an answer IMO.
– JohnDoea
2 days ago
Can't understand why this was down voted.
– JohnDoea
Nov 18 at 6:02
Can't understand why this was down voted.
– JohnDoea
Nov 18 at 6:02
This usage is incorrect. Use shell script file instead of copying and pasting into terminal.
– Alvin Liang
Nov 18 at 19:28
This usage is incorrect. Use shell script file instead of copying and pasting into terminal.
– Alvin Liang
Nov 18 at 19:28
@AlvinLiang I see no reason why it's necessarily incorrect, I have good experience with copy-pasting (when I find it elegant) or executing a script directly from GitHub without downloading it with
git
which is even more elegant: askubuntu.com/questions/992448/… but yes, indeed the usual way is to download a program with git and execute locally, it's just not something I want to do here.– JohnDoea
Nov 18 at 22:41
@AlvinLiang I see no reason why it's necessarily incorrect, I have good experience with copy-pasting (when I find it elegant) or executing a script directly from GitHub without downloading it with
git
which is even more elegant: askubuntu.com/questions/992448/… but yes, indeed the usual way is to download a program with git and execute locally, it's just not something I want to do here.– JohnDoea
Nov 18 at 22:41
1
1
It's incorrect because paste is an input behavior, and read -p expects user input. Even if it does not stop your paste the behavior will not be correct.
– Alvin Liang
2 days ago
It's incorrect because paste is an input behavior, and read -p expects user input. Even if it does not stop your paste the behavior will not be correct.
– Alvin Liang
2 days ago
1
1
@AlvinLiang seems what you write indicated it can only be run as part of a script and not as a command-set pasted in the terminal. This should be an answer IMO.
– JohnDoea
2 days ago
@AlvinLiang seems what you write indicated it can only be run as part of a script and not as a command-set pasted in the terminal. This should be an answer IMO.
– JohnDoea
2 days ago
add a comment |
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
As soon as "read -p" line is invoked, terminal clears your original paste buffer because it's expecting meaningful user input, and you cannot just paste it into terminal like this.
If you don't feel like creating a script file, press ctrl-x and then ctrl-e in the terminal, it will bring up the default editor. Paste it into the editor, save and exit, dash will run you script correctly from a temp file.
The correct default behavior: after press ctrl+x and then ctrl+e, the nano editor should be brought up. Paste you script in to the nano editor and save/exit, dash will run the script.
– Alvin Liang
2 days ago
nano
does bring nano up. Anyway, I createdx.sh
with the code and executed the file. Hitting N executedbreak
but hitting Y brought an error;x.sh: line 4: break: only meaningful in a
for',while', or
until' loop`. Do you have an idea why?
– JohnDoea
2 days ago
1
This is correct response, because your break command is meaningless here. You don't need to add break in every switch option like in C.
– Alvin Liang
2 days ago
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
As soon as "read -p" line is invoked, terminal clears your original paste buffer because it's expecting meaningful user input, and you cannot just paste it into terminal like this.
If you don't feel like creating a script file, press ctrl-x and then ctrl-e in the terminal, it will bring up the default editor. Paste it into the editor, save and exit, dash will run you script correctly from a temp file.
The correct default behavior: after press ctrl+x and then ctrl+e, the nano editor should be brought up. Paste you script in to the nano editor and save/exit, dash will run the script.
– Alvin Liang
2 days ago
nano
does bring nano up. Anyway, I createdx.sh
with the code and executed the file. Hitting N executedbreak
but hitting Y brought an error;x.sh: line 4: break: only meaningful in a
for',while', or
until' loop`. Do you have an idea why?
– JohnDoea
2 days ago
1
This is correct response, because your break command is meaningless here. You don't need to add break in every switch option like in C.
– Alvin Liang
2 days ago
add a comment |
up vote
3
down vote
accepted
As soon as "read -p" line is invoked, terminal clears your original paste buffer because it's expecting meaningful user input, and you cannot just paste it into terminal like this.
If you don't feel like creating a script file, press ctrl-x and then ctrl-e in the terminal, it will bring up the default editor. Paste it into the editor, save and exit, dash will run you script correctly from a temp file.
The correct default behavior: after press ctrl+x and then ctrl+e, the nano editor should be brought up. Paste you script in to the nano editor and save/exit, dash will run the script.
– Alvin Liang
2 days ago
nano
does bring nano up. Anyway, I createdx.sh
with the code and executed the file. Hitting N executedbreak
but hitting Y brought an error;x.sh: line 4: break: only meaningful in a
for',while', or
until' loop`. Do you have an idea why?
– JohnDoea
2 days ago
1
This is correct response, because your break command is meaningless here. You don't need to add break in every switch option like in C.
– Alvin Liang
2 days ago
add a comment |
up vote
3
down vote
accepted
up vote
3
down vote
accepted
As soon as "read -p" line is invoked, terminal clears your original paste buffer because it's expecting meaningful user input, and you cannot just paste it into terminal like this.
If you don't feel like creating a script file, press ctrl-x and then ctrl-e in the terminal, it will bring up the default editor. Paste it into the editor, save and exit, dash will run you script correctly from a temp file.
As soon as "read -p" line is invoked, terminal clears your original paste buffer because it's expecting meaningful user input, and you cannot just paste it into terminal like this.
If you don't feel like creating a script file, press ctrl-x and then ctrl-e in the terminal, it will bring up the default editor. Paste it into the editor, save and exit, dash will run you script correctly from a temp file.
answered 2 days ago
Alvin Liang
3216
3216
The correct default behavior: after press ctrl+x and then ctrl+e, the nano editor should be brought up. Paste you script in to the nano editor and save/exit, dash will run the script.
– Alvin Liang
2 days ago
nano
does bring nano up. Anyway, I createdx.sh
with the code and executed the file. Hitting N executedbreak
but hitting Y brought an error;x.sh: line 4: break: only meaningful in a
for',while', or
until' loop`. Do you have an idea why?
– JohnDoea
2 days ago
1
This is correct response, because your break command is meaningless here. You don't need to add break in every switch option like in C.
– Alvin Liang
2 days ago
add a comment |
The correct default behavior: after press ctrl+x and then ctrl+e, the nano editor should be brought up. Paste you script in to the nano editor and save/exit, dash will run the script.
– Alvin Liang
2 days ago
nano
does bring nano up. Anyway, I createdx.sh
with the code and executed the file. Hitting N executedbreak
but hitting Y brought an error;x.sh: line 4: break: only meaningful in a
for',while', or
until' loop`. Do you have an idea why?
– JohnDoea
2 days ago
1
This is correct response, because your break command is meaningless here. You don't need to add break in every switch option like in C.
– Alvin Liang
2 days ago
The correct default behavior: after press ctrl+x and then ctrl+e, the nano editor should be brought up. Paste you script in to the nano editor and save/exit, dash will run the script.
– Alvin Liang
2 days ago
The correct default behavior: after press ctrl+x and then ctrl+e, the nano editor should be brought up. Paste you script in to the nano editor and save/exit, dash will run the script.
– Alvin Liang
2 days ago
nano
does bring nano up. Anyway, I created x.sh
with the code and executed the file. Hitting N executed break
but hitting Y brought an error; x.sh: line 4: break: only meaningful in a
for', while', or
until' loop`. Do you have an idea why?– JohnDoea
2 days ago
nano
does bring nano up. Anyway, I created x.sh
with the code and executed the file. Hitting N executed break
but hitting Y brought an error; x.sh: line 4: break: only meaningful in a
for', while', or
until' loop`. Do you have an idea why?– JohnDoea
2 days ago
1
1
This is correct response, because your break command is meaningless here. You don't need to add break in every switch option like in C.
– Alvin Liang
2 days ago
This is correct response, because your break command is meaningless here. You don't need to add break in every switch option like in C.
– Alvin Liang
2 days ago
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1093677%2fi-paste-a-code-in-wsl-but-i-get-only-part-of-it%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Can't understand why this was down voted.
– JohnDoea
Nov 18 at 6:02
This usage is incorrect. Use shell script file instead of copying and pasting into terminal.
– Alvin Liang
Nov 18 at 19:28
@AlvinLiang I see no reason why it's necessarily incorrect, I have good experience with copy-pasting (when I find it elegant) or executing a script directly from GitHub without downloading it with
git
which is even more elegant: askubuntu.com/questions/992448/… but yes, indeed the usual way is to download a program with git and execute locally, it's just not something I want to do here.– JohnDoea
Nov 18 at 22:41
1
It's incorrect because paste is an input behavior, and read -p expects user input. Even if it does not stop your paste the behavior will not be correct.
– Alvin Liang
2 days ago
1
@AlvinLiang seems what you write indicated it can only be run as part of a script and not as a command-set pasted in the terminal. This should be an answer IMO.
– JohnDoea
2 days ago