diff options
author | Peter Stephenson <pws@users.sourceforge.net> | 2008-09-16 15:02:01 +0000 |
---|---|---|
committer | Peter Stephenson <pws@users.sourceforge.net> | 2008-09-16 15:02:01 +0000 |
commit | 2920c227d3f8e6d8af1f2b0c3163badb95cde9b5 (patch) | |
tree | 854021a4e3cfa7a72bf67a364ce55e6803ca800b /Src/prompt.c | |
parent | 14905ddc74f78b54c75434c8a4d7e029b1933280 (diff) | |
download | zsh-2920c227d3f8e6d8af1f2b0c3163badb95cde9b5.tar.gz zsh-2920c227d3f8e6d8af1f2b0c3163badb95cde9b5.tar.xz zsh-2920c227d3f8e6d8af1f2b0c3163badb95cde9b5.zip |
25677: add %x and %I prompt escapes for shell source code debugging
tidy up interface to doshfunc()
Diffstat (limited to 'Src/prompt.c')
-rw-r--r-- | Src/prompt.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/Src/prompt.c b/Src/prompt.c index 36eaca3e9..7bba51c61 100644 --- a/Src/prompt.c +++ b/Src/prompt.c @@ -725,11 +725,37 @@ putpromptchar(int doprint, int endchar, unsigned int *txtchangep) if(Rstring) stradd(Rstring); break; + case 'I': + if (funcstack && funcstack->tp != FS_SOURCE) { + /* + * We're in a function or an eval with + * EVALLINENO. Calculate the line number in + * the file. + */ + zlong flineno = lineno + funcstack->flineno; + /* take account of eval line nos. starting at 1 */ + if (funcstack->tp == FS_EVAL) + lineno--; + addbufspc(DIGBUFSIZE); + sprintf(bp, "%ld", (long)flineno); + bp += strlen(bp); + break; + } + /* else we're in a file and lineno is already correct */ + /* FALLTHROUGH */ case 'i': addbufspc(DIGBUFSIZE); sprintf(bp, "%ld", (long)lineno); bp += strlen(bp); break; + case 'x': + if (funcstack && funcstack->tp != FS_SOURCE) + promptpath(funcstack->filename ? funcstack->filename : "", + arg, 0); + else + promptpath(scriptfilename ? scriptfilename : argzero, + arg, 0); + break; case '\0': return 0; case Meta: |