Bourne Shell: Difference between revisions
Content added Content deleted
(Examples marked "Works with: Bourne Shell" should work in any of the Bourne-compatible shells.) |
(Show a bug with here documents.) |
||
Line 10: | Line 10: | ||
In 2009, [[wp:Computerworld|Computerworld]] published an in-depth interview with Steve Bourne, ''[http://www.computerworld.com.au/article/279011/a-z_programming_languages_bourne_shell_sh/ The A-Z of Programming Languages: Bourne shell, or sh]'', which details the Bourne shell origins and design decisions. |
In 2009, [[wp:Computerworld|Computerworld]] published an in-depth interview with Steve Bourne, ''[http://www.computerworld.com.au/article/279011/a-z_programming_languages_bourne_shell_sh/ The A-Z of Programming Languages: Bourne shell, or sh]'', which details the Bourne shell origins and design decisions. |
||
== Bugs == |
|||
Bourne Shell and Heirloom Shell have problems with here documents. Here is one such problem. A substitution, inside a here document, inside backquotes, inside double quotes, does insert too many backslashes. |
|||
<lang bash>f() { |
|||
cat <<! |
|||
here $1 |
|||
! |
|||
} |
|||
expr "`f string`" |
|||
# Output from Bourne Shell: here \s\t\r\i\n\g |
|||
# Correct output: here string</lang> |
|||
The workaround is to move the backquotes to an assignment. |
|||
<lang bash>f() { |
|||
cat <<! |
|||
here $1 |
|||
! |
|||
} |
|||
var=`f string` |
|||
expr "$var" |
|||
# Output: here string</lang> |