Skip to contentSkip to conversation

How to list functions?

DISCUSSION Alexander Huemer 2 participants 3 messages Oct 22, 2013

lore
Share & tools
lore
#0 lore raw

Hi,

posh has support for functions.

$ f() { echo foo; }
$ f
foo
$ 

Unfortunately I am unable to list the defined functions.
I tried typeset, declare and set without success in posh 0.10.2 on Debain Wheezy.
Any hints very welcome.
Thanks in advance.

Kind regards,
-Alex

#1 lore raw
Quoted 3 lines · Alexander Huemer

Hi,

posh has support for functions.

Wrong list. posh is a different shell than dash, so there's nothing this list can do to change posh.

Quoted 8 lines
$ f() { echo foo; }
$ f
foo
$ 

Unfortunately I am unable to list the defined functions.
I tried typeset, declare and set without success in posh 0.10.2 on

posh tries hard to limit itself to POSIX (which does not yet define 'typeset', lacks 'declare', and where 'set' does not list function bodies). As far as I can see, POSIX doesn't require shells to be able to output function bodies. For posh to provide this, they'd have to give you an extension beyond POSIX; but that goes against the goals of posh. Sorry.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#2 lore raw
In reply to Alexander Huemer
Quoted 3 lines · Alexander Huemer

Hi,

posh has support for functions.

Wrong list. posh is a different shell than dash, so there's nothing this list can do to change posh.

Quoted 8 lines
$ f() { echo foo; }
$ f
foo
$ 

Unfortunately I am unable to list the defined functions.
I tried typeset, declare and set without success in posh 0.10.2 on

posh tries hard to limit itself to POSIX (harder than dash), and POSIX does not yet define 'typeset', lacks 'declare', and does not require 'set' to list function bodies. Thus, as far as I can see, POSIX doesn't require shells to be able to output function bodies. For posh to provide this, they'd have to give you an extension beyond POSIX; but that goes against the goals of posh. Sorry.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org