[PATCH 1/3] scripts/bareboxenv: Only print information if -v is given

Sascha Hauer s.hauer at pengutronix.de
Thu Sep 27 13:14:00 EDT 2012


Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 scripts/bareboxenv.c |   15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/scripts/bareboxenv.c b/scripts/bareboxenv.c
index a4aec94..f44a1f8 100644
--- a/scripts/bareboxenv.c
+++ b/scripts/bareboxenv.c
@@ -130,7 +130,8 @@ void usage(char *prgname)
 		"options:\n"
 		"  -s        save (directory -> environment sector)\n"
 		"  -l        load (environment sector -> directory)\n"
-		"  -p <size> pad output file to given size\n",
+		"  -p <size> pad output file to given size\n"
+		"  -v        verbose\n",
 		prgname);
 }
 
@@ -139,8 +140,9 @@ int main(int argc, char *argv[])
 	int opt;
 	int save = 0, load = 0, pad = 0, fd;
 	char *filename = NULL, *dirname = NULL;
+	int verbose = 0;
 
-	while((opt = getopt(argc, argv, "slp:")) != -1) {
+	while((opt = getopt(argc, argv, "slp:v")) != -1) {
 		switch (opt) {
 		case 's':
 			save = 1;
@@ -151,6 +153,9 @@ int main(int argc, char *argv[])
 		case 'p':
 			pad = strtoul(optarg, NULL, 0);
 			break;
+		case 'v':
+			verbose = 1;
+			break;
 		}
 	}
 
@@ -184,11 +189,13 @@ int main(int argc, char *argv[])
 	}
 
 	if (load) {
-		printf("loading env from file %s to %s\n", filename, dirname);
+		if (verbose)
+			printf("loading env from file %s to %s\n", filename, dirname);
 		envfs_load(filename, dirname);
 	}
 	if (save) {
-		printf("saving contents of %s to file %s\n", dirname, filename);
+		if (verbose)
+			printf("saving contents of %s to file %s\n", dirname, filename);
 		envfs_save(filename, dirname);
 	}
 	exit(0);
-- 
1.7.10.4




More information about the barebox mailing list