4

Why does the following line break the terminal when executed in a non-interactive shell, but doesn't have the same effect when executed in an interactive shell?

for i in {1..10}; do sudo -u testuser echo & done ;wait

I have password-less sudo, so I don't ordinarily get prompted for a password.

3
  • It doesn't break the terminal for me with sudo 1.9.17p2 on Debian in the screen or xterm terminal emulators when run at the prompt of a zsh or bash interactive shell. In which way does it break the terminal for you? Commented Dec 2 at 5:53
  • @StéphaneChazelas, when I put this into a script and run that script. I also have password-less sudo. Commented Dec 2 at 8:04
  • 2
    Again, in what way does it break your terminal? Can you include a screenshot? Commented Dec 2 at 8:07

1 Answer 1

3

Because the authors of sudo take special precautions to ensure that it sends prompts to, and receives input from, an actual interactive terminal.

This is sudo functioning as designed.

For more information, read man sudo sudoers.

For even more information, you can download, and read, the source.

1
  • The user says they use passwordless sudo, so it should not prompt for anything, right? Commented Dec 2 at 11:41

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.