zsh-users
 help / Atom feed
* howto run curl again with quoted argument if it failed due to parsing error?
@ 2018-09-30 13:54 chiasa.men
  2018-09-30 14:02 ` Pier Paolo Grassi
  0 siblings, 1 reply; 2+ messages in thread
From: chiasa.men @ 2018-09-30 13:54 UTC (permalink / raw)
  To: zsh-users

if you call e.g. curl with a link that contains an & zsh says:  
zsh: parse error near `&'. 

Is there an zsh idiom to fix that? 
I came up with 
curl ^@|ctrl+shift+v|esc'. 

I also tried sth like 
!!:*:q 
but that doesnt return the whole link (only a part of it)
curl https://www.google.com/search?q=test&ie=utf-8&oe=utf-8&client=firefox-b-ab
zsh: parse error near `&'
echo !!:*:q
echo 'https://www.google.com/search?q=test&ie=utf-8&'
https://www.google.com/search?q=test&ie=utf-8&

Is that related to my zshrc entry:
WORDCHARS='*?_-.[]~=&;!#$%^(){}<>'
or intended behavior? It breaks at a 'o' it seems..


Strangely :0-$ gets the whole link:
echo !!:0-$:q
echo 'curl' 'https://www.google.com/search?
q=test&ie=utf-8&oe=utf-8&client=firefox-b-ab'
curl https://www.google.com/search?q=test&ie=utf-8&oe=utf-8&client=firefox-b-ab

Why is that?



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: howto run curl again with quoted argument if it failed due to parsing error?
  2018-09-30 13:54 howto run curl again with quoted argument if it failed due to parsing error? chiasa.men
@ 2018-09-30 14:02 ` Pier Paolo Grassi
  0 siblings, 0 replies; 2+ messages in thread
From: Pier Paolo Grassi @ 2018-09-30 14:02 UTC (permalink / raw)
  To: chiasa.men; +Cc: Zsh-Users List

[-- Attachment #1: Type: text/plain, Size: 1841 bytes --]

hello, you should quote the "offending" argument, since it contains shell
metacharacters

curl
https://www.google.com/search?q=test&ie=utf-8&oe=utf-8&client=firefox-b-ab

should become

curl "
https://www.google.com/search?q=test&ie=utf-8&oe=utf-8&client=firefox-b-ab"

you can use single or double quotes, or you can escape (prefixing with a
blackslash) only the & and the ? character, since they both are shell
metacharacters, like this:

curl
https://www.google.com/search\?q=test\&ie=utf-8\&oe=utf-8\&client=firefox-b-ab

you can read more about shell metacharacters here:

http://faculty.salina.k-state.edu/tim/unix_sg/shell/metachar.html

I hope to have been helpful, best regards

Il giorno dom 30 set 2018 alle ore 15:55 chiasa.men <chiasa.men@web.de> ha
scritto:

> if you call e.g. curl with a link that contains an & zsh says:
> zsh: parse error near `&'.
>
> Is there an zsh idiom to fix that?
> I came up with
> curl ^@|ctrl+shift+v|esc'.
>
> I also tried sth like
> !!:*:q
> but that doesnt return the whole link (only a part of it)
> curl
> https://www.google.com/search?q=test&ie=utf-8&oe=utf-8&client=firefox-b-ab
> zsh: parse error near `&'
> echo !!:*:q
> echo 'https://www.google.com/search?q=test&ie=utf-8&'
> https://www.google.com/search?q=test&ie=utf-8&
>
> Is that related to my zshrc entry:
> WORDCHARS='*?_-.[]~=&;!#$%^(){}<>'
> or intended behavior? It breaks at a 'o' it seems..
>
>
> Strangely :0-$ gets the whole link:
> echo !!:0-$:q
> echo 'curl' 'https://www.google.com/search?
> q=test&ie=utf-8&oe=utf-8&client=firefox-b-ab'
> curl
> https://www.google.com/search?q=test&ie=utf-8&oe=utf-8&client=firefox-b-ab
>
> Why is that?
>
>
>

-- 
Pier Paolo Grassi
email: pierpaolog@gmail.com
linkedin: https://www.linkedin.com/in/pier-paolo-grassi-19300217
founder: https://www.meetup.com/it-IT/Machine-Learning-TO

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-30 13:54 howto run curl again with quoted argument if it failed due to parsing error? chiasa.men
2018-09-30 14:02 ` Pier Paolo Grassi

zsh-users

Archives are clonable: git clone --mirror http://inbox.vuxu.org/zsh-users

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.users


AGPL code for this site: git clone https://public-inbox.org/ public-inbox