From 546fcc16def92e05d742fc6f538dcd0f7151013c Mon Sep 17 00:00:00 2001 From: nukuta Date: Sat, 24 Jul 2021 00:14:23 +0800 Subject: [PATCH] Handle XDG directories with spaces in autocomplete commands (#383) On some OSs ([i.e. macOS](https://github.com/adrg/xdg#xdg-base-directory)), XDG directories contain spaces, so we need to wrap the resulting path used in autocomplete sourcing commands in quotation marks. Co-authored-by: Matthew Daley Reviewed-on: https://gitea.com/gitea/tea/pulls/383 Reviewed-by: Andrew Thornton Reviewed-by: Norwin Co-authored-by: nukuta Co-committed-by: nukuta --- cmd/autocomplete.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/autocomplete.go b/cmd/autocomplete.go index cb69887..4c0ab1a 100644 --- a/cmd/autocomplete.go +++ b/cmd/autocomplete.go @@ -40,12 +40,12 @@ func runAutocompleteAdd(ctx *cli.Context) error { case "zsh": remoteFile = "contrib/autocomplete.zsh" localFile = "autocomplete.zsh" - cmds = "echo 'PROG=tea _CLI_ZSH_AUTOCOMPLETE_HACK=1 source %s' >> ~/.zshrc && source ~/.zshrc" + cmds = "echo 'PROG=tea _CLI_ZSH_AUTOCOMPLETE_HACK=1 source \"%s\"' >> ~/.zshrc && source ~/.zshrc" case "bash": remoteFile = "contrib/autocomplete.sh" localFile = "autocomplete.sh" - cmds = "echo 'PROG=tea source %s' >> ~/.bashrc && source ~/.bashrc" + cmds = "echo 'PROG=tea source \"%s\"' >> ~/.bashrc && source ~/.bashrc" case "powershell": remoteFile = "contrib/autocomplete.ps1"