This is an old revision of the document!


Obsolete and deprecated syntax

Here's a (probably incomplete) table of syntax and commands I consider obsolete. Unfortunately these syntax elements are still suggested in many Bash and general shell guides I've seen.

However, these suggestions may collide with the POSIX standard - they are obsolete for Bash, not obsolete for general scripting! Also this page overlaps with the portability page, of course.

&>FILE and >&FILE This redirection syntax is short for >FILE 2>&1 and originates in the Bourne Shell. It's very old and not part of POSIX. However, it's useful in interactive shells, to save typing, but don't use it in scripts. See redirection
$[EXPRESSION] This syntax is completely replaced by the POSIX-conform arithmetic expansion $((EXPRESSION)). See arithmetic expansion
`COMMANDS` This is an older form of the command substitution. The usage of the POSIX-form $(COMMANDS) is preferred.
function NAME { …; } This form of the function definition is not recommended, it's not POSIX. Simply use NAME() { …; } to define a function. See shell function definitions
let "MATH"This is the classic form of the arithmetic evaluation command. Bash has an own compound command for that, which should be used if possible: ((MATH)). See arithmetic evaluation compound command
[ EXPRESSION ]
and
test EXPRESSION
This is the old-fashioned test command. Due to its nature, it has several disadvantages. Use the conditional expression ("new test command") [[ EXPRESSION ]]

See also

Discussion

Enter your comment. Wiki syntax is allowed: