Skip to content

exec does not redirect correctly #1904

@ndtodoroff

Description

@ndtodoroff

What happened, and what did you expect to happen?

Not 100% sure if this is a bug or intended behavior, but redirects with exec seem to do nothing (which is not the way it works in bash for example).

To demonstrate this, I'm going to spawn a shell in a shell and use # for the first shell prompt and $ for the subshell prompt.

Doing the following in Elvish

# exec elvish >test.log
$ echo test

will echo test to the console and leave test.log empty, while

# elvish >test.log
$ echo test

will write test to test.log as desired. Doing the same experiment in bash, the first example acts the same as the second example, i.e. test is not output to the console and instead test.log contains test.

This came up because I wanted to write a wrapper script for a program to set some environment variables and redirect output to a log file, and thought that execing the program at the end of the script was the natural thing to do.

Output of "elvish -version"

0.21.0+archlinux1

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    ❓Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions