Brash: Bourne Reborn Again SHell
Brash.exe is a re-coding of the bourne shell -- from scratch -- for the windows environment using threads instead of child processes. It also has some features borrowed from GNU Bash and a few new features of its own -- such as numerous simple but robust implementations of the normal unix helper commands: ls, diff, grep, sed, cut, expand, stat, etc.
Brash is not, in any way dependent on GNU libraries, but it is dependent on GNU source code for regular expression processing, and file name pattern matching. Nor is Brash in any way dependent on the CYGWIN environment. A few source files created by other individuals are also included. Each file in the distribution should be reviewed for copyright details. The .ver command lists all the corresponding copyrights.
Brash runs in a normal Windows Console and it supports TAB-completion that understands the windows file system:
- backslash rather than forward slash (\ vs /)
- case insensitivity
- drive letters (c:\\) etc
Brash lets you write unix style pathnames, but when you press the tab key, it converts them to windows style names. Note that most of the time, this means using two backslashes to represent the directory separator:
c:\\dir\\path\\fileBut if you are using apostrophe quote strings, brash recognizes this fact -- as best it can -- and uses a single quote in that situation. For example, if you type
echo 'fred/Brash will change the text to
echo 'fred\The difference being the number of back-slashes. Within an aphostrophe quote string, you get a single backslash.
The source code is fully available and was created specifically with the goal of being made public and covered mainly by the author's personal copyright, see below. Though some parts of the source are covered by the GNU copyright and possibly one other copyrights. Note that the parts that are covered by GNU copyrights could be easily replaced. I can explain this via email to anyone who is interested.
Why Bother with Brash?
Brash is meant for people who love the bourne shell or GNU bash but who need to work in the Microsoft Windows environment. Also, if you need unix commands that are not properly duplicated in Windows (diff, grep, sed, cut, etc), Brash can provide reasonable implementations of these in its single executable installation.Windows developers who are used to using the CMD.exe program should have a low learning curve as well. The startup resources file, .brashrc, by default provides aliases and shell functions that map to both the CMD.exe environment and the bourne shell. For example:
- copy is provided as a shell function that invokes CMD.exe to perform copies -- using the normal Windows copy syntax.
- The unix cp function is also provided as a shell function that supports the unix cp command syntax but uses the windows copy command to do the actual copying.
- ditto for rm, rmdir, mkdir, and a few other commands.
Basically, brash lets you think like a unix programmer but also use all the tools available to you on windows.
Part of the bourne-like environment is provided using new builtin shell commands that provide unix like functionality. These new extensions to the bourne builtin command begin with the dot character:
- .ls -- roughly like the unix command ls
- .diff -- roughly like unix diff command
- .regex -- roughly like the following unix commands rolled into one:
- grep
- sed
- nl
- .rm -- lets you delete files and directories
- .rename -- lets you rename files and directories
- .cat -- roughly like the unix command cat
- .cut -- roughly like the unix cut command.
- .stat -- roughly like the unix command stat
- .regex -- roughly like the unix commands grep and sed
- .attrib -- roughly like the windows attrib command
- .expand -- expands tabs / compresses with tabs
- .wc -- word count
- .head -- head
- .date -- date
- .solve -- guassian simultaneous linear equation solver
- .linreg -- linear regression calculator. Solves and predicts.
- .ver -- lists the brash version and various copyright notices.
So why not just use CYGWIN bash?
If you already have bash installed, there's no reason to switch to Brash, but if you don't -- for example if you don't have any of the cygwin tools, installed, you can install brash by downloading a single executable. (Just one!) You don't have to install a bunch of DLL's and use installer programs that modify your registry.You should also download a .brashrc file, which will set up some common default emulations of standard windows commands. Or you you can emulate standard linux commands if you prefer. as well -- so the minimal download is actually these 2 files:
- brash.exe -- put in your PATH somewhere
- .brashrc -- put in your %USERPROFILE%
Brash is a true hybrid between unix and windows. If you are a unix/linux programmer who is also familiar with windows cmd.exe scripting, you will find that the annoyances of cmd.exe are gone but windows file names and commands are respected: most cmd.exe commands are available, or are easily scripted. Though you may to do do some of this yourself. See .brashrc for examples.
Note that the tab key will auto-convert unix and partially correct windows file names into correctly formatted file names. Use it often!
Licensing
Brash was developed with the specific purpose of making it freely available -- though some parts of the s/w are coverted by the GNU library license, version 2. See the individual source code files for more details.The bulk of the source code, however, is covered by my personal license:
Copyright 2002-2016, Lowell Boggs Jr.
This file or directory, containing source code for a computer program,
is Copyrighted by Lowell Boggs, Jr. 987 Regency Drive, Lewisville
TX (USA), 75067. You may use, copy, modify, and distribute this
source file without charge or obligation so long as you agree to
the following:
1. You must indemnify Lowell Boggs against any and all financial
obligations caused by its use, misuse, function, or malfunction.
Further, you acknowledge that there is no warranty of any kind,
whatsoever.
2. You agree not to attempt to patent any portion of this original
work -- though you may attempt to patent your own extensions to
it if you so choose.
3. You keep this copyright notice with the file and all copies
of the file and do not change it anyway except language translation.
You are responsible for enforcing your own compliance with these
conditions and may not use this source file if you cannot agree to the
above terms and conditions.
For the .diff command copyright see
en.wikibooks.org
Although, I have signicantly modified the C++ version found there.
Downloads
Right click on one of the following links and use the Save-Link-As feature of
your browser:
Note Use the brash command, builtins, to get a list of the available commands. Use the -h option for each builtin command for more details
Release Numbering Convention
Release numbers consist of 3 parts:- Major release number -- new operating system ports, etc.
- Minor release number -- new functionality
- Bug fixes.
Installation Instructions
To install brash, you will need to have a BIN directory, a place in your windows Path environment variable that can used to store user created .bat files, programs, and scripts. You can call it what you like, but you must put brash executables therein.Here's how to install brash:
- First, determine the name of a directory from your Path variable where you
which to put the executables. You may want to add a new directory to your
path.
Suggestion, create the following directory:
%USERPROFILE%/BIN
Then add this directory to your path variable. This variable can be modified using:
- Control Panel
- System
- Advanced
- Environment Variables
- Advanced
- System
- Control Panel
- If you modify your Path variable, remember to exit any console windows so as to refresh the Path they are using.
- Once you have determined the name of the directory to hold brash.exe, make sure that you can put .bat files in that directory, and that you can execute them from a console window without needing to specify the full pathname to run the .bat commands.
- Use a browser to store BRASH.EXE in your bin directory of choice.
- In your %USERPROFILE% directory, download the .brashrc file from the brash downloads page. You may add additional customizations to this file later.
- From a newly created Windows console command line prompt, you should be able to type brash and
see the following:
Welcome to brash 1.1.20 ...
From this point, you should be barely functional.Note -- you may have to create a new command window to get this to work if you have modified your windows Path in any way.
- Now, if desired, use the brash downloads page to store the following in your bin directory:
- mus.exe (can be used vaguely like SED on linux)
- utf8dec.exe (needed to make the sort command work right in most cases)
Compilation Instructions
brash.exe is available in a compiled form on this website, see above. It is only available, at this time, for Microsoft Windows 7, 8, and 10.The source code can be obtained from the links above, and can be compiled using the following approach:
Requirements:
- Windows 7 or higher
- Visual Studio / C++ version 2008 or higher
Compilation Instructions:
- Use your browser to download brash.zip to working directory where you can perform the build.
- Use unzip or WinZip to extract the archve. The top level directory will be named "cxx"
- cd cxx
- build.bat
- brash.exe
- mus.exe
- utf8dec.exe
The others are in cxx/bin.
Other Stuff
In addition to the brash executable, the following optional executables are available with the
same license restrictions:
- MUS.EXE: A partial SED clone.
- UTF8DEC.EXE: Downconverts utf8/utf16 text into simple ascii. This program improves the way the sort.exe program interacts with brash. Sort is not broken, nor is brash, but sorting a mix of unicode (such as file names produced by brash's .ls command) and normal text can cause problems. See .brashrc and look for the the sort function.
Compatibility
Brash is intentionally meant to be as compatible with GNU BASH as possible, but that is very tall order. Here are the know limitations with respect to bash:Limitations in version 1.1.33
- no support for GNU bash array variables (bourne doesn't have them either)
- "if", "while", and "untile" statements can only accept 1 command in the "condition" part of the statement. The body, of course can handle an unlimited number. Note: you can use a { ... } statement as the condition -- and it can have an unlimited number of members.
- missing or limited builtin commands:
- the keyboard handling lacks the depth of bash's configurability, but is fairly full featured. See "Console Window Edit Keys", below.
- the set command is very limited. Use the command "builtins" to get a list of what is supported.
- The following commands are not supported at all:
caller enable exec help local printf readarray readonly suspend times trap typeset umask ulimit wait bg fg
- the & operator works to execute commands in the background
- history (instead use fc -l range...)
- the jobs command is very limited
- mapfile ( but read -f can simulate )
- test ( though [ expression ] does work )