diff options
author | 2006-02-15 05:57:47 +1000 | |
---|---|---|
committer | 2006-02-15 05:57:47 +1000 | |
commit | 8be3bf3e5db8519ac69c3372342c97418c82e5ff (patch) | |
tree | 4d31e0384ffbb006c6c9d5e12df5404f0b2d7093 /builtin.c | |
parent | 3e165297ce4a2f29117ff957c0e8946e0dd8b3ef (diff) |
Add support for checking current filename and current line nuber to status builtin
darcs-hash:20060214195747-ac50b-77b6aba42c99da4f79ea500c47cc00bba12ec663.gz
Diffstat (limited to 'builtin.c')
-rw-r--r-- | builtin.c | 34 |
1 files changed, 31 insertions, 3 deletions
@@ -1613,6 +1613,8 @@ static int builtin_status( wchar_t **argv ) IS_NO_JOB_CONTROL, STACK_TRACE, DONE, + CURRENT_FILENAME, + CURRENT_LINE_NUMBER } ; @@ -1659,6 +1661,14 @@ static int builtin_status( wchar_t **argv ) } , { + 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; |