1SLSH(1)                                                                SLSH(1)
2
3
4

NAME

6       slsh - Interpreter for S-Lang scripts
7

SYNOPSIS

9       slsh  [  --help  ]  [ --version ] [ -g ] [ -n ] [ --init file ] [ --no-
10       readline ] [ -e string ] [ -i ] [ -q, --quiet  ]  [  -t  ]  [  -v  ]  [
11       -|script-file args... ]
12
13

DESCRIPTION

15       slsh  is a simple program for interpreting S-Lang scripts.  It supports
16       dynamic loading of S-Lang modules and includes a readline interface for
17       interactive use.
18

OPTIONS

20       --help Show a summary of options
21
22       --version
23              Show slsh version information
24
25       -g     Compile with debugging code, tracebacks, etc
26
27       -n     Don't load the personal initialization file
28
29       --init file
30              Use this file instead of ~/.slshrc
31
32       --no-readline
33              Do not use a readline interface for the interactive mode
34
35       -e string
36              Execute ``string'' as S-Lang code.
37
38       -i     Force  interactive mode.  Normally slsh will go into interactive
39              mode if both stdin and stdout are attached to a terminal.
40
41       -q, --quiet
42              Startup quietly by not printing the version and copyright infor‐
43              mation.
44
45       -t     Normally,  slsh  will call slsh_main if it is defined.  This op‐
46              tion prevents that from happening making it useful for  checking
47              for syntax error.
48
49       -v     Show  verbose  loading messages.  This is useful for seeing what
50              files are being loaded.
51

INITIALIZATION

53       Upon startup, the program will try to load slsh.rc as follows.  If  ei‐
54       ther  SLSH_CONF_DIR  or  SLSH_LIB_DIR environment variables exist, then
55       slsh will look look in the corresponding directories for slsh.rc.  Oth‐
56       erwise it will look in:
57
58       $(prefix)/etc/   (as specified in the Makefile)
59
60       /usr/local/etc/
61
62       /usr/local/etc/slsh/
63
64       /etc/
65
66       /etc/slsh/
67
68       The  slsh.rc file may load other files from slsh's library directory in
69       the manner described below.
70
71       Once slsh.rc has been loaded, slsh will load $HOME/.slshrc if  present.
72       Finally, it will load the script specified on the command line.  If the
73       name of the script is -, then it will  be  read  from  stdin.   If  the
74       script  name  is  not present, or a string to execute was not specified
75       using the -e option, then slsh will go into interactive mode  and  read
76       input  from the terminal.  If the script is present and defines a func‐
77       tion called slsh_main, that function will be called.
78

LOADING FILES

80       When a script loads a file via the built-in evalfile  function  or  the
81       require  function  (autoloaded  by  slsh.rc),  the file is searched for
82       along the SLSH_PATH as specified in the Makefile.   An  alternate  path
83       may be specified by the SLSH_PATH environment variable.
84
85       The  search  path  may  be  queried  and  set  during  run time via the
86       get_slang_load_path and set_slang_load_path functions, e.g.,
87
88          set_slang_load_path ("/home/bill/lib/slsh:/usr/share/slsh");
89

INTERACTIVE MODE

91       When slsh is invoked without a script or is given the -i  command  line
92       argument,  it  will  go  into into interactive mode.  In this mode, the
93       user will be prompted for input.  The program will leave this mode  and
94       exit  if  it sees an EOF (Ctrl-D) or the user exits by issuing the quit
95       command.
96
97       If an uncaught exception occurs during execution of a command, the  er‐
98       ror message will be shown and the user will be prompted for more input.
99
100       Any  objects  left on the stack after a command will be printed and the
101       stack cleared.  This makes interactive mode  useful  as  a  calculator,
102       e.g.,
103
104            slsh> 3*10;
105            30
106            slsh> x = [1:20];
107            slsh> sum (sin(x)-cos(x));
108            0.458613
109            slsh> quit;
110       Note that in this mode, variables are automatically declared.
111
112       The interactive mode also supports command logging.  Logging is enabled
113       by the start_log function.  The stop_log function will  turn  off  log‐
114       ging.   The  default  file where logging information will be written is
115       slsh.log.  An alternative may be specified as an optional  argument  to
116       the start_log function:
117
118            slsh> start_log;
119            Logging input to slsh.log
120               .
121               .
122            slsh> stop_log;
123            slsh> start_log("foo.log");
124            Logging input to foo.log
125               .
126               .
127            slsh> stop_log;
128            slsh> start_log;
129            Logging input to foo.log
130
131       Similarly, the save_input function may be used to save the previous in‐
132       put to a specified file:
133
134            slsh> save_input;
135            Input saved to slsh.log
136            slsh> save_input ("foo.log");
137            Input saved to foo.log
138
139       As the above examples indicate, lines must end in a semicolon.  This is
140       a  basic  feature of the language and permits commands to span multiple
141       lines, e.g.,
142
143            slsh> x = [
144                   1,2,3,
145                   4,5,6];
146            slsh> sum(x);
147       For convenience some users prefer that commands be automatically termi‐
148       nated  with  a semicolon.  To have a semicolon silently appended to the
149       end of an input line, put the following in $HOME/.slshrc file:
150
151           #ifdef __INTERACTIVE__
152           slsh_append_semicolon (1);
153           #endif
154
155       The interactive mode also supports shell escapes.  To pass a command to
156       the shell, prefix it with !, e.g.,
157
158           slsh> !pwd
159           /grandpa/d1/src/slang2/slsh
160           slsh> !cd doc/tm
161           slsh> !pwd
162           /grandpa/d1/src/slang2/slsh/doc/tm
163
164       Finally, the interactive mode supports a help and apropos function:
165
166           slsh> apropos list
167           apropos list ==>
168           List_Type
169           list_append
170           list_delete
171              .
172              .
173           slsh> help list_append
174           list_append
175
176            SYNOPSIS
177              Append an object to a list
178
179            USAGE
180              list_append (List_Type, object, Int_Type nth)
181              .
182              .
183       For convenience, the help and apropos functions do not require the syn‐
184       tactic constraints of the other functions.
185

