From 8be3bf3e5db8519ac69c3372342c97418c82e5ff Mon Sep 17 00:00:00 2001 From: axel Date: Wed, 15 Feb 2006 05:57:47 +1000 Subject: [PATCH] Add support for checking current filename and current line nuber to status builtin darcs-hash:20060214195747-ac50b-77b6aba42c99da4f79ea500c47cc00bba12ec663.gz --- builtin.c | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/builtin.c b/builtin.c index 8514dad8d..235902efa 100644 --- a/builtin.c +++ b/builtin.c @@ -1613,6 +1613,8 @@ static int builtin_status( wchar_t **argv ) IS_NO_JOB_CONTROL, STACK_TRACE, 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"current-filename", no_argument, &mode, CURRENT_FILENAME + } + , + { + L"current-line-number", no_argument, &mode, CURRENT_LINE_NUMBER + } + , { L"job-control", required_argument, 0, 'j' } @@ -1732,6 +1742,24 @@ static int builtin_status( wchar_t **argv ) 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: return !is_interactive_session; @@ -1766,9 +1794,9 @@ static int builtin_status( wchar_t **argv ) else sb_printf( sb_out, _( L"This is not a login shell\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_NONE?_(L"Never"):_(L"Always")) ); + 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_NONE ? _( L"Never" ) : _( L"Always" ) ) ); parser_stack_trace( current_block, sb_out ); break;