scsh
© Ian C

C-shell type interface for MSDOS


INDEX

  1. OVERVIEW
  2. USAGE
  3. INSTALLATION
  4. IMPORTANT NOTE ON ESCAPING
  5. COMMAND INPUT
  6. SMALL CSH ONLY COMMANDS
  7. SUPPORTED CSH COMMANDS
  8. UNSUPPORTED CSH COMMANDS
  9. SETS (shell variables)
  10. KNOWN BUGS
  11. BUG REPORTS
  12. CHANGE LOG
  13. COPYRIGHT

OVERVIEW

scsh is a unix CSH style command line interface for MSDOS. Provides reasonably close csh command line functionality with these omissions and differences:



USAGE

scsh [options] [command [args]]

Where options are :

-b
Stop interpreting command line arguments. Useful for passing switches to [command].
-c
Read the first argument as a command. In the scsh this means that all files that are non-executable (ie. do not end in .com, .exe, etc) are treated as scsh scripts regardless of the presence of #/bin/[s]csh on their first line.
-e
Exit scsh if any command or built-in command returns a non-zero status. Note in the case of sequential or piped commands (eg. ls foo ; ls bar) only the last command has it's status checked.
-f
Do not read CSHRC and LOGIN on startup (see INSTALLATION)
-i
Forced interactive in CSH. In scsh forces reads from a basic stdin, disabling the PC specific based key reading and editing routine.
-n
Parse but do not execute commands.
-s
Take commands from standard input. In scsh forces reads from a basic stdin, disabling the PC specific based key reading and editing routine.
-t
Accept one command and then quit.
-v
Verbose. Entered commands are echoed after history substitution.
-V
Set verbose before reading CSHRC
-x
Echo. Entered commands are echoed just before execution and after all expansions.
-X
Set echo before reading CSHRC
-L
Force Small CSH to assume this is a login shell. See the section in INSTALLATION to see what different actions are performed for a login shell.


INSTALLATION

Install scsh.exe along your path. On startup scsh will look for first a .cshrc file, and if that's not there a _cshrc file, in your home directory. Your home directory is defined by the variable HOME, and if it doesn't exist then the root directory is taken to be home.

If the first character of the executable name is '-' then a .login (or _login) file is also executed from our home directory. Note this is just to match the workings of the real csh under UNIX, and is probably pointless for DOS; and indeed the -L switch is provided to emulate this far more easily under DOS.

Also note that to get the best out of scsh you will need external programs to do your dirs, copies, etc - just like a normal UNIX shell. There are good versions of UNIX like utilities (including all the text processing ones) available from SIMTEL mirrors in the DJGPP directories. I'd recommend using these with scsh.



IMPORTANT NOTE ON ESCAPING

