mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-12 07:57:22 +00:00
Add support for checking current filename and current line nuber to status builtin
darcs-hash:20060214195747-ac50b-77b6aba42c99da4f79ea500c47cc00bba12ec663.gz
This commit is contained in:
parent
3e165297ce
commit
8be3bf3e5d
1 changed files with 31 additions and 3 deletions
34
builtin.c
34
builtin.c
|
@ -1613,6 +1613,8 @@ static int builtin_status( wchar_t **argv )
|
||||||
IS_NO_JOB_CONTROL,
|
IS_NO_JOB_CONTROL,
|
||||||
STACK_TRACE,
|
STACK_TRACE,
|
||||||
DONE,
|
DONE,
|
||||||
|
CURRENT_FILENAME,
|
||||||
|
CURRENT_LINE_NUMBER
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -1658,6 +1660,14 @@ static int builtin_status( wchar_t **argv )
|
||||||
L"is-no-job-control", no_argument, &mode, IS_NO_JOB_CONTROL
|
L"is-no-job-control", no_argument, &mode, IS_NO_JOB_CONTROL
|
||||||
}
|
}
|
||||||
,
|
,
|
||||||
|
{
|
||||||
|
L"current-filename", no_argument, &mode, CURRENT_FILENAME
|
||||||
|
}
|
||||||
|
,
|
||||||
|
{
|
||||||
|
L"current-line-number", no_argument, &mode, CURRENT_LINE_NUMBER
|
||||||
|
}
|
||||||
|
,
|
||||||
{
|
{
|
||||||
L"job-control", required_argument, 0, 'j'
|
L"job-control", required_argument, 0, 'j'
|
||||||
}
|
}
|
||||||
|
@ -1732,6 +1742,24 @@ static int builtin_status( wchar_t **argv )
|
||||||
|
|
||||||
switch( mode )
|
switch( mode )
|
||||||
{
|
{
|
||||||
|
case CURRENT_FILENAME:
|
||||||
|
{
|
||||||
|
const wchar_t *fn = parser_current_filename();
|
||||||
|
|
||||||
|
if( !fn )
|
||||||
|
fn = _(L"Standard input");
|
||||||
|
|
||||||
|
sb_printf( sb_out, L"%ls\n", fn );
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case CURRENT_LINE_NUMBER:
|
||||||
|
{
|
||||||
|
sb_printf( sb_out, L"%d\n", parser_get_lineno() );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case IS_INTERACTIVE:
|
case IS_INTERACTIVE:
|
||||||
return !is_interactive_session;
|
return !is_interactive_session;
|
||||||
|
|
||||||
|
@ -1766,9 +1794,9 @@ static int builtin_status( wchar_t **argv )
|
||||||
else
|
else
|
||||||
sb_printf( sb_out, _( L"This is not a login shell\n" ) );
|
sb_printf( sb_out, _( L"This is not a login shell\n" ) );
|
||||||
|
|
||||||
sb_printf( sb_out, _(L"Job control: %ls\n"),
|
sb_printf( sb_out, _( L"Job control: %ls\n" ),
|
||||||
job_control_mode==JOB_CONTROL_INTERACTIVE?_(L"Only on interactive jobs"):
|
job_control_mode==JOB_CONTROL_INTERACTIVE?_( L"Only on interactive jobs" ):
|
||||||
(job_control_mode==JOB_CONTROL_NONE?_(L"Never"):_(L"Always")) );
|
(job_control_mode==JOB_CONTROL_NONE ? _( L"Never" ) : _( L"Always" ) ) );
|
||||||
|
|
||||||
parser_stack_trace( current_block, sb_out );
|
parser_stack_trace( current_block, sb_out );
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue