aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2015-04-05 19:23:36 -0500
committerRob Landley <rob@landley.net>2015-04-05 19:23:36 -0500
commitad602aa127e44eade76fbb05fd27ee8f5825282a (patch)
treefed1277f2657759e3e217c5270dbcacd9f2c2f7f
parentdabd89c86484595a8a44f0ba38b0f28825c72e64 (diff)
downloadtoybox-ad602aa127e44eade76fbb05fd27ee8f5825282a.tar.gz
Add --version to multiplexer.
Can't think of a better place to stick the actual version info than a #define at the top of main. Makefile and toys.h are equally awkward, querying git tags wouldn't work if building a release tarball... watch me forget to update this when cutting a release.
-rw-r--r--main.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/main.c b/main.c
index 4644d198..dbc39bec 100644
--- a/main.c
+++ b/main.c
@@ -5,6 +5,8 @@
#include "toys.h"
+#define TOYBOX_VERSION "0.5.2"
+
// Populate toy_list[].
#undef NEWTOY
@@ -155,14 +157,12 @@ void toybox_main(void)
if (toys.argv[1]) {
toys.optc = toys.recursion = 0;
toy_exec(toys.argv+1);
- if (toys.argv[1][0] == '-') goto list;
-
- error_exit("Unknown command %s",toys.argv[1]);
+ if (toys.argv[1][0] != '-') error_exit("Unknown command %s", toys.argv[1]);
}
-list:
+ if (!strcmp("--version", toys.argv[1])) printf(TOYBOX_VERSION);
// Output list of command.
- for (i=1; i<ARRAY_LEN(toy_list); i++) {
+ else for (i=1; i<ARRAY_LEN(toy_list); i++) {
int fl = toy_list[i].flags;
if (fl & TOYMASK_LOCATION) {
if (toys.argv[1]) {