zsh-users
 help / color / mirror / code / Atom feed
* Re: Problem with "?" symbol
@ 2010-08-03 13:35 Manuel Presnitz
  2010-08-03 14:46 ` Dan Nelson
  0 siblings, 1 reply; 13+ messages in thread
From: Manuel Presnitz @ 2010-08-03 13:35 UTC (permalink / raw)
  To: zsh-users

Hi,

> The ? is a special character for the shell (which cannot know
> whether the argument is a filename or not). There are 2 solutions:
> 
> 1. Quote the character manually (...)
> 2. Quote the character automatically (...)

I think there is also a third solution:

Unset the option nomatch:

$ zsh -f
$ curl -vvv -k https://HOST.COM/page/page2/?virtual_serial=101032
zsh: no matches found: https://HOST.COM/page/page2/?virtual_serial=101032
$ unsetopt nomatch
$ curl -vvv -k https://HOST.COM/page/page2/?virtual_serial=101032
* About to connect() to HOST.COM port 443
*   Trying 208.73.210.28... 

The manual explains, what happens, when nomatch is set (which is the default for invokation as zsh):
NOMATCH (+3) <C> <Z>
 If  a  pattern  for  filename  generation has no matches, print an error,
 instead of leaving it unchanged in the argument list.  This also  applies
 to file expansion of an initial `~' or `='.


I like this option, it is very handy, also for things like that:
$ nmap -sP 192.168.1.*


Best regards,
Manuel.



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

* Re: Problem with "?" symbol
  2010-08-03 13:35 Problem with "?" symbol Manuel Presnitz
@ 2010-08-03 14:46 ` Dan Nelson
  2010-08-03 21:05   ` Vincent Lefevre
  2010-08-08 12:49   ` Nadav Har'El
  0 siblings, 2 replies; 13+ messages in thread
From: Dan Nelson @ 2010-08-03 14:46 UTC (permalink / raw)
  To: Manuel Presnitz; +Cc: zsh-users

In the last episode (Aug 03), Manuel Presnitz said:
> > The ? is a special character for the shell (which cannot know
> > whether the argument is a filename or not). There are 2 solutions:
> > 
> > 1. Quote the character manually (...)
> > 2. Quote the character automatically (...)
> 
> I think there is also a third solution:
> 
> Unset the option nomatch:
> 
> $ zsh -f
> $ curl -vvv -k https://HOST.COM/page/page2/?virtual_serial=101032
> zsh: no matches found: https://HOST.COM/page/page2/?virtual_serial=101032
> $ unsetopt nomatch
> $ curl -vvv -k https://HOST.COM/page/page2/?virtual_serial=101032
> * About to connect() to HOST.COM port 443
> *   Trying 208.73.210.28... 
> 
> The manual explains, what happens, when nomatch is set (which is the
> default for invokation as zsh):
>
> NOMATCH (+3) <C> <Z>
>  If  a  pattern  for  filename  generation has no matches, print an error,
>  instead of leaving it unchanged in the argument list.  This also applies
>  to file expansion of an initial `~' or `='.
> 
> 
> I like this option, it is very handy, also for things like that:
> $ nmap -sP 192.168.1.*

This can get you into trouble if you happen to have files matching your
wildcard in the current directory.  "noglob" completely disables globbing;
"NO_NOMATCH" still tries to match the wildcard but leaves it if there are no
matches.

-- 
	Dan Nelson
	dnelson@allantgroup.com


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

* Re: Problem with "?" symbol
  2010-08-03 14:46 ` Dan Nelson
@ 2010-08-03 21:05   ` Vincent Lefevre
  2010-08-08 12:49   ` Nadav Har'El
  1 sibling, 0 replies; 13+ messages in thread
From: Vincent Lefevre @ 2010-08-03 21:05 UTC (permalink / raw)
  To: zsh-users

On 2010-08-03 09:46:57 -0500, Dan Nelson wrote:
> In the last episode (Aug 03), Manuel Presnitz said:
> > I think there is also a third solution:
> > 
> > Unset the option nomatch:
[...]
> 
> This can get you into trouble if you happen to have files matching
> your wildcard in the current directory. "noglob" completely disables
> globbing; "NO_NOMATCH" still tries to match the wildcard but leaves
> it if there are no matches.

Moreover the no_nomatch option is global, thus affects commands for
which one doesn't want this feature.

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)


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

* Re: Problem with "?" symbol
  2010-08-03 14:46 ` Dan Nelson
  2010-08-03 21:05   ` Vincent Lefevre
@ 2010-08-08 12:49   ` Nadav Har'El
  2010-08-08 13:50     ` Benjamin R. Haskell
  1 sibling, 1 reply; 13+ messages in thread
From: Nadav Har'El @ 2010-08-08 12:49 UTC (permalink / raw)
  To: Dan Nelson; +Cc: Manuel Presnitz, zsh-users

On Tue, Aug 03, 2010, Dan Nelson wrote about "Re: Problem with "?" symbol":
> This can get you into trouble if you happen to have files matching your
> wildcard in the current directory.  "noglob" completely disables globbing;
> "NO_NOMATCH" still tries to match the wildcard but leaves it if there are no
> matches.

When I last proposed making 'set +o nomatch' the default, like it is in
Bourne shell, Ksh, and Bash, I got similar feedback - that it is dangerous
because sometimes the wildcards do expand something, and sometimes they don't,
etc. But has this ever actually caused problems for anybody? For me, it simply
"does the right thing" most (if not all) of the time. The "nomatch" error
always reminds of those "you forgot a semicolon at the end of the line"
compilation errors in C - if you know I forgot something, why not help me
and fix it for me? :-)

And considering that people coming from other shells (not including csh,
which I wonder who continues to use) assume this feature, I still wonder
why it's not the default in zsh.

-- 
Nadav Har'El                        |          Sunday, Aug  8 2010, 28 Av 5770
nyh@math.technion.ac.il             |-----------------------------------------
Phone +972-523-790466, ICQ 13349191 |A diplomat thinks twice before saying
http://nadav.harel.org.il           |nothing.


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

* Re: Problem with "?" symbol
  2010-08-08 12:49   ` Nadav Har'El
@ 2010-08-08 13:50     ` Benjamin R. Haskell
  0 siblings, 0 replies; 13+ messages in thread
From: Benjamin R. Haskell @ 2010-08-08 13:50 UTC (permalink / raw)
  To: Nadav Har'El; +Cc: Dan Nelson, Manuel Presnitz, zsh-users

On Sun, 8 Aug 2010, Nadav Har'El wrote:

> On Tue, Aug 03, 2010, Dan Nelson wrote about "Re: Problem with "?" symbol":
> > This can get you into trouble if you happen to have files matching 
> > your wildcard in the current directory.  "noglob" completely 
> > disables globbing; "NO_NOMATCH" still tries to match the wildcard 
> > but leaves it if there are no matches.
> 
> When I last proposed making 'set +o nomatch' the default, like it is 
> in Bourne shell, Ksh, and Bash, I got similar feedback - that it is 
> dangerous because sometimes the wildcards do expand something, and 
> sometimes they don't, etc. But has this ever actually caused problems 
> for anybody? For me, it simply "does the right thing" most (if not 
> all) of the time. The "nomatch" error always reminds of those "you 
> forgot a semicolon at the end of the line" compilation errors in C - 
> if you know I forgot something, why not help me and fix it for me? :-)

Detecting that something is wrong is much easier than knowing what the 
correct fix is.

In the nomatch case, it bugs me (a lot) that other shells silently 
convert the input I've given them into something that is not equivalent.  
It commonly bites me with the '?' case (With '*' and '&', I usually 
notice that I need to quote something), but I'd much rather it complain 
than silently do something I don't intend.  E.g. catching the typo in:

mv otherstuff impotrant* /backup/

(Probably a lame example, but the point about not changing my input in 
ways I don't intend stands.)


> And considering that people coming from other shells (not including 
> csh, which I wonder who continues to use) assume this feature, I still 
> wonder why it's not the default in zsh.

For the same reason that SH_WORD_SPLIT isn't the default.  "What other 
shells do" isn't always the best indication of what Zsh users want.

(In my opinion, obviously.)

-- 
Best,
Ben


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

* Re: Problem with "?" symbol
  2010-08-03 12:26 Volodya Khomchak
                   ` (2 preceding siblings ...)
  2010-08-03 12:46 ` Vincent Lefevre
@ 2010-08-08 12:10 ` Bryan Hunt
  3 siblings, 0 replies; 13+ messages in thread
From: Bryan Hunt @ 2010-08-08 12:10 UTC (permalink / raw)
  To: zsh-users

URL Stuff causes problems in umpteen scenarios/shells. 
A much simpler solution is to just always quote URL's, i.e.  

curl -vvv -k "https://HOST.COM/page/page2/?virtual_serial=101032"

Simple, end of problem, do the same thing with SMB filenames too, while
you're at it.

