Bash declare/typeset: Difference between revisions
Jump to navigation
Jump to search
(→-f) |
(→-t) |
||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
=External= | |||
* https://www.gnu.org/software/bash/manual/html_node/Bash-Builtins.html | |||
=Internal= | =Internal= | ||
Line 35: | Line 38: | ||
Also see: {{Internal|Bash_Functions#Function_Info|Function Info}} | Also see: {{Internal|Bash_Functions#Function_Info|Function Info}} | ||
==-t== | |||
Used to detect when variables are used, with [[Trap|trap]]. Give each name the "trace" attribute. Traced functions inherit the [[Trap#DEBUG|DEBUG]] and [[Trap#RETURN|RETURN]] traps from the calling shell. The trace attribute has no special meaning for variables. |
Latest revision as of 22:27, 23 July 2020
External
Internal
Overview
declare and typeset are equivalent.
Options
-p
Without an argument, the command will display the attributes and values of each variable name.
-F
Returns the name of the functions declared in the current context. Returns output similar to:
declare -f backup declare -f comma_separated_list_to_space_separated declare -f debug declare -f debug_args declare -f debug_args_no_nl declare -f get_user_name ...
Also see:
-f
Returns a functions' body.
typeset -f declare -f
Also see:
-t
Used to detect when variables are used, with trap. Give each name the "trace" attribute. Traced functions inherit the DEBUG and RETURN traps from the calling shell. The trace attribute has no special meaning for variables.