mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
'functions --copy': added sanity check on new function name.
Now matches function create behaviour, running the new function name through wcsfuncname() and parser_keywords_is_reserved(), before allowing the copy.
This commit is contained in:
parent
7914c92824
commit
5c9b42e260
2 changed files with 10 additions and 2 deletions
10
builtin.c
10
builtin.c
|
@ -1471,6 +1471,16 @@ static int builtin_functions( wchar_t **argv )
|
|||
return STATUS_BUILTIN_ERROR;
|
||||
}
|
||||
|
||||
if( (wcsfuncname( new_func ) != 0) || parser_keywords_is_reserved( new_func ) )
|
||||
{
|
||||
sb_printf( sb_err,
|
||||
_( L"%ls: Illegal function name '%ls'\n"),
|
||||
argv[0],
|
||||
new_func );
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
return STATUS_BUILTIN_ERROR;
|
||||
}
|
||||
|
||||
// keep things simple: don't allow existing names to be copy targets.
|
||||
if( function_exists( new_func ) )
|
||||
{
|
||||
|
|
|
@ -226,8 +226,6 @@ int function_copy( const wchar_t *name, const wchar_t *new_name )
|
|||
CHECK( name, 0 );
|
||||
CHECK( new_name, 0 );
|
||||
|
||||
fn_events = 0;
|
||||
|
||||
orig_d = (function_internal_data_t *)hash_get(&function, name);
|
||||
if( !orig_d )
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue