Content deleted Content added
Blush30720 (talk | contribs) Undid revision 1307857444 by OceanLoop Reverting disruptive edit from yesterday. Work on the prose is in-process. |
Blush30720 (talk | contribs) Undid revision 1307855327 by OceanLoop Reverting second disruptive edit. |
||
Line 241:
=== ASCII, strings and numbers <span class="anchor" id="ASCII"></span> <span class="anchor" id="strings"></span> <span class="anchor" id="numbers"></span> ===
<!-- Important concepts: ASCII
[x] Characters
[x] Human/computer communitcation
Line 249:
[ ] Information
-->
<!-- Important concepts: strings
[x] String
[x] Filenames
-->
<!-- Important concepts: numbers
[x] Zero-based numbering
-->
{{Blockquote
| The input language to the shell shall be first recognized at the character level.<ref>
Line 321 ⟶ 329:
</syntaxhighlight>
Any series of characters is called a "[[String (computer science) |string]]," or sometimes a "[[string literal]]."
In Unix-like operating systems, all characters, printable and non-printing, except for a few such as the [[null character]] and forward slash {{char|/}}, can be used in naming [[Filenames |files]].
Line 342 ⟶ 346:
</ref>
In everyday life, people usually begin counting some group of items from the number one: 1, 2, 3 apples.
In computer science it is customary to do as the computers do and begin counting the first item from the number zero: 0, 1, 2 oranges, for a total of 3 oranges.
Line 407:
=== CLI and GUI <span class="anchor" id="CLI and GUI"></span> ===
<!-- Important concepts:
[x] Origin of CLI paradigm
[x] Origin of terminal emulators
[x] GUI
-->
{{Main
Line 416 ⟶ 422:
}}
Long after the first Analytical Engine, in the mid-1960's one of the primary ways for humans and computers to interact in real time was at a keyboard with a [[teleprinter]]: only display of textual characters was possible.<ref>
{{Cite web
Line 529 ⟶ 530:
[] stream of characters
[] delineate full commandlines (newline, semi-colon)
[x] Bash reads one line at a time
[x] Line continuation
[] division into commands and parts of commands (optargs)
[] uses metacharacters
-->
{{Blockquote
Line 555 ⟶ 548:
}}
A person typing at a keyboard creates something called a ''stream'' of characters.
In the [[Command-line interface#Comparison to graphical user interfaces |command-line interface]] [[paradigm]], via a [[terminal emulator]] Bash receives a series of characters from the user and expects each series of characters to be a command.
By default, Bash reads user code one line at a time, interprets any newline or semi-colon character {{code|;}} as the end of the current command, and executes commands in sequence.
If an interactive command extends beyond the width of the terminal emulator, it's usually possible to keep typing and the command will wrap around.
To extend a command beyond a newline onto an additional line, it's necessary that the final character of the first line be an unescaped backslash, {{code|\}}, which signals "line continuation."
Bash always finishes parsing and executing one full commandline before moving on to and beginning with the parsing of the next commandline.
:<syntaxhighlight lang="console">
$ foo=aa bar=bb quux=cc zork=dd; set -o xtrace
$ : "${foo}"; : "${bar}"
+ : aa
+ : bb
$ : "${quux}" \
> : "${zork}"
+ : cc : dd
$
</syntaxhighlight>
When Bash reads a ''full commandline,'' the complete string is broken down according to a certain set of rules into individual units called ''"tokens."''
<syntaxhighlight lang = text>
"Tokens"
\_ "Blanks"
\_ "Operators" (Ops)
\_ "Control Ops"
\_ "Redirection Ops"
\_ "Words"
\_ "Reserved Words"
\_ "Names"
</syntaxhighlight>
"Tokens" are identified using, and separated from each other using ''"metacharacters."'' (As of version 5.3:)
Line 645 ⟶ 669:
<!-- Important concepts:
[] replacement of placeholders / logical substitution
[] Expansion vs substitution
-->
"Expansion" is a crucial concept in Unix-like shells. See [[String interpolation]].
Line 677 ⟶ 703:
[x] Arrays
-->
For data structures Bash offers variables and arrays, and though there are numerous kinds of each of these available, the data structures are relatively simple compared to other languages like [[C (programming language) |C]] or [[Java (programming language) |Java]].<ref>{{Cite web
| access-date = 15 August 2025
Line 816 ⟶ 843:
=== Processes <span class="anchor" id="Processes"></span> ===
<!-- Important concepts:
Line 830 ⟶ 852:
[x] Working directory
-->
{{Main
| Process (computing)
| Attribute (computing)
}}
Each [[operating system]] (OS) has at its core a program called the [[Kernel (operating system) |kernel]] which runs commands.<ref name = Brit_control-unit>
{{Cite web
Line 871 ⟶ 899:
=== Files and permissions <span class="anchor" id="Files and permissions"></span><span class="anchor" id="Files"></span><span class="anchor" id="Permissions"></span> ===
<!-- This subsection is messy -->
Line 886 ⟶ 908:
[?] umask
-->
{{Main
| File system
| Unix file types
| File-system permissions
}}
In Unix-like operating systems, all objects locatable on the [[file system]] are considered to be "files."<ref name = tldp_3.1.1>
{{Cite web
Line 928 ⟶ 957:
=== Paths <span class="anchor" id="Paths"></span> ===
<!-- Important concepts:
Line 938 ⟶ 963:
[x] File anchor: './'
-->
{{Main |Path (computing)
| Hierarchical file system
}}
In Unix-like OS's, files, hardlinks, device nodes, etc., (i.e., "files") are sorted into [[Directory (computing) |directories]] that form a hierarchical file structure which is nested in a "parent" and "child" manner.
The base of the hierarchy is called the "root directory" which is denoted by one forward slash: {{char|/}}.
Line 963 ⟶ 993:
=== Execution <span class="anchor" id="Execution"></span> ===
<!-- Important concepts:
[x] Execution / to execute a command
[x] An executable
[x] Command position
[ ] A single logical construct is parsed as a single unit
-->
{{Main
| Execution (computing)
}}
"Execution" of a given program occurs when a user (or some other program) asks the operating system to act upon the instructions contained in the given program.
The first word of a commandline is known as the "command position."
Line 1,470 ⟶ 1,483:
[x] Description and visual example of xtrace
[x] How to enable and disable xtrace
[x] Thompson-style comments visible in xtrace
[x] xtrace re POSIX
-->
Line 1,489 ⟶ 1,503:
$
</syntaxhighlight>
Comments denoted with a colon character, {{char|:}}, originated with the [[Thompson shell]].<ref>
Line 1,534 ⟶ 1,525:
:<syntaxhighlight lang="console">
$
$ set -x
$ : "${foo}"
+ : bar
$
</syntaxhighlight>
The {{Mono| xtrace}} shell setting is specified by POSIX.
See also {{section link||Debugging}}.
=== The {{mono| verbose}} option ===
<!-- Important concepts:
[x] Saying something about Verbose mode
-->
The verbose option prints strings to the terminal as they are read, and before any expansions are performed. Rarely used.<ref>See {{Code| set -v| bash}} in the documentation.</ref>
=== Exit codes ===
Line 1,553:
[x] Lack of standardization
-->
When bash executes commands, [[exit status]] codes, also called "return codes," are produced which can offer some insight into the manner in which a program ceased running.
The value of the most recently captured exit code is held within the shell parameter, 'question mark:' {{Code| $? }}.
|