| t ->
eprintf "whenjobs: --type: unknown type (%s)\n" t;
exit 1 in
+ let nr_args = List.length args in
+ let arg1 = match args with [] -> "" | a::_ -> a in
(* Depending on the selected mode, perform a different action. *)
match mode with
set_variable (List.hd args) (List.hd (List.tl args)) typ
| Some `Get ->
- if List.length args != 1 then (
+ if nr_args != 1 then (
eprintf "whenjobs --get variable\n";
suggest_help ();
exit 1
);
- get_variable (List.hd args)
+ get_variable arg1
| Some `Variables ->
unused_error args "--variables";
jobs ()
| Some `Cancel ->
- if List.length args != 1 then (
+ if nr_args != 1 then (
eprintf "whenjobs --cancel serial\n";
suggest_help ();
exit 1
);
- cancel_job (List.hd args)
+ cancel_job arg1
| Some `Start ->
- if List.length args != 1 then (
+ if nr_args != 1 then (
eprintf "whenjobs --start jobname\n";
eprintf "If 'value' contains spaces, you may need to quote it.\n";
suggest_help ();
exit 1
);
- start_job (List.hd args)
+ start_job arg1
| Some `Tail ->
- if List.length args != 1 then (
+ if nr_args != 1 then (
eprintf "whenjobs --tail serial\n";
suggest_help ();
exit 1
);
- tail (List.hd args)
+ tail arg1
and edit_file () =
(* If there is no initial file, create an empty one containing the