Author Topic: SamaruX - Unix-like shell for CP/M  (Read 4966 times)

0 Members and 1 Guest are viewing this topic.

Offline FloppySoftware

  • CPC6128
  • ****
  • Posts: 236
  • Country: es
  • The best team: Amstrad PCW, CP/M, and the Z80 cpu.
    • Floppy Software
  • Liked: 230
SamaruX - Unix-like shell for CP/M
« on: 01:24, 24 February 15 »
Hello!

I'm proud of announce the release of SamaruX v1.00, my Unix-like Shell Project for CP/M.
Also, it's ready a new release of MESCC (v1.03), my Small-C compiler version.
They can be download from my website.
Suggestions, comments, etc. are welcome!
--
SamaruX
(c) Miguel I. Garcia Lopez / FloppySoftware
FloppySoftware
cpm-connections.blogspot.com
floppysoftware@gmail.com
Overview
SamaruX is a Unix-like shell for the CP/M operating system & the Z80 CPU.
It has been developed with MESCC, my Small-C compiler version for CP/M and Z80.
Instead of write separate commands for each task as in real Unix, the shell has some built-in commands.
Of course, it's not at all a new idea (see BusyBox, for example), but I believe this scheme has a lot of advantages in a small environment like CP/M.
For example, we can save some bytes on disk by joining some commands in one file, instead of writing them as separated ones, because we don't have to repeat some shared code in each of them.
Obviously, SamaruX doesn't have all functionalities of Unix, but it has some nice and useful commands, to work in a Unix-like system, under our beloved CP/M operating system.
Some SamaruX functionalities are:
-Redirection of stdin and stdout with > and <.
-Piping with |.
-Environment with variables $TERM, $USER, etc.
-Command line history.
-Profiling for environment customization.
-Command aliasing.
-Batch processing with flow control and arguments passing.
-Complete on-line manual.
-Prompt customization.
-Built-in commands: cp, rm, mv, man, cat, more, grep ...
This document is not an exhaustive reference of SamaruX, but only an overview, in order to show some of its capabilities.
Please, refer to the manual for a complete description.
Execution modes
There are two execution modes:
-CP/M mode: The SamaruX shell will execute only a command and will return to CP/M.
-Interactive mode: The SamaruX shell will read and execute your commands from the keyboard, until you return to CP/M.
CP/M mode example:
A>sx echo Hello world!
Hello world!
A>
 
Interactive mode example:
A>sx
Samarux v1.00 / 29 Dec 2014 - (c) FloppySoftware, Spain
CP/M version 2.2
28 built-in commands
Hi FloppySoftware welcome to Samarux!
[FloppySoftware at B00:] $ env
TERM = vt52
USER = FloppySoftware
PROMPT = [%u at %w] %$
[FloppySoftware at B00:] $ exit
A>
 
Profiling
With profiling, you can customize your SamaruX environment.
Its use it's not compulsory, but highly recommended (and useful).
There are two files for profiling::
-profile.sx: For the CP/M mode.
-profcpm.sx: For the interactive mode.
An example of profiling in interactive mode:
# -------------------------- #
# SAMARUX START-UP PROFILE   #
# -------------------------- #
env TERM vt52
env USER FloppySoftware
env PROMPT [%u at %w] %$
#
alias h history 0
alias logout exit
#
echo Hi $USER welcome to Samarux!
echo
 
Piping and redirection
With SamaruX, you can enter useful command lines like:
-cat letter.txt | more
-grep 'Gary Kildall' cpm.txt article.doc news.txt > refs.txt
-ls -l *.h *.c > cfiles.txt
-man cat | more
Command line
You can separate commands in the same line with the semicolon ( ;) :
 man cp > cp.txt ; clear ; cat cp.txt | more 
You can include environment variables in your command lines:
 env NAME Julius ; echo My name is $NAME 
