What is a shell? What's Bash?
A shell is a user interface, in the simplest form prompts the user and the user enters a program name.
It also can be instructed to set options to control execution and define macros and expand them.
Or, verbosely and more accuractly,
a Command Language Interpreter accepts text, uses a set of rules involving special characters to expand them to create expressions and executes commands.
A File containing commands can be treated as a command If the file name is the same as a command,
the file will be executedinstead of the system command.
bash is a version of a shell known as the "Borne Again SHell" ( based on Stephen Bourne's shell)
Builtin Commands
.
:
[
alias
bg
bind
break
builtin
cd
command
continue
declare
dirs
disown
echo
enable
eval
exec
exit
export
fc
fg
getopts
hash
help
history
jobs
kill
let
local
logout
mapfile
popd
printf
pushd
pwd
read
readarray
readonly
return
set
shift
shopt
source
suspend
test
times
trap
type
typeset
ulimit
umask
unalias
unset
wait
SPECIAL builtin commands
Cannot be invoked with nice.
. : break continue eval exec exit export readonly return set shift times trap unset history suspend
Reserved Words
!
case esac
[[ ]]
if then elif else fi
while
for [ conditional] ; do done
{ }
in
until
select
time
function
Installing Bash
>
> bash --help # as of 7/28/16
GNU bash, version 4.1.2(1)-release-(x86_64-redhat-linux-gnu)
Usage: bash [GNU long option] [option] …
bash [GNU long option] [option] script-file …
GNU long options:
--debug --debugger
--dump-po-strings --dump-strings
--help
--init-file --login --noediting --noprofile --norc --rcfile
--posix --restricted --protected --rpm-requires
--verbose
--version
Shell options:
Display using set |more # Functions will be displayed causing variables to scroll off screen.
-irsD or -c command or -O shopt_option (invocation only)
-abefhkmnptuvxBCHP or -o option
Type bash -c "help set" for more information about shell options.
Type bash -c help for more information about shell builtin commands.
(The following are rearranged, i.e. not exactly as displayed.)
> sh -c "help set"
set: set [--abefhkmnptuvxBCHP] [-o option] [arg …]
-o option-name
Set the variable corresponding to option-name:
variable | flag
allexport -a | Mark variables which are modified or created for export.
| braceexpand -B | the shell will perform brace expansion
| errexit -e Exit immediately if a command exits with a non-zero status.
| errtrace -E | ERR trap is inherited by shell functions.
| functrace -T | If set, the DEBUG trap is inherited by shell functions.
| hashall -h | Save path of commands in cache
| history | | enable command history
| histexpand -H Enable !nth style history substitution.
Default on when shell is interactive.
Retrieve the -nth command or
first argument(!^) or last argument(!$) or
all arguments (!*).
Format !n:w.
geek.nz has more info.
| ignoreeof | | the shell will not exit upon reading EOF. For example typeing ^d
| keyword -k All assignment arguments are placed in the environment for a command,
not just those that precede the command name.
| noclobber -C | Prevent redirection overwriting existing files.
| noglob -f Disable file name generation (globbing).
| monitor -m Job control is enabled.
| notify -b Immediately notify of job termination .
| nounset -u Treat unset variables as an error when substituting.
| onecmd -t Exit after reading and executing one command.
| physical -P Do not follow symbolic links when executing commands such as
cd which change the current directory.
| pipefail | The return value of a pipeline is the status of the
last command to exit with a non-zero status
or zero if no command exited with a non-zero status
| privilege -p On when the real and effective user ids do not match. Usually do to a sudo.
Disables processing of the $ENV file and importing of functions.
Turning this option off causes the effective uid and gid to be set to the real uid and gid.
| vi | use vi-style Line editing See readline
| emacs | use emacs-style line editing
| noexec -n Read commands but do not execute them.
| verbose -v display input lines as they are read.
| xtrace -x display commands and arguments as they are executed.
| posix | --1q | operate as 1003.2 standard
| interactive-comments | | allow comments in interactive commands
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
- Assign any remaining arguments to the positional parameters.
The -x and -v are turned off.
The flags can be used at invocation of the shell,
current set of flags may be found in $-. echo $- himBH (hashall, jobcontrol, Braceexpand, HistExpand )
The remaining n ARGs are positional parameters and are assigned, in order, to
$1, $2, … $n.
If no ARGs are given, all variables are output.
set BASH_COMPLETION_COMPAT_DIR=/etc/bash_completion.d empty ??
/etc/bashrc_Apple_Terminal :
Versions
Apple is currently supporting zsh
Mac OS has an older version of bash 3.2.57.(1) Iand will not include newer versions,
as well as several other commands (including: sed )
becuse they have a GPL V3 license that explicitly restricts commercial Unix vendors from including them.
Where there is an open source command you are allowed to install it (in an unprotected directory, safe from Mac OS upgrades).
Package managers that can add them include: Homebrew\,
MacPorts, Fink.
Various distrbutions:
cygwin 2.05b.0(8)-release
Midphase uses 4.2.46(2), goDaddy uses 4.4.20(1), ionos uses 5.1.4(1.
Changes of note:
⌘ :
> /bin/sh -c 'echo -e "Hello\n\tWorld"'
-e Hello
World
> /bin/bash -c 'echo -e "Hello\n\tWorld"'
Hello
World
Severly hacked by Dennis G German beginning 12/18/01 and continuing today.
-53