* Bug: Ubuntu apt-get install package-*
@ 2016-11-10 22:43 Bob
2016-11-11 2:54 ` Bart Schaefer
2016-11-11 4:49 ` Eric Cook
0 siblings, 2 replies; 5+ messages in thread
From: Bob @ 2016-11-10 22:43 UTC (permalink / raw)
To: zsh-workers
[-- Attachment #1: Type: text/plain, Size: 259 bytes --]
Hello,
Thank you for your great work on ZSH.
I'd like to report a bug.
When I run install commands with `*` for all packages I get a zsh error
while it works in bash.
For example I recently tried this: sudo apt-get install numix-wallpaper-*
Regards,
Bob
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Bug: Ubuntu apt-get install package-*
2016-11-10 22:43 Bug: Ubuntu apt-get install package-* Bob
@ 2016-11-11 2:54 ` Bart Schaefer
2016-11-14 16:25 ` Oliver Kiddle
2016-11-11 4:49 ` Eric Cook
1 sibling, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2016-11-11 2:54 UTC (permalink / raw)
To: zsh-workers
[>workers]
On Nov 10, 10:43pm, Bob wrote:
}
} When I run install commands with `*` for all packages I get a zsh error
} while it works in bash.
Maybe it's time for something like this?
(Truly horrible implementation follows, don't commit this, presented
for example purposes only, etc. etc.)
torch% echo bl?or*
zsh: no matches found: bl?or*
torch% setopt correctall
torch% echo bl?or*
zsh: correct 'bl?or*' to 'bl\?or\*' [nyae]? y
bl?or*
diff --git a/Src/utils.c b/Src/utils.c
index 3d535b8..b9cd227 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -2948,6 +2948,31 @@ spckword(char **s, int hist, int cmd, int ask)
return;
if (!(*s)[0] || !(*s)[1])
return;
+
+ if (!incond && !incmdpos && isset(NOMATCH) && haswilds(*s)) {
+ char *b, *g;
+ untokenize(g = dupstring(guess = *s));
+ b = quotestring(best = g, QT_BACKSLASH_PATTERN);
+ if (ask) {
+ if (noquery(0)) {
+ x = 'n';
+ } else if (shout) {
+ char *pptbuf;
+ pptbuf = promptexpand(sprompt, 0, b, g, NULL);
+ zputs(pptbuf, shout);
+ free(pptbuf);
+ fflush(shout);
+ zbeep();
+ x = getquery("nyae \t", 0);
+ if (cmd && x == 'n')
+ pathchecked = path;
+ } else
+ x = 'n';
+ } else
+ x = 'y';
+ goto Interpret;
+ }
+
if (cmd) {
if (shfunctab->getnode(shfunctab, *s) ||
builtintab->getnode(builtintab, *s) ||
@@ -3087,6 +3112,7 @@ spckword(char **s, int hist, int cmd, int ask)
x = 'n';
} else
x = 'y';
+ Interpret:
if (x == 'y' || x == ' ' || x == '\t') {
*s = dupstring(best);
if (hist)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Bug: Ubuntu apt-get install package-*
2016-11-10 22:43 Bug: Ubuntu apt-get install package-* Bob
2016-11-11 2:54 ` Bart Schaefer
@ 2016-11-11 4:49 ` Eric Cook
1 sibling, 0 replies; 5+ messages in thread
From: Eric Cook @ 2016-11-11 4:49 UTC (permalink / raw)
To: zsh-workers
On 11/10/2016 05:43 PM, Bob wrote:
> Hello,
>
> Thank you for your great work on ZSH.
>
> I'd like to report a bug.
>
> When I run install commands with `*` for all packages I get a zsh error
> while it works in bash.
>
> For example I recently tried this: sudo apt-get install numix-wallpaper-*
>
> Regards,
> Bob
>
It isn't an bug, the * is a metacharacter used for globbing.
The difference is what the shells do when a glob fails to match a filename.
bash will pass the glob as-is to the command while zsh will stop processing the line.
You can mimic zsh's behavior in bash with: shopt -s failglob
and you can mimic bash's behavior in zsh with: unsetopt nomatch
But by default in zsh if you want to to pass arguments to a command that contain
valid metacharacters to zsh, you have to escape them by quoting.
So the correct way is:
sudo apt-get install numix-wallpaper-\*
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Bug: Ubuntu apt-get install package-*
2016-11-11 2:54 ` Bart Schaefer
@ 2016-11-14 16:25 ` Oliver Kiddle
2016-11-14 17:29 ` Bart Schaefer
0 siblings, 1 reply; 5+ messages in thread
From: Oliver Kiddle @ 2016-11-14 16:25 UTC (permalink / raw)
To: zsh-workers
On 10 Nov, Bart wrote:
> On Nov 10, 10:43pm, Bob wrote:
> }
> } When I run install commands with `*` for all packages I get a zsh error
> } while it works in bash.
>
> Maybe it's time for something like this?
>
> (Truly horrible implementation follows, don't commit this, presented
> for example purposes only, etc. etc.)
> torch% echo bl?or*
> zsh: correct 'bl?or*' to 'bl\?or\*' [nyae]? y
> bl?or*
An interesting idea. Given that correction happens before globbing
I can't think of any particularly sane criteria for when to trigger
this correction. The "horrible implementation" seems to take anything
two characters in length or longer and ~ is not regarded as a pattern
character. So haswilds must be returning false for just '*' or '?' which
seems odd.
So as it is, it would just be irritating because it would offer a
correction virtually every time you attempt to use a glob. If you defer
the correction to when a glob fails then it could be irritating if a
glob gets used in a loop and it could mean that a complex command
combination might be half-way through already before you see a
correction that would warrant an abort or edit response.
And without making this the default, it probably won't help the situation
much for bash exiles expecting nonomatch behaviour.
Oliver
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Bug: Ubuntu apt-get install package-*
2016-11-14 16:25 ` Oliver Kiddle
@ 2016-11-14 17:29 ` Bart Schaefer
0 siblings, 0 replies; 5+ messages in thread
From: Bart Schaefer @ 2016-11-14 17:29 UTC (permalink / raw)
To: zsh-workers
On Nov 14, 5:25pm, Oliver Kiddle wrote:
}
} > torch% echo bl?or*
} > zsh: correct 'bl?or*' to 'bl\?or\*' [nyae]? y
} > bl?or*
}
} An interesting idea. Given that correction happens before globbing
} I can't think of any particularly sane criteria for when to trigger
} this correction.
The less-horrible implementation would be to do this at the globbing
step where CSH_NULL_GLOB is applied. I just didn't want to go to the
effort of hooking up an entirely new spckword()-alike.
} The "horrible implementation" seems to take anything
} two characters in length or longer and ~ is not regarded as a pattern
} character. So haswilds must be returning false for just '*' or '?' which
} seems odd.
Yes, spckword() is doing funny things to avoid giving spelling errors on
~username etc. I didn't take very much care to avoid any of that when I
threw that example together.
} So as it is, it would just be irritating because it would offer a
} correction virtually every time you attempt to use a glob.
The NO_NOMATCH option would disable this, as would NULL_GLOB.
} If you defer
} the correction to when a glob fails then it could be irritating if a
} glob gets used in a loop
Yes, there would have to be a flag at some level that would indicate
whether the user had already accepted NO_NOMATCH behavior, so you'd
only be asked once per top-level prompt.
} And without making this the default, it probably won't help the situation
} much for bash exiles expecting nonomatch behaviour.
Yes, it would have to be the default when NOMATCH.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-11-14 17:36 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-10 22:43 Bug: Ubuntu apt-get install package-* Bob
2016-11-11 2:54 ` Bart Schaefer
2016-11-14 16:25 ` Oliver Kiddle
2016-11-14 17:29 ` Bart Schaefer
2016-11-11 4:49 ` Eric Cook
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).