An argument can contain spaces if it is surrounded by single quotes ('):
 env NAME 'Julius Smith' ; echo My name is $NAME 
SamaruX has a command line history facility.
To see the history, just type:
 history 
And the history command will reply something like:
[FloppySoftware at B00:] $ history
0: cat manual.doc | more
1: ed letter.txt
2: ls *.c
3: man cat
 
To select a history command entry, just type its number:
 history 2 
And the shell will present a command line, ready to be edited and / or executed:
 [FloppySoftware at B00:] $ ls *.c 
Executing CP/M commands
You can execute CP/M commands by using the cpm command:
 cpm PIP A:=M:*.COM 
You will return to SamaruX, once the CP/M command had finished its work.
Aliases
You can make aliases for your most frequently used commands:
 alias dirall ls -f 
Then, you can enter the defined alias as a single word:
 dirall 
Small text editor
SamaruX has the ed command, a very humble text editor, but very useful to create and edit small text files in a fast way.
 
[FloppySoftware at B00:] $ ed profile.sx
File :  profile.sx
Lines:  14/48
ed> print
    0: # -------------------------- #
    1: # SAMARUX START-UP PROFILE   #
    2: # -------------------------- #
    3: # env HOME A00:
    4: env TERM vt52
    5: # env TEMP M00:
    6: env USER FloppySoftware
    7: env PROMPT [%u at %w] %$
    8: #
    9: alias h history 0
   10: alias logout exit
   11: #
   12: echo Hi $USER welcome to Samarux!
   13: echo
ed> edit 8
    8: # This is a comment
 
Help!
SamaruX has a built-in command named man, to offer on-line help about commands an other topics.
The help contents is stored in the man.sx file.
As this file is an ordinary text file with a simple structure, you can even add or modify topics.
To see the available topics, just type:
 man | more 
To read about a topic in particular, say cat, just type:
 man cat | more 
In addition to this, SamaruX has a built-in command named builtin, that prints the name of all available built-in commands. Just type:
 builtin 
Batch processing and flow control
With the batch command, you can process files with commands as if they were typed on the keyboard.
Some other SamaruX commands will help you with flow control in batch processing:
-if
-goto
-read
-exit
An example:
# ----------- #
# TEST SCRIPT #
# ----------- #
#
echo Test Script
echo ===========
# Menu:
echo
echo 1 : Option One
echo 2 : Option Two
echo 0 : Exit
echo
echo -n Your choice:
read OP
echo
if $OP eq 1 goto One
if $OP eq 2 goto Two
if $OP eq 0 goto Exit
echo Bad choice, try again.
goto Menu
# One:
echo Your choice was Option One.
goto Menu
# Two:
echo Your choice was Option Two.
goto Menu
# Exit:
env OP
 
You can include arguments in batch processing.
If you have a file named write.sx with this contents:
echo $1 $2 $3

And you type:
 batch write.sx How are you? 
The system will reply with:
 How are you? 

License
Copyright (c) Miguel I. Garcia Lopez / FloppySoftware, Spain
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.

--






floppysoftware.es < NEW URL!!!
cpm-connections.blogspot.com.es

Offline Munchausen

  • 6128 Plus
  • ******
  • Posts: 763
  • Country: gb
  • Liked: 197
Re: SamaruX - Unix-like shell for CP/M
« Reply #1 on: 03:02, 24 February 15 »
This looks great  ;D ! Can you run CP/M software from SamaruX?

EDIT: I see that it can... what's the $$$.SUB trick?!
« Last Edit: 03:19, 24 February 15 by Munchausen »

Offline Munchausen

  • 6128 Plus
  • ******
  • Posts: 763
  • Country: gb
  • Liked: 197
Re: SamaruX - Unix-like shell for CP/M
« Reply #2 on: 03:17, 24 February 15 »
Also, I guess this should work fine on the CPC under CP/M?

I'm also very interested in MESCC... again does it work for CPC? And what features does it have vs normal C? I ask because the "standard" small C only implements a relatively small part of the C standard (no structs, no floats, no unsigned types, no for loops, no goto, no switch statements, etc), is K&R rather than ANSI, and doesn't do any optimisation. I'm also wondering what optimisations you do?

Awesome stuff :)

Offline FloppySoftware

  • CPC6128
  • ****
  • Posts: 236
  • Country: es
  • The best team: Amstrad PCW, CP/M, and the Z80 cpu.
    • Floppy Software
  • Liked: 230
Re: SamaruX - Unix-like shell for CP/M
« Reply #3 on: 10:18, 24 February 15 »
This looks great  ;D ! Can you run CP/M software from SamaruX?

EDIT: I see that it can... what's the $$$.SUB trick?!
Under CP/M 2, to chain from a program to another, we can use the $$$.SUB feature of the CCP.
As far as I know, SUBMIT uses that procedure.
In fact, in a $$$.SUB file we can write more than one command, one 128 byte record for each one in reverse order.
Some CP/M MENU programs use that.
Under CP/M 3, this feature is supported for compatibility, but there is a "new" BDOS function (CHAIN TO PROGRAM) to perform that without tricks.
SUBMIT for CP/M 3 uses a RSX, not the $$$.SUB feature.
In SamaruX I used the $$$.SUB file method for compatibility.
 
floppysoftware.es < NEW URL!!!
cpm-connections.blogspot.com.es

Offline FloppySoftware

  • CPC6128
  • ****
  • Posts: 236
  • Country: es
  • The best team: Amstrad PCW, CP/M, and the Z80 cpu.
    • Floppy Software
  • Liked: 230
Re: SamaruX - Unix-like shell for CP/M
« Reply #4 on: 10:34, 24 February 15 »
Also, I guess this should work fine on the CPC under CP/M?

I'm also very interested in MESCC... again does it work for CPC? And what features does it have vs normal C? I ask because the "standard" small C only implements a relatively small part of the C standard (no structs, no floats, no unsigned types, no for loops, no goto, no switch statements, etc), is K&R rather than ANSI, and doesn't do any optimisation. I'm also wondering what optimisations you do?

