* PATCH: assume -s
@ 2003-08-28 13:32 Aaron VanDevender
2003-08-29 10:38 ` Thien-Thi Nguyen
0 siblings, 1 reply; 18+ messages in thread
From: Aaron VanDevender @ 2003-08-28 13:32 UTC (permalink / raw)
Cc: guile-sources
How would people feel about a patch like this? It makes guile
assume -s if its given an argument that doesn't match a known
flag. So you can say
guile foo.scm
instead of
guile -s foo.scm
The former is, of course, more in line with standard script
engines (bash, perl, etc...)
--- libguile.old/script.c 2003-08-28 08:13:55.000000000 -0500
+++ libguile/script.c 2003-08-28 08:26:02.000000000 -0500
@@ -595,9 +595,24 @@
else
{
- fprintf (stderr, "%s: Unrecognized switch `%s'\n",
- scm_usage_name, argv[i]);
- scm_shell_usage (1, 0);
+ /* If we specified the -ds option, do_script points to the
+ cdr of an expression like (load #f); we replace the car
+ (i.e., the #f) with the script name. */
+ if (!SCM_NULLP (do_script))
+ {
+ SCM_SETCAR (do_script, scm_makfrom0str (argv[i]));
+ do_script = SCM_EOL;
+ }
+ else
+ /* Construct an application of LOAD to the script name. */
+ tail = scm_cons (scm_cons2 (sym_load,
+ scm_makfrom0str (argv[i]),
+ SCM_EOL),
+ tail);
+ argv0 = argv[i];
+ i++;
+ interactive = 0;
+ break;
}
}
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: PATCH: assume -s
2003-08-28 13:32 PATCH: assume -s Aaron VanDevender
@ 2003-08-29 10:38 ` Thien-Thi Nguyen
2003-08-29 13:20 ` Aaron VanDevender
0 siblings, 1 reply; 18+ messages in thread
From: Thien-Thi Nguyen @ 2003-08-29 10:38 UTC (permalink / raw)
Cc: guile-user
From: Aaron VanDevender <sig@netdot.net>
Date: Thu, 28 Aug 2003 09:32:29 -0400
you can say
guile foo.scm
instead of
guile -s foo.scm
cool.
[patch]
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
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: PATCH: assume -s
2003-08-29 10:38 ` Thien-Thi Nguyen
@ 2003-08-29 13:20 ` Aaron VanDevender
2003-08-29 15:41 ` Thien-Thi Nguyen
2003-08-30 19:40 ` Neil Jerram
0 siblings, 2 replies; 18+ messages in thread
From: Aaron VanDevender @ 2003-08-29 13:20 UTC (permalink / raw)
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
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: PATCH: assume -s
2003-08-29 13:20 ` Aaron VanDevender
@ 2003-08-29 15:41 ` Thien-Thi Nguyen
2003-08-31 18:23 ` Marius Vollmer
2003-08-30 19:40 ` Neil Jerram
1 sibling, 1 reply; 18+ messages in thread
From: Thien-Thi Nguyen @ 2003-08-29 15:41 UTC (permalink / raw)
Cc: guile-user
From: Aaron VanDevender <sig@netdot.net>
Date: Fri, 29 Aug 2003 09:20:31 -0400
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.
[patch]
thanks, this new patch is good to go. short, so no papers needed.
i will mention in the docs that SCRIPT must not begin w/ "-".
thi
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: PATCH: assume -s
2003-08-29 13:20 ` Aaron VanDevender
2003-08-29 15:41 ` Thien-Thi Nguyen
@ 2003-08-30 19:40 ` Neil Jerram
2003-08-30 20:00 ` Neil Jerram
2003-09-03 1:54 ` Kevin Ryde
1 sibling, 2 replies; 18+ messages in thread
From: Neil Jerram @ 2003-08-30 19:40 UTC (permalink / raw)
Cc: guile-user
>>>>> "Aaron" == Aaron VanDevender <sig@netdot.net> writes:
Aaron> Ok, I've reworked it so that it doesn't duplicate code. I've
Aaron> also changed the semantics *slightly*. In the old case, anything
Aaron> that wasn't a recognized switch was treated as a SCRIPT. This
Aaron> was, only things that don't begin with a '-' will be assumed as
Aaron> a script. That way people won't rely on, for example, -a *not*
Aaron> being a switch, invoking scheme -a, with -a being a script, and
Aaron> then one day someone implementing the -a switch and breaking the
Aaron> previous invocation. Its a long shot, (why would you ever want
Aaron> to name a script -a?) better to be safe. The new patch also
Aaron> updates the usage message.
Thanks. This was discussed in October 2002 on the list, and there
seemed a pretty clear consensus in favour, so I'll apply this soon.
(One slight objection at that time was the risk of someone coding
"guile %s", and then someone else passing "-x" as the %s, and then
getting unexpected results; but this is addressed by your semantics as
described above.)
Neil
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: PATCH: assume -s
2003-08-30 19:40 ` Neil Jerram
@ 2003-08-30 20:00 ` Neil Jerram
2003-08-31 18:16 ` Marius Vollmer
2003-09-03 1:54 ` Kevin Ryde
1 sibling, 1 reply; 18+ messages in thread
From: Neil Jerram @ 2003-08-30 20:00 UTC (permalink / raw)
Cc: guile-user
>>>>> "Neil" == Neil Jerram <neil@ossau.uklinux.net> writes:
Neil> Thanks. This was discussed in October 2002 on the list, and there
Neil> seemed a pretty clear consensus in favour, so I'll apply this soon.
Just to be clear, to CVS head only; unless Marius says otherwise, I
don't think this should go into the 1.6 branch.
Neil
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: PATCH: assume -s
2003-08-30 20:00 ` Neil Jerram
@ 2003-08-31 18:16 ` Marius Vollmer
2003-08-31 22:56 ` Neil Jerram
0 siblings, 1 reply; 18+ messages in thread
From: Marius Vollmer @ 2003-08-31 18:16 UTC (permalink / raw)
Cc: guile-user, Aaron VanDevender
Neil Jerram <neil@ossau.uklinux.net> writes:
> >>>>> "Neil" == Neil Jerram <neil@ossau.uklinux.net> writes:
>
> Neil> Thanks. This was discussed in October 2002 on the list, and there
> Neil> seemed a pretty clear consensus in favour, so I'll apply this soon.
>
> Just to be clear, to CVS head only; unless Marius says otherwise, I
> don't think this should go into the 1.6 branch.
Right. Please go ahead, Neil. Thanks!
--
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3 331E FAF8 226A D5D4 E405
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: PATCH: assume -s
2003-08-29 15:41 ` Thien-Thi Nguyen
@ 2003-08-31 18:23 ` Marius Vollmer
2003-09-01 9:24 ` Thien-Thi Nguyen
0 siblings, 1 reply; 18+ messages in thread
From: Marius Vollmer @ 2003-08-31 18:23 UTC (permalink / raw)
Thien-Thi Nguyen <ttn@glug.org> writes:
> thanks, this new patch is good to go. short, so no papers needed.
> i will mention in the docs that SCRIPT must not begin w/ "-".
Unless I'm missing something, Thien-Thi is talking about his own line of
Guile development here, not about the 'official' one.
Thien-Thi, please try not to give the impression that your version of
Guile is the one that is currently released by the FSF as versions
1.6.x.
--
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3 331E FAF8 226A D5D4 E405
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: PATCH: assume -s
2003-08-31 18:16 ` Marius Vollmer
@ 2003-08-31 22:56 ` Neil Jerram
0 siblings, 0 replies; 18+ messages in thread
From: Neil Jerram @ 2003-08-31 22:56 UTC (permalink / raw)
Cc: guile-user, Aaron VanDevender
>>>>> "Marius" == Marius Vollmer <mvo@zagadka.de> writes:
Marius> Neil Jerram <neil@ossau.uklinux.net> writes:
>> >>>>> "Neil" == Neil Jerram <neil@ossau.uklinux.net> writes:
>>
Neil> Thanks. This was discussed in October 2002 on the list, and there
Neil> seemed a pretty clear consensus in favour, so I'll apply this soon.
>>
>> Just to be clear, to CVS head only; unless Marius says otherwise, I
>> don't think this should go into the 1.6 branch.
Marius> Right. Please go ahead, Neil. Thanks!
Now done.
Neil
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: PATCH: assume -s
2003-08-31 18:23 ` Marius Vollmer
@ 2003-09-01 9:24 ` Thien-Thi Nguyen
0 siblings, 0 replies; 18+ messages in thread
From: Thien-Thi Nguyen @ 2003-09-01 9:24 UTC (permalink / raw)
Cc: guile-user
From: Marius Vollmer <mvo@zagadka.de>
Date: 31 Aug 2003 20:23:13 +0200
Unless I'm missing something, Thien-Thi is talking about his own line
of Guile development here, not about the 'official' one.
Thien-Thi, please try not to give the impression that your version of
Guile is the one that is currently released by the FSF as versions
1.6.x.
fsf already has my papers for guile, so if i accept patches for whatever
version i'm working on (the fruits of which are assigned to fsf anyway),
the same considerations apply. the only difference between my work and
those w/ write privs is exactly that: write privs (or lack thereof ;-).
if i were to be less scrupulous that would make it difficult to
entertain the hope that write privs will be restored someday, at which
time the value of clean record keeping would be realized. perhaps this
hope is slimly supported in your lifetime; that's fine, too.
as for what impression people may take from my words and actions, that's
their business and for the most part out of my control.
thi
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: PATCH: assume -s
2003-08-30 19:40 ` Neil Jerram
2003-08-30 20:00 ` Neil Jerram
@ 2003-09-03 1:54 ` Kevin Ryde
2003-09-03 23:17 ` Neil Jerram
1 sibling, 1 reply; 18+ messages in thread
From: Kevin Ryde @ 2003-09-03 1:54 UTC (permalink / raw)
Neil Jerram <neil@ossau.uklinux.net> writes:
>
> Thanks. This was discussed in October 2002 on the list, and there
> seemed a pretty clear consensus in favour, so I'll apply this soon.
Does "guile -- foo.scm" do the same as "guile foo.scm"?
It looks like "--" brings up the interpreter instead, whereas I'd
think the two ought to be the same.
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: PATCH: assume -s
2003-09-03 1:54 ` Kevin Ryde
@ 2003-09-03 23:17 ` Neil Jerram
2003-09-04 0:05 ` Kevin Ryde
0 siblings, 1 reply; 18+ messages in thread
From: Neil Jerram @ 2003-09-03 23:17 UTC (permalink / raw)
Cc: guile-user
>>>>> "Kevin" == Kevin Ryde <user42@zip.com.au> writes:
Kevin> Neil Jerram <neil@ossau.uklinux.net> writes:
>>
>> Thanks. This was discussed in October 2002 on the list, and there
>> seemed a pretty clear consensus in favour, so I'll apply this soon.
Kevin> Does "guile -- foo.scm" do the same as "guile foo.scm"?
No. Personally I think this is useful. Does it contravene some GNU
standard though?
(If the script uses getopt, though, I wonder if something like
"guile foo.scm -s switch -- arg" works? I'd guess it does.)
Neil
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: PATCH: assume -s
2003-09-03 23:17 ` Neil Jerram
@ 2003-09-04 0:05 ` Kevin Ryde
2003-09-04 16:02 ` Paul Jarc
2003-09-04 18:56 ` Neil Jerram
0 siblings, 2 replies; 18+ messages in thread
From: Kevin Ryde @ 2003-09-04 0:05 UTC (permalink / raw)
Cc: guile-user
Neil Jerram <neil@ossau.uklinux.net> writes:
>
> No. Personally I think this is useful. Does it contravene some GNU
> standard though?
Well I guess it's a posix convention that `--' ends option processing.
I think it'd be pretty important for consistency to do the same thing
with or without it.
> (If the script uses getopt, though, I wonder if something like
> "guile foo.scm -s switch -- arg" works? I'd guess it does.)
Hope so. If args are passed to foo.scm then you wouldn't want options
to be sought out right through the command line (the way gnu getopt
does), but instead left for foo to interpret.
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: PATCH: assume -s
2003-09-04 0:05 ` Kevin Ryde
@ 2003-09-04 16:02 ` Paul Jarc
2003-09-05 18:22 ` Robert Uhl
2003-09-09 22:58 ` Kevin Ryde
2003-09-04 18:56 ` Neil Jerram
1 sibling, 2 replies; 18+ messages in thread
From: Paul Jarc @ 2003-09-04 16:02 UTC (permalink / raw)
Cc: guile-user, Neil Jerram
Kevin Ryde <user42@zip.com.au> wrote:
> Well I guess it's a posix convention that `--' ends option processing.
> I think it'd be pretty important for consistency to do the same thing
> with or without it.
Making "guile foo.scm" equivalent to "guile -s foo.scm" doesn't break
compatibility, but making "guile -- foo.scm" also equivalent would.
I'd much rather see Guile behave consistently with its own existing
behavior than see it change for the sake of behaving similarly to
other programs.
paul
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: PATCH: assume -s
2003-09-04 0:05 ` Kevin Ryde
2003-09-04 16:02 ` Paul Jarc
@ 2003-09-04 18:56 ` Neil Jerram
1 sibling, 0 replies; 18+ messages in thread
From: Neil Jerram @ 2003-09-04 18:56 UTC (permalink / raw)
Cc: guile-user
>>>>> "Kevin" == Kevin Ryde <user42@zip.com.au> writes:
Kevin> Neil Jerram <neil@ossau.uklinux.net> writes:
>>
>> No. Personally I think this is useful. Does it contravene some GNU
>> standard though?
Kevin> Well I guess it's a posix convention that `--' ends option processing.
Kevin> I think it'd be pretty important for consistency to do the same thing
Kevin> with or without it.
I think there's room to interpret this convention as consistent with
the new behaviour. From Guile's perspective, the script filename
appears as an option (as it always has done); non-options are not
passed into whatever code gets run as the value of (cdr
(command-line)). All the recent change does is say that, for
convenience, you can leave out the "-s".
>> (If the script uses getopt, though, I wonder if something like
>> "guile foo.scm -s switch -- arg" works? I'd guess it does.)
Kevin> Hope so. If args are passed to foo.scm then you wouldn't want options
Kevin> to be sought out right through the command line (the way gnu getopt
Kevin> does), but instead left for foo to interpret.
Agreed, and this is what happens:
[neil@laruns ~]$ guile test.scm -s switch -- arg
("-s" "switch" "--" "arg")
where test.scm is:
(write (cdr (command-line)))
(newline)
Regards,
Neil
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: PATCH: assume -s
2003-09-04 16:02 ` Paul Jarc
@ 2003-09-05 18:22 ` Robert Uhl
2003-09-09 22:58 ` Kevin Ryde
1 sibling, 0 replies; 18+ messages in thread
From: Robert Uhl @ 2003-09-05 18:22 UTC (permalink / raw)
prj@po.cwru.edu (Paul Jarc) writes:
>
> Making "guile foo.scm" equivalent to "guile -s foo.scm" doesn't break
> compatibility, but making "guile -- foo.scm" also equivalent would.
> I'd much rather see Guile behave consistently with its own existing
> behavior than see it change for the sake of behaving similarly to
> other programs.
Not I. Changing to be like other progs hurts once, and then it's over.
Being weird hurts every time a user gets screwed by following his
instincts and does what works elsewhere only to be burned.
--
Robert Uhl <ruhl@4dv.net>
Government does not cause affluence. Citizens of totalitarian countries
have plenty of government and nothing of anything else. --P. J. O'Rourke
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: PATCH: assume -s
2003-09-04 16:02 ` Paul Jarc
2003-09-05 18:22 ` Robert Uhl
@ 2003-09-09 22:58 ` Kevin Ryde
2003-09-10 16:51 ` Paul Jarc
1 sibling, 1 reply; 18+ messages in thread
From: Kevin Ryde @ 2003-09-09 22:58 UTC (permalink / raw)
prj@po.cwru.edu (Paul Jarc) writes:
>
> Making "guile foo.scm" equivalent to "guile -s foo.scm" doesn't break
> compatibility, but making "guile -- foo.scm" also equivalent would.
Oh, I see, it was explicitly documented, whereas "guile foo.scm" was
previously an error.
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: PATCH: assume -s
2003-09-09 22:58 ` Kevin Ryde
@ 2003-09-10 16:51 ` Paul Jarc
0 siblings, 0 replies; 18+ messages in thread
From: Paul Jarc @ 2003-09-10 16:51 UTC (permalink / raw)
Kevin Ryde <user42@zip.com.au> wrote:
> prj@po.cwru.edu (Paul Jarc) writes:
>> Making "guile foo.scm" equivalent to "guile -s foo.scm" doesn't break
>> compatibility, but making "guile -- foo.scm" also equivalent would.
>
> Oh, I see, it was explicitly documented, whereas "guile foo.scm" was
> previously an error.
Right. "guile -- foo.scm" already means something, and that something
is useful. In this particular case, it's only for interactive use, so
changing the meaning of that invocation probably wouldn't break much
old code, but at the very least, there should still be *some* way to
do the same thing that "guile -- foo.scm" does now, even if it's by a
different spelling.
paul
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2003-09-10 16:51 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-08-28 13:32 PATCH: assume -s Aaron VanDevender
2003-08-29 10:38 ` Thien-Thi Nguyen
2003-08-29 13:20 ` Aaron VanDevender
2003-08-29 15:41 ` Thien-Thi Nguyen
2003-08-31 18:23 ` Marius Vollmer
2003-09-01 9:24 ` Thien-Thi Nguyen
2003-08-30 19:40 ` Neil Jerram
2003-08-30 20:00 ` Neil Jerram
2003-08-31 18:16 ` Marius Vollmer
2003-08-31 22:56 ` Neil Jerram
2003-09-03 1:54 ` Kevin Ryde
2003-09-03 23:17 ` Neil Jerram
2003-09-04 0:05 ` Kevin Ryde
2003-09-04 16:02 ` Paul Jarc
2003-09-05 18:22 ` Robert Uhl
2003-09-09 22:58 ` Kevin Ryde
2003-09-10 16:51 ` Paul Jarc
2003-09-04 18:56 ` Neil Jerram
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).