while( command && command[index]) {
if (command[index] == '\\') {
char *tmp = command+index+1;
while( command && command[index]) {
if (command[index] == '\\') {
char *tmp = command+index+1;
- command[index+1] = process_escape_sequence( &tmp );
- memmove(command+index, command+index+1, strlen(command+index));
+ command[index] = process_escape_sequence( &tmp );
+ memmove(command+index + 1, tmp, strlen(tmp)+1);
/* This first part uses wordexp() which is a wonderful C lib
* function which expands nearly everything. */
retval = wordexp (command, &expand_result, WRDE_SHOWERR);
/* This first part uses wordexp() which is a wonderful C lib
* function which expands nearly everything. */
retval = wordexp (command, &expand_result, WRDE_SHOWERR);
* but don't overflow command which is BUFSIZ in length */
for (i=0; i < expand_result.gl_pathc; i++) {
length=strlen(expand_result.gl_pathv[i]);
* but don't overflow command which is BUFSIZ in length */
for (i=0; i < expand_result.gl_pathc; i++) {
length=strlen(expand_result.gl_pathv[i]);
int dstlen = strlen(dst);
/* Is this a ${foo} type variable? */
if (dstlen >=2 && *(dst+1) == '{') {
src=strchr(dst+1, '}');
int dstlen = strlen(dst);
/* Is this a ${foo} type variable? */
if (dstlen >=2 && *(dst+1) == '{') {
src=strchr(dst+1, '}');
}
/* Move stuff to the end of the string to accommodate
* filling the created gap with the new stuff */
}
/* Move stuff to the end of the string to accommodate
* filling the created gap with the new stuff */
- memmove(dst+subst_len, src, trail_len);
- *(dst+subst_len+trail_len)='\0';
+ memmove(dst+subst_len, src, trail_len+1);
/* Now copy in the new stuff */
memcpy(dst, var, subst_len);
src = dst+subst_len;
/* Now copy in the new stuff */
memcpy(dst, var, subst_len);
src = dst+subst_len;