minibuffer

How to run some Emacs Lisp code in batch mode?

September 23, 2023
◉ tony@tony:~/minibuffer:
$ emacs --batch
◉ tony@tony:~/minibuffer:
$ emacs --batch --eval '(+ 1 1)'
◉ tony@tony:~/minibuffer:
$ emacs --batch --eval '(message "%s" (+ 1 1))'
2
◉ tony@tony:~/minibuffer:
$ emacs --batch --eval '(message "%s" (+ 1 1))' 2>err
◉ tony@tony:~/minibuffer:
$ cat err
2
◉ tony@tony:~/minibuffer:
$ emacs --batch --eval '(princ (+ 1 1))'
2◉ tony@tony:~/minibuffer:
$ emacs --batch --eval '(princ (+ 1 1))' 2>err
2◉ tony@tony:~/minibuffer:
$ emacs --batch --eval '(princ (read-string ""))'
^C◉ tony@tony:~/minibuffer:
$ echo foo | emacs --batch --eval '(princ (read-string ""))'
foo