Bash 4547 226125137 2008-07-16T22:44:27Z Tedickey 1942604 rm comment unrelated to portability {{otheruses4|the Unix shell}} {{Refimprove|date=June 2007}} {{ Infobox Software | name = Bash | logo = [[image:bash-org.jpg|165px]] | screenshot = [[Image:Bash demo.png|250px]] | caption = Screenshot of bash and [[Bourne shell|sh]] sessions demonstrating some features | developer = [[Chet Ramey]] | latest_release_version = 3.2.33 | latest_release_date = {{release date|2007|12|15}} | programming language = [[C (programming language)|C]] | operating_system = [[Cross-platform]] | platform = [[GNU]] | language = English, multilingual ([[gettext]]) | status = Active | genre = [[Unix shell]] | source_model = [[Free software]] | license = [[GNU General Public License]] | website = [http://tiswww.case.edu/php/chet/bash/bashtop.html Home page] }} '''Bash''' is a [[free software]] [[Unix shell]] written for the [[GNU Project]]. Its name is an [[acronym]] which stands for ''Bourne-again shell'',<ref>http://www.ddj.com/cpp/184404693</ref> a [[pun]] on the name of the [[Bourne shell]] (sh), an early and important Unix shell written by [[Stephen Bourne]] and distributed with [[Version 7 Unix]] circa 1978,<ref>http://www.ddj.com/architect/184415340</ref> and the concept of being "[[Born again Christianity|born again]]". Bash was created in 1987 by [[Brian Fox]]. In 1990 [[Chet Ramey]] became the primary maintainer.<ref name="Bourne shell grammar">{{ cite web | first = Chet | last = Ramey | title = Bash - the GNU shell (Reflections and Lessons Learned) | url = http://www.wing.rug.nl/info/programs/bash/article.html#6 | accessdate = 2008-01-15 }}</ref> Bash is the default shell on most [[Linux|GNU/Linux]] systems as well as on [[Mac OS X]] and it can be run on most [[Unix-like]] operating systems. It has also been ported to [[Microsoft Windows]] using the [[POSIX]] emulation provided by [[Cygwin]], to [[MS-DOS]] by the [[DJGPP]] project and to [[Novell NetWare]]. == Features == The Bash command syntax is a superset of the Bourne shell command syntax. The vast majority of Bourne shell scripts can be executed by Bash without modification, with the exception of Bourne shell scripts referencing a Bourne special variable or those using [[shell builtin|builtin]] Bourne commands. Bash command syntax includes ideas drawn from the [[Korn shell]] (ksh) and the [[C shell]] (csh) such as command line editing, [[command history]], the directory stack, the <tt>$RANDOM</tt> and <tt>$PPID</tt> variables, and [[POSIX]] command substitution syntax <tt>$(…)</tt>. When used as an interactive command shell and pressing the [[tab key]], Bash automatically uses [[command line completion]] to match partly typed program names, filenames and variable names. Bash's syntax has many extensions which the Bourne shell lacks. Bash can perform integer calculations without spawning external processes, unlike the Bourne shell. Bash uses the <tt>((…))</tt> command and the <tt>$[…]</tt> variable syntax for this purpose. Bash syntax simplifies [[Redirection (Unix)|I/O redirection]] in ways that are not possible in the traditional Bourne shell. For example, Bash can redirect [[Standard streams#Standard output (stdout)|standard output]] (stdout) and [[Standard streams#Standard error (stderr)|standard error]] (stderr) at the same time using the <tt>&></tt> operator. This is simpler to type than the Bourne shell equivalent '<tt>command > file 2>&1</tt>'. Bash supports [[here document]]s just as the Bourne shell always has. However, since version 2.05b Bash can redirect [[Standard streams#Standard input (stdin)|standard input]] (stdin) from a "here string" using the <tt><<<</tt> operator. Bash 3.0 supports in-process [[regular expression]] matching using a syntax reminiscent of [[Perl]].<ref>The syntax matches that shown on the <code>[http://www.tin.org/bin/man.cgi?section=7&topic=regex regex(7)]</code> [[man page]].</ref> == Startup scripts == When Bash starts, it executes the commands in a variety of different scripts. When Bash is invoked as an interactive login shell, it first reads and executes commands from the file <tt>/etc/profile</tt>, if that file exists. After reading that file, it looks for <tt>~/.bash_profile</tt>, <tt>~/.bash_login</tt>, and <tt>~/.profile</tt>, in that order, and reads and executes commands from the first one that exists and is readable. When a login shell exits, Bash reads and executes commands from the file <tt>~/.bash_logout</tt>, if it exists. When an interactive shell that is not a login shell is started, Bash reads and executes commands from <tt>~/.bashrc</tt>, if that file exists. This may be inhibited by using the <tt>--norc</tt> option. The <tt>--rcfile file</tt> option will force Bash to read and execute commands from <tt>file</tt> instead of <tt>~/.bashrc</tt>. == Portability == Shell scripts written with Bash-specific features (''bashisms'') will not function on a system using the Bourne shell or one of its replacements, unless bash is installed as a secondary shell and the script begins with ''#!/bin/bash''. This problem became particularly important when [[Ubuntu (operating system)|Ubuntu]] began, in October 2006, to ship the [[Debian Almquist shell]], dash, as the default scripting shell, causing a wide variety of scripts to fail. == See also == {{portal|Free software|Free Software Portal Logo.svg}} * [[Comparison of command shells]] == References == {{reflist}} == External links == {{wikibooks|Bourne Shell Scripting}} * [http://www.gnu.org/software/bash/bash.html Bash home page] * {{tldp|LDP/Bash-Beginners-Guide|Bash Guide for Beginners}} * {{tldp|LDP/abs|Advanced Bash Scripting Guide}} * [http://bashdb.sf.net/bashdb.html Bash Debugger] * [http://linuxcommand.org/learning_the_shell.php Learning the shell]. * [http://www.computerworld.com.au/index.php/id;1591223321;fp;16;fpid;1;pf;1 2008 interview with GNU Bash's maintainer, Chet Ramey] * [http://bashscripts.org Bash Online Forum] {{GNU}} [[Category:Domain-specific programming languages]] [[Category:Text-oriented programming languages]] [[Category:Scripting languages]] [[Category:Unix shells]] [[Category:Unix software]] [[Category:GNU project software]] [[Category:Command shells]] [[Category:Free software programmed in C]] [[ar:باش]] [[bs:Bash]] [[bg:Bash]] [[ca:Bash]] [[cs:Bash]] [[de:Unix-Shell#Die Bourne-Again-Shell]] [[es:Bash]] [[eo:Bash]] [[fr:Bourne-Again shell]] [[gl:Bash]] [[ko:본 어게인 셸]] [[hr:Bash]] [[it:Bash]] [[he:Bourne-again shell]] [[hu:Bash]] [[ms:Bash]] [[nl:Bash]] [[ja:Bash]] [[pl:Bash]] [[pt:Bash]] [[ru:Bash]] [[sk:Bash]] [[sr:Баш]] [[sh:Bash]] [[fi:Bash]] [[sv:Bash]] [[th:Bash]] [[tr:Bash]] [[zh:Bash]]