On Wed Jan 21 13:42:39 2026 +0000, eric pouech wrote:
solving this requires touching the arguments parsing, which is currently quite messy there's are several types of helpers (each one with limitations, each one with bugs) before this is worked out, I think the better approach in this case is to use the default parsing (storing values in global variables quals, param1, param2) target is to get rid of there global variables, but the nice part is that they separate parameters from options (qualifiers: starting with /) this patch also ensures that a single arg is passed to pushd this patch should be better ``` diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c index 7d1ad5c1e15..5272719bf0b 100644 --- a/programs/cmd/builtins.c +++ b/programs/cmd/builtins.c @@ -1783,10 +1783,11 @@ RETURN_CODE WCMD_pushd(const WCHAR *args) if (!*args) return errorlevel = NO_ERROR;
- if (wcschr(args, '/') != NULL) { - SetLastError(ERROR_INVALID_PARAMETER); - WCMD_print_error(); - return errorlevel = ERROR_INVALID_FUNCTION; + if (*quals || *param2) + { + SetLastError(ERROR_INVALID_PARAMETER); + WCMD_print_error(); + return errorlevel = ERROR_INVALID_FUNCTION; }
curdir = xalloc(sizeof(struct env_stack)); @@ -1796,7 +1797,7 @@ RETURN_CODE WCMD_pushd(const WCHAR *args) lstrcpyW(quals, L"/D"); GetCurrentDirectoryW (1024, thisdir);
- return_code = WCMD_setshow_default(args); + return_code = WCMD_setshow_default(param1); if (return_code != NO_ERROR) { free(curdir); ``` Your solution doesn't seem very feasible. This is because Windows supports input in this format: `"pushd path with space"`. If a directory named `"path with space"` exists in the current directory, this command will execute successfully and navigate into `"path with space"`. During the argument parsing stage, we cannot treat this as a single parameter because it is not wrapped in quotes. `pushd` currently works well, and I don't think making extensive modifications is a good idea. I lean more towards patching its minor flaws. As mentioned earlier, Windows's handling is very complex when dealing with combinations of quotes, `/`, and spaces. Without fully grasping the underlying rules, we should not attempt to perfectly solve the problem all at once and expect to achieve behavior identical to Windows.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/9881#note_127667