Category:UNIX Shell Implementations: Difference between revisions
Content deleted Content added
m comparison of shells |
m Proofreading, links |
||
Line 1:
{{implementation cat|UNIX Shell}}
There are many [[UNIX Shell
The original Bourne shell went through a number of revisions in the early years of UNIX, and support for some features varies considerably. By the time the SUSv3 (Single Unix Specification, version 3) features stabilized, all versions of the various Bourne-compatible shells should support a common set of features. This is denoted in Rosette Code examples with the phrase: "SUSv3" features.
Note that even when using a common subset of supported features there are subtle implementation differences, and, in some cases, parsing bugs, which can affect the portability of shell script examples.
{ echo foo; echo bar } ## Bug!!!
... though this is technically a bug in the language parsing (The braces used for command grouping are not delimiters in the same class as semicolons nor parentheses; so this example is ambiguous because ''echo }'' (outside of any command grouping) should work the same as ''echo "}"'' --- but in bash versions 1.x it behaves inconsistently).
{ echo foo; echo bar; } ## Note the required semicolon
Line 15:
... (Or the ''}'' token can be put on a separate line)
Variations of this bug probably
Another common portability issue among different Bourne-compatible shells is a subtle matter of how pipe operations are handled.
... implicitly invokes a subshell (separate process) as either the producer or the consumer (writer into or reader from) this data "pipe."
The crucial
unset bar; echo "foo" | read bar; echo "$bar"
... shells such as ''ksh'' and ''zsh'' spawn their subshells to the left of the pipe ... so the sub-process is writing into the pipeline.
To be portable such code must use command grouping:
Line 39:
unset bar; bar=$(echo "foo"); echo "$bar" # some very old shells may require ` (backticks) instead of the $(...) syntax
Note that in all these examples the ''unset bar'' command is simply to avoid any confusion in the unlikely event that a variable named "bar" was present in the shell environment or local variable heap prior to our functional examples.
==Comparison of various shells==
[http://athena.vvsu.ru/docs/unix/unix_adm/ch13.htm
|