Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Shell script
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Advantages and disadvantages== Perhaps the biggest advantage of writing a shell script is that the commands and syntax are exactly the same as those directly entered at the command-line. The programmer does not have to switch to a totally different syntax, as they would if the script were written in a different language, or if a compiled language were used. Often, writing a shell script is much quicker than writing the equivalent code in other programming languages. The many advantages include easy program or file selection, quick start, and interactive debugging. A shell script can be used to provide a sequencing and decision-making linkage around existing programs, and for moderately sized scripts the absence of a compilation step is an advantage. Interpretive running makes it easy to write debugging code into a script and re-run it to detect and fix bugs. Non-expert users can use scripting to tailor the behavior of programs, and shell scripting provides some limited scope for multiprocessing. On the other hand, shell scripting is prone to costly errors. Inadvertent typing errors such as <code>[[rm (Unix)|rm]] -rf * /</code> (instead of the intended <code>rm -rf */</code>) are folklore in the Unix community; a single extra space converts the command from one that deletes all subdirectories contained in the current directory, to one which deletes everything from the file system's [[root directory]]. Similar problems can transform <code>[[cp (Unix)|cp]]</code> and <code>[[mv (Unix)|mv]]</code> into dangerous weapons, and misuse of the <code>></code> redirect can delete the contents of a file. This is made more problematic by the fact that many UNIX commands differ in name by only one letter: <code>cp</code>, <code>[[cd (command)|cd]]</code>, <code>[[dd (Unix)|dd]]</code>, <code>[[df (Unix)|df]]</code>, etc. Another significant disadvantage is the slow execution speed and the need to launch a new process for almost every shell command executed. When a script's job can be accomplished by setting up a [[Pipeline (computing)|pipeline]] in which efficient [[Filter (software)|filter]] commands perform most of the work, the slowdown is mitigated, but a complex script is typically several orders of magnitude slower than a conventional compiled program that performs an equivalent task. There are also compatibility problems between different platforms. [[Larry Wall]], creator of [[Perl]], famously wrote that "It's easier to port a shell than a shell script."<ref>{{cite newsgroup |title=Finding the last arg |author=[[Larry Wall]] |date=January 4, 1991 |newsgroup=comp.unix.shell |url=https://www.tuhs.org/Usenet/comp.unix.shell/1991-January/002464.html |access-date=January 5, 2023}}</ref> Similarly, more complex scripts can run into the limitations of the shell scripting language itself; the limits make it difficult to write quality code, and extensions by various shells to ameliorate problems with the original shell language can make problems worse.<ref>{{cite web|url=https://www.ooblick.com/text/CshProgrammingConsideredHarmful.html|title=Csh Programming Considered Harmful|author=Christiansen, Tom}}</ref> Many disadvantages of using some script languages are caused by design flaws within the [[programming language syntax|language syntax]] or implementation, and are not necessarily imposed by the use of a text-based command-line; there are a number of shells which use other shell programming languages or even full-fledged languages like [[Scsh]] (which uses [[Scheme (programming language)|Scheme]]).
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Shell script
(section)
Add topic