Release calc version 2.11.0t10.5.1

This commit is contained in:
Landon Curt Noll
1999-12-14 12:23:24 -08:00
parent 94e35d9b07
commit 0514dc0de9
519 changed files with 4194 additions and 17762 deletions

View File

@@ -2,313 +2,187 @@ Calc command line
Calc has the following command line:
calc [-c] [-C] [-d] [-D calc_debug[:resource_debug:[user_debug]]]
[-e] [-h] [-i] [-m mode] [-n] [-p] [-q] [-s] [-u] [-v]
[calc_cmd ...]
calc [-c] [-C] [-d] [-D calc_debug[:lib_debug:[user_debug]]]
[-e] [-h] [-i] [-m mode] [-n] [-p] [-q] [-u] [-v] [calc_cmd ...]
#!/usr/local/bin/calc -S [-other_flags ...]
-c Continue reading command lines even after an execution
error has caused the abandonment of a line.
-c Continue reading command lines even after an execution
error has caused the abandonment of a line.
For example:
For example:
calc read many_errors.cal
calc read many_errors.cal
will cause calc to abort on the first error, whereas:
will cause calc to abort on the first error, whereas:
calc -c read many_errors.cal
calc -c read many_errors.cal
will cause calc to try to process each line being read
despite the errors that it encounters.
will cause calc to try to process each line being read
despite the errors that it encounters.
By default, calc startup scripts ($CALCRC) are silently
ignored if not found. This flag will report missing
startup scripts unless -d is also given.
By default, calc startup resource files ($CALCRC) are
silently ignored if not found. This flag will report
missing startup scripts unless -d is also given.
-C Permit the execution of custom builtin functions. Without
this flag, calling the custom() builtin function will
simply generate an error.
Use if this flag may cause calc to execute functions that
are non-standard and that are not portable. Custom builtin
functions are disabled by default for this reason.
-C Permit the execution of custom builtin functions.
Without this flag, calling the custom() builtin
function will simply generate an error.
-d Disable the printing of the opening title. The printing
of library debug and informational messages is also disabled
as if config("lib_debug",0) had been executed.
Use if this flag may cause calc to execute functions
that are non-standard and that are not portable.
Custom builtin functions are disabled by default for
this reason.
For example:
calc 'read qtime; qtime(2)'
-d Disable the printing of the opening title. The
printing of resource file debug and informational messages is
also disabled as if config("resource_debug", 0) had been
executed.
will output something like:
For example:
qtime(utc_hr_offset) defined
It's nearly ten past six.
calc 'read qtime; qtime(2)'
whereas:
will output something like:
calc -d 'read qtime; qtime(2)'
qtime(utc_hr_offset) defined
It's nearly ten past six.
will just say:
whereas:
It's nearly ten past six.
calc -d 'read qtime; qtime(2)'
This flag disables the reporting of missing calc
startup scripts ($CALCRC).
will just say:
-D calc_debug[:lib_debug:[user_debug]]
It's nearly ten past six.
Force the initial value of config("calc_debug"),
config("lib_debug") and config("user_debug").
This flag disables the reporting of missing calc
startup scripts ($CALCRC).
The : separated strings are interpreted as signed 32 bit values.
After an optional leading sign a leading zero indicates octal
conversion, and a leading ``0x'' or ``0X'' hexadecimal
conversion. Otherwise, decimal conversion is assumed.
By default, calc_debug is 0, lib_debug is 3 and lib_debug is 0.
-D calc_debug[:resource_debug:[user_debug]]
Force the initial value of config("calc_debug"),
config("resource_debug") and config("user_debug").
For more information use the following calc command:
The : separated strings are interpreted as signed 32
bit values. After an optional leading sign a leading
zero indicates octal conversion, and a leading ``0x''
or ``0X'' hexadecimal conversion. Otherwise, decimal
conversion is assumed.
help config
By default, calc_debug is 0, resource_debug is 3 and
user_debug is 0.
-e Ignore any environment variables on startup. The
getenv() builtin will still return values, however.
For more information use the following calc command:
-h Print a help message. This option implies -q. This
is equivalent to the calc command help help. The help
facility is disabled unless the mode is 5 or 7. See -m.
help config
-i Become interactive if possible. Be default, if calc_cmd
args are given, calc will execute them and exit. This flag
will cause calc to drop into interactive mode after the
commands are executed.
For example:
-e Ignore any environment variables on startup. The
getenv() builtin will still return values, however.
calc 2+5
will print the value 7 and exit whereas:
-h Print a help message. This option implies -q. This is
equivalent to the calc command help help. The help
facility is disabled unless the mode is 5 or 7. See
-m.
calc -i 2+5
will print the value 7 and prompt the user for more
calc commands.
-i Become interactive if possible. Be default, if
calc_cmd args are given, calc will execute them and
exit. This flag args are given, calc will execute them
and exit. This flag will cause calc to drop into
interactive mode after the commands are executed.
-m mode
This flag sets the permission mode of calc. It
controls the ability for calc to open files and execute
programs. Mode may be a number from 0 to 7.
For example:
The mode value is interpreted in a way similar to that
of the chmod(1) octal mode:
calc 2+5
0 do not open any file, do not execute progs
1 do not open any file
2 do not open files for reading, do not execute progs
3 do not open files for reading
4 do not open files for writing, do not execute progs
5 do not open files for writing
6 do not execute any program
7 allow everything (default mode)
will print the value 7 and exit whereas:
If one wished to run calc from a privileged user, one
might want to use -m 0 in an effort to make calc more
secure.
calc -i 2+5
Mode bits for reading and writing apply only on an
open. Files already open are not effected. Thus if one
wanted to use the -m 0 in an effort to make calc more
secure, but still wanted to read and write a specific
file, one might want to do in sh, ksh, bash-like shells:
will print the value 7 and prompt the user for more
calc commands.
calc -m 0 3<a.file
Files presented to calc in this way are opened in an
unknown mode. Calc will attempt to read or write them
if directed.
-m mode
This flag sets the permission mode of calc. It
controls the ability for calc to open files and execute
programs. Mode may be a number from 0 to 7.
If the mode disables opening of files for reading, then
the startup library scripts are disabled as of -q was
given. The reading of key bindings is also disabled
when the mode disables opening of files for reading.
The mode value is interpreted in a way similar to that
of the chmod(1) octal mode:
-n Use the new configuration defaults instead of the old
default classic defaults. This flag as the same effect
as executing config("all", "newcfg") at startup time.
0 do not open any file, do not execute progs
1 do not open any file
2 do not open files for reading, do not execute progs
3 do not open files for reading
4 do not open files for writing, do not execute progs
5 do not open files for writing
6 do not execute any program
7 allow everything (default mode)
-p Pipe processing is enabled by use of -p. For example:
If one wished to run calc from a privileged user, one
might want to use -m 0 in an effort to make calc
somewhat more secure.
calc -p '2^21701-1' | fizzbin
Mode bits for reading and writing apply only on an
open. Files already open are not effected. Thus if
one wanted to use the -m 0 in an effort to make calc
somewhat more secure, but still wanted to read and
write a specific file, one might want to do in sh(1),
ksh(1), bash(1)-like shells:
In pipe mode, calc does not prompt, does not print leading
tabs and does not print the initial header. The -p flag
overrides -i.
calc -m 0 3<a.file
-q Disable the use of the $CALCRC startup scripts.
Files presented to calc in this way are opened in an
unknown mode. Calc will attempt to read or write them
if directed.
-u Disable buffering of stdin and stdout.
If the mode disables opening of files for reading, then
the startup resource files are disabled as of -q was
given. The reading of key bindings is also disabled
when the mode disables opening of files for reading.
-v Print calc version number and exit.
Without `calc_cmd', calc operates interactively. If one or more
`calc_cmd' are given on the command line, calc will execute them and
exit. If -i is given, calc will attempt to become interactive
even of one or more `calc_cmd' are given on the command line.
-n Use the new configuration defaults instead of the old
default classic defaults. This flag as the same effect
as executing config("all", "newcfg") at startup time.
Normally on startup, calc attempts to execute a collection of
library scripts. The environment variable $CALCRC (if non-existent
then a compiled in value) contains a : separated list of startup
library scripts. No error conditions are produced if these startup
library scripts are not found.
If the mode disables opening of files for reading, then the startup
library scripts are disabled as of -q was given and $CALCRC as well
as the default compiled in value are ignored.
-p Pipe processing is enabled by use of -p. For example:
Filenames are subject to ``~'' expansion (see below). The
environment variable $CALCPATH (if non-existent then a compiled in
value) contains a : separated list of search directories. If a
file does not begin with /, ~ or ./, then it is searched for under
each directory listed in the $CALCPATH. It is an error if no such
readable file is found.
calc -p '2^21701-1' | fizzbin
Calc treats all open files, other than stdin, stdout and
stderr as files available for reading and writing. One may
present calc with an already open file using sh, ksh or bash-like
shells is to:
In pipe mode, calc does not prompt, does not print
leading tabs and does not print the initial header.
The -p flag overrides -i.
calc 3<open_file 4<open_file2
For more information use the following calc commands:
-q Disable the use of the $CALCRC startup scripts.
-s By default, all calc_cmd args are evaluated and
executed. This flag will disable their evaluation and
instead make them available as strings for the argv()
builtin function.
-u Disable buffering of stdin and stdout.
-v Print the calc version number and exit.
CALC COMMAND LINE
Without calc_cmd, calc operates interactively. If one or
more calc_cmd are given on the command line and -s is NOT
given, then calc will evaluate and execute them and then
exit.
If -i is given, calc will attempt to become interactive even
of one or more calc_cmd are given on the command line.
If -s is given, calc will not evaluate any calc_cmd
arguments but instead make them available as strings to the
argv() builtin function.
Normally on startup, calc attempts to execute a collection
of resource files. The environment variable $CALCRC (if
non-existent then a compiled in value) contains a
: separated list of startup resource files. No error
conditions are produced if these startup resource file are
not found.
If the mode disables opening of files for reading, then the
startup resource files are disabled as of -q was given and
$CALCRC as well as the default compiled in value are
ignored.
Filenames are subject to ``~'' expansion (see below). The
environment variable $CALCPATH (if non-existent then a
compiled in value) contains a : separated list of search
directories. If a file does not begin with /, ~ or ./, then
it is searched for under each directory listed in the
$CALCPATH. It is an error if no such readable file is
found.
Calc treats all open files, other than stdin, stdout and
stderr as files available for reading and writing. One may
present calc with an already open file using sh(1), ksh(1),
bash(1)-like shells is to:
calc 3<open_file 4<open_file2
SHELL SCRIPT MODE
If an executable file begins with:
#!/usr/local/bin/calc -S [-other_flags ...]
the rest of the file will be processed in shell script mode.
Note that -S (UPPER CASE -S) must be the first -flag on the
``#!'' line. Any other optional ``-other_flags'' must come
after the -S.
In shell script mode the contents of the file are evaluated
and executed as if they were processed by the read command.
Any optional ``-other_flags'' will by parsed first followed
by any arguments given shell script itself.
In shell script mode, -s (lower case -s) is always assumed.
In addition, -d and -p are automatically set if -i is not
given.
For example, if the file /tmp/mersenne:
#!/usr/local/bin/calc -S -q
#
# mersenne - an example of a calc shell script file
/* parse args */
if (argv() != 1) {
fprintf(files(2), "usage: %s exp\n", config("program"));
abort "must give one exponent arg";
}
/* print the mersenne number */
print "2^": argv(0) : "-1 =", 2^eval(argv(0))-1;
is made an executable file by:
chmod +x /tmp/mersenne
then the command line:
/tmp/mersenne 127
will print:
2^127-1 = 170141183460469231731687303715884105727
Note that because -s is assumed in shell script mode and
non-dashed args are made available as strings via the argv()
builtin function. Therefore:
2^eval(argv(0))-1
will print the decimal value of 2^n-1 but
2^argv(0)-1
will not.
For more information use the following calc commands:
help help
help overview
help config
help argv
help environment
## Copyright (C) 1999 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
## @(#) $Revision: 29.1 $
## @(#) $Id: usage,v 29.1 1999/12/14 09:16:10 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/usage,v $
##
## Under source code control: 1991/07/21 04:37:25
## File existed as early as: 1991
##
## chongo <was here> /\oo/\ http://reality.sgi.com/chongo/
## Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
help help
help overview
help usage
help environment
help config