aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--builtin.c2
-rw-r--r--common.c6
-rw-r--r--common.h8
-rw-r--r--doc_src/function.txt2
4 files changed, 16 insertions, 2 deletions
diff --git a/builtin.c b/builtin.c
index 23feee57..7b1dac54 100644
--- a/builtin.c
+++ b/builtin.c
@@ -1281,7 +1281,7 @@ static int builtin_function( wchar_t **argv )
argc-woptind );
res=1;
}
- else if( !(is_binding?wcsbindingname( argv[woptind] ) : !wcsvarname( argv[woptind] ) ))
+ else if( wcsfuncname( argv[woptind] ) )
{
sb_printf( sb_err,
_( L"%ls: Illegal function name '%ls'\n" ),
diff --git a/common.c b/common.c
index ca05b369..65f73af0 100644
--- a/common.c
+++ b/common.c
@@ -421,6 +421,12 @@ wchar_t *wcsvarname( const wchar_t *str )
return 0;
}
+wchar_t *wcsfuncname( const wchar_t *str )
+{
+ return wcschr( str, L'/' );
+}
+
+
int wcsvarchr( wchar_t chr )
{
return ( (iswalnum(chr)) || (chr == L'_' ));
diff --git a/common.h b/common.h
index 5aa6c276..f6cfcc0a 100644
--- a/common.h
+++ b/common.h
@@ -211,6 +211,14 @@ wchar_t *wcsvarname( const wchar_t *str );
/**
+ Test if the given string is a valid function name.
+
+ \return null if this is a valid name, and a pointer to the first invalid character otherwise
+*/
+
+wchar_t *wcsfuncname( const wchar_t *str );
+
+/**
Test if the given string is valid in a variable name
\return 1 if this is a valid name, 0 otherwise
diff --git a/doc_src/function.txt b/doc_src/function.txt
index 37ed23fc..75bf9e88 100644
--- a/doc_src/function.txt
+++ b/doc_src/function.txt
@@ -5,7 +5,7 @@
\subsection function-description Description
-- \c -b or \c --key-binding specifies that the function is a key biding. Key binding functions work exactly like regular functions except that they can not be tab-completed, and may contain the '-' character.
+- \c -b or \c --key-binding specifies that the function is a key biding. Key binding functions work exactly like regular functions except that they can not be tab-completed.
- <code>-d DESCRIPTION</code> or \c --description=DESCRIPTION is a description of what the function does, suitable as a completion description
- <code>-j PID</code> or <code> --on-job-exit PID</code> tells fish to run this function when the job with group id PID exits. Instead of PID, the string 'caller' can be specified. This is only legal when in a command substitution, and will result in the handler being triggered by the exit of the job which created this command substitution.
- <code>-p PID</code> or <code> --on-process-exit PID</code> tells fish to run this function when the fish child process with process id PID exits