Skip to content

shell.exec() has odd issues with line breaks in the returned output #55

Description

@davidm-ro

macOS 15.5.

Using this Python script:

test.py:

#!/usr/bin/env python3

def main():
    print("Hello, World!")

if __name__ == "__main__":
    main()

If I execute a train script:


log("Testing Python script with single argument...");
try {
    var result = shell.exec("/usr/bin/python3", "test.py", {
        timeout: 60,
        capture: true,
        workdir: "."
    });
    log("Result: '" + result + "'");
    log("Expected: Hello World and line break");
} catch (e) {
    log("Error: " + e);
}

log("Testing Python script with multiple arguments...");
try {
    var result = shell.exec("/usr/bin/python3", "test.py --validate-only", {
        timeout: 60,
        capture: true,
        workdir: "."
    });
    log("Result: '" + result + "'");
    og("Expected: Hello World and one line break");
} catch (e) {
    log("Error: " + e);
}

Expected vs Observed

For both, to see simple 'Hello world'. For the first, I get nothing: result is ''. That may be the same as #54 .

For the second, I do get the captured output! But I get two line breaks:

  shell.exec(/usr/bin/python3 test.py --validate-only) { }   
  Result: 'Hello, World!

'

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions