Bug 6 - Incorrect use of "break"
Summary: Incorrect use of "break"
Alias: None
Product: abcde
Classification: Unclassified
Component: Ripping (show other bugs)
Version: unspecified
Hardware: All All
: Normal normal
Assignee: Andrew Strong
Depends on:
Reported: 2015-07-29 07:44 BST by Reuben Thomas
Modified: 2015-09-11 01:45 BST (History)
1 user (show)

See Also:

Fix syntax error (1.74 KB, patch)
2015-09-08 13:17 BST, Reuben Thomas

Note You need to log in before you can comment on or make changes to this bug.
Description Reuben Thomas 2015-07-29 07:44:00 BST
What steps will reproduce the problem?
1. Start ripping a CD
2. Eject the disc
3. Get an error "line 4356: break: only meaningful in a `for', `while' or `until' loop"

What is the expected output? What do you see instead?

As far as I can tell, nothing incorrect happens; the ripping aborts as the disc is no longer there. However, the code is certainly not correct. The line in question reads:

	if [ "$GOAHEAD" = "NO" ]; then break; fi

and as far as I can see it's not in a loop.

What version of the product are you using? On what operating system?

This is with current git (as of 29 Dec 2014).

Since the statement is in an if statement, changing it to:

if [ "$GOAHEAD" != "NO" ]; then
... rest of contents of if

would seem correct. The same test is used elsewhere to break out of a loop.

Copied from https://code.google.com/p/abcde/issues/detail?id=122
Comment 1 Andrew Strong 2015-09-08 09:29:13 BST
Have you had a chance to patch all instances of this error and test?
Comment 2 Reuben Thomas 2015-09-08 13:17:09 BST
Created attachment 2 [details]
Fix syntax error
Comment 3 Reuben Thomas 2015-09-08 13:17:32 BST
I think possibly I was unclear: there's only one instance that needs patching, the other use of this construct is correct.

If I patch current git and then put a CD in, start ripping, then eject the CD, abcde simply waits, having printed a correct error message observing that the disc was ejected.

With unpatched abcde it does the same, but first prints the syntax error message. Hence, the fix appears to work.

I attach the patch.
Comment 4 Andrew Strong 2015-09-08 21:34:09 BST
Thanks Reuben! Give me until the weekend when I shall re-test and commit...
Comment 5 Andrew Strong 2015-09-11 01:45:06 BST
Updated in git. Thanks Reuben...