| | @@ -347,6 +347,15 @@ |
| 347 | 347 | return Files.arg(p^.at - 1), true; |
| 348 | 348 | end; |
| 349 | 349 | |
| 350 | +(* The number of the argument operand would give next, after what |
| 351 | + options are left: the operands from there on are Files.arg(i), for |
| 352 | + i up to ARGC() - 1, as an interpreter hands them to its script. *) |
| 353 | +proc at*(p: ^Parser): INT; |
| 354 | +begin |
| 355 | + while next(p) do end; |
| 356 | + return p^.at; |
| 357 | +end; |
| 358 | + |
| 350 | 359 | (* The options of the subcommand name, from the word after its own, |
| 351 | 360 | which operand has given. *) |
| 352 | 361 | proc scope*(p: ^Parser; name: []U8); |
| | @@ -387,7 +396,7 @@ |
| 387 | 396 | no synopsis lines; and holds each to what it writes, and its status. *) |
| 388 | 397 | proc keep; |
| 389 | 398 | const wait = 1; |
| 390 | | -var p: Parser; verbose, ok: BOOL; secs: I64; bar, job, w: []U8; b: Buf.Buf; |
| 399 | +var p: Parser; verbose, ok: BOOL; secs: I64; bar, job, w: []U8; b: Buf.Buf; i: INT; |
| 391 | 400 | begin |
| 392 | 401 | secs := 10; |
| 393 | 402 | init(ADR(p), "keep", [ |
| | @@ -414,16 +423,15 @@ |
| 414 | 423 | if p.letter = 'b' then bar := p.value; end; |
| 415 | 424 | end; |
| 416 | 425 | job, ok := operand(ADR(p)); |
| 417 | | - w, ok := operand(ADR(p)); |
| 418 | | - if not ok then fail(ADR(p), "start needs a name and a command; see keep start -h"); end; |
| 426 | + (* the command and its arguments, as they are, by at *) |
| 427 | + if not ok or (at(ADR(p)) >= ARGC()) then |
| 428 | + fail(ADR(p), "start needs a name and a command; see keep start -h"); |
| 429 | + end; |
| 419 | 430 | if verbose then Fmt.print("waiting {}s\n", [Fmt.int(secs)]); end; |
| 420 | 431 | Fmt.print("job {}", [Fmt.str(job)]); |
| 421 | 432 | if LEN(bar) > 0 then Fmt.print(" [{}]", [Fmt.str(bar)]); end; |
| 422 | 433 | Fmt.print(":", []); |
| 423 | | - while ok do |
| 424 | | - Fmt.print(" {}", [Fmt.str(w)]); |
| 425 | | - w, ok := operand(ADR(p)); |
| 426 | | - end; |
| 434 | + for i := at(ADR(p)) to ARGC() - 1 do Fmt.print(" {}", [Fmt.str(Files.arg(i))]); end; |
| 427 | 435 | Fmt.print("\n", []); |
| 428 | 436 | end; |
| 429 | 437 | |
| | @@ -512,6 +520,7 @@ |
| 512 | 520 | {mode: k, args: ["keep", "start", "-", "c", "--", "-h"], out: "job -: c -- -h\n"}, |
| 513 | 521 | {mode: k, args: ["keep", "start", "n", "c", "-b", "x"], out: "job n: c -b x\n"}, |
| 514 | 522 | {mode: k, args: ["keep", "start", "-bh", "n", "c"], out: "job n [h]: c\n"}, |
| 523 | + {mode: k, args: ["keep", "start", "-b", "x", "n"], err: "keep: start needs a name and a command; see keep start -h\n", status: 2}, |
| 515 | 524 | {mode: k, args: ["keep", "-h"], out: keepHelp}, |
| 516 | 525 | {mode: k, args: ["keep", "-v", "--help", "-x"], out: keepHelp}, |
| 517 | 526 | {mode: k, args: ["keep", "-vh"], out: keepHelp}, |