Softpanorama
(slightly skeptical) Open Source Software Educational Society

May the source be with you, but remember the KISS principle ;-)

Softpanorama Search

Bash as an Enterprise-level Shell

News

See also

Best Shell Books

Recommended Links Papers, ebooks  tutorials

Language

Reference

FAQs

Annotated List of Bash Enhancements

Control structures

NCD clones

Dot files

 Command Completion

readline

Pipes

Arithmetic expressions

Regular Expressions

Pretty Printing

String Operations Conditional operators Advanced navigation cdpath Arithmetic expressions Bash Variables Functions

Loops

Pipes in Loops
Shell Prompts Command history reuse IFS Pushd, popd and dirs VIM Tips Scripts collections Strange Files Deletion Shell Input and Output Redirection  Portability
Command completion Vi mode BASH Debugging Debugging bash Tips and Tricks Tips and Tricks Unix shell history Humor Etc

Bash is a standard shell on Linux and with version 3.2 available on all enterprise platform and installed on Solaris and AIX it make sense to make it standard shell on all enterprise-class Unixes. Only HP-UX does not include bash by-default.  Bash 3.2 and later has important enhancements that make it a better shell (see Annotated List of Bash Enhancements) although scripts should be generally limited to small to medium size as Perl represents much better scripting environment then bash. 

