bzr exit code does not depend on status-flags for files in the checkout

Bug #774446 reported by Adam Porter
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Bazaar
Confirmed
Wishlist
Unassigned

Bug Description

I put together a short script to find all bzr repos in my homedir, cd into each one, and if "bzr status" found changed files, drop into a new shell so I can diff, commit, etc. The problem is, "bzr status" returns 0 whether or not it finds changes. So this fails:

if bzr status $dir; then bash; fi

The status command should return 0 if there are changes and 1 if there are no changes.

John A Meinel (jameinel)
Changed in bzr:
importance: Undecided → Wishlist
status: New → Confirmed
tags: added: easy status
Revision history for this message
Dimitri John Ledkov (xnox) wrote :

bzr returns non-zero status when a real error happens. E.g. an exception is 3, a crash is 4.

Above can be triggered on $ bzr status, for example do `bzr status /'

You should be redirecting stdout and checking that instead. There is '-V, --versioned Only show versioned files.' option if that's what you are after.

git status returns 0, if it succeeds. the exit status doesn't depend on the VCS status of the files in the repository. Instead it indicates that the program did run & return correct output and exited successfully.

summary: - bzr status always returns 0 exit code
+ bzr exit code does not depend on status-flags for files in the checkout
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

"bzr diff" returns 1 if there are changes and 0 if there are no changes. It would make sense for "bzr status" to do the same.

Revision history for this message
Martin Pool (mbp) wrote : Re: [Bug 774446] Re: bzr status always returns 0 exit code

Contrary to the git status example, there is for example unix diff
which returns a status code about whether there are any differences or
not.

Returning non-0 for normal conditions can be problematic.

Perhaps we should add an option (I think other programs have --test)
that says you want the return code to vary.

Revision history for this message
haydoni (andyhayden1) wrote :

>"bzr diff" returns 1 if there are changes and 0 if there are no changes.

and this sucks. +1 on a way to turn this off and have the behaviour match git/hg with exit code 0.

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.