Adding '--rename' option to 'functions' builtin.

Aim is to allow an existing function to be renamed, allowing some basic function chaining.

Example:

> function foo
     echo Hello
  end
> foo
Hello
> functions --rename foo bar
> foo
fish: Unknown command 'foo'
> bar
Hello
> functions --rename fish_prompt old_prompt
> function fish_prompt
      printf "{Boo!}%s" (old_prompt)
  end
{Boo!}>

Note in the last case, the new fish_prompt is calling its old definition.
This commit is contained in:
Christopher Nilsson
2010-09-08 03:31:05 +10:00
parent 1eb089d722
commit 208be0f4d4
3 changed files with 134 additions and 7 deletions

View File

@@ -131,4 +131,15 @@ array_list_t *function_get_named_arguments( const wchar_t *name );
*/
int function_get_shadows( const wchar_t *name );
/**
Creates a new function using the same definition as the specified function.
Returns non-zero if copy is successful.
*/
int function_copy( const wchar_t *name, const wchar_t *new_name );
/**
Renames the specified function.
*/
void function_rename( const wchar_t *name, const wchar_t *new_name );
#endif