Mail Archives: cygwin/1999/02/17/01:15:35
Hello cygwin,
This little utilty might be of help for some few people, I
guess. http://www.infoservice.lg.ua/~paul/devel/sh-supp.html
------------
Sh-Supp the Native Win32 shell to POSIX sh command exectution synax
converter and script supporter
"Bringing both worlds together"
Functionality
Sh-Supp utility does following:
* Converts COMMAND.COM's command execution syntax
COMMAND.COM /C <command> <arg1> <arg2> ... <argN>
to POSIX shell excution syntax
<shell> -c '<command;> <arg1> <arg2> ... <argN>'
* Checks whether <command> is POSIX shell script, and if so, issues
corresponding interpreter call to execute it:
<interpreter> <command> <arg1> <arg2> ... <argN>
(which is executed via shell, of course)
Purpose
There are following reasons to use it:
* Some people (like me) happy to have real shell underneath, but prefer
to use additional fullscreen shell for direct interaction
* Some people (like me) don't want to use buggy and sluggish current
ports of real shells, still retaining some nice capabilties such as
script handling.
How it works
MS designed a hook to specify a program which executes a coomand - the
COMSPEC environment variable. DOS and Windows programs supposed to favor
its setting. So, we just override COMSPEC with 'sh-supp.exe'. Then
following POSIX-based shell-lookup rules apply:
* Use contents of SHELL environment variable as shell name
* If SHELL is not set, suppose 'C:\COMMAND.COM /C' (sane setting for
Win95)
* If shell name contains '/C' (case-sensitive), that shell considered
having ms-idiosyncratic syntax, else - POSIX syntax
Then, file named <command> searched on PATH (with following rules: if PATH
doesn't contain an '.' path, it searches current directory before all
listed on path, else it doesn't implicitly search current direcory).
If such file found and has its first line starting with '#!', it considers
it shell script and forms new command line, starting with rest of script's
first line, followed by original <command> <arg1> ... <argN>. (Note, this
happens independently whether shell POSIX or not).
Either original or new-formed command line executed with method appropriate
for type of shell in effect.
Note that, unlike POSIX specifies, script interpreter is searched on path,
so you may specify just '#!awk -f' (That's considered to be feature). If
you want POSIX to this joke utility portabilty, you have to have your stuff
in appropriate places (/bin, /usr/bin, and /usr/local/bin mostly), or
recompile it with cygwin and use its mount table and/or symlinks.
Installation
1. Decide where you'll put variables settings. Bat script of your default
environment is most appropriate place, autoexec.bat's branch to Win is
another possibilty. Be careful not to set it in autoexec.bat
unconditionally, or you will be unable to run anything in pure dos
(restart with shift pressed to bypass autoexec.bat in such case).
2. If you don't have SHELL, set it to your POSIX shell, or if you don't
care about that, to '<path>\COMMAND.COM /C' (Win9x) or '<path>\CMD.EXE
/C' (NT).
Links
(Fullscreen) Shells that favor COMSPEC
* Volkov Commander is John Socha's Norton Commander clone, DOS
applaction
* FAR is another NC clone, win32 console application, one I use and
mostly happy with
Download
Sh-Supp 1.0, sources and binary
------------------------------------------------------------------------
Best regards,
Paul mailto:paul-ml AT is DOT lg DOT ua
- Raw text -