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

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

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

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

unofficial mirror of guile-user@gnu.org 

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://yhetil.org/guile-user/0 guile-user/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 guile-user guile-user/ https://yhetil.org/guile-user \
		guile-user@gnu.org
	public-inbox-index guile-user

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.lisp.guile.user
	nntp://news.gmane.io/gmane.lisp.guile.user


AGPL code for this site: git clone http://ou63pmih66umazou.onion/public-inbox.git