mainThe GNU Bourne-Again SHell - Support: sr #110821, declare -p not functioning as...

 
 

sr #110821: declare -p not functioning as expected with functions

Submitter:  Martin Anantharaman <manantharaman>
Submitted:  Sat 21 Jan 2023 06:14:19 AM UTC
   
 
Category:  None Priority:  5 - Normal
Severity:  3 - Normal Status:  Invalid
Privacy:  Public Assigned to:  None
Open/Closed:  Open Operating System:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 24 Jan 2023 09:03:21 PM UTC, comment #1: 

`declare' deals with variables unless told to treat its arguments as function names using `-f'.

The `-F' option is for use by the debugger, and prints the function name and attributes. If you enable extdebug, it prints the source file name and line number, too.

Everything is working as intended.

Chet Ramey <chet>
Group administrator
Sat 21 Jan 2023 06:14:19 AM UTC, original submission:  

Using type and declare to detect type of definitions (including functionsI found this:
[martin@MartinsAspire ~]$ function f { echo this is function f; }
[martin@MartinsAspire ~]$ type f
f ist eine Funktion.
f ()
{
    echo this is function f
}
[martin@MartinsAspire ~]$ type -t f
function
[martin@MartinsAspire ~]$ declare -p f
bash: declare: f: Nicht gefunden.
[martin@MartinsAspire ~]$ declare -pf f
f ()
{
    echo this is function f
}
[martin@MartinsAspire ~]$ declare -pF f
declare -f f
[martin@MartinsAspire ~]$

... where the unexpected behaviour is in bold. In the case of "declare -p f" I'd say this is wrong, and in case of "declare -pF f" questionable (what's it supposed to convey, how can it be used?).

Martin Anantharaman <manantharaman>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by chet (Posted a comment)
  • -email is unavailable- added by manantharaman (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-01-24 chet StatusNone Invalid

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code