READLINE HISTORY MECHANISM

187       By default, slsh is built to use the S-Lang readline  interface,  which
188       includes  a  customizable  command  completion and a history mechanism.
189       When slsh (or any S-Lang application that makes use  of  this  feature)
190       starts  in interactive mode, it will look for a file in the user's home
191       directory called .slrlinerc and load it if present.  This  file  allows
192       the  user to customize the readline interface and enable the history to
193       be saved between sessions.  As an example, here is a version of the au‐
194       thor's .slrlinerc file:
195
196            % Load some basic functions that implement the history mechanism
197            () = evalfile ("rline/slrline.rc");
198            % The name of the history file -- expands to .slsh_hist for slsh
199            RLine_History_File = "$HOME/.${name}_hist";
200
201            % Some addition keybindings.  Some of these functions are defined
202            % in rline/editfuns.sl, loaded by rline/slrline.rc
203            rline_unsetkey ("^K");
204            rline_setkey ("bol",   "^B");
205            rline_setkey ("eol",   "^E");
206            rline_setkey (&rline_kill_eol,  "^L");
207            rline_setkey (&rline_set_mark,  "^K^B");
208            rline_setkey (&rline_copy_region, "^Kk");
209            rline_setkey (&rline_kill_region, "^K^V");
210            rline_setkey (&rline_yank,  "^K^P");
211            rline_setkey ("redraw",   "^R");
212
213            #ifexists rline_up_hist_search
214            % Map the up/down arrow to the history search mechanism
215            rline_setkey (&rline_up_hist_search, "\e[A");
216            rline_setkey (&rline_down_hist_search, "\e[B");
217            #endif
218
219            #ifexists rline_edit_history
220            rline_setkey (&rline_edit_history, "^Kj");
221            #endif
222
223            % Add a new function
224            private define double_line ()
225            {
226               variable p = rline_get_point ();
227               variable line = rline_get_line ();
228               rline_eol ();
229               variable pend = rline_get_point ();
230               rline_ins (line);
231               rline_set_point (pend + p);
232            }
233           rline_setkey (&double_line,  "^K^L");
234

MISCELLANEOUS SCRIPTS

236       Several    useful    example    scripts    are    located    in   $pre‐
237       fix/share/slsh/scripts/, where $prefix represents the slsh installation
238       prefix (/usr, /usr/local,...).  These scripts include:
239
240       sldb   A script that runs the S-Lang debugger.
241
242       jpegsize
243              Reports the size of a jpeg file.
244
245       svnsh  A shell for browsing an SVN repository.
246

AUTHOR

248       The  principal  author of slsh is John E. Davis <www.jedsoft.org>.  The
249       interactive mode was provided by Mike Noble.  The S-Lang  library  upon
250       which  slsh  is  based is primarily the work of John E. Davis with help
251       from many others.
252
253       This manual page was originally written by Rafael Laboissiere  for  the
254       Debian system (but may be used by others).
255
256       Permission  is  granted to copy, distribute and/or modify this document
257       under the terms of the GNU General Public License, Version 2 any  later
258       version published by the Free Software Foundation.
259
260       On  Debian systems, the complete text of the GNU General Public License
261       can be found in /usr/share/common-licenses/GPL
262
263
264
265                               19 February 2021                        SLSH(1)
Impressum