Bryan

Excerpts from Volodya Khomchak's message of Tue Aug 03 13:26:30 +0100 2010:
> Hi Folks,
> 
> I faced with next issue in zsh. I'm new with this and don't have any
> idea why this occurs.
> So the problem is next:
> 
> [kolombo:~]> curl -vvv -k https://HOST.COM/page/page2/?virtual_serial=101032
> zsh: no matches found:
> https://esx16-bsd05.qa.sbr.ironport.com/atlas/ipcs/?virtual_serial=101032
> 
> This command fails on "?" symbol, do you have any idea why  this occurs ?
> 
> Also I know that this could be resolved by this:
> alias curl="noglob curl"
> 
> 
> Cheers,
> Volodya
-- 
--


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

* Re: Problem with "?" symbol
  2010-08-03 13:06   ` René 'Necoro' Neumann
@ 2010-08-03 15:17     ` Bart Schaefer
  0 siblings, 0 replies; 13+ messages in thread
From: Bart Schaefer @ 2010-08-03 15:17 UTC (permalink / raw)
  To: zsh-users

} > autoload -Uz url-quote-magic
} > zle -N self-insert url-quote-magic
} 
} Is there any documentation about it? Searching for "url-quote" in 'man
} zshall' didn't bring up anything.

It's never been added to the zshcontrib yodl source.  There's a lot of doc
in the function source itself, though:

    more ${^fpath}/url-quote-magic(N)


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

* Re: Problem with "?" symbol
  2010-08-03 12:35 ` Alexey I. Froloff
@ 2010-08-03 13:06   ` René 'Necoro' Neumann
  2010-08-03 15:17     ` Bart Schaefer
  0 siblings, 1 reply; 13+ messages in thread
From: René 'Necoro' Neumann @ 2010-08-03 13:06 UTC (permalink / raw)
  To: zsh-users

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

Am 03.08.2010 14:35, schrieb Alexey I. Froloff:
> On Tue, Aug 03, 2010 at 03:26:30PM +0300, Volodya Khomchak wrote:
>> This command fails on "?" symbol, do you have any idea why  this occurs ?
> Because '?' is a special char, used in patterns.  Try adding to
> your ~/.zshrc:
> 
> autoload -Uz url-quote-magic
> zle -N self-insert url-quote-magic
> 

Is there any documentation about it? Searching for "url-quote" in 'man
zshall' didn't bring up anything.

- René


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

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

* Re: Problem with "?" symbol
  2010-08-03 12:39 ` Jérémie Roquet
@ 2010-08-03 12:50   ` Vincent Lefevre
  0 siblings, 0 replies; 13+ messages in thread
From: Vincent Lefevre @ 2010-08-03 12:50 UTC (permalink / raw)
  To: zsh-users

On 2010-08-03 14:39:51 +0200, Jérémie Roquet wrote:
> If you like copy-pasting urls in your shell, have a look at the
> url-quote-magic widget to escape glob operators automatically.

Note that url-quote-magic also works when typing URL's (which is
almost the same thing as pasting a URL -- url-quote-magic doesn't
use a time-based logic).

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)


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

* Re: Problem with "?" symbol
  2010-08-03 12:26 Volodya Khomchak
  2010-08-03 12:35 ` Alexey I. Froloff
  2010-08-03 12:39 ` Jérémie Roquet
@ 2010-08-03 12:46 ` Vincent Lefevre
  2010-08-08 12:10 ` Bryan Hunt
  3 siblings, 0 replies; 13+ messages in thread
From: Vincent Lefevre @ 2010-08-03 12:46 UTC (permalink / raw)
  To: zsh-users

Hi,

On 2010-08-03 15:26:30 +0300, Volodya Khomchak wrote:
> I faced with next issue in zsh. I'm new with this and don't have any
> idea why this occurs.
> So the problem is next:
> 
> [kolombo:~]> curl -vvv -k https://HOST.COM/page/page2/?virtual_serial=101032
> zsh: no matches found:
> https://esx16-bsd05.qa.sbr.ironport.com/atlas/ipcs/?virtual_serial=101032
> 
> This command fails on "?" symbol, do you have any idea why  this occurs ?

The ? is a special character for the shell (which cannot know
whether the argument is a filename or not). There are 2 solutions:

1. Quote the character manually, e.g.

     cmd foo\?bar

   or

     cmd "foo?bar"

2. Quote the character automatically:

     autoload -Uz url-quote-magic
     zle -N self-insert url-quote-magic

   in your ".zshrc".

Note: solution (2) is only a heuristic, which works well in practice,
but may need more configuration in specific cases.

> Also I know that this could be resolved by this:
> alias curl="noglob curl"

Not necessarily a good solution, as curl also works with filename
arguments.

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)


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

* Re: Problem with "?" symbol
  2010-08-03 12:26 Volodya Khomchak
  2010-08-03 12:35 ` Alexey I. Froloff
