-
Notifications
You must be signed in to change notification settings - Fork 52
/
calc.man
1531 lines (1411 loc) · 26.9 KB
/
calc.man
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
.\"
.\" Copyright (C) 1999-2007,2014,2018,2021 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.
.\" 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
.\"
.\" Under source code control: 1991/07/23 05:48:26
.\" File existed as early as: 1991
.\"
.\" chongo <was here> /\oo/\ http://www.isthe.com/chongo/
.\" Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
.\"
.\" calculator by David I. Bell
.\" man page by Landon Noll
.\"
.TH calc 1 "^..^" "Share and enjoy! :-)"
.SH NAME
calc \- arbitrary precision calculator
.SH SYNOPSIS
\fIcalc\fP
.RB [ \-c ]
.RB [ \-C ]
.RB [ \-d ]
.br
.in +5n
.RB [ -D\ \&calc_debug[:resource_debug[:user_debug]] ]
.br
.RB [ \-e ]
.RB [ \-f\ \&filename ]
.RB [ \-h ]
.RB [ \-i ]
.RB [ \-m\ \&mode ]
.RB [ \-O ]
.br
.RB [ \-p ]
.RB [ \-q ]
.RB [ \-s ]
.RB [ \-u ]
.RB [ \-v ]
.RB [ [\-\-]\ calc_cmd\ \&.\|.\|. ]
.in -5n
.sp
\fI#!${BINDIR}/calc\fP\ [optional_other_flags\ \&...] \fB\-f\fP
.PP
.SH DESCRIPTION
.PP
.TP
.B \-c
Continue reading command lines even after a scan/parse
error has caused the abandonment of a line.
Note that this option only deals with scanning and
parsing of the calc language.
It does not deal with execution or run-time errors.
.sp 1
For example:
.sp 1
.in +5n
.nf
calc read many_errors.cal
.fi
.in -5n
.sp 1
will cause
.B calc
to abort on the first syntax error, whereas:
.sp 1
.in +5n
.nf
calc -c read many_errors.cal
.fi
.in -5n
.sp 1
will
cause
.B calc
to try to process each line being read
despite the scan/parse errors that it encounters.
.sp 1
By default, calc startup resource files are silently
ignored if not found.
This flag will report missing
startup resource files unless
.B \-d
is also given.
.TP
.B \-C
Permit the execution of custom builtin functions.
Without
this flag, calling the custom() builtin function will
simply generate an error.
.sp 1
Use of this flag may cause
.B calc
to execute functions
that are non-standard and that are not portable. Custom builtin
functions are disabled by default for this reason.
.TP
.B \-d
Disable the printing of the opening title. The printing
of resource file debug and informational messages is also disabled
as if \fBconfig("resource_debug", 0)\fP had been executed.
.sp 1
For example:
.sp 1
.in +5n
calc "read qtime; qtime(2)"
.in -5n
.sp 1
will output something like:
.sp 1
.in +5n
.nf
qtime(utc_hr_offset) defined
It's nearly ten past six.
.fi
.in -5n
.sp 1
whereas:
.sp 1
.in +5n
.nf
calc -d "read qtime; qtime(2)"
.fi
.in -5n
.sp 1
will just print:
.sp 1
.in +5n
.nf
It's nearly ten past six.
.fi
.in -5n
.sp 1
This flag disables the reporting of missing calc
startup resource files.
.sp 1
This flag also disables the printing the leading tilde. For example:
.sp 1
.in +5n
.nf
calc 2/3
.fi
.in -5n
.sp 1
will print:
.sp 1
.in +5n
.nf
~0.66666666666666666667
.fi
.in -5n
.sp 1
.sp 1
whereas:
.sp 1
.in +5n
.nf
calc -d 2/3
.fi
.in -5n
.sp 1
will just print:
.sp 1
.in +5n
.nf
0.66666666666666666667
.fi
.in -5n
.sp 1
.TP
.BR -D " calc_debug[:resource_debug[:user_debug]]"
Force the initial value of config("calc_debug"),
config("resource_debug") and config("user_debug").
.sp 1
The : separated strings are interpreted as signed 32 bit integers.
After an optional leading sign a leading zero indicates octal
conversion, and a leading ``0x'' or ``0X'' hexadecimal
conversion. Otherwise, decimal conversion is assumed.
.sp 1
By default,
.I calc_debug
is 0,
.I resource_debug
is 3 and
.I user_debug
is 0.
.sp 1
For more information use the following
.B calc
command:
.sp 1
.in +5n
.nf
help config
.fi
.in -5n
.TP
.B \-e
Ignore any environment variables on startup.
The getenv() builtin will still return values, however.
.TP
.BR \-f " filename"
This flag is normally only with calc shell scripts.
.sp 1
This flag is required when using calc in
.BR "shell script mode" .
It must be at the end of the initial
.B #!
line of the script, as in:
.sp 1
.in +5n
.nf
\fI#!${BINDIR}/calc\fP\ [optional_other_flags\ \&...] \fB\-f\fP
.fi
.in -5n
.sp 1
the rest of the file will be processed in
.BR "shell script mode" .
.sp 1
A common flag to use, prior to the
.B \-f
on the #! line is the
.B \-q
flag.
For example:
.sp 1
.in +5n
.nf
\fI#!${BINDIR}/calc\fP \fB\-q\fP \fB\-f\fP
.fi
.in -5n
.sp 1
See
.B "SHELL SCRIPT MODE"
section of this man page
below for details.
.sp 1
While the actual form of this flag is:
.sp 1
.in +5n
.BR \-f
filename
.in -5n
.sp 1
for systems that treat an executable that begins with
.B #!
as a script, the path of the executable is appended by the kernel
as the final argument to the exec() system call.
This is why the
.B \-f
flag at the very end of the
.B #!
line.
.sp 1
It is possible use
.B \-f
filename
on the command line:
.sp 1
.in +5n
.nf
\fIcalc\fP\ [optional_other_flags\ \&...] \fB\-f\fP filename
.fi
.in -5n
.sp 1
This will cause calc to process lines in
.B filename
in
.BR "shell script mode" .
.sp 1
.B NOTE:
The use of
.BR \-f
does
.B NOT
imply
.BR \-q
and thus one would need to use
.sp 1
.in +5n
.nf
\fIcalc\fP\ [optional_other_flags\ \&...] \fB\-q\fP \fB\-f\fP filename
.fi
.in -5n
.sp 1
to disable the use of calc startup files as well.
.sp 1
The use of
.B \-f
filename
implies the
.B \-s
flag.
.TP
.B \-h
Print a help message. This option implies
.BR \-q .
This
is equivalent to the
.B calc
command help help.
The help facility is disabled unless the mode is 5 or 7.
See
.BR \-m .
.TP
.B \-i
Become interactive if possible.
This flag will cause
.B calc
to drop into interactive mode after the
.I calc_cmd
arguments on the command line are evaluated.
Without this flag,
.B calc
will exit after they are evaluated.
.sp 1
For example:
.sp 1
.in +5n
.nf
calc 2+5
.fi
.in -5n
.sp 1
will print the value 7 and exit whereas:
.sp 1
.in +5n
.nf
calc -i 2+5
.fi
.in -5n
.sp 1
will print the value 7 and prompt the user for more
.B calc
commands.
.TP
.BR \-m " mode"
This flag sets the permission mode of
.BR calc .
It controls the ability for
.B calc
to open files and execute programs.
.I Mode
may be a number from 0 to 7.
.sp 1
The mode value is interpreted in a way similar to that
of the
.BR chmod (1)
octal mode:
.sp 1
.in +5n
.nf
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)
.fi
.in -5n
.sp 1
If one wished to run
.B calc
from a privileged user, one might want to use
.BR \-m " 0"
in an effort to make
.B calc
somewhat more secure.
.sp 1
Mode bits for reading and writing apply only on an
open.
Files already open are not effected.
Thus if one wanted to use the
.BR \-m " 0"
in an effort to make
.B calc
somewhat more secure, but still wanted to read and write a specific
file, one might want to do in
.BR sh (1),
.BR ksh (1),
.BR bash (1)-like
shells:
.sp 1
.in +5n
.nf
calc -m 0 3<a.file
.fi
.in -5n
.sp 1
Files presented to
.B calc
in this way are opened in an
unknown mode.
.B Calc
will attempt to read or write them if directed.
.sp 1
If the mode disables opening of files for reading, then
the startup resource files are disabled as if
.B \-q
was given.
The reading of key bindings is also disabled
when the mode disables opening of files for reading.
.TP
.B \-O
Use the old classic defaults instead of the
default configuration.
This flag as the same effect
as executing \fBconfig("all", "oldcfg")\fP at startup time.
.sp 1
NOTE: Older versions of calc used
.B \-n
to setup a modified form of the default calc configuration.
The
.B \-n
flag currently does nothing.
Use of the
.B \-n
flag is now deprecated and may be used for
something else in the future.
.TP
.B \-p
Pipe processing is enabled by use of
.BR \-p .
For example:
.sp 1
.in +5n
.nf
calc -p "2^21701-1" | fizzbin
.fi
.in -5n
.sp 1
In pipe mode,
.B calc
does not prompt, does not print leading
tabs and does not print the initial header.
The
.B \-p
flag overrides
.BR \-i .
.sp 1
When running calc as a shell script (see
.B "SHELL SCRIPT MODE"
for details), calc will close standard input (stdin)
during startup
.B UNLESS
the
.B \-p
flag is given on the command line.
When calc is running in
.BR "shell script mode" ,
shell scripts that call the
.BR prompt (str)
builtin will not work properly (the prompt builtin
will always fail) unless the
.B \-p
flag is given on the command line.
.TP
.B \-q
Disable the reading of the startup scripts.
.sp 1
This allows the script to run independently of
startup scripts such those managed by the
.B $CALCRC
environment variable.
For example, this will disable the use of the common calcrc file
(usually ~/.calcrc).
.TP
.B \-s
By default, all
.I 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.
.TP
.B \-u
Disable buffering of stdin and stdout.
.TP
.B \-v
Print the
.B calc
version number and exit.
.TP
.B \-\-
The double dash indicates to calc that no more options follow.
Thus calc will ignore a later argument on the command line
even if it starts with a dash.
This is useful when entering negative values on the command line as in:
.sp 1
.in +5n
.nf
calc \-p \-\- \-1 - -7
.fi
.in -5n
.sp 1
.PP
.SH CALC COMMAND LINE
.PP
With no
.I calc_cmd
arguments,
.B calc
operates interactively.
If one or more
arguments are given on the command line and
.B \-s
is NOT given, then
.B calc
will read and execute them and either attempt
to go interactive according as the
.B \-i
flag was present or absent.
.sp
If
.B \-s
is given,
.B calc
will not evaluate any
.I calc_cmd
arguments but instead make them available
as strings to the argv() builtin function.
Sufficiently simple commands with no characters like
parentheses, brackets, semicolons, '*', which have special
interpretations in UNIX shells may be entered, possibly with
spaces, until the terminating newline.
For example:
.sp 1
.in +5n
.nf
calc 23 + 47
.fi
.in -5n
.sp 1
will print 70.
However, command lines will have problems:
.sp 1
.in +5n
.nf
calc 23 * 47
.sp 1
calc -23 + 47
.fi
.in -5n
.sp 1
The first example above fails because the shell interprets the '*'
as a file glob.
The second example fails because '\-23' is viewed as a calc option
(which it is not) and do calc objects to that it thinks of as an unknown option.
These cases can usually be made to work as expected by
enclosing the command between quotes:
.sp 1
.in +5n
.nf
calc '23 * 47'
.sp 1
calc "print sqrt(2), exp(1)"
.fi
.in -5n
.sp 1
or in parentheses and quotes to avoid leading \-'s as in:
.sp 1
.in +5n
.nf
calc '(-23 + 47)'
.fi
.in -5n
.sp 1
One may also use a double dash to denote that calc options have ended as in:
.sp 1
.in +5n
.nf
calc -- -23 + 47
.sp 1
calc -q -- -23 + 47
.fi
.in -5n
.sp 1
If '!' is to be used to indicate the factorial function, for
shells like
.BI csh (1)
for which '!' followed by a non-space character
is used for history substitution, it may be necessary to
include a space or use a backslash to escape the special
meaning of '!'.
For example, the command:
.sp 1
.in +5n
.nf
print 27!^2
.fi
.in -5n
.sp 1
may have to be replaced by:
.sp 1
.in +5n
.nf
print 27! ^2 or print 27\\!^2
.fi
.in -5n
Reading from standard input when calc is part of a pipe works
as long as the \-p flag is given to calc. For example, this
will print chongo was here:
.sp 1
.in +5n
.nf
echo chongo was here | calc \-p 'print fgetline(files(0));'
.sp 1
.fi
.in -5n
.sp 1
while this does not:
.sp 1
.in +5n
.nf
echo chongo was here | calc 'print fgetline(files(0));'
.sp 1
.fi
.in -5n
.sp 1
nor will this print chongo was here:
.sp 1
.in +5n
.nf
echo chongo was here | calc \-i 'print fgetline(files(0));'
.sp 1
.fi
.in -5n
.sp 1
This is because without
.BR \-p ,
the interactive parser, in an effort
to parse interactive commands, flushes data on standard input.
.PP
.SH CALC STARTUP FILES
.PP
Normally on startup,
if the environment variable
.B $CALCRC
is undefined and
.B calc
is invoked without the
.B \-q
flag, or if
.B $CALCRC
is defined and calc is invoked with
.BR \-e ,
.B calc
looks for a file "startup" in the calc resource directory
.B .calcrc
in the user's home directory, and
.B .calcinit in the current directory.
If one or more of these are found, they are read in succession as
.B calc
scripts and their commands executed.
When defined,
.B $CALCRC
is to contain a ':' separated list of names of files,
and if calc is then invoked without either the
.B \-q
or
.B \-e
flags, these files are read in succession and their commands executed.
No error condition is produced if a listed file is not found.
.sp
If the mode specified by
.B \-m
disables opening of files for reading, then the reading of startup
files is also disabled as if
.B \-q
was given.
.PP
.SH CALC FILE SEARCH PATH
.PP
If the environment variable
.B $CALCPATH
is undefined, or if it
is defined and
.B calc
is invoked with the
.B \-e
flag, when a file name not beginning with
.BR / ,
.B ~
or
.BR ./ ,
is specified as in:
.sp 1
.in +5n
.nf
calc read myfile
.fi
.in -5n
.sp 1
.B calc
searches in succession:
.sp 1
.in +5n
.nf
\a./myfile
\a./myfile.cal
${LIBDIR}/myfile
${LIBDIR}/myfile.cal
${CUSTOMCALDIR}/myfile
${CUSTOMCALDIR}/myfile.cal
.fi
.in -5n
.sp 1
If the file is found, the
search stops and the commands in the file are executed.
It is an error if no readable file with the specified name is found.
An alternative search path can be specified by defining
.B $CALCPATH
in the same way as PATH is defined, as a ':' separated
list of directories, and then invoking
.B calc
without the
.B \-e
flag.
.PP
.B Calc
treats all open files, other than stdin, stdout and
stderr as files available for reading and writing.
One may
present
.B calc
with an already open file using
.BR sh (1),
.BR ksh (1),
.BR bash (1)-like
shells is to:
.sp 1
.in +5n
calc 3<open_file 4<open_file2
.in -5n
.sp 1
For more information use the following
.B calc
commands:
.sp 1
.in +5n
.nf
help help
help overview
help usage
help environment
help config
.fi
.in -5n
.sp 1
.PP
.SH SHELL SCRIPT MODE
.PP
If the first line of an executable file begins
.B #!
followed by the absolute pathname of the
.B calc
program and the first line ends with the flag
.B \-f
as in:
.sp 1
.in +5n
.nf
\fI#!${BINDIR}/calc\fP\ [optional_other_flags\ \&...] \fB\-f\fP
.fi
.in -5n
.sp 1
the rest of the file will be processed in
.BR "shell script mode" .
Note that
.B \-s
.B \-f
must be at the end of the initial ``#!'' line.
Any other optional
.B "optional_other_flags"
must come before
the
.B \-f
flag.
.sp 1
In
.B "shell script mode"
the contents of the file are read and
executed as if they were in a file being processed by a read
command, except that a "command" beginning with '#' followed by
whitespace and ending at the next newline is treated as a comment.
Any optional
.B "optional_other_flags"
will be parsed first followed by
the later lines within the script itself.
.sp 1
In
.BR "shell script mode" ,
.B \-s
is always assumed.
In addition,
.B \-d
and
.B \-p
are automatically set if
.B \-i
is not given.
.sp 1
.B NOTE:
The use of
.BR \-f
does
.B NOT
imply
.BR \-q
and thus one would need to use
.sp 1
.in +5n
.nf
\fIcalc\fP\ [optional_other_flags\ \&...] \fB\-q\fP \fB\-f\fP filename
.fi
.in -5n
.sp 1
to disable the use of calc startup files as well.
.sp 1
For example, if
the file
.BR /tmp/mersenne :
.sp 1
.in +5n
.nf
\fI#!${BINDIR}/calc\fP\ \&\fB\-q\fP \fB\-f\fP
/* setup */
argc = argv();
program = argv(0);
stderr = files(2);
/* parse args */
if (argc != 2) {
fprintf(stderr, "usage: %s exp\n", program);
abort "must give one exponent arg";
}
exp = eval(argv(1));
if (!isint(exp) || exp < 0) {
fprintf(stderr, "%s: exp must be non-negative integer\n", program);
abort "must give one exponent arg";
}
/* print the mersenne number */
print "2^": exp : "-1 =", 2^exp-1;
.fi
.in -5n
.sp 1
is made an executable file by:
.sp 1
.in +5n
.nf
chmod +x /tmp/mersenne
.fi
.in -5n
.sp 1
then the command line:
.sp 1
.in +5n
.nf
/tmp/mersenne 127
.fi
.in -5n
.sp 1
will print:
.sp 1
.in +5n
.nf
2^127-1 = 170141183460469231731687303715884105727
.fi
.in -5n
.sp 1
Note that because
.B \-s
is required in
.B "shell script mode"
non-dashed args are made available as
strings via the
.BR argv ()
builtin function.
Therefore:
.sp 1
.in +5n
.nf
2^eval(argv(1))-1
.fi
.in -5n
.sp 1
will print the decimal value of 2^n-1
whereas
.sp 1
.in +5n
.nf
2^argv(1)-1
.fi
.in -5n
.sp 1
will not.
.sp 1
By default, using calc startup in
.BR "shell script mode" ,
calc will close standard input (stdin).
Thus builtin functions such as
.BR prompt (str)
will fail (return a null value).
Calc shell scripts that call the
.BR prompt (str)
builtin will not work properly (the prompt builtin
will always fail and return a null value) unless the
.B \-p
flag is given on the command line.
.sp 1
The following shell script will always print "got null" because
stdin will be closed by calc during startup:
.sp 1
.in +5n
.nf
#!/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);
}
.fi
.in -5n
.sp 1
However the following shell script (note the
.B \-p
before the
.B \-f
in the 1st line) will be interactive, prompt with "Test> " and print
the "got" result as expected:
.sp 1
.in +5n
.nf
#!/usr/bin/calc \-q \-p \-f
n = prompt("Test> ");