Menu ▾ ▴

#2105 ADDRESS WITH INPUT USING a File object sends no input to the command

5.3.0
pending
Erich
None
none
3
6 hours ago
10 hours ago
No

Description:

rexxref, ADDRESS, WITH INPUT:

If option USING is specified, expr must be [...] an expression enclosed in parentheses that evaluates to a String, a Stem object, an InputStream, a Monitor or a File object, [...]. If the resulting object is a String, the command will receive a single input line, if it is a Stem, an InputStream, a Monitor, or a File object, input is redirected as described for options STEM and STREAM.

So a File object should feed the lines of the file to the command, as INPUT STREAM does. It doesn't: the command receives no input at all.

f = "/tmp/inusing.txt"
call lineout f, "alpha"
call lineout f, "beta"
call stream f, "c", "close"

out.0 = 0
address system "cat" with input using (.File~new(f)) output stem out.
say "INPUT USING .File  : rc="rc", lines="out.0      -- expected 2

out.0 = 0
address system "cat" with input stream (f) output stem out.
say "INPUT STREAM       : rc="rc", lines="out.0      -- 2

Actual:

  • r13263: rc=0, lines=0. cat gets an empty input.
  • r13237 and r13261: the command hangs. This is the symptom of an empty input before the fix for #2086 (r13263): the File never provided any data, so the pipe was never closed. So this is not a regression introduced by that fix; it was already there, hidden by the hang.
    Expected: rc=0, lines=2 (alpha, beta), as with INPUT STREAM.

Notes:

  • With the same file, INPUT STREAM, INPUT USING (.Stream~new(f)) and OUTPUT USING (.File~new(g)) all work.
  • The File object is accepted as a source (an object that is not a valid source, like .Object~new, gives 98.924, "is not a valid ADDRESS WITH INPUT source"), but it is read as if it were empty.
  • Tested on Linux (Ubuntu 24.04, 64-bit) with r13237, r13261 and r13263. Not tested on Windows.
  • A complete test program, address-input-using-file.rex, is attached.
1 Attachments

Discussion

  • Erich

    Erich - 6 hours ago
    • status: open --> pending
    • assigned_to: Erich
    • Priority: 5 --> 3
     
  • Erich

    Erich - 6 hours ago

    fixed code and added test with revision [r13266]

     

    Related

    Commit: [r13266]

Anonymous
Anonymous

Add attachments
Cancel