@ 2010-08-03 12:39 ` Jérémie Roquet
  2010-08-03 12:50   ` Vincent Lefevre
  2010-08-03 12:46 ` Vincent Lefevre
  2010-08-08 12:10 ` Bryan Hunt
  3 siblings, 1 reply; 13+ messages in thread
From: Jérémie Roquet @ 2010-08-03 12:39 UTC (permalink / raw)
  To: zsh-users; +Cc: Volodya Khomchak

Hi,

2010/8/3 Volodya Khomchak <kolombo.inc@gmail.com>:
> I faced with next issue in zsh. I'm new with this and don't have any
> idea why this occurs.
> So the problem is next:
>
> [kolombo:~]> curl -vvv -k https://HOST.COM/page/page2/?virtual_serial=101032
> zsh: no matches found:
> https://esx16-bsd05.qa.sbr.ironport.com/atlas/ipcs/?virtual_serial=101032
>
> This command fails on "?" symbol, do you have any idea why  this occurs ?

Yes: "?" is a glob operator meaning "any character", similar to "*"
(which means "any sequence of characters").

See "man zshexpn", section "glob operators" for more information.

> Also I know that this could be resolved by this:
> alias curl="noglob curl"

You might prefer escaping the "?" with a backslash:

curl -vvv -k https://HOST.COM/page/page2/\?virtual_serial=101032

If you like copy-pasting urls in your shell, have a look at the
url-quote-magic widget to escape glob operators automatically.

Best regards,

-- 
Jérémie


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

* Re: Problem with "?" symbol
  2010-08-03 12:26 Volodya Khomchak
@ 2010-08-03 12:35 ` Alexey I. Froloff
  2010-08-03 13:06   ` René 'Necoro' Neumann
  2010-08-03 12:39 ` Jérémie Roquet
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 13+ messages in thread
From: Alexey I. Froloff @ 2010-08-03 12:35 UTC (permalink / raw)
  To: zsh-users

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

On Tue, Aug 03, 2010 at 03:26:30PM +0300, Volodya Khomchak wrote:
> This command fails on "?" symbol, do you have any idea why  this occurs ?
Because '?' is a special char, used in patterns.  Try adding to
your ~/.zshrc:

autoload -Uz url-quote-magic
zle -N self-insert url-quote-magic

-- 
Regards,    --
Sir Raorn.   --- http://thousandsofhate.blogspot.com/

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Problem with "?" symbol
@ 2010-08-03 12:26 Volodya Khomchak
  2010-08-03 12:35 ` Alexey I. Froloff
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Volodya Khomchak @ 2010-08-03 12:26 UTC (permalink / raw)
  To: zsh-users

Hi Folks,

I faced with next issue in zsh. I'm new with this and don't have any
idea why this occurs.
So the problem is next:

[kolombo:~]> curl -vvv -k https://HOST.COM/page/page2/?virtual_serial=101032
zsh: no matches found:
https://esx16-bsd05.qa.sbr.ironport.com/atlas/ipcs/?virtual_serial=101032

This command fails on "?" symbol, do you have any idea why  this occurs ?

Also I know that this could be resolved by this:
alias curl="noglob curl"


Cheers,
Volodya


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

end of thread, other threads:[~2010-08-08 13:58 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-03 13:35 Problem with "?" symbol Manuel Presnitz
2010-08-03 14:46 ` Dan Nelson
2010-08-03 21:05   ` Vincent Lefevre
2010-08-08 12:49   ` Nadav Har'El
2010-08-08 13:50     ` Benjamin R. Haskell
  -- strict thread matches above, loose matches on Subject: below --
2010-08-03 12:26 Volodya Khomchak
2010-08-03 12:35 ` Alexey I. Froloff
2010-08-03 13:06   ` René 'Necoro' Neumann
2010-08-03 15:17     ` Bart Schaefer
2010-08-03 12:39 ` Jérémie Roquet
2010-08-03 12:50   ` Vincent Lefevre
2010-08-03 12:46 ` Vincent Lefevre
2010-08-08 12:10 ` Bryan Hunt

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).