From: Phillip Wood Date: Thu, 26 Nov 2026 14:56:14 GMT Subject: Re: [PATCH] config: make the suggested "set" command safe to paste Message-ID: <607d6273-14ba-4005-b038-3778ad2812fe@gmail.com> In-Reply-To: <02A50A47-A048-417E-9D1E-0C12D8FB1476@gmail.com> On 26/11/2026 12:30, Ben Knoble wrote: >> Le 25 nov. 2026 à 13:54, Harald Nordgren via GitGitGadget a écrit : >> >> From: Harald Nordgren >> >> Quote the value when it needs it, and put the command on a line of >> its own the way other hints show commands, so it can be copied >> without the surrounding quotes: >> >> hint: did you mean: >> hint: >> hint: git config set status.comparebranches '@{upstream} @{push}' > > I wanted to bring both folks together to figure out: should we shell quote > assuming a POSIX-like shell, and do the current patches > work or not on Windows? > > In other words, would we need to do something different to > behave sensibly in other shells (fish?), or is that not a target worth > worrying about (GfW comes with a Bash environment)? Ideally sq_quote_buf_pretty() would take the current shell into account so that it generated different output for powershell, cmd.exe, etc. Currently the output is suitable for POSIX shells and csh (though this particular patch does some post-processing that removes support for csh). As a fish user I agree it would be nice to support that as well. Fish recognizes \\ and \' as escapes within single quotes, so we could support it in addition to POSIX shells and csh by always backslash escaping backslashes as we already do for single quotes and exclamation marks. A prettier option would be to only backslash escape backslashes that are followed by a backslash or single quote. > One other thing: it might be nice to centralize some kind of > automatic quoting for suggested commands. sq_quote_buf_pretty() is intended for that use case, so we already have a central location for that logic. The output could be prettier though, in particular in would be nice to avoid the redundant pairs of single quotes at the beginning and end of ''\''hello there'\''' so that it produced \''hello there'\' instead. "'hello there'" would be even prettier but would take more work. Thanks Phillip