-
Notifications
You must be signed in to change notification settings - Fork 2
/
samarux.man
1356 lines (1198 loc) · 25.9 KB
/
samarux.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
# SamaruX Manual
#
# (c) 2007-2023 Miguel I. Garcia Lopez, FloppySoftware, Spain
#
# Created: 08 Dec 2014
# Last edited: 27 Dec 2023
#
# $NM is NAME
# $SY is SYNOPSIS
# $DE is DESCRIPTION
# $OP is OPTIONS
# $EX is EXAMPLES
# $NT is NOTES
#
# ========
@alias
#
$NM
alias - Manage command aliases
$SY
alias [name [arg ...]]
$DE
The command alias creates, removes and prints command
aliases.
To create (or modify) an alias, enter the alias name,
the real command name and the arguments (if any).
To remove an alias, simply enter the alias name.
To print all the aliases, enter a command line
without arguments.
$OP
None.
$EX
alias = Prints all the aliases
alias dir ls = Creates an alias without arguments
alias lf ls -f = Creates an alias with arguments
alias lf = Removes the named alias
$NT
Aliases defined with arguments can't be executed with
pipes (single aliases, can).
# ========
@ascii
#
$NM
ascii - Print the character table
$SY
ascii
$DE
The command ascii prints the character table.
$OP
None.
$EX
ascii
# ========
@batch
#
$NM
batch - Execute commands from a file
$SY
batch file [arg ...]
$DE
The command batch executes commands from a file.
If it's not specified, the default type for the
file name will be ".sx".
When executing, the name of the file becomes
the $0 variable.
If arguments are included, the 1st argument becomes
the $1 variable, the 2nd argument becomes the $2
variable and so on.
The $# variable will have the number of arguments
supplied to batch.
$OP
None.
$EX
batch setmyenv John B01:
batch backup.sx
$NT
Batch commands can be nexted up to 3 levels.
# ========
@builtin
#
$NM
builtin - Print the internal command names
$SY
cmds
$DE
The command builtin prints the available internal
command names.
$OP
None.
$EX
builtin
# ========
@cat
#
$NM
cat - Concatenate files
$SY
cat [-kn] [file ...]
$DE
The command cat writes its input to the standard output.
If no arguments are given, it reads from the standard
input.
The - file means the standard input.
$OP
-k Skip empty lines
-n Number lines
$EX
cat
cat -kn phrases.txt
cat -n facts.doc
cat header.txt - footer.txt > myletter.txt
# ========
@cd
#
$NM
cd - Change the current working directory
$SY
cd [directory]
$DE
The command cd changes the current working directory.
If the directory is not supplied as an argument, cd
tries to use the $HOME environment variable.
$OP
None.
$EX
cd A02:
cd 1:
cd
$NT
See the diralias command, for directory names.
# ========
@chmod
#
$NM
chmod - Change file modes (CP/M attributes)
$SY
chmod mode file ...
$DE
The command chmod changes file modes (CP/M attributes).
$OP
Modes are:
+w To set write permission (R/W in CP/M).
-w To reset write permission (R/O in CP/M).
+s To set system attribute (SYS in CP/M).
-s To reset system attribute (DIR in CP/M).
+a To set archive attribute (ARCHIVE ON in CP/M 3).
-a To reset archive attribute (ARCHIVE OFF in CP/M 3).
Modes can be combined.
If an attribute is not specified, it will remain unchanged.
$EX
chmod +s login.com
chmod +wa-s notes.txt calendar.doc
# ========
@clear
#
$NM
clear - Clear the console
$SY
clear
$DE
The command clear clears the console.
$OP
None.
$EX
clear
$NT
The command clear searches for the $TERM environment
variable, in order to know how to clear the console.
# ========
@command
#
$NM
Command edition
$SY
Rules to edit command lines
$DE
An usual command line looks like this:
command arg0 arg1 arg2 ...
To include spaces in an argument, enclose it between
single quotes:
'This is a single argument'
Environment variables can be used in the command line as
arguments and they will be substituted with their values,
if you precede them with '$':
echo Your name is $USER
You can include more than a command in the same command
line, by separating them with the ';' character:
cp letter.old letter.new ; cat letter.new
A command line starting with the '#' character, it is a
comment, with no effect:
# This is a comment, not a command
You can redirect stdin (console input) with the '<'
character:
ed < letter.txt
You can redirect stdout (console output) with '>' or
'>>':
ls *.c > mydir.txt
echo 'Buy some butler' >> todo.txt
You can redirect the output of a command to the input
of another command (piping), with the character '|':
ls *.c | more
Or you can enter a combination of above.
You can use the following control characters to edit
the command line:
- To delete the last character:
BS / CTRL-H (0x08)
DEL (0x7F)
- To delete the entire line:
CTRL-U (0x15)
CTRL-X (0x18)
- To retype the line:
CTRL-R (0x12)
- To execute the line:
CR / CTRL-M (0x0D)
LF / CTRL-J (0x0A)
Be aware that in the case of external commands,
if the variable BINDIR exists, SamaruX will
search there the executable files.
If the variable doesn't exists, SamaruX will
search in the current working directory.
To force SamaruX to search in another directory,
prefix the filename with it:
a04:program
To force SamaruX to search in the current working
directory, prefix the filename with ':':
:program
$NT
Some commands (alias) have restrictions on above.
Pipes are done using temporary files.
# ========
@compile
#
$NM
How to compile the SamaruX shell and its commands
$SY
This topic explains how to compile the shell with
its builtin commands, and the external commands.
$DE
To compile the shell (and its builtin commands):
1.Compile with MESCC - in CP/M:
cc sx
2.Optimize the code (optional) - in CP/M:
ccopt sx.zsm
3.Assemble the ZSM file - in CP/M:
zsm sx
4.Build the COM file from the HEX file - in CP/M:
hextocom sx
Once you have build the shell, you must modify the
file samarux.h, and recompile all the SamaruX external
commands.
To compile an external command (for example: less.c):
1.Compile with MESCC - in CP/M:
cc less
2.Optimize the code (optional) - in CP/M:
ccopt less.zsm
3.Build the REL file - in the host OS:
zmac less.zsm --rel
4.Build the PRL file - in CP/M:
link less [OP]
5.Rename the file from PRL to X - in CP/M:
ren less.prl less.x
$NT
To build the REL file, I use ZMAC version 03 Dec 2014,
a Z80 cross assembler, downloaded from George Phillips's
site: http://members.shaw.ca/gp2000/zmac.html.
Of course, you can use your preferred tools to achieve
the same results: emulators, hexcom, genprl, etc.
See the source files for more information.
# ========
@cp
#
$NM
cp - Copy files
$SY
cp [-fi] file_src file_dst
cp [-fi] src ... directory
$DE
The command cp copies files.
In the first form, only a single file can be copied.
In the second form, more than a file can be copied (src
can be a single file, an ambiguous file name, or a
directory).
$OP
-f Force: Delete destination if already exists
-i Interactive: Asks to user to delete destination if
already exists. It has prevalence
over -f option.
-v Verbose
$EX
cp myfile.txt myfile.bak
cp -i cat.c ls.c head.c b01:
cp 1:*.c 2:*.h 3:
cp -fv a00: b01:
# ========
@cpm
#
$NM
cpm - Execute CP/M commands
$SY
cpm command [arg ...]
$DE
The command cpm executes CP/M commands as PIP, STAT,
ED, BASIC, etc.
Pipes or redirections are useless.
If there are other commands after this in the same command
line, they will not be executed.
The procedure is:
- Save current environment variables and aliases.
- Exit from SamaruX to CP/M.
- Execute the CP/M command.
- Execute SamaruX quietly.
- Restore environment variables and aliases.
$OP
None.
$EX
cpm PIP A:=B:*.TXT
cpm BASIC myprog
cpm WS
$NT
In CP/M 2, it uses the $$$.SUB feature of the
standard CP/M CCP.
In CP/M 3, it uses the BDOS function CHAIN TO PROGRAM.
It uses the temporary batch file PROFRST.SX to load and
save the environment variables and aliases.
# ========
@date
#
$NM
date - Print or set the system date and time
$SY
date [[YYYY-MM-DD] hh:mm:ss]
date [[YYYY/MM/DD] hh:mm:ss]
$DE
The command date prints or sets the system date and
time.
$OP
None.
$EX
date
date 17:20:00
date 2015-04-08 17:20:00
$NT
Needs CP/M version 3.
# ========
@df
#
$NM
df - Print free disk space
$SY
df [drive ...]
$DE
The command df prints the free disk space for the
specified drives.
If no drive is specified, it prints the free disk
space for the current drive.
$OP
None.
$EX
df
df A: B:
# ========
@diralias
#
$NM
diralias - Manage directory names
$SY
diralias [name [directory]]
$DE
The command diralias manages the directory names.
A directory name, is an alias for a drive and user
specification.
To create a directory alias, enter the alias name,
followed by the drive and user specification.
To delete a directory alias, simply enter the alias
name.
To print all the directory aliases, enter a command
line without arguments.
$OP
None.
$EX
diralias = Prints all the directory aliases
diralias root a0: = ROOT: will reference A00:
diralias root = Removes the directory alias
cd root:
ls root:*.txt
cat root:profile.sx
# ========
@dump
#
$NM
dump - Print files in hexadecimal and ascii
$SY
dump file ...
$DE
The command dump prints files in hexadecimal and
ascii form.
$OP
None.
$EX
dump dump.com
dump login.txt cat.com
# ========
@echo
#
$NM
echo - Print its arguments
$SY
echo [-n] [arg ...]
$DE
The command echo prints its arguments.
$OP
-n To suppress the new line.
$EX
echo Hello world
echo -n Hello world
# ========
@ed
#
$NM
ed - Edit small text files
$SY
ed [file]
$DE
The command ed edits small text files.
Once in the editor, you can enter the following commands:
edit line_number -- Edit an line
insert line_number -- Insert a line over another
remove line_number -- Remove (delele) a line
copy line_number -- Copy to clipboard
paste line_number -- Paste from clipboard
append -- Append a line
print [line_number [how_many_lines]]
-- Print lines on the console
write [file_name] -- Write the file
info -- Information
help -- Help on commands
exit -- Exit to shell
$OP
None.
$EX
ed letter.txt
1 lines read.
ed> print
0: Hello
ed> append
1: Bye!
ed> print
0: Hello
1: Bye!
ed> insert 1
1: How are you?
ed> edit 0
0: Hello my friend.
ed> print
0: Hello my friend.
1: How are you?
2: Bye!
ed> write
ed> exit
# ========
@env
#
$NM
env - Manage environment variables
$SY
env [name [arg ...]]
env [-s] name arg ...
$DE
The command env creates, removes and prints environment
variables.
To create (or modify) an environment variable, enter the
variable name, and the arguments.
To remove an environment variable, simply enter the
variable name.
To print all the environment variables, enter a command
line without arguments.
$OP
-s To skip spaces
$EX
env = Prints all the variables
env TERM vt52 = Creates a variable
env TERM = Removes the named variable
env -s NAME John Smith = Creates NAME as JohnSmith
env -s FILE $HOME phones = Creates FILE as A00:phones
$NT
See the topic 'variables' to find a list of environment
variables used by SamaruX.
# ========
@exit
#
$NM
exit - Quit the shell
$SY
exit
$DE
The command exit quits the shell.
$OP
None.
$EX
exit
# ========
@expr
#
$NM
expr - Compute simple expressions
$SY
expr number1 operator number2
$DE
The command expr computes a simple expression and
outputs the result to the console.
The numbers and the result are 16 bit signed integers,
from -32,768 to +32,767.
Valid operators are:
add -- add two numbers
sub -- subtract two numbers
mul -- multiply two numbers
div -- divide two numbers
mod -- remainder after divide two numbers
$OP
None.
$EX
expr 1 add 3 = Prints 4
expr 5 add -1 = Prints 4
expr 5 sub 1 = Prints 4
# ========
@false
#
$NM
false - Return false
$SY
false
$DE
The command false returns the value false: 1.
$OP
None.
$EX
false
# ========
@fortune
#
$NM
fortune - Print a random adage
$SY
fortune [file]
$DE
The command fortune prints a random epigram of
one line of text.
If no file is specified in the command line, the
source for epigrams will be the file 'fortunes.txt'.
$OP
None.
$EX
fortune
fortune jokes.txt
# ========
@files
#
$NM
File and directory names
$SY
Rules to name files and directories
$DE
SamaruX accepts all usual CP/M file names, including
wildcards (* and ?) with the usual behaviour.
In addition to this, you can specify the directory in
the file name.
A directory can be named with its drive letter and
user number.
Also, you can use the diralias command to name
directories, and use that name instead.
If the drive letter is not included, it's assumed to
be the current drive.(1)
If the user number is not included, it's assumed to
be the current user number.(1)
(1) Be aware that in some circunstances, SamaruX will
search a file in another directory, instead of the
current one, if you don't specify it in the
filename (see the variables BINDIR for external
executables, and MANPATH for manuals).
To force SamaruX to search a file in the current
working directory, prefix the filename with the
character ':', as in:
:myprog
man :mescc stdio
$EX
Legal file and directory names:
a01:file.txt -- File in drive A, user number 1
2:account.dat -- File in current drive, user number 2
*.h -- Files matching *.h in current directory
b2:*.c -- Files matching *.c in drive A, user
number 2
c3: -- Directory on drive A, user number 3
Using diralias to name directories:
diralias root a0:
ls root:*.x
cd root:
Illegal file and directory names:
a:letter.doc -- User number not included
c: -- User number not included
$NT
In some commands, a directory name is equivalent to
all files in that directory (i.e. A2: means A2:*.*).
See the diralias command, to know more about directory
names.
# ========
@goto
#
$NM
goto - Jump to label in batch mode
$SY
goto label
$DE
The command goto jumps to a label in batch mode.
Labels are maximum 8 characteres long, must follow a
comment and must end with a ':' (see example).
$OP
None.
$EX
1: # Entry:
2: echo -n Enter 'y':
3: read REPLY
4: if $REPLY eq y goto Cont
5: goto Entry
6: # Cont:
# ========
@grep
#
$NM
grep - Find text patterns in files
$SY
grep [-options] pattern [file ...]
$DE
The command greps find patterns in files and sends the
result to the standard output.
If no file names are entered, more reads from the
standard input.
The - file means the standard input.
$OP
-c : Count [non] matching lines.
-i : Ignore case.
-v : Select non matching lines instead of matching ones.
$EX
grep -i Elvis bio.txt story.txt article.doc
# ========
@head
#
$NM
head - Print first lines from files
$SY
head [-nNUMBER] [file ...]
$DE
The command head writes the first NUMBER lines from files
to the standard output.
If no arguments are given, it reads from the standard
input.
The - file means the standard input.
$OP
-nNUMBER Writes up to NUMBER lines (default = 10).
$EX
head -n12 mytasks.txt
head myapp.c
# ========
@history
#
$NM
history - Manage command line history
$SY
history [entry]
$DE
The command history selects an entry from the
command line history or prints all the entries.
To select a history entry, enter the entry
number. The entry number 0 has the last
entered command line.
To print the history entries, enter a command
line without arguments.
$OP
None.
$EX
history 0 = Selects the last command line
history 3 = Selects the entry number 3
history = Prints all the history entries
# ========
@if
#
$NM
if - Test condition
$SY
if arg1 [not] eq arg2 command
if file [not] exist command
if arg1 [not] in_env command
$DE
The command if tests a condition and runs a command if
the result of the test is true:
eq -- Test if two strings are equal.
exist -- Test if a file exists.
in_env -- Test if an environment variable exists.
The optional word not inverts the test result.
$OP
None.
$EX
if TERM not in_env echo Terminal type is unknown!
if $USER eq John batch profjohn
if letter.txt exist ed letter.txt
$NT
The command if it's very useful in batch mode.
# ========
@ls
#
$NM
ls - List files
$SY
ls [-avksfl ...] [dir|file ...]
$DE
The command ls list files.
You can enter ambiguous file names.
If no file name is entered, ls lists all
the files (*.*).
$OP
-a Print file attributes
-v Verbose
-k Print file sizes
-s Sort file names
-f Same as -aksv
-l Same as -aks
$EX
ls a02:
ls -f *.c
ls -sv myfile.c m00:myfile.h myfile.zsm
# ========
@man
#
$NM
man - Print manual pages
$SY
man [[file] topic | ALL | TOPICS]
$DE
The command man prints manual pages about a topic, all
topics, or prints the available topics.
If no file name is given, man searchs in the default
man file "samarux.man".
If no arguments are given, the command is equivalent to:
man TOPICS
The optional MANPATH environment variable has the man
file path.
If MANPATH does not exists or it's not a valid path,
the current directory will be used instead.
To force man to search in another directory, prefix the
filename with it:
man a04:mescc stdio
To force man to search in the current working directory,
prefix the filename with ':':
man :mescc stdio
$OP
None.
$EX
man -- Print available topics in samarux.man
man cat -- Print cat topic help in samarux.man
man ALL -- Print all contents in samarux.man
man wp TOPICS -- Print available topics in wp.man
man wp fi -- Print fi topic help in wp.man
# ========
@mem
#
$NM
mem - Print memory usage
$SY
mem
$DE
The command mem prints the free and used memory size
in bytes.
$OP
None.
# ========
@more
#
$NM
more - Print the contents of text files
$SY
more [-number] [file ...]
$DE
The command more prints the contents of text files,
doing a pause when the screen is full.
You can enter the number of screen lines or leave
more to take this data from the system.
If no file names are entered, more reads from
the standard input.
The - file means the standard input.
$OP
-number To specify the number of screen lines
$EX
more
more myfile.doc
more -24 file.txt letter.doc
# ========
@mv
#
$NM
mv - Rename files
$SY
mv old_name new_name
$DE
The command mv rename files.
$OP
None.
$EX
mv schedule.txt schedule.bak
$NT
The command mv can't be used to move files,
or rename directories.
# ========
@profile
#
$NM
Profile
$SY
Profiling the shell
$DE
When running the shell, an optional startup file can be
used to setup your SamaruX environment:
profile.sx : For interactive mode.
profcpm.sx : For CP/M mode.
# ========
@ps
#
$NM
ps - Print running commands
$SY
ps
$DE
The command ps prints the running commands.
$OP
None.
$EX
ps
# ========
@pwd
#
$NM
pwd - Print the current working directory
$SY
pwd
$DE
The command pwd prints the current working
directory.
$OP
None.
$EX
pwd
# ========
@read
#
$NM
read - Read a line from standard input
$SY
read name
$DE
The command read reads a line from standard input and
assign its value to an environment variable.
$OP
None
$EX
echo -n Enter your name:
read USER
echo Hello $USER !!!
# ========
@rm
#
$NM
rm - Remove files
$SY
rm [-fi] dir|file ...
$DE
The command rm remove files.
You can enter ambiguous file names.
If a directory name is entered, rm assumes
all the files in that directory (*.*).
If the file name is ambiguous, rm will
print an error if the option -f is not
entered.
$OP
-f To force deletion in ambiguous file names
-i To ask to user for each file deletion
-v To be verbose
$EX
rm myfile.txt
rm hello.c hello.h