'ls *.h Config.h' works. Fixed a silly typo with fg/bg process control.
Made cmdedit exit sanely when it cannot read input.
fflush(stdout); /* buffered out to fast */
if (read(inputFd, &c, 1) < 1)
- return;
+ /* if we can't read input then exit */
+ goto prepare_to_die;
switch (c) {
case '\n':
/* Control-d -- Delete one character, or exit
* if the len=0 and no chars to delete */
if (len == 0) {
+prepare_to_die:
printf("exit");
clean_up_and_die(0);
} else {
(tmpcmd = strsep_space(cmd, &ix)) != NULL; cmd += ix, ix=0) {
if (*tmpcmd == '\0')
break;
+ /* we need to trim() the result for glob! */
+ trim(tmpcmd);
retval = glob(tmpcmd, flags, NULL, &expand_result);
free(tmpcmd); /* Free mem allocated by strsep_space */
if (retval == GLOB_NOSPACE) {
error_msg(out_of_space);
return FALSE;
}
- if (i>0) {
- strcat(command+total_length, " ");
- total_length+=1;
- }
+ strcat(command+total_length, " ");
+ total_length+=1;
strcat(command+total_length, expand_result.gl_pathv[i]);
total_length+=length;
}
if (!job_list.fg) {
/* move the shell to the foreground */
/* suppress messages when run from /linuxrc mag@sysgo.de */
- if (tcsetpgrp(0, getpid()) && errno != ENOTTY)
+ if (tcsetpgrp(0, getpgrp()) && errno != ENOTTY)
perror_msg("tcsetpgrp");
}
}
(tmpcmd = strsep_space(cmd, &ix)) != NULL; cmd += ix, ix=0) {
if (*tmpcmd == '\0')
break;
+ /* we need to trim() the result for glob! */
+ trim(tmpcmd);
retval = glob(tmpcmd, flags, NULL, &expand_result);
free(tmpcmd); /* Free mem allocated by strsep_space */
if (retval == GLOB_NOSPACE) {
error_msg(out_of_space);
return FALSE;
}
- if (i>0) {
- strcat(command+total_length, " ");
- total_length+=1;
- }
+ strcat(command+total_length, " ");
+ total_length+=1;
strcat(command+total_length, expand_result.gl_pathv[i]);
total_length+=length;
}
if (!job_list.fg) {
/* move the shell to the foreground */
/* suppress messages when run from /linuxrc mag@sysgo.de */
- if (tcsetpgrp(0, getpid()) && errno != ENOTTY)
+ if (tcsetpgrp(0, getpgrp()) && errno != ENOTTY)
perror_msg("tcsetpgrp");
}
}
fflush(stdout); /* buffered out to fast */
if (read(inputFd, &c, 1) < 1)
- return;
+ /* if we can't read input then exit */
+ goto prepare_to_die;
switch (c) {
case '\n':
/* Control-d -- Delete one character, or exit
* if the len=0 and no chars to delete */
if (len == 0) {
+prepare_to_die:
printf("exit");
clean_up_and_die(0);
} else {
(tmpcmd = strsep_space(cmd, &ix)) != NULL; cmd += ix, ix=0) {
if (*tmpcmd == '\0')
break;
+ /* we need to trim() the result for glob! */
+ trim(tmpcmd);
retval = glob(tmpcmd, flags, NULL, &expand_result);
free(tmpcmd); /* Free mem allocated by strsep_space */
if (retval == GLOB_NOSPACE) {
error_msg(out_of_space);
return FALSE;
}
- if (i>0) {
- strcat(command+total_length, " ");
- total_length+=1;
- }
+ strcat(command+total_length, " ");
+ total_length+=1;
strcat(command+total_length, expand_result.gl_pathv[i]);
total_length+=length;
}
if (!job_list.fg) {
/* move the shell to the foreground */
/* suppress messages when run from /linuxrc mag@sysgo.de */
- if (tcsetpgrp(0, getpid()) && errno != ENOTTY)
+ if (tcsetpgrp(0, getpgrp()) && errno != ENOTTY)
perror_msg("tcsetpgrp");
}
}