unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* env, -l and command line arguments
@ 2021-02-20 22:54 Formbi
  2021-02-21  4:13 ` Nala Ginrut
  0 siblings, 1 reply; 3+ messages in thread
From: Formbi @ 2021-02-20 22:54 UTC (permalink / raw)
  To: guile-user@gnu.org

Hi

I'd like to make a script and be able to jump into the REPL if needed (for example if «--repl» is not passed, «(exit)» is run). I also run Guile through env -S, because I'm on Guix and I wanna make the script portable.

However, I can't find an easy way to do it. When I use «-l» and pass some command-line arguments to the script, Guile crashes because it interprets the arguments as files to load. When I use «-l --», it crashes because it can't find the «--» file. When I use «-- -l», it doesn't load the file. Even weirder to me is the fact that if I just put «(exit)» in the script, Guile doesn't crash.

I kinda managed to get the REPL functionality using some Bash shenanigans made by someone else, but shouldn't there be an easier way? Or does it exist, but I haven't stumbled upon it?



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: env, -l and command line arguments
  2021-02-20 22:54 env, -l and command line arguments Formbi
@ 2021-02-21  4:13 ` Nala Ginrut
  2021-02-21 21:45   ` Formbi via General Guile related discussions
  0 siblings, 1 reply; 3+ messages in thread
From: Nala Ginrut @ 2021-02-21  4:13 UTC (permalink / raw)
  To: Formbi; +Cc: guile-user@gnu.org

Hi Fombi!
I find it's not easy to understand what you want to do, could you give us
an example?

Best regards.

On Sun, Feb 21, 2021 at 7:43 AM Formbi <formbi@protonmail.com> wrote:

> Hi
>
> I'd like to make a script and be able to jump into the REPL if needed (for
> example if «--repl» is not passed, «(exit)» is run). I also run Guile
> through env -S, because I'm on Guix and I wanna make the script portable.
>
> However, I can't find an easy way to do it. When I use «-l» and pass some
> command-line arguments to the script, Guile crashes because it interprets
> the arguments as files to load. When I use «-l --», it crashes because it
> can't find the «--» file. When I use «-- -l», it doesn't load the file.
> Even weirder to me is the fact that if I just put «(exit)» in the script,
> Guile doesn't crash.
>
> I kinda managed to get the REPL functionality using some Bash shenanigans
> made by someone else, but shouldn't there be an easier way? Or does it
> exist, but I haven't stumbled upon it?
>
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: env, -l and command line arguments
  2021-02-21  4:13 ` Nala Ginrut
@ 2021-02-21 21:45   ` Formbi via General Guile related discussions
  0 siblings, 0 replies; 3+ messages in thread
From: Formbi via General Guile related discussions @ 2021-02-21 21:45 UTC (permalink / raw)
  To: Nala Ginrut; +Cc: guile-user@gnu.org

Hi

> I find it's not easy to understand what you want to do, could you give us an example?

I wanted to be able to do something like that:
(unless
(or
(member "-r" (command-line))
(member "--repl" (command-line)))

(begin
(display "foo")
(newline)
(exit)))

And I figured out how to do it (and it's even more portable):
#!/bin/sh
exec guile -l "$0" -- "$@"
!#

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-02-21 21:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-20 22:54 env, -l and command line arguments Formbi
2021-02-21  4:13 ` Nala Ginrut
2021-02-21 21:45   ` Formbi via General Guile related discussions

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).