* -I for guile command line
@ 2004-07-02 1:35 Richard Todd
2004-07-10 0:12 ` Kevin Ryde
2004-08-15 21:27 ` Marius Vollmer
0 siblings, 2 replies; 9+ messages in thread
From: Richard Todd @ 2004-07-02 1:35 UTC (permalink / raw)
Cc: Richard Todd
[-- Attachment #1: Type: text/plain, Size: 234 bytes --]
any interest in this patch? It lets you put -I on the guile command
line, to add directories to the load path.
as in:
guile -I .. -I . script-in-development.scm
I find this easier than mucking with that environment variable.
[-- Attachment #2: dash_i.patch --]
[-- Type: application/octet-stream, Size: 1734 bytes --]
Index: libguile/script.c
===================================================================
RCS file: /cvsroot/guile/guile/guile-core/libguile/script.c,v
retrieving revision 1.61
diff -u -r1.61 script.c
--- libguile/script.c 16 Jun 2004 04:08:25 -0000 1.61
+++ libguile/script.c 2 Jul 2004 01:29:05 -0000
@@ -361,6 +361,7 @@
"remaining arguments as the value of (command-line).\n"
"If FILE begins with `-' the -s switch is mandatory.\n"
"\n"
+ " -I DIRECTORY add DIRECTORY to the module load path\n"
" -l FILE load Scheme source code from FILE\n"
" -e FUNCTION after reading script, apply FUNCTION to\n"
" command line arguments\n"
@@ -395,7 +396,10 @@
SCM_SYMBOL (sym_top_repl, "top-repl");
SCM_SYMBOL (sym_quit, "quit");
SCM_SYMBOL (sym_use_srfis, "use-srfis");
-
+SCM_SYMBOL (sym_load_path, "%load-path");
+SCM_SYMBOL (sym_set_x, "set!");
+SCM_SYMBOL (sym_cons, "cons");
+
/* Given an array of command-line switches, return a Scheme expression
to carry out the actions specified by the switches.
@@ -485,6 +489,18 @@
break;
}
+ else if (! strcmp (argv[i], "-I"))
+ {
+ if (++i < argc)
+ tail = scm_cons (SCM_LIST3 (sym_set_x, sym_load_path,
+ SCM_LIST3 (sym_cons,
+ scm_makfrom0str(argv[i]),
+ sym_load_path)),
+ tail);
+ else
+ scm_shell_usage (1, "missing argument to -I switch");
+ }
+
else if (! strcmp (argv[i], "-l")) /* load a file */
{
if (++i < argc)
[-- Attachment #3: Type: text/plain, Size: 143 bytes --]
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: -I for guile command line
@ 2004-07-05 17:56 Andy Wingo
0 siblings, 0 replies; 9+ messages in thread
From: Andy Wingo @ 2004-07-05 17:56 UTC (permalink / raw)
On Thu, 2004-07-01 at 20:35 -0500, Richard Todd wrote:
> any interest in this patch? It lets you put -I on the guile command
> line, to add directories to the load path.
I'm interested. I think that environment variable sucks, too.
(Especially given the recent discussion about "/foo/dir:" including the
current dir, in relation to hacking LD_LIBRARY_PATH and security
vulnerabilities.)
One thing: since guile scripts can chdir, perhaps the paths should be
resolved to absolute paths. But ++votes for it to be included in
guile :)
Cheers,
--
Andy Wingo <wingo@pobox.com>
http://ambient.2y.net/wingo/
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: -I for guile command line
2004-07-02 1:35 -I for guile command line Richard Todd
@ 2004-07-10 0:12 ` Kevin Ryde
2004-07-10 1:28 ` Richard Todd
2004-08-15 21:27 ` Marius Vollmer
1 sibling, 1 reply; 9+ messages in thread
From: Kevin Ryde @ 2004-07-10 0:12 UTC (permalink / raw)
Cc: guile-devel
Richard Todd <rwtodd@mac.com> writes:
>
> guile -I .. -I . script-in-development.scm
Or call it -L, like emacs takes (ld and cc too of course). Might be
easy to remember as L for load-path.
(I know -I is used by perl, I guess that makes sense there since it's
the @INC variable which gets munged.)
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: -I for guile command line
2004-07-10 0:12 ` Kevin Ryde
@ 2004-07-10 1:28 ` Richard Todd
0 siblings, 0 replies; 9+ messages in thread
From: Richard Todd @ 2004-07-10 1:28 UTC (permalink / raw)
Cc: Richard Todd, guile-devel
On Jul 9, 2004, at 7:12 PM, Kevin Ryde wrote:
> (I know -I is used by perl, I guess that makes sense there since it's
> the @INC variable which gets munged.)
>
Yeah, I was just matching perl, since I'm used to it. I don't care
which letter gets used, as long as the facility is there. (well, as
long as everyone agrees that '-classpath' is right out!)
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: -I for guile command line
2004-07-02 1:35 -I for guile command line Richard Todd
2004-07-10 0:12 ` Kevin Ryde
@ 2004-08-15 21:27 ` Marius Vollmer
2004-08-15 21:36 ` Richard Todd
1 sibling, 1 reply; 9+ messages in thread
From: Marius Vollmer @ 2004-08-15 21:27 UTC (permalink / raw)
Cc: guile-devel
Richard Todd <rwtodd@mac.com> writes:
> any interest in this patch? It lets you put -I on the guile command
> line, to add directories to the load path.
>
> as in:
> guile -I .. -I . script-in-development.scm
>
> I find this easier than mucking with that environment variable.
That's a nice feature, we should add it.
But, in which order should the arguments be added to the load path?
The usual way would be to add them in such a way that the first
argument is searched first, I'd say. You patch makes the frist one be
searched last.
Also, the command-line dirs should probably be searched before the
environment ones, which you patch does, but we need to document this
all properly.
I'd say we should use '-L' instead of '-I'.
Sooo, could you make a new patch that addresses the issues above, if
you agree?
--
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3 331E FAF8 226A D5D4 E405
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: -I for guile command line
2004-08-15 21:27 ` Marius Vollmer
@ 2004-08-15 21:36 ` Richard Todd
2004-08-15 23:17 ` Richard Todd
0 siblings, 1 reply; 9+ messages in thread
From: Richard Todd @ 2004-08-15 21:36 UTC (permalink / raw)
Cc: Richard Todd, guile-devel
On Aug 15, 2004, at 4:27 PM, Marius Vollmer wrote:
> Sooo, could you make a new patch that addresses the issues above, if
> you agree?
Sure.
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: -I for guile command line
2004-08-15 21:36 ` Richard Todd
@ 2004-08-15 23:17 ` Richard Todd
2004-08-15 23:18 ` Richard Todd
2004-08-21 17:45 ` Marius Vollmer
0 siblings, 2 replies; 9+ messages in thread
From: Richard Todd @ 2004-08-15 23:17 UTC (permalink / raw)
Cc: guile-devel, Marius Vollmer
On Aug 15, 2004, at 4:36 PM, Richard Todd wrote:
> On Aug 15, 2004, at 4:27 PM, Marius Vollmer wrote:
>
>> Sooo, could you make a new patch that addresses the issues above, if
>> you agree?
>
> Sure.
Try this patch... I think it addresses everything you mentioned. I
use '-L' now, and the paths end up in %load-path in command-line
left-to-right order. I made an attempt at documenting it in the .texi
files.
I chose to make the -L flags take effect _after_ loading the user's
.guile file, since I assume it'd be rare that a user actually wants to
redirect their standard startup modules on a per-run basis. If you
disagree with me, just move the place where I do the scm_append_x down
a couple lines.
Richard
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: -I for guile command line
2004-08-15 23:17 ` Richard Todd
@ 2004-08-15 23:18 ` Richard Todd
2004-08-21 17:45 ` Marius Vollmer
1 sibling, 0 replies; 9+ messages in thread
From: Richard Todd @ 2004-08-15 23:18 UTC (permalink / raw)
Cc: Marius Vollmer, guile-devel
[-- Attachment #1: Type: text/plain, Size: 43 bytes --]
this time, with the actual patch...sorry!
[-- Attachment #2: dash_L.patch --]
[-- Type: application/octet-stream, Size: 4790 bytes --]
Index: doc/ref/ChangeLog
===================================================================
RCS file: /cvsroot/guile/guile/guile-core/doc/ref/ChangeLog,v
retrieving revision 1.220
diff -u -r1.220 ChangeLog
--- doc/ref/ChangeLog 14 Aug 2004 01:06:13 -0000 1.220
+++ doc/ref/ChangeLog 15 Aug 2004 23:04:27 -0000
@@ -1,3 +1,7 @@
+2004-08-15 Richard Todd <rwtodd@mac.com>
+
+ * scheme-scripts.texi (Invoking Guile): documented new '-L' switch.
+
2004-08-14 Kevin Ryde <user42@zip.com.au>
* api-scheduling.texi (Mutexes): New datatype-centric section, adding
Index: doc/ref/scheme-scripts.texi
===================================================================
RCS file: /cvsroot/guile/guile/guile-core/doc/ref/scheme-scripts.texi,v
retrieving revision 1.1
diff -u -r1.1 scheme-scripts.texi
--- doc/ref/scheme-scripts.texi 2 Aug 2004 12:29:00 -0000 1.1
+++ doc/ref/scheme-scripts.texi 15 Aug 2004 23:04:28 -0000
@@ -103,6 +103,12 @@
@code{(@var{guile} @var{arg...})}, where @var{guile} is the path of the
Guile executable.
+@item -L @var{directory}
+Add @var{directory} to the front of Guile's module load path. The
+given directory is searched before any directories in the GUILE_LOAD_PATH
+environment variable. Paths added here are @emph{not} in effect during
+execution of the user's @file{.guile} file.
+
@item -l @var{file}
Load Scheme source code from @var{file}, and continue processing the
command line.
Index: libguile/ChangeLog
===================================================================
RCS file: /cvsroot/guile/guile/guile-core/libguile/ChangeLog,v
retrieving revision 1.2119
diff -u -r1.2119 ChangeLog
--- libguile/ChangeLog 13 Aug 2004 12:28:38 -0000 1.2119
+++ libguile/ChangeLog 15 Aug 2004 23:04:41 -0000
@@ -1,3 +1,8 @@
+2004-08-15 Richard Todd <rwtodd@mac.com>
+
+ * script.c (scm_compile_shell_switches): added '-L' switch to
+ add to the %load-path.
+
2004-08-13 Marius Vollmer <marius.vollmer@uni-dortmund.de>
* load.c (scm_init_load_path): Do not pass NULL to
Index: libguile/script.c
===================================================================
RCS file: /cvsroot/guile/guile/guile-core/libguile/script.c,v
retrieving revision 1.64
diff -u -r1.64 script.c
--- libguile/script.c 12 Aug 2004 17:35:53 -0000 1.64
+++ libguile/script.c 15 Aug 2004 23:04:42 -0000
@@ -361,6 +361,7 @@
"remaining arguments as the value of (command-line).\n"
"If FILE begins with `-' the -s switch is mandatory.\n"
"\n"
+ " -L DIRECTORY add DIRECTORY to the front of the module load path\n"
" -l FILE load Scheme source code from FILE\n"
" -e FUNCTION after reading script, apply FUNCTION to\n"
" command line arguments\n"
@@ -395,7 +396,9 @@
SCM_SYMBOL (sym_top_repl, "top-repl");
SCM_SYMBOL (sym_quit, "quit");
SCM_SYMBOL (sym_use_srfis, "use-srfis");
-
+SCM_SYMBOL (sym_load_path, "%load-path");
+SCM_SYMBOL (sym_set_x, "set!");
+SCM_SYMBOL (sym_cons, "cons");
/* Given an array of command-line switches, return a Scheme expression
to carry out the actions specified by the switches.
@@ -418,6 +421,7 @@
the "load" command, in case we get
the "-ds" switch. */
SCM entry_point = SCM_EOL; /* for -e switch */
+ SCM user_load_path = SCM_EOL; /* for -L switch */
int interactive = 1; /* Should we go interactive when done? */
int inhibit_user_init = 0; /* Don't load user init file */
int use_emacs_interface = 0;
@@ -496,6 +500,19 @@
scm_shell_usage (1, "missing argument to `-l' switch");
}
+ else if (! strcmp (argv[i], "-L")) /* add to %load-path */
+ {
+ if (++i < argc)
+ user_load_path = scm_cons (scm_list_3 (sym_set_x,
+ sym_load_path,
+ scm_list_3(sym_cons,
+ scm_makfrom0str (argv[i]),
+ sym_load_path)),
+ user_load_path);
+ else
+ scm_shell_usage (1, "missing argument to `-L' switch");
+ }
+
else if (! strcmp (argv[i], "-e")) /* entry point */
{
if (++i < argc)
@@ -629,6 +646,13 @@
/* After the following line, actions will be added to the front. */
tail = scm_reverse_x (tail, SCM_UNDEFINED);
+
+ /* add the user-specified load path here, so it won't be in effect
+ during the loading of the user's customization file. */
+ if(!SCM_NULLP(user_load_path))
+ {
+ tail = scm_append_x( scm_cons2(user_load_path, tail, SCM_EOL) );
+ }
/* If we didn't end with a -c or a -s and didn't supply a -q, load
the user's customization file. */
[-- Attachment #3: Type: text/plain, Size: 812 bytes --]
On Aug 15, 2004, at 6:17 PM, Richard Todd wrote:
> On Aug 15, 2004, at 4:36 PM, Richard Todd wrote:
>
>> On Aug 15, 2004, at 4:27 PM, Marius Vollmer wrote:
>>
>>> Sooo, could you make a new patch that addresses the issues above, if
>>> you agree?
>>
>> Sure.
>
> Try this patch... I think it addresses everything you mentioned. I
> use '-L' now, and the paths end up in %load-path in command-line
> left-to-right order. I made an attempt at documenting it in the .texi
> files.
>
> I chose to make the -L flags take effect _after_ loading the user's
> .guile file, since I assume it'd be rare that a user actually wants to
> redirect their standard startup modules on a per-run basis. If you
> disagree with me, just move the place where I do the scm_append_x down
> a couple lines.
>
> Richard
>
[-- Attachment #4: Type: text/plain, Size: 143 bytes --]
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: -I for guile command line
2004-08-15 23:17 ` Richard Todd
2004-08-15 23:18 ` Richard Todd
@ 2004-08-21 17:45 ` Marius Vollmer
1 sibling, 0 replies; 9+ messages in thread
From: Marius Vollmer @ 2004-08-21 17:45 UTC (permalink / raw)
Cc: guile-devel
Richard Todd <rwtodd@mac.com> writes:
> Try this patch... I think it addresses everything you mentioned.
Yep, excellent, thanks! I have applied it.
--
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3 331E FAF8 226A D5D4 E405
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2004-08-21 17:45 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-07-02 1:35 -I for guile command line Richard Todd
2004-07-10 0:12 ` Kevin Ryde
2004-07-10 1:28 ` Richard Todd
2004-08-15 21:27 ` Marius Vollmer
2004-08-15 21:36 ` Richard Todd
2004-08-15 23:17 ` Richard Todd
2004-08-15 23:18 ` Richard Todd
2004-08-21 17:45 ` Marius Vollmer
-- strict thread matches above, loose matches on Subject: below --
2004-07-05 17:56 Andy Wingo
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).