Re: documentation... readonly help is not accurate

2013-03-04 Thread Chet Ramey
On 3/3/13 4:40 PM, Gotmy Nick wrote:
> Hello,
> 
>Sorry if this has been reported earlier, but I can't find nothing
> related in the archives.
> 
>   $ help readonly | grep -- '-p'
>   readonly: readonly [-aAf] [name[=value] ...] or readonly -p
> -pdisplay a list of all readonly variables and functions
> 
>   $ echo $BASH_VERSION
>   4.2.37(1)-release
> 
>I think the description should say "or" instead of "and". I think
> it's the sorter way to clarify the behavior.
> 
>This is, it will not print readonly functions unless called with
> -fp, and in such case, it will not print variables, so in my opinion,
> using "or" could be more accurate than "and".

This isn't accurate.  Run the following script:

foo()
{
echo foo
}
bar=quux

readonly foo
readonly bar

readonly

In addition to the built-in bash readonly variables, both bar and foo will
be listed.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/



Re: documentation... readonly help is not accurate

2013-03-04 Thread Gotmy Nick
On 4 March 2013 14:51, Chet Ramey  wrote:
>
> This isn't accurate.  Run the following script:
>
> foo()
> {
> echo foo
> }
> bar=quux
>
> readonly foo
> readonly bar
>
> readonly
>
> In addition to the built-in bash readonly variables, both bar and foo will
> be listed.

Maybe I'm wrong, but this is creating a variable "foo" which is empty.

After this, we can re-declare foo() and it works. For example foo() {
echo bar; }

But trying foo=1 fails (as we created a readonly variable).

Maybe this is more clear to explain what I was stating:

foo1 () { echo foo1; }
readonly -f foo1
foo2=1
readonly foo2
readonly -pf
readonly


Best regards

-- 
IƱigo Tejedor Arrondo