Sysquake Pro – Table of Contents
Sysquake for LaTeX – Table of Contents
Extension - Shell
This section describes functions related to the Unix or Windows shell. They are available only on Windows and on Unix (or Unix-like) systems, such as macOS.
The versions for Unix and Windows have significant differences:
- Most functions described here are defined on both Unix and Windows, to avoid errors when loading functions which contain conditional code for Unix and Windows. Functions with an empty implementation return the error "Not supported". Table below gives the status of all commands.
- On Windows, some of the functionality of unix is provided by dos. The main difference is that dos does not give any output, except for the status code of the command.
Command | Unix | Windows |
---|---|---|
cd | supported | supported |
cputime | supported | undefined |
dir | supported | supported |
dos | not supported | supported |
getenv | supported | supported |
pwd | supported | supported |
setenv | supported | not supported |
sleep | supported | supported |
unix | supported | not supported |
unsetenv | supported | not supported |
Functions
cd
Set or get the current directory.
Syntax
cd(str) str = cd
Description
cd(str) changes the current directory. Without input argument, cd gives the current directory, like pwd.
The current directory is the root directory where files specified by relative paths are searched by functions like fopen and dir. LME libraries are specified by name, not by path; the places where they are searched is specified by a list of search paths, typically specified with a path command or a dialog box in a graphical user interface.
Example
cd('/usr/include');
See also
cputime
Amount of processing time since the beginning of the process.
Syntax
t = cputime
Description
cputime gives the amount of processing time spent since the application has been launched.
See also
dir
List of files and directories.
Syntax
dir dir(path) r = dir r = dir(path)
Description
dir displays the list of files and directories in the current path. A string input argument can specify the path.
With an output argument, dir returns the list of files and directories as a structure array with the following fields:
Name | Value |
---|---|
name | file name or directory name |
isdir | false for files, true for directories |
altname | alternate name (Windows only) |
Field isdir may be missing on some patforms. On Windows, altname contains the DOS-compatible name (a.k.a. "8.3") if it exists, or an empty string otherwise.
See also
dos
Execute a command under Windows.
Syntax
status = dos(str)
Description
dos(str) executes a command with the system Windows function. No input can be provided, and output is discarded. dos returns the status code of the command, which is normally 0 for successful execution.
Example
dos('del C:/tmp/data.txt');
See also
getenv
Get the value of an environment variable.
Syntax
value = getenv(name)
Description
getenv(name) gives the value of the environment variable of the specified name. If no such environment variable exists, getenv returns an empty string.
Example
user = getenv('USER');
See also
pwd
Get the current directory.
Syntax
str = pwd
Description
pwd ("print working directory") gives the current directory. It has the same effect as cd without input argument.
See also
setenv
Set the value of an environment variable.
Syntax
setenv(name, value) setenv(name)
Description
setenv(name,value) sets the value of the environment variable of the specified name. Both arguments are strings. If no such environment variable exists, it is created.
With a single input argument, setenv creates an empty environment variable (or remove the value of an exisisting environment variable).
Environment variables are defined in the context of the application; they can be accessed in the application or in processes it launches. Environment variables of the calling process (command shell, for instance) are not changed.
setenv is not defined for Windows.
Example
setenv('CONTROLDEBUG', '1');
See also
sleep
Suspend execution for a specified amount of time.
Syntax
sleep(t)
Description
sleep(t) suspend execution during t seconds with a resolution of a microsecond.
Example
sleep(1e-3);
unix
Execute a Unix command.
Syntax
unix(str)
Description
unix(str) executes a command with the default shell. No input can be provided, and output is directed to the standard output of LME.
Examples
unix ls unix('cc -o calc calc.c; ./calc')
See also
unsetenv
Remove an environment variable.
Syntax
unsetenv(name)
Description
unsetenv(name) removes the definition of the environment variable of the specified name. Argument is a string. If no such environment variable exists, unsetenv does nothing.
Environment variables are defined in the context of the application; they can be accessed in the application or in processes it launches. Environment variables of the calling process (command shell, for instance) are not changed.
unsetenv is not defined for Windows.
Example
unsetenv('CONTROLDEBUG');