bzr modified adds unnecessary quotes around filenames

Bug #544297 reported by James Troup
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Bazaar
Confirmed
Medium
Unassigned

Bug Description

bzr modified adds unnecessary quotes around some filenames, e.g.

| root@tuna:/etc# bzr modified | grep grub.d
| grub.d/00_header
| grub.d/10_linux
| "grub.d/20_memtest86+"
| grub.d/30_os-prober
| root@tuna:/etc#

This breaks things like: 'bzr di $(bzr modified)'

I'm using bzr 2.1.0-1 from Lucid.

Revision history for this message
John A Meinel (jameinel) wrote : Re: [Bug 544297] [NEW] bzr modified adds unnecessary quotes around filenames

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

James Troup wrote:
> Public bug reported:
>
> bzr modified adds unnecessary quotes around some filenames, e.g.
>
> | root@tuna:/etc# bzr modified | grep grub.d
> | grub.d/00_header
> | grub.d/10_linux
> | "grub.d/20_memtest86+"
> | grub.d/30_os-prober
> | root@tuna:/etc#
>
> This breaks things like: 'bzr di $(bzr modified)'
>
> I'm using bzr 2.1.0-1 from Lucid.
>
> ** Affects: bzr
> Importance: Undecided
> Status: New
>

So the original motivation was to allow for command line parsers to
work. Specifically, because of stuff like "foo bar" (a file with a space
in it).

Does 'bzr di `bzr modified`' work? (I'm wondering if it handles quoting
differently.)

 status: incomplete

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkunqOwACgkQJdeBCYSNAAMV9gCfRb8KH7YKdXzUXSuu81cc0WCI
LVsAoJhYsKCnmWUXJK4PhBV31vK5/6Sy
=6tZ9
-----END PGP SIGNATURE-----

Changed in bzr:
status: New → Incomplete
Revision history for this message
James Troup (elmo) wrote :

John A Meinel <email address hidden> writes:

> So the original motivation was to allow for command line parsers to
> work. Specifically, because of stuff like "foo bar" (a file with a
> space in it).

Except that won't work either?

| $ bzr modified
| "foo bar"
| $ bzr di $(bzr modified)
| bzr: ERROR: Path(s) are not versioned: "bar"" ""foo"
| $

Maybe I'm being dense about shells, quoting and IFS but I don't see how
the quoting bzr modified does now would help anyone/where.

> Does 'bzr di `bzr modified`' work? (I'm wondering if it handles quoting
> differently.)

No.

--
James

Revision history for this message
Martin Pool (mbp) wrote :

So should we

1- just consider + as a character that does not need quoting in this way, or
2- do away with quotes around filenames in this form altogether?

It might be nice to change this to ask the ui factory "show a list of filenames" along the lines Robert followed in testr, so this is abstracted out from cmd_modified in particular.

Changed in bzr:
importance: Undecided → Medium
status: Incomplete → Confirmed
tags: added: easy ui
Revision history for this message
Colin Watson (cjwatson) wrote :

I tend to agree that quoting is a bad idea. In the shell, quote removal only applies to quote characters that did *not* result from a previous expansion pass - so a " character resulting from command substitution (whether $() or ``) is a literal ", not any kind of metacharacter.

All this sort of thing makes bzr's output less predictable and so more difficult to process automatically. It would be better to simply say that the filenames are newline-separated, and let callers deal with that. For bonus points, add a --print0 option (or similar - the analogy is to find(1)) that prints items separated by an ASCII NUL byte, so that you can say:

  bzr modified --print0 | xargs -0 bzr di

Revision history for this message
Colin Watson (cjwatson) wrote :

Oh, and as James alluded to, it's possible for the caller to deal with newline-separated input by setting IFS. There's no way that quoting in bzr can help with this though.

Revision history for this message
John A Meinel (jameinel) wrote : Re: [Bug 544297] Re: bzr modified adds unnecessary quotes around filenames

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Colin Watson wrote:
> Oh, and as James alluded to, it's possible for the caller to deal with
> newline-separated input by setting IFS. There's no way that quoting in
> bzr can help with this though.
>

So we do have the 'bzr ls' command, which has the functionality like -0,
etc. My original goal was to have 'bzr ls' handle shell-like
interaction, over having N commands to do so. (bzr ls --modified --null
| xargs -0)

I think the pushback was about whether "bzr ls" was about an exact
state, or could include information about the difference between states.
(--modified can only be determined as a difference between 2 states).

Anyway, my vote would be to get --modified on 'bzr ls' and deprecate the
individual "bzr added", "bzr ignored", "bzr modified" commands...

John
=:->

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkuo1eIACgkQJdeBCYSNAANYzwCgvmHLJ3JLTKQ/4JvXn3FRayCb
d9AAoKdGmIkr5ZNwVRJoFbV3+yPU7GM/
=T2eU
-----END PGP SIGNATURE-----

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

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Colin Watson wrote:
> Oh, and as James alluded to, it's possible for the caller to deal with
> newline-separated input by setting IFS. There's no way that quoting in
> bzr can help with this though.
>

Oh, and why do you need "bzr dif $(bzr modified)" isn't that just "bzr
dif"? I suppose if you were doing "bzr diff $(bzr modified | grep X)"...

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkuo1gUACgkQJdeBCYSNAAONlQCeJbMZpNDvLG4UqV21d4bwKBzl
ALwAoLCphLFb67jCDtrjuHrog0ohTYb6
=UpUO
-----END PGP SIGNATURE-----

Revision history for this message
Colin Watson (cjwatson) wrote : Re: [Bug 544297] Re: bzr modified adds unnecessary quotes around filenames

I see that 'bzr modified' in fact has that --null option too. In that
case I think the answer is straightforward, leaving wider UI concerns
aside: the quoting is worse than useless and should be removed. If you
need machine-readable output, use --null instead.

I can't speak for why James wanted 'bzr ls $(bzr modified)'; I assume
this was a simplification of something more elaborate.

Revision history for this message
Colin Watson (cjwatson) wrote :

I suppose one justification for the quoting would be to aid
copy-and-paste. It does a pretty poor job of that, though - right now,
a file that's called (say) a"b will be rendered as "a"b", which isn't
much good. Perhaps simpler is better.

Revision history for this message
James Troup (elmo) wrote : Re: [Bug 544297] Re: bzr modified adds unnecessary quotes around filenames

John A Meinel <email address hidden> writes:

> Oh, and why do you need "bzr dif $(bzr modified)" isn't that just "bzr
> dif"? I suppose if you were doing "bzr diff $(bzr modified | grep X)"...

'bzr di $(bzr modified)' shows me a diff of (pre-)existing modified
files only.

'bzr di' shows me the diff of all changed files including new(ly added)
files which in some circumstances I'm not interested in seeing.

--
James

Revision history for this message
Ian Clatworthy (ian-clatworthy) wrote :

John A Meinel wrote:

> Anyway, my vote would be to get --modified on 'bzr ls' and deprecate the
> individual "bzr added", "bzr ignored", "bzr modified" commands...

+1

Ian C.

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.