fortypoundhead.com

DECLARE

Posted On 2007-04-27 by FortyPoundHead
Keywords: Command Reference
Tags: Linux Commandline Linux
Views: 1435


Declare variables and give them attributes.

SYNTAX
declare [-afFrxi] [-p] [name[=value]]

OPTIONS

-a Each name is an array variable.

-f Use function names only.
-F Inhibit the display of function definitions;
only the function name and attributes are printed.
(implies -f)

-i The variable is to be treated as an integer;
arithmetic evaluation is performed when the
variable is assigned a value.
-p Display the attributes and values of each name.
When `-p'' is used, additional options are ignored.

-r Make names readonly. These names cannot then be assigned values by subsequent assignment statements
or unset.
-x Mark each name for export to subsequent commands via the environment.If no names are given, then `declare'' will display the values of variables instead.

Using `+'' instead of `-'' turns off the attribute instead.

When used in a function, declare makes each name local, as with the local command.

The typeset command is supplied for compatibility with the Korn shell; however, it has been deprecated in favor of the declare builtin command.

The return status is zero unless an invalid option is encountered, an attempt is made to define a function using `-f foo=bar'', an attempt is made to assign a value to a readonly variable, an attempt is made to assign a value to an array variable without using the compound assignment syntax , one of the names is not a valid shell variable name, an attempt is made to turn off readonly status for a readonly variable, an attempt is made to turn off array status for an array variable, or an attempt is made to display a non-existent function with `-f''.


About the Author

FortyPoundHead has posted a total of 1974 articles.

 


Comments On This Post

No comments on this post yet!


Do you have a thought relating to this post? You can post your comment here. If you have an unrelated question, you can use the Q&A section to ask it.

Or you can drop a note to the administrators if you're not sure where you should post.


Your IP address is:54.224.50.28

Before you can post, you need to prove you are human. If you log in, this test goes away.




Recent Forum Posts

Advanced search added
dwirch posted on September 23, 2017 at about 13:44 in Site News

Job Spammer: Gaurav Mehta - AgreeYa Solutions
dwirch posted on September 22, 2017 at about 10:35 in Spammers

Job Spammer: Prutha Siri - Javelin Systems
dwirch posted on September 10, 2017 at about 6:15 in Spammers

New security implemented
dwirch posted on September 7, 2017 at about 7:16 in Site News

Malicious IP Checker Companion Tool
dwirch posted on August 12, 2017 at about 20:24 in Site News

Job Spammer: Steve Adams
dwirch posted on August 8, 2017 at about 7:44 in Spammers