The parser at the moment is not at all clever, so as a quick workaround use single quotes (') to escape history and $ characters. Eg.
in the real csh

becomes in scsh

Note that has an happy side effect of this method of escaping using shell variables in the prompt means they will only be expanded at execution time, so that

will work in the scsh.

Note that the normal escape character (\) still works at the start of a command to disable aliasing.



COMMAND INPUT

Unless stdin mode (-s or -i) is selected scsh reads commands through a PC specific input routine that allows editing and recognises these keys:

LEFT/RIGHT
Move cursor along current line
CONTROL LEFT/RIGHT
Move cursor along current line in words.
BACKSPACE/DELETE
Delete character before/at cursor.
CTRL DELETE
Delete to end of line from cursor position.
HOME/END
Move to start/end of line.
UP/DOWN
Make the previous/next history item the current input.
INSERT
Toggle insert mode on/off.
CTRL D
If file name completion is on, list the files that match the word directly before the cursor. Typed at the start of an empty line it will act as an EOF character.
ESCAPE
If file name completion is on complete the word directly before the cursor.
CTRL W
Erase the previous word.
CTRL U
Empty the current line.
CTRL Z
If typed as the first character, acts as an EOF character.
CTRL L
Enters a none breaking space. eg.
> ls /Program[CTRL L]Files/*

SMALL CSH ONLY COMMANDS

These commands are additional to the standard commands listed in the next section.

.code

Prompts for a key, then once pressed returns the code for that key to be used by the .key command.

.key [keycode [string]]

Without any arguments lists all the installed key expansions. Given a keycode it displays the expansion for that code. Given a code and string defines that key to return that string. The \n and \r C style escape characters will cause RETURN to be pressed for the string.

Note that keycodes are only expanded if the PC specific entry routine is being used and that recursive definitions are possible and will break Small CSH!

.unkey [keycode]

Without any argument removes all keycodes. Otherwise just removes the key definition for keycode.

.version [-l]

Display build and version information. If the -l switch is used then the limits defined at compilation of the shell are also listed.
Use the output from version -l when reporting bugs.


SUPPORTED CSH COMMANDS

These csh commands are implemented in the following ways:

:
Null command.

alias [name [def]]

Assigns def to be the alias name. If def is missing the alias for name is displayed if defined. If just alias is typed then all the aliases are displayed.

break
This command is parsed and then ignored in scsh currently.

breaksw

This command is parsed and then ignored in scsh currently.

case [label:]

This command is parsed and then ignored in scsh currently.

cd [dir]
chdir [dir])

Change the working director to dir. If no argument is given then change directory to the users home directory ($home).
If the argument is a dash (-) and no such directory exists then the previous directory is used as the argument (see $oldcwd).

continue
default:

These commands are parsed and then ignored in scsh.

dirs

Prints the current directory stack, most recent first; the first being the current directory.

echo [-n] list

The arguments are printed to stdout, separated by spaces. Output is terminated by newline, unless -n is supplied.
Note that the following C style escapes are allowed:

\n	Newline
\m	Carriage return
\a	Alert (bell)
\t	Tab
\0n	1,2,3 or 4 character octal code.

eval argument

Executes the argument, and then takes the output from the command and uses that as a command.

exec command

Execute command in place of the current shell.

exit [n]

Exits to the process which invoked scsh, returning a status code of n if passed, zero otherwise.

foreach var (wordlist)
...
end

This command is parsed and then ignored in scsh currently.

glob argument

Performs wildcard expansion on argument. Resulting names are printed to stdout, separated by the nul character.

goto label

This command is parsed and then ignored in scsh currently.

hashstat

This command is parsed and then ignored in scsh currently.

history [-hr] [n]

Display the history list. If n is given, displays only the n most recent entries.

-r	Reverse printout order
-h	Don't prefix output with history numbers

if (expr) command
if (expr) then
...
else if (expr2) then
...
else
...
endif

This command is parsed and then ignored in scsh currently.

limit [-h]

Displays the limits of resource usage available to the shell. The hard limits are displayed if -h is supplied.
Note that unlike the real csh limits can only be displayed, not set.

logout

In scsh the equivilent of 'exit 0'

popd [+n]

Takes the top entry on the directory stack and cds there. If +n is supplied the nth item is removed (where 0 is the most recent).

pushd [+n | dir]

Pushes the current directory onto the directory stack and cds to dir. If no arguments are given the top two directories on the top of the stack are swapped. If +n is given then the stack is rotated so the nth element is on top and that dir cd'ed to.
If the argument is a dash (-) and no such directory exists then the previous directory is used as the argument (see $oldcwd).

rehash

This commands is parsed and then ignored in scsh currently.

repeat count command

Repeat command count times.

set [var [= value]]
set var[n] = word

With no arguments set displays all the current shell variables. If just var is supplied var is set to an empty value. When value is supplied var is set to value [either a single word or a (word list)].
The second form replaces element n of var with word.

setenv [VAR [value]]

With no arguments displays all current environment vars. With VAR sets the environment variable up to be empty. If value is supplied then VAR is set to value.

shift [var]

The first word of the set var is discarded and the remaining elements moved down (ie. $var[2] becomes $var[1]). Shifting and empty or non-existent set is an error.

source [-h] file

Reads commands from file. If -h is supplied the commands are added to history, but not executed.

time [command]

This produces differently output to the normal time command. On it's own, it reports the length of time since startup, and given a command it will reply with a time taken to execute the command. The resulting output is in the form:

    [n days] hh:mm:ss.mmm

switch (string)
case label:
...
breaksw
...
default:
...
breaksw
endsw

This command is parsed and then ignored in scsh currently.

unalias pattern

Discard aliases that match (filename substitution) pattern. All aliases are removed by unalias *.

unhash

This command is parsed and then ignored in scsh currently.

unset pattern

Remove variables whose names match pattern. All variables are removed by 'unset *' - this is not advisable!

unsetenv variable

Remove variable from the environment. Unlike unset no pattern matching is done.
NOTE: This is currently unimplemented.

while (expr)
...
end

This command is parsed and then ignored in scsh currently.

@ [var =expr]
@ [var[n] =expr]

This command is parsed and then ignored in scsh currently.


UNSUPPORTED CSH COMMANDS

Aside from various commands, which are parsed and not yet implemented, these commands are parsed, but print a warning saying they are not supported :


SETS

Some shell variables have special meaning to the shell itself. These are :

$$

The process ID of the shell. This will return a meaningless, semi-random value under DOS.

cwd

Your current directory.

oldcwd

Your previous directory. Initially the same as cwd on start up.

echo

If set then commands are echoed just before being executed and after all expansions have been done to the line.

filec

if set and the PC specific input routines (ie. scsh was not started with -i or -s) used allows filename completion. Pressing ESCAPE at the end of a word will try and complete the argument to a filename. Pressing ^D will show matches for the current word, e.g if directory holds fred, freda and frog then :
> vi fre[CTRL D]
fred freda
> vi fro[ESCAPE]
> vi frog

Note the way the expansion works with .exe files too - e.g if directory holds prog.exe and prog.c then :
> pr[ESCAPE]
> prog
> prog.e[ESCAPE]
> prog.exe

fignore

If set, the filenames ending in any of the set's listed extensions are omitted from filename completions. Defaults to (.o).

fnconv

If set then all '/' characters in the command line are converted to '\' characters, unless enclosed in single (') quotes. Defaults to being unset.

history

Setting this to a number defines who many of your previous commands are stored in the shell's history.

savehist

Setting this to a number defines how much of your history is saved into a file called $HOME/.history (or _history if that cannot be written). On next starting the shell this file is read and the history populated with it.

home

The users home directory. Initialised but not used by scsh, so unsetting or setting to different values has no effect.

ignoreeof

If set and using the PC specific input routines (ie. scsh was not started with -i or -s) then ^Z (EOF) is ignored on the input steam. Defaults to set. Note that ignoreeof does not currently work if stdin is being used for input.

noclobber

If set redirecting out to a file that already exists; or doesn't exist if the redirection is an append; is an error.

noglob

Switch off wildcard expansion. eg.
> echo *
fred freda frog
> set noglob
> echo *
*

nonomatch

If set then wildcards that don't match anything are passed onto the program being called. eg.
> ls *
fred freda frog
> ls *.XXX
scsh: no match
> set nonomatch
> ls *
fred freda frog
> ls *.XXX
ls: *.XXX not found

path

Lists the directories to search to find executables. Note that the environment variable PATH is updated whenever this variable is set and likewise the set is updated anytime setenv PATH=<path> is done.

pcedins

If set and the PC specific input routines then the keyboard is switched to insert mode. Unset to go back to overwrite. Note that using the 'Insert' key on the keyboard also alters the mode and this variable.

prompt

If set the value of prompt is displayed in front of the next line of user input. Note that in scsh variable expansion is done on the value, so this will work : set prompt='$cwd) '

status

The status code returned by the last command.

user

Your user name. Initialised but not used by scsh, so unsetting or setting to different values has no effect.

verbose

If set then the command line is echoed after history substitution has taken place.

scshver

Contains version number of scsh.



KNOWN BUGS

  1. Filename completion sometimes destroys case. This is currently unavoidable due to the way DJGPP handles case significance while globbing files.
  2. Filename completion and globbing does not work with files beginning with a dot.
  3. After a while the shell may be unable to spawn new processes. This is a restriction of the Windows DMPI memory manager and is unavoidable.


BUG REPORTS

Mail problems (include the output from the .version -l command) or fixes to ianc@noddybox.demon.co.uk



CHANGE LOG

Version 1.01
	- Fixed bug whereby executables given with path prefixes are ignored
	- Added '-' argument for cd and pushd

Version 1.0
	- Initial release.


COPYRIGHT

This software may be freely distributed providing no charge is made for it. If modified it must be distributed with the original copyrights, docs and sources intact along with any amendments.



$Id: scsh.html,v 0.10 1999/11/19 22:05:51 dosuser Exp dosuser $