[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: PATCH: assume -s
From: |
Aaron VanDevender |
Subject: |
Re: PATCH: assume -s |
Date: |
Fri, 29 Aug 2003 09:20:31 -0400 |
User-agent: |
Mutt/1.2.5.1i |
On Fri, Aug 29, 2003 at 06:38:23AM -0400, Thien-Thi Nguyen wrote:
>
> this implementation duplicates code in the "-s" handling case. while
> understandable (given the intent of the change), i'd like to request
> another patch that is more immune to future code skew. could you rework
> it so that both the "-s" and the non-recognized case use the same code?
>
> thi
Ok, I've reworked it so that it doesn't duplicate code. I've
also changed the semantics *slightly*. In the old case, anything
that wasn't a recognized switch was treated as a SCRIPT. This
was, only things that don't begin with a '-' will be assumed as
a script. That way people won't rely on, for example, -a *not*
being a switch, invoking scheme -a, with -a being a script, and
then one day someone implementing the -a switch and breaking the
previous invocation. Its a long shot, (why would you ever want
to name a script -a?) better to be safe. The new patch also
updates the usage message.
Anyway, on to the new patch:
--- guile-core.old/libguile/script.c 2003-08-28 08:13:55.000000000 -0500
+++ guile-core/libguile/script.c 2003-08-29 08:09:28.000000000 -0500
@@ -373,7 +373,8 @@
"Usage: %s OPTION ...\n"
"Evaluate Scheme code, interactively or from a script.\n"
"\n"
- " -s SCRIPT load Scheme source code from FILE, and exit\n"
+ " SCRIPT load Scheme source code from SCRIPT, and exit\n"
+ " -s SCRIPT load Scheme source code from SCRIPT, and exit\n"
" -c EXPR evalute Scheme expression EXPR, and exit\n"
" -- stop scanning arguments; run interactively\n"
"The above switches stop argument processing, and pass all\n"
@@ -450,9 +451,9 @@
for (i = 1; i < argc; i++)
{
- if (! strcmp (argv[i], "-s")) /* load script */
+ if ((! strcmp (argv[i], "-s")) || (argv[i][0] != '-')) /* load script */
{
- if (++i >= argc)
+ if ((argv[i][0] == '-') && (++i >= argc))
scm_shell_usage (1, "missing argument to `-s' switch");
/* If we specified the -ds option, do_script points to the