0

So I have a simple file.scm file with following code in it:

#!/usr/bin/guile -s 
!#
(define (printer arg)
  (display arg))

I know you can execute it inside guile repl by doing a (load "file.scm"), and then by invoking the function like (printer "this").

Is there is any way to run that function through the command-line terminal such as guile "file.scm" (printer "this") ?

Stephen Ostermiller
  • 23,933
  • 14
  • 88
  • 109
tvman
  • 13
  • 4

2 Answers2

1

According to the manual, something like

guile -l file.scm -c '(printer "this")'

will work.

Shawn
  • 47,241
  • 3
  • 26
  • 60
0

You could just use the -e flag

guile -e printer file.scm 1 2 3

Or better yet

#!/usr/bin/env -S guile -e printer
!#

(define (printer args)
  (display args))

and run as

./file.scm 1 2 3

Many other (official) Guile Scripting examples: https://www.gnu.org/software/guile/manual/html_node/Scripting-Examples.html

lycuid
  • 2,555
  • 1
  • 18
  • 28