summaryrefslogtreecommitdiff
path: root/usr/src/lib/libshell/common/edit/completion.c
diff options
context:
space:
mode:
authorApril Chin <April.Chin@Sun.COM>2008-12-27 14:59:38 -0800
committerApril Chin <April.Chin@Sun.COM>2008-12-27 14:59:38 -0800
commit7c2fbfb345896881c631598ee3852ce9ce33fb07 (patch)
tree4b173b5657508562dfc0aa05f7d056d1e9add505 /usr/src/lib/libshell/common/edit/completion.c
parent6071ac1de68fed78e1e10052045bbb5f1732a263 (diff)
downloadillumos-gate-7c2fbfb345896881c631598ee3852ce9ce33fb07.tar.gz
PSARC/2008/094 ksh93 Update 1
PSARC/2008/344 ksh93 Integration Update 1 Amendments 1 PSARC/2008/589 Remove /usr/bin/printf from PSARC case 2008 094 6619428 *ksh93* RFE: Update ksh93 in Solaris to ast-ksh.2008-11-04 6788659 RFE: Update libpp in Solaris to ast-open.2008-07-25 6561901 RFE: Add "shcomp" (shell script compiler) + kernel module to exec binary sh code 6599668 RFE: Move consumers of alias.sh over to ksh93 6595183 *ksh93* RFE: Update ksh93-integration demo code 6775901 *ksh93* no C message catalogs are generated for ksh93 6451262 *sleep* RFE: /usr/bin/sleep should support floating-point values 6687139 *ksh93* command substitution, exec, and stdout redirection cause allocation loop 6703761 *ksh93* crashes in script containing uncommon output redirections 6715496 *ksh93* SEGVs on array reinitialization 6713682 *ksh93* Creating a compound variable in a subshell "bleeds through" to the calling subshell 6672350 *ksh93* causes parent shell to die when child shell is suspended 6745015 *ksh93* VARIABLE=`command substitution` assignment is not reliable on OpenSolaris 6710205 *ksh93* problem with command substitution (within back quotes) containing \$' 6737600 *ksh93* exits debugger when user presses ctrl-c 6748645 *ksh93* fc -l -e - is mis-parsed, outputs wrong error message "-e - requires single argument" 6754020 *ksh93* does weird '[' expansion 6753538 *ksh93* umask modification leaks out of a ksh93 subshell 6766246 *ksh93* bug in pattern matching 6763594 *ksh93* executes command after "command" builtin twice on failure 6762665 *ksh93* Difficult-to-reproduce SIGSEGV in ksh93
Diffstat (limited to 'usr/src/lib/libshell/common/edit/completion.c')
-rw-r--r--usr/src/lib/libshell/common/edit/completion.c34
1 files changed, 22 insertions, 12 deletions
diff --git a/usr/src/lib/libshell/common/edit/completion.c b/usr/src/lib/libshell/common/edit/completion.c
index 050019fbe5..54b4212470 100644
--- a/usr/src/lib/libshell/common/edit/completion.c
+++ b/usr/src/lib/libshell/common/edit/completion.c
@@ -1,10 +1,10 @@
/***********************************************************************
* *
* This software is part of the ast package *
-* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* Copyright (c) 1982-2008 AT&T Intellectual Property *
* and is licensed under the *
* Common Public License, Version 1.0 *
-* by AT&T Knowledge Ventures *
+* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* http://www.opensource.org/licenses/cpl1.0.txt *
@@ -68,7 +68,8 @@ static char *overlaid(register char *str,register const char *newstr,int nocase)
static char *find_begin(char outbuff[], char *last, int endchar, int *type)
{
register char *cp=outbuff, *bp, *xp;
- register int c,inquote = 0;
+ register int c,inquote = 0, inassign=0;
+ int mode=*type;
bp = outbuff;
*type = 0;
while(cp < last)
@@ -94,7 +95,7 @@ static char *find_begin(char outbuff[], char *last, int endchar, int *type)
if(inquote == '\'')
break;
c = *(unsigned char*)cp;
- if(isaletter(c) || c=='{')
+ if(mode!='*' && (isaletter(c) || c=='{'))
{
int dot = '.';
if(c=='{')
@@ -112,7 +113,7 @@ static char *find_begin(char outbuff[], char *last, int endchar, int *type)
if((c= mbchar(cp)) , c!=dot && !isaname(c))
break;
}
- if(cp>=last)
+ if(cp>=last && c!= '}')
{
*type='$';
return(++xp);
@@ -120,6 +121,7 @@ static char *find_begin(char outbuff[], char *last, int endchar, int *type)
}
else if(c=='(')
{
+ *type = mode;
xp = find_begin(cp,last,')',type);
if(*(cp=xp)!=')')
bp = xp;
@@ -129,6 +131,13 @@ static char *find_begin(char outbuff[], char *last, int endchar, int *type)
break;
case '=':
if(!inquote)
+ {
+ bp = cp;
+ inassign = 1;
+ }
+ break;
+ case ':':
+ if(!inquote && inassign)
bp = cp;
break;
case '~':
@@ -139,7 +148,10 @@ static char *find_begin(char outbuff[], char *last, int endchar, int *type)
if(c && c==endchar)
return(xp);
if(!inquote && ismeta(c))
+ {
bp = cp;
+ inassign = 0;
+ }
break;
}
}
@@ -172,7 +184,7 @@ int ed_expand(Edit_t *ep, char outbuff[],int *cur,int *eol,int mode, int count)
{
if(count> ep->e_nlist)
return(-1);
- mode = '*';
+ mode = '?';
av[0] = ep->e_clist[count-1];
av[1] = 0;
}
@@ -207,6 +219,7 @@ int ed_expand(Edit_t *ep, char outbuff[],int *cur,int *eol,int mode, int count)
register int c;
char *last = out;
c = *(unsigned char*)out;
+ var = mode;
begin = out = find_begin(outbuff,last,0,&var);
/* addstar set to zero if * should not be added */
if(var=='$')
@@ -234,6 +247,8 @@ int ed_expand(Edit_t *ep, char outbuff[],int *cur,int *eol,int mode, int count)
out++;
}
}
+ if(mode=='?')
+ mode = '*';
if(var!='$' && mode=='\\' && out[-1]!='*')
addstar = '*';
if(*begin=='~' && !strchr(begin,'/'))
@@ -264,7 +279,7 @@ int ed_expand(Edit_t *ep, char outbuff[],int *cur,int *eol,int mode, int count)
}
else
{
- com = sh_argbuild(&narg,comptr,0);
+ com = sh_argbuild(ep->sh,&narg,comptr,0);
/* special handling for leading quotes */
if(begin>outbuff && (begin[-1]=='"' || begin[-1]=='\''))
begin--;
@@ -373,14 +388,9 @@ int ed_expand(Edit_t *ep, char outbuff[],int *cur,int *eol,int mode, int count)
{
Namval_t *np;
/* add as tracked alias */
-#ifdef PATH_BFPATH
Pathcomp_t *pp;
if(*cp=='/' && (pp=path_dirfind(sh.pathlist,cp,'/')) && (np=nv_search(begin,sh.track_tree,NV_ADD)))
path_alias(np,pp);
-#else
- if(*cp=='/' && (np=nv_search(begin,sh.track_tree,NV_ADD)))
- path_alias(np,cp);
-#endif
out = strcopy(begin,cp);
}
/* add quotes if necessary */