if (strncmp(v, "PS1=", 4)==0)
PS1 = getenv("PS1");
else if (strncmp(v, "PS2=", 4)==0)
if (strncmp(v, "PS1=", 4)==0)
PS1 = getenv("PS1");
else if (strncmp(v, "PS2=", 4)==0)
for (i = 0; i < cmd->num_progs; i++) {
free(cmd->progs[i].argv);
if (cmd->progs[i].redirects)
free(cmd->progs[i].redirects);
}
for (i = 0; i < cmd->num_progs; i++) {
free(cmd->progs[i].argv);
if (cmd->progs[i].redirects)
free(cmd->progs[i].redirects);
}
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);
char *tmpcmd, *cmd, *cmd_copy;
/* We need a clean copy, so strsep can mess up the copy while
* we write stuff into the original (in a minute) */
char *tmpcmd, *cmd, *cmd_copy;
/* We need a clean copy, so strsep can mess up the copy while
* we write stuff into the original (in a minute) */
/* Convert from char** (one word per string) to a simple char*,
* but don't overflow command which is BUFSIZ in length */
for (i=0; i < expand_result.gl_pathc; i++) {
/* Convert from char** (one word per string) to a simple char*,
* but don't overflow command which is BUFSIZ in length */
for (i=0; i < expand_result.gl_pathc; 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;