From 53c1079e31fb166511fa1a66cd526fc33eb42c86 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 25 Nov 2018 02:10:31 +0100 Subject: [PATCH] envsubst: On native Windows, produce output suitable for the shell. * autogen.sh (GNULIB_MODULES_RUNTIME_FOR_SRC): Add 'binary-io'. * gettext-runtime/src/envsubst.c (main): In --variables mode, put stdout in binary mode. --- autogen.sh | 1 + gettext-runtime/src/envsubst.c | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/autogen.sh b/autogen.sh index a96b04c41..c6f66330f 100755 --- a/autogen.sh +++ b/autogen.sh @@ -137,6 +137,7 @@ if ! $skip_gnulib; then GNULIB_MODULES_RUNTIME_FOR_SRC=' atexit basename + binary-io closeout error getopt-gnu diff --git a/gettext-runtime/src/envsubst.c b/gettext-runtime/src/envsubst.c index 941452b03..8416b7a9d 100644 --- a/gettext-runtime/src/envsubst.c +++ b/gettext-runtime/src/envsubst.c @@ -1,5 +1,5 @@ /* Substitution of environment variables in shell format strings. - Copyright (C) 2003-2007, 2012, 2015-2018 Free Software Foundation, Inc. + Copyright (C) 2003-2007, 2012, 2018 Free Software Foundation, Inc. Written by Bruno Haible , 2003. This program is free software: you can redistribute it and/or modify @@ -34,6 +34,7 @@ #include "basename.h" #include "xalloc.h" #include "propername.h" +#include "binary-io.h" #include "gettext.h" #define _(str) gettext (str) @@ -139,6 +140,11 @@ There is NO WARRANTY, to the extent permitted by law.\n\ default: abort (); } + + /* The result is most often used in shell `...` expressions. + Therefore, on native Windows, don't produce CR/LF newlines. */ + set_binary_mode (STDOUT_FILENO, O_BINARY); + print_variables (argv[optind++]); } else -- 2.47.2