From 8ad95c375ad6376143bd8ba938525bb4c7894ccb Mon Sep 17 00:00:00 2001 From: Thomas Queiroz Date: Tue, 2 Nov 2021 19:53:40 -0300 Subject: [PATCH] env: force specifying command with --chdir --- src/uu/env/src/env.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/uu/env/src/env.rs b/src/uu/env/src/env.rs index 6d5431aa9..835c8766c 100644 --- a/src/uu/env/src/env.rs +++ b/src/uu/env/src/env.rs @@ -229,6 +229,14 @@ fn run_env(args: impl uucore::Args) -> UResult<()> { } } + // GNU env tests this behavior + if opts.program.is_empty() && running_directory.is_some() { + return Err(UUsageError::new( + 125, + "must specify command with --chdir (-C)".to_string(), + )); + } + // NOTE: we manually set and unset the env vars below rather than using Command::env() to more // easily handle the case where no command is given