Differences between declare, typeset and local variable in Bash

  • Difference between typeset and declare:

The former is more portable(e.g. ksh), while the latter is more preferable when portability is not a concern.

  • Difference between declare(or typeset) and local when used inside a function:

The former implies the latter, but more powerful. For example, declare -i x makes x have the integer attribute, declare -r x makes x readonly, etc.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)