Enabling "--r6rs-script" changes behavior of "(command-line)"

Bug #159776 reported by Michael D. Adams on 2007-11-03
2
Affects Status Importance Assigned to Milestone
Ikarus Scheme
Low
Abdulaziz Ghuloum

Bug Description

When "--r6rs-script" is off, (command-line) does not include the script name, but when "--r6rs-script" is on, it does include the script name. This behavior is inconsistent. The behavior when "--r6rs-script" is understandable/necessary given that there might actually be multiple files loaded. My recommendation is that the "on" behavior be changed to match the "off" behavior.

On Nov 3, 2007, at 1:23 PM, Michael D. Adams wrote:

> Public bug reported:
>
> When "--r6rs-script" is off, (command-line) does not include the
> script
> name, but when "--r6rs-script" is on, it does include the script name.
> This behavior is inconsistent. The behavior when "--r6rs-script" is
> understandable/necessary given that there might actually be multiple
> files loaded. My recommendation is that the "on" behavior be
> changed to
> match the "off" behavior.

The behavior of command-line for r6rs-scripts (script-name followed by
arguments) is consistent with R6RS, so it won't change.

There is a yet-to-be-documented "--script" flag described as follows:

   $ ikarus init-files ... --script script-file arguments ...

   Each of the init-files are loaded, one by one, into the interaction
   environment, followed by loading the script-file. The interaction
   environment initially contains all the bindings exported from the
   (ikarus) library. The value of calling the command-line procedure
   is a list containing the name of script-file and the arguments.

So, basically, when invoking ikarus as a script interpreter, you
get the script name. When ikarus is used interactively, there is
no script name, but you do get the option of adding whatever
arguments you want after the -- flag.

Example:

Suppose a.ss contains the one line:
   (display "Hi, I'm A\n")

and suppose that b.ss contains the following 3 lines:
   (display "Hello, I'm B\n")
   (write (command-line))
   (newline)

calling:
     ikarus a.ss --script b.ss x y z
produces:
   Hi, I'm A
   Hello, I'm B
   ("b.ss" "x" "y" "z")

The reason I didn't add a.ss to the command-line is that I take
a.ss is be an argument to ikarus, not an argument to your script.
So, ikarus has three modes: r6rs-script, script, and interactive.
The scripting modes are consistent. The interactive mode has no
script, only init-files, which ikarus consumes and drops from the
command line.

How does this sound?

Aziz,,,

Abdulaziz Ghuloum (aghuloum) wrote :

Will fix documentaion.

Changed in ikarus:
assignee: nobody → aghuloum
status: New → In Progress
Michael D. Adams (mdmkolbe) wrote :

Given that R6RS specifies the behavior, I see your point. One option might be to change the interactive behavior to supply a dummy "argv[0]". For example, GHC will report "<interactive>" as the program name when in interactive mode. Or Python just goes with the empty string. In the end it is up to you. I just tripped over it when I tested whether "(command-line)" included the program name by running it on the command like and then got bit when it was different inside a script.

Abdulaziz Ghuloum (aghuloum) wrote :

Fixed in revision 970, adding "*interactive*" to the list of args.
Thanks!

Changed in ikarus:
importance: Undecided → Low
status: In Progress → Fix Committed
Abdulaziz Ghuloum (aghuloum) wrote :

This bug report is about to be closed as the fix comitted previously
will be incorporated in the next 0.0.2 release of Ikarus Scheme,
scheduled for November 28, 2007.
A release candidate tarball is available for download from:
  http://www.cs.indiana.edu/~aghuloum/ikarus/ikarus-0.0.2-rc1.tar.gz
Please do test it if you have the time and report any issues you
might encounter. Thank you very much for your support. Aziz,,,
(Sorry for the duplicates; I'm updating every open bug.)

Changed in ikarus:
milestone: none → 0.0.2
Changed in ikarus:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers