calc(1) General Commands Manual calc(1) (NAME) calc - (SYNOPSIS) calc [-c] [-C] [-d] [-D calc_debug[:resource_debug[:user_debug]]] [-e] [-f filename] [-h] [-i] [-m mode] [-O] [-p] [-q] [-s] [-u] [-v] [[--] calc_cmd ...] #!/usr/bin/calc [optional_other_flags ...] -f (DESCRIPTION) -c / (scan/parse) . calc . (run-time) . : calc read many_errors.cal calc (syntax error) : calc -c read many_errors.cal calc / . (resource files) calc . -d . -C (custom builtin functions). custom() . calc . . -d . config("resource_debug", 0) . : calc "read qtime; qtime(2)" : qtime(utc_hr_offset) defined It's nearly ten past six. : calc -d "read qtime; qtime(2)" : It's nearly ten past six. calc . (~) . : calc 2/3 : ~0.66666666666666666667 : calc -d 2/3 : 0.66666666666666666667 -D calc_debug[:resource_debug[:user_debug]] config("calc_debug") config("resource_debug") config("user_debug"). : . (octal) <<0x>> <<0X>> (hexadecimal) . (decimal) . calc_debug 0 resource_debug 3 user_debug 0 . calc : help config -e . getenv() . -f filename calc . calc . #! : #!/usr/bin/calc [optional_other_flags ...] -f . -f #! -q . : #!/usr/bin/calc -q -f SHELL SCRIPT MODE . : -f filename #! exec() . -f #! . -f filename : calc [optional_other_flags ...] -f filename calc filename . : -f -q calc : calc [optional_other_flags ...] -q -f filename . -f filename -s . -h . -q . help help calc . mode 5 7 . -m . -i . calc calc_cmd . calc . : calc 2+5 7 : calc -i 2+5 7 calc . -m mode (permission mode) calc calc . Mode 0 7 . mode chmod(1) : 0 1 2 3 4 5 6 7 ( ) calc ( ) -m 0 calc . (open) . . -m 0 calc sh(1) ksh(1) bash(1) : calc -m 0 3 calc . Calc . mode -q . mode (key bindings) ..TP -O . config("all", "oldcfg") . : calc -n calc . -n . -n . -p (pipe) -p . : calc -p "2^21701-1" | fizzbin calc (prompt) . -p -i ( ). calc ( SHELL SCRIPT MODE ) calc (stdin) -p . calc prompt(str) ( prompt ) -p . -q . ( $CALCRC ) . calcrc ( ~/.calcrc) . -s calc_cmd . argv() . -u (buffering) (stdin) (stdout). -v calc . -- calc . calc . : calc -p -- -1 - -7 CALC (CALC COMMAND LINE) calc_cmd calc . -s calc -i . -s calc calc_cmd argv() . <<*>> (newline) . : calc 23 + 47 70 . : calc 23 * 47 calc -23 + 47 <<*>> (file glob) . <<-23>> calc ( ) calc . : calc '23 * 47' calc "print sqrt(2), exp(1)" : calc '(-23 + 47)' calc : calc -- -23 + 47 calc -q -- -23 + 47 <> csh(1) <> (history substitution) <> . : print 27!^2 : print 27! ^2 print 27\!^2 calc (pipe) -p calc . chongo was here : echo chongo was here | calc -p 'print fgetline(files(0));' : echo chongo was here | calc 'print fgetline(files(0));' chongo was here : echo chongo was here | calc -i 'print fgetline(files(0));' -p (flush) ..PP CALC (CALC STARTUP FILES) $CALCRC calc -q $CALCRC calc -e calc "startup" calc .calcrc .calcinit . calc . $CALCRC ':' calc -q -e . . -m -q . CALC (CALC FILE SEARCH PATH) $CALCPATH calc -e / ~ ./ : calc read myfile calc : ./myfile ./myfile.cal /usr/lib/myfile /usr/lib/myfile.cal /usr/share/calc/custom/myfile /usr/share/calc/custom/myfile.cal . . $CALCPATH PATH ':' calc -e . Calc stdin stdout stderr . calc sh(1) ksh(1) bash(1) : calc 3 calc : help help help overview help usage help environment help config #! calc -f : #!/usr/bin/calc [optional_other_flags ...] -f (shell script mode) . -s -f <<#!>> . optional_other_flags -f . (shell script mode) read <<>> '#' (whitespace) (comment) . optional_other_flags . (shell script mode) -s . -i -d -p . : -f -q : calc [optional_other_flags ...] -q -f filename calc . /tmp/mersenne: #!/usr/bin/calc -q -f /* setup */ argc = argv(); program = argv(0); stderr = files(2); /* parse args */ if (argc != 2) { fprintf(stderr, "usage: %s exp0, program); abort "must give one exponent arg"; } exp = eval(argv(1)); if (!isint(exp) || exp < 0) { fprintf(stderr, "%s: exp must be non-negative integer0, program); abort "must give one exponent arg"; } /* print the mersenne number */ print "2^": exp : "-1 =", 2^exp-1; : chmod +x /tmp/mersenne : /tmp/mersenne 127 : 2^127-1 = 170141183460469231731687303715884105727 -s (shell script mode) argv() . : 2^eval(argv(1))-1 2^n-1 : 2^argv(1)-1 . calc (shell script mode) calc (stdin) . prompt(str) ( null ). calc prompt(str) ( prompt null ) -p . "got null" stdin calc : #!/usr/bin/calc -q -f # The prompt will ALWAYS FAIL and return a null value n = prompt("Test> "); if (isnull(n)) { print("got null"); } else { print("got " + n); } ( -p -f ) "Test> " "got" : #!/usr/bin/calc -q -p -f n = prompt("Test> "); if (isnull(n)) { print("got null"); } else { print("got " + n); } -p -f ..PP (DATA TYPES) . (object) . (modulus) . calc : help types help obj show objfuncs (VARIABLES) calc (typeless) . . . (scope) (global) (procedure) . (stack) (queue) . calc : help variable help mat help list show globals / (INPUT/OUTPUT) "0x" () "0b" () "0" () . "i" "3+4i". . calc . . / stdio . (seek) . Korn Shell C-Shell " " . : ~/.calcrc ~chongo/lib/fft_multiply.cal calc : help file CALC (CALC LANGUAGE) calc -C . (tests) . C . calc . (help) (resource files) . calc : help command help statement help expression help operator help config /usr/bin/calc calc /usr/bin/cscript/* calc /usr/lib/*.cal calc /usr/lib/help/* /usr/lib/bindings GNU-readline /usr/include/calc/*.h (include) C /usr/lib/libcalc.a calc /usr/lib/libcustcalc.a /usr/share/calc/custom/*.cal /usr/share/calc/custhelp/* (ENVIRONMENT) CALCPATH <<:>> calc / ./ ~ . calc $XDG_DATA_HOME $XDG_CONFIG_HOME . calc : ${XDG_DATA_HOME}/calc ${XDG_CONFIG_HOME}/calc ${CALC_SHAREDIR} /usr/share/calc/custom XDG : ~/.cal ${CALC_SHAREDIR} /usr/share/calc/custom CALCRC ( -h -q ) calc <<:>> . calc $XDG_CONFIG_HOME . calc : ${XDG_CONFIG_HOME}/calc/calcrc ${CALC_SHAREDIR}/startup $XDG_CONFIG_HOME : ~/.calcrc ${CALC_SHAREDIR}/startup CALCBINDINGS ( -h -q -m ) calc (key bindings) . $CALCPATH . : binding calc GNU-readline . readline ( readline(3)) . CALCHISTFILE calc. calc ~/.calc_history . calc $XDG_STATE_HOME . : ${XDG_STATE_HOME}/calc/history : ~/.calc_history calc GNU-readline . CALCHELP calc. : /usr/share/calc/help CALCCUSTOMHELP calc. : /usr/share/calc/custhelp CALCPATH CALCRC CALCHISTFILE calc << XDG>> . calc . : export CALCRC="./.calcinit:$HOME/.calcrc:/usr/share/calc/startup" export CALCPATH=".:./cal:$HOME/.cal:/usr/share/calc:/usr/share/calc/custom" export CALCHISTFILE="$HOME/.calc_history" << XDG>> : https://specifications.freedesktop.org/basedir/latest calc $CALCHISTFILE . : mkdir -p $(dirname $CALCHISTFILE) calc David I. Bell . (primary mirror) calc calc Landon Curt Noll . Landon Curt Noll (master reference source) calc . Peter Miller Neil Justusson Landon Noll. Stephen Rothwell hist.c . Ernest W. Bowen . . Ernest . (public domain) . . / (COPYING / CALC GNU LESSER GENERAL PUBLIC LICENSE) Calc 2.1 (GNU Lesser General Public License) . / . calc: help copyright help copying help copying-lgpl help credit COPYING COPYING-LGPL . GNU Lesser General Public License calc / . 2.1 . : Free Software Foundation, Inc. 51 Franklin Street Fifth Floor Boston, MA 02110-1301 USA () Calc . : Copyright (C) year David I. Bell Copyright (C) year David I. Bell and Landon Curt Noll Copyright (C) year David I. Bell and Ernest Bowen Copyright (C) year David I. Bell, Landon Curt Noll and Ernest Bowen Copyright (C) year Landon Curt Noll Copyright (C) year Ernest Bowen and Landon Curt Noll Copyright (C) year Ernest Bowen Copyright (C) year Petteri Kettunen and Landon Curt Noll Copyright (C) year Christoph Zurnieden Copyright (C) year Landon Curt Noll and Thomas Jones-Low Copyright (C) year Klaus Alexander Seistrup and Landon Curt Noll calc <> . : https://unlicense.org (CALC QUESTIONS) calc calc : ; help question : QUESTIONS : https://github.com/lcn2/calc/blob/master/QUESTIONS calc calc : ; help bugs : BUGS : https://github.com/lcn2/calc/blob/master/BUGS CALC (CONTRIBUTING CODE TO CALC) Calc . calc calc . calc calc : ; help contrib : CONTRIB-CODE : https://github.com/lcn2/calc/blob/master/CONTRIB-CODE CALC (CALC WEB SITE) Landon Noll calc : www.isthe.com/chongo/tech/comp/calc CALC (CALC SOURCE CODE) calc GitHub : https://github.com/lcn2/calc calc master . calc : https://github.com/lcn2/calc/releases ((Pre-release)) . ((Pre-release)) . Share and enjoy! :-) ^..^ calc(1)