Re: [PATCH v2 01/10] test-chmtime: Fix exit code on Windows

2013-11-20 Thread Erik Faye-Lund
On Fri, Jun 7, 2013 at 10:53 PM, Johannes Sixt  wrote:
> MinGW's bash does not recognize an exit code -1 as failure. See also
> 47e3de0e (MinGW: truncate exit()'s argument to lowest 8 bits) and 2488df84
> (builtin run_command: do not exit with -1). Exit code 1 is good enough.
>
> Signed-off-by: Johannes Sixt 
> ---
>  test-chmtime.c | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/test-chmtime.c b/test-chmtime.c
> index 02b42ba..2e601a8 100644
> --- a/test-chmtime.c
> +++ b/test-chmtime.c
> @@ -84,7 +84,7 @@ int main(int argc, const char *argv[])
> if (stat(argv[i], &sb) < 0) {
> fprintf(stderr, "Failed to stat %s: %s\n",
> argv[i], strerror(errno));
> -   return -1;
> +   return 1;
> }
>
>  #ifdef WIN32
> @@ -92,7 +92,7 @@ int main(int argc, const char *argv[])
> chmod(argv[i], sb.st_mode | S_IWUSR)) {
> fprintf(stderr, "Could not make user-writable %s: %s",
> argv[i], strerror(errno));
> -   return -1;
> +   return 1;
> }
>  #endif
>
> @@ -107,7 +107,7 @@ int main(int argc, const char *argv[])
> if (utb.modtime != sb.st_mtime && utime(argv[i], &utb) < 0) {
> fprintf(stderr, "Failed to modify time on %s: %s\n",
> argv[i], strerror(errno));
> -   return -1;
> +   return 1;
> }
> }
>
> @@ -115,5 +115,5 @@ int main(int argc, const char *argv[])
>
>  usage:
> fprintf(stderr, "usage: %s %s\n", argv[0], usage_str);
> -   return -1;
> +   return 1;
>  }
> --
> 1.8.3.rc1.32.g8b61cbb
>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

Hmmm. Perhaps we should do something like this?

diff --git a/compat/mingw.h b/compat/mingw.h
index 1f9ab5f..cbee8bd 100644
--- a/compat/mingw.h
+++ b/compat/mingw.h
@@ -462,7 +462,7 @@ static int mingw_main(c,v); \
 int main(c,v) \
 { \
  mingw_startup(); \
- return mingw_main(__argc, __argv); \
+ return mingw_main(__argc, __argv) & 0xff; \
 } \
 static int mingw_main(c,v)
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 01/10] test-chmtime: Fix exit code on Windows

2013-06-07 Thread Johannes Sixt
MinGW's bash does not recognize an exit code -1 as failure. See also
47e3de0e (MinGW: truncate exit()'s argument to lowest 8 bits) and 2488df84
(builtin run_command: do not exit with -1). Exit code 1 is good enough.

Signed-off-by: Johannes Sixt 
---
 test-chmtime.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/test-chmtime.c b/test-chmtime.c
index 02b42ba..2e601a8 100644
--- a/test-chmtime.c
+++ b/test-chmtime.c
@@ -84,7 +84,7 @@ int main(int argc, const char *argv[])
if (stat(argv[i], &sb) < 0) {
fprintf(stderr, "Failed to stat %s: %s\n",
argv[i], strerror(errno));
-   return -1;
+   return 1;
}
 
 #ifdef WIN32
@@ -92,7 +92,7 @@ int main(int argc, const char *argv[])
chmod(argv[i], sb.st_mode | S_IWUSR)) {
fprintf(stderr, "Could not make user-writable %s: %s",
argv[i], strerror(errno));
-   return -1;
+   return 1;
}
 #endif
 
@@ -107,7 +107,7 @@ int main(int argc, const char *argv[])
if (utb.modtime != sb.st_mtime && utime(argv[i], &utb) < 0) {
fprintf(stderr, "Failed to modify time on %s: %s\n",
argv[i], strerror(errno));
-   return -1;
+   return 1;
}
}
 
@@ -115,5 +115,5 @@ int main(int argc, const char *argv[])
 
 usage:
fprintf(stderr, "usage: %s %s\n", argv[0], usage_str);
-   return -1;
+   return 1;
 }
-- 
1.8.3.rc1.32.g8b61cbb

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html