vipsi - the built-in words
Author: kio@little-bat.de
Keywords: vipsi shell script interpreter programming

# vipsi - shell and script language

## the built-in words

### other functions

functions which return lists, no value or values of varying type.

#### env

    list = env

create environment variables list.

returns a list with one item for each environment variable. each item is a text containing the variable's value. each item is named with the environment variable's name.

e.g.:

        var e=env,i=0;
        do
            while ++i<=count e
            put name e[i], "=", e[i], nl
        loop

#### dir

    (1) dir [#number,] dirpath
    (2) list = dir dirpath

(1) print or (2) return contents of directory dirpath.
dirpath may be full or partial or start with ~ for user's home directory and may contain a match pattern with wildcards for files to list.

displayed length is in bytes for files or number of entries for directories or bytes (characters) for symbolic links. symbolic links are not followed. information on the link is returned instead.

flags[1] is 'd' for directories and 'l' for symbolic links.

if you pass an empty text for dirpath, then a list of mounted devices with lots of information is returned. not all information can currently be deduced on all systems.

(1) statement: print beautified folder listing to stdout or supplied stream number.

    vipsi> dir "./var*"

    Folder unix/var*                                  35.882 GB free

    file or folder name             flags    length  modified
    ------------------------------- ---- ----------  -------------------
    var.o                           -rw-      51072  2003-10-20 20:02:52
    var_test_suite.o                -rw-      87544  2003-10-20 20:02:52

    vipsi> dir ""

    Host: vanilla; User: kio(no group); SysLoad: 0.09,0.13,0.10
    Time: 2003-10-20 20:33:07; Booted: 2003-10-20 17:02:38 (3h:30m:29s);

    volume name                     flags      free  modified
    ------------------------------- ---- ----------  -------------------
    /                               drwx   4.710 GB  2003-10-20 20:26:17
    /home                           drwx  41.750 GB  2003-10-20 20:25:02
    /local                          drwx  20.199 GB  2003-10-20 20:26:17

    vipsi>

(2) function: returns a 2-dimensional list:
the returned list consists of 1 item per directory entry. each item in return is a list of currently 6 named items. you should access them by name, not by position.
time values are time stamps as for now and can be converted to readable text with datestr.

    vipsi> put nl, dir "var.o", nl
    { { fname="var.o", flags="-rw-", length=51072, mtime=1066577579,
    atime=1066672972, ctime=1066577579 } }

    vipsi> put nl, (dir "")[1], nl /*show only first drive*/
    { fname="/", flags="drwx", length=21, mtime=1066662175, atime=1066675052,
    ctime=1066662175, fs_type_id=61267, mountflags="((not implemented))",
    blocksize=4096, iosize=4096, blocks=2027999, blocksfree=1046917,
    blocksfree_su=1149933, files=1030176, filesfree=844014,
    owner="((unknown))", fstype="ext3", mountpoint="/", device="/dev/hda3",
    bytes=8306683904, bytesfree=4710125568, bytesfree_su=0 }

    vipsi>