Next: , Up: shell   [Contents][Index]


23.2.1 Shell Variables

A number of gdbmtool parameters is kept in its internal variables. To examine or modify variables, use the set command (see set).

gdbmtool variable: bool confirm

Whether to ask for confirmation before certain destructive operations, such as truncating the existing database.

Default is true.

gdbmtool variable: string ps1

Primary prompt string. Its value can contain conversion specifiers, consisting of the ‘%’ character followed by another character. These specifiers are expanded in the resulting prompt as follows:

SequenceExpansion
%fname of the current database file
%pprogram invocation name
%Ppackage name (GDBM)
%vprogram version
%_single space character
%%%

The default value is ‘%p>%_’, i.e. the program name, followed by a “greater than” sign, followed by a single space.

gdbmtool variable: string ps2

Secondary prompt. See ps1 for a description of its value. This prompt is displayed before reading the second and subsequent lines of a multi-line command.

The default value is ‘%_>%_’.

gdbmtool variable: string delim1

A string used to delimit fields of a structured datum on output (see definitions).

Default is ‘,’ (a comma). This variable cannot be unset.

gdbmtool variable: string delim2

A string used to delimit array items when printing a structured datum (see definitions).

Default is ‘,’ (a comma). This variable cannot be unset.

gdbmtool variable: string pager

The name and command line of the pager program to pipe output to. This program is used in interactive mode when the estimated number of output lines is greater then the number of lines on your screen.

The default value is inherited from the environment variable PAGER. Unsetting this variable disables paging.

gdbmtool variable: bool quiet

Whether to display a welcome banner at startup. To affect gdbmtool, this variable should be set in a startup script file (see startup files). See -q option.

The following variables control how the database is opened:

gdbmtool variable: numeric blocksize

Sets the block size. See block_size. Unset by default.

gdbmtool variable: numeric cachesize

Sets the cache size. See GDBM_SETCACHESIZE. By default this variable is not set.

gdbmtool variable: string open

Open mode. The following values are allowed:

newdb

Truncate the database if it exists or create a new one. Open it in read-write mode.

Technically, this sets the GDBM_NEWDB flag in call to gdbm_open. See GDBM_NEWDB.

wrcreat
rw

Open the database in read-write mode. Create it if it does not exist. This is the default.

Technically speaking, it sets the GDBM_WRCREAT flag in call to gdbm_open. See GDBM_WRCREAT.

reader
readonly

Open the database in read-only mode. Signal an error if it does not exist.

This sets the GDBM_READER flag (see GDBM_READER).

Attempting to set any other value or to unset this variable results in error.

gdbmtool variable: number filemode

File mode (in octal) for creating new database files and database dumps.

gdbmtool variable: bool lock

Lock the database. This is the default.

Setting this variable to false or unsetting it results in passing GDBM_NOLOCK flag to gdbm_open (see GDBM_NOLOCK).

gdbmtool variable: bool mmap

Use memory mapping. This is the default.

Setting this variable to false or unsetting it results in passing GDBM_NOMMAP flag to gdbm_open (see GDBM_NOMMAP).

gdbmtool variable: bool sync

Flush all database writes on disk immediately. Default is false. See GDBM_SYNC.

gdbmtool variable: bool coalesce

Enables the coalesce mode, i.e. merging of the freed blocks of GDBM files with entries in available block lists. This provides for effective memory management at the cost of slight increase in execution time when calling gdbm_delete. See GDBM_SETCOALESCEBLKS.

This variable affects the open command and should be set before invoking it.

gdbmtool variable: bool centfree

Set to true, enables the use of central free block pool in newly opened databases. See GDBM_SETCENTFREE.

This variable affects the open command and should be set before invoking it.

The following commands are used to list or modify the variables:

command verb: set [assignments]

When used without arguments, lists all variables and their values. Unset variables are shown after a comment sign (‘#’). For string and numeric variables, values are shown after an equals sign. For boolean variables, only the variable name is displayed if the variable is true. If it is false, its name is prefixed with ‘no’.

For example:

ps1="%p>%_"
ps2="%_>%_"
delim1=","
delim2=","
confirm
# cachesize is unset
# blocksize is unset
open="wrcreat"
lock
mmap
nosync
pager="less"
# quiet is unset

If used with arguments, the set command alters the specified variables. In this case, arguments are variable assignments in the form ‘name=value’. For boolean variables, the value is interpreted as follows: if it is numeric, 0 stands for false, any non-zero value stands for true. Otherwise, the values on, true, and yes denote true, and off, false, no stand for false. Alternatively, only the name of a boolean variable can be supplied to set it to true, and its name prefixed with no can be used to set it to false. For example, the following command sets the delim2 variable to ‘;’ and the confirm variable to false:

set delim2=";" noconfirm
command verb: unset variables

Unsets the listed variables. The effect of unsetting depends on the variable. Unless explicitly described in the discussion of the variables above, unsetting a boolean variable is equivalent to setting it to false. Unsetting a string variable is equivalent to assigning it an empty string.


Next: , Up: shell   [Contents][Index]