Differences between revisions 4 and 5
Revision 4 as of 2009-02-10 00:14:19
Size: 1657
Editor: GreyCat
Comment: database queries
Revision 5 as of 2009-02-11 03:38:36
Size: 1990
Editor: localhost
Comment: minor "binary data" changes, minor cleanup of capitalisations, addition of "variable names" problem
Deletions are marked like this. Additions are marked like this.
Line 15: Line 15:
 * Binary data, bash has no way to store the null byte, so  binary data has to be encoded to be put in a variable. Parsing binary data is also a problem. Try Perl or C.   * Binary data.  Bash has no way to store the null byte, so binary data either has to be encoded or placed awkwardly in an array.  Parsing binary data is also a problem.  Try perl or C.
Line 17: Line 17:
 * Text Processing. Though bash has fairly advanced string manipulation features it's not designed for this. The shell is made to run commands, if are only processing text, an AWK or perl script is going to be much much MUCH faster. If you are going to process text with bash, be sure to learn about the pitfalls associated with read.  * Text Processing.  Though Bash has fairly advanced string manipulation features it's not designed for this.  The shell is made to run commands, if are only processing text, an AWK or perl script is going to be much much MUCH faster.  If you are going to process text with bash, be sure to learn about the pitfalls associated with `read`.
Line 19: Line 19:
 * Database queries. When retrieving a tuple from a relational database, there is no way for bash to understand where one element of the tuple ends and the next begins. In general, bash is not suited to any sort of data retrieval that extracts multiple data values in a single operation, unless there is a clearly defined delimiter between fields. For database queries (SQL or otherwise), switch to a language that supports the database's query API.  * Database queries. When retrieving a tuple from a relational database, there is no way for Bash to understand where one element of the tuple ends and the next begins. In general, Bash is not suited to any sort of data retrieval that extracts multiple data values in a single operation, unless there is a clearly defined delimiter between fields. For database queries (SQL or otherwise), switch to a language that supports the database's query API.

 * Variable declarations. While you can do some limited amount of declaration with the builtin declare command, There is no protection against misspelling variable names. In each case where you type a variable name wrong, you will have to run the program, discover that it fails, and waste time finding it.

This is a stub. Please fill in the missing pieces.

There are certain things BASH is not very good at. There are certain tasks you shouldn't do in bash, unless you really, truly have to. It's often better to switch to a different language for most of these tasks.

  • Floating point math. Bash has only integer math. Use bc(1) or AWK instead.

  • Associative arrays (coming in bash 4.0). Use AWK or perl or Tcl instead.
  • Fancy ProcessManagement. Bash has nothing analogous to select(2) or poll(2). Use C instead.

  • XML and HTML (or alike) parsing. You'd need external tools for that, at best, use Perl.
  • Binary data. Bash has no way to store the null byte, so binary data either has to be encoded or placed awkwardly in an array. Parsing binary data is also a problem. Try perl or C.
  • Text Processing. Though Bash has fairly advanced string manipulation features it's not designed for this. The shell is made to run commands, if are only processing text, an AWK or perl script is going to be much much MUCH faster. If you are going to process text with bash, be sure to learn about the pitfalls associated with read.

  • Database queries. When retrieving a tuple from a relational database, there is no way for Bash to understand where one element of the tuple ends and the next begins. In general, Bash is not suited to any sort of data retrieval that extracts multiple data values in a single operation, unless there is a clearly defined delimiter between fields. For database queries (SQL or otherwise), switch to a language that supports the database's query API.
  • Variable declarations. While you can do some limited amount of declaration with the builtin declare command, There is no protection against misspelling variable names. In each case where you type a variable name wrong, you will have to run the program, discover that it fails, and waste time finding it.

BashWeaknesses (last edited 2022-09-01 18:14:07 by 188)