Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pasting brackets gets escaped #6654

Closed
ctron opened this issue Mar 2, 2018 · 21 comments
Closed

Pasting brackets gets escaped #6654

ctron opened this issue Mar 2, 2018 · 21 comments

Comments

@ctron
Copy link

ctron commented Mar 2, 2018

Executing shell commands from e.g. a tutorial containing something like $(cmd ...) always triggers
an escape of the initial (. This is really annoying.

Pasting: echo $(foo bar)
Gives: echo $\(foo bar), which cannot be executed

Is there a way to disable this?

@abbi-gaurav
Copy link

facing the same issue.

@mcornella
Copy link
Member

What zsh --version do you have and what does zle -l | egrep '(self-insert|bracketed-paste)' output?

@ctron
Copy link
Author

ctron commented Aug 10, 2018

What zsh --version do you have and what does zle -l | egrep '(self-insert|bracketed-paste)' output?

➜  ~ zsh --version
zsh 5.0.2 (x86_64-redhat-linux-gnu)
➜  ~ zle -l | egrep '(self-insert|bracketed-paste)'
self-insert (url-quote-magic)

@abbi-gaurav
Copy link

What zsh --version do you have and what does zle -l | egrep '(self-insert|bracketed-paste)' output?

$ zsh --version
zsh 5.3 (x86_64-apple-darwin17.0)

$ zle -l | egrep '(self-insert|bracketed-paste)'
bracketed-paste (bracketed-paste-magic)
self-insert (url-quote-magic)

@mcornella
Copy link
Member

Does this happen when running zsh without rc files? Try that with zsh -f

@ctron
Copy link
Author

ctron commented Aug 30, 2018

Does this happen when running zsh without rc files? Try that with zsh -f

Running with -fworks as expected. Nothing gets escaped in this case.

image

@mcornella
Copy link
Member

Ok, let's narrow down the culprit. First, comment out the source $ZSH/oh-my-zsh.sh line in your zshrc file to stop loading OMZ, and see if the issue persists. If not, then start sourcing files in the $ZSH/lib folder one by one, checking if it's still there.

My guess is that lib/misc.zsh is at fault, so if you want you can check that out directly.

@ctron
Copy link
Author

ctron commented Aug 31, 2018

Removing/commenting out the source $ZSH/oh-my-zsh.sh line fixes the issue.

@ctron
Copy link
Author

ctron commented Aug 31, 2018

Sourcing misc.zsh indeed causes the problem:

[jreimann@jreimann ~]$ zsh
[jreimann@jreimann]~% curl -X POST --insecure -T addresses.json -H "content-type: application/json" https://$(oc -n enmasse get route restapi -o jsonpath='{.spec.host}')/apis/enmasse.io/v1alpha1/namespaces/enmasse/addressspaces/default/addresses
[jreimann@jreimann]~% cd .oh-my-zsh 
[jreimann@jreimann]~/.oh-my-zsh% source lib/misc.zsh 
bash: env_default: command not found...
lib/misc.zsh:22: command not found: env_default
bash: env_default: command not found...
lib/misc.zsh:23: command not found: env_default
[jreimann@jreimann]~/.oh-my-zsh% curl -X POST --insecure -T addresses.json -H "content-type: application/json" https://$\(oc -n enmasse get route restapi -o jsonpath='{.spec.host}')/apis/enmasse.io/v1alpha1/namespaces/enmasse/addressspaces/default/addresses

@mcornella
Copy link
Member

That's expected behavior because it's inside a URL (pasting a quoted URL should get rid of this behavior). Can you try with your first example, echo $(foo bar)?

@AlmightyOatmeal
Copy link

AlmightyOatmeal commented Sep 3, 2018

I resolved this issue by adding this to my ~/.zshrc file to disable ZSH's url-quote-magic:

zstyle ':urlglobber' url-other-schema

@ctron
Copy link
Author

ctron commented Sep 4, 2018

@mcornella Well I definitely don't expect that behavior, so how can I turn this off?
@AlmightyOatmeal Sorry, that didn't work.

@AlmightyOatmeal
Copy link

@ctron,

If you added it to your ~/.zshrc file, did you source ~/.zshrc or load a new shell? You can otherwise run the command outright to test it like I did on my work machine:

$ wget https://media.giphy.com/media/t6Jlf4jIk1GbS/giphy.gif\?taco\=cat
--2018-09-04 09:47:34--  https://media.giphy.com/media/t6Jlf4jIk1GbS/giphy.gif?taco=cat
Resolving media.giphy.com (media.giphy.com)... 151.101.150.2
Connecting to media.giphy.com (media.giphy.com)|151.101.150.2|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1250157 (1.2M) [image/gif]
Saving to: ‘giphy.gif?taco=cat’

giphy.gif?taco=cat                    100%[=========================================================================>]   1.19M  1.20MB/s    in 1.0s

2018-09-04 09:47:35 (1.20 MB/s) - ‘giphy.gif?taco=cat’ saved [1250157/1250157]
$ zstyle ':urlglobber' url-other-schema
$ wget https://media.giphy.com/media/t6Jlf4jIk1GbS/giphy.gif?taco=cat
zsh: no matches found: https://media.giphy.com/media/t6Jlf4jIk1GbS/giphy.gif?taco=cat

$ wget "https://media.giphy.com/media/t6Jlf4jIk1GbS/giphy.gif?taco=cat"
--2018-09-04 09:48:06--  https://media.giphy.com/media/t6Jlf4jIk1GbS/giphy.gif?taco=cat
Resolving media.giphy.com (media.giphy.com)... 151.101.150.2
Connecting to media.giphy.com (media.giphy.com)|151.101.150.2|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1250157 (1.2M) [image/gif]
Saving to: ‘giphy.gif?taco=cat.1’

giphy.gif?taco=cat.1                  100%[=========================================================================>]   1.19M  1.09MB/s    in 1.1s

2018-09-04 09:48:08 (1.09 MB/s) - ‘giphy.gif?taco=cat.1’ saved [1250157/1250157]

@ctron
Copy link
Author

ctron commented Sep 4, 2018

If you added it to your ~/.zshrc file, did you source ~/.zshrc or load a new shell?

I did start a new shell. …

So I tried your proposal. Executing this in the shell, works for me as well. So I re-activated it in the .zshrc again … still no luck. I don't know what the difference is, but putting it in the ~/.zshrc, doesn't work for me. And it is the last active statement in that file, the rest are only comments.

@AlmightyOatmeal
Copy link

@ctron,

Since the command by itself does work then your zsh may not be reading ~/.zshrc; if zsh is reading a file other than ~/.zshrc then add it to the respective and appropriate file for your configuration/operating system.

The other thing that may be happening is that the shell is aborting reading the entire file due to an error so only some of the variables get set and some of the commands get executed but not all. This will take a little investigation on your part but at least there is a viable solution.

@ctron
Copy link
Author

ctron commented Sep 4, 2018

I definitely is reading this file,.zshrc. I did add an echo after this line, to check if this gets executed up until this point. And I could see the output when starting a new shell instance.

When I start zsh -v, then I can see my statement disable this:

…
# disable auto escape
zstyle ':urlglobber' url-other-schema

And when I run int that same shell zstyle I do get:

…
tag-order
        :completion:*:cd:* local-directories directory-stack path-directories
url-globbers
(eval)  :url-quote-magic 'zmodload -i zsh/parameter;
	 reply=( noglob
		 ${(k)galiases[(R)(* |)(noglob|urlglobber|globurl) *]:-}
		 ${(k)aliases[(R)(* |)(noglob|urlglobber|globurl) *]:-} )'
url-local-schema
        :urlglobber ftp file
url-metas
        :url-quote-magic:* '*?[]^(|)~#{}='
url-other-schema
        :urlglobber http https ftp
url-seps
(eval)  :url-quote-magic:* 'reply=(";&<>${histchars[1]}")'
use-cache
        :completion::complete:* 1
…

When I execute zstyle ':urlglobber' url-other-schema it changes to:

…
tag-order
        :completion:*:cd:* local-directories directory-stack path-directories
url-globbers
(eval)  :url-quote-magic 'zmodload -i zsh/parameter;
	 reply=( noglob
		 ${(k)galiases[(R)(* |)(noglob|urlglobber|globurl) *]:-}
		 ${(k)aliases[(R)(* |)(noglob|urlglobber|globurl) *]:-} )'
url-local-schema
        :urlglobber ftp file
url-metas
        :url-quote-magic:* '*?[]^(|)~#{}='
url-other-schema
        :urlglobber
url-seps
(eval)  :url-quote-magic:* 'reply=(";&<>${histchars[1]}")'
use-cache
        :completion::complete:* 1
…

@mlibbey
Copy link

mlibbey commented Nov 27, 2018

Is this a dupe of #5499 ?

@AlmightyOatmeal
Copy link

That issue is very specific to two versions of OS X where-as this is not. I have had this issue on more versions of OS X than listed but seems to only be on OS X versions of zsh obtained from brew.

@ctron
Copy link
Author

ctron commented Nov 27, 2018

And I do have it on CentOS, so this is not a Mac OS X only issue.

@shai-kappel
Copy link

@AlmightyOatmeal 10x man this solved the issue for me, i wish it will be included OOB in future releases of zsh

@mcornella
Copy link
Member

After the latest update (run upgrade_oh_my_zsh), you can add DISABLE_MAGIC_FUNCTIONS=true to your zshrc (before OMZ is sourced) to bypass the loading of the magic functions.

atsuya pushed a commit to atsuya/oh-my-zsh that referenced this issue Jun 9, 2019
Fixes ohmyzsh#5499
Fixes ohmyzsh#5569
Fixes ohmyzsh#6338
Fixes ohmyzsh#6654
Fixes ohmyzsh#6255
Fixes ohmyzsh#7632

Closes ohmyzsh#7763

Co-authored-by: Daniel Galán y Martins <git@galan.de>
dukegod pushed a commit to dukegod/oh-my-zsh that referenced this issue Jul 16, 2019
Fixes ohmyzsh#5499
Fixes ohmyzsh#5569
Fixes ohmyzsh#6338
Fixes ohmyzsh#6654
Fixes ohmyzsh#6255
Fixes ohmyzsh#7632

Closes ohmyzsh#7763

Co-authored-by: Daniel Galán y Martins <git@galan.de>
chihchun pushed a commit to chihchun/oh-my-zsh that referenced this issue Aug 6, 2019
Fixes ohmyzsh#5499
Fixes ohmyzsh#5569
Fixes ohmyzsh#6338
Fixes ohmyzsh#6654
Fixes ohmyzsh#6255
Fixes ohmyzsh#7632

Closes ohmyzsh#7763

Co-authored-by: Daniel Galán y Martins <git@galan.de>
lewg pushed a commit to lewg/oh-my-zsh that referenced this issue Nov 25, 2019
Fixes ohmyzsh#5499
Fixes ohmyzsh#5569
Fixes ohmyzsh#6338
Fixes ohmyzsh#6654
Fixes ohmyzsh#6255
Fixes ohmyzsh#7632

Closes ohmyzsh#7763

Co-authored-by: Daniel Galán y Martins <git@galan.de>
spiliopoulos pushed a commit to spiliopoulos/zsh-config that referenced this issue Jun 17, 2020
Fixes ohmyzsh#5499
Fixes ohmyzsh#5569
Fixes ohmyzsh#6338
Fixes ohmyzsh#6654
Fixes ohmyzsh#6255
Fixes ohmyzsh#7632

Closes ohmyzsh#7763

Co-authored-by: Daniel Galán y Martins <git@galan.de>
crdant referenced this issue in crdant/oh-my-zsh-custom Dec 30, 2020
Fixes #5499
Fixes #5569
Fixes #6338
Fixes #6654
Fixes #6255
Fixes #7632

Closes #7763

Co-authored-by: Daniel Galán y Martins <git@galan.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants