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

READLINE HISTORY MECHANISM

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

MISCELLANEOUS SCRIPTS

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

AUTHOR

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