git.annexia.org
/
whenjobs.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
928f6dc
)
Simplify code in the whenjobs tool by creating nr_args, arg1 variables.
author
Richard W.M. Jones
<rjones@redhat.com>
Sat, 10 Mar 2012 12:13:40 +0000
(12:13 +0000)
committer
Richard W.M. Jones
<rjones@redhat.com>
Sat, 10 Mar 2012 12:23:09 +0000
(12:23 +0000)
tools/whenjobs.ml
patch
|
blob
|
history
diff --git
a/tools/whenjobs.ml
b/tools/whenjobs.ml
index
be38f67
..
ff166a6
100644
(file)
--- a/
tools/whenjobs.ml
+++ b/
tools/whenjobs.ml
@@
-143,6
+143,8
@@
Options:
| t ->
eprintf "whenjobs: --type: unknown type (%s)\n" t;
exit 1 in
| 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
(* Depending on the selected mode, perform a different action. *)
match mode with
@@
-173,12
+175,12
@@
Options:
set_variable (List.hd args) (List.hd (List.tl args)) typ
| Some `Get ->
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
);
eprintf "whenjobs --get variable\n";
suggest_help ();
exit 1
);
- get_variable
(List.hd args)
+ get_variable
arg1
| Some `Variables ->
unused_error args "--variables";
| Some `Variables ->
unused_error args "--variables";
@@
-205,29
+207,29
@@
Options:
jobs ()
| Some `Cancel ->
jobs ()
| Some `Cancel ->
- if
List.length
args != 1 then (
+ if
nr_
args != 1 then (
eprintf "whenjobs --cancel serial\n";
suggest_help ();
exit 1
);
eprintf "whenjobs --cancel serial\n";
suggest_help ();
exit 1
);
- cancel_job
(List.hd args)
+ cancel_job
arg1
| Some `Start ->
| 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
);
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 ->
| Some `Tail ->
- if
List.length
args != 1 then (
+ if
nr_
args != 1 then (
eprintf "whenjobs --tail serial\n";
suggest_help ();
exit 1
);
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
and edit_file () =
(* If there is no initial file, create an empty one containing the