mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Christian Kapeller <christian.kapeller@cmotion.eu>
To: barebox@lists.infradead.org
Subject: [PATCH] bareboxenv: Return proper exit code on failure.
Date: Tue, 26 Feb 2013 12:20:29 +0100	[thread overview]
Message-ID: <1361877629-10890-1-git-send-email-christian.kapeller@cmotion.eu> (raw)

In case environment loading/saving failed, the calling program
should be informed about that by returning a non zero exit code.

Signed-off-by: Christian Kapeller <christian.kapeller@cmotion.eu>
---
 scripts/bareboxenv.c |   16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/scripts/bareboxenv.c b/scripts/bareboxenv.c
index 707d63d..3fd1429 100644
--- a/scripts/bareboxenv.c
+++ b/scripts/bareboxenv.c
@@ -138,7 +138,7 @@ void usage(char *prgname)
 int main(int argc, char *argv[])
 {
 	int opt;
-	int save = 0, load = 0, pad = 0, fd;
+	int save = 0, load = 0, pad = 0, err = 0, fd;
 	char *filename = NULL, *dirname = NULL;
 	int verbose = 0;
 
@@ -191,12 +191,20 @@ int main(int argc, char *argv[])
 	if (load) {
 		if (verbose)
 			printf("loading env from file %s to %s\n", filename, dirname);
-		envfs_load(filename, dirname, 0);
+
+		err = envfs_load(filename, dirname, 0);
+
+		if(verbose && err)
+			printf("loading env failed: %d\n", err);
 	}
 	if (save) {
 		if (verbose)
 			printf("saving contents of %s to file %s\n", dirname, filename);
-		envfs_save(filename, dirname);
+
+		err = envfs_save(filename, dirname);
+
+		if(verbose && err)
+			printf("saving env failed: %d\n", err);
 	}
-	exit(0);
+	exit((err)?1:0);
 }
-- 
1.7.9.5


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

             reply	other threads:[~2013-02-26 11:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-26 11:20 Christian Kapeller [this message]
2013-02-26 11:36 ` Marc Kleine-Budde
2013-02-26 12:04   ` Christian Kapeller
2013-02-26 14:02     ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1361877629-10890-1-git-send-email-christian.kapeller@cmotion.eu \
    --to=christian.kapeller@cmotion.eu \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox