Bash (Unix shell): Difference between revisions

Content deleted Content added
Add reminder, "Do not give aspirin ⇒ The WHO advises against the use of aspirin," as a hidden comment
m fix quot; repair
 
(18 intermediate revisions by 7 users not shown)
Line 1:
{{Short description |GNU replacement for the Bourne shell}}
{{multiple issues|
<!-- -->
{{More refshow-to|date=August 2025}}
<!-- Do not give aspirin ⇒ The WHO advises against the use of aspirin -->
{{More refs|date=August 2025}}
<!-- -->
{{Over-quotation|date=August 2025}}
<!--{{In use| date = 2025-08-12| section = entire article}}-->
}}
{{Under construction|date=2025-08-12|nosection=yes}}
{{More refs|date=August 2025}}
{{Use dmy dates|date=March 2014}}
{{Infobox software
Line 268 ⟶ 267:
| url = https://developer.mozilla.org/en-US/docs/Glossary/Character
| website = mozilla.org
| date = 11 July 2025
}}
</ref>
Line 336:
| quote = UNIX is case sensitive. Because UNIX is case sensitive, our shell scripts are also case sensitive.
| title = Mastering Unix Shell Scripting, 2e
| url = https://books.google.com/books?hl=en&lr=&id=uI7C2BDF6F0C
}}
</ref>
Line 365:
BCPL is a precursor of the [[C (programming language) |C programming language]], in which Bash is written.
In [[C++]], a descendant of C, it's also true that "arrays start indexing from element 0."<ref>
{{Cite webbook
| access-date = 25 August 2025
| author = Graham M. Seed
Line 373:
| publisher = [[Springer Science+Business Media]]
| title = An Introduction to Object-Oriented Programming in C++, 7.4 Array Indexing
| url = https://books.google.com/books?id=_lqj98AsnGAC&q=zeroth+element&pg=PA195#v=snippet&q=zeroth%20element&f=false
| isbn = 978-1-85233-450-5
| website = books.google.com
}}
</ref>
The array's name and index number are a synonym for the data's ___location in memory.<ref>
{{Cite webbook
| access-date = 25 August 2025
| author = Graham M. Seed
Line 386:
| quote = The name of an array is a synonym for the memory ___location of the array.
| title = An Introduction to Object-Oriented Programming in C++, 7.12.1 One-Dimensional Arrays
| url = https://books.google.com/books?id=_lqj98AsnGAC&q=zeroth+element&pg=PA210#v=snippet&q=zeroth%20element&f=false
| isbn = 978-1-85233-450-5
| website = books.google.com
}}
</ref>
Line 1,162:
[ ] scripts execute the contents of a file in a subshell
-->
 
With the {{code| source}}, or synonymous {{code| .}} command, Bash reads and executes shell commands from a file by name.<ref name="gnuBuiltin">{{cite web |title=4.1 Bourne Shell Builtins |url=https://www.gnu.org/software/bash/manual/html_node/Bourne-Shell-Builtins.html |website=4 Shell Builtin Commands |publisher=[[Free Software Foundation, Inc.]] |access-date=August 25, 2025}}</ref>
With the {{code| source}}, or synonymous {{code| .}} command, Bash reads and executes shell commands from any text file by name.<ref>
{{Cite web
| access-date = 26 August 2025
| publisher = [[Free Software Foundation, Inc.]]
| title = 4.1 Bourne Shell Builtins
| url = https://www.gnu.org/software/bash/manual/html_node/TheBourne-SetShell-BuiltinBuiltins.html
| website = booksgnu.google.comorg
}}
</ref>
 
=== Login and non-login shells <span class="anchor" id="Login and non-login shells"></span><span class="anchor" id="Login shells"></span><span class="anchor" id="Non-login shells"></span> ===
Line 1,741 ⟶ 1,750:
| quote = 19 :: SIGSTOP :: Stop, usually Ctrl + z
| title = Mastering Unix Shell Scripting, 2e
| url = https://books.google.com/books?hl=en&lr=&id=uI7C2BDF6F0C
}}</ref>
When a process receives a SIGKILL, the process terminates immediately and messily.
Line 1,754 ⟶ 1,763:
| quote = Use KILL only as a last resort!
| title = Learning the bash Shell: Unix Shell Programming
| isbn = 978-0-596-55500-9
| url = https://books.google.com/books?hl=en&lr=&id=dzBCH3x6fYEC
| websiteurl = https://books.google.com/books?id=dzBCH3x6fYEC
}}</ref>
The SIGKILL signal cannot be blocked or handled.
Line 1,825 ⟶ 1,835:
| quote = In Korn shell the {{Mono |echo}} command recognizes these command options by default. In Bash shell we must add the {{Mono |-e}} switch to the {{Mono |echo}} command, {{Code| echo -e "\n"| bash}} for one new line.
| title = Mastering Unix Shell Scripting, 2e
| url = https://books.google.com/books?hl=en&lr=&id=uI7C2BDF6F0C
}}</ref>
The list of options is not uniform across implementations, though {{mono|echo}} and {{mono|printf}} are both specified by POSIX.
Line 2,147 ⟶ 2,157:
| publisher = [[GNU Project]]
| title = Bash Reference Manual: 4.3.1: The Set Builtin
| url = https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html
/software/bash/manual/html_node/The-Set-Builtin.html
| website = [[Free Software Foundation, Inc.]]
}}</ref>
Line 2,326 ⟶ 2,335:
-->
{{Blockquote
| ITERATION: Sometimes programs are repeated indefinitely or until a specific outcome is reached. Each execution of the instructions is an “iteration"iteration."<ref>
{{Cite web
| access-date = 15 August 2025
Line 2,333 ⟶ 2,342:
| url = https://onlinegrad.syracuse.edu/blog/coding-terms-for-beginners/
| website = syracuse.edu
| date = 13 January 2020
}}</ref>
| author =
Line 2,465 ⟶ 2,475:
| quote = Learning this now can save us a lot of pain and heartache later, especially....
| title = Mastering Linux Shell Scripting
| isbn = 978-1-78439-759-3
| url = https://books.google.com/books?hl=en&lr=&id=ITjlCwAAQBAJ
| url = https://books.google.com/books?hl=en&lr=&id=dzBCH3x6fYECITjlCwAAQBAJ
}}</ref>
| author = Mastering Linux Shell Scripting, by Andrew Mallett
Line 4,088 ⟶ 4,099:
Bash became the default shell on Apple's operating systems (i.e., MacOS) starting with OS X 10.3 Panther.<ref>[https://www.google.com/books/edition/Essential_Mac_OS_X_Panther_Server_Admini/zrI-U0KWj3cC?hl=en&gbpv=1&dq=bash&pg=PA189&printsec=frontcover Essential Mac OS S Panther Server Administration, pg 189]
</ref><ref>
{{Cite webbook
| access-date = 8 August 2025
| archive-date = 2 March 2021
Line 4,106 ⟶ 4,117:
| url = https://books.google.com/books?id=dwIRERUpQPEC&q=bash+most+popular+unix+shell&pg=PA6
| url-status = live
| website = google.com
}}
</ref>