Skip to content

redirect input on debug #141

Description

@axiqia

I'd love to have something like this http://stackoverflow.com/questions/32863807/visual-studio-code-redirect-input-on-debug without a workaround. That is, ability to redirect input from a given file, when debugging.

I have tried to add arg option in launch.json,

    "configurations": [
        {
            "name": "Python: Debug",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "args": ["<",
                "input.txt"
            ]
        }
    ]

but the launch command doesn't work as usual. The terminal hangs and after I type enter, I got a exception.

Exception has occurred: ValueError
invalid literal for int() with base 10: '

The python script:

n = int(input())
print(n)

The input.txt content:
5

Is there any suggestion?

Activity

  1. int19h commented on Apr 24, 2020

    @int19h
    Contributor

    This didn't work, because stuff like < or | aren't command line arguments in a proper sense - they're shell operators. When you use them in "args", it will just quote and/or escape them to make sure that they are, in fact, interpreted as arguments rather than operators.

    For it to work properly, we'd need to support it specifically. But for us to support redirection, the "runInTerminal" request in VSCode would need to support it first, since we rely on that to spawn the debuggee.

    I'm going to leave this open as an enhancement, so that we can gauge interest in this feature from the votes.

  2. locked and limited conversation to collaborators on Jan 19, 2023
  3. converted this issue into a discussion #1182 on Jan 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions