summaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2014-11-05 15:47:38 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2014-11-05 15:47:38 +0100
commitda1a9005c28e1b2b15bf9557809b0ca47dc7b57b (patch)
treeb93524bcc272636013ae66e31c428764b1800359 /commands
parent8a55a7ddf120affd2145f06f2d52fdfbe13cb01d (diff)
parent6aaba64b0c7044c242329499d5d4c53c3d0cde3a (diff)
downloadbarebox-da1a9005c28e1b2b15bf9557809b0ca47dc7b57b.tar.gz
barebox-da1a9005c28e1b2b15bf9557809b0ca47dc7b57b.tar.xz
Merge branch 'for-next/fs'
Diffstat (limited to 'commands')
-rw-r--r--commands/Kconfig10
-rw-r--r--commands/Makefile1
-rw-r--r--commands/cmp.c42
3 files changed, 53 insertions, 0 deletions
diff --git a/commands/Kconfig b/commands/Kconfig
index d73a393885..bef58473a5 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -811,6 +811,16 @@ config CMD_CP
Options:
-v verbose
+config CMD_CMP
+ tristate
+ prompt "cmp"
+ help
+ compare two files
+
+ Usage: cmp FILE1 FILE2
+
+ Returns successfully if the two files are the same, return with an error if not
+
config CMD_DIRNAME
tristate
prompt "dirname"
diff --git a/commands/Makefile b/commands/Makefile
index b1cdf331c4..be174969b0 100644
--- a/commands/Makefile
+++ b/commands/Makefile
@@ -106,3 +106,4 @@ obj-$(CONFIG_CMD_IMD) += imd.o
obj-$(CONFIG_CMD_HWCLOCK) += hwclock.o
obj-$(CONFIG_CMD_USBGADGET) += usbgadget.o
obj-$(CONFIG_CMD_FIRMWARELOAD) += firmwareload.o
+obj-$(CONFIG_CMD_CMP) += cmp.o
diff --git a/commands/cmp.c b/commands/cmp.c
new file mode 100644
index 0000000000..c493988a78
--- /dev/null
+++ b/commands/cmp.c
@@ -0,0 +1,42 @@
+/*
+ * cmp - determine if two files differ
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <common.h>
+#include <command.h>
+#include <complete.h>
+#include <libfile.h>
+
+static int do_cmp(int argc, char *argv[])
+{
+ if (argc != 3)
+ return COMMAND_ERROR_USAGE;
+
+ return compare_file(argv[1], argv[2]);
+}
+
+BAREBOX_CMD_HELP_START(cmp)
+BAREBOX_CMD_HELP_TEXT("Returns successfully if the two files are the same, return with an error if not")
+BAREBOX_CMD_HELP_END
+
+BAREBOX_CMD_START(cmp)
+ .cmd = do_cmp,
+ BAREBOX_CMD_DESC("compare two files")
+ BAREBOX_CMD_OPTS("FILE1 FILE2")
+ BAREBOX_CMD_GROUP(CMD_GRP_FILE)
+ BAREBOX_CMD_HELP(cmd_cmp_help)
+BAREBOX_CMD_END