Bug 12

Summary: Inconsistent handling of backslashes in OUTPUTFORMAT
Product: abcde Reporter: campbell
Component: RippingAssignee: Steve McIntyre <steve>
Status: CONFIRMED ---    
Severity: minor CC: andrew.david.strong, campbell, vicacid+abcde
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Attachments: Patch to fix eval echo calls

Description campbell 2015-10-10 04:49:07 BST
In 2.7.1 (have not tested older versions), if I have parens in my OUTPUTFORMAT path, when abcde tries to get album art, I get the error: 

/usr/local/bin/abcde: eval: line 3186: syntax error near unexpected token `('
/usr/local/bin/abcde: eval: line 3186: `echo ${OUTPUT}/${ARTISTFILE} - ${YEAR} - ${ALBUMFILE} (P)/${TRACKNUM} - ${TRACKFILE}'

If I try and escape those parens with backslashes, the error goes away and the album art shows up in the correct folder, but the songs show up in a different folder that has the backslashes themselves in the title. This is because do_getalbumart is parsing OUTPUTFORMAT differently than other places in the script. 

In do_getalbumart, line 3186 looks like:

ALBUMARTDIR="$(eval echo "$OUTPUTFORMAT")"

while a similar line in do_move (line 1565) looks like:

OUTPUTFILE="$(eval echo \""$ONETRACKOUTPUTFORMAT"\")"

I'm not sure which of those styles is supposed to be correct, but it seems like a bug that they're different.
Comment 1 John A. 2016-12-17 17:58:24 GMT
I was just bitten by this issue as well, using 2.7.2. In my case, I use semicolons in the *OUTPUTFORMATs between the artist and album names. I escaped the semicolons but the inconsistent calls to eval echo caused issues where sometimes the semicolon was properly escaped and others where it was treated literally as \; in the dir name.

Hoping to help, I've created a patch that may address this. In it, I've created a new function __format_to_path() that can be used in most if not all places that explicitly called eval echo. I've also made a quick sweep through the code and converted most of the eval echo calls to use __format_to_path() instead.

I've only tested it with my limited setup (works with albumart and move at least) so some additional testing may be required to make sure it doesn't break other things.

Hope this helps!
Comment 2 John A. 2016-12-17 18:00:57 GMT
Created attachment 39 [details]
Patch to fix eval echo calls