esh: fix output for fg, bg when no jobs

This commit is contained in:
K. Lange 2018-10-29 21:21:39 +09:00
parent 614eb752d4
commit 829ebcd4a1

View File

@ -1941,8 +1941,7 @@ int get_available_job(int argc, char * argv[]) {
list_free(keys); list_free(keys);
free(keys); free(keys);
if (!suspended_pgid) { if (!suspended_pgid) {
fprintf(stderr, "no current job\n"); return 0;
return 1;
} }
} }
return suspended_pgid; return suspended_pgid;
@ -1954,7 +1953,7 @@ int get_available_job(int argc, char * argv[]) {
uint32_t shell_cmd_fg(int argc, char * argv[]) { uint32_t shell_cmd_fg(int argc, char * argv[]) {
int pid = get_available_job(argc,argv); int pid = get_available_job(argc,argv);
if (!pid || !hashmap_has(job_hash, (void*)pid)) { if (!pid || !hashmap_has(job_hash, (void*)pid)) {
fprintf(stderr, "invalid job"); fprintf(stderr, "no current job\n");
return 1; return 1;
} }
@ -1970,7 +1969,7 @@ uint32_t shell_cmd_fg(int argc, char * argv[]) {
uint32_t shell_cmd_bg(int argc, char * argv[]) { uint32_t shell_cmd_bg(int argc, char * argv[]) {
int pid = get_available_job(argc,argv); int pid = get_available_job(argc,argv);
if (!pid || !hashmap_has(job_hash, (void*)pid)) { if (!pid || !hashmap_has(job_hash, (void*)pid)) {
fprintf(stderr, "invalid job"); fprintf(stderr, "no current job\n");
return 1; return 1;
} }