Skip to content

install with piped input fails if target file exists #12407

@edwardpeek-crown-public

Description

Reproduction steps

$ echo foo | install /dev/stdin bar
$ echo foo | install /dev/stdin bar
install: No such file or directory

Expected behaviour

Piped content is written to target file as per coreutils behaviour, regardless of whether target file exists.

Actual behaviour

Error message printed about missing file only if target file already exists.

From an strace it looks like it trips up chasing symlinks for the stdin pipe:

readlink("/proc", 0x7ffe5f48f540, 1023) = -1 EINVAL (Invalid argument)
readlink("/proc/self", "328710", 1023)  = 6
readlink("/proc/328710", 0x7ffe5f48f540, 1023) = -1 EINVAL (Invalid argument)
readlink("/proc/328710/fd", 0x7ffe5f48f540, 1023) = -1 EINVAL (Invalid argument)
readlink("/proc/328710/fd/0", "pipe:[2063159]", 1023) = 14
readlink("/proc/328710/fd/pipe:[2063159]", 0x7ffe5f48f540, 1023) = -1 ENOENT (No such file or directory)

Metadata

Metadata

Assignees

No one assigned

    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