Skip to content

sudo pipe linefeeds in output #989

Description

@arnon-weinberg

Piping sudo mangles output (LF with no CR):

>ksh -c 'sudo printf "123\n456\n" | head'
123
   456

This doesn't happen without ksh, without sudo, or without pipe:

>bash -c 'sudo printf "123\n456\n" | head'
123
456
>ksh -c 'printf "123\n456\n" | head'
123
456
>ksh -c 'sudo printf "123\n456\n"'
123
456

Replicated on:

>ksh --version 
  version         sh (AT&T Research) 93u+m/1.0.6 2023-06-13
>sudo --version
Sudo version 1.9.17p2

and

>ksh --version
  version         sh (AT&T Research) 93u+m/1.0.10 2024-08-01
>sudo --version
Sudo version 1.9.17p2

and latest

>ksh --version
  version         sh (AT&T Research) 93u+m/1.1.0-alpha+0bcf7877 2026-05-08
>sudo --version
Sudo version 1.9.17p2

but not

>ksh --version
  version         sh (AT&T Research) 93u+ 2012-08-01
>sudo --version
Sudo version 1.8.23

or latest

>ksh --version
  version         sh (AT&T Research) 93u+m/1.1.0-alpha+0bcf7877 2026-05-08
>sudo --version
Sudo version 1.8.23

In other words, it only happens with the more recent version of sudo. Perhaps that means it's a sudo bug, but since bash is not affected, I figured that I would post here first.

I worked around the issue with this in /etc/sudoers:
#Defaults !use_pty

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is not working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions