[llvm] [llvm-lit] Resolve env subcommand required error (PR #98414)

Petr Hosek via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 10 23:21:02 PDT 2024


================
@@ -743,7 +743,8 @@ def _executeShCmd(cmd, shenv, results, timeoutHelper):
                     cmd_shenv = ShellEnvironment(shenv.cwd, shenv.env)
                 args = updateEnv(cmd_shenv, args)
                 if not args:
-                    raise InternalShellError(j, "Error: 'env' requires a" " subcommand")
+                    # Return the environment variables if no argument is provided 
+                    return {key: value for key, value in cmd_shenv.env.items()}
----------------
petrhosek wrote:

I don't think this is correct since there might be other piped commands, for example you could do this:
```
env | grep TERM
```
Furthermore all return paths from this function return exit code so returning a dictionary here is not correct.

https://github.com/llvm/llvm-project/pull/98414


More information about the llvm-commits mailing list