@@ -121,24 +121,28 @@ int compl_cmds(const char *prefix, int print, int *r_len, char *r_p)
121
121
struct cmpl_s cmpl = { };
122
122
glob_t gl_bat , gl_exe , gl_com ;
123
123
int err , ret = -1 , cnt = 0 ;
124
+ const char * p ;
125
+ const char * suff = ((p = strchr (prefix , '.' )) ? "" : "*." );
124
126
125
- snprintf (buf , MAXPATH , "%s*.bat" , prefix );
127
+ if (p && p [1 ] != '\0' )
128
+ return compl_fname (prefix , print , r_len , r_p );
129
+ snprintf (buf , MAXPATH , "%s%sbat" , prefix , suff );
126
130
err = glob (buf , GLOB_ERR , NULL , & gl_bat );
127
131
if (err && err != GLOB_NOMATCH )
128
132
return -1 ;
129
133
if (!err ) {
130
134
glb_add (& cmpl , & gl_bat );
131
135
cnt += gl_bat .gl_pathc ;
132
136
}
133
- snprintf (buf , MAXPATH , "%s*.exe " , prefix );
137
+ snprintf (buf , MAXPATH , "%s%sexe " , prefix , suff );
134
138
err = glob (buf , GLOB_ERR , NULL , & gl_exe );
135
139
if (err && err != GLOB_NOMATCH )
136
140
goto err1 ;
137
141
if (!err ) {
138
142
glb_add (& cmpl , & gl_exe );
139
143
cnt += gl_exe .gl_pathc ;
140
144
}
141
- snprintf (buf , MAXPATH , "%s*.com " , prefix );
145
+ snprintf (buf , MAXPATH , "%s%scom " , prefix , suff );
142
146
err = glob (buf , GLOB_ERR , NULL , & gl_com );
143
147
if (err && err != GLOB_NOMATCH )
144
148
goto err2 ;
@@ -147,13 +151,15 @@ int compl_cmds(const char *prefix, int print, int *r_len, char *r_p)
147
151
cnt += gl_com .gl_pathc ;
148
152
}
149
153
150
- cmpl .compls [cmpl .num ].opaque = cmd_table ;
151
- cmpl .compls [cmpl .num ].get_name = get_cmd_name ;
152
- cmpl .compls [cmpl .num ].num = CMD_TABLE_COUNT ;
153
- cmpl .num ++ ;
154
+ if (!p ) {
155
+ cmpl .compls [cmpl .num ].opaque = cmd_table ;
156
+ cmpl .compls [cmpl .num ].get_name = get_cmd_name ;
157
+ cmpl .compls [cmpl .num ].num = CMD_TABLE_COUNT ;
158
+ cmpl .num ++ ;
159
+ cnt += CMD_TABLE_COUNT ;
160
+ }
154
161
155
- ret = do_compl (prefix , print , r_len , r_p , get_compl_name , & cmpl ,
156
- CMD_TABLE_COUNT + cnt );
162
+ ret = do_compl (prefix , print , r_len , r_p , get_compl_name , & cmpl , cnt );
157
163
158
164
globfree (& gl_com );
159
165
err2 :
0 commit comments