.\" This manpage has been automatically generated by docbook2man .\" from a DocBook document. This tool can be found at: .\" .\" Please send any bug reports, improvements, comments, patches, .\" etc. to Steve Cheng . .TH "SLSH" "1" "19 February 2021" "" "" .SH NAME slsh \- Interpreter for S-Lang scripts .SH SYNOPSIS \fBslsh\fR [ \fB--help\fR ] [ \fB--version\fR ] [ \fB-g\fR ] [ \fB-n\fR ] [ \fB--init \fIfile\fB\fR ] [ \fB--no-readline\fR ] [ \fB-e \fIstring\fB\fR ] [ \fB-i\fR ] [ \fB-q, --quiet\fR ] [ \fB-t\fR ] [ \fB-v\fR ] [ \fB-|\fIscript-file args...\fB\fR ] .SH "DESCRIPTION" .PP \fBslsh\fR is a simple program for interpreting S-Lang scripts. It supports dynamic loading of S-Lang modules and includes a readline interface for interactive use. .SH "OPTIONS" .TP \fB--help\fR Show a summary of options .TP \fB--version\fR Show \fBslsh\fR version information .TP \fB-g\fR Compile with debugging code, tracebacks, etc .TP \fB-n\fR Don't load the personal initialization file .TP \fB--init \fIfile\fB\fR Use this file instead of ~/.slshrc .TP \fB--no-readline\fR Do not use a readline interface for the interactive mode .TP \fB-e \fIstring\fB\fR Execute ``string'' as S-Lang code. .TP \fB-i\fR Force interactive mode. Normally \fBslsh\fR will go into interactive mode if both stdin and stdout are attached to a terminal. .TP \fB-q, --quiet\fR Startup quietly by not printing the version and copyright information. .TP \fB-t\fR Normally, \fBslsh\fR will call slsh_main if it is defined. This option prevents that from happening making it useful for checking for syntax error. .TP \fB-v\fR Show verbose loading messages. This is useful for seeing what files are being loaded. .SH "INITIALIZATION" .PP Upon startup, the program will try to load \fIslsh.rc\fR as follows. If either SLSH_CONF_DIR or SLSH_LIB_DIR environment variables exist, then \fBslsh\fR will look look in the corresponding directories for \fIslsh.rc\fR\&. Otherwise it will look in: \fI$(prefix)/etc/\fR (as specified in the Makefile) \fI/usr/local/etc/\fR \fI/usr/local/etc/slsh/\fR \fI/etc/\fR \fI/etc/slsh/\fR .PP The \fIslsh.rc\fR file may load other files from slsh's library directory in the manner described below. .PP Once \fIslsh.rc\fR has been loaded, \fBslsh\fR will load $HOME/.slshrc if present. Finally, it will load the script specified on the command line. If the name of the script is -, then it will be read from stdin. If the script name is not present, or a string to execute was not specified using the -e option, then \fBslsh\fR will go into interactive mode and read input from the terminal. If the script is present and defines a function called slsh_main, that function will be called. .SH "LOADING FILES" .PP When a script loads a file via the built-in evalfile function or the require function (autoloaded by slsh.rc), the file is searched for along the SLSH_PATH as specified in the Makefile. An alternate path may be specified by the SLSH_PATH environment variable. .PP The search path may be queried and set during run time via the get_slang_load_path and set_slang_load_path functions, e.g., .nf set_slang_load_path ("/home/bill/lib/slsh:/usr/share/slsh"); .fi .SH "INTERACTIVE MODE" .PP When \fBslsh\fR is invoked without a script or is given the \fB-i\fR command line argument, it will go into into interactive mode. In this mode, the user will be prompted for input. The program will leave this mode and exit if it sees an EOF (Ctrl-D) or the user exits by issuing the quit command. .PP If an uncaught exception occurs during execution of a command, the error message will be shown and the user will be prompted for more input. .PP Any objects left on the stack after a command will be printed and the stack cleared. This makes interactive mode useful as a calculator, e.g., .nf slsh> 3*10; 30 slsh> x = [1:20]; slsh> sum (sin(x)-cos(x)); 0.458613 slsh> quit; .fi Note that in this mode, variables are automatically declared. .PP The interactive mode also supports command logging. Logging is enabled by the start_log function. The stop_log function will turn off logging. The default file where logging information will be written is \fIslsh.log\fR\&. An alternative may be specified as an optional argument to the start_log function: .nf slsh> start_log; Logging input to slsh.log \&. \&. slsh> stop_log; slsh> start_log("foo.log"); Logging input to foo.log \&. \&. slsh> stop_log; slsh> start_log; Logging input to foo.log .fi .PP Similarly, the save_input function may be used to save the previous input to a specified file: .nf slsh> save_input; Input saved to slsh.log slsh> save_input ("foo.log"); Input saved to foo.log .fi .PP As the above examples indicate, lines must end in a semicolon. This is a basic feature of the language and permits commands to span multiple lines, e.g., .nf slsh> x = [ 1,2,3, 4,5,6]; slsh> sum(x); .fi For convenience some users prefer that commands be automatically terminated with a semicolon. To have a semicolon silently appended to the end of an input line, put the following in \fI$HOME/.slshrc\fR file: .nf #ifdef __INTERACTIVE__ slsh_append_semicolon (1); #endif .fi .PP The interactive mode also supports shell escapes. To pass a command to the shell, prefix it with !, e.g., .nf slsh> !pwd /grandpa/d1/src/slang2/slsh slsh> !cd doc/tm slsh> !pwd /grandpa/d1/src/slang2/slsh/doc/tm .fi .PP Finally, the interactive mode supports a help and apropos function: .nf slsh> apropos list apropos list ==> List_Type list_append list_delete \&. \&. slsh> help list_append list_append SYNOPSIS Append an object to a list USAGE list_append (List_Type, object, Int_Type nth) \&. \&. .fi For convenience, the help and apropos functions do not require the syntactic constraints of the other functions. .SH "READLINE HISTORY MECHANISM" .PP By default, \fBslsh\fR is built to use the S-Lang readline interface, which includes a customizable command completion and a history mechanism. When \fBslsh\fR (or any S-Lang application that makes use of this feature) starts in interactive mode, it will look for a file in the user's home directory called \fI\&.slrlinerc\fR and load it if present. This file allows the user to customize the readline interface and enable the history to be saved between sessions. As an example, here is a version of the author's \fI\&.slrlinerc\fR file: .nf % Load some basic functions that implement the history mechanism () = evalfile ("rline/slrline.rc"); % The name of the history file -- expands to .slsh_hist for slsh RLine_History_File = "$HOME/.${name}_hist"; % Some addition keybindings. Some of these functions are defined % in rline/editfuns.sl, loaded by rline/slrline.rc rline_unsetkey ("^K"); rline_setkey ("bol", "^B"); rline_setkey ("eol", "^E"); rline_setkey (&rline_kill_eol, "^L"); rline_setkey (&rline_set_mark, "^K^B"); rline_setkey (&rline_copy_region, "^Kk"); rline_setkey (&rline_kill_region, "^K^V"); rline_setkey (&rline_yank, "^K^P"); rline_setkey ("redraw", "^R"); #ifexists rline_up_hist_search % Map the up/down arrow to the history search mechanism rline_setkey (&rline_up_hist_search, "\\e[A"); rline_setkey (&rline_down_hist_search, "\\e[B"); #endif #ifexists rline_edit_history rline_setkey (&rline_edit_history, "^Kj"); #endif % Add a new function private define double_line () { variable p = rline_get_point (); variable line = rline_get_line (); rline_eol (); variable pend = rline_get_point (); rline_ins (line); rline_set_point (pend + p); } rline_setkey (&double_line, "^K^L"); .fi .SH "MISCELLANEOUS SCRIPTS" .PP Several useful example scripts are located in \fI$prefix/share/slsh/scripts/\fR, where $prefix represents the \fBslsh\fR installation prefix (\fI/usr\fR, \fI/usr/local\fR,...). These scripts include: .TP \fBsldb\fR A script that runs the S-Lang debugger. .TP \fBjpegsize\fR Reports the size of a jpeg file. .TP \fBsvnsh\fR A shell for browsing an SVN repository. .SH "AUTHOR" .PP The principal author of \fBslsh\fR is John E. Davis \&. The interactive mode was provided by Mike Noble. The S-Lang library upon which \fBslsh\fR is based is primarily the work of John E. Davis with help from many others. .PP This manual page was originally written by Rafael Laboissiere for the Debian system (but may be used by others). .PP Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 any later version published by the Free Software Foundation. .PP On Debian systems, the complete text of the GNU General Public License can be found in \fI/usr/share/common-licenses/GPL\fR