Menu

#1394 SOURCELINE(1) reports different content, if hashbang exists

5.0.0
closed
nobody
None
none
1
2023-01-01
2016-08-19
Erich
No

If a Rexx program starts with a hashbang (shebang) like "#!/usr/bin/rexx", the built-in function SOURCELINE() (and .context~package~source and .context~package~sourceLine) will report a different value for the first line

This code ..

1
2
3
4
5
#!/usr/bin/rexx
-- what does sourceline(1) return?
do line = 1 to 3
  say line":" sourceline(line) 
end

.. when run with 4.2 will report

1: --/usr/bin/rexx
2: -- what does sourceline(1) return?
3: do line = 1 to 3

.. when run with 5.0 will report

1:
2: -- what does sourceline(1) return?
3: do line = 1 to 3

Should we care? If so, what do we want it to return?

In any case, I assume, we should document this behaviour.
(I also notice that the docs don't mention the fact that Rexx programs may start with a hashbang line)

Related

Bugs: #1394

Discussion

  • LesK

    LesK - 2016-08-19

    I would argue that hashbang is part of the source and should be properly reported
    in its entirety. My justification: The program won't run on linux w/o it.

    I understand the argument

    'To satisfy archaic OSes, ooRexx allows a source file to
    start with "#!". The interpreter treats the line as a comment.'

    However, I don't think it
    should lie to the programmer about the contents of the line!

     
    • Bruce

      Bruce - 2016-08-19

      Nothing more archaic than using file types/file extensions to denote the command processor.

      And Rexx programs run just fine without it, i.e. "rexx myprogram arg1 arg2".

      Bruce
      Sent by Magic!

      On Aug 19, 2016, at 11:59 AM, LesK vmrexx@users.sf.net wrote:

      I would argue that hashbang is part of the source and should be properly reported
      in its entirety. My justification: The program won't run on linux w/o it.

      I understand the argument

      'To satisfy archaic OSes, ooRexx allows a source file to
      start with "#!". The interpreter treats the line as a comment.'

      However, I don't think it
      should lie to the programmer about the contents of the line!

      [bugs:#1394] SOURCELINE(1) reports different content, if hashbang exists

      Status: open
      Group: 5.0.0
      Created: Fri Aug 19, 2016 02:47 PM UTC by Erich
      Last Updated: Fri Aug 19, 2016 02:47 PM UTC
      Owner: nobody

      If a Rexx program starts with a hashbang (shebang) like "#!/usr/bin/rexx", the built-in function SOURCELINE() (and .context~package~source and .context~package~sourceLine) will report a different value for the first line

      This code ..

      1
      2
      3
      4
      5

      !/usr/bin/rexx

      -- what does sourceline(1) return?
      do line = 1 to 3
      say line":" sourceline(line)
      end
      .. when run with 4.2 will report

      1: --/usr/bin/rexx
      2: -- what does sourceline(1) return?
      3: do line = 1 to 3
      .. when run with 5.0 will report

      1:
      2: -- what does sourceline(1) return?
      3: do line = 1 to 3
      Should we care? If so, what do we want it to return?

      In any case, I assume, we should document this behaviour.
      (I also notice that the docs don't mention the fact that Rexx programs may start with a hashbang line)

      Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/oorexx/bugs/1394/

      To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/

       

      Related

      Bugs: #1394

  • Bruce

    Bruce - 2016-08-19

    I would argue that if the non-linux/unix versions show '/Rexx /' as the first line, then it would also show the hashbang line. Both lines serve the same function of alerting the OS to the interpreter to be used to interpret the file.

     
  • Rick McGuire

    Rick McGuire - 2018-12-15
    • status: open --> accepted
    • Pending work items: none --> doc+test
     
  • Rick McGuire

    Rick McGuire - 2018-12-15

    Code committed [r11615]

     

    Related

    Commit: [r11615]

  • Erich

    Erich - 2018-12-16
    • status: accepted --> pending
    • Pending work items: doc+test --> none
     
  • Erich

    Erich - 2018-12-16

    Added tests with [r11620]

     

    Related

    Commit: [r11620]

  • Rony G. Flatscher

    • Status: pending --> closed
     

Anonymous
Anonymous

Add attachments
Cancel