mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-27 20:25:12 +00:00
Make error message for ${foo}-type errors nicer
darcs-hash:20060720233319-ac50b-a5ffbe91b3c7dceba9f0f5e67a6e044fc5508f47.gz
This commit is contained in:
parent
4ba9ac28bb
commit
8c4708b51e
1 changed files with 39 additions and 5 deletions
44
expand.c
44
expand.c
|
@ -59,7 +59,7 @@ parameter expansion.
|
||||||
/**
|
/**
|
||||||
Error issued on invalid variable name
|
Error issued on invalid variable name
|
||||||
*/
|
*/
|
||||||
#define COMPLETE_VAR_BRACKET_DESC _( L"Did you mean {$VARIABLE}? The '$' character begins a variable name. A bracket, which directly followed a '$', is not allowed as a part of a variable name, and variable names may not be zero characters long. To learn more about variable expansion in fish, type 'help expand-variable'." )
|
#define COMPLETE_VAR_BRACKET_DESC _( L"Did you mean %ls{$%ls}%ls? The '$' character begins a variable name. A bracket, which directly followed a '$', is not allowed as a part of a variable name, and variable names may not be zero characters long. To learn more about variable expansion in fish, type 'help expand-variable'." )
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Error issued on invalid variable name
|
Error issued on invalid variable name
|
||||||
|
@ -678,9 +678,43 @@ void expand_variable_error( const wchar_t *token, int token_pos, int error_pos )
|
||||||
{
|
{
|
||||||
case BRACKET_BEGIN:
|
case BRACKET_BEGIN:
|
||||||
{
|
{
|
||||||
error( SYNTAX_ERROR,
|
wchar_t *cpy = wcsdup( token );
|
||||||
error_pos,
|
*(cpy+token_pos)=0;
|
||||||
COMPLETE_VAR_BRACKET_DESC );
|
wchar_t *name = &cpy[stop_pos+1];
|
||||||
|
wchar_t *end = wcschr( name, BRACKET_END );
|
||||||
|
wchar_t *post;
|
||||||
|
int is_var=0;
|
||||||
|
if( end )
|
||||||
|
{
|
||||||
|
post = end+1;
|
||||||
|
*end = 0;
|
||||||
|
|
||||||
|
if( !wcsvarname( name ) )
|
||||||
|
{
|
||||||
|
is_var = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( is_var )
|
||||||
|
{
|
||||||
|
error( SYNTAX_ERROR,
|
||||||
|
error_pos,
|
||||||
|
COMPLETE_VAR_BRACKET_DESC,
|
||||||
|
cpy,
|
||||||
|
name,
|
||||||
|
post );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
error( SYNTAX_ERROR,
|
||||||
|
error_pos,
|
||||||
|
COMPLETE_VAR_BRACKET_DESC,
|
||||||
|
L"",
|
||||||
|
L"VARIABLE",
|
||||||
|
L"" );
|
||||||
|
}
|
||||||
|
free( cpy );
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -688,7 +722,7 @@ void expand_variable_error( const wchar_t *token, int token_pos, int error_pos )
|
||||||
{
|
{
|
||||||
error( SYNTAX_ERROR,
|
error( SYNTAX_ERROR,
|
||||||
error_pos,
|
error_pos,
|
||||||
COMPLETE_VAR_PARAN_DESC );
|
COMPLETE_VAR_PARAN_DESC );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue