* src/env.c (main): Avoid an isatty() call
(introduced in commit v9.12-10-g782a1e5bc) when
invoking a command, and not outputting.
---
 src/env.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/env.c b/src/env.c
index f87d79a36..27bbf5e2a 100644
--- a/src/env.c
+++ b/src/env.c
@@ -1124,9 +1124,14 @@ main (int argc, char **argv)
       ++optind;
     }
 
+  int program_index = optind;
+  while (program_index < argc && strchr (argv[program_index], '='))
+    program_index++;
+  bool program_specified = program_index < argc;
+
   bool quote_output = false;
   int qs = quoting_style_opt;
-  if (qs < 0 && isatty (STDOUT_FILENO))
+  if (! program_specified && qs < 0 && isatty (STDOUT_FILENO))
     {
       /* Get the value from $QUOTING_STYLE before unsetting env vars.  */
       qs = getenv_quoting_style ();
@@ -1182,8 +1187,6 @@ main (int argc, char **argv)
       optind++;
     }
 
-  bool program_specified = optind < argc;
-
   if (opt_nul_terminate_output && program_specified)
     {
       error (0, 0, _("cannot specify --null (-0) with command"));
-- 
2.55.0


Reply via email to