Command framework should say which arguments want glob expansion

Bug #97706 reported by Martin Pool
2
Affects Status Importance Assigned to Milestone
Bazaar
Confirmed
Wishlist
Unassigned

Bug Description

On Windows, we need to expand globs/wildcards in command line arguments in bzr. This is done ad-hoc for some commands like add, but maybe should be done in the Command framework.

Revision history for this message
Alexander Belchenko (bialix) wrote : Re: [Bug 97706] Command framework should say which arguments want glob expansion

glob expansion should be avoided for 'ignore' command.
So if we want to do glob expasion, I'd suggest to
have specal attribute for each command, that control
this behavior on/off.

[µ]

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

On Thu, 29 Mar 2007 04:36:11 -0000
Alexander Belchenko <email address hidden> wrote:

> glob expansion should be avoided for 'ignore' command.
> So if we want to do glob expasion, I'd suggest to
> have specal attribute for each command, that control
> this behavior on/off.
There is no way to turn it off on POSIX (as it's done by the shell,
not the application), so I think it makes for it to be on for all
commands on Windows for consistency.

Cheers,

Jelmer

--
Jelmer Vernooij <email address hidden> / Jabber: <email address hidden>
http://samba.org/~jelmer/

Revision history for this message
Martin Pool (mbp) wrote : Re: [Bug 97706] Command framework should say which arguments want glob expansion

On 3/29/07, Jelmer Vernooij <email address hidden> wrote:
> > glob expansion should be avoided for 'ignore' command.
> > So if we want to do glob expasion, I'd suggest to
> > have specal attribute for each command, that control
> > this behavior on/off.
> There is no way to turn it off on POSIX (as it's done by the shell,
> not the application), so I think it makes for it to be on for all
> commands on Windows for consistency.

So the glob-expander on Windows would need to be aware of quotes and
not expand quoted globs. That's probably not bad.

I wonder, should it expand globs that don't match anything, or error,
or leave them unexpanded?

  echo unmatched*

will say different things in different unix shells.

--
Martin

Revision history for this message
Alexander Belchenko (bialix) wrote : Re: [Bug 97706] Command framework should say which arguments want glob expansion

Jelmer Vernooij пишет:
> On Thu, 29 Mar 2007 04:36:11 -0000
> Alexander Belchenko <email address hidden> wrote:
>
>> glob expansion should be avoided for 'ignore' command.
>> So if we want to do glob expasion, I'd suggest to
>> have specal attribute for each command, that control
>> this behavior on/off.
> There is no way to turn it off on POSIX (as it's done by the shell,
> not the application), so I think it makes for it to be on for all
> commands on Windows for consistency.

I disagree with you. Because as other people often say: "you need
quoting glob to prevent expand by shell". I assume on POSIX
you need to do something like:

$ bzr ignore '$.obj'

and it works.

[µ]

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

On Thu, Mar 29, 2007 at 12:42:07PM +0300, Olexandr Byelchenko wrote:
> Jelmer Vernooij ??????????:
> > On Thu, 29 Mar 2007 04:36:11 -0000
> > Alexander Belchenko <email address hidden> wrote:
> >> glob expansion should be avoided for 'ignore' command.
> >> So if we want to do glob expasion, I'd suggest to
> >> have specal attribute for each command, that control
> >> this behavior on/off.
> > There is no way to turn it off on POSIX (as it's done by the shell,
> > not the application), so I think it makes for it to be on for all
> > commands on Windows for consistency.
> I disagree with you. Because as other people often say: "you need
> quoting glob to prevent expand by shell". I assume on POSIX
> you need to do something like:

> $ bzr ignore '$.obj'

> and it works.
Sorry, I should've been more clear. I meant there's no way to turn it
off in POSIX /from the application/.

Cheers,

Jelmer

--
Jelmer Vernooij <email address hidden> - http://jelmer.vernstok.nl/
 12:52:40 up 5 days, 16:22, 1 user, load average: 0.25, 0.32, 0.50

Revision history for this message
Alexander Belchenko (bialix) wrote :

Jelmer Vernooij пишет:
> On Thu, Mar 29, 2007 at 12:42:07PM +0300, Olexandr Byelchenko wrote:
>> I assume on POSIX
>> you need to do something like:
>
>> $ bzr ignore '*.obj'
>
>> and it works.
> Sorry, I should've been more clear. I meant there's no way to turn it
> off in POSIX /from the application/.

Because Martin propose to emulate shell expansion behavior on Windows
inside bzrlib, I was trying to say that in this case we need
to turn it off from application, and only on Windows of course.

[µ]

Revision history for this message
John A Meinel (jameinel) wrote :

Well, another thing to be aware of is that Windows doesn't respect the single quote as a quoting character. So doing:

bzr commit -m "foo bar baz"

works, but doing

bzr commit -m 'foo bar baz'

tries to commit using the message 'foo, and tries to commit the files bar and baz'.

We have bug 59302 open to remind us of that.

Also, I want to remind everyone that because Windows doesn't handle '*' but *does* handle '"' we have some real problems detecting if the user did or did not quote their request.

Specifically, I wrote a script which was just:
import sys
print sys.argv

And this is what I got:

> python test_args.py
['test_args.py']

> python test_args.py foo bar
['test_args.py', 'foo', 'bar']

> python test_args.py "foo bar"
['test_args.py', 'foo bar'] # Notice that the shell interpreted the "" for us

> python test_args.py 'foo bar'
['test_args.py', "'foo", "bar'"] # Notice that it didn't do anything with ''

> python test_args.py "bar*"
['test_args.py', 'bar*']

> python test_args.py bar*
['test_args.py', 'bar*']

So we have no way of telling the difference between:
  bzr ignore foo*
and
  bzr ignore "foo*"

If we ask users to use single quotes:
  bzr ignore 'foo*'

Then we really should change the command processor to handle single quotes in general
  bzr ignore './foo bar'
  bzr add 'foo bar'
  bzr commit -m 'foo bar'

Or we can say... "Do a reasonably good approximation, but windows cmd.exe is too different to implement true POSIX semantics."
And instead focus our energies on getting bzr good, and Olive/TortoiseBzr working for people on Windows.

Revision history for this message
Alexander Belchenko (bialix) wrote :

Kuno Meyer wrote the patch that use heuristic about which types of arguments should be globbed on Windows (i.e. filename* etc.). His patch was marked to resubmit, but apparently he did not sent new version. If heuristic is enough for this purpose, than I think we could close this bug.

John A Meinel (jameinel)
Changed in bzr:
importance: Undecided → Wishlist
status: New → Triaged
Martin Pool (mbp)
Changed in bzr:
status: Triaged → Confirmed
Jelmer Vernooij (jelmer)
tags: added: check-for-breezy
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.