0

As an example, I paste the following into my terminal (with the newline at the end):

pwd
adb doesnotexist
ls
​

All three run. The second exits with a failure. On the other hand, pasting this:

pwd
adb shell pwd
ls
​

stops at adb and does not continue to paste or execute ls.

  1. What mechanism is at work here to abort the paste?
  2. How can I override it?
1
  • 1
    you could use && and ; to concatenate all commands in a single line (you still can paste) , depending on the behavior that you want described here
    – bistoco
    Oct 4 '16 at 19:11
1

I think this is happening because you are running these commands into a terminal, and some commands interfere with the terminal configuration. E.g., when sudo asks for a password, it will clear the terminal buffer, so you cannot pre-type your password: you cannot do sleep 5; sudo ls, then type your password during sleep. Same with rm asking for confirmations.

I can get the same effect with:

ls
script -c ls -f /dev/null
pwd

Meaning, if I mouse-paste these in Konsole, pwd doesn't get executed. Here, the second command surely messes with the terminal configuration, which leads me to believe that so does adb shell (but probably not abd doesnotexist).

1
  • Thanks for the info! For completeness, source /dev/stdin, paste, Ctrl-D is a quick solution.
    – jozxyqk
    Oct 4 '16 at 20:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.