38

I can type

alias

and get a list of defined aliases in zsh

How can I get a list of function names defined in zsh?

When I type "functions", my shell window hangs after displaying lots of functions, always ending at

__rvm_checksum_none () {
    [[ -z "${_checksum_md5:-}" && -z "${_checksum_sha512:-}" ]]
}
__rvm_checksum_read () {

What's super annoying is that this won't quit with ctrl-c (using item2 AND terminal).

iterm2: enter image description here

Picture of terminal having the same issue: enter image description here

justingordon
  • 1,613
  • Usually the listing is done with the functions builtin. Do you get an output if you undefine the problematic(?) function first: unfunction __rvm_checksum_read? – mpy Dec 04 '13 at 19:13
  • What if I want to get the functions list (not full declarations)? If I unfunction that method, another __rvm_curl also has issues. – justingordon Dec 05 '13 at 02:08
  • See my answer. But the behavior you describe sounds strange... so just out of interest: Does the full listing work with another terminal emulator? Can you use the problematic functions successful? – mpy Dec 05 '13 at 09:09
  • terminal has the same issue as item 2. The answer below is AWESOME. While I'd like to know why the terminal hangs just using the 'functions' command (even when piped to less), does it matter? Any reason this will cause issues? – justingordon Dec 05 '13 at 20:31
  • I supposed there are some really strange character sequences in these functions which mess up the terminal. To narrow this down you could redirect the output to a file functions > /tmp/foo. If it's a zsh problem this should've issue, too. When it's a terminal problem it shouldn't. If your problem may interfere with everyday's usage -- I could not say, sorry. – mpy Dec 05 '13 at 23:16
  • functions > /tmp/foo also hangs, with the last bit being written as "__rvm_checksum_read () {". I'm guessing that method must have some characters that zsh doesn't like. – justingordon Dec 06 '13 at 03:29
  • Just some last clues, which come to my mind: (1) Do you use a recent version of zsh? (2) Can you use e.g. the __rvm_checksum_read function or does this hang the shell, too? (3) Can you use which __rvm_checksum_read to display the function successful? – mpy Dec 06 '13 at 11:53
  • which __rvm_checksum_read hangs as well. Contents are:
  • – justingordon Dec 06 '13 at 21:31
  • __rvm_checksum_read () { __rvm_checksum_none || return 0 typeset _type _value _name typeset -a _list list=() for _name in "$@" do list+=("$_name") if [[ "$_name" =~ "?" ]] then repeat st do if then for _name in "${list[@]}" do _checksum_md5="$( "$rvm_scripts_path/db" "$rvm_path/config/md5" "$_name" | head -n 1 )" [[ -n "${_checksum_md5:-}" ]] || _checksum_md5="$( "$rvm_scripts_path/db" "$rvm_user_path/md5" "$_name" | head -n 1 )" – justingordon Dec 06 '13 at 21:32
  • _checksum_sha512="$( "$rvm_scripts_path/db" "$rvm_path/config/sha512" "$_name" | head -n 1 )" [[ -n "${_checksum_sha512:-}" ]] || _checksum_sha512="$( "$rvm_scripts_path/db" "$rvm_user_path/sha512" "$_name" | head -n 1 )" __rvm_checksum_none || return 0 done return 1 fi done fi done

    }

    – justingordon Dec 06 '13 at 21:32
  • most current zsh, 2) function __rvm_checksum_read runs, and returns error code 1
  • – justingordon Dec 06 '13 at 21:33
  • I'm sorry, a cannot see a problem in these functions... – mpy Dec 07 '13 at 23:00