I don't understand the problem about which the standard shell in Debian (dash) complains:test@debian:~$ sh$ man lsctrl+Z[1] + Stopped                    man ls$ jobs[1] + Stopped                    man ls$ fg %mansh: 3: fg: %man: ambiguousShouldn't fg %string simply bring the job whose command begins with string to the foreground? Why is %man ambiguous?
Job control in dash
job control;dash
This looks like a bug; the loop which handles strings in this context doesn't have a valid exit condition:        while (1) {                if (!jp)                        goto err;                if (match(jp->ps[0].cmd, p)) {                        if (found)                                goto err;                        found = jp;                        err_msg = %s: ambiguous;                }                jp = jp->prev_job;        }If a job matches the string, found is set, and err_msg is pre-loaded; then it goes round the loop again, after setting jp to the previous job. When it reaches the end, the first condition matches, so control goes to err, which prints the error:err:        sh_error(err_msg, name);I guess there should be a goto gotit somewhere...The following patch fixes this (I've sent it to the upstream maintainer):diff --git a/src/jobs.c b/src/jobs.cindex c2c2332..37f3b41 100644--- a/src/jobs.c+++ b/src/jobs.c@@ -715,8 +715,14 @@ check:        found = 0;        while (1) {-               if (!jp)-                       goto err;+               if (!jp) {+                       if (found) {+                               jp = found;+                               goto gotit;+                       } else {+                               goto err;+                       }+               }                if (match(jp->ps[0].cmd, p)) {                        if (found)                                goto err;