Thus document describes how you can make CLISP your login shell on GNU/Linux.
You can probably use these instructions on other UNIX systems too.
last modified: 2001-06-01
Notes marked NB from SDS were added by Sam Steingold.
On Linux, you need to have built your
CLISP with the
--with-module=bindings/glibc
option,
and you should make sure that you have it compiled with readline.
See the CLISP build instructions and Makefile.
Put /usr/bin/clisp
(or /usr/local/bin/clisp
)
in /etc/shells
so it looks (something) like this:
# /etc/shells: valid login shells #/bin/ash /bin/bash /bin/sh /usr/bin/clisp
You can set up your $PATH
in
/etc/login.defs
by modifying the entry for
ENV_PATH
to look (something) like this:
ENV_PATH PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
Once you have your CLISP shell set up, you can control the
environment variables (on Linux) via the glibc bindings (see
${clisp-src}/modules/bindings/glibc/linux.lisp
):
setenv, putenv, getenv, etc.
CLISP has a setf
able built-in
ext:getenv
,
e.g., (setf (ext:getenv "foo") "bar")
.
The startx
command is a shell script, so we cannot use it.
As a temporary fix, I have defunned thus:
(defun startx () (execute "/usr/X11R6/bin/xinit"))
Which works for me. Although I haven't investigated all the
consequences of not going via shell's startx. Also I do not use
GNOME or
KDE which may complicate
things for you if you do.
I use fvwm2
and have this in my .xinitrc
:
exec fvwm2
Once CLISP is set up, you will also be able to type:
> #[xinit]
from Lisp to start X.
You should be able to run a shell script using the
CLISP built-in function
ext:shell
.
For conveniently running external programs (i.e., I do not want to
have to type (run-program "ls" :arguments '("-lh"))
every
time) I have set up a read macro.
Put the following in somefile.lisp
:
(set-macro-character #\] (get-macro-character #\))) (set-dispatch-macro-character #\# #\[ (lambda (stream char1 char2) (declare (ignore char1 char2)) (setf (readtable-case *readtable*) :preserve) (unwind-protect (let ((command-line (read-delimited-list #\] stream t))) (list 'ext:run-program (princ-to-string (car command-line)) :arguments `',(mapcar #'princ-to-string (rest command-line)))) (setf (readtable-case *readtable*) :upcase))))
I heavily modified this macro.
Note that
ext:run-program
will not execute shell scripts, while
ext:shell
will invoke a shell for each command - these are the trade-offs.
It's also a PITA to have to type "#[" and "]" everytime you want to
run a command, so add the following in your
$HOME/.inputrc
:
#for clash: prints the square brackets to run an external command "\ec": "#[]\C-b"
When you type ESC-c (or META-c) readline will print "#[]" to the console and put the cursor inside the brackets. If you are running CLISP as your shell, and do this, you will then be able to run programs (more or less) normally. You will need to escape the dot in any filenames that start with a dot, e.g.,
> #[cat \.xinitrc]
and sometimes (eek) a colon.
Do NOT modify your /etc/passwd
yet!
Start up a clisp with
$ clisp -K full -i somefile.fas
Hit ESC c, type ls -l, hit Enter and see if it works.
You do not have command line completion for external
programs inside the read-macro. So hitting tab will just give you a
list of all CLISP's possibilties, which is not much use here. However,
ext:run-program
(which is part of what's hiding behind the
read macro) does search your path for executables so you don't have to
do #[/bin/ls -l]
There are CLISP built-ins like
ext:dir
and
ext:cd
, and most other
shell built-ins can be implemented in CLISP pretty easily.
If you are happy, and think you can live with this setup then you must do the following:
/usr/[local]/lib/clisp
.
(wherever yours is installed)/usr/lib/clisp
to "orig-base".Change your /etc/passwd
to reflect your new shell.
Light 13 candles in a circle round your Linux box, Sacrifice a white rooster, invoke Saint IGNUcious and ...
Login again.
If you start pining for Bash, you can run:
> #[bash]
You will have to explicitly source all your configuration files (.profile etc)
Have fun,
Peter