While bash has a humble start and much weaker designer then ksh93 and was at times extremely buggy, the gap narrowed in version 3.2 to the extent that better command line user friendliness of bash make it more attractive. Most ksh93 innovations are now present in some form in bash 3.2.  As bash is standard shell on Linux and is installed by default in Solaris it status as an enterprise shell is almost as strong as ksh93 (which is mostly present in old, weaker versions. Current bash has the best debugger and from this point of view represents the best shell. 

Bash 3.2 and later is the one of the most portable advanced shell around (ksh93 and zsh are still a strong competition; ksh93 is definitely more reliable for scripts and does not contain such design blunders as the last stage of the pipe belonging to subshell instead of the invoking shell ). 

Bash-related books dominates shell-related publications and as such the level of known-how for bash is higher then for other shells (see Best Shell Books). The advantage of bash for large enterprise environment is that it comes by default with linux, Solaris and AIX. Only HP-UX does not have installed by default. Also it is the best portable interactive shell , much closer to tcsh then any competition. 

Still you need some efforts to make the default shell. Unfortunately the default shell for Solaris is the "Bourne shell" or /usr/bin/sh

Bourne shell is a pretty weak outdated shell and attempt to base shell scripting portability on this outdated shell is a serious strategic error (bash probably should be used instead). It is still used as root shell in Solaris but that's due to Solaris legacy not because it gives anything but disadvantages; attempts to claim that this somehow increases the security of root due to the fact that it is static linked are weak and the argumentation is open for discussion. All-in-all usage of Bourne shell as a default root shell in Solaris might be considered to be a blunder: system administrators definitely need a better shell.

Usage of Borne shall as a default shell might slightly increase the chances of recovery in case /usr  partition is damaged, but this is a pretty serious case and usually means serious troubles with other partitions on the disk anyway (unless this is the case when in Solaris link /bin -> usr/bin is destroyed, but such cases are simple to fight by refereeing shell as /usr/bin/ksh in /etc/passwd). If this is a serious trouble than booting from a CD a mounting the damaged volume is always a good idea and in this case it does not matter what shell root is using; you can change it anyway.

Bash 3.2 is reasonably easy to build from source. Get and unpack in your home directory the archive. This will create a directory called bash-3.2 in your home directory. If you do not have the gunzip utility, you can obtain it in the same way you obtained bash or simply use gzip -d instead. The archive contains all of the source code needed to compile bash and a large amount of documentation and examples. the latter have their own value.

The bash archive contains a main directory and a set of files and subdirectories. Among the first files you should examine are:

CHANGES A comprehensive list of bug fixes and new features since the last version

COPYING The GNU Copyleft for bash

MANIFEST A list of all the files and directories in the archive

NEWS A list of new features since the last version

README A short introduction and instructions for compiling bash

doc Directory with information related to bash in various formats

examples Directory with examples of startup files, scripts, and functions

The doc directory contains a few articles that are worth reading. You can print man page for reference with command  nroff-man bash.1 | more  It is convenient to have a hardcopy so you can write notes all over it. Also valuable, FAQ is a Frequently Asked Questions document with answers, readline.3 is the manual entry for the readline facility, and article.ms is an article about the shell that appeared in Linux Journal, and was written by the current bash maintainer Chet Ramey.  An examples directory that is well worth exploring (after you've finished reading this book, of course). It includes sample code, scripts, functions, and startup files. See Examples shipped with bash 3.2 and newer

Some interesting features of bash include:

Due to this bash shell is gradually gaining grounds as the preferred interactive shell for Solaris and other enterprize class Unixes.

Older version of bash (2.x series) are obsolete and should not be used. The recommended version is 3.2 patch level 3 or above.  The latter is a recommended version as it's more compatible with ksh93. It supports many important enhancements introduced by ksh93.



Old News ;-)

[Apr 7, 2009] The GNU bash-4.0

Look more like bash 3.3 then bash 4.0. complete absence of interesting features and very poor understanding of the necessary path of shell development... (just look at  William Park's BASFDIFF and other patches and you understand this negative comment better).

    The current version of bash is bash-4.0. (GPG signature).

[Apr 6, 2009] Bash Process Substitution by Mitch Frazier

May 22, 2008 Linux Journal

In addition to the fairly common forms of input/output redirection the shell recognizes something called process substitution. Although not documented as a form of input/output redirection, its syntax and its effects are similar.

The syntax for process substitution is:

  <(list)
or
  >(list)
where each list is a command or a pipeline of commands. The effect of process substitution is to make each list act like a file. This is done by giving the list a name in the file system and then substituting that name in the command line. The list is given a name either by connecting the list to named pipe or by using a file in /dev/fd (if supported by the O/S). By doing this, the command simply sees a file name and is unaware that its reading from or writing to a command pipeline.

To substitute a command pipeline for an input file the syntax is:

  command ... <(list) ...
To substitute a command pipeline for an output file the syntax is:
  command ... >(list) ...

At first process substitution may seem rather pointless, for example you might imagine something simple like:

  uniq <(sort a)
to sort a file and then find the unique lines in it, but this is more commonly (and more conveniently) written as:
  sort a | uniq
The power of process substitution comes when you have multiple command pipelines that you want to connect to a single command.

For example, given the two files:

  # cat a
  e
  d
  c
  b
  a
  # cat b
  g
  f
  e
  d
  c
  b
To view the lines unique to each of these two unsorted files you might do something like this:
  # sort a | uniq >tmp1
  # sort b | uniq >tmp2
  # comm -3 tmp1 tmp2
  a
        f
        g
  # rm tmp1 tmp2
With process substitution we can do all this with one line:
  # comm -3 <(sort a | uniq) <(sort b | uniq)
  a
        f
        g

Depending on your shell settings you may get an error message similar to:

  syntax error near unexpected token `('
when you try to use process substitution, particularly if you try to use it within a shell script. Process substitution is not a POSIX compliant feature and so it may have to be enabled via:
  set +o posix
Be careful not to try something like:
  if [[ $use_process_substitution -eq 1 ]]; then
    set +o posix
    comm -3 <(sort a | uniq) <(sort b | uniq)
  fi
The command set +o posix enables not only the execution of process substitution but the recognition of the syntax. So, in the example above the shell tries to parse the process substitution syntax before the "set" command is executed and therefore still sees the process substitution syntax as illegal.

 

Of course, note that all shells may not support process substitution, these examples will work with bash.

 

[Apr 5, 2009] Using Named Pipes (FIFOs) with Bash

 

[Apr 3, 2008] Advanced Bash-Scripting Guide

[Apr 2, 2008] System Administration Toolkit: Get the most out of bash

Good paper !

Ease your system administration tasks by taking advantage of key parts of the Bourne-again shell (bash) and its features. Bash is a popular alternative to the original Bourne and Korn shells. It provides an impressive range of additional functionality that includes improvements to the scripting environment, extensive aliasing techniques, and improved methods for automatically completing different commands, files, and paths.

!!! [Apr 1, 2008] Linux tip: Bash parameters and parameter expansions  by Ian Shields

Definitely gifted author !

Do you sometimes wonder how to use parameters with your scripts, and how to pass them to internal functions or other scripts? Do you need to do simple validity tests on parameters or options, or perform simple extraction and replacement operations on the parameter strings? This tip helps you with parameter use and the various parameter expansions available in the bash shell.

3.1-0.09 October 27, 2007

[Mar 14, 2008] Advanced Bash Scripting Guide 5.2 (Stable) by M. Leo Cooper

About: The Advanced Bash Scripting Guide is both a reference and a tutorial on shell scripting. This comprehensive book (the equivalent of 880+ print pages) covers almost every aspect of shell scripting. It contains 340 profusely commented illustrative examples, a number of tables, and a cross-linked index/glossary. Not just a shell scripting tutorial, this book also provides an introduction to basic programming techniques, such as sorting and recursion. It is well suited for either individual study or classroom use. It covers Bash, up to and including version 3.2x.

Changes: Many bugfixes and stylistic cleanups were done. Four new example scripts were added. A new subsection on version 3.2 Bash update was added. Explanations of certain difficult concepts were clarified. This is an important update.

[Mar 8, 2008] BashStyle-NG: A Graphical Tool for styling the BASH version 5.2

BashStyle is a Graphical Tool for changing the Bash's behaviour and look'n'feel.

It has been part of *NixStyle-NG but is now splitt-off for easier maintainance.

It features some predefinied Themes, most of them are re-colorable. The first 4 Extra Options are only for the Separator Style (Theme).

Themes are 100% compatible with the Linux Console. When on it, colors will be deactivated automatically (to avoid ugly look'n'feel).

You can also enable colored manpages or get colored output from grep.

INSTALLATION:

run ./configure to check the dependencies

and run (sudo/su) make install to install BashStyle

then run bashstyle or go to Menu -> Accesoires -> BashStyle

Have Fun!

Requirements
This application requires GTK+ version 2.10.x. Other dependencies include:
Required: python 2.4+,pygtk 2.4+, pyglade 2.4+, bash 3.0+, sed, coreutils, gconf

Optional: psyco, /dev/random

BASH Frequently-Asked Questions (FAQ version 3.36) - comp.unix.questions Google Groups

Bash 3.2 is available
B1) What's new in version 3.2?

Bash-3.2 is the second maintenance release of the third major release of bash.  It contains the following significant new features (see the manual page for complete descriptions and the CHANGES and NEWS files in the bash-3.2 distribution).

  • Bash-3.2 now checks shell scripts for NUL characters rather than non-printing   characters when deciding whether or not a script is a binary file.
  • Quoting the string argument to the [[ command's  =~ (regexp) operator now   forces string matching, as with the other pattern-matching operators.

    A short feature history dating from Bash-2.0:

    Bash-3.1 contained the following new features:
     

  • Bash-3.1 may now be configured and built in a mode that enforces strict POSIX compliance.
  • The `+=' assignment operator, which appends to the value of a string or array variable, has been implemented.
  • It is now possible to ignore case when matching in contexts other than   filename generation using the new `nocasematch' shell option.

    Bash-3.0 contained the following new features:
     

  • Features to support the bash debugger have been implemented, and there   is a new `extdebug' option to turn the non-default options on
  • HISTCONTROL is now a colon-separated list of options and has been   extended with a new `erasedups' option that will result in only one   copy of a command being kept in the history list
  • Brace expansion has been extended with a new {x..y} form, producing   sequences of digits or characters
  • Timestamps are now kept with history entries, with an option to save   and restore them from the history file; there is a new HISTTIMEFORMAT   variable describing how to display the timestamps when listing history   entries
  • The `[[' command can now perform extended regular expression (egrep-like)   matching, with matched subexpressions placed in the BASH_REMATCH array   variable
  • A new `pipefail' option causes a pipeline to return a failure status if   any command in it fails
  • The `jobs', `kill', and `wait' builtins now accept job control notation   in their arguments even if job control is not enabled
  • The `gettext' package and libintl have been integrated, and the shell   messages may be translated into other languages

    Bash-2.05b introduced the following new features:

  • support for multibyte characters has been added to both bash and readline
  • the DEBUG trap is now run *before* simple commands, ((...)) commands,   [[...]] conditional commands, and for ((...)) loops
  • the shell now performs arithmetic in the largest integer size the machine   supports (intmax_t)
  • there is a new \D{...} prompt expansion; passes the `...' to strftime(3)   and inserts the result into the expanded prompt
  • there is a new `here-string' redirection operator:  <<< word
  • when displaying variables, function attributes and definitions are shown   separately, allowing them to be re-used as input (attempting to re-use   the old output would result in syntax errors).

    o `read' has a new `-u fd' option to read from a specified file descriptor

  • the bash debugger in examples/bashdb has been modified to work with the   new DEBUG trap semantics, the command set has been made more gdb-like,   and the changes to $LINENO make debugging functions work better
  • the expansion of $LINENO inside a shell function is only relative to the   function start if the shell is interactive -- if the shell is running a   script, $LINENO expands to the line number in the script.  This is as   POSIX-2001 requires

    Bash-2.05a introduced the following new features:

  • The `printf' builtin has undergone major work
  • There is a new read-only `shopt' option: login_shell, which is set by   login shells and unset otherwise 
  • New `\A' prompt string escape sequence; expanding to time in 24-hour   HH:MM format 
  • New `-A group/-g' option to complete and compgen; goes group name   completion 
  • New [+-]O invocation option to set and unset `shopt' options at startup 
  • ksh-like `ERR' trap 

    o `for' loops now allow empty word lists after the `in' reserved word 

  • new `hard' and `soft' arguments for the `ulimit' builtin 
  • Readline can be configured to place the user at the same point on the line   when retrieving commands from the history list 
  • Readline can be configured to skip `hidden' files (filenames with a leading   `.' on Unix) when performing completion 

    Bash-2.05 introduced the following new features: 

  • This version has once again reverted to using locales and strcoll(3) when   processing pattern matching bracket expressions, as POSIX requires.
  • Added a new `--init-file' invocation argument as a synonym for `--rcfile',   per the new GNU coding standards.
  • The /dev/tcp and /dev/udp redirections now accept service names as well as   port numbers.<li>`complete' and `compgen' now take a `-o value' option, which controls some    of the aspects of that compspec.  Valid values are: 

            default - perform bash default completion if programmable                   completion produces no matches         dirnames - perform directory name completion if programmable                    completion produces no matches         filenames - tell readline that the compspec produces filenames,                     so it can do things like append slashes to                     directory names and suppress trailing spaces

  • A new loadable builtin, realpath, which canonicalizes and expands symlinks   in pathname arguments.
  • When `set' is called without options, it prints function defintions in a   way that allows them to be reused as input.  This affects `declare' and   `declare -p' as well.  This only happens when the shell is not in POSIX    mode, since POSIX.2 forbids this behavior. 

    Bash-2.04 introduced the following new features:  

  • Programmable word completion with the new `complete' and `compgen' builtins;   examples are provided in examples/complete/complete-examples
  • `history' has a new `-d' option to delete a history entry
  • `bind' has a new `-x' option to bind key sequences to shell commands
  • The prompt expansion code has new `\j' and `\l' escape sequences
  • The `no_empty_cmd_completion' shell option, if enabled, inhibits   command completion when TAB is typed on an empty line
  • `help' has a new `-s' option to print a usage synopsis
  • New arithmetic operators: var++, var--, ++var, --var, expr1,expr2 (comma)
  • New ksh93-style arithmetic for command:         for ((expr1 ; expr2; expr3 )); do list; done<li>`read' has new options: `-t', `-n', `-d', `-s'
  • The redirection code handles several filenames specially:  /dev/fd/N,   /dev/stdin, /dev/stdout, /dev/stderr
  • The redirection code now recognizes /dev/tcp/HOST/PORT and   /dev/udp/HOST/PORT and tries to open a TCP or UDP socket, respectively,   to the specified port on the specified host
  • The ${!prefix*} expansion has been implemented
  • A new FUNCNAME variable, which expands to the name of a currently-executing   function
  • The GROUPS variable is no longer readonly
  • A new shopt `xpg_echo' variable, to control the behavior of echo with   respect to backslash-escape sequences at runtime
  • The NON_INTERACTIVE_LOGIN_SHELLS #define has returned 

    The version of Readline released with Bash-2.04, Readline-4.1, had several new features as well:

  • Parentheses matching is always compiled into readline, and controllable   with the new `blink-matching-paren' variable
  • The history-search-forward and history-search-backward functions now leave   point at the end of the line when the search string is empty, like   reverse-search-history, and forward-search-history
  • A new function for applications:  rl_on_new_line_with_prompt()
  • New variables for applications:  rl_already_prompted, and rl_gnu_readline_p 

    Bash-2.03 had very few new features, in keeping with the convention that odd-numbered releases provide mainly bug fixes.  A number of new features were added to Readline, mostly at the request of the Cygnus folks. 

    A new shopt option, `restricted_shell', so that startup files can test         whether or not the shell was started in restricted mode Filename generation is now performed on the words between ( and ) in         compound array assignments (this is really a bug fix) OLDPWD is now auto-exported, as POSIX.2 requires ENV and BASH_ENV are read-only variables in a restricted shell Bash may now be linked against an already-installed Readline library,         as long as the Readline library is version 4 or newer All shells begun with the `--login' option will source the login shell         startup files, even if the shell is not interactive 

    There were lots of changes to the version of the Readline library released along with Bash-2.03.  For a complete list of the changes, read the file CHANGES in the Bash-2.03 distribution. 

    Bash-2.02 contained the following new features: 

    a new version of malloc (based on the old GNU malloc code in previous         bash versions) that is more page-oriented, more conservative         with memory usage, does not `orphan' large blocks when they         are freed, is usable on 64-bit machines, and has allocation         checking turned on unconditionally POSIX.2-style globbing character classes ([:alpha:], [:alnum:], etc.) POSIX.2-style globbing equivalence classes POSIX.2-style globbing collating symbols the ksh [[...]] extended conditional command the ksh egrep-style extended pattern matching operators a new `printf' builtin the ksh-like $(<filename) command substitution, which is equivalent to         $(cat filename) new tilde prefixes that expand to directories from the directory stack new `**' arithmetic operator to do exponentiation case-insensitive globbing (filename expansion) menu completion a la tcsh `magic-space' history expansion function like tcsh the readline inputrc `language' has a new file inclusion directive ($include) 

    Bash-2.01 contained only a few new features:  

    new `GROUPS' builtin array variable containing the user's group list new bindable readline commands: history-and-alias-expand-line and         alias-expand-line 

    Bash-2.0 contained extensive changes and new features from bash-1.14.7. Here's a short list: 

    new `time' reserved word to time pipelines, shell builtins, and         shell functions one-dimensional arrays with a new compound assignment statement,         appropriate expansion constructs and modifications to some         of the builtins (read, declare, etc.) to use them new quoting syntaxes for ANSI-C string expansion and locale-specific         string translation new expansions to do substring extraction, pattern replacement, and         indirect variable expansion new builtins: `disown' and `shopt' new variables: HISTIGNORE, SHELLOPTS, PIPESTATUS, DIRSTACK, GLOBIGNORE,                MACHTYPE, BASH_VERSINFO special handling of many unused or redundant variables removed         (e.g., $notify, $glob_dot_filenames, $no_exit_on_failed_exec) dynamic loading of new builtin commands; many loadable examples provided new prompt expansions: \a, \e, \n, \H, \T, \@, \v, \V history and aliases available in shell scripts new readline variables: enable-keypad, mark-directories, input-meta,         visible-stats, disable-completion, comment-begin new readline commands to manipulate the mark and operate on the region new readline emacs mode commands and bindings for ksh-88 compatibility updated and extended builtins new DEBUG trap expanded (and now documented) restricted shell mode 

    implementation stuff:   autoconf-based configuration nearly all of the bugs reported since version 1.14 have been fixed most builtins converted to use builtin `getopt' for consistency most builtins use -p option to display output in a reusable form         (for consistency) grammar tighter and smaller (66 reduce-reduce conflicts gone) lots of code now smaller and faster test suite greatly expanded

    B2) Are there any user-visible incompatibilities between bash-3.2 and     bash-2.05b?

    There are a few incompatibilities between version 2.05b and version 3.2. They are detailed in the file COMPAT in the bash distribution.  That file is not meant to be all-encompassing; send mail to bash-maintain...@gnu.org if if you find something that's not mentioned there.

  • [Dec 11, 2007] Working more productively with bash 2.x-3.x by Ian Macdonald

    $HISTIGNORE
    Set this to to avoid having consecutive duplicate commands and other not so useful information appended to the history list. This will cut down on hitting the up arrow endlessly to get to the command before the one you just entered twenty times. It will also avoid filling a large percentage of your history list with useless commands.

    Try this:

    $ export HISTIGNORE="&:ls:ls *:mutt:[bf]g:exit"

    Using this, consecutive duplicate commands, invocations of ls, executions of the mutt mail client without any additional parameters, plus calls to the bg, fg and exit built-ins will not be appended to the history list.

    readline Tips and Tricks

    The readline library is used by bash and many other programs to read a line from the terminal, allowing the user to edit the line with standard Emacs editing keys.

    Advanced Bash-Scripting HOWTO by Mendel Cooper

    This is an older and more compact version of his Advanced Bash-Scripting Guide

    ! [Jun 10, 2007] Linux tip: Bash parameters and parameter expansions  by Ian Shields

    Definitely gifted author !

    Do you sometimes wonder how to use parameters with your scripts, and how to pass them to internal functions or other scripts? Do you need to do simple validity tests on parameters or options, or perform simple extraction and replacement operations on the parameter strings? This tip helps you with parameter use and the various parameter expansions available in the bash shell.

    William Park's BASFDIFF

    BashDiff is a patch against Bash-3.0 shell, incorporating many useful features from Awk, Python, Zsh, Ksh, and others. It implements in the main core

    and as dynamically loadable builtins

    Release focus: Major feature enhancements

    Changes:
    This release adds a shell interface to GTK+2 widget library, for building a simple GUI dialog or layout. It uses XML syntax for layout, and returns the user's selection in a shell variable or runs a shell command as callback. The name of the 'xml' builtin has been changed to 'expat'. The <<+ here document now removes space and tab indents.

    Author:
    William Park
    [contact developer]

    [Mar 21, 2005] freshmeat.net Project details for Advanced Bash Scripting Guide

    More bugfixes were made, some of them fairly important. New material was added, including a few rather useful example scripts. This is more than a "minor" update, but not quite a major one.

    The Advanced Bash Scripting Guide is both a reference and a tutorial on shell scripting. This comprehensive book (the equivalent of about 646 print pages) covers almost every aspect of shell scripting. It contains over 300 profusely commented illustrative examples, and a number of tables. Not just a shell scripting tutorial, this book also provides an introduction to basic programming techniques, such as sorting and recursion. It is well suited for either individual study or classroom use.

    GeSHi - Generic Syntax Highlighter Home

    Can be used for shell scripts and bash initrc

    Bash Config Files

    How Bash executes startup files.

    For Login shells (subject to the -noprofile option):

    On logging in:
    If `/etc/profile' exists, then source it.

    If `~/.bash_profile' exists, then source it,
    else if `~/.bash_login' exists, then source it,
    else if `~/.profile' exists, then source it.

    On logging out:
    If `~/.bash_logout' exists, source it.

    For non-login interactive shells (subject to the -norc and -rcfile options):
    On starting up:
    If `~/.bashrc' exists, then source it.

    For non-interactive shells:
    On starting up:
    If the environment variable `ENV' is non-null, expand the variable and source the file named by the value. If Bash is not started in Posix mode, it looks for `BASH_ENV' before `ENV'.

    So, typically, your `~/.bash_profile' contains the line
    `if [ -f `~/.bashrc' ]; then source `~/.bashrc'; fi' after (or before) any login specific initializations.

    If Bash is invoked as `sh', it tries to mimic the behavior of `sh' as closely as possible. For a login shell, it attempts to source only `/etc/profile' and `~/.profile', in that order. The `-noprofile' option may still be used to disable this behavior. A shell invoked as `sh' does not attempt to source any other startup files.

    When Bash is started in POSIX mode, as with the `-posix' command line option, it follows the Posix 1003.2 standard for startup files. In this mode, the `ENV' variable is expanded and that file sourced; no other startup files are read.

    My .bashrc can be found here.

    My .bash_profile can be found here.

    .inputrc (readline)

    Although the Readline library comes with a set of Emacs-like key bindings installed by default, it is possible that you would like to use a different set of keybindings. You can customize programs that use Readline by putting commands in an "init" file in your home directory. The name of this file is taken from the value of the shell variable `INPUTRC'. If that variable is unset, the default is `~/.inputrc'.

    When a program which uses the Readline library starts up, the init file is read, and the key bindings are set.

    In addition, the `C-x C-r' command re-reads this init file, thus incorporating any changes that you might have made to it.

    Conditional Init Constructs within readline

    Readline implements a facility similar in spirit to the conditional compilation features of the C preprocessor which allows key bindings and variable settings to be performed as the result of tests. There are three parser directives used.

    `$if' The `$if' construct allows bindings to be made based on the editing mode, the terminal being used, or the application using Readline. The text of the test extends to the end of the line; no characters are required to isolate it.
    `mode' The `mode=' form of the `$if' directive is used to test whether Readline is in `emacs' or `vi' mode. This may be used in conjunction with the `set keymap' command, for instance, to set bindings in the `emacs-standard' and `emacs-ctlx' keymaps only if Readline is starting out in `emacs' mode.
    `term' The `term=' form may be used to include terminal-specific key bindings, perhaps to bind the key sequences output by the terminal's function keys. The word on the right side of the `=' is tested against the full name of the terminal and the portion of the terminal name before the first `-'. This allows SUN to match both SUN and SUN-CMD, for instance.
    `application' The APPLICATION construct is used to include application-specific settings. Each program using the Readline library sets the APPLICATION NAME, and you can test for it. This could be used to bind key sequences to
    functions useful for a specific program.
    `$endif' This command terminates an `$if' command.
    `$else' Commands in this branch of the `$if' directive are executed if the test fails.

    The following command adds a key sequence that quotes the current or previous word in Bash:
    $if bash
    # Quote the current or previous word
    "\C-xq": "\eb\"\ef\""
    $endif
     

    My .inputrc file is here

    Last update by Hermann Heimhardt on October 7, 2001

    Patch against 2.05 Bash to make cd take 2 Args like ksh

    From: Eli
    Subject: Patch against 2.05 Bash to make cd take 2 Args like ksh
    Date: Fri, 22 Jun 2001 14:38:17 -0400

    *** origBash/bash-2.05/builtins/cd.def  Wed Oct 11 11:10:20 2000
    --- bash-2.05/builtins/cd.def   Fri Jun 22 14:31:08 2001
    ***************
    *** 187,192 ****
    --- 187,225 ----
            }
            lflag = interactive ? LCD_PRINTPATH : 0;
          }
    +   else if (list->next)
    +     {
    +       /* if next then 2 args, so replace in PWD arg1 with arg2 */
    +       int beginLen, oldLen, newLen, endLen;
    +       char *replace;
    +       path = get_string_value ("PWD");
    +       if (( replace = strstr( path,list->word->word)) == (char *)0 )
    +         {
    +          builtin_error ("Couldn't find arg1 in PWD");
    +          return (EXECUTION_FAILURE);
    +       }
    +       beginLen = replace - path;
    +       oldLen = strlen( list->word->word);
    +       newLen = strlen( list->next->word->word);
    +       endLen = strlen( path + beginLen + oldLen ) + 1 ;
    + 
    +       dirname = xmalloc( beginLen + newLen + endLen );
    +       /* copy path up to begining of string to replace */
    +       memcpy( dirname, path, beginLen );
    + 
    +       /* then add new replacement string */
    +       memcpy( dirname + beginLen, list->next->word->word, newLen );
    + 
    +       /* finally add end of path after replacement */
    +       memcpy( dirname + beginLen + newLen, path + beginLen+
    oldLen,endLen);
    + 
    +       printf("%s\n",dirname);
    +       if (change_to_directory (dirname, no_symlinks))
    +       {
    +          free(dirname);
    +          return (bindpwd (posixly_correct || no_symlinks));
    +       }
    +     }
        else if (absolute_pathname (list->word->word))
          dirname = list->word->word;
        else if (cdpath = get_string_value ("CDPATH"))

    [Nov 26, 2004] kcd Home Page

    kcd is a directory change utility under Linux or any other Unix clones. It helps you navigate the directory tree. You can supply the desired directory name in the command line and let kcd find it for you or let kcd show the entire directory tree and use arrow keys to go to the destination directory.

    Here is a list some features available in kcd:

    kcd is available as stable version and development version. You can distinguish development version from stable version by looking at its version number. Beginning from version 5.0.0, any version x.y.z where y is even is a stable version. Those where y is odd is a development version. Features currently present in the development version will eventually appear in the future stable version 8.0.0.

    kcd is distributed in source form under General Public License (GPL).

    The program and this web page is maintained by Kriang Lerdsuwanakij

    [Nov 15, 2004] Erwin Waterlander, WCD Wherever Change Directory

    Another Norton Change Directory (NCD) clone with more features.

    Wcd is a program to change directory fast. It saves time typing at the keyboard. One needs to type only a part of a directory name and wcd will jump to it. By default wcd searches for a directory with a name that begins with what has been typed, but the use of wildcards is also fully supported.
    For instance:

    wcd Desk

    will change to directory /home/waterlan/Desktop

    But also

    wcd *top
    

    will do that.

    Wcd is free to use and you can get the source code too.

    Some features of wcd:

  • Full screen interactive directory browser with speed search.
  • Present the user a list in case of multiple matches.
  • Wildcards *, ? and [SET] supported.
  • Directory stack, push pop.
  • Subdir definition possible. E.g. wcd subdira/subdirb
  • Long directory names support in Win95/98/NT DOS-box
  • Windows LAN UNC paths supported.
  • Change drive and directory at once.
  • Alias directories.
  • Ban directories.
  • 'cd' behaviour
  • Free portable source-code, no special libraries required
  • Multi platform:
    DOS 16 bit, DOS 32 bit, DOS bash, Windows 3.1/95/NT DOS-box, Cygwin bash, Unix ksh, csh, bash and zsh.
  • Wcd has been tested on: FreeDOS, MS-DOS 6.2, Win95, Win98, Windows NT 4.0, Linux, FreeBSD, HP-UX, SunOS, Solaris, SGI IRIX. Wcd works on any PC and can be ported to any Unix system.

    WCD is free software, distributed under GNU General Public License.

    [Nov 11, 2004]  Freeware List for SPARC

    [Nov 5, 2004] Bash 3.0 now has degugger

    This is a terse description of the new features added to bash-3.0 since the release of bash-2.05b.  As always, the manual page (doc/bash.1) is the place to look for complete descriptions.

    cc. The [[ ... ]] command has a new binary `=~' operator that performs  extended regular expression (egrep-like) matching.

    l.  New invocation option:  --debugger.  Enables debugging and turns on new  `extdebug' shell option.

    f.  HISTCONTROL may now include the `erasedups' option, which causes all lines matching a line being added to be removed from the history list.

    j.  for, case, select, arithmetic commands now keep line number information for the debugger.

    p.  `declare -F' now prints out extra line number and source file information if the `extdebug' option is set.

    r.  New `caller' builtin to provide a call stack for the bash debugger.

    t.  `for', `select', and `case' command heads are printed when `set -x' is enabled.

    u.  There is a new {x..y} brace expansion, which is shorthand for {x.x+1, x+2,...,y}.  x and y can be integers or single characters; the sequence  may ascend or descend; the increment is always 1.

    v.  New ksh93-like ${!array[@]} expansion, expands to all the keys (indices)  of array.

    z.  New `-o plusdirs' option to complete and compgen; if set, causes directory  name completion to be performed and the results added to the rest of the possible completions.

    ee. Subexpressions matched by the =~ operator are placed in the new BASH_REMATCH array variable.

    gg. New `set -o pipefail' option that causes a pipeline to return a failure status if any of the processes in the pipeline fail, not just the last   one.

    kk. The `\W' prompt expansion now abbreviates $HOME as `~', like `\w'.

    ll. The error message printed when bash cannot open a shell script supplied as argument 1 now includes the name of the shell, to better identify the error as coming from bash.

    2.  New Features in Readline

    a.  History expansion has a new `a' modifier equivalent to the `g' modifier for compatibility with the BSD csh.

    b.  History expansion has a new `G' modifier equivalent to the BSD csh `g'
        modifier, which performs a substitution once per word.

    c.  All non-incremental search operations may now undo the operation of replacing the current line with the history line.

    d.  The text inserted by an `a' command in vi mode can be reinserted with  `.'.

    e.  New bindable variable, `show-all-if-unmodified'.  If set, the readline completer will list possible completions immediately if there is more  than one completion and partial completion cannot be performed.

    g.  History list entries now contain timestamp information; the history file functions know how to read and write timestamp information associated with each entry.

    n.  When listing completions, directories have a `/' appended if the  `mark-directories' option has been enabled.

    Not much changed (Score:5, Insightful)
    by opk (149665) on Thursday July 29, @10:28AM (#9831965)
    Doesn't seem to be much changed given the version number increase. [[ =~ ]] can match regexes and it can do zsh style {1..3} expansions. Improved multibyte support too. There were bigger changes in some of the 2.0x updates.
    • Re:First "zsh rules" post! by Anonymous Coward (Score:3) Thursday July 29, @10:30AM
        Re:First "zsh rules" post! (Score:5, Informative)
        by opk (149665) on Thursday July 29, @10:46AM (#9832230)
        Globs are more powerful: **/*.c will recursively search for .c files: much quicker to type than find.
        You can match file types: e.g. *(@) will get you symlinks. *(U) gets files owned by you.

        Syntax for alternation is a lot easier. No @(this|that) or !(*.f). Instead, it is (this|that) and ^*.f

        Next point is completion. It includes a vast range of definitions so completion works well for lots of commands. The completion system handles completing parts of words so it better handles user@host completion. You get descriptions with completion match listings. Completion also has a really powerful context sensitive configuration system so you can make it work the way you like.

        It has modules. For running a simple shell script it will actually use less space than bash because it doesn't need to load the line editor and other interactive related code into memory.

        There is much much more. It takes a while to learn everything but if you just enable the completion functions (autoload -U compinit; compinit) you'll find it better than bash or tcsh from day 1.

    Re:Just wondering... (Score:5, Informative)
    by opk (149665) on Thursday July 29, @11:05AM (#9832448)
    Zsh is still the best.

    Bash developers have different priorities.
    Bash became the default primarily because it is GNU.
    Zsh has some ugly but powerful features like nested expansions. The two areas where bash is better than zsh is multibyte support and POSIX compliance. Much of that was contributed by IBM and Apple respectively. But if you use the shell a lot, you'll find zsh does a lot of things better. The completion is amazing. And when it isn't emulating sh/posix, it fixes some of the broken design decisions (like word splitting of variables) which saves you from doing stupid things.

    The FSF actually does development in a very closed manner when it can (the gcc egcs split was partly because of this). Bash is a good example of this. That perhaps a good thing because it is probably good that bash doesn't get some of zsh's nasty (but powerful) features. And if zsh didn't exist, bash might have been forked by now. If you care about your shell, you'll find much more of a community on the zsh lists than the spam filled bug-bash list. You can't even get at alpha releases of bash without being one of the chosen few.

    Can arrow key history be like Matlab's? (Score:3, Interesting)
    by dara (119068) on Thursday July 29, @10:54AM (#9832323)
    I read the announcement and it mentions "History traversal with arrow keys", but what I would really like doesn't seem to be mentioned (but perhaps it is possible with bash-2.05, I'm not much of a shell expert). In Matlab, the up-arrow key searches the history for commands that match all the characters on the line. No characters and it acts like a normal bash arrow, if "figure, plot" is at the beginning of the line, it will quickly scroll through all plotting commands that have been entered at the shell.

    Any idea if this is possible?

    Dara Parsavand

     
    TThe Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
    Re:Can arrow key history be like Matlab's? (Score:2)
    by Atzanteol (99067) on Thursday July 29, @11:10AM (#9832500)
    (http://www.edespot.com/~amackenz/)
    Try 'ctrl+r'. Not *exactly* what you're looking for, but it lets you search through your history.

    i.e. on an empty line hit ctrl+r, then start typing.

    [ Parent ]
    Re:Can arrow key history be like Matlab's? (Score:3, Informative)
    by Anonymous Coward on Thursday July 29, @12:38PM (#9833770)
    cat >> ~/.inputrc
    "\e[A": history-search-backward
    "\e[B": history-search-forward
    ^D
    Re:Can arrow key history be like Matlab's? (Score:1, Informative)
    by Anonymous Coward on Thursday July 29, @01:17PM (#9834391)
    Here you are,put this in .inputrc:

    "\e[6~": history-search-forward
    "\e[5~": history-search-backward

    and use page-up pagge-down to search

    I can live whithout it since 4dos

    Autocompletion like W2K? (Score:2)
    by tstoneman (589372) on Thursday July 29, @01:12PM (#9834316)
    I like bash, but the one thing that it doesn't support (out-of-the-box anyway) is auto-completion a la W2K. In NT, when you hit tab, you can cycle through all the words that can complete the letters you typed... on bash, it shows you a list.

    Is there a way to make bash behave more like W2K in this sense?

    bash completion getting better (Score:3, Informative)
    by AT (21754) on Thursday July 29, @11:08AM (#9832478)
    The completion ability of bash has been steadily improving. There is a nice script here [caliban.org] that sets up a lot of good completion rules for bash.
    Re:First "zsh rules" post! (Score:2)
    by Just Some Guy (3352) <`kirk+slashdot' `at' `strauser.com'> on Thursday July 29, @05:30PM (#9837797)
    (http://subwiki.honeypot.net/ | Last Journal: Monday September 27, @09:09AM)
    That's just... I mean... Wow. Really. I just patched my .zshenv with

    - export SSH_AUTH_SOCK=$(find 2>/dev/null /tmp -maxdepth 2 -type s -user $USER -regex '/tmp/ssh-.*/agent\..*')
    + export SSH_AUTH_SOCK=$(echo /tmp/ssh-*/agent.*(=UN))

    That's sweet. Thanks for the pointer! The more I learn about zsh, the more I love it.

    Re:First "zsh rules" post! (Score:1)
    by sorbits (516598) on Saturday July 31, @01:09PM (#9853305)
    (http://macromates.com/)
    I will certainly give it a try then!

    Until now I have sticked with tcsh for one single reason: history substition [go.dlr.de]!

    Basically it lets me insert text from my history (including the current line) using few symbols (e.g. !$ is the last argument of the previous line) -- it's extremely powerful, e.g. it allows to search in the history and can do substitutions in results, or head/tail for paths etc.

    I use it a lot to keep down the number of characters I need to type, and I have even assigned hotkeys to some of the substitutions I use the most.

    This is really the make-or-break feature for wether or not I want to use a shell, so I really hope zsh has something similar!?!

    Re:First "zsh rules" post! (Score:5, Informative)
    by Just Some Guy (3352) <`kirk+slashdot' `at' `strauser.com'> on Thursday July 29, @10:50AM (#9832279)
    (http://subwiki.honeypot.net/ | Last Journal: Monday September 27, @09:09AM)
    Bigs ones for me:
    • A sane auto-completion system. That is, "cvs <tab>" gives a list of all of the commands that cvs understands. "cvs -<tab>" (same as above but tabbing after typing "-") gives a list of all of the options that cvs understands. These are good things. Now, in fairness, bash also has a command completion library. Unfortunately, it's implemented as a huge set of Bash functions. In zsh, "set|wc" returns 179 lines. In bash, "set|wc" returns 3,961 lines. The net effect is that zsh's system is noticeably faster and less polluting to the local environment.
    • Modules. Wrappers for TCP connections, a built-in cron thingy, and PCRE are all loadable modules to do tricky things easily.
    • Lots of pre-defined things. Load the "colors" and "zsh/terminfo" modules and you get defined associative arrays like $fg, which emits terminal-appropriate escape codes to set the foreground color of printed text. The command "echo ${fg[red]}red text${fg[default]}normal text" prints "red text" in red, and "normal text" in your default color.

    Bash is a good shell, and I have nothing bad to say about it. However, zsh seems to have been designed from the ground up by power users and for power users. I absolutely love it and everyone that I've given a example config file to (to get them running with little hassle) has permanently switched.

    Re:First "zsh rules" post! (Score:5, Informative)
    by Just Some Guy (3352) <`kirk+slashdot' `at' `strauser.com'> on Thursday July 29, @11:21AM (#9832638)
    (http://subwiki.honeypot.net/ | Last Journal: Monday September 27, @09:09AM)
    As the maintainer of FreeBSD's bash-completion [freshports.org] port, I'm reasonably familiar with it. Yes, it's approximately as powerful as zsh's completion module. Still, have you ever looked at it? It's a giant set of defined functions and glue. Seriously, get to a bash prompt and type "set" to see all of the things that've been stuffed into your shell's namespace. Now, try that with zsh and be pleasantly surprised.

    As I said in another post, a big side effect is that zsh's completions seem to be much faster than bash's. That alone is worth the price of admission for me.

    Re:Dear Apple haters... (Score:5, Informative)
    by Jahf (21968) on Thursday July 29, @10:58AM (#9832361)
    (Last Journal: Thursday August 05, @03:55PM)
    Believe it or not, -most- of the large companies that use GPL'ed tools give back to the community.

    Apple has done numerous fixes, not just on BASH.

    Sun (disclaimer: for whom I work) has done -tons- of work on GNOME, Mozilla and don't forget Open Office (just to name a few).

    IBM works on many projects and gives back ... plus contributing all new things like JFS.

    All the distro makers like Red Hat, Novell, etc give back tons.

    Each of those companies pay engineers to fix pieces not done in Open Source projects as well as to extend them for their customers. The patches are covered under GPL just like the main code, and these companies know it and yet knowingly dedicate serious money and hours to these projects. And then they satisfy the GPL by putting them out on source CDs or submitting them back to the main projects.

    The big problem for getting submitted code accepted is that these companies are usually fixing and developing on a codebase that is aging. For instance, Sun did numerous I18N fixes for GNOME 2.6, but by the time they were ready the main GNOME organization had moved on to 2.8. That means there is a disconnect between the two and the changes have to be ported forward before they will hit the main code branch. The same problem can happen with kernel patches and just about any other codebase that changes versions so quickly.

    Sorry, you were doing the good thing and pointing out Apple's contributions. But so many people think these companies violate the GPL (in spirit if not in law) when they are very large contributors to open source. Sure, some do, and the community usually find out about it and shame them into minimal compliance (Linksys and Sveasoft come to mind after my delving into alternate WRT54G firmwares last night), but generally speaking the big companies have been a good part of the community.

    Re:On the list of changes: (Score:5, Informative)
    by Prowl (554277) on Thursday July 29, @11:12AM (#9832526)
    GNU or Unix would seem to be the most appropriate

    bash has been around since 1989 (according to copywrite on man page). Linux 1.0 came around 5 years later.

    The editors should know better, unless they're intentionally trying to piss off RMS

    Looks great, but prefer Ash for scripts (Score:3, Interesting)
    by Etcetera (14711) * <<cleaver> <at> <rohan.sdsu.edu>> on Thursday July 29, @10:41AM (#9832171)
    (http://www-rohan.sdsu.edu/~cleaver/software/)

    Looks like a nice Unicode-savvy release that should help with dealing with international languages at the command line. And yay to Apple for giving back (again). When will people finally accept that Apple is indeed helping out the OSS community through GCC, bash, and other tools...?

    Kind of off-topic, but for speed purposes in scripts that have to run fast, I find nothing better or more convenient than Ash, especially on systems where /bin/sh is a symlink to /bin/bash.

    Does anyone know any history on this shell? Is it a clone of the original bourne shell or of bash? I can't seem to find anything useful on Google ...

    Re:Looks great, but prefer Ash for scripts (Score:2)
    by mihalis (28146) on Thursday July 29, @10:52AM (#9832301)
    (http://www.mihalis.net)
    As I understand it, ash was written by Kenneth Almquist. I used to see his name on some of the Ada related mailing lists and newsgroups.
    Re:Looks great, but prefer Ash for scripts (Score:2, Informative)
    by Stephen Williams (23750) on Thursday July 29, @11:46AM (#9832931)
    (http://nysa.cx/journal/ | Last Journal: Thursday December 05, @05:02AM)
    Ash (or dash, as it's called nowadays) is a Linux port of NetBSD's /bin/sh. It's a POSIX shell with separate lineage from bash.

    http://gondor.apana.org.au/~herbert/dash/

    It's /bin/sh on my system too. Faster and smaller than bash; watch those configure scripts fly!

    -Stephen

    Some people don't agree. (Score:2)
    by emil (695) on Thursday July 29, @12:48PM (#9833940)
    (http://rhadmin.org/)
    Ash appears to consume large amounts of memory, and some people in BSD circles have serious objections to it.

    See the discussion here [undeadly.org] (scroll down a bit into the postings). I don't have an opinion on the issue one way or another.

    And can I set up bash so I can, for instance, move from rc2.d to rc3.d by typing

    $ cd 2 3

    [May 16, 2004] freshmeat.net Project details for BASH Debugger

    BASH Debugger provides a patched BASH that enables better debugging support as well as improved error reporting. It also contains the most comprehensive source code debugger for BASH that has been written. It can be used as a springboard for other experimental features (such as a timestamped history file), since dnter"

    Recommended Links


    In case of broken links please try to use Google search. If you find the page please notify us about new location
    Google     

    Please visit  Heiner Steven SHELLdorado  the best shell scripting site on the Internet

    Advanced Bash-Scripting Guide

    Reference

    Examples shipped with bash 3.2 and newer
    Path Description X-ref
    ./bashdb Deprecated sample implementation of a bash debugger.  
    ./complete Shell completion code.  
    ./functions Example functions.  
    ./functions/array-stuff Various array functions (ashift, array_sort, reverse).  
    ./functions/array-to-string Convert an array to a string.  
    ./functions/autoload An almost ksh-compatible 'autoload' (no lazy load). ksh
    ./functions/autoload.v2 An almost ksh-compatible 'autoload' (no lazy load). ksh
    ./functions/autoload.v3 A more ksh-compatible 'autoload' (with lazy load). ksh
    ./functions/basename A replacement for basename(1). basename
    ./functions/basename2 Fast basename(1) and dirname(1) functions for bash/sh. basename, dirname
    ./functions/coproc.bash Start, control, and end co-processes.  
    ./functions/coshell.bash Control shell co-processes (see coprocess.bash).  
    ./functions/coshell.README README for coshell and coproc.  
    ./functions/csh-compat A C-shell compatibility package. csh
    ./functions/dirfuncs Directory manipulation functions from the book The Korn Shell.  
    ./functions/dirname A replacement for dirname(1). dirname
    ./functions/emptydir Find out if a directory is empty.  
    ./functions/exitstat Display the exit status of processes.  
    ./functions/external Like command, but forces the use of external command.  
    ./functions/fact Recursive factorial function.  
    ./functions/fstty Front-end to sync TERM changes to both stty(1) and readline 'bind'. stty.bash
    ./functions/func Print out definitions for functions named by arguments.  
    ./functions/gethtml Get a web page from a remote server (wget(1) in bash).  
    ./functions/getoptx.bash getopt function that parses long-named options.  
    ./functions/inetaddr Internet address conversion (inet2hex and hex2inet).  
    ./functions/inpath Return zero if the argument is in the path and executable. inpath
    ./functions/isnum.bash Test user input on numeric or character value.  
    ./functions/isnum2 Test user input on numeric values, with floating point.  
    ./functions/isvalidip Test user input for valid IP addresses.  
    ./functions/jdate.bash Julian date conversion.  
    ./functions/jj.bash Look for running jobs.  
    ./functions/keep Try to keep some programs in the foreground and running.  
    ./functions/ksh-cd ksh-like cd: cd [-LP] [dir[change]]. ksh
    ./functions/ksh-compat-test ksh-like arithmetic test replacements. ksh
    ./functions/kshenv Functions and aliases to provide the beginnings of a ksh environment for bash ksh
    ./functions/login Replace the login and newgrp built-ins in old Bourne shells.  
    ./functions/lowercase Rename files to lowercase. rename lower
    ./functions/manpage Find and print a manpage. fman
    ./functions/mhfold Print MH folders, useful only because folders(1) doesn't print mod date/times.  
    ./functions/notify.bash Notify when jobs change status.  
    ./functions/pathfuncs Path related functions (no_path, add_path, pre-path, del_path). path
    ./functions/README README  
    ./functions/recurse Recursive directory traverser.  
    ./functions/repeat2 A clone of the C shell built-in repeat. repeat, csh
    ./functions/repeat3 A clone of the C shell built-in repeat. repeat, csh
    ./functions/seq Generate a sequence from m to n;m defaults to 1.  
    ./functions/seq2 Generate a sequence from m to n;m defaults to 1.  
    ./functions/shcat Readline-based pager. cat, readline pager
    ./functions/shcat2 Readline-based pagers. cat, readline pager
    ./functions/sort-pos-params Sort the positional parameters.  
    ./functions/substr A function to emulate the ancient ksh built-in. ksh
    ./functions/substr2 A function to emulate the ancient ksh built-in. ksh
    ./functions/term A shell function to set the terminal type interactively or not.  
    ./functions/whatis An implementation of the 10th Edition Unix sh built-in whatis(1) command.  
    ./functions/whence An almost ksh-compatible whence(1) command.  
    ./functions/which An emulation of which(1) as it appears in FreeBSD.  
    ./functions/xalias.bash Convert csh alias commands to bash functions. csh, aliasconv
    ./functions/xfind.bash A find(1) clone.  
    ./loadables/ Example loadable replacements.  
    ./loadables/basename.c Return nondirectory portion of pathname. basename
    ./loadables/cat.c cat(1) replacement with no options—the way cat was intended. cat, readline pager
    ./loadables/cut.c cut(1) replacement.  
    ./loadables/dirname.c Return directory portion of pathname. dirname
    ./loadables/finfo.c Print file info.  
    ./loadables/getconf.c POSIX.2 getconf utility.
    ./loadables/getconf.h Replacement definitions for ones the system doesn't provide.  
    ./loadables/head.c Copy first part of files.  
    ./loadables/hello.c Obligatory "Hello World" / sample loadable.  
    ./loadables/id.c POSIX.2 user identity.  
    ./loadables/ln.c Make links.  
    ./loadables/logname.c Print login name of current user.  
    ./loadables/Makefile.in Simple makefile for the sample loadable built-ins.  
    ./loadables/mkdir.c Make directories.  
    ./loadables/necho.c echo without options or argument interpretation.  
    ./loadables/pathchk.c Check pathnames for validity and portability.  
    ./loadables/print.c Loadable ksh-93 style print built-in.  
    ./loadables/printenv.c Minimal built-in clone of BSD printenv(1).  
    ./loadables/push.c Anyone remember TOPS-20?  
    ./loadables/README README  
    ./loadables/realpath.c Canonicalize pathnames, resolving symlinks.  
    ./loadables/rmdir.c Remove directory.  
    ./loadables/sleep.c Sleep for fractions of a second.  
    ./loadables/strftime.c Loadable built-in interface to strftime(3).  
    ./loadables/sync.c Sync the disks by forcing pending filesystem writes to complete.  
    ./loadables/tee.c Duplicate standard input.  
    ./loadables/template.c Example template for loadable built-in.  
    ./loadables/truefalse.c True and false built-ins.  
    ./loadables/tty.c Return terminal name.  
    ./loadables/uname.c Print system information.  
    ./loadables/unlink.c Remove a directory entry.  
    ./loadables/whoami.c Print out username of current user.  
    ./loadables/perl/ Illustrates how to build a Perl interpreter into bash.  
    ./misc Miscellaneous  
    ./misc/aliasconv.bash Convert csh aliases to bash aliases and functions. csh, xalias
    ./misc/aliasconv.sh Convert csh aliases to bash aliases and functions. csh, xalias
    ./misc/cshtobash Convert csh aliases, environment variables, and variables to bash equivalents. csh, xalias
    ./misc/README README  
    ./misc/suncmd.termcap SunView TERMCAP string.  
    ./obashdb Modified version of the Korn Shell debugger from Bill Rosenblatt's Learning the Korn Shell.
    ./scripts.noah Noah Friedman's collection of scripts (updated to bash v2 syntax by Chet Ramey).  
    ./scripts.noah/aref.bash Pseudo-arrays and substring indexing examples.  
    ./scripts.noah/bash.sub.bash Library functions used by require.bash.  
    ./scripts.noah/bash_version. bash A function to slice up $BASH_VERSION.  
    ./scripts.noah/meta.bash Enable and disable eight-bit readline input.  
    ./scripts.noah/mktmp.bash Make a temporary file with a unique name.  
    ./scripts.noah/number.bash A fun hack to translate numerals into English.  
    ./scripts.noah/PERMISSION Permissions to use the scripts in this directory.  
    ./scripts.noah/prompt.bash A way to set PS1 to some predefined strings.  
    ./scripts.noah/README README  
    ./scripts.noah/remap_keys.bash A front end to bind to redo readline bindings. readline
    ./scripts.noah/require.bash Lisp-like require/provide library functions for bash.  
    ./scripts.noah/send_mail. Replacement SMTP client written in bash.  
    ./scripts.noah/shcat.bash bash replacement for cat(1). cat
    ./scripts.noah/source.bash Replacement for source that uses current directory.  
    ./scripts.noah/string.bash The string(3) functions at the shell level.  
    ./scripts.noah/stty.bash Front-end to stty(1) that changes readline bindings too. fstty
    ./scripts.noah/y_or_n_p.bash Prompt for a yes/no/quit answer. ask
    ./scripts.v2 John DuBois' ksh script collection (converted to bash v2 syntax by Chet Ramey).  
    ./scripts.v2/arc2tarz Convert an arc archive to a compressed tar archive.  
    ./scripts.v2/bashrand Random number generator with upper and lower bounds and optional seed. random
    ./scripts.v2/cal2day.bash Convert a day number to a name.  
    ./scripts.v2/cdhist.bash cd replacement with a directory stack added.  
    ./scripts.v2/corename Tell what produced a core file.  
    ./scripts.v2/fman Fast man(1) replacement. manpage
    ./scripts.v2/frcp Copy files using ftp(1) but with rcp-type command-line syntax.  
    ./scripts.v2/lowercase Change filenames to lowercase. rename lower
    ./scripts.v2/ncp A nicer front end for cp(1) (has -i, etc)..  
    ./scripts.v2/newext Change the extension of a group of files. rename
    ./scripts.v2/nmv A nicer front end for mv(1) (has -i, etc).. rename
    ./scripts.v2/pages Print specified pages from files.  
    ./scripts.v2/PERMISSION Permissions to use the scripts in this directory.  
    ./scripts.v2/pf A pager front end that handles compressed files.  
    ./scripts.v2/pmtop Poor man's top(1) for SunOS 4.x and BSD/OS.  
    ./scripts.v2/README README  
    ./scripts.v2/ren Rename files by changing parts of filenames that match a pattern. rename
    ./scripts.v2/rename Change the names of files that match a pattern. rename
    ./scripts.v2/repeat Execute a command multiple times. repeat
    ./scripts.v2/shprof Line profiler for bash scripts.  
    ./scripts.v2/untar Unarchive a (possibly compressed) tarfile into a directory.  
    ./scripts.v2/uudec Carefully uudecode(1) multiple files.  
    ./scripts.v2/uuenc uuencode(1) multiple files.  
    ./scripts.v2/vtree Print a visual display of a directory tree. tree
    ./scripts.v2/where Show where commands that match a pattern are.  
    ./scripts Example scripts.  
    ./scripts/adventure.sh Text adventure game in bash!  
    ./scripts/bcsh.sh Bourne shell's C shell emulator. csh
    ./scripts/cat.sh Readline-based pager. cat, readline pager
    ./scripts/center Center a group of lines.  
    ./scripts/dd-ex.sh Line editor using only /bin/sh, /bin/dd, and /bin/rm.  
    ./scripts/fixfiles.bash Recurse a tree and fix files containing various bad characters.  
    ./scripts/hanoi.bash The inevitable Towers of Hanoi in bash.  
    ./scripts/inpath Search $PATH for a file the same name as $1; return TRUE if found. inpath
    ./scripts/krand.bash Produces a random number within integer limits. random
    ./scripts/line-input.bash Line input routine for GNU Bourne Again Shell plus terminal-control primitives.  
    ./scripts/nohup.bash bash version of nohup command.  
    ./scripts/precedence Test relative precedences for && and || operators.  
    ./scripts/randomcard.bash Print a random card from a card deck. random
    ./scripts/README README  
    ./scripts/scrollbar Display scrolling text.  
    ./scripts/scrollbar2 Display scrolling text.  
    ./scripts/self-repro A self-reproducing script (careful!).  
    ./scripts/showperm.bash Convert ls(1) symbolic permissions into octal mode.  
    ./scripts/shprompt Display a prompt and get an answer satisfying certain criteria. ask
    ./scripts/spin.bash Display a spinning wheel to show progress.  
    ./scripts/timeout Give rsh(1) a shorter timeout.  
    ./scripts/vtree2 Display a tree printout of the direcotry with disk use in 1k blocks. tree
    ./scripts/vtree3 Display a graphical tree printout of dir. tree
    ./scripts/vtree3a Display a graphical tree printout of dir. tree
    ./scripts/websrv.sh A web server in bash!  
    ./scripts/xterm_title Print the contents of the xterm title bar.  
    ./scripts/zprintf Emulate printf (obsolete since printf is now a bash built-in).  
    ./startup-files Example startup files.  
    ./startup-files/Bash_aliases Some useful aliases (written by Fox).  
    ./startup-files/Bash_profile Sample startup file for bash login shells (written by Fox).  
    ./startup-files/bash-profile Sample startup file for bash login shells (written by Ramey).  
    ./startup-files/bashrc Sample Bourne Again Shell init file (written by Ramey).  
    ./startup-files/Bashrc.bfox Sample Bourne Again Shell init file (written by Fox).  
    ./startup-files/README README  
    ./startup-files/apple Example startup files for Mac OS X.  
    ./startup-files/apple/aliases Sample aliases for Mac OS X.  
    ./startup-files/apple/bash.defaults Sample User preferences file.  
    ./startup-files/apple/environment Sample Bourne Again Shell environment file.  
    ./startup-files/apple/login Sample login wrapper.  
    ./startup-files/apple/logout Sample logout wrapper.  
    ./startup-files/apple/rc Sample Bourne Again Shell config file.  
    ./startup-files/apple/README README

    Things bash has or uses that ksh88 does not:

    long invocation options

    [-+]O invocation option

    `!' reserved word

    arithmetic for command: for ((expr1 ; expr2; expr3 )); do list; done

    posix mode and posix conformance

    command hashing

    tilde expansion for assignment statements that look like $PATH

    process substitution with named pipes if /dev/fd is not available

    the ${!param} indirect parameter expansion operator

    the ${!param*} prefix expansion operator

    the ${param:offset[:length]} parameter substring operator

    the ${param/pat[/string]} parameter pattern substitution operator

    variables: BASH, BASH_VERSION, BASH_VERSINFO, UID, EUID, SHLVL,

       TIMEFORMAT, HISTCMD, HOSTTYPE, OSTYPE, MACHTYPE,

       HISTFILESIZE, HISTIGNORE, HISTCONTROL, PROMPT_COMMAND,

       IGNOREEOF, FIGNORE, INPUTRC, HOSTFILE, DIRSTACK,

       PIPESTATUS, HOSTNAME, OPTERR, SHELLOPTS, GLOBIGNORE,

       GROUPS, FUNCNAME, histchars, auto_resume

    prompt expansion with backslash escapes and command substitution

    redirection: &> (stdout and stderr)

    more extensive and extensible editing and programmable completion

    builtins: bind, builtin, command, declare, dirs, echo -e/-E, enable,

      exec -l/-c/-a, fc -s, export -n/-f/-p, hash, help, history,

      jobs -x/-r/-s, kill -s/-n/-l, local, logout, popd, pushd,

      read -e/-p/-a/-t/-n/-d/-s, readonly -a/-n/-f/-p,

      set -o braceexpand/-o histexpand/-o interactive-comments/

      -o notify/-o physical/-o posix/-o hashall/-o onecmd/

      -h/-B/-C/-b/-H/-P, set +o, suspend, trap -l, type,

      typeset -a/-F/-p, ulimit -u, umask -S, alias -p, shopt,

      disown, printf, complete, compgen

    `!' csh-style history expansion

    POSIX.2-style globbing character classes

    POSIX.2-style globbing equivalence classes

    POSIX.2-style globbing collating symbols

    egrep-like extended pattern matching operators

    case-insensitive pattern matching and globbing

    `**' arithmetic operator to do exponentiation

    redirection to /dev/fd/N, /dev/stdin, /dev/stdout, /dev/stderr

    arrays of unlimited size

    Things ksh88 has or uses that bash does not:

    tracked aliases (alias -t)

    variables: ERRNO, FPATH, EDITOR, VISUAL

    co-processes (|&, >&p, <&p)

    weirdly-scoped functions

    typeset +f to list all function names without definitions

    text of command history kept in a file, not memory

    builtins: alias -x, cd old new, fc -e -, newgrp, print,

      read -p/-s/-u/var?prompt, set -A/-o gmacs/

      -o bgnice/-o markdirs/-o nolog/-o trackall/-o viraw/-s,

      typeset -H/-L/-R/-Z/-A/-ft/-fu/-fx/-l/-u/-t, whence

    using environment to pass attributes of exported variables

    arithmetic evaluation done on arguments to some builtins

    reads .profile from $PWD when invoked as login shell

    Implementation differences:

    Bash Scripting

    function korn bash
    simple output print echo
    discipline functions yes no
    POSIX character classes yes no
    help no yes
    'cd' spelling correction no yes
    arithmetic (C-style) for yes no
    arithmetic bases 2-36 2-64
    array initialization set -A USERVAR value1 .... USERVAR=(value1 ....)
    array size limited unlimited
    associative arrays yes no
    compond arrays yes no

    FAQs

    [gnu.bash.bug] BASH Frequently-Asked Questions (FAQ version 3.29)

    FAQ This is the Bash FAQ, version 3.29, for Bash version 3.0.

    Etc

    Re Suggestions for corrections to executable.el - use of PATHEXT

    From: Lennart Borgman
    Subject: Re: Suggestions for corrections to executable.el - use of PATHEXT
    Date: Sun, 12 Sep 2004 12:56:08 +0200

    From: "Eli Zaretskii" <address@bogus.example.com>
    
    > First, I'm not sure we should look at PATHEXT.  That variable is AFAIK
    > looked at by the shell, so if we want Emacs behave _exactly_ like the
    > shell does, we should at least look at the value of SHELL and/or
    > ComSpec (and COMSPEC for older systems).  I mean, what if the user's
    > shell is Bash, which AFAIK doesn't look at PATHEXT at all?  And if the
    > shell is COMMAND.COM, then ".cmd" should not be in the list.  Etc.,
    > etc.
    
    PATHEXT is looked at by cmd.exe (the default shell on the NT hereditary
    line). I do not know if it is used by command.com (the default shell on the
    95 line) but I doubt it. When I tested now I found that the Run entry in
    Windows Start menu honor the default extensions for PATHEXT (.com, .exe.,
    .bat, .cmd). It does not however not recognize .pl which I have in my
    PATHEXT (cmd.exe recognize it). I am using NT4 when testing this.
    
    So perhaps not even ms windows is consistent here. What seems clear however
    is that the main purpose of PATHEXT is as far as I can see to make it easier
    for the user when entering a command interactively. The user may for example
    type "notepad" instead of "notepad.exe".
    
    PATHEXT is set by the user and expresses the users wish to type less. It
    seems reasonable to use PATHEXT for this purpose in Emacs too. The variable
    executable-binary-suffixes is (if I understand this correctly) used for this
    purpose by executable-find. This is however not clearly expressed in the
    documentation.
    
    A note: w32-shell-execute does something quite different. It calls the ms
    windows API ShellExecute to do the action associated with a certain "verb"
    on a file type (on windows this means file extension). Typical verbs are
    "open" and "print". Windows Explorer uses this.
    
    Having said all this I just want to say that I regret that I took this issue
    up without looking closer at the problem.
    
    - Lennart
    


    Copyright © 1996-2009 by Dr. Nikolai Bezroukov. www.softpanorama.org was created as a service to the UN Sustainable Development Networking Programme (SDNP) in the author free time. Submit comments This document is an industrial compilation designed and created exclusively for educational use and is placed under the copyright of the Open Content License(OPL). Site uses AdSense so you need to be aware of Google privacy policy. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.

    Disclaimer:

    Last modified: August 15, 2009