Awesome stuff :)
Yes, it would run perfectly in a CPC under CP/M 2 or 3.  8)
In fact, this should run in any CP/M computer with a Z80 cpu.
Regarding MESCC, it's a Small C derived version that supports for, switch, unsigned types, a better CPP, etc.
But sorry, no floats or structs, no ANSI.  :'(
It's a CP/M compiler and should run in any CP/M computer with a Z80 cpu, but the generated assembler code it's not CP/M dependant by itself.
It's has good libraries with optional support for stdin, stdout, stderr and redirection in the command line.
The priority to generate assembler code is small size, not speed (but don't expect 100% optimized assembler code!).  ;)
I use it for nearly all my projects for CP/M and/or the PCW.
Why?
Well, it has limitations, of course, but I understand the source code and I can mantain it an modify it if something goes wrong.  :-\
And as far as i know, is very stable. That's very important to me, because I prefer to search bugs in my programs, not in the compiler!  :laugh:
 
 
 
floppysoftware.es < NEW URL!!!
cpm-connections.blogspot.com.es

Offline TFM

  • Visit the mysteries of the CPC at www.futureos.de
  • Supporter
  • 6128 Plus
  • *
  • Posts: 10.103
  • Country: aq
  • Space Chicken for FutureOS is free!
    • index.php?action=treasury
    • FutureOS - The revolution on CPC!
  • Liked: 1967
Re: SamaruX - Unix-like shell for CP/M
« Reply #5 on: 20:49, 24 February 15 »
Hello!

I'm proud of announce the release of SamaruX v1.00


I wonder if you ever worked with Z3Plus for CP/M. If yes, does it work with SamaruX?

TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

Offline FloppySoftware

  • CPC6128
  • ****
  • Posts: 236
  • Country: es
  • The best team: Amstrad PCW, CP/M, and the Z80 cpu.
    • Floppy Software
  • Liked: 230
Re: SamaruX - Unix-like shell for CP/M
« Reply #6 on: 21:41, 24 February 15 »

I wonder if you ever worked with Z3Plus for CP/M. If yes, does it work with SamaruX?
SamaruX is an standard CP/M program.
If Z3Plus accepts standard CP/M programs, the reply would be YES.
 
floppysoftware.es < NEW URL!!!
cpm-connections.blogspot.com.es

Offline TFM

  • Visit the mysteries of the CPC at www.futureos.de
  • Supporter
  • 6128 Plus
  • *
  • Posts: 10.103
  • Country: aq
  • Space Chicken for FutureOS is free!
    • index.php?action=treasury
    • FutureOS - The revolution on CPC!
  • Liked: 1967
Re: SamaruX - Unix-like shell for CP/M
« Reply #7 on: 23:36, 24 February 15 »
Get information about Z3Plus, you will not regret it! It replaces the CCP and BDOS for CP/M Plus. Has terminal descriptors and and and... so similar to SamuraX. It was commercial back the day. Wordstar 4 supported it. The cp-m 2.2 version was called nzcom. I don't want to derail the thread, but I think that SamuraX and Z3Plus would be a great team.

TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

Offline FloppySoftware

  • CPC6128
  • ****
  • Posts: 236
  • Country: es
  • The best team: Amstrad PCW, CP/M, and the Z80 cpu.
    • Floppy Software
  • Liked: 230
Re: SamaruX - Unix-like shell for CP/M
« Reply #8 on: 19:43, 27 February 15 »
New available version!
SamaruX v1.02, 27 Feb 2015
--------------------------

Last changes.

New control characters for command line edition:
------------------------------------------------

To delete the entire line:
     CTRL-U (0x15)
     CTRL-X (0x18)

To retype the line:
     CTRL-R (0x12)

New environment variables:
--------------------------

- LINES   : Number of console lines
- COLUMNS : Number of console columns
- TMPDIR  : Temporary directory (used by pipes)

The use of these environment variables is optional.
When a builtin command asks for a system variable,
the procedure is as follows:

- If the corresponding environment variable exists and
  has a legal value, use it.

- Under CP/M 3, use the value from the SCB.
- Otherwise, use the default values (for the console dimensions,
  the values #defined in the source code; for the temporary
  drive, the current drive).

 
floppysoftware.es < NEW URL!!!
cpm-connections.blogspot.com.es

Offline Prodatron

  • 6128 Plus
  • ******
  • Posts: 802
  • Country: de
  • Back on the Z80
    • index.php?action=treasury
    • SymbOS SYmbiosis Multitasking Based Operating System
  • Liked: 988
Re: SamaruX - Unix-like shell for CP/M
« Reply #9 on: 23:24, 27 February 15 »
Wow that's very impressive!!
Did you implement Piping with temporary files?
Have to try it out soon. What kind of search strings does Grep accept?

CU,
Prodatron

*EDIT* Sorry, I already got the answers from the package, really cool!
« Last Edit: 12:05, 28 February 15 by Prodatron »

GRAPHICAL Z80 MULTITASKING OPERATING SYSTEM