Content deleted Content added
Blush30720 (talk | contribs) →Features: add a feature description |
|||
(30 intermediate revisions by 8 users not shown) | |||
Line 150:
| url-status = dead
}}
</ref>
Since its inception, Bash has gained widespread adoption and is commonly used as the default [[login]] shell for numerous [[Linux]] distributions. It holds historical significance as one of the earliest programs ported to Linux by [[Linus Torvalds]], alongside the GNU Compiler ([[GNU Compiler Collection|GCC]]).<ref name="groups.google.com">
Line 164:
</ref> It is available on nearly all modern operating systems, making it a versatile tool in various computing environments.
As a [[Command-line interface|command processor]], Bash operates within a [[Terminal emulator|text window]] where users input commands to execute various tasks. It also supports the execution of commands from files, known as [[shell script]]s, facilitating [[automation]]. In keeping with [[Unix shell]] conventions, Bash incorporates a rich set of features. The [[Keyword (computer programming)|keywords]], [[Syntax (programming languages)|syntax]], [[Scope (computer science)#Dynamic scoping|dynamically scoped]] variables and other basic features of the [[formal language|language]] are all copied from the [[Bourne shell]],
== History ==
While
{{ cite web
| access-date = April 9, 2016
Line 177:
| url-status = dead
}}
</ref> it
{{ cite web
| title = A desktop alternative
Line 469:
As a [[Command-line interface|command processor]], Bash operates within a [[Terminal emulator|text window]] where users input commands to execute various tasks. It also supports the execution of commands from files, known as [[shell script]]s, facilitating [[automation]]. In keeping with [[Unix shell]] conventions, Bash incorporates a rich set of features, including:
* [[
** [[Interactivity|Interactive]] shell,
** Non-interactive shell, or
** Login shell;
* A [[command-line interface]];
* [[Exit status]] codes;
* [[Control flow|Control structures]] for
** [[Conditional (computer programming)|Condition testing]],
*** <code>if</code>, <code>case</code>, <code>select</code>,
*** logical AND (<code>&&</code>) and OR (<code>||</code>), and
** [[Iteration]]
*** <code>for</code>, <code>while</code>, <code>until</code> loops, and
*** Arithmetic C-style loop: <code>for ((</code>;
* Syntaxes for file type, string value and integer value testing
** Traditional single bracket test: <code>[</code>,
** Modern double bracket test: <code> [[ ... ]]</code>, including
*** Extended [[regular expression]] and extglob matching
*** Lexicographic sorting with <code><</code> and <code>></code>;
* [[Unix|UNIX]]-style [[Pipeline (Unix)|pipelines]]: <code>|</code>;
* [[Child process|Subshells]]: <code>( ... )</code>;
* [[Signal (IPC)|Signaling]] as a means of [[inter-process communication]] using the <code>trap</code> builtin;
* Asynchronous execution: <code>job_spec &</code>;
* A shell [[Porting|portability]] mode where commands can be interpreted in conformance with the [[POSIX terminal interface|POSIX]] standard;
* Command parsing:
** Comments are ignored:
*** Bourne-style <code>#</code> hashtag comments, and
*** Thompson-style <code>:</code> colon comments;
** Commands are parsed one line at a time,
*** Control structures are honored, and
*** Backslash <code>\</code> escapes are also honored at the ends of lines,
** Split into words (i.e., [[Text segmentation|word splitting]]) according to [[String literal|quoting]] rules,
*** Including ANSI-C quoting <code>$'...'</code>, and
** Seven kinds of expansions are performed on the resulting string in the following order:
***
*** (Step 2) Tilde expansion <code>~</code>,
*** (Step 3) In a left-to-right fashion:
**** [[Parameter (computer programming)|Parameter]] and [[Variable (computer science)|variable]] expansion <code>$foo</code> or <code>${bar}</code>, including
***** [[Scope (computer science)#Dynamic scoping|Dynamically scoped]] variables,
***** Indexed [[Array (data type)|arrays]] of unlimited size,
***** [[Associative array]]s via <code>declare -A</code>, and
***** Expansion syntaxes which can perform some tasks more quickly than external utilities, such as
****** Pattern Substitution
******* <code>${foo//x/y}</code> for <code>sed 's/x/y/g'</code>,
****** Remove Matching Prefix or Suffix Pattern
******* <code>${bar##[a-zA-Z0-9]*}</code> for <code>cut -c8-</code>,
****** Print Array Keys
******* <code>${!array[@]}</code>, and
****** Display Error if Null or Unset
******* <code>${var:?error message}</code>, among others,
**** [[Command substitution]]: <code>$( ... )</code>,
**** [[Process substitution]], <code><()</code> or <code>>()</code>, when a system supports it:
**** Arithmetic expansion, <code>(( ... ))</code> or <code>$(( ... ))</code>, including
***** Integer [[arithmetic]] in any [[Radix|base]] from two to sixty-four, although
***** [[Floating-point arithmetic]] is not available from within the shell itself (for this functionality, see current versions of [[Bc (programming language)|<code>bc</code>]] and [[AWK|<code>awk</code>]], among others),
*** (Step 4) [[Text segmentation|Word splitting]] (again),
*** (Step 5) Pathname expansion,
**** Meaning shell-style [[Glob (programming)|globbing]] and [[pattern matching]] using <code>*</code>, <code>?</code>, <code>[...]</code>, and
*** [[String literal|Quote]] removal;
** [[Redirection (computing)|Redirections]] of Standard Input, Standard Output and Standard Error [[Standard streams|data streams]] are performed, including
*** File writing, <code>></code>, and appending, <code>>></code>,
*** [[Here document]]s, <code><<</code>,
*** Here strings, <code><<<</code>, which allow parameters to be used as input, and
*** A redirection operator, <code>>|</code>, which can force overwriting of a file when a shell's "noclobber" setting is enabled;
** Command name lookup is performed, in the following order:
*** [[Command (computing)|Commands]] internal to the [[Shell (computing)|shell]]:
**** [[Alias (command)|Shell aliases]],
**** Shell reserved words,
**** [[Function (computer programming)|Shell functions]], and
**** [[Shell builtin|Shell built-in commands]];
*** Commands external to the shell:
**** Separate [[Unix|UNIX]]-style programs such as [[ls|<code>ls</code>]] or [[Ln (Unix)|<code>ln</code>]], and
**** [[Shell script]]s, which are [[File system|files]] containing executable commands. (Shell scripts do not require compilation before execution and, when certain requirements are met, can be invoked as commands by using their filename.)
** The resulting string is executed as a command.
Bash also offers...
* Configurable execution environment(s):<ref>
{{ cite web
| title = Command Execution Environment (Bash Reference Manual)
| url = https://www.gnu.org/software/bash/manual/html_node/Command-Execution-Environment.html
| website = www.gnu.org}}
</ref>
** Shell and [[Session (computer science)|session]] startup files such as
* Settings (
* With interactive invocation only,
** Unlimited size [[
** [[Job (computing)|Jobs]] and [[Job control (Unix)|job control]],
** A directory stack (see <code>pushd</code> and <code>popd</code> built-ins),
** [[Command-line completion|Tab completion]],
** Configurable [[Command-line interface#Command prompt|prompts]], and
Line 531 ⟶ 563:
* Shell [[Compatibility mode|compatibility modes]]: bash 5.1 can operate as if it were bash 4.2, etc.;
* Documentation:
** A built-in
** A [[man page]], and
** An [[Info (Unix)|info page]] which is the same as the GNU manual;
Line 538 ⟶ 570:
** Mailing lists at https://www.gnu.org/software/bash/
The [[Keyword (computer programming)|keywords]], [[Syntax (programming languages)|syntax]], [[Scope (computer science)#Dynamic scoping|dynamically scoped]] variables and other basic features of the [[formal language|language]] are all copied from [[Bourne shell|sh]]. Other features, e.g., [[C shell#History|history]], are copied from [[C shell|csh]] and [[KornShell|ksh]].
The Bash [[command (computing)|command]] syntax is a [[superset]] of the Bourne shell command syntax. Bash supports [[brace expansion]],<ref>
Line 666 ⟶ 697:
| website = www.gnu.org
}}
</ref> They can be used to emulate multidimensional arrays. Bash 4 also switches its license to [[GNU General Public License#Version 3|GPL-3.0-or-later]]; some users suspect this licensing change is why
{{ cite web
| access-date = June 25, 2018
Line 676 ⟶ 707:
| website = Ask Different
}}
</ref>
{{ cite web
| access-date = 2021-01-12
Line 750 ⟶ 781:
===Startup scripts===
{{
When Bash starts, it executes the commands in a variety of [[Hidden file and hidden directory#Unix and Unix-like environments|dot files]]. Unlike Bash shell scripts, dot files do typically have neither the execute permission enabled nor an [[interpreter directive]] like <code>#!/bin/bash</code>.
Line 804 ⟶ 835:
* Bash-specific builtins
* [[Coprocess]]es
* $EPOCHSECONDS and $EPOCHREALTIME variables
{{ cite web
| access-date = June 3, 2020
Line 859 ⟶ 890:
In this example, when command1 is finished, command2 is executed, and when command2 has completed, command3 will execute.
A [[Background process|background execution]] of command1 can occur using (symbol &) at the end of an execution command, and process will be executed in background while
<syntaxhighlight lang="bash">command1 &</syntaxhighlight>
Or to have a concurrent execution of
<syntaxhighlight lang="bash">
Line 959 ⟶ 990:
=== Program name ===
{{
The program's name is a [[figure of speech]] or [[wit]]ticism which begins with an [[Homage (arts)|homage]] to [[Stephen R. Bourne|Stephen Bourne]], the creator of [[Bourne shell|one]] of the shell programs which have sometimes been considered superseded by the bash shell. His name is used as a [[pun]] on the [[Imagery|image]] of childbirth. With that pun, it would seem, is added an [[allusion]]: possibly to the [[Hinduism|Hindu]] or [[Buddhism|Buddhist]] idea of [[reincarnation]]; possibly to the [[Christianity|Christian]] [[idiom]] known as "being [[born again]];" or quite possibly just to the more abstract idea of [[wikt:renewal|renewal]]. While numerous [[English language|English]] [[translation]]s of the Christian [[New Testament]], Book of [[Gospel of John|John]], [https://www.biblegateway.com/passage/?search=John%203&version=NIV chapter] [https://www.biblegateway.com/passage/?search=John%203&version=KJV 3] do contain the words "born again," [[Merriam-Webster
{{ cite web
| access-date = 2024-01-09
Line 982 ⟶ 1,013:
| website = www.gnu.org
}}
</ref>
The [[acronym]] of that name then is "bash," a word meaning "to strike violently.<ref>
Line 993 ⟶ 1,024:
| website = www.merriam-webster.com
}}
</ref>" In the context of computer programming, to "violently hit something," such as a computer keyboard, could be considered a [[Hyperbole|hyperbolic]] [[Imagery|image]] of some ''frustration''. Such [[imagery]] of negative emotionality could be seen as standing in direct [[juxtaposition]] to the idea of becoming "born again."
The naming could be considered an instance of verbal [[irony]]<ref>
Line 1,053 ⟶ 1,084:
| url = https://wiki.bash-hackers.org/scripting/obsolete
}}
</ref> so much so that it seems likely that the bash project has been ''committed'' to improving its
=== Documentation ===
Line 1,076 ⟶ 1,107:
| website = git.savannah.gnu.org
}}
</ref> is intended to be the authoritative explanatory document for the understanding of how
On modern Linuxes, information on shell built-in commands can be found by executing <code>help,</code> <code>help [built-in name]</code>or
"The project maintainer also has a Bash page which includes Frequently Asked Questions",<ref>
|