Skip to contentSkip to conversation

diff: trivial fix for --output file error message

PATCH New Matthieu Moy 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 diff: trivial fix for --output file error message

Since we use parse_long_opt(), the option argument is either after --output=... or in the next command-line argument. optarg is the reliable way to access it.

---

On my system, it seems --output file works, probably because the argument array is stored as "--output\0file", but we should definitely not rely on that ...

 diff.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff.c +1 -1
index 276e029..38f5f9c 100644
@@ -3315,7 +3315,7 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
 	else if ((argcount = parse_long_opt("output", av, &optarg))) {
 		options->file = fopen(optarg, "w");
 		if (!options->file)
-			die_errno("Could not open '%s'", arg + strlen("--output="));
+			die_errno("Could not open '%s'", optarg);
 		options->close_file = 1;
 		return argcount;
 	} else
Signature · 1 line
1.7.3.